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.

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

mercurial