From c7c9c557bbae81f8d274c1cea074bf0180e9e81a Mon Sep 17 00:00:00 2001 From: Sad Ellie Date: Wed, 18 Jan 2023 20:34:54 +0400 Subject: [PATCH] Module fixes Removed Firebase F-Droid can detects updates again --- app/build.gradle.kts | 11 +---- app/src/main/AndroidManifest.xml | 6 --- .../sadellie/unitto/ConfigureKotlinAndroid.kt | 6 --- build.gradle.kts | 12 ------ core/base/build.gradle.kts | 31 -------------- .../unitto/core/base/FirebaseHelper.kt | 40 ------------------ core/base/src/main/res/values-de/strings.xml | 2 - .../src/main/res/values-en-rGB/strings.xml | 2 - core/base/src/main/res/values-fr/strings.xml | 2 - core/base/src/main/res/values-ru/strings.xml | 3 +- core/base/src/main/res/values/strings.xml | 2 - core/base/src/playStore/AndroidManifest.xml | 24 ----------- .../unitto/core/base/FirebaseHelper.kt | 42 ------------------- .../data/preferences/UserPreferences.kt | 20 +-------- .../unitto/feature/converter/MainViewModel.kt | 10 +---- .../unitto/feature/settings/SettingsScreen.kt | 19 --------- .../feature/settings/SettingsViewModel.kt | 15 +------ gradle/libs.versions.toml | 9 ---- 18 files changed, 7 insertions(+), 249 deletions(-) delete mode 100644 core/base/src/fdroid/java/com/sadellie/unitto/core/base/FirebaseHelper.kt delete mode 100644 core/base/src/playStore/AndroidManifest.xml delete mode 100644 core/base/src/playStore/java/com/sadellie/unitto/core/base/FirebaseHelper.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 580ffe51..8c5012a2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -32,8 +32,8 @@ android { applicationId = "com.sadellie.unitto" minSdk = 21 targetSdk = 33 - versionCode = libs.versions.appCode.get().toInt() - versionName = libs.versions.appName.get() + versionCode = 14 + versionName = "Glaucous" } buildTypes { @@ -42,7 +42,6 @@ android { isDebuggable = true isShrinkResources = false isMinifyEnabled = false - manifestPlaceholders["crashlytics_enabled"] = false } // Release with analytics and minified, not debuggable @@ -51,17 +50,11 @@ android { isShrinkResources = true isDebuggable = false isMinifyEnabled = true - manifestPlaceholders["crashlytics_enabled"] = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } - - create("releaseNoCrashlytics") { - initWith(getByName("release")) - manifestPlaceholders["crashlytics_enabled"] = false - } } flavorDimensions += "mainFlavorDimension" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d7512aae..75a80508 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,12 +10,6 @@ android:supportsRtl="true" android:theme="@style/Theme.Unitto"> - - diff --git a/build-logic/convention/src/main/java/com/sadellie/unitto/ConfigureKotlinAndroid.kt b/build-logic/convention/src/main/java/com/sadellie/unitto/ConfigureKotlinAndroid.kt index 65d3f9e9..9142fd0b 100644 --- a/build-logic/convention/src/main/java/com/sadellie/unitto/ConfigureKotlinAndroid.kt +++ b/build-logic/convention/src/main/java/com/sadellie/unitto/ConfigureKotlinAndroid.kt @@ -34,12 +34,6 @@ internal fun Project.configureKotlinAndroid( minSdk = 21 } - buildTypes { - create("releaseNoCrashlytics") { - initWith(getByName("release")) - } - } - flavorDimensions += "mainFlavorDimension" productFlavors { create("playStore") {} diff --git a/build.gradle.kts b/build.gradle.kts index c7334f4b..b619cd60 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,15 +1,3 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - classpath(libs.com.google.gms) - classpath(libs.com.google.firebase) - } -} - @Suppress("DSL_SCOPE_VIOLATION") plugins { alias(libs.plugins.android.gradlePlugin) apply false diff --git a/core/base/build.gradle.kts b/core/base/build.gradle.kts index 139db75a..eac549db 100644 --- a/core/base/build.gradle.kts +++ b/core/base/build.gradle.kts @@ -20,21 +20,12 @@ plugins { id("unitto.library") } -if (!gradle.startParameter.taskRequests.toString().contains("Fdroid")) { - // Google Services and Firebase Crashlytics are for all flavors except fdroid - apply(plugin="com.google.gms.google-services") - apply(plugin="com.google.firebase.crashlytics") -} else { - println("Didn't add Google Services since F-Droid flavor was chosen.") -} - android { namespace = "com.sadellie.unitto.core.base" defaultConfig { buildConfigField("String", "APP_NAME", """"${libs.versions.appName.get()}"""") buildConfigField("String", "APP_CODE", """"${libs.versions.appCode.get()}"""") - buildConfigField("Boolean", "ANALYTICS", "true") } productFlavors { @@ -61,15 +52,6 @@ android { "STORE_LINK", "\"https://github.com/sadellie/unitto\"" ) - buildConfigField("Boolean", "ANALYTICS", "false") - } - } - - sourceSets { - // Making specified flavors use same source as "playStore" flavor - listOf("appGallery", "ruPlayStore").forEach { - getByName(it).java.srcDirs("src/playStore/java") - getByName(it).manifest.srcFile("src/playStore") } } @@ -81,16 +63,3 @@ android { this.warning.add("MissingTranslation") } } - -configurations { - val playStoreImplementation = getByName("playStoreImplementation") - listOf("appGallery", "ruPlayStore").forEach { - getByName("${it}Implementation").extendsFrom(playStoreImplementation) - } -} - -dependencies { - "playStoreImplementation"(platform(libs.com.google.firebase.bom)) - "playStoreImplementation"(libs.com.google.firebase.analytics) - "playStoreImplementation"(libs.com.google.firebase.crashlytics) -} \ No newline at end of file diff --git a/core/base/src/fdroid/java/com/sadellie/unitto/core/base/FirebaseHelper.kt b/core/base/src/fdroid/java/com/sadellie/unitto/core/base/FirebaseHelper.kt deleted file mode 100644 index 0321a2d3..00000000 --- a/core/base/src/fdroid/java/com/sadellie/unitto/core/base/FirebaseHelper.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.core.base - -import android.content.Context - -/** - * This class is NOT actually using firebase. Used for flavors WITHOUT Firebase dependency. - */ -@Suppress("EmptyMethod") -class FirebaseHelper { - - /** - * Method that doesn't actually enable/disable analytics. - */ - @Suppress("UNUSED_PARAMETER") - fun setAnalyticsCollectionEnabled(context: Context, enable: Boolean) {} - - /** - * Methods that doesn't actually send exceptions. - */ - @Suppress("UNUSED_PARAMETER") - fun recordException(e: Exception) {} -} \ No newline at end of file diff --git a/core/base/src/main/res/values-de/strings.xml b/core/base/src/main/res/values-de/strings.xml index 6dd4a544..401f5d77 100644 --- a/core/base/src/main/res/values-de/strings.xml +++ b/core/base/src/main/res/values-de/strings.xml @@ -725,7 +725,5 @@ Einheitengruppe aktivieren Einheitengruppe umordnen Einheitengruppe deaktivieren - Nutzungsstatistiken senden - Allen Daten sind anonymisiert und verschlüsselt Versionsname \ No newline at end of file diff --git a/core/base/src/main/res/values-en-rGB/strings.xml b/core/base/src/main/res/values-en-rGB/strings.xml index 7b333023..92979844 100644 --- a/core/base/src/main/res/values-en-rGB/strings.xml +++ b/core/base/src/main/res/values-en-rGB/strings.xml @@ -726,8 +726,6 @@ Enable unit group Reorder unit group Disable unit group - Send usage statistics - All data is anonymous and encrypted Version name About Unitto Learn about the app diff --git a/core/base/src/main/res/values-fr/strings.xml b/core/base/src/main/res/values-fr/strings.xml index 6c1f96e7..3b030f1f 100644 --- a/core/base/src/main/res/values-fr/strings.xml +++ b/core/base/src/main/res/values-fr/strings.xml @@ -714,8 +714,6 @@ Activer le groupe d\'unités Réorganiser le groupe d\'unités Désactiver le groupe d\'unités - Envoyer des statistiques d\'utilisation - Toutes les données sont anonymes et chiffrées Nom de la version À propos d\'Unitto En savoir plus sur l\'application diff --git a/core/base/src/main/res/values-ru/strings.xml b/core/base/src/main/res/values-ru/strings.xml index 795d41ec..421a11c8 100644 --- a/core/base/src/main/res/values-ru/strings.xml +++ b/core/base/src/main/res/values-ru/strings.xml @@ -726,8 +726,7 @@ Включить группу величин Переместить группу величин Отключить группу величин - Отправлять статистику использования - Все данные анонимны и зашифрованы + Название версии О Unitto Узнайте больше о приложении diff --git a/core/base/src/main/res/values/strings.xml b/core/base/src/main/res/values/strings.xml index f44dd83a..22662322 100644 --- a/core/base/src/main/res/values/strings.xml +++ b/core/base/src/main/res/values/strings.xml @@ -1079,8 +1079,6 @@ Reorder unit group Disable unit group - Send usage statistics - All data is anonymous and encrypted Version name About Unitto Learn about the app diff --git a/core/base/src/playStore/AndroidManifest.xml b/core/base/src/playStore/AndroidManifest.xml deleted file mode 100644 index e89b864d..00000000 --- a/core/base/src/playStore/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/core/base/src/playStore/java/com/sadellie/unitto/core/base/FirebaseHelper.kt b/core/base/src/playStore/java/com/sadellie/unitto/core/base/FirebaseHelper.kt deleted file mode 100644 index 58836900..00000000 --- a/core/base/src/playStore/java/com/sadellie/unitto/core/base/FirebaseHelper.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Unitto is a unit converter for Android - * Copyright (c) 2023 Elshan Agaev - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.sadellie.unitto.core.base - -import android.content.Context -import com.google.firebase.analytics.FirebaseAnalytics -import com.google.firebase.crashlytics.FirebaseCrashlytics - -/** - * This class is actually using firebase. Used for flavors with Firebase dependency. - */ -class FirebaseHelper { - - /** - * Wrapper for FirebaseAnalytics method with the same name. - */ - fun setAnalyticsCollectionEnabled( - context: Context, - enable: Boolean - ) = FirebaseAnalytics.getInstance(context).setAnalyticsCollectionEnabled(enable) - - /** - * Wrapper for FirebaseCrashlytics method with the same name. - */ - fun recordException(e: Exception) = FirebaseCrashlytics.getInstance().recordException(e) -} \ No newline at end of file diff --git a/data/src/main/java/com/sadellie/unitto/data/preferences/UserPreferences.kt b/data/src/main/java/com/sadellie/unitto/data/preferences/UserPreferences.kt index 9672b0c1..adcf137f 100644 --- a/data/src/main/java/com/sadellie/unitto/data/preferences/UserPreferences.kt +++ b/data/src/main/java/com/sadellie/unitto/data/preferences/UserPreferences.kt @@ -50,7 +50,6 @@ import javax.inject.Inject * @property outputFormat Current [OutputFormat] that is applied to converted value (not input) * @property latestLeftSideUnit Latest [AbstractUnit] that was on the left side * @property latestRightSideUnit Latest [AbstractUnit] that was on the right side - * @property enableAnalytics Whether or not user wants to share application usage data * @property shownUnitGroups [UnitGroup]s that user wants to see. Excludes other [UnitGroup]s */ data class UserPreferences( @@ -62,14 +61,14 @@ data class UserPreferences( val outputFormat: Int = OutputFormat.PLAIN, val latestLeftSideUnit: String = MyUnitIDS.kilometer, val latestRightSideUnit: String = MyUnitIDS.mile, - val enableAnalytics: Boolean = true, val shownUnitGroups: List = ALL_UNIT_GROUPS ) /** * Repository that works with DataStore */ -class UserPreferencesRepository @Inject constructor(private val dataStore: DataStore) { +class +UserPreferencesRepository @Inject constructor(private val dataStore: DataStore) { /** * Keys for DataStore */ @@ -82,7 +81,6 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS val OUTPUT_FORMAT = intPreferencesKey("OUTPUT_FORMAT_PREF_KEY") val LATEST_LEFT_SIDE = stringPreferencesKey("LATEST_LEFT_SIDE_PREF_KEY") val LATEST_RIGHT_SIDE = stringPreferencesKey("LATEST_RIGHT_SIDE_PREF_KEY") - val ENABLE_ANALYTICS = booleanPreferencesKey("ENABLE_ANALYTICS_PREF_KEY") val SHOWN_UNIT_GROUPS = stringPreferencesKey("SHOWN_UNIT_GROUPS_PREF_KEY") } @@ -112,8 +110,6 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS preferences[PrefsKeys.LATEST_LEFT_SIDE] ?: MyUnitIDS.kilometer val latestRightSideUnit: String = preferences[PrefsKeys.LATEST_RIGHT_SIDE] ?: MyUnitIDS.mile - val enableAnalytics: Boolean = - preferences[PrefsKeys.ENABLE_ANALYTICS] ?: true val shownUnitGroups: List = preferences[PrefsKeys.SHOWN_UNIT_GROUPS]?.let { list -> // Everything is in hidden (nothing in shown) @@ -137,7 +133,6 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS outputFormat = outputFormat, latestLeftSideUnit = latestLeftSideUnit, latestRightSideUnit = latestRightSideUnit, - enableAnalytics = enableAnalytics, shownUnitGroups = shownUnitGroups ) } @@ -175,17 +170,6 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS } } - /** - * Update analytics preference in DataStore - * - * @param enableAnalytics True if user wants to share data, False if not - */ - suspend fun updateEnableAnalytics(enableAnalytics: Boolean) { - dataStore.edit { preferences -> - preferences[PrefsKeys.ENABLE_ANALYTICS] = enableAnalytics - } - } - /** * Update latest used pair of [AbstractUnit] in DataStore. Need it so when user restarts the app, * this pair will be already set. diff --git a/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt b/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt index 649a387f..5224e9ff 100644 --- a/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt +++ b/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt @@ -23,7 +23,6 @@ import androidx.lifecycle.viewModelScope import com.github.keelar.exprk.ExpressionException import com.github.keelar.exprk.Expressions import com.sadellie.unitto.core.base.DIGITS -import com.sadellie.unitto.core.base.FirebaseHelper import com.sadellie.unitto.core.base.KEY_0 import com.sadellie.unitto.core.base.KEY_1 import com.sadellie.unitto.core.base.KEY_2 @@ -529,14 +528,7 @@ class MainViewModel @Inject constructor( CurrencyApi.retrofitService.getCurrencyPairs(unitFrom.unitId) allUnitsRepository.updateBasicUnitsForCurrencies(pairs.currency) } catch (e: Exception) { - when (e) { - // 403, Network and Adapter exceptions can be ignored - is retrofit2.HttpException, is java.net.UnknownHostException, is com.squareup.moshi.JsonDataException -> {} - else -> { - // Unexpected exception, should report it - FirebaseHelper().recordException(e) - } - } + // Dangerous and stupid, but who cares _showError.update { true } } finally { /** diff --git a/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsScreen.kt b/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsScreen.kt index 00eee5dc..a25eb77f 100644 --- a/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsScreen.kt +++ b/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsScreen.kt @@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Info -import androidx.compose.material.icons.filled.Insights import androidx.compose.material.icons.filled.Palette import androidx.compose.material.icons.filled.RateReview import androidx.compose.material.icons.filled.Rule @@ -47,7 +46,6 @@ import com.sadellie.unitto.core.base.PRECISIONS import com.sadellie.unitto.core.base.SEPARATORS import com.sadellie.unitto.core.ui.common.Header import com.sadellie.unitto.core.ui.common.UnittoLargeTopAppBar -import com.sadellie.unitto.core.ui.common.UnittoListItem import com.sadellie.unitto.core.ui.openLink import com.sadellie.unitto.feature.R import com.sadellie.unitto.feature.settings.components.AlertDialogWithList @@ -146,23 +144,6 @@ internal fun SettingsScreen( // ADDITIONAL GROUP item { Header(stringResource(R.string.additional_settings_group)) } - // ANALYTICS - if (BuildConfig.ANALYTICS) { - item { - UnittoListItem( - leadingContent = { - Icon( - Icons.Default.Insights, - stringResource(R.string.send_usage_statistics), - ) - }, - label = stringResource(R.string.send_usage_statistics), - supportText = stringResource(R.string.send_usage_statistics_support), - switchState = userPrefs.value.enableAnalytics - ) { viewModel.updateEnableAnalytics(it) } - } - } - // RATE THIS APP if (BuildConfig.STORE_LINK.isNotEmpty()) { item { diff --git a/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsViewModel.kt b/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsViewModel.kt index d99e0c6e..09d0a110 100644 --- a/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsViewModel.kt +++ b/feature/settings/src/main/java/com/sadellie/unitto/feature/settings/SettingsViewModel.kt @@ -18,15 +18,13 @@ package com.sadellie.unitto.feature.settings -import android.app.Application import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.sadellie.unitto.core.base.FirebaseHelper +import com.sadellie.unitto.core.ui.Formatter import com.sadellie.unitto.data.preferences.UserPreferences import com.sadellie.unitto.data.preferences.UserPreferencesRepository import com.sadellie.unitto.data.units.UnitGroup import com.sadellie.unitto.data.units.UnitGroupsRepository -import com.sadellie.unitto.core.ui.Formatter import dagger.hilt.android.lifecycle.HiltViewModel import io.github.sadellie.themmo.ThemingMode import kotlinx.coroutines.flow.SharingStarted @@ -41,7 +39,6 @@ import javax.inject.Inject class SettingsViewModel @Inject constructor( private val userPrefsRepository: UserPreferencesRepository, private val unitGroupsRepository: UnitGroupsRepository, - private val application: Application, ) : ViewModel() { var userPrefs = userPrefsRepository.userPreferencesFlow .onEach { Formatter.setSeparator(it.separator) } @@ -103,16 +100,6 @@ class SettingsViewModel @Inject constructor( } } - /** - * See [UserPreferencesRepository.updateEnableAnalytics] - */ - fun updateEnableAnalytics(enableAnalytics: Boolean) { - viewModelScope.launch { - userPrefsRepository.updateEnableAnalytics(enableAnalytics) - FirebaseHelper().setAnalyticsCollectionEnabled(application, enableAnalytics) - } - } - /** * See [UnitGroupsRepository.markUnitGroupAsHidden] and * [UserPreferencesRepository.updateShownUnitGroups] diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ba6a13f1..1a173a15 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,12 +25,8 @@ comSquareupRetrofit2 = "2.9.0" comGithubSadellieThemmo = "cf6be7e592" orgBurnoutcrewComposereorderable = "0.9.6" comGithubSadellieExprk = "e55cba8f41" -firebaseBom = "31.1.0" androidGradlePlugin = "7.3.1" kotlin = "1.7.21" -comGoogleGms = "4.3.14" -comGoogleFirebase = "2.9.2" - [libraries] androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } @@ -62,16 +58,11 @@ com-squareup-retrofit2 = { group = "com.squareup.retrofit2", name = "converter-m com-github-sadellie-themmo = { group = "com.github.sadellie", name = "themmo", version.ref = "comGithubSadellieThemmo" } org-burnoutcrew-composereorderable = { group = "org.burnoutcrew.composereorderable", name = "reorderable", version.ref = "orgBurnoutcrewComposereorderable" } com-github-sadellie-exprk = { group = "com.github.sadellie", name = "ExprK", version.ref = "comGithubSadellieExprk" } -com-google-firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" } -com-google-firebase-analytics = { group = "com.google.firebase", name = "firebase-analytics-ktx" } -com-google-firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics-ktx" } # classpath android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } com-google-dagger = { group = "com.google.dagger", name = "hilt-android-gradle-plugin", version.ref = "comGoogleDagger" } -com-google-gms = { group = "com.google.gms", name = "google-services", version.ref = "comGoogleGms" } -com-google-firebase = { group = "com.google.firebase", name = "firebase-crashlytics-gradle", version.ref = "comGoogleFirebase" } [plugins] android-gradlePlugin = { id = "com.android.application", version.ref = "androidGradlePlugin" }