This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #2593: FxA automatic sign-in integration
- Loading branch information
Showing
10 changed files
with
202 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...a/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingAutomaticSignInViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* 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.home.sessioncontrol.viewholders.onboarding | ||
|
||
import android.view.View | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.google.android.material.snackbar.Snackbar | ||
import kotlinx.android.synthetic.main.onboarding_automatic_signin.view.turn_on_sync_button | ||
import kotlinx.android.synthetic.main.onboarding_automatic_signin.view.header_text | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import mozilla.components.service.fxa.sharing.ShareableAccount | ||
import org.mozilla.fenix.R | ||
import org.mozilla.fenix.components.FenixSnackbar | ||
import org.mozilla.fenix.ext.components | ||
|
||
class OnboardingAutomaticSignInViewHolder(private val view: View) : RecyclerView.ViewHolder(view) { | ||
private lateinit var shareableAccount: ShareableAccount | ||
|
||
init { | ||
view.turn_on_sync_button.setOnClickListener { | ||
it.turn_on_sync_button.text = it.context.getString( | ||
R.string.onboarding_firefox_account_signing_in | ||
) | ||
it.turn_on_sync_button.isEnabled = false | ||
|
||
CoroutineScope(Dispatchers.Main).launch { | ||
val result = view.context.components.backgroundServices.accountManager | ||
.signInWithShareableAccountAsync(shareableAccount).await() | ||
if (result) { | ||
// Success. | ||
} else { | ||
// Failed to sign-in (either network problem, or bad credentials). Allow to try again. | ||
it.turn_on_sync_button.text = it.context.getString( | ||
R.string.onboarding_firefox_account_auto_signin_confirm | ||
) | ||
it.turn_on_sync_button.isEnabled = true | ||
FenixSnackbar.make(it, Snackbar.LENGTH_SHORT).setText( | ||
it.context.getString(R.string.onboarding_firefox_account_automatic_signin_failed) | ||
).show() | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun bind(account: ShareableAccount) { | ||
shareableAccount = account | ||
view.header_text.text = view.context.getString( | ||
R.string.onboarding_firefox_account_auto_signin_header_2, account.email | ||
) | ||
} | ||
|
||
companion object { | ||
const val LAYOUT_ID = R.layout.onboarding_automatic_signin | ||
} | ||
} |
55 changes: 0 additions & 55 deletions
55
...la/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingFirefoxAccountViewHolder.kt
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...illa/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingManualSignInViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* 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.home.sessioncontrol.viewholders.onboarding | ||
|
||
import android.view.View | ||
import androidx.navigation.Navigation | ||
import androidx.recyclerview.widget.RecyclerView | ||
import kotlinx.android.synthetic.main.onboarding_manual_signin.view.* | ||
import org.mozilla.fenix.R | ||
import org.mozilla.fenix.home.HomeFragmentDirections | ||
|
||
class OnboardingManualSignInViewHolder(private val view: View) : RecyclerView.ViewHolder(view) { | ||
init { | ||
view.turn_on_sync_button.setOnClickListener { | ||
val directions = HomeFragmentDirections.actionHomeFragmentToTurnOnSyncFragment() | ||
Navigation.findNavController(view).navigate(directions) | ||
} | ||
} | ||
|
||
fun bind() { | ||
val appName = view.context.getString(R.string.app_name) | ||
view.header_text.text = view.context.getString(R.string.onboarding_firefox_account_header, appName) | ||
} | ||
|
||
companion object { | ||
const val LAYOUT_ID = R.layout.onboarding_manual_signin | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?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/. --> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
style="@style/OnboardingCardDark" | ||
android:id="@+id/onboarding_card" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<androidx.appcompat.widget.AppCompatTextView | ||
android:id="@+id/header_text" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginBottom="14dp" | ||
tools:text="@string/onboarding_firefox_account_auto_signin_header_2" | ||
android:drawableStart="@drawable/ic_onboarding_avatar_anonymous" | ||
android:drawablePadding="12dp" | ||
android:textAppearance="@style/Header16TextStyle" | ||
android:textColor="@color/onboarding_card_primary_text_dark" /> | ||
|
||
<Button | ||
android:id="@+id/turn_on_sync_button" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:background="@drawable/button_background" | ||
android:clickable="true" | ||
android:focusable="true" | ||
android:gravity="center" | ||
android:padding="10dp" | ||
android:text="@string/onboarding_firefox_account_auto_signin_confirm" | ||
android:textAllCaps="false" | ||
android:textColor="?neutral" | ||
android:textSize="14sp" | ||
android:textStyle="bold" | ||
app:backgroundTint="@color/onboarding_card_button_background_dark" /> | ||
|
||
</LinearLayout> |
Oops, something went wrong.