Skip to content

Commit

Permalink
For mozilla-mobile#15403 - Adds a secret debug info screen in settings (
Browse files Browse the repository at this point in the history
mozilla-mobile#15540)

Co-authored-by: Elise Richards <erichards@mozilla.com>
  • Loading branch information
boek and eliserichards committed Dec 11, 2020
1 parent 1ca34a2 commit cf61c10
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* 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.Preference
import androidx.preference.PreferenceFragmentCompat
import com.leanplum.Leanplum
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.showToolbar

class SecretDebugSettingsFragment : PreferenceFragmentCompat() {

override fun onResume() {
super.onResume()
showToolbar(getString(R.string.preferences_debug_info))
}

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.secret_info_settings_preferences, rootKey)

requirePreference<Preference>(R.string.pref_key_leanplum_user_id).apply {
summary = Leanplum.getUserId().let {
if (it.isNullOrEmpty()) {
"No User Id"
} else {
it
}
}
}

requirePreference<Preference>(R.string.pref_key_leanplum_device_id).apply {
summary = Leanplum.getDeviceId().let {
if (it.isNullOrEmpty()) {
"No Device Id"
} else {
it
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ 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 SecretSettingsFragment : PreferenceFragmentCompat() {

override fun onResume() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
resources.getString(R.string.pref_key_debug_settings) -> {
SettingsFragmentDirections.actionSettingsFragmentToSecretSettingsFragment()
}
resources.getString(R.string.pref_key_secret_debug_info) -> {
SettingsFragmentDirections.actionSettingsFragmentToSecretInfoSettingsFragment()
}
resources.getString(R.string.pref_key_override_amo_collection) -> {
val context = requireContext()
val dialogView = LayoutInflater.from(context).inflate(R.layout.amo_collection_override_dialog, null)
Expand Down Expand Up @@ -416,6 +419,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
findPreference<Preference>(
getPreferenceKey(R.string.pref_key_debug_settings)
)?.isVisible = requireContext().settings().showSecretDebugMenuThisSession
findPreference<Preference>(
getPreferenceKey(R.string.pref_key_secret_debug_info)
)?.isVisible = requireContext().settings().showSecretDebugMenuThisSession

setupAmoCollectionOverridePreference(requireContext().settings())
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right" />
<action
android:id="@+id/action_settingsFragment_to_secretInfoSettingsFragment"
app:destination="@id/secretInfoSettingsFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right" />
<action
android:id="@+id/action_settingsFragment_to_customizationFragment"
app:destination="@id/customizationFragment"
Expand Down Expand Up @@ -610,6 +617,10 @@
android:id="@+id/secretSettingsPreference"
android:name="org.mozilla.fenix.settings.SecretSettingsFragment"
android:label="@string/preferences_debug_settings" />
<fragment
android:id="@+id/secretInfoSettingsFragment"
android:name="org.mozilla.fenix.settings.SecretDebugSettingsFragment"
android:label="@string/preferences_debug_info" />
<fragment
android:id="@+id/crashReporterFragment"
android:name="org.mozilla.fenix.crashes.CrashReporterFragment"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/preference_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,9 @@
<string name="pref_key_camera_permissions_needed" translatable="false">pref_key_camera_permissions_needed</string>

<string name="pref_key_return_to_browser" translatable="false">pref_key_return_to_browser</string>

<!-- Secret Info Setting Keys -->
<string name="pref_key_secret_debug_info" translatable="false">pref_key_secret_debug_info</string>
<string name="pref_key_leanplum_user_id" translatable="false">pref_key_leanplum_user_id</string>
<string name="pref_key_leanplum_device_id" translatable="false">pref_key_leanplum_device_id</string>
</resources>
12 changes: 12 additions & 0 deletions app/src/main/res/values/static_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@

<!-- Label for the secret settings preference -->
<string name="preferences_debug_settings">Secret Settings</string>
<!-- Label for the secret settings preference -->
<string name="preferences_debug_info" translatable="false">Secret Debug Info</string>
<!-- Label for the show top frequently visited sites preference -->
<string name="preferences_debug_settings_enable_top_frecent_sites">Show Top Frequently Visited Sites</string>
<!-- Label for the wait until first paint preference -->
<string name="preferences_debug_settings_wait_first_paint">Wait Until First Paint To Show Page Content</string>

<!-- Label for showing Synced Tabs in the tabs tray -->
<string name="preferences_debug_synced_tabs_tabs_tray">Show Synced Tabs in the tabs tray</string>

Expand All @@ -56,4 +63,9 @@
<string name="mp_dialog_close_transfer">Close</string>
<string name="mp_dialog_title_transfer_failure">Transfer failed</string>
<string name="mp_dialog_message_transfer_failure">An unknown error occurred and logins could not be transferred.</string>

<!-- Secret debug info strings -->
<string name="debug_info_telemetry_title" translatable="false">Telemetry</string>
<string name="debug_info_leanplum_user_id" translatable="false">Leanplum User Id</string>
<string name="debug_info_leanplum_device_id" translatable="false">Leanplum Device Id</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,10 @@
android:key="@string/pref_key_debug_settings"
android:title="@string/preferences_debug_settings"
app:isPreferenceVisible="false" />
<androidx.preference.Preference
android:icon="@drawable/ic_info"
android:key="@string/pref_key_secret_debug_info"
android:title="@string/preferences_debug_info"
app:isPreferenceVisible="false" />
</androidx.preference.PreferenceCategory>
</androidx.preference.PreferenceScreen>
19 changes: 19 additions & 0 deletions app/src/main/res/xml/secret_info_settings_preferences.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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">
<PreferenceCategory
android:title="@string/debug_info_telemetry_title">
<Preference
android:key="@string/pref_key_leanplum_user_id"
android:title="@string/debug_info_leanplum_user_id"
android:enabled="false" />
<Preference
android:key="@string/pref_key_leanplum_device_id"
android:title="@string/debug_info_leanplum_device_id"
android:enabled="false" />
</PreferenceCategory>

</PreferenceScreen>

0 comments on commit cf61c10

Please sign in to comment.