Initial view for the "Turn on Sync" fragment
UX: https://mozilla.invisionapp.com/share/QSR2F8UD4PN#/screens/357470308nightly-build-test
parent
aa6d36dda9
commit
e067ffbbf6
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
@ -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>
|
Loading…
Reference in New Issue