various refactoring

fixes #7

- tweak proguard-rules.pro to try to fix a bug
- modernize update activity

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 2 years ago
parent fbb6ecd40c
commit a0c0d86f78

@ -14,12 +14,12 @@
# Uncomment this to preserve the line number information for # Uncomment this to preserve the line number information for
# debugging stack traces. # debugging stack traces.
-keepattributes SourceFile,LineNumberTable,Signature # -keepattributes SourceFile,LineNumberTable,Signature
-printmapping mapping.txt -printmapping mapping.txt
# Optimisations # Optimisations
-repackageclasses "" -repackageclasses ""
-overloadaggressively # -overloadaggressively
-allowaccessmodification -allowaccessmodification
@ -188,13 +188,13 @@
} }
# Keep all of Cronet API and google's internal classes # Keep all of Cronet API and google's internal classes
-keep class com.google.common.util.concurrent.** { *; } # -keep class com.google.common.util.concurrent.** { *; }
-keepclassmembers class kotlin.SafePublicationLazyImpl { -keepclassmembers class kotlin.SafePublicationLazyImpl {
java.lang.Object _value; java.lang.Object _value;
} }
# fix bug with androidx work and future # fix bug with androidx work and future
-keep class androidx.work.impl.utils.futures.* { *; } # -keep class androidx.work.impl.utils.futures.* { *; }
# Silence some warnings # Silence some warnings
-dontwarn android.os.SystemProperties -dontwarn android.os.SystemProperties

@ -25,9 +25,6 @@ import java.util.zip.ZipFile;
import timber.log.Timber; import timber.log.Timber;
interface NotificationTypeCst {
}
public enum NotificationType implements NotificationTypeCst { public enum NotificationType implements NotificationTypeCst {
DEBUG(R.string.debug_build, R.drawable.ic_baseline_bug_report_24, com.google.android.material.R.attr.colorSecondary, com.google.android.material.R.attr.colorOnSecondary) { DEBUG(R.string.debug_build, R.drawable.ic_baseline_bug_report_24, com.google.android.material.R.attr.colorSecondary, com.google.android.material.R.attr.colorOnSecondary) {
@Override @Override

@ -0,0 +1,3 @@
package com.fox2code.mmm
internal interface NotificationTypeCst

@ -53,7 +53,7 @@ class RuntimeUtils {
activity.layoutInflater.inflate(R.layout.dialog_checkbox, null) activity.layoutInflater.inflate(R.layout.dialog_checkbox, null)
val checkBox = view.findViewById<CheckBox>(R.id.checkbox) val checkBox = view.findViewById<CheckBox>(R.id.checkbox)
checkBox.setText(R.string.dont_ask_again) checkBox.setText(R.string.dont_ask_again)
checkBox.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean -> checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
PreferenceManager.getDefaultSharedPreferences( PreferenceManager.getDefaultSharedPreferences(
context context
).edit().putBoolean( ).edit().putBoolean(
@ -61,14 +61,14 @@ class RuntimeUtils {
).apply() ).apply()
} }
builder.setView(view) builder.setView(view)
builder.setPositiveButton(R.string.permission_notification_grant) { dialog, which -> builder.setPositiveButton(R.string.permission_notification_grant) { _, _ ->
// Request the permission // Request the permission
activity.requestPermissions( activity.requestPermissions(
arrayOf(Manifest.permission.POST_NOTIFICATIONS), 0 arrayOf(Manifest.permission.POST_NOTIFICATIONS), 0
) )
MainActivity.doSetupNowRunning = false MainActivity.doSetupNowRunning = false
} }
builder.setNegativeButton(R.string.cancel) { dialog, which -> builder.setNegativeButton(R.string.cancel) { dialog, _ ->
// Set pref_background_update_check to false and dismiss dialog // Set pref_background_update_check to false and dismiss dialog
val prefs = PreferenceManager.getDefaultSharedPreferences(context) val prefs = PreferenceManager.getDefaultSharedPreferences(context)
prefs.edit().putBoolean("pref_background_update_check", false).apply() prefs.edit().putBoolean("pref_background_update_check", false).apply()
@ -104,7 +104,7 @@ class RuntimeUtils {
val view: View = activity.layoutInflater.inflate(R.layout.dialog_checkbox, null) val view: View = activity.layoutInflater.inflate(R.layout.dialog_checkbox, null)
val checkBox = view.findViewById<CheckBox>(R.id.checkbox) val checkBox = view.findViewById<CheckBox>(R.id.checkbox)
checkBox.setText(R.string.dont_ask_again) checkBox.setText(R.string.dont_ask_again)
checkBox.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean -> checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
PreferenceManager.getDefaultSharedPreferences( PreferenceManager.getDefaultSharedPreferences(
context context
).edit() ).edit()
@ -112,7 +112,7 @@ class RuntimeUtils {
.apply() .apply()
} }
builder.setView(view) builder.setView(view)
builder.setPositiveButton(R.string.permission_notification_grant) { dialog, which -> builder.setPositiveButton(R.string.permission_notification_grant) { _, _ ->
// Open notification settings // Open notification settings
val intent = Intent() val intent = Intent()
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
@ -121,7 +121,7 @@ class RuntimeUtils {
activity.startActivity(intent) activity.startActivity(intent)
MainActivity.doSetupNowRunning = false MainActivity.doSetupNowRunning = false
} }
builder.setNegativeButton(R.string.cancel) { dialog, which -> builder.setNegativeButton(R.string.cancel) { dialog, _ ->
// Set pref_background_update_check to false and dismiss dialog // Set pref_background_update_check to false and dismiss dialog
val prefs = MainApplication.getSharedPreferences("mmm") val prefs = MainApplication.getSharedPreferences("mmm")
prefs.edit().putBoolean("pref_background_update_check", false).apply() prefs.edit().putBoolean("pref_background_update_check", false).apply()
@ -207,11 +207,11 @@ class RuntimeUtils {
val prefs = MainApplication.getSharedPreferences("mmm") val prefs = MainApplication.getSharedPreferences("mmm")
if (prefs.getInt("weblate_snackbar_shown", 0) == BuildConfig.VERSION_CODE) return if (prefs.getInt("weblate_snackbar_shown", 0) == BuildConfig.VERSION_CODE) return
val snackbar: Snackbar = Snackbar.make( val snackbar: Snackbar = Snackbar.make(
activity.findViewById<View>(R.id.root_container), activity.findViewById(R.id.root_container),
activity.getString(R.string.language_not_available, languageName), activity.getString(R.string.language_not_available, languageName),
Snackbar.LENGTH_LONG Snackbar.LENGTH_LONG
) )
snackbar.setAction(R.string.ok) { v -> snackbar.setAction(R.string.ok) {
val intent = Intent(Intent.ACTION_VIEW) val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("https://translate.nift4.org/engage/foxmmm/?language=$language") intent.data = Uri.parse("https://translate.nift4.org/engage/foxmmm/?language=$language")
activity.startActivity(intent) activity.startActivity(intent)

@ -1,11 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
tools:context=".UpdateActivity"> tools:context=".UpdateActivity">
<LinearLayout
android:id="@+id/update_container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="center"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
android:orientation="vertical">
<!-- Activity used to download and install app updates --> <!-- Activity used to download and install app updates -->
<!-- first, upgrade icon --> <!-- first, upgrade icon -->
<ImageView <ImageView
@ -14,7 +24,7 @@
android:layout_height="93dp" android:layout_height="93dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="8dp" android:layout_margin="8dp"
android:contentDescription="@string/crash_icon" android:contentDescription="@string/update"
android:src="@drawable/baseline_system_update_24" /> android:src="@drawable/baseline_system_update_24" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
@ -53,33 +63,6 @@
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:textAppearance="?attr/textAppearanceBody2" /> android:textAppearance="?attr/textAppearanceBody2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="4dp"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
android:id="@+id/update_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:text="@string/update_button"
android:visibility="invisible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/update_cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginTop="16dp"
android:text="@string/update_cancel_button"
android:visibility="visible" />
</LinearLayout>
<!-- Invisible warning for debug builds --> <!-- Invisible warning for debug builds -->
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/update_debug_warning" android:id="@+id/update_debug_warning"
@ -118,5 +101,19 @@
android:textAppearance="?attr/textAppearanceBody2" /> android:textAppearance="?attr/textAppearanceBody2" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<!-- bottom nav for cancel and finish -->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="0dp"
android:visibility="visible"
app:compatShadowEnabled="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/update_container"
app:menu="@menu/update_nav" />
</androidx.constraintlayout.widget.ConstraintLayout >

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/update_cancel_button"
android:icon="@drawable/baseline_close_24"
android:title="@string/cancel"
android:visible="true"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_update"
android:icon="@drawable/ic_baseline_refresh_24"
android:title="@string/update_button"
android:visible="true"
android:enabled="false"
app:showAsAction="ifRoom" />
</menu>
Loading…
Cancel
Save