mobile/android/base/preferences/SyncPreference.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

     1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 package org.mozilla.gecko.preferences;
     8 import org.mozilla.gecko.fxa.activities.FxAccountGetStartedActivity;
     9 import org.mozilla.gecko.sync.setup.SyncAccounts;
    10 import org.mozilla.gecko.sync.setup.activities.SetupSyncActivity;
    12 import android.content.Context;
    13 import android.content.Intent;
    14 import android.preference.Preference;
    15 import android.util.AttributeSet;
    17 class SyncPreference extends Preference {
    18     private static final boolean DEFAULT_TO_FXA = true;
    20     private Context mContext;
    22     public SyncPreference(Context context, AttributeSet attrs) {
    23         super(context, attrs);
    24         mContext = context;
    25     }
    27     private void openSync11Settings() {
    28         // Show Sync setup if no accounts exist; otherwise, show account settings.
    29         if (SyncAccounts.syncAccountsExist(mContext)) {
    30             SyncAccounts.openSyncSettings(mContext);
    31             return;
    32         }
    33         Intent intent = new Intent(mContext, SetupSyncActivity.class);
    34         mContext.startActivity(intent);
    35     }
    37     private void launchFxASetup() {
    38         Intent intent = new Intent(mContext, FxAccountGetStartedActivity.class);
    39         intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    40         mContext.startActivity(intent);
    41     }
    43     @Override
    44     protected void onClick() {
    45         // If we're not defaulting to FxA, just do what we've always done.
    46         if (!DEFAULT_TO_FXA) {
    47             openSync11Settings();
    48             return;
    49         }
    51         // If there's a legacy Sync account (or a pickled one on disk),
    52         // open the settings page.
    53         if (SyncAccounts.syncAccountsExist(mContext)) {
    54             SyncAccounts.openSyncSettings(mContext);
    55             return;
    56         }
    58         // Otherwise, launch the FxA "Get started" activity, which will
    59         // dispatch to the right location.
    60         launchFxASetup();
    61     }
    62 }

mercurial