mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/2717 - Adds auto signed in state to the accounts onboarding card
This commit is contained in:
parent
06fb88d9b0
commit
d01c2f9121
@ -51,7 +51,7 @@ sealed class AdapterItem {
|
||||
|
||||
object OnboardingHeader : AdapterItem()
|
||||
data class OnboardingSectionHeader(val labelBuilder: (Context) -> String) : AdapterItem()
|
||||
object OnboardingFirefoxAccount : AdapterItem()
|
||||
data class OnboardingFirefoxAccount(val state: OnboardingState) : AdapterItem()
|
||||
object OnboardingThemePicker : AdapterItem()
|
||||
object OnboardingTrackingProtection : AdapterItem()
|
||||
object OnboardingPrivateBrowsing : AdapterItem()
|
||||
@ -72,7 +72,7 @@ sealed class AdapterItem {
|
||||
is TabInCollectionItem -> TabInCollectionViewHolder.LAYOUT_ID
|
||||
OnboardingHeader -> OnboardingHeaderViewHolder.LAYOUT_ID
|
||||
is OnboardingSectionHeader -> OnboardingSectionHeaderViewHolder.LAYOUT_ID
|
||||
OnboardingFirefoxAccount -> OnboardingFirefoxAccountViewHolder.LAYOUT_ID
|
||||
is OnboardingFirefoxAccount -> OnboardingFirefoxAccountViewHolder.LAYOUT_ID
|
||||
OnboardingThemePicker -> OnboardingThemePickerViewHolder.LAYOUT_ID
|
||||
OnboardingTrackingProtection -> OnboardingTrackingProtectionViewHolder.LAYOUT_ID
|
||||
OnboardingPrivateBrowsing -> OnboardingPrivateBrowsingViewHolder.LAYOUT_ID
|
||||
@ -156,6 +156,9 @@ class SessionControlAdapter(
|
||||
is OnboardingSectionHeaderViewHolder -> holder.bind(
|
||||
(items[position] as AdapterItem.OnboardingSectionHeader).labelBuilder
|
||||
)
|
||||
is OnboardingFirefoxAccountViewHolder -> holder.bind(
|
||||
(items[position] as AdapterItem.OnboardingFirefoxAccount).state == OnboardingState.AutoSignedIn
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,21 +70,15 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List<Adapt
|
||||
OnboardingState.SignedOut -> {
|
||||
listOf(
|
||||
AdapterItem.OnboardingSectionHeader { it.getString(R.string.onboarding_fxa_section_header) },
|
||||
AdapterItem.OnboardingFirefoxAccount
|
||||
AdapterItem.OnboardingFirefoxAccount(onboardingState)
|
||||
)
|
||||
}
|
||||
OnboardingState.AutoSignedIn -> {
|
||||
listOf(
|
||||
AdapterItem.OnboardingSectionHeader { it.getString(R.string.onboarding_fxa_section_header) },
|
||||
AdapterItem.OnboardingFirefoxAccount
|
||||
)
|
||||
}
|
||||
OnboardingState.ManuallySignedIn -> {
|
||||
listOf(
|
||||
AdapterItem.OnboardingSectionHeader { it.getString(R.string.onboarding_fxa_section_header) },
|
||||
AdapterItem.OnboardingFirefoxAccount
|
||||
AdapterItem.OnboardingFirefoxAccount(onboardingState)
|
||||
)
|
||||
}
|
||||
else -> listOf()
|
||||
})
|
||||
|
||||
items.addAll(listOf(
|
||||
|
@ -11,18 +11,31 @@ import kotlinx.android.synthetic.main.onboarding_firefox_account.view.*
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||
|
||||
class OnboardingFirefoxAccountViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
|
||||
class OnboardingFirefoxAccountViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
||||
init {
|
||||
val appName = view.context.getString(R.string.app_name)
|
||||
view.header_text.text = view.context.getString(R.string.onboarding_firefox_account_header, appName)
|
||||
|
||||
view.turn_on_sync_button.setOnClickListener {
|
||||
val directions = HomeFragmentDirections.actionHomeFragmentToTurnOnSyncFragment()
|
||||
Navigation.findNavController(view).navigate(directions)
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(autoSignedIn: Boolean) {
|
||||
val appName = view.context.getString(R.string.app_name)
|
||||
|
||||
val icon =
|
||||
if (autoSignedIn) view.context.getDrawable(R.drawable.ic_onboarding_avatar_anonymous)
|
||||
else view.context.getDrawable(R.drawable.ic_onboarding_firefox_accounts)
|
||||
|
||||
view.header_text.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null)
|
||||
view.header_text.text =
|
||||
if (!autoSignedIn) view.context.getString(R.string.onboarding_firefox_account_auto_signin_header)
|
||||
else view.context.getString(R.string.onboarding_firefox_account_header, appName)
|
||||
|
||||
view.turn_on_sync_button.visibility = if (autoSignedIn) View.GONE else View.VISIBLE
|
||||
view.stay_signed_in_button.visibility = if (autoSignedIn) View.VISIBLE else View.GONE
|
||||
view.sign_out_button.visibility = if (autoSignedIn) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val LAYOUT_ID = R.layout.onboarding_firefox_account
|
||||
}
|
||||
|
47
app/src/main/res/drawable/ic_onboarding_avatar_anonymous.xml
Normal file
47
app/src/main/res/drawable/ic_onboarding_avatar_anonymous.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M17.6655,14.2092C16.1843,12.4998 14.1333,14.8 11.9997,14.8C9.8675,14.8 7.8151,12.4998 6.3339,14.2092C5.9139,14.6936 5.8803,15.3992 6.2401,15.9284C7.4959,17.7764 9.5959,19 11.9997,19C14.4035,19 16.5035,17.7764 17.7593,15.9284C18.1205,15.3992 18.0855,14.6936 17.6655,14.2092M16.25,9.25C16.25,6.9026 14.3474,5 12,5C9.6526,5 7.75,6.9026 7.75,9.25C7.75,11.5974 9.6526,13.5 12,13.5C14.3474,13.5 16.25,11.5974 16.25,9.25Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillType="nonZero"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startY="21.265238"
|
||||
android:startX="10.078417"
|
||||
android:endY="-6.155523"
|
||||
android:endX="18.457676"
|
||||
android:type="linear">
|
||||
<item android:offset="0" android:color="#FF00B3F4"/>
|
||||
<item android:offset="0.16" android:color="#FF07B8ED"/>
|
||||
<item android:offset="0.41" android:color="#FF1AC6D8"/>
|
||||
<item android:offset="0.7" android:color="#FF39DCB7"/>
|
||||
<item android:offset="0.76" android:color="#FF3FE1B0"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:pathData="M12,22C6.4772,22 2,17.5228 2,12C2,6.4772 6.4772,2 12,2C17.5228,2 22,6.4772 22,12C21.9939,17.5203 17.5203,21.9939 12,22L12,22ZM12,4C7.5817,4 4,7.5817 4,12C4,16.4183 7.5817,20 12,20C16.4183,20 20,16.4183 20,12C19.995,7.5838 16.4162,4.005 12,4Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillType="nonZero"
|
||||
android:strokeColor="#00000000">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:startY="25.236055"
|
||||
android:startX="7.735972"
|
||||
android:endY="-13.936461"
|
||||
android:endX="26.325832"
|
||||
android:type="linear">
|
||||
<item android:offset="0" android:color="#FF00B3F4"/>
|
||||
<item android:offset="0.16" android:color="#FF07B8ED"/>
|
||||
<item android:offset="0.41" android:color="#FF1AC6D8"/>
|
||||
<item android:offset="0.7" android:color="#FF39DCB7"/>
|
||||
<item android:offset="0.76" android:color="#FF3FE1B0"/>
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
</vector>
|
@ -42,4 +42,49 @@
|
||||
android:textColor="?neutral"
|
||||
android:textSize="14sp" />
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/stay_signed_in_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:backgroundTint="@color/onboarding_card_button_background_dark"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:padding="10dp"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:textStyle="bold"
|
||||
android:gravity="center"
|
||||
android:text="@string/onboarding_firefox_account_stay_signed_in"
|
||||
android:textColor="?neutral"
|
||||
android:textSize="14sp" />
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/sign_out_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:padding="10dp"
|
||||
android:visibility="gone">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:gravity="center"
|
||||
android:text="@string/onboarding_firefox_account_sign_out"
|
||||
android:textColor="?neutral"
|
||||
android:textSize="12sp" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
@ -34,8 +34,15 @@
|
||||
<!-- text for the firefox account onboarding card header
|
||||
The first parameter is the name of the app defined in app_name (for example: Firefox Preview) -->
|
||||
<string name="onboarding_firefox_account_header" translatable="false">Get the most out of %s.</string>
|
||||
<!-- text for the button to sign into your Firefox account -->
|
||||
<!-- text for the firefox account onboarding card header when we detect you're already signed in to
|
||||
another Firefox browser. (The word `Firefox` should not be translated -->
|
||||
<string name="onboarding_firefox_account_auto_signin_header" translatable="false">You are signed in to another Firefox browser on this phone.</string>
|
||||
<!-- text for the button to sign into your Firefox account. The word "Firefox" should not be translated -->
|
||||
<string name="onboarding_firefox_account_sign_in">Sign in to Firefox</string>
|
||||
<!-- text for the button to stay signed into your Firefox account. -->
|
||||
<string name="onboarding_firefox_account_stay_signed_in">Stay signed in</string>
|
||||
<!-- text for the button to sign out of your Firefox account. -->
|
||||
<string name="onboarding_firefox_account_sign_out">Sign out</string>
|
||||
<!-- text for the tracking protection onboarding card header -->
|
||||
<string name="onboarding_tracking_protection_header" translatable="false">Protect yourself</string>
|
||||
<!-- text for the tracking protection card description
|
||||
|
Loading…
Reference in New Issue
Block a user