diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6cfd750..7cada00e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - #113 - Added QR code scanner - #975 - Added telemetry for preference switches - #1955 - Added a confirmation dialog for QR code and barcode searches +- #1874 - Added a "Turn on Sync" fragment for Firefox Accounts login and sign up ### Changed - #1429 - Updated site permissions ui for MVP diff --git a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt index eb7f2ecb8..8df75d5d4 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/SettingsFragment.kt @@ -188,15 +188,8 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse private fun getClickListenerForSignIn(): OnPreferenceClickListener { return OnPreferenceClickListener { - requireComponents.services.accountsAuthFeature.beginAuthentication() - // TODO The sign-in web content populates session history, - // so pressing "back" after signing in won't take us back into the settings screen, but rather up the - // session history stack. - // We could auto-close this tab once we get to the end of the authentication process? - // Via an interceptor, perhaps. - view?.let { - (activity as HomeActivity).openToBrowser(BrowserDirection.FromSettings) - } + val directions = SettingsFragmentDirections.actionSettingsFragmentToSyncFragment() + Navigation.findNavController(view!!).navigate(directions) true } } diff --git a/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt new file mode 100644 index 000000000..dd3cb51de --- /dev/null +++ b/app/src/main/java/org/mozilla/fenix/settings/TurnOnSyncFragment.kt @@ -0,0 +1,50 @@ +/* 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.appcompat.app.AppCompatActivity +import androidx.preference.Preference +import androidx.preference.PreferenceFragmentCompat +import org.mozilla.fenix.BrowserDirection +import org.mozilla.fenix.HomeActivity +import org.mozilla.fenix.R +import org.mozilla.fenix.ext.getPreferenceKey +import org.mozilla.fenix.ext.requireComponents + +class TurnOnSyncFragment : PreferenceFragmentCompat() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + (activity as AppCompatActivity).title = getString(R.string.preferences_sync) + (activity as AppCompatActivity).supportActionBar?.show() + } + + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { + setPreferencesFromResource(R.xml.turn_on_sync_preferences, rootKey) + + val preferenceSignIn = + findPreference(context!!.getPreferenceKey(R.string.pref_key_sync_sign_in)) + val preferenceNewAccount = + findPreference(context!!.getPreferenceKey(R.string.pref_key_sync_create_account)) + preferenceSignIn?.onPreferenceClickListener = getClickListenerForSignIn() + preferenceNewAccount?.onPreferenceClickListener = getClickListenerForSignIn() + } + + private fun getClickListenerForSignIn(): Preference.OnPreferenceClickListener { + return Preference.OnPreferenceClickListener { + requireComponents.services.accountsAuthFeature.beginAuthentication() + // TODO The sign-in web content populates session history, + // so pressing "back" after signing in won't take us back into the settings screen, but rather up the + // session history stack. + // We could auto-close this tab once we get to the end of the authentication process? + // Via an interceptor, perhaps. + view?.let { + (activity as HomeActivity).openToBrowser(BrowserDirection.FromSettings) + } + true + } + } +} diff --git a/app/src/main/res/drawable/ic_sign_in.xml b/app/src/main/res/drawable/ic_sign_in.xml new file mode 100644 index 000000000..e02a2ef30 --- /dev/null +++ b/app/src/main/res/drawable/ic_sign_in.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 47d136e45..a7469568f 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -226,6 +226,9 @@ + @@ -261,6 +264,16 @@ android:name="org.mozilla.fenix.settings.SearchEngineFragment" android:label="SearchEngineFragment" /> + + + + pref_key_sync_bookmarks pref_key_sign_out pref_key_cached_account + pref_key_sync_sign_in + pref_key_sync_create_account pref_key_show_search_suggestions diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0c22c4717..a0b38a866 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -179,6 +179,14 @@ %s health report + + + Turn on Sync + + Sign in + + Create an account + Light diff --git a/app/src/main/res/xml/turn_on_sync_preferences.xml b/app/src/main/res/xml/turn_on_sync_preferences.xml new file mode 100644 index 000000000..a6fb9fbc8 --- /dev/null +++ b/app/src/main/res/xml/turn_on_sync_preferences.xml @@ -0,0 +1,16 @@ + + + + + + +