mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Module fixes
Removed Firebase F-Droid can detects updates again
This commit is contained in:
parent
f46fef9644
commit
c7c9c557bb
@ -32,8 +32,8 @@ android {
|
|||||||
applicationId = "com.sadellie.unitto"
|
applicationId = "com.sadellie.unitto"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 33
|
targetSdk = 33
|
||||||
versionCode = libs.versions.appCode.get().toInt()
|
versionCode = 14
|
||||||
versionName = libs.versions.appName.get()
|
versionName = "Glaucous"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@ -42,7 +42,6 @@ android {
|
|||||||
isDebuggable = true
|
isDebuggable = true
|
||||||
isShrinkResources = false
|
isShrinkResources = false
|
||||||
isMinifyEnabled = false
|
isMinifyEnabled = false
|
||||||
manifestPlaceholders["crashlytics_enabled"] = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release with analytics and minified, not debuggable
|
// Release with analytics and minified, not debuggable
|
||||||
@ -51,17 +50,11 @@ android {
|
|||||||
isShrinkResources = true
|
isShrinkResources = true
|
||||||
isDebuggable = false
|
isDebuggable = false
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
manifestPlaceholders["crashlytics_enabled"] = true
|
|
||||||
proguardFiles(
|
proguardFiles(
|
||||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
"proguard-rules.pro"
|
"proguard-rules.pro"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
create("releaseNoCrashlytics") {
|
|
||||||
initWith(getByName("release"))
|
|
||||||
manifestPlaceholders["crashlytics_enabled"] = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flavorDimensions += "mainFlavorDimension"
|
flavorDimensions += "mainFlavorDimension"
|
||||||
|
@ -10,12 +10,6 @@
|
|||||||
|
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Unitto">
|
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
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
@ -34,12 +34,6 @@ internal fun Project.configureKotlinAndroid(
|
|||||||
minSdk = 21
|
minSdk = 21
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
create("releaseNoCrashlytics") {
|
|
||||||
initWith(getByName("release"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
flavorDimensions += "mainFlavorDimension"
|
flavorDimensions += "mainFlavorDimension"
|
||||||
productFlavors {
|
productFlavors {
|
||||||
create("playStore") {}
|
create("playStore") {}
|
||||||
|
@ -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")
|
@Suppress("DSL_SCOPE_VIOLATION")
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.android.gradlePlugin) apply false
|
alias(libs.plugins.android.gradlePlugin) apply false
|
||||||
|
@ -20,21 +20,12 @@ plugins {
|
|||||||
id("unitto.library")
|
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 {
|
android {
|
||||||
namespace = "com.sadellie.unitto.core.base"
|
namespace = "com.sadellie.unitto.core.base"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
buildConfigField("String", "APP_NAME", """"${libs.versions.appName.get()}"""")
|
buildConfigField("String", "APP_NAME", """"${libs.versions.appName.get()}"""")
|
||||||
buildConfigField("String", "APP_CODE", """"${libs.versions.appCode.get()}"""")
|
buildConfigField("String", "APP_CODE", """"${libs.versions.appCode.get()}"""")
|
||||||
buildConfigField("Boolean", "ANALYTICS", "true")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
productFlavors {
|
productFlavors {
|
||||||
@ -61,15 +52,6 @@ android {
|
|||||||
"STORE_LINK",
|
"STORE_LINK",
|
||||||
"\"https://github.com/sadellie/unitto\""
|
"\"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")
|
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)
|
|
||||||
}
|
|
@ -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) {}
|
|
||||||
}
|
|
@ -725,7 +725,5 @@
|
|||||||
<string name="enable_unit_group_description">Einheitengruppe aktivieren</string>
|
<string name="enable_unit_group_description">Einheitengruppe aktivieren</string>
|
||||||
<string name="reorder_unit_group_description">Einheitengruppe umordnen</string>
|
<string name="reorder_unit_group_description">Einheitengruppe umordnen</string>
|
||||||
<string name="disable_unit_group_description">Einheitengruppe deaktivieren</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>
|
<string name="app_version_name_setting">Versionsname</string>
|
||||||
</resources>
|
</resources>
|
@ -726,8 +726,6 @@
|
|||||||
<string name="enable_unit_group_description">Enable unit group</string>
|
<string name="enable_unit_group_description">Enable unit group</string>
|
||||||
<string name="reorder_unit_group_description">Reorder 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="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="app_version_name_setting">Version name</string>
|
||||||
<string name="about_unitto">About Unitto</string>
|
<string name="about_unitto">About Unitto</string>
|
||||||
<string name="about_unitto_support">Learn about the app</string>
|
<string name="about_unitto_support">Learn about the app</string>
|
||||||
|
@ -714,8 +714,6 @@
|
|||||||
<string name="enable_unit_group_description">Activer le groupe d\'unités</string>
|
<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="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="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="app_version_name_setting">Nom de la version</string>
|
||||||
<string name="about_unitto">À propos d\'Unitto</string>
|
<string name="about_unitto">À propos d\'Unitto</string>
|
||||||
<string name="about_unitto_support">En savoir plus sur l\'application</string>
|
<string name="about_unitto_support">En savoir plus sur l\'application</string>
|
||||||
|
@ -726,8 +726,7 @@
|
|||||||
<string name="enable_unit_group_description">Включить группу величин</string>
|
<string name="enable_unit_group_description">Включить группу величин</string>
|
||||||
<string name="reorder_unit_group_description">Переместить группу величин</string>
|
<string name="reorder_unit_group_description">Переместить группу величин</string>
|
||||||
<string name="disable_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="app_version_name_setting">Название версии</string>
|
||||||
<string name="about_unitto">О Unitto</string>
|
<string name="about_unitto">О Unitto</string>
|
||||||
<string name="about_unitto_support">Узнайте больше о приложении</string>
|
<string name="about_unitto_support">Узнайте больше о приложении</string>
|
||||||
|
@ -1079,8 +1079,6 @@
|
|||||||
<string name="reorder_unit_group_description">Reorder 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="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="app_version_name_setting">Version name</string>
|
||||||
<string name="about_unitto">About Unitto</string>
|
<string name="about_unitto">About Unitto</string>
|
||||||
<string name="about_unitto_support">Learn about the app</string>
|
<string name="about_unitto_support">Learn about the app</string>
|
||||||
|
@ -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>
|
|
@ -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)
|
|
||||||
}
|
|
@ -50,7 +50,6 @@ import javax.inject.Inject
|
|||||||
* @property outputFormat Current [OutputFormat] that is applied to converted value (not input)
|
* @property outputFormat Current [OutputFormat] that is applied to converted value (not input)
|
||||||
* @property latestLeftSideUnit Latest [AbstractUnit] that was on the left side
|
* @property latestLeftSideUnit Latest [AbstractUnit] that was on the left side
|
||||||
* @property latestRightSideUnit Latest [AbstractUnit] that was on the right 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
|
* @property shownUnitGroups [UnitGroup]s that user wants to see. Excludes other [UnitGroup]s
|
||||||
*/
|
*/
|
||||||
data class UserPreferences(
|
data class UserPreferences(
|
||||||
@ -62,14 +61,14 @@ data class UserPreferences(
|
|||||||
val outputFormat: Int = OutputFormat.PLAIN,
|
val outputFormat: Int = OutputFormat.PLAIN,
|
||||||
val latestLeftSideUnit: String = MyUnitIDS.kilometer,
|
val latestLeftSideUnit: String = MyUnitIDS.kilometer,
|
||||||
val latestRightSideUnit: String = MyUnitIDS.mile,
|
val latestRightSideUnit: String = MyUnitIDS.mile,
|
||||||
val enableAnalytics: Boolean = true,
|
|
||||||
val shownUnitGroups: List<UnitGroup> = ALL_UNIT_GROUPS
|
val shownUnitGroups: List<UnitGroup> = ALL_UNIT_GROUPS
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Repository that works with DataStore
|
* 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
|
* Keys for DataStore
|
||||||
*/
|
*/
|
||||||
@ -82,7 +81,6 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS
|
|||||||
val OUTPUT_FORMAT = intPreferencesKey("OUTPUT_FORMAT_PREF_KEY")
|
val OUTPUT_FORMAT = intPreferencesKey("OUTPUT_FORMAT_PREF_KEY")
|
||||||
val LATEST_LEFT_SIDE = stringPreferencesKey("LATEST_LEFT_SIDE_PREF_KEY")
|
val LATEST_LEFT_SIDE = stringPreferencesKey("LATEST_LEFT_SIDE_PREF_KEY")
|
||||||
val LATEST_RIGHT_SIDE = stringPreferencesKey("LATEST_RIGHT_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")
|
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
|
preferences[PrefsKeys.LATEST_LEFT_SIDE] ?: MyUnitIDS.kilometer
|
||||||
val latestRightSideUnit: String =
|
val latestRightSideUnit: String =
|
||||||
preferences[PrefsKeys.LATEST_RIGHT_SIDE] ?: MyUnitIDS.mile
|
preferences[PrefsKeys.LATEST_RIGHT_SIDE] ?: MyUnitIDS.mile
|
||||||
val enableAnalytics: Boolean =
|
|
||||||
preferences[PrefsKeys.ENABLE_ANALYTICS] ?: true
|
|
||||||
val shownUnitGroups: List<UnitGroup> =
|
val shownUnitGroups: List<UnitGroup> =
|
||||||
preferences[PrefsKeys.SHOWN_UNIT_GROUPS]?.let { list ->
|
preferences[PrefsKeys.SHOWN_UNIT_GROUPS]?.let { list ->
|
||||||
// Everything is in hidden (nothing in shown)
|
// Everything is in hidden (nothing in shown)
|
||||||
@ -137,7 +133,6 @@ class UserPreferencesRepository @Inject constructor(private val dataStore: DataS
|
|||||||
outputFormat = outputFormat,
|
outputFormat = outputFormat,
|
||||||
latestLeftSideUnit = latestLeftSideUnit,
|
latestLeftSideUnit = latestLeftSideUnit,
|
||||||
latestRightSideUnit = latestRightSideUnit,
|
latestRightSideUnit = latestRightSideUnit,
|
||||||
enableAnalytics = enableAnalytics,
|
|
||||||
shownUnitGroups = shownUnitGroups
|
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,
|
* Update latest used pair of [AbstractUnit] in DataStore. Need it so when user restarts the app,
|
||||||
* this pair will be already set.
|
* this pair will be already set.
|
||||||
|
@ -23,7 +23,6 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import com.github.keelar.exprk.ExpressionException
|
import com.github.keelar.exprk.ExpressionException
|
||||||
import com.github.keelar.exprk.Expressions
|
import com.github.keelar.exprk.Expressions
|
||||||
import com.sadellie.unitto.core.base.DIGITS
|
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_0
|
||||||
import com.sadellie.unitto.core.base.KEY_1
|
import com.sadellie.unitto.core.base.KEY_1
|
||||||
import com.sadellie.unitto.core.base.KEY_2
|
import com.sadellie.unitto.core.base.KEY_2
|
||||||
@ -529,14 +528,7 @@ class MainViewModel @Inject constructor(
|
|||||||
CurrencyApi.retrofitService.getCurrencyPairs(unitFrom.unitId)
|
CurrencyApi.retrofitService.getCurrencyPairs(unitFrom.unitId)
|
||||||
allUnitsRepository.updateBasicUnitsForCurrencies(pairs.currency)
|
allUnitsRepository.updateBasicUnitsForCurrencies(pairs.currency)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
when (e) {
|
// Dangerous and stupid, but who cares
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_showError.update { true }
|
_showError.update { true }
|
||||||
} finally {
|
} finally {
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,6 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Info
|
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.Palette
|
||||||
import androidx.compose.material.icons.filled.RateReview
|
import androidx.compose.material.icons.filled.RateReview
|
||||||
import androidx.compose.material.icons.filled.Rule
|
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.base.SEPARATORS
|
||||||
import com.sadellie.unitto.core.ui.common.Header
|
import com.sadellie.unitto.core.ui.common.Header
|
||||||
import com.sadellie.unitto.core.ui.common.UnittoLargeTopAppBar
|
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.core.ui.openLink
|
||||||
import com.sadellie.unitto.feature.R
|
import com.sadellie.unitto.feature.R
|
||||||
import com.sadellie.unitto.feature.settings.components.AlertDialogWithList
|
import com.sadellie.unitto.feature.settings.components.AlertDialogWithList
|
||||||
@ -146,23 +144,6 @@ internal fun SettingsScreen(
|
|||||||
// ADDITIONAL GROUP
|
// ADDITIONAL GROUP
|
||||||
item { Header(stringResource(R.string.additional_settings_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
|
// RATE THIS APP
|
||||||
if (BuildConfig.STORE_LINK.isNotEmpty()) {
|
if (BuildConfig.STORE_LINK.isNotEmpty()) {
|
||||||
item {
|
item {
|
||||||
|
@ -18,15 +18,13 @@
|
|||||||
|
|
||||||
package com.sadellie.unitto.feature.settings
|
package com.sadellie.unitto.feature.settings
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
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.UserPreferences
|
||||||
import com.sadellie.unitto.data.preferences.UserPreferencesRepository
|
import com.sadellie.unitto.data.preferences.UserPreferencesRepository
|
||||||
import com.sadellie.unitto.data.units.UnitGroup
|
import com.sadellie.unitto.data.units.UnitGroup
|
||||||
import com.sadellie.unitto.data.units.UnitGroupsRepository
|
import com.sadellie.unitto.data.units.UnitGroupsRepository
|
||||||
import com.sadellie.unitto.core.ui.Formatter
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import io.github.sadellie.themmo.ThemingMode
|
import io.github.sadellie.themmo.ThemingMode
|
||||||
import kotlinx.coroutines.flow.SharingStarted
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
@ -41,7 +39,6 @@ import javax.inject.Inject
|
|||||||
class SettingsViewModel @Inject constructor(
|
class SettingsViewModel @Inject constructor(
|
||||||
private val userPrefsRepository: UserPreferencesRepository,
|
private val userPrefsRepository: UserPreferencesRepository,
|
||||||
private val unitGroupsRepository: UnitGroupsRepository,
|
private val unitGroupsRepository: UnitGroupsRepository,
|
||||||
private val application: Application,
|
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var userPrefs = userPrefsRepository.userPreferencesFlow
|
var userPrefs = userPrefsRepository.userPreferencesFlow
|
||||||
.onEach { Formatter.setSeparator(it.separator) }
|
.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
|
* See [UnitGroupsRepository.markUnitGroupAsHidden] and
|
||||||
* [UserPreferencesRepository.updateShownUnitGroups]
|
* [UserPreferencesRepository.updateShownUnitGroups]
|
||||||
|
@ -25,12 +25,8 @@ comSquareupRetrofit2 = "2.9.0"
|
|||||||
comGithubSadellieThemmo = "cf6be7e592"
|
comGithubSadellieThemmo = "cf6be7e592"
|
||||||
orgBurnoutcrewComposereorderable = "0.9.6"
|
orgBurnoutcrewComposereorderable = "0.9.6"
|
||||||
comGithubSadellieExprk = "e55cba8f41"
|
comGithubSadellieExprk = "e55cba8f41"
|
||||||
firebaseBom = "31.1.0"
|
|
||||||
androidGradlePlugin = "7.3.1"
|
androidGradlePlugin = "7.3.1"
|
||||||
kotlin = "1.7.21"
|
kotlin = "1.7.21"
|
||||||
comGoogleGms = "4.3.14"
|
|
||||||
comGoogleFirebase = "2.9.2"
|
|
||||||
|
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" }
|
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" }
|
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" }
|
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-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
|
# classpath
|
||||||
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
|
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" }
|
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-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]
|
[plugins]
|
||||||
android-gradlePlugin = { id = "com.android.application", version.ref = "androidGradlePlugin" }
|
android-gradlePlugin = { id = "com.android.application", version.ref = "androidGradlePlugin" }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user