Skip to content

Commit

Permalink
Merge pull request #33 from pakka-papad/dev
Browse files Browse the repository at this point in the history
Update to 1.2.5
  • Loading branch information
pakka-papad authored Jan 26, 2025
2 parents 3dfbd24 + 13bdfd8 commit 3111a3b
Show file tree
Hide file tree
Showing 12 changed files with 448 additions and 223 deletions.
3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ android {

dependencies {
implementation(project(":m3utils"))
implementation(Libraries.kotlinxCollectionsImmutable)
implementation(Libraries.androidxCore)

implementation(Libraries.androidxLifecycle)
Expand Down Expand Up @@ -169,6 +170,7 @@ dependencies {

implementation(platform(Libraries.firebaseBom))
implementation(Libraries.firebaseCrashlytics)
implementation(Libraries.appUpdate)

// implementation(Libraries.exoPlayer)
implementation(Libraries.media3ExoPlayer)
Expand Down
27 changes: 27 additions & 0 deletions app/src/main/java/com/github/pakka_papad/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import com.github.pakka_papad.data.ZenCrashReporter
import com.github.pakka_papad.data.ZenPreferenceProvider
import com.github.pakka_papad.databinding.ActivityMainBinding
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateOptions
import com.google.android.play.core.install.model.AppUpdateType
import com.google.android.play.core.install.model.UpdateAvailability
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

Expand All @@ -17,6 +22,10 @@ class MainActivity : AppCompatActivity() {

@Inject lateinit var preferencesProvider: ZenPreferenceProvider

@Inject lateinit var appUpdateManager: AppUpdateManager

@Inject lateinit var crashReporter: ZenCrashReporter

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen().apply {
Expand All @@ -30,4 +39,22 @@ class MainActivity : AppCompatActivity() {
WindowCompat.setDecorFitsSystemWindows(window,false)
window.statusBarColor = Color.TRANSPARENT
}

override fun onResume() {
super.onResume()

try {
appUpdateManager.appUpdateInfo.addOnSuccessListener {
if (it.updateAvailability() == UpdateAvailability.DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS){
appUpdateManager.startUpdateFlow(
it,
this,
AppUpdateOptions.defaultOptions(AppUpdateType.IMMEDIATE)
)
}
}
} catch (e: Exception) {
crashReporter.logException(e)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.*
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
Expand All @@ -18,8 +23,6 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.core.graphics.drawable.toBitmap
import androidx.palette.graphics.Palette
import coil.compose.AsyncImage
import com.github.pakka_papad.components.SongCardV1
import com.github.pakka_papad.components.more_options.SongOptions
Expand Down Expand Up @@ -85,25 +88,11 @@ fun CollectionImage(
.height(240.dp),
contentAlignment = Alignment.BottomCenter
) {
val surface = MaterialTheme.colorScheme.surface
val onSurface = MaterialTheme.colorScheme.onSurface
var textColor by remember { mutableStateOf(onSurface) }
var backgroundColor by remember { mutableStateOf(surface) }
AsyncImage(
model = imageUri,
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize(),
onSuccess = { result ->
Palette.Builder(result.result.drawable.toBitmap()).generate { palette ->
palette?.let {
it.mutedSwatch?.let { vbs ->
backgroundColor = Color(vbs.rgb)
textColor = Color(vbs.titleTextColor).copy(alpha = 1f)
}
}
}
}
)
Text(
text = title ?: "",
Expand All @@ -112,12 +101,12 @@ fun CollectionImage(
.fillMaxWidth()
.background(
Brush.verticalGradient(
listOf(Color.Transparent, backgroundColor)
listOf(Color.Transparent, MaterialTheme.colorScheme.surface)
)
)
.padding(10.dp),
maxLines = 2,
color = textColor,
color = MaterialTheme.colorScheme.onSurface,
fontWeight = FontWeight.ExtraBold,
overflow = TextOverflow.Ellipsis
)
Expand Down
37 changes: 35 additions & 2 deletions app/src/main/java/com/github/pakka_papad/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,37 @@ import androidx.media3.extractor.DefaultExtractorsFactory
import androidx.media3.extractor.mp3.Mp3Extractor
import androidx.room.Room
import com.github.pakka_papad.Constants
import com.github.pakka_papad.data.*
import com.github.pakka_papad.data.AppDatabase
import com.github.pakka_papad.data.QueueState
import com.github.pakka_papad.data.QueueStateSerializer
import com.github.pakka_papad.data.UserPreferences
import com.github.pakka_papad.data.UserPreferencesSerializer
import com.github.pakka_papad.data.ZenCrashReporter
import com.github.pakka_papad.data.ZenPreferenceProvider
import com.github.pakka_papad.data.music.SongExtractor
import com.github.pakka_papad.data.services.*
import com.github.pakka_papad.data.services.AnalyticsService
import com.github.pakka_papad.data.services.AnalyticsServiceImpl
import com.github.pakka_papad.data.services.BlacklistService
import com.github.pakka_papad.data.services.BlacklistServiceImpl
import com.github.pakka_papad.data.services.PlayerService
import com.github.pakka_papad.data.services.PlayerServiceImpl
import com.github.pakka_papad.data.services.PlaylistService
import com.github.pakka_papad.data.services.PlaylistServiceImpl
import com.github.pakka_papad.data.services.QueueService
import com.github.pakka_papad.data.services.QueueServiceImpl
import com.github.pakka_papad.data.services.SearchService
import com.github.pakka_papad.data.services.SearchServiceImpl
import com.github.pakka_papad.data.services.SleepTimerService
import com.github.pakka_papad.data.services.SleepTimerServiceImpl
import com.github.pakka_papad.data.services.SongService
import com.github.pakka_papad.data.services.SongServiceImpl
import com.github.pakka_papad.data.services.ThumbnailService
import com.github.pakka_papad.data.services.ThumbnailServiceImpl
import com.github.pakka_papad.player.ZenBroadcastReceiver
import com.github.pakka_papad.util.MessageStore
import com.github.pakka_papad.util.MessageStoreImpl
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
import com.google.firebase.crashlytics.FirebaseCrashlytics
import dagger.Module
import dagger.Provides
Expand Down Expand Up @@ -283,4 +308,12 @@ object AppModule {
thumbnailDao = db.thumbnailDao(),
)
}

@Singleton
@Provides
fun providesAppUpdateManager(
@ApplicationContext context: Context,
): AppUpdateManager {
return AppUpdateManagerFactory.create(context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.ComposeView
Expand All @@ -21,8 +22,12 @@ import androidx.navigation.fragment.findNavController
import com.github.pakka_papad.R
import com.github.pakka_papad.components.Snackbar
import com.github.pakka_papad.components.TopBarWithBackArrow
import com.github.pakka_papad.data.ZenCrashReporter
import com.github.pakka_papad.data.ZenPreferenceProvider
import com.github.pakka_papad.ui.theme.ZenTheme
import com.google.android.play.core.appupdate.AppUpdateManager
import com.google.android.play.core.appupdate.AppUpdateOptions
import com.google.android.play.core.install.model.AppUpdateType
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

Expand All @@ -33,8 +38,11 @@ class SettingsFragment : Fragment() {

private lateinit var navController: NavController

@Inject
lateinit var preferenceProvider: ZenPreferenceProvider
@Inject lateinit var preferenceProvider: ZenPreferenceProvider

@Inject lateinit var appUpdateManager: AppUpdateManager

@Inject lateinit var crashReporter: ZenCrashReporter

override fun onCreateView(
inflater: LayoutInflater,
Expand All @@ -51,6 +59,10 @@ class SettingsFragment : Fragment() {

val tabsSelection by viewModel.tabsSelection.collectAsStateWithLifecycle()

val isAppUpdateAvailable by remember { derivedStateOf {
viewModel.appUpdateInfo.value != null
} }

val restoreClicked = remember{ {
if (navController.currentDestination?.id == R.id.settingsFragment){
navController.navigate(R.id.action_settingsFragment_to_restoreFragment)
Expand Down Expand Up @@ -87,6 +99,8 @@ class SettingsFragment : Fragment() {
content = { paddingValues ->
SettingsList(
paddingValues = paddingValues,
isAppUpdateAvailable = isAppUpdateAvailable,
onAppUpdateClicked = ::onAppUpdateClicked,
themePreference = themePreference,
onThemePreferenceChanged = preferenceProvider::updateTheme,
scanStatus = scanStatus,
Expand Down Expand Up @@ -115,4 +129,20 @@ class SettingsFragment : Fragment() {
}
}
}

private fun onAppUpdateClicked() {
val appUpdateInfo = viewModel.appUpdateInfo.value
viewModel.consumeAppUpdateInfo()
try {
appUpdateInfo?.let {
appUpdateManager.startUpdateFlow(
it,
requireActivity(),
AppUpdateOptions.defaultOptions(AppUpdateType.IMMEDIATE)
)
}
} catch (e: Exception) {
crashReporter.logException(e)
}
}
}
Loading

0 comments on commit 3111a3b

Please sign in to comment.