Skip to content

Commit a0c0d86

Browse files
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>
1 parent fbb6ecd commit a0c0d86

6 files changed

Lines changed: 121 additions & 106 deletions

File tree

app/proguard-rules.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
# Uncomment this to preserve the line number information for
1616
# debugging stack traces.
17-
-keepattributes SourceFile,LineNumberTable,Signature
17+
# -keepattributes SourceFile,LineNumberTable,Signature
1818
-printmapping mapping.txt
1919

2020
# Optimisations
2121
-repackageclasses ""
22-
-overloadaggressively
22+
# -overloadaggressively
2323
-allowaccessmodification
2424

2525

@@ -188,13 +188,13 @@
188188
}
189189

190190
# Keep all of Cronet API and google's internal classes
191-
-keep class com.google.common.util.concurrent.** { *; }
191+
# -keep class com.google.common.util.concurrent.** { *; }
192192
-keepclassmembers class kotlin.SafePublicationLazyImpl {
193193
java.lang.Object _value;
194194
}
195195

196196
# fix bug with androidx work and future
197-
-keep class androidx.work.impl.utils.futures.* { *; }
197+
# -keep class androidx.work.impl.utils.futures.* { *; }
198198

199199
# Silence some warnings
200200
-dontwarn android.os.SystemProperties

app/src/main/java/com/fox2code/mmm/NotificationType.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525

2626
import timber.log.Timber;
2727

28-
interface NotificationTypeCst {
29-
}
30-
3128
public enum NotificationType implements NotificationTypeCst {
3229
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) {
3330
@Override
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package com.fox2code.mmm
2+
3+
internal interface NotificationTypeCst

app/src/main/java/com/fox2code/mmm/utils/RuntimeUtils.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ class RuntimeUtils {
5353
activity.layoutInflater.inflate(R.layout.dialog_checkbox, null)
5454
val checkBox = view.findViewById<CheckBox>(R.id.checkbox)
5555
checkBox.setText(R.string.dont_ask_again)
56-
checkBox.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean ->
56+
checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
5757
PreferenceManager.getDefaultSharedPreferences(
5858
context
5959
).edit().putBoolean(
6060
"pref_dont_ask_again_notification_permission", isChecked
6161
).apply()
6262
}
6363
builder.setView(view)
64-
builder.setPositiveButton(R.string.permission_notification_grant) { dialog, which ->
64+
builder.setPositiveButton(R.string.permission_notification_grant) { _, _ ->
6565
// Request the permission
6666
activity.requestPermissions(
6767
arrayOf(Manifest.permission.POST_NOTIFICATIONS), 0
6868
)
6969
MainActivity.doSetupNowRunning = false
7070
}
71-
builder.setNegativeButton(R.string.cancel) { dialog, which ->
71+
builder.setNegativeButton(R.string.cancel) { dialog, _ ->
7272
// Set pref_background_update_check to false and dismiss dialog
7373
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
7474
prefs.edit().putBoolean("pref_background_update_check", false).apply()
@@ -104,15 +104,15 @@ class RuntimeUtils {
104104
val view: View = activity.layoutInflater.inflate(R.layout.dialog_checkbox, null)
105105
val checkBox = view.findViewById<CheckBox>(R.id.checkbox)
106106
checkBox.setText(R.string.dont_ask_again)
107-
checkBox.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean ->
107+
checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
108108
PreferenceManager.getDefaultSharedPreferences(
109109
context
110110
).edit()
111111
.putBoolean("pref_dont_ask_again_notification_permission", isChecked)
112112
.apply()
113113
}
114114
builder.setView(view)
115-
builder.setPositiveButton(R.string.permission_notification_grant) { dialog, which ->
115+
builder.setPositiveButton(R.string.permission_notification_grant) { _, _ ->
116116
// Open notification settings
117117
val intent = Intent()
118118
intent.action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS
@@ -121,7 +121,7 @@ class RuntimeUtils {
121121
activity.startActivity(intent)
122122
MainActivity.doSetupNowRunning = false
123123
}
124-
builder.setNegativeButton(R.string.cancel) { dialog, which ->
124+
builder.setNegativeButton(R.string.cancel) { dialog, _ ->
125125
// Set pref_background_update_check to false and dismiss dialog
126126
val prefs = MainApplication.getSharedPreferences("mmm")
127127
prefs.edit().putBoolean("pref_background_update_check", false).apply()
@@ -207,11 +207,11 @@ class RuntimeUtils {
207207
val prefs = MainApplication.getSharedPreferences("mmm")
208208
if (prefs.getInt("weblate_snackbar_shown", 0) == BuildConfig.VERSION_CODE) return
209209
val snackbar: Snackbar = Snackbar.make(
210-
activity.findViewById<View>(R.id.root_container),
210+
activity.findViewById(R.id.root_container),
211211
activity.getString(R.string.language_not_available, languageName),
212212
Snackbar.LENGTH_LONG
213213
)
214-
snackbar.setAction(R.string.ok) { v ->
214+
snackbar.setAction(R.string.ok) {
215215
val intent = Intent(Intent.ACTION_VIEW)
216216
intent.data = Uri.parse("https://translate.nift4.org/engage/foxmmm/?language=$language")
217217
activity.startActivity(intent)
Lines changed: 88 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,119 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
xmlns:tools="http://schemas.android.com/tools"
45
android:layout_width="match_parent"
56
android:layout_height="match_parent"
67
android:orientation="vertical"
78
tools:context=".UpdateActivity">
89

9-
<!-- Activity used to download and install app updates -->
10-
<!-- first, upgrade icon -->
11-
<ImageView
12-
android:id="@+id/update_icon"
13-
android:layout_width="101dp"
14-
android:layout_height="93dp"
15-
android:layout_gravity="center"
16-
android:layout_margin="8dp"
17-
android:contentDescription="@string/crash_icon"
18-
android:src="@drawable/baseline_system_update_24" />
19-
20-
<com.google.android.material.textview.MaterialTextView
21-
android:id="@+id/update_title"
22-
android:layout_width="wrap_content"
23-
android:layout_height="wrap_content"
24-
android:layout_gravity="center"
25-
android:layout_marginHorizontal="16dp"
26-
android:layout_marginTop="16dp"
27-
android:text="@string/update_title"
28-
android:textAppearance="?attr/textAppearanceHeadline6" />
29-
30-
<com.google.android.material.textview.MaterialTextView
31-
android:id="@+id/update_subtitle"
32-
android:layout_width="wrap_content"
33-
android:layout_height="wrap_content"
34-
android:layout_gravity="center"
35-
android:layout_marginHorizontal="16dp"
36-
android:layout_marginTop="8dp"
37-
android:text="@string/update_message"
38-
android:textAppearance="?attr/textAppearanceBody2" />
39-
40-
<com.google.android.material.progressindicator.LinearProgressIndicator
41-
android:id="@+id/update_progress"
42-
style="@style/Widget.Material3.LinearProgressIndicator"
10+
<LinearLayout
11+
android:id="@+id/update_container"
4312
android:layout_width="match_parent"
44-
android:layout_height="wrap_content"
45-
android:layout_marginHorizontal="16dp"
46-
android:layout_marginTop="16dp" />
47-
48-
<com.google.android.material.textview.MaterialTextView
49-
android:id="@+id/update_progress_text"
50-
android:layout_width="wrap_content"
51-
android:layout_height="wrap_content"
52-
android:layout_marginHorizontal="16dp"
53-
android:layout_marginTop="8dp"
54-
android:textAppearance="?attr/textAppearanceBody2" />
13+
android:layout_height="0dp"
14+
android:gravity="center"
15+
app:layout_constraintTop_toTopOf="parent"
16+
app:layout_constraintBottom_toTopOf="@id/bottom_navigation"
17+
android:orientation="vertical">
5518

56-
<LinearLayout
57-
android:layout_width="wrap_content"
58-
android:layout_height="wrap_content"
59-
android:layout_gravity="bottom|end"
60-
android:layout_margin="4dp"
61-
android:orientation="horizontal">
19+
<!-- Activity used to download and install app updates -->
20+
<!-- first, upgrade icon -->
21+
<ImageView
22+
android:id="@+id/update_icon"
23+
android:layout_width="101dp"
24+
android:layout_height="93dp"
25+
android:layout_gravity="center"
26+
android:layout_margin="8dp"
27+
android:contentDescription="@string/update"
28+
android:src="@drawable/baseline_system_update_24" />
6229

63-
<com.google.android.material.button.MaterialButton
64-
android:id="@+id/update_button"
30+
<com.google.android.material.textview.MaterialTextView
31+
android:id="@+id/update_title"
6532
android:layout_width="wrap_content"
6633
android:layout_height="wrap_content"
34+
android:layout_gravity="center"
6735
android:layout_marginHorizontal="16dp"
6836
android:layout_marginTop="16dp"
69-
android:text="@string/update_button"
70-
android:visibility="invisible" />
37+
android:text="@string/update_title"
38+
android:textAppearance="?attr/textAppearanceHeadline6" />
7139

72-
<com.google.android.material.button.MaterialButton
73-
android:id="@+id/update_cancel_button"
40+
<com.google.android.material.textview.MaterialTextView
41+
android:id="@+id/update_subtitle"
7442
android:layout_width="wrap_content"
7543
android:layout_height="wrap_content"
44+
android:layout_gravity="center"
7645
android:layout_marginHorizontal="16dp"
77-
android:layout_marginTop="16dp"
78-
android:text="@string/update_cancel_button"
79-
android:visibility="visible" />
80-
81-
</LinearLayout>
82-
83-
<!-- Invisible warning for debug builds -->
84-
<com.google.android.material.textview.MaterialTextView
85-
android:id="@+id/update_debug_warning"
86-
android:layout_width="wrap_content"
87-
android:layout_height="wrap_content"
88-
android:layout_marginHorizontal="16dp"
89-
android:layout_marginTop="16dp"
90-
android:text="@string/update_debug_warning"
91-
android:textAppearance="?attr/textAppearanceBody2"
92-
android:visibility="gone" />
93-
46+
android:layout_marginTop="8dp"
47+
android:text="@string/update_message"
48+
android:textAppearance="?attr/textAppearanceBody2" />
9449

95-
<!-- Changelog view -->
96-
<LinearLayout
97-
android:layout_width="match_parent"
98-
android:layout_height="wrap_content"
99-
android:orientation="vertical">
50+
<com.google.android.material.progressindicator.LinearProgressIndicator
51+
android:id="@+id/update_progress"
52+
style="@style/Widget.Material3.LinearProgressIndicator"
53+
android:layout_width="match_parent"
54+
android:layout_height="wrap_content"
55+
android:layout_marginHorizontal="16dp"
56+
android:layout_marginTop="16dp" />
10057

10158
<com.google.android.material.textview.MaterialTextView
102-
android:id="@+id/changelog_title"
103-
android:layout_width="match_parent"
59+
android:id="@+id/update_progress_text"
60+
android:layout_width="wrap_content"
10461
android:layout_height="wrap_content"
10562
android:layout_marginHorizontal="16dp"
106-
android:layout_marginTop="16dp"
107-
android:text="@string/changelog"
108-
android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" />
63+
android:layout_marginTop="8dp"
64+
android:textAppearance="?attr/textAppearanceBody2" />
10965

66+
<!-- Invisible warning for debug builds -->
11067
<com.google.android.material.textview.MaterialTextView
111-
android:id="@+id/update_changelog"
112-
android:layout_width="match_parent"
68+
android:id="@+id/update_debug_warning"
69+
android:layout_width="wrap_content"
11370
android:layout_height="wrap_content"
11471
android:layout_marginHorizontal="16dp"
11572
android:layout_marginTop="16dp"
116-
android:scrollbars="vertical"
117-
android:text="@string/changelog_none"
118-
android:textAppearance="?attr/textAppearanceBody2" />
73+
android:text="@string/update_debug_warning"
74+
android:textAppearance="?attr/textAppearanceBody2"
75+
android:visibility="gone" />
11976

77+
78+
<!-- Changelog view -->
79+
<LinearLayout
80+
android:layout_width="match_parent"
81+
android:layout_height="wrap_content"
82+
android:orientation="vertical">
83+
84+
<com.google.android.material.textview.MaterialTextView
85+
android:id="@+id/changelog_title"
86+
android:layout_width="match_parent"
87+
android:layout_height="wrap_content"
88+
android:layout_marginHorizontal="16dp"
89+
android:layout_marginTop="16dp"
90+
android:text="@string/changelog"
91+
android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" />
92+
93+
<com.google.android.material.textview.MaterialTextView
94+
android:id="@+id/update_changelog"
95+
android:layout_width="match_parent"
96+
android:layout_height="wrap_content"
97+
android:layout_marginHorizontal="16dp"
98+
android:layout_marginTop="16dp"
99+
android:scrollbars="vertical"
100+
android:text="@string/changelog_none"
101+
android:textAppearance="?attr/textAppearanceBody2" />
102+
103+
</LinearLayout>
120104
</LinearLayout>
121105

122-
</LinearLayout>
106+
<!-- bottom nav for cancel and finish -->
107+
<com.google.android.material.bottomnavigation.BottomNavigationView
108+
android:id="@+id/bottom_navigation"
109+
android:layout_width="match_parent"
110+
android:layout_height="wrap_content"
111+
android:paddingBottom="0dp"
112+
android:visibility="visible"
113+
app:compatShadowEnabled="true"
114+
app:layout_constraintBottom_toBottomOf="parent"
115+
app:layout_constraintEnd_toEndOf="parent"
116+
app:layout_constraintTop_toBottomOf="@id/update_container"
117+
app:menu="@menu/update_nav" />
118+
119+
</androidx.constraintlayout.widget.ConstraintLayout >
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
<item
5+
android:id="@+id/update_cancel_button"
6+
android:icon="@drawable/baseline_close_24"
7+
android:title="@string/cancel"
8+
android:visible="true"
9+
app:showAsAction="ifRoom" />
10+
11+
<item
12+
android:id="@+id/action_update"
13+
android:icon="@drawable/ic_baseline_refresh_24"
14+
android:title="@string/update_button"
15+
android:visible="true"
16+
android:enabled="false"
17+
app:showAsAction="ifRoom" />
18+
</menu>

0 commit comments

Comments
 (0)