mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
For #9506: Add possibility to navigate to a preference in settings.
This commit is contained in:
parent
91223817c6
commit
20794296dc
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.settings
|
package org.mozilla.fenix.settings
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
@ -15,6 +16,7 @@ import android.widget.Toast
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.NavDirections
|
import androidx.navigation.NavDirections
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
|
import androidx.navigation.fragment.navArgs
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@ -27,8 +29,8 @@ import mozilla.components.concept.sync.OAuthAccount
|
|||||||
import mozilla.components.concept.sync.Profile
|
import mozilla.components.concept.sync.Profile
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.Config
|
import org.mozilla.fenix.Config
|
||||||
import org.mozilla.fenix.HomeActivity
|
|
||||||
import org.mozilla.fenix.FeatureFlags
|
import org.mozilla.fenix.FeatureFlags
|
||||||
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.application
|
import org.mozilla.fenix.ext.application
|
||||||
@ -45,6 +47,7 @@ import kotlin.system.exitProcess
|
|||||||
@Suppress("LargeClass", "TooManyFunctions")
|
@Suppress("LargeClass", "TooManyFunctions")
|
||||||
class SettingsFragment : PreferenceFragmentCompat() {
|
class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
|
private val args by navArgs<SettingsFragmentArgs>()
|
||||||
private lateinit var accountUiView: AccountUiView
|
private lateinit var accountUiView: AccountUiView
|
||||||
|
|
||||||
private val accountObserver = object : AccountObserver {
|
private val accountObserver = object : AccountObserver {
|
||||||
@ -124,6 +127,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||||||
updateMakeDefaultBrowserPreference()
|
updateMakeDefaultBrowserPreference()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("RestrictedApi")
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
|
|
||||||
@ -136,6 +140,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||||||
requireView().findViewById<RecyclerView>(R.id.recycler_view)
|
requireView().findViewById<RecyclerView>(R.id.recycler_view)
|
||||||
?.hideInitialScrollBar(viewLifecycleOwner.lifecycleScope)
|
?.hideInitialScrollBar(viewLifecycleOwner.lifecycleScope)
|
||||||
|
|
||||||
|
if (args.preferenceToScrollTo != null) {
|
||||||
|
scrollToPreference(args.preferenceToScrollTo)
|
||||||
|
}
|
||||||
|
|
||||||
// Consider finish of `onResume` to be the point at which we consider this fragment as 'created'.
|
// Consider finish of `onResume` to be the point at which we consider this fragment as 'created'.
|
||||||
creatingFragment = false
|
creatingFragment = false
|
||||||
}
|
}
|
||||||
|
@ -410,6 +410,11 @@
|
|||||||
android:id="@+id/settingsFragment"
|
android:id="@+id/settingsFragment"
|
||||||
android:name="org.mozilla.fenix.settings.SettingsFragment"
|
android:name="org.mozilla.fenix.settings.SettingsFragment"
|
||||||
android:label="@string/settings_title">
|
android:label="@string/settings_title">
|
||||||
|
<argument
|
||||||
|
android:name="preference_to_scroll_to"
|
||||||
|
android:defaultValue="@null"
|
||||||
|
app:argType="string"
|
||||||
|
app:nullable="true" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_settingsFragment_to_dataChoicesFragment"
|
android:id="@+id/action_settingsFragment_to_dataChoicesFragment"
|
||||||
app:destination="@id/dataChoicesFragment"
|
app:destination="@id/dataChoicesFragment"
|
||||||
|
Loading…
Reference in New Issue
Block a user