Module fixes

Removed Firebase
F-Droid can detects updates again
This commit is contained in:
Sad Ellie 2023-01-18 20:34:54 +04:00
parent f46fef9644
commit c7c9c557bb
18 changed files with 7 additions and 249 deletions

View File

@ -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"

View File

@ -10,12 +10,6 @@
android:supportsRtl="true"
android:theme="@style/Theme.Unitto">
<meta-data
android:name="firebase_analytics_collection_enabled"
android:value="false" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="${crashlytics_enabled}" />
<activity
android:name=".MainActivity"
android:exported="true">

View File

@ -34,12 +34,6 @@ internal fun Project.configureKotlinAndroid(
minSdk = 21
}
buildTypes {
create("releaseNoCrashlytics") {
initWith(getByName("release"))
}
}
flavorDimensions += "mainFlavorDimension"
productFlavors {
create("playStore") {}

View File

@ -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

View File

@ -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)
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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) {}
}

View File

@ -725,7 +725,5 @@
<string name="enable_unit_group_description">Einheitengruppe aktivieren</string>
<string name="reorder_unit_group_description">Einheitengruppe umordnen</string>
<string name="disable_unit_group_description">Einheitengruppe deaktivieren</string>
<string name="send_usage_statistics">Nutzungsstatistiken senden</string>
<string name="send_usage_statistics_support">Allen Daten sind anonymisiert und verschlüsselt</string>
<string name="app_version_name_setting">Versionsname</string>
</resources>

View File

@ -726,8 +726,6 @@
<string name="enable_unit_group_description">Enable unit group</string>
<string name="reorder_unit_group_description">Reorder unit group</string>
<string name="disable_unit_group_description">Disable unit group</string>
<string name="send_usage_statistics">Send usage statistics</string>
<string name="send_usage_statistics_support">All data is anonymous and encrypted</string>
<string name="app_version_name_setting">Version name</string>
<string name="about_unitto">About Unitto</string>
<string name="about_unitto_support">Learn about the app</string>

View File

@ -714,8 +714,6 @@
<string name="enable_unit_group_description">Activer le groupe d\'unités</string>
<string name="reorder_unit_group_description">Réorganiser le groupe d\'unités</string>
<string name="disable_unit_group_description">Désactiver le groupe d\'unités</string>
<string name="send_usage_statistics">Envoyer des statistiques d\'utilisation</string>
<string name="send_usage_statistics_support">Toutes les données sont anonymes et chiffrées</string>
<string name="app_version_name_setting">Nom de la version</string>
<string name="about_unitto">À propos d\'Unitto</string>
<string name="about_unitto_support">En savoir plus sur l\'application</string>

View File

@ -726,8 +726,7 @@
<string name="enable_unit_group_description">Включить группу величин</string>
<string name="reorder_unit_group_description">Переместить группу величин</string>
<string name="disable_unit_group_description">Отключить группу величин</string>
<string name="send_usage_statistics">Отправлять статистику использования</string>
<string name="send_usage_statistics_support">Все данные анонимны и зашифрованы</string>
<string name="app_version_name_setting">Название версии</string>
<string name="about_unitto">О Unitto</string>
<string name="about_unitto_support">Узнайте больше о приложении</string>

View File

@ -1079,8 +1079,6 @@
<string name="reorder_unit_group_description">Reorder unit group</string>
<string name="disable_unit_group_description">Disable unit group</string>
<string name="send_usage_statistics">Send usage statistics</string>
<string name="send_usage_statistics_support">All data is anonymous and encrypted</string>
<string name="app_version_name_setting">Version name</string>
<string name="about_unitto">About Unitto</string>
<string name="about_unitto_support">Learn about the app</string>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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 <https://www.gnu.org/licenses/>.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
</manifest>

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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)
}

View File

@ -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<UnitGroup> = ALL_UNIT_GROUPS
)
/**
* Repository that works with DataStore
*/
class UserPreferencesRepository @Inject constructor(private val dataStore: DataStore<Preferences>) {
class
UserPreferencesRepository @Inject constructor(private val dataStore: DataStore<Preferences>) {
/**
* 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<UnitGroup> =
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.

View File

@ -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 {
/**

View File

@ -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 {

View File

@ -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]

View File

@ -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" }