2012-01-25 22:44:59 +00:00
|
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2012-01-25 22:44:59 +00:00
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
2012-07-28 00:53:54 +00:00
|
|
|
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
|
|
|
import org.mozilla.gecko.sync.setup.activities.SetupSyncActivity;
|
|
|
|
|
2012-01-25 22:44:59 +00:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.preference.Preference;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
|
2012-07-18 00:54:54 +00:00
|
|
|
class SyncPreference extends Preference {
|
2012-01-25 22:44:59 +00:00
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
public SyncPreference(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
mContext = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onClick() {
|
2012-07-06 23:46:24 +00:00
|
|
|
// Show Sync setup if no accounts exist; otherwise, show account settings.
|
2012-07-07 01:35:29 +00:00
|
|
|
if (SyncAccounts.syncAccountsExist(mContext)) {
|
2012-07-06 23:46:24 +00:00
|
|
|
SyncAccounts.openSyncSettings(mContext);
|
|
|
|
} else {
|
|
|
|
Intent intent = new Intent(mContext, SetupSyncActivity.class);
|
|
|
|
mContext.startActivity(intent);
|
|
|
|
}
|
2012-01-25 22:44:59 +00:00
|
|
|
}
|
|
|
|
}
|