From 56097f43162181e54b3f6b8770de6118afa4824b Mon Sep 17 00:00:00 2001 From: Mikhail Barashkov Date: Thu, 29 Jul 2021 18:15:14 +0300 Subject: [PATCH] Upgrade Gradle; fix crashes on Android L; add checkbox to turn crash collection on or off (off by default). --- app/build.gradle | 4 ++-- app/src/googleplay/res/xml/preferences.xml | 5 +++++ app/src/main/assets/whatsnew.htm | 11 +++++++++++ .../com/handydev/financier/FinancierApplication.kt | 9 ++++++++- .../handydev/financier/activity/CategorySelector.kt | 8 +++++--- .../handydev/financier/activity/MyEntitySelector.kt | 8 +++++--- .../main/java/com/handydev/financier/utils/Utils.kt | 11 +++++++++++ .../java/com/handydev/financier/view/NodeInflater.kt | 3 ++- app/src/main/res/values-ru/strings.xml | 3 +++ app/src/main/res/values/strings.xml | 3 +++ build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 12 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/com/handydev/financier/utils/Utils.kt diff --git a/app/build.gradle b/app/build.gradle index 701ab92a..6ae2e369 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,8 +48,8 @@ android { applicationId "com.handydev.financier" minSdkVersion 21 targetSdkVersion 29 - versionCode 217 - versionName "2.0.17" + versionCode 218 + versionName "2.0.18" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true javaCompileOptions { diff --git a/app/src/googleplay/res/xml/preferences.xml b/app/src/googleplay/res/xml/preferences.xml index 459c8033..199e2300 100644 --- a/app/src/googleplay/res/xml/preferences.xml +++ b/app/src/googleplay/res/xml/preferences.xml @@ -449,6 +449,11 @@ android:key="restore_missed_scheduled_transactions" android:summary="@string/restore_missed_scheduled_transactions_summary" android:title="@string/restore_missed_scheduled_transactions" /> + diff --git a/app/src/main/assets/whatsnew.htm b/app/src/main/assets/whatsnew.htm index 6e4c054d..713b9b23 100644 --- a/app/src/main/assets/whatsnew.htm +++ b/app/src/main/assets/whatsnew.htm @@ -17,6 +17,17 @@ +

2.0.18

+

+ [*]Fix crashes on Android L. + [+]Add checkbox to turn off crash collection. +

+ +

2.0.17

+

+ [+]Crash reports using Acra service. +

+

2.0.16

[*]Crash fixed when going back from Add Category screen.
diff --git a/app/src/main/java/com/handydev/financier/FinancierApplication.kt b/app/src/main/java/com/handydev/financier/FinancierApplication.kt index b307cdae..acbf14bf 100644 --- a/app/src/main/java/com/handydev/financier/FinancierApplication.kt +++ b/app/src/main/java/com/handydev/financier/FinancierApplication.kt @@ -1,7 +1,10 @@ package com.handydev.financier import android.content.Context +import android.preference.PreferenceManager import androidx.multidex.MultiDexApplication +import com.handydev.financier.activity.PreferencesActivity +import com.handydev.financier.utils.MyPreferences import org.acra.ACRA import org.acra.config.httpSender import org.acra.data.StringFormat @@ -12,6 +15,10 @@ import java.lang.RuntimeException open class FinancierApplication : MultiDexApplication() { override fun attachBaseContext(base: Context) { super.attachBaseContext(base) + val acraPrefExists = PreferenceManager.getDefaultSharedPreferences(this).contains("acra.enable") + if(!acraPrefExists) { + PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("acra.enable", false).commit() + } initAcra { //core configuration: @@ -24,6 +31,6 @@ open class FinancierApplication : MultiDexApplication() { httpMethod = HttpSender.Method.POST } } - ACRA.DEV_LOGGING = true + //ACRA.DEV_LOGGING = true } } \ No newline at end of file diff --git a/app/src/main/java/com/handydev/financier/activity/CategorySelector.kt b/app/src/main/java/com/handydev/financier/activity/CategorySelector.kt index 8226ce3b..01131588 100644 --- a/app/src/main/java/com/handydev/financier/activity/CategorySelector.kt +++ b/app/src/main/java/com/handydev/financier/activity/CategorySelector.kt @@ -25,6 +25,7 @@ import com.handydev.financier.model.* import com.handydev.financier.utils.ArrUtils import com.handydev.financier.utils.TransactionUtils import com.handydev.financier.utils.Utils +import com.handydev.financier.utils.getColorHelper import com.handydev.financier.view.AttributeView import com.handydev.financier.view.AttributeViewFactory import java.util.* @@ -128,9 +129,10 @@ class CategorySelector @JvmOverloads constructor(private categoryText = filterNode?.textView autoCompleteTextView = filterNode?.autoCompleteTextView if(darkUI) { - categoryText?.setTextColor(activity!!.resources.getColor(R.color.main_text_color, null)) - autoCompleteTextView?.setTextColor(activity!!.resources.getColor(R.color.main_text_color, null)) - autoCompleteTextView?.setHintTextColor(activity!!.resources.getColor(R.color.main_text_color, null)) + val color = getColorHelper(activity!!, R.color.main_text_color) + categoryText?.setTextColor(color) + autoCompleteTextView?.setTextColor(color) + autoCompleteTextView?.setHintTextColor(color) } return categoryText } diff --git a/app/src/main/java/com/handydev/financier/activity/MyEntitySelector.kt b/app/src/main/java/com/handydev/financier/activity/MyEntitySelector.kt index 3678cc30..8837c653 100644 --- a/app/src/main/java/com/handydev/financier/activity/MyEntitySelector.kt +++ b/app/src/main/java/com/handydev/financier/activity/MyEntitySelector.kt @@ -14,6 +14,7 @@ import com.handydev.financier.model.MultiChoiceItem import com.handydev.financier.model.MyEntity import com.handydev.financier.utils.ArrUtils import com.handydev.financier.utils.Utils +import com.handydev.financier.utils.getColorHelper import java.util.* abstract class MyEntitySelector internal constructor( @@ -68,9 +69,10 @@ abstract class MyEntitySelector internal co node = filterNode!!.nodeLayout autoCompleteView = filterNode!!.autoCompleteTextView if(darkUI) { - text?.setTextColor(activity!!.resources.getColor(R.color.main_text_color, null)) - autoCompleteView?.setTextColor(activity!!.resources.getColor(R.color.main_text_color, null)) - autoCompleteView?.setHintTextColor(activity!!.resources.getColor(R.color.main_text_color, null)) + val color = getColorHelper(activity!!, R.color.main_text_color) + text?.setTextColor(color) + autoCompleteView?.setTextColor(color) + autoCompleteView?.setHintTextColor(color) } } return text diff --git a/app/src/main/java/com/handydev/financier/utils/Utils.kt b/app/src/main/java/com/handydev/financier/utils/Utils.kt new file mode 100644 index 00000000..9e0b7009 --- /dev/null +++ b/app/src/main/java/com/handydev/financier/utils/Utils.kt @@ -0,0 +1,11 @@ +package com.handydev.financier.utils + +import android.content.Context +import android.os.Build +import androidx.annotation.ColorInt +import androidx.annotation.ColorRes + +@Suppress("DEPRECATION") +@ColorInt +fun getColorHelper(context: Context, @ColorRes id: Int) = + if (Build.VERSION.SDK_INT >= 23) context.getColor(id) else context.resources.getColor(id); \ No newline at end of file diff --git a/app/src/main/java/com/handydev/financier/view/NodeInflater.kt b/app/src/main/java/com/handydev/financier/view/NodeInflater.kt index a3bc5b67..52ef2ea9 100644 --- a/app/src/main/java/com/handydev/financier/view/NodeInflater.kt +++ b/app/src/main/java/com/handydev/financier/view/NodeInflater.kt @@ -11,6 +11,7 @@ import com.handydev.financier.BuildConfig import com.handydev.financier.R import com.handydev.financier.activity.RequestPermission import com.handydev.financier.utils.PicturesUtil +import com.handydev.financier.utils.getColorHelper class NodeInflater(var inflater: LayoutInflater) { @@ -45,7 +46,7 @@ class NodeInflater(var inflater: LayoutInflater) { val labelView = v.findViewById(R.id.label) labelView.setText(labelId) if (darkUI) { - labelView.setTextColor(inflater.context.resources.getColor(R.color.main_text_color, null)) + labelView.setTextColor(getColorHelper(inflater.context, R.color.main_text_color)) } return this } diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 93dafc9a..927f915f 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -945,5 +945,8 @@ %1$s: не удалось найти \"%2$s\"? Создать новую сущность? Категория: не удалось найти \"%s\"? Создайте новую категорию нажав кнопку +. Список + Позволить отправлять отчёты о ошибках + Ошибки собираются и отправляются с использованием открытой библиотеки ACRA на наш внутренний сервер Acrarium, без передачи личных данных + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6b7514c1..552db4ff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1003,6 +1003,9 @@ List all Type template… + Allow to send anonymous crash reports + Crashes are collected and sent using the open-source ACRA library to our internal Acrarium server + Show Filter Show List diff --git a/build.gradle b/build.gradle index f02a34ef..220329b6 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.android.tools.build:gradle:7.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 102b2a13..6907d537 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip