mobile/android/base/fxa/activities/FxAccountVerifiedAccountActivity.java

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mobile/android/base/fxa/activities/FxAccountVerifiedAccountActivity.java	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +package org.mozilla.gecko.fxa.activities;
     1.9 +
    1.10 +import org.mozilla.gecko.R;
    1.11 +import org.mozilla.gecko.background.common.log.Logger;
    1.12 +import org.mozilla.gecko.fxa.authenticator.AndroidFxAccount;
    1.13 +import org.mozilla.gecko.fxa.login.State;
    1.14 +import org.mozilla.gecko.sync.setup.activities.ActivityUtils;
    1.15 +
    1.16 +import android.os.Bundle;
    1.17 +import android.view.View;
    1.18 +import android.view.View.OnClickListener;
    1.19 +
    1.20 +/**
    1.21 + * Activity which displays "Account verified" success screen.
    1.22 + */
    1.23 +public class FxAccountVerifiedAccountActivity extends FxAccountAbstractActivity {
    1.24 +  private static final String LOG_TAG = FxAccountVerifiedAccountActivity.class.getSimpleName();
    1.25 +
    1.26 +  protected AndroidFxAccount fxAccount;
    1.27 +
    1.28 +  public FxAccountVerifiedAccountActivity() {
    1.29 +    super(CANNOT_RESUME_WHEN_NO_ACCOUNTS_EXIST);
    1.30 +  }
    1.31 +
    1.32 +  /**
    1.33 +   * {@inheritDoc}
    1.34 +   */
    1.35 +  @Override
    1.36 +  public void onCreate(Bundle icicle) {
    1.37 +    Logger.debug(LOG_TAG, "onCreate(" + icicle + ")");
    1.38 +
    1.39 +    super.onCreate(icicle);
    1.40 +    setContentView(R.layout.fxaccount_account_verified);
    1.41 +  }
    1.42 +
    1.43 +  @Override
    1.44 +  public void onResume() {
    1.45 +    super.onResume();
    1.46 +    this.fxAccount = getAndroidFxAccount();
    1.47 +    if (fxAccount == null) {
    1.48 +      Logger.warn(LOG_TAG, "Could not get Firefox Account.");
    1.49 +      setResult(RESULT_CANCELED);
    1.50 +      finish();
    1.51 +      return;
    1.52 +    }
    1.53 +    State state = fxAccount.getState();
    1.54 +    if (!state.verified) {
    1.55 +      Logger.warn(LOG_TAG, "Firefox Account is not verified; not displaying verified account activity.");
    1.56 +      setResult(RESULT_CANCELED);
    1.57 +      finish();
    1.58 +      return;
    1.59 +    }
    1.60 +
    1.61 +    View backToBrowsingButton = ensureFindViewById(null, R.id.button, "back to browsing button");
    1.62 +    backToBrowsingButton.setOnClickListener(new OnClickListener() {
    1.63 +      @Override
    1.64 +      public void onClick(View v) {
    1.65 +        ActivityUtils.openURLInFennec(v.getContext(), null);
    1.66 +      }
    1.67 +    });
    1.68 +  }
    1.69 +}

mercurial