Skip to content

Commit

Permalink
Add search current/home region to debug screen. (mozilla-mobile#17015)
Browse files Browse the repository at this point in the history
  • Loading branch information
pocmo committed Dec 15, 2020
1 parent d0b09b7 commit 46813dd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.leanplum.Leanplum
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.requireComponents
import org.mozilla.fenix.ext.showToolbar

class SecretDebugSettingsFragment : PreferenceFragmentCompat() {
Expand All @@ -21,6 +22,8 @@ class SecretDebugSettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.secret_info_settings_preferences, rootKey)

val store = requireComponents.core.store

requirePreference<Preference>(R.string.pref_key_leanplum_user_id).apply {
summary = Leanplum.getUserId().let {
if (it.isNullOrEmpty()) {
Expand All @@ -40,5 +43,13 @@ class SecretDebugSettingsFragment : PreferenceFragmentCompat() {
}
}
}

requirePreference<Preference>(R.string.pref_key_search_region_home).apply {
summary = store.state.search.region?.home ?: "Unknown"
}

requirePreference<Preference>(R.string.pref_key_search_region_current).apply {
summary = store.state.search.region?.current ?: "Unknown"
}
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/values/preference_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,6 @@
<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>
<string name="pref_key_search_region_home" translatable="false">pref_key_search_region_home</string>
<string name="pref_key_search_region_current" translatable="false">pref_key_search_region_current</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/static_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@
<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>
<string name="debug_info_search_title" translatable="false">Search</string>
<string name="debug_info_region_home" translatable="false">Home region</string>
<string name="debug_info_region_current" translatable="false">Current region</string>
</resources>
13 changes: 13 additions & 0 deletions app/src/main/res/xml/secret_info_settings_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@
android:enabled="false" />
</PreferenceCategory>

<PreferenceCategory
android:title="@string/debug_info_search_title">
<Preference
android:key="@string/pref_key_search_region_home"
android:title="@string/debug_info_region_home"
android:enabled="false" />
<Preference
android:key="@string/pref_key_search_region_current"
android:title="@string/debug_info_region_current"
android:enabled="false" />
</PreferenceCategory>


</PreferenceScreen>

0 comments on commit 46813dd

Please sign in to comment.