|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 package org.mozilla.gecko.fxa.activities; |
|
6 |
|
7 import org.mozilla.gecko.R; |
|
8 import org.mozilla.gecko.background.common.log.Logger; |
|
9 import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount; |
|
10 import org.mozilla.gecko.fxa.login.State; |
|
11 import org.mozilla.gecko.sync.setup.activities.ActivityUtils; |
|
12 |
|
13 import android.os.Bundle; |
|
14 import android.view.View; |
|
15 import android.view.View.OnClickListener; |
|
16 |
|
17 /** |
|
18 * Activity which displays "Account verified" success screen. |
|
19 */ |
|
20 public class FxAccountVerifiedAccountActivity extends FxAccountAbstractActivity { |
|
21 private static final String LOG_TAG = FxAccountVerifiedAccountActivity.class.getSimpleName(); |
|
22 |
|
23 protected AndroidFxAccount fxAccount; |
|
24 |
|
25 public FxAccountVerifiedAccountActivity() { |
|
26 super(CANNOT_RESUME_WHEN_NO_ACCOUNTS_EXIST); |
|
27 } |
|
28 |
|
29 /** |
|
30 * {@inheritDoc} |
|
31 */ |
|
32 @Override |
|
33 public void onCreate(Bundle icicle) { |
|
34 Logger.debug(LOG_TAG, "onCreate(" + icicle + ")"); |
|
35 |
|
36 super.onCreate(icicle); |
|
37 setContentView(R.layout.fxaccount_account_verified); |
|
38 } |
|
39 |
|
40 @Override |
|
41 public void onResume() { |
|
42 super.onResume(); |
|
43 this.fxAccount = getAndroidFxAccount(); |
|
44 if (fxAccount == null) { |
|
45 Logger.warn(LOG_TAG, "Could not get Firefox Account."); |
|
46 setResult(RESULT_CANCELED); |
|
47 finish(); |
|
48 return; |
|
49 } |
|
50 State state = fxAccount.getState(); |
|
51 if (!state.verified) { |
|
52 Logger.warn(LOG_TAG, "Firefox Account is not verified; not displaying verified account activity."); |
|
53 setResult(RESULT_CANCELED); |
|
54 finish(); |
|
55 return; |
|
56 } |
|
57 |
|
58 View backToBrowsingButton = ensureFindViewById(null, R.id.button, "back to browsing button"); |
|
59 backToBrowsingButton.setOnClickListener(new OnClickListener() { |
|
60 @Override |
|
61 public void onClick(View v) { |
|
62 ActivityUtils.openURLInFennec(v.getContext(), null); |
|
63 } |
|
64 }); |
|
65 } |
|
66 } |