Skip to content

Commit

Permalink
update libs + bug fixes
Browse files Browse the repository at this point in the history
- Fixes #88
- Fixes #75
- Possibly fixes #92

Signed-off-by: androidacy-user <opensource@androidacy.com>
  • Loading branch information
androidacy-user committed Dec 10, 2023
1 parent 63b5e0c commit e0fafde
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 128 deletions.
24 changes: 12 additions & 12 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -353,20 +353,20 @@ configurations {
dependencies {
// UI
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("androidx.activity:activity-ktx:1.8.0")
implementation("androidx.activity:activity-ktx:1.8.1")
implementation("androidx.emoji2:emoji2:1.4.0")
implementation("androidx.emoji2:emoji2-views-helper:1.4.0")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("androidx.webkit:webkit:1.8.0")
implementation("androidx.webkit:webkit:1.9.0")
implementation("com.google.android.material:material:1.10.0")

implementation("com.mikepenz:aboutlibraries:10.9.1")
implementation("com.mikepenz:aboutlibraries:10.9.2")

// Utils
implementation("androidx.work:work-runtime:2.8.1")
implementation("androidx.work:work-runtime:2.9.0")
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.11")
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:5.0.0-alpha.11")
// logging interceptor
Expand Down Expand Up @@ -405,14 +405,14 @@ dependencies {
implementation("androidx.security:security-crypto:1.1.0-alpha06")

// some utils
implementation("commons-io:commons-io:2.15.0")
implementation("org.apache.commons:commons-compress:1.24.0")
implementation("commons-io:commons-io:2.15.1")
implementation("org.apache.commons:commons-compress:1.25.0")

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

// annotations
implementation("org.jetbrains:annotations-java5:24.0.1")
implementation("org.jetbrains:annotations-java5:24.1.0")

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

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

// room
implementation("androidx.room:room-runtime:2.6.0")
implementation("androidx.room:room-runtime:2.6.1")

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

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

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

Expand All @@ -445,7 +445,7 @@ android {
}
}

ndkVersion = "25.2.9519653"
ndkVersion = "26.1.10909125"
dependenciesInfo {
includeInApk = false
includeInBundle = false
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/kotlin/com/fox2code/mmm/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle
return existingKey!!
}

override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder().build()
}

fun updateTheme() {
@StyleRes val themeResId: Int
var theme: String?
Expand Down Expand Up @@ -772,4 +768,7 @@ class MainApplication : Application(), Configuration.Provider, ActivityLifecycle

override fun onActivityDestroyed(activity: Activity) {
}

override val workManagerConfiguration: Configuration
get() = Configuration.Builder().build()
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class AndroidacyWebAPI(
* return current effective compat mode
*/
@get:JavascriptInterface
var effectiveCompatMode = 0
var notifiedCompatMode = 0
var effectiveCompatMode = 1
var notifiedCompatMode = 1
fun forceQuitRaw(error: String?) {
Toast.makeText(activity, error, Toast.LENGTH_LONG).show()
activity.runOnUiThread { activity.finish() }
Expand Down
154 changes: 45 additions & 109 deletions app/src/main/kotlin/com/fox2code/mmm/settings/RepoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.os.Handler
import android.os.Looper
import android.text.Editable
import android.text.TextWatcher
import android.view.LayoutInflater
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import android.widget.Toast
Expand All @@ -38,6 +39,7 @@ import com.fox2code.mmm.utils.room.ReposListDatabase
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textfield.TextInputEditText
import com.topjohnwu.superuser.internal.UiThreadHandler
import timber.log.Timber
import java.io.IOException
Expand All @@ -55,91 +57,7 @@ class RepoFragment : PreferenceFragmentCompat() {
// CaptchaWebview.setVisible(false);
val androidacyTestMode =
findPreference<Preference>("pref_androidacy_test_mode")!!
if (!MainApplication.isDeveloper) {
androidacyTestMode.isVisible = false
} else {
// Show a warning if user tries to enable test mode
androidacyTestMode.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
if (java.lang.Boolean.parseBoolean(newValue.toString())) {
// Use MaterialAlertDialogBuilder
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.warning)
.setCancelable(false).setMessage(
R.string.androidacy_test_mode_warning
)
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
// User clicked OK button
MainApplication.getPreferences("mmm")!!
.edit().putBoolean("androidacy_test_mode", true).apply()
// Check the switch
val mStartActivity =
Intent(requireContext(), MainActivity::class.java)
mStartActivity.flags =
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
val mPendingIntentId = 123456
// If < 23, FLAG_IMMUTABLE is not available
val mPendingIntent: PendingIntent = PendingIntent.getActivity(
requireContext(),
mPendingIntentId,
mStartActivity,
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val mgr =
requireContext().getSystemService(ALARM_SERVICE) as AlarmManager
mgr[AlarmManager.RTC, System.currentTimeMillis() + 100] =
mPendingIntent
if (MainApplication.forceDebugLogging) Timber.d(
"Restarting app to save staging endpoint preference: %s",
newValue
)
exitProcess(0) // Exit app process
}
.setNegativeButton(android.R.string.cancel) { _: DialogInterface?, _: Int ->
// User cancelled the dialog
// Uncheck the switch
val switchPreferenceCompat =
androidacyTestMode as SwitchPreferenceCompat
switchPreferenceCompat.isChecked = false
// There's probably a better way to do this than duplicate code but I'm too lazy to figure it out
MainApplication.getPreferences("mmm")!!
.edit().putBoolean("androidacy_test_mode", false).apply()
}.show()
} else {
MainApplication.getPreferences("mmm")!!
.edit().putBoolean("androidacy_test_mode", false).apply()
// Show dialog to restart app with ok button
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.warning)
.setCancelable(false).setMessage(
R.string.androidacy_test_mode_disable_warning
)
.setNeutralButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
// User clicked OK button
val mStartActivity =
Intent(requireContext(), MainActivity::class.java)
mStartActivity.flags =
Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
val mPendingIntentId = 123456
// If < 23, FLAG_IMMUTABLE is not available
val mPendingIntent: PendingIntent = PendingIntent.getActivity(
requireContext(),
mPendingIntentId,
mStartActivity,
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val mgr =
requireContext().getSystemService(ALARM_SERVICE) as AlarmManager
mgr[AlarmManager.RTC, System.currentTimeMillis() + 100] =
mPendingIntent
if (MainApplication.forceDebugLogging) Timber.d(
"Restarting app to save staging endpoint preference: %s",
newValue
)
exitProcess(0) // Exit app process
}.show()
}
true
}
}
androidacyTestMode.isVisible = false
// Get magisk_alt_repo enabled state from room reposlist db
val db = Room.databaseBuilder(
requireContext(),
Expand Down Expand Up @@ -218,6 +136,38 @@ class RepoFragment : PreferenceFragmentCompat() {
findPreference<LongClickablePreference>("pref_androidacy_repo_donate")!!
prefAndroidacyRepoApiD.isEnabled = false
prefAndroidacyRepoApiD.isVisible = false
} else {
val clipboard =
requireContext().getSystemService(CLIPBOARD_SERVICE) as ClipboardManager
val prefDonateAndroidacy =
findPreference<LongClickablePreference>("pref_androidacy_repo_donate")!!
prefDonateAndroidacy.onPreferenceClickListener =
Preference.OnPreferenceClickListener { _: Preference? ->
// copy FOX2CODE promo code to clipboard and toast user that they can use it for half off any subscription
val toastText = requireContext().getString(R.string.promo_code_copied)
clipboard.setPrimaryClip(ClipData.newPlainText(toastText, "FOX2CODE"))
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show()
// open androidacy
IntentHelper.openUrl(
MainApplication.INSTANCE!!.lastActivity!!,
"https://www.androidacy.com/membership-join/?utm_source=AMMM&utm_medium=app&utm_campaign=donate"
)
true
}
// handle long click on pref_donate_androidacy
prefDonateAndroidacy.onPreferenceLongClickListener =
LongClickablePreference.OnPreferenceLongClickListener { _: Preference? ->
// copy to clipboard
val toastText = requireContext().getString(R.string.link_copied)
clipboard.setPrimaryClip(
ClipData.newPlainText(
toastText,
"https://www.androidacy.com/membership-join/?utm_source=AMMM&utm_medium=app&utm_campaign=donate"
)
)
Toast.makeText(requireContext(), toastText, Toast.LENGTH_SHORT).show()
true
}
}
}
val originalApiKeyRef = arrayOf(
Expand Down Expand Up @@ -510,15 +460,13 @@ class RepoFragment : PreferenceFragmentCompat() {
Preference.OnPreferenceClickListener {
val context = requireContext()
val builder = MaterialAlertDialogBuilder(context)
val input = EditText(context)
input.setHint(R.string.custom_url)
input.setHorizontallyScrolling(true)
input.maxLines = 1
val view = LayoutInflater.from(context).inflate(R.layout.custom_repo_input, null)
builder.setIcon(R.drawable.ic_baseline_add_box_24)
builder.setTitle(R.string.add_repo)
// make link in message clickable
builder.setMessage(R.string.add_repo_message)
builder.setView(input)
builder.setView(view)
val input = view.findViewById<TextInputEditText>(R.id.custom_repo_input_edit)
builder.setPositiveButton("OK") { _: DialogInterface?, _: Int ->
var text = input.text.toString()
text = text.trim { it <= ' ' }
Expand Down Expand Up @@ -571,8 +519,7 @@ class RepoFragment : PreferenceFragmentCompat() {
)
startActivity(intent)
}
val alertDialog = builder.show()
val positiveButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE)
val alertDialog = builder.create()
// validate as they type
input.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(
Expand All @@ -594,42 +541,31 @@ class RepoFragment : PreferenceFragmentCompat() {
if (charSequence.toString().isEmpty()) {
input.error = getString(R.string.empty_field)
if (MainApplication.forceDebugLogging) Timber.d("No input for repo")
positiveButton.isEnabled = false
return
} else if (!charSequence.toString()
.matches("^https://.*".toRegex())
) {
input.error = getString(R.string.invalid_repo_url)
if (MainApplication.forceDebugLogging) Timber.d("Non https link for repo")
positiveButton.isEnabled = false
return
} else if (charSequence.toString().contains(" ")) {
input.error = getString(R.string.invalid_repo_url)
if (MainApplication.forceDebugLogging) Timber.d("Repo url has space")
positiveButton.isEnabled = false
return
} else if (!customRepoManager.canAddRepo(charSequence.toString())) {
input.error = getString(R.string.repo_already_added)
if (MainApplication.forceDebugLogging) Timber.d("Could not add repo for misc reason")
positiveButton.isEnabled = false
return
} else {
// enable ok button
if (MainApplication.forceDebugLogging) Timber.d("Repo URL is ok")
positiveButton.isEnabled = true
return
}
}

override fun afterTextChanged(s: Editable) {}
})
positiveButton.isEnabled = false
val dp10 = MainApplication.INSTANCE!!.lastActivity?.resources?.getDimensionPixelSize(
R.dimen.dp10
) ?: 0
val dp20 = MainApplication.INSTANCE!!.lastActivity?.resources?.getDimensionPixelSize(
R.dimen.dp20
) ?: 0
alertDialog.window!!.setSoftInputMode(20)
alertDialog.window!!.setLayout(
dp20,
dp10
)
alertDialog.show()
true
}
}
Expand Down
33 changes: 33 additions & 0 deletions app/src/main/res/layout/custom_repo_input.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:padding="16dp">

<!-- md3 edit text -->
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/custom_repo_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/custom_url"
android:inputType="textUri"
android:textColorHint="@color/white"
app:boxStrokeColor="@color/white"
app:boxStrokeWidth="1dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
app:layout_constraintTop_toTopOf="parent">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/custom_repo_input_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:inputType="textUri"
android:textColor="@color/white" />

</com.google.android.material.textfield.TextInputLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 4 additions & 0 deletions app/src/main/res/values-v27/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="cornerRadius">@dimen/card_corner_radius</item>
<item name="alertDialogTheme">@style/Theme.MagiskModuleManager.AlertDialog</item>
<!-- md3 theme for text input -->
<item name="editTextStyle">@style/Widget.Material3.TextInputEditText.OutlinedBox</item>
<item name="textInputStyle">@style/Widget.Material3.TextInputLayout.OutlinedBox</item>
</style>
</resources>
Loading

0 comments on commit e0fafde

Please sign in to comment.