Skip to content

Commit e0fafde

Browse files
update libs + bug fixes
- Fixes #88 - Fixes #75 - Possibly fixes #92 Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 63b5e0c commit e0fafde

9 files changed

Lines changed: 126 additions & 128 deletions

File tree

app/build.gradle.kts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -353,20 +353,20 @@ configurations {
353353
dependencies {
354354
// UI
355355
implementation("androidx.appcompat:appcompat:1.6.1")
356-
implementation("androidx.activity:activity-ktx:1.8.0")
356+
implementation("androidx.activity:activity-ktx:1.8.1")
357357
implementation("androidx.emoji2:emoji2:1.4.0")
358358
implementation("androidx.emoji2:emoji2-views-helper:1.4.0")
359359
implementation("androidx.preference:preference-ktx:1.2.1")
360360
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
361361
implementation("androidx.recyclerview:recyclerview:1.3.2")
362362
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
363-
implementation("androidx.webkit:webkit:1.8.0")
363+
implementation("androidx.webkit:webkit:1.9.0")
364364
implementation("com.google.android.material:material:1.10.0")
365365

366-
implementation("com.mikepenz:aboutlibraries:10.9.1")
366+
implementation("com.mikepenz:aboutlibraries:10.9.2")
367367

368368
// Utils
369-
implementation("androidx.work:work-runtime:2.8.1")
369+
implementation("androidx.work:work-runtime:2.9.0")
370370
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.11")
371371
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:5.0.0-alpha.11")
372372
// logging interceptor
@@ -405,14 +405,14 @@ dependencies {
405405
implementation("androidx.security:security-crypto:1.1.0-alpha06")
406406

407407
// some utils
408-
implementation("commons-io:commons-io:2.15.0")
409-
implementation("org.apache.commons:commons-compress:1.24.0")
408+
implementation("commons-io:commons-io:2.15.1")
409+
implementation("org.apache.commons:commons-compress:1.25.0")
410410

411411
// analytics
412412
implementation("ly.count.android:sdk:23.8.4")
413413

414414
// annotations
415-
implementation("org.jetbrains:annotations-java5:24.0.1")
415+
implementation("org.jetbrains:annotations-java5:24.1.0")
416416

417417
// debugging
418418
debugImplementation("com.squareup.leakcanary:leakcanary-android:2.12")
@@ -421,16 +421,16 @@ dependencies {
421421
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")
422422

423423
// yes
424-
implementation("com.github.fingerprintjs:fingerprint-android:2.0.2")
424+
implementation("com.github.fingerprintjs:fingerprint-android:2.1.0")
425425

426426
// room
427-
implementation("androidx.room:room-runtime:2.6.0")
427+
implementation("androidx.room:room-runtime:2.6.1")
428428

429429
// To use Kotlin Symbol Processing (KSP)
430-
ksp("androidx.room:room-compiler:2.6.0")
430+
ksp("androidx.room:room-compiler:2.6.1")
431431

432432
// optional - Kotlin Extensions and Coroutines support for Room
433-
implementation("androidx.room:room-ktx:2.6.0")
433+
implementation("androidx.room:room-ktx:2.6.1")
434434

435435
implementation("pl.droidsonroids.gif:android-gif-drawable:1.2.28")
436436

@@ -445,7 +445,7 @@ android {
445445
}
446446
}
447447

448-
ndkVersion = "25.2.9519653"
448+
ndkVersion = "26.1.10909125"
449449
dependenciesInfo {
450450
includeInApk = false
451451
includeInBundle = false

app/src/main/kotlin/com/fox2code/mmm/MainApplication.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
135135
return existingKey!!
136136
}
137137

138-
override fun getWorkManagerConfiguration(): Configuration {
139-
return Configuration.Builder().build()
140-
}
141-
142138
fun updateTheme() {
143139
@StyleRes val themeResId: Int
144140
var theme: String?
@@ -772,4 +768,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
772768

773769
override fun onActivityDestroyed(activity: Activity) {
774770
}
771+
772+
override val workManagerConfiguration: Configuration
773+
get() = Configuration.Builder().build()
775774
}

app/src/main/kotlin/com/fox2code/mmm/androidacy/AndroidacyWebAPI.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class AndroidacyWebAPI(
5959
* return current effective compat mode
6060
*/
6161
@get:JavascriptInterface
62-
var effectiveCompatMode = 0
63-
var notifiedCompatMode = 0
62+
var effectiveCompatMode = 1
63+
var notifiedCompatMode = 1
6464
fun forceQuitRaw(error: String?) {
6565
Toast.makeText(activity, error, Toast.LENGTH_LONG).show()
6666
activity.runOnUiThread { activity.finish() }

app/src/main/kotlin/com/fox2code/mmm/settings/RepoFragment.kt

Lines changed: 45 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import android.os.Handler
1515
import android.os.Looper
1616
import android.text.Editable
1717
import android.text.TextWatcher
18+
import android.view.LayoutInflater
1819
import android.view.inputmethod.EditorInfo
1920
import android.widget.EditText
2021
import android.widget.Toast
@@ -38,6 +39,7 @@ import com.fox2code.mmm.utils.room.ReposListDatabase
3839
import com.google.android.material.dialog.MaterialAlertDialogBuilder
3940
import com.google.android.material.snackbar.BaseTransientBottomBar
4041
import com.google.android.material.snackbar.Snackbar
42+
import com.google.android.material.textfield.TextInputEditText
4143
import com.topjohnwu.superuser.internal.UiThreadHandler
4244
import timber.log.Timber
4345
import java.io.IOException
@@ -55,91 +57,7 @@ class RepoFragment : PreferenceFragmentCompat() {
5557
// CaptchaWebview.setVisible(false);
5658
val androidacyTestMode =
5759
findPreference<Preference>("pref_androidacy_test_mode")!!
58-
if (!MainApplication.isDeveloper) {
59-
androidacyTestMode.isVisible = false
60-
} else {
61-
// Show a warning if user tries to enable test mode
62-
androidacyTestMode.onPreferenceChangeListener =
63-
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
64-
if (java.lang.Boolean.parseBoolean(newValue.toString())) {
65-
// Use MaterialAlertDialogBuilder
66-
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.warning)
67-
.setCancelable(false).setMessage(
68-
R.string.androidacy_test_mode_warning
69-
)
70-
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
71-
// User clicked OK button
72-
MainApplication.getPreferences("mmm")!!
73-
.edit().putBoolean("androidacy_test_mode", true).apply()
74-
// Check the switch
75-
val mStartActivity =
76-
Intent(requireContext(), MainActivity::class.java)
77-
mStartActivity.flags =
78-
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
79-
val mPendingIntentId = 123456
80-
// If < 23, FLAG_IMMUTABLE is not available
81-
val mPendingIntent: PendingIntent = PendingIntent.getActivity(
82-
requireContext(),
83-
mPendingIntentId,
84-
mStartActivity,
85-
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
86-
)
87-
val mgr =
88-
requireContext().getSystemService(ALARM_SERVICE) as AlarmManager
89-
mgr[AlarmManager.RTC, System.currentTimeMillis() + 100] =
90-
mPendingIntent
91-
if (MainApplication.forceDebugLogging) Timber.d(
92-
"Restarting app to save staging endpoint preference: %s",
93-
newValue
94-
)
95-
exitProcess(0) // Exit app process
96-
}
97-
.setNegativeButton(android.R.string.cancel) { _: DialogInterface?, _: Int ->
98-
// User cancelled the dialog
99-
// Uncheck the switch
100-
val switchPreferenceCompat =
101-
androidacyTestMode as SwitchPreferenceCompat
102-
switchPreferenceCompat.isChecked = false
103-
// There's probably a better way to do this than duplicate code but I'm too lazy to figure it out
104-
MainApplication.getPreferences("mmm")!!
105-
.edit().putBoolean("androidacy_test_mode", false).apply()
106-
}.show()
107-
} else {
108-
MainApplication.getPreferences("mmm")!!
109-
.edit().putBoolean("androidacy_test_mode", false).apply()
110-
// Show dialog to restart app with ok button
111-
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.warning)
112-
.setCancelable(false).setMessage(
113-
R.string.androidacy_test_mode_disable_warning
114-
)
115-
.setNeutralButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
116-
// User clicked OK button
117-
val mStartActivity =
118-
Intent(requireContext(), MainActivity::class.java)
119-
mStartActivity.flags =
120-
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
121-
val mPendingIntentId = 123456
122-
// If < 23, FLAG_IMMUTABLE is not available
123-
val mPendingIntent: PendingIntent = PendingIntent.getActivity(
124-
requireContext(),
125-
mPendingIntentId,
126-
mStartActivity,
127-
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
128-
)
129-
val mgr =
130-
requireContext().getSystemService(ALARM_SERVICE) as AlarmManager
131-
mgr[AlarmManager.RTC, System.currentTimeMillis() + 100] =
132-
mPendingIntent
133-
if (MainApplication.forceDebugLogging) Timber.d(
134-
"Restarting app to save staging endpoint preference: %s",
135-
newValue
136-
)
137-
exitProcess(0) // Exit app process
138-
}.show()
139-
}
140-
true
141-
}
142-
}
60+
androidacyTestMode.isVisible = false
14361
// Get magisk_alt_repo enabled state from room reposlist db
14462
val db = Room.databaseBuilder(
14563
requireContext(),
@@ -218,6 +136,38 @@ class RepoFragment : PreferenceFragmentCompat() {
218136
findPreference<LongClickablePreference>("pref_androidacy_repo_donate")!!
219137
prefAndroidacyRepoApiD.isEnabled = false
220138
prefAndroidacyRepoApiD.isVisible = false
139+
} else {
140+
val clipboard =
141+
requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
142+
val prefDonateAndroidacy =
143+
findPreference<LongClickablePreference>("pref_androidacy_repo_donate")!!
144+
prefDonateAndroidacy.onPreferenceClickListener =
145+
Preference.OnPreferenceClickListener { _: Preference? ->
146+
// copy FOX2CODE promo code to clipboard and toast user that they can use it for half off any subscription
147+
val toastText = requireContext().getString(R.string.promo_code_copied)
148+
clipboard.setPrimaryClip(ClipData.newPlainText(toastText, "FOX2CODE"))
149+
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show()
150+
// open androidacy
151+
IntentHelper.openUrl(
152+
MainApplication.INSTANCE!!.lastActivity!!,
153+
"https://www.androidacy.com/membership-join/?utm_source=AMMM&utm_medium=app&utm_campaign=donate"
154+
)
155+
true
156+
}
157+
// handle long click on pref_donate_androidacy
158+
prefDonateAndroidacy.onPreferenceLongClickListener =
159+
LongClickablePreference.OnPreferenceLongClickListener { _: Preference? ->
160+
// copy to clipboard
161+
val toastText = requireContext().getString(R.string.link_copied)
162+
clipboard.setPrimaryClip(
163+
ClipData.newPlainText(
164+
toastText,
165+
"https://www.androidacy.com/membership-join/?utm_source=AMMM&utm_medium=app&utm_campaign=donate"
166+
)
167+
)
168+
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show()
169+
true
170+
}
221171
}
222172
}
223173
val originalApiKeyRef = arrayOf(
@@ -510,15 +460,13 @@ class RepoFragment : PreferenceFragmentCompat() {
510460
Preference.OnPreferenceClickListener {
511461
val context = requireContext()
512462
val builder = MaterialAlertDialogBuilder(context)
513-
val input = EditText(context)
514-
input.setHint(R.string.custom_url)
515-
input.setHorizontallyScrolling(true)
516-
input.maxLines = 1
463+
val view = LayoutInflater.from(context).inflate(R.layout.custom_repo_input, null)
517464
builder.setIcon(R.drawable.ic_baseline_add_box_24)
518465
builder.setTitle(R.string.add_repo)
519466
// make link in message clickable
520467
builder.setMessage(R.string.add_repo_message)
521-
builder.setView(input)
468+
builder.setView(view)
469+
val input = view.findViewById<TextInputEditText>(R.id.custom_repo_input_edit)
522470
builder.setPositiveButton("OK") { _: DialogInterface?, _: Int ->
523471
var text = input.text.toString()
524472
text = text.trim { it <= ' ' }
@@ -571,8 +519,7 @@ class RepoFragment : PreferenceFragmentCompat() {
571519
)
572520
startActivity(intent)
573521
}
574-
val alertDialog = builder.show()
575-
val positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE)
522+
val alertDialog = builder.create()
576523
// validate as they type
577524
input.addTextChangedListener(object : TextWatcher {
578525
override fun beforeTextChanged(
@@ -594,42 +541,31 @@ class RepoFragment : PreferenceFragmentCompat() {
594541
if (charSequence.toString().isEmpty()) {
595542
input.error = getString(R.string.empty_field)
596543
if (MainApplication.forceDebugLogging) Timber.d("No input for repo")
597-
positiveButton.isEnabled = false
544+
return
598545
} else if (!charSequence.toString()
599546
.matches("^https://.*".toRegex())
600547
) {
601548
input.error = getString(R.string.invalid_repo_url)
602549
if (MainApplication.forceDebugLogging) Timber.d("Non https link for repo")
603-
positiveButton.isEnabled = false
550+
return
604551
} else if (charSequence.toString().contains(" ")) {
605552
input.error = getString(R.string.invalid_repo_url)
606553
if (MainApplication.forceDebugLogging) Timber.d("Repo url has space")
607-
positiveButton.isEnabled = false
554+
return
608555
} else if (!customRepoManager.canAddRepo(charSequence.toString())) {
609556
input.error = getString(R.string.repo_already_added)
610557
if (MainApplication.forceDebugLogging) Timber.d("Could not add repo for misc reason")
611-
positiveButton.isEnabled = false
558+
return
612559
} else {
613560
// enable ok button
614561
if (MainApplication.forceDebugLogging) Timber.d("Repo URL is ok")
615-
positiveButton.isEnabled = true
562+
return
616563
}
617564
}
618565

619566
override fun afterTextChanged(s: Editable) {}
620567
})
621-
positiveButton.isEnabled = false
622-
val dp10 = MainApplication.INSTANCE!!.lastActivity?.resources?.getDimensionPixelSize(
623-
R.dimen.dp10
624-
) ?: 0
625-
val dp20 = MainApplication.INSTANCE!!.lastActivity?.resources?.getDimensionPixelSize(
626-
R.dimen.dp20
627-
) ?: 0
628-
alertDialog.window!!.setSoftInputMode(20)
629-
alertDialog.window!!.setLayout(
630-
dp20,
631-
dp10
632-
)
568+
alertDialog.show()
633569
true
634570
}
635571
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
android:padding="16dp">
7+
8+
<!-- md3 edit text -->
9+
<com.google.android.material.textfield.TextInputLayout
10+
android:id="@+id/custom_repo_input"
11+
android:layout_width="0dp"
12+
android:layout_height="wrap_content"
13+
android:hint="@string/custom_url"
14+
android:inputType="textUri"
15+
android:textColorHint="@color/white"
16+
app:boxStrokeColor="@color/white"
17+
app:boxStrokeWidth="1dp"
18+
app:layout_constraintEnd_toEndOf="parent"
19+
app:layout_constraintStart_toStartOf="parent"
20+
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
21+
app:layout_constraintTop_toTopOf="parent">
22+
23+
<com.google.android.material.textfield.TextInputEditText
24+
android:id="@+id/custom_repo_input_edit"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:background="@null"
28+
android:inputType="textUri"
29+
android:textColor="@color/white" />
30+
31+
</com.google.android.material.textfield.TextInputLayout>
32+
33+
</androidx.constraintlayout.widget.ConstraintLayout>

app/src/main/res/values-v27/themes.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@
3333
<item name="android:windowActionBar">false</item>
3434
<item name="android:windowNoTitle">true</item>
3535
<item name="cornerRadius">@dimen/card_corner_radius</item>
36+
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
37+
<!-- md3 theme for text input -->
38+
<item name="editTextStyle">@style/Widget.Material3.TextInputEditText.OutlinedBox</item>
39+
<item name="textInputStyle">@style/Widget.Material3.TextInputLayout.OutlinedBox</item>
3640
</style>
3741
</resources>

0 commit comments

Comments
 (0)