Skip to content

Commit f86edc2

Browse files
use md3 switches for prefs w/o java
Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent 23c4bf2 commit f86edc2

15 files changed

Lines changed: 41 additions & 30 deletions

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class AppearanceFragment : PreferenceFragmentCompat() {
5454
throw RuntimeException(getString(R.string.error_encrypted_shared_preferences))
5555
}
5656
setPreferencesFromResource(R.xml.theme_preferences, rootKey)
57-
SettingsActivity.applyMaterial3(preferenceScreen)
5857
val themePreference = findPreference<ListPreference>("pref_theme")
5958
// If transparent theme(s) are set, disable monet
6059
if (themePreference!!.value == "transparent_light") {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class CreditsFragment : PreferenceFragmentCompat() {
4545
}
4646

4747
setPreferencesFromResource(R.xml.credits_preferences, rootKey)
48-
SettingsActivity.applyMaterial3(preferenceScreen)
4948

5049

5150

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class DebugFragment : PreferenceFragmentCompat() {
5454
}
5555
setPreferencesFromResource(R.xml.debugging_preferences, rootKey)
5656

57-
SettingsActivity.applyMaterial3(preferenceScreen)
5857

5958
if (!MainApplication.isDeveloper) {
6059
findPreference<Preference>("pref_disable_low_quality_module_filter")!!.isVisible = false

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class InfoFragment : PreferenceFragmentCompat() {
4545
}
4646

4747
setPreferencesFromResource(R.xml.app_info_preferences, rootKey)
48-
SettingsActivity.applyMaterial3(preferenceScreen)
4948

5049
val clipboard =
5150
requireContext().getSystemService(FoxActivity.CLIPBOARD_SERVICE) as ClipboardManager

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class PrivacyFragment : PreferenceFragmentCompat() {
5050
throw RuntimeException(getString(R.string.error_encrypted_shared_preferences))
5151
}
5252
setPreferencesFromResource(R.xml.privacy_preferences, rootKey)
53-
SettingsActivity.applyMaterial3(preferenceScreen)
5453
// Crash reporting
5554
val crashReportingPreference =
5655
findPreference<TwoStatePreference>("pref_crash_reporting")

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import android.widget.Toast
2121
import androidx.preference.EditTextPreference
2222
import androidx.preference.Preference
2323
import androidx.preference.PreferenceFragmentCompat
24-
import androidx.preference.PreferenceGroup
2524
import androidx.preference.SwitchPreferenceCompat
2625
import androidx.preference.TwoStatePreference
2726
import androidx.room.Room
@@ -70,7 +69,7 @@ class RepoFragment : PreferenceFragmentCompat() {
7069
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.warning)
7170
.setCancelable(false).setMessage(
7271
R.string.androidacy_test_mode_warning
73-
)
72+
)
7473
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
7574
// User clicked OK button
7675
MainApplication.getSharedPreferences("mmm")!!
@@ -115,7 +114,7 @@ class RepoFragment : PreferenceFragmentCompat() {
115114
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.warning)
116115
.setCancelable(false).setMessage(
117116
R.string.androidacy_test_mode_disable_warning
118-
)
117+
)
119118
.setNeutralButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
120119
// User clicked OK button
121120
val mStartActivity =
@@ -174,7 +173,7 @@ class RepoFragment : PreferenceFragmentCompat() {
174173
MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.androidacy_repo_disabled)
175174
.setCancelable(false).setMessage(
176175
R.string.androidacy_repo_disabled_message
177-
)
176+
)
178177
.setPositiveButton(R.string.download_full_app) { _: DialogInterface?, _: Int ->
179178
// User clicked OK button. Open GitHub releases page
180179
val browserIntent = Intent(
@@ -367,7 +366,9 @@ class RepoFragment : PreferenceFragmentCompat() {
367366
// If the key is valid, save it
368367
if (valid) {
369368
originalApiKeyRef[0] = apiKey
370-
RepoManager.getINSTANCE()!!.androidacyRepoData!!.setToken(apiKey)
369+
RepoManager.getINSTANCE()!!.androidacyRepoData!!.setToken(
370+
apiKey
371+
)
371372
MainApplication.getSharedPreferences("androidacy")!!
372373
.edit()
373374
.putString("pref_androidacy_api_token", apiKey)
@@ -422,7 +423,10 @@ class RepoFragment : PreferenceFragmentCompat() {
422423
BaseTransientBottomBar.LENGTH_SHORT
423424
).show()
424425
// Save the original key
425-
MainApplication.INSTANCE!!.getSharedPreferences("androidacy", 0)
426+
MainApplication.INSTANCE!!.getSharedPreferences(
427+
"androidacy",
428+
0
429+
)
426430
.edit().putString(
427431
"pref_androidacy_api_token",
428432
originalApiKeyRef[0]
@@ -848,7 +852,6 @@ class RepoFragment : PreferenceFragmentCompat() {
848852
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
849853
preferenceManager.sharedPreferencesName = "mmm"
850854
setPreferencesFromResource(R.xml.repo_preferences, rootKey)
851-
SettingsActivity.applyMaterial3(preferenceScreen)
852855
setRepoData(RepoManager.MAGISK_ALT_REPO)
853856
setRepoData(RepoManager.ANDROIDACY_MAGISK_REPO_ENDPOINT)
854857
updateCustomRepoList(true)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class SecurityFragment : PreferenceFragmentCompat() {
5252
}
5353

5454
setPreferencesFromResource(R.xml.security_preferences, rootKey)
55-
SettingsActivity.applyMaterial3(preferenceScreen)
5655

5756
findPreference<Preference>("pref_dns_over_https")!!.onPreferenceChangeListener =
5857
Preference.OnPreferenceChangeListener { _: Preference?, v: Any? ->

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import android.widget.Toast
1717
import androidx.fragment.app.FragmentTransaction
1818
import androidx.preference.Preference
1919
import androidx.preference.PreferenceFragmentCompat
20-
import androidx.preference.PreferenceGroup
21-
import androidx.preference.SwitchPreferenceCompat
2220
import androidx.security.crypto.EncryptedSharedPreferences
2321
import androidx.security.crypto.MasterKey
2422
import com.fox2code.foxcompat.app.FoxActivity
@@ -165,7 +163,6 @@ class SettingsActivity : FoxActivity(), LanguageActivity,
165163
throw RuntimeException(getString(R.string.error_encrypted_shared_preferences))
166164
}
167165
setPreferencesFromResource(R.xml.root_preferences, rootKey)
168-
applyMaterial3(preferenceScreen)
169166
// track all non empty values
170167
dataStore.sharedPreferences
171168
// disabled until EncryptedSharedPreferences fixes getAll()
@@ -282,16 +279,6 @@ class SettingsActivity : FoxActivity(), LanguageActivity,
282279
}
283280
}
284281

285-
286-
fun applyMaterial3(p: Preference) {
287-
if (p is PreferenceGroup) {
288-
for (i in 0 until p.preferenceCount) {
289-
applyMaterial3(p.getPreference(i))
290-
}
291-
}
292-
(p as? SwitchPreferenceCompat)?.widgetLayoutResource =
293-
R.layout.preference_material_switch
294-
}
295282
}
296283

297284
override fun onPreferenceStartFragment(

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class UpdateFragment : PreferenceFragmentCompat() {
6060
throw RuntimeException(getString(R.string.error_encrypted_shared_preferences))
6161
}
6262
setPreferencesFromResource(R.xml.update_preferences, rootKey)
63-
SettingsActivity.applyMaterial3(preferenceScreen)
6463
// track all non empty values
6564
val sharedPreferences = dataStore.sharedPreferences
6665
val debugNotification = findPreference<Preference>("pref_background_update_check_debug")

app/src/main/res/xml/debugging_preferences.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
2+
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
3+
xmlns:android="http://schemas.android.com/apk/res/android">
34

45
<PreferenceCategory app:title="@string/debug_cat">
56

67
<SwitchPreferenceCompat
8+
android:widgetLayout="@layout/preference_material_switch"
79
app:defaultValue="false"
810
app:icon="@drawable/ic_baseline_hide_source_24"
911
app:key="pref_show_incompatible"
@@ -12,6 +14,7 @@
1214
app:title="@string/show_incompatible_pref" />
1315

1416
<SwitchPreferenceCompat
17+
android:widgetLayout="@layout/preference_material_switch"
1518
app:defaultValue="false"
1619
app:icon="@drawable/ic_baseline_warning_24"
1720
app:key="pref_disable_low_quality_module_filter"
@@ -20,6 +23,7 @@
2023
app:title="@string/disable_low_quality_module_filter_pref" />
2124

2225
<SwitchPreferenceCompat
26+
android:widgetLayout="@layout/preference_material_switch"
2327
app:defaultValue="false"
2428
app:icon="@drawable/ic_baseline_numbers_24"
2529
app:key="pref_use_magisk_install_command"

0 commit comments

Comments
 (0)