From 81fdcb498d258f6fd90289e13be5adb274ea28f2 Mon Sep 17 00:00:00 2001 From: Ashinch Date: Tue, 10 May 2022 22:38:57 +0800 Subject: [PATCH] Add GitHub and F-droid flavors (#59) --- app/build.gradle | 10 ++++++ app/src/main/java/me/ash/reader/App.kt | 4 ++- .../ui/page/settings/tips/TipsAndSupport.kt | 33 +++++++++---------- .../ui/page/settings/tips/UpdateViewModel.kt | 15 +++++---- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7977463..1528f1e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,6 +29,16 @@ android { useSupportLibrary true } } + + flavorDimensions "channel" + productFlavors { + fdroid { + dimension "channel" + } + github { + dimension "channel" + } + } signingConfigs { release { keyAlias keyProps["keyAlias"] diff --git a/app/src/main/java/me/ash/reader/App.kt b/app/src/main/java/me/ash/reader/App.kt index d04971a..def3ca0 100644 --- a/app/src/main/java/me/ash/reader/App.kt +++ b/app/src/main/java/me/ash/reader/App.kt @@ -73,7 +73,9 @@ class App : Application(), Configuration.Provider { applicationScope.launch(dispatcherDefault) { accountInit() workerInit() - checkUpdate() + if (BuildConfig.FLAVOR != "fdroid") { + checkUpdate() + } } } diff --git a/app/src/main/java/me/ash/reader/ui/page/settings/tips/TipsAndSupport.kt b/app/src/main/java/me/ash/reader/ui/page/settings/tips/TipsAndSupport.kt index 66e00de..b9f0b76 100644 --- a/app/src/main/java/me/ash/reader/ui/page/settings/tips/TipsAndSupport.kt +++ b/app/src/main/java/me/ash/reader/ui/page/settings/tips/TipsAndSupport.kt @@ -35,7 +35,6 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.navigation.NavHostController -import kotlinx.coroutines.launch import me.ash.reader.R import me.ash.reader.ui.component.CurlyCornerShape import me.ash.reader.ui.component.FeedbackIconButton @@ -118,26 +117,24 @@ fun TipsAndSupport( onTap = { if (System.currentTimeMillis() - clickTime > 2000) { clickTime = System.currentTimeMillis() - context.showToast(context.getString(R.string.checking_updates)) - scope.launch { - updateViewModel.dispatch( - UpdateViewAction.CheckUpdate( - { - context.dataStore.put( - DataStoreKeys.SkipVersionNumber, - "" + updateViewModel.dispatch( + UpdateViewAction.CheckUpdate( + { + context.showToast(context.getString(R.string.checking_updates)) + context.dataStore.put( + DataStoreKeys.SkipVersionNumber, + "" + ) + }, + { + if (!it) { + context.showToast( + context.getString(R.string.is_latest_version) ) - }, - { - if (!it) { - context.showToast( - context.getString(R.string.is_latest_version) - ) - } } - ) + } ) - } + ) } else { clickTime = System.currentTimeMillis() } diff --git a/app/src/main/java/me/ash/reader/ui/page/settings/tips/UpdateViewModel.kt b/app/src/main/java/me/ash/reader/ui/page/settings/tips/UpdateViewModel.kt index 4d7d75c..03739ca 100644 --- a/app/src/main/java/me/ash/reader/ui/page/settings/tips/UpdateViewModel.kt +++ b/app/src/main/java/me/ash/reader/ui/page/settings/tips/UpdateViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch +import me.ash.reader.BuildConfig import me.ash.reader.data.repository.AppRepository import me.ash.reader.data.source.Download import javax.inject.Inject @@ -32,12 +33,14 @@ class UpdateViewModel @Inject constructor( preProcessor: suspend () -> Unit = {}, postProcessor: suspend (Boolean) -> Unit = {} ) { - viewModelScope.launch { - preProcessor() - appRepository.checkUpdate().let { - it?.let { - changeUpdateDialogVisible(it) - postProcessor(it) + if (BuildConfig.FLAVOR != "fdroid") { + viewModelScope.launch { + preProcessor() + appRepository.checkUpdate().let { + it?.let { + changeUpdateDialogVisible(it) + postProcessor(it) + } } } }