diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt index 3655412f23..cf39033bfb 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt @@ -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 + ) } } } diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlUIView.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlUIView.kt index 8b2b0bf13b..680f846e31 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlUIView.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlUIView.kt @@ -70,21 +70,15 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List { 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( diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingFirefoxAccountViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingFirefoxAccountViewHolder.kt index 442a2666d5..e033260af2 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingFirefoxAccountViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingFirefoxAccountViewHolder.kt @@ -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 } diff --git a/app/src/main/res/drawable/ic_onboarding_avatar_anonymous.xml b/app/src/main/res/drawable/ic_onboarding_avatar_anonymous.xml new file mode 100644 index 0000000000..1c9d76a104 --- /dev/null +++ b/app/src/main/res/drawable/ic_onboarding_avatar_anonymous.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/onboarding_firefox_account.xml b/app/src/main/res/layout/onboarding_firefox_account.xml index d13a71d1af..3658eda9f9 100644 --- a/app/src/main/res/layout/onboarding_firefox_account.xml +++ b/app/src/main/res/layout/onboarding_firefox_account.xml @@ -42,4 +42,49 @@ android:textColor="?neutral" android:textSize="14sp" /> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/static_strings.xml b/app/src/main/res/values/static_strings.xml index c4a4077f73..e0fe438464 100644 --- a/app/src/main/res/values/static_strings.xml +++ b/app/src/main/res/values/static_strings.xml @@ -34,8 +34,15 @@ Get the most out of %s. - + + You are signed in to another Firefox browser on this phone. + Sign in to Firefox + + Stay signed in + + Sign out Protect yourself