2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-09 19:10:42 +00:00

Initial view for the "Turn on Sync" fragment

UX: https://mozilla.invisionapp.com/share/QSR2F8UD4PN#/screens/357470308
This commit is contained in:
vladikoff 2019-04-21 22:07:36 -04:00 committed by Emily Kager
parent aa6d36dda9
commit e067ffbbf6
8 changed files with 105 additions and 9 deletions

View File

@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- #113 - Added QR code scanner - #113 - Added QR code scanner
- #975 - Added telemetry for preference switches - #975 - Added telemetry for preference switches
- #1955 - Added a confirmation dialog for QR code and barcode searches - #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 ### Changed
- #1429 - Updated site permissions ui for MVP - #1429 - Updated site permissions ui for MVP

View File

@ -188,15 +188,8 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
private fun getClickListenerForSignIn(): OnPreferenceClickListener { private fun getClickListenerForSignIn(): OnPreferenceClickListener {
return OnPreferenceClickListener { return OnPreferenceClickListener {
requireComponents.services.accountsAuthFeature.beginAuthentication() val directions = SettingsFragmentDirections.actionSettingsFragmentToSyncFragment()
// TODO The sign-in web content populates session history, Navigation.findNavController(view!!).navigate(directions)
// 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 true
} }
} }

View File

@ -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<Preference>(context!!.getPreferenceKey(R.string.pref_key_sync_sign_in))
val preferenceNewAccount =
findPreference<Preference>(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
}
}
}

View File

@ -0,0 +1,13 @@
<?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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M11.586,11l-1.293,-1.293a1,1 0,0 1,1.414 -1.414l3,3a1,1 0,0 1,0 1.414l-3,3a1,1 0,0 1,-1.414 -1.414L11.586,13H3a1,1 0,0 1,0 -2h8.586zM7,8a1,1 0,1 1,-2 0V6a4,4 0,0 1,4 -4h8a4,4 0,0 1,4 4v12a4,4 0,0 1,-4 4H9a4,4 0,0 1,-4 -4v-2a1,1 0,0 1,2 0v2a2,2 0,0 0,2 2h8a2,2 0,0 0,2 -2V6a2,2 0,0 0,-2 -2H9a2,2 0,0 0,-2 2v2z"
android:fillColor="?primaryText" />
</vector>

View File

@ -226,6 +226,9 @@
<action <action
android:id="@+id/action_settingsFragment_to_searchEngineFragment" android:id="@+id/action_settingsFragment_to_searchEngineFragment"
app:destination="@id/searchEngineFragment" /> app:destination="@id/searchEngineFragment" />
<action
android:id="@+id/action_settingsFragment_to_syncFragment"
app:destination="@id/syncFragment" />
<action <action
android:id="@+id/action_settingsFragment_to_aboutFragment" android:id="@+id/action_settingsFragment_to_aboutFragment"
app:destination="@id/aboutFragment" /> app:destination="@id/aboutFragment" />
@ -261,6 +264,16 @@
android:name="org.mozilla.fenix.settings.SearchEngineFragment" android:name="org.mozilla.fenix.settings.SearchEngineFragment"
android:label="SearchEngineFragment" /> android:label="SearchEngineFragment" />
<fragment
android:id="@+id/syncFragment"
android:name="org.mozilla.fenix.settings.TurnOnSyncFragment"
android:label="SyncFragment">
<action
android:id="@+id/action_settingsFragment_to_browserFragment"
app:destination="@id/browserFragment"
app:popUpTo="@+id/settingsFragment" />
</fragment>
<fragment <fragment
android:id="@+id/aboutFragment" android:id="@+id/aboutFragment"
android:name="org.mozilla.fenix.settings.AboutFragment" android:name="org.mozilla.fenix.settings.AboutFragment"

View File

@ -35,6 +35,8 @@
<string name="pref_key_sync_bookmarks" translatable="false">pref_key_sync_bookmarks</string> <string name="pref_key_sync_bookmarks" translatable="false">pref_key_sync_bookmarks</string>
<string name="pref_key_sign_out" translatable="false">pref_key_sign_out</string> <string name="pref_key_sign_out" translatable="false">pref_key_sign_out</string>
<string name="pref_key_cached_account" translatable="false">pref_key_cached_account</string> <string name="pref_key_cached_account" translatable="false">pref_key_cached_account</string>
<string name="pref_key_sync_sign_in" translatable="false">pref_key_sync_sign_in</string>
<string name="pref_key_sync_create_account" translatable="false">pref_key_sync_create_account</string>
<!-- Search Settings --> <!-- Search Settings -->
<string name="pref_key_show_search_suggestions" translatable="false">pref_key_show_search_suggestions</string> <string name="pref_key_show_search_suggestions" translatable="false">pref_key_show_search_suggestions</string>

View File

@ -179,6 +179,14 @@
<!-- Preference switch for app health report. The first parameter is the name of the application (For example: Fenix) --> <!-- Preference switch for app health report. The first parameter is the name of the application (For example: Fenix) -->
<string name="preferences_fenix_health_report">%s health report</string> <string name="preferences_fenix_health_report">%s health report</string>
<!-- Turn On Sync Preferences -->
<!-- Header of the Turn on Sync preference view -->
<string name="preferences_sync">Turn on Sync</string>
<!-- Preference for account login -->
<string name="preferences_sync_sign_in">Sign in</string>
<!-- Preference for account creation -->
<string name="preferences_sync_create_account">Create an account</string>
<!-- Theme Preferences --> <!-- Theme Preferences -->
<!-- Preference for using light theme --> <!-- Preference for using light theme -->
<string name="preference_light_theme">Light</string> <string name="preference_light_theme">Light</string>

View File

@ -0,0 +1,16 @@
<?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/. -->
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.preference.Preference
android:key="@string/pref_key_sync_sign_in"
android:title="@string/preferences_sync_sign_in"
android:icon="@drawable/ic_sign_in" />
<androidx.preference.Preference
android:key="@string/pref_key_sync_create_account"
android:title="@string/preferences_sync_create_account"
android:icon="@drawable/ic_new" />
</androidx.preference.PreferenceScreen>