forked from mozilla-mobile/fenix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added secret debug menu to override the push server URL (mozilla-mobi…
…le#24170) - Created a new "sync debug" pref screen to hold the Fxa, Sync, and Push server override prefs. They were taking a lot of screen space on the top-level settings menu as individual items - Added button on that screen to quit FF which is needed to apply the changes. - This is definitely not the nicest UI, but hopefully QA can just override the prefs once save them in an emulator and never have to go back to this screen. - I do think this is a nicer UI than before, where FF would quit after a change to any of the prefs. That forces you to restart FF 3 times if you wanted to override all 3 server URLs.
- Loading branch information
Showing
10 changed files
with
165 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
app/src/main/java/org/mozilla/fenix/settings/SyncDebugFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.fenix.settings | ||
|
||
import android.os.Bundle | ||
import androidx.preference.EditTextPreference | ||
import androidx.preference.Preference | ||
import androidx.preference.Preference.OnPreferenceClickListener | ||
import androidx.preference.PreferenceFragmentCompat | ||
import kotlin.system.exitProcess | ||
import mozilla.components.support.base.log.logger.Logger | ||
import org.mozilla.fenix.R | ||
import org.mozilla.fenix.ext.settings | ||
import org.mozilla.fenix.ext.showToolbar | ||
|
||
/** | ||
* Lets the user customize Private browsing options. | ||
*/ | ||
class SyncDebugFragment : PreferenceFragmentCompat() { | ||
private val logger = Logger("SyncDebugFragment") | ||
private var hasChanges = false | ||
|
||
private val preferenceUpdater = object : StringSharedPreferenceUpdater() { | ||
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean { | ||
return super.onPreferenceChange(preference, newValue).also { | ||
hasChanges = true | ||
updateMenu() | ||
} | ||
} | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
showToolbar(getString(R.string.preferences_sync_debug)) | ||
} | ||
|
||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { | ||
setPreferencesFromResource(R.xml.sync_debug_preferences, rootKey) | ||
requirePreference<EditTextPreference>(R.string.pref_key_override_fxa_server).let { pref -> | ||
pref.setOnBindEditTextListener { it.setSingleLine() } | ||
pref.onPreferenceChangeListener = preferenceUpdater | ||
} | ||
requirePreference<EditTextPreference>(R.string.pref_key_override_sync_tokenserver).let { pref -> | ||
pref.setOnBindEditTextListener { it.setSingleLine() } | ||
pref.onPreferenceChangeListener = preferenceUpdater | ||
} | ||
requirePreference<EditTextPreference>(R.string.pref_key_override_push_server).let { pref -> | ||
pref.setOnBindEditTextListener { it.setSingleLine() } | ||
pref.onPreferenceChangeListener = preferenceUpdater | ||
} | ||
requirePreference<Preference>(R.string.pref_key_sync_debug_quit).let { pref -> | ||
pref.onPreferenceClickListener = OnPreferenceClickListener { | ||
// Copied from StudiesView. This feels like a dramatic way to | ||
// quit, is there a better way? | ||
exitProcess(0) | ||
} | ||
} | ||
updateMenu() | ||
} | ||
|
||
private fun updateMenu() { | ||
val settings = requireContext().settings() | ||
requirePreference<EditTextPreference>(R.string.pref_key_override_fxa_server).let { | ||
it.summary = settings.overrideFxAServer.ifEmpty { null } | ||
} | ||
requirePreference<EditTextPreference>(R.string.pref_key_override_sync_tokenserver).let { | ||
it.summary = settings.overrideSyncTokenServer.ifEmpty { null } | ||
} | ||
requirePreference<EditTextPreference>(R.string.pref_key_override_push_server).let { | ||
it.summary = settings.overridePushServer.ifEmpty { null } | ||
} | ||
requirePreference<Preference>(R.string.pref_key_sync_debug_quit).let { pref -> | ||
pref.isVisible = hasChanges | ||
} | ||
|
||
// val accountConnected = | ||
// requireComponents.backgroundServices.accountManager.authenticatedAccount() == null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- This Source Code Form is subject to the terms of the Mozilla Public | ||
- License, v. 2.0. If a copy of the MPL was not distributed with this | ||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> | ||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
<androidx.preference.EditTextPreference | ||
android:key="@string/pref_key_override_fxa_server" | ||
android:title="@string/preferences_override_fxa_server" | ||
android:inputType="textUri" | ||
app:iconSpaceReserved="false" /> | ||
<androidx.preference.EditTextPreference | ||
android:key="@string/pref_key_override_sync_tokenserver" | ||
android:title="@string/preferences_override_sync_tokenserver" | ||
android:inputType="textUri" | ||
app:iconSpaceReserved="false" /> | ||
<androidx.preference.EditTextPreference | ||
android:key="@string/pref_key_override_push_server" | ||
android:title="@string/preferences_override_push_server" | ||
android:inputType="textUri" | ||
app:iconSpaceReserved="false" /> | ||
<androidx.preference.Preference | ||
android:key="@string/pref_key_sync_debug_quit" | ||
android:title="@string/preferences_sync_debug_quit_button_title" | ||
android:summary="@string/preferences_sync_debug_quit_button_summary" | ||
android:icon="@drawable/ic_close" | ||
app:isPreferenceVisible="false" /> | ||
</PreferenceScreen> |