Use Drawer in Settings app
- get rid of PreferenceActivity as much as we can and use fragments instead - add Drawer widget - add Dashboard high level entry into the Drawer (but this is work in progress and would be done in another CL) - add bypass of fragment's Header validation when launched from the Drawer but *force* validation if external call thru an Intent Be aware that WifiPickerActivity should remain for now a PreferenceActivity. It is used by SetupWizard and should not trigger running the SettingsActivity's header building code. SetupWizard is a Home during the provisionnig process and then deactivate itself as a Home but would make the Home header to appear in the Drawer (because momentarily we would have two Home). Also, verified that: - the WiFi settings still work when called from SetupWizard - when you have multiple Launchers, the Home header will appear in the list of Headers in the Drawer Change-Id: I407a5e0fdd843ad7615d3d511c416a44e3d97c90
This commit is contained in:
@@ -38,7 +38,6 @@ import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Log;
|
||||
|
@@ -31,6 +31,7 @@ import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -142,7 +143,7 @@ public class AddAccountSettings extends Activity {
|
||||
getIntent().getStringArrayExtra(AccountPreferenceBase.AUTHORITIES_FILTER_KEY);
|
||||
final String[] accountTypes =
|
||||
getIntent().getStringArrayExtra(AccountPreferenceBase.ACCOUNT_TYPES_FILTER_KEY);
|
||||
final Intent intent = new Intent(this, ChooseAccountActivity.class);
|
||||
final Intent intent = new Intent(this, Settings.ChooseAccountActivity.class);
|
||||
if (authorities != null) {
|
||||
intent.putExtra(AccountPreferenceBase.AUTHORITIES_FILTER_KEY, authorities);
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.accounts;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -27,12 +28,12 @@ import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import com.android.internal.util.CharSequences;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.google.android.collect.Maps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -44,9 +45,9 @@ import java.util.Map;
|
||||
/**
|
||||
* Activity asking a user to select an account to be set up.
|
||||
*/
|
||||
public class ChooseAccountActivity extends PreferenceActivity {
|
||||
public class ChooseAccountFragment extends SettingsPreferenceFragment {
|
||||
|
||||
private static final String TAG = "ChooseAccountActivity";
|
||||
private static final String TAG = "ChooseAccountFragment";
|
||||
private String[] mAuthorities;
|
||||
private PreferenceGroup mAddAccountGroup;
|
||||
private final ArrayList<ProviderEntry> mProviderList = new ArrayList<ProviderEntry>();
|
||||
@@ -76,14 +77,13 @@ public class ChooseAccountActivity extends PreferenceActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
|
||||
setContentView(R.layout.add_account_screen);
|
||||
addPreferencesFromResource(R.xml.add_account_settings);
|
||||
mAuthorities = getIntent().getStringArrayExtra(
|
||||
mAuthorities = getActivity().getIntent().getStringArrayExtra(
|
||||
AccountPreferenceBase.AUTHORITIES_FILTER_KEY);
|
||||
String[] accountTypesFilter = getIntent().getStringArrayExtra(
|
||||
String[] accountTypesFilter = getActivity().getIntent().getStringArrayExtra(
|
||||
AccountPreferenceBase.ACCOUNT_TYPES_FILTER_KEY);
|
||||
if (accountTypesFilter != null) {
|
||||
mAccountTypesFilter = new HashSet<String>();
|
||||
@@ -100,7 +100,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
|
||||
* and update any UI that depends on AuthenticatorDescriptions in onAuthDescriptionsUpdated().
|
||||
*/
|
||||
private void updateAuthDescriptions() {
|
||||
mAuthDescs = AccountManager.get(this).getAuthenticatorTypes();
|
||||
mAuthDescs = AccountManager.get(getActivity()).getAuthenticatorTypes();
|
||||
for (int i = 0; i < mAuthDescs.length; i++) {
|
||||
mTypeToAuthDescription.put(mAuthDescs[i].type, mAuthDescs[i]);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
|
||||
for (ProviderEntry pref : mProviderList) {
|
||||
Drawable drawable = getDrawableForType(pref.type);
|
||||
ProviderPreference p =
|
||||
new ProviderPreference(this, pref.type, drawable, pref.name);
|
||||
new ProviderPreference(getActivity(), pref.type, drawable, pref.name);
|
||||
mAddAccountGroup.addPreference(p);
|
||||
}
|
||||
} else {
|
||||
@@ -160,7 +160,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
|
||||
}
|
||||
Log.v(TAG, "No providers found for authorities: " + auths);
|
||||
}
|
||||
setResult(RESULT_CANCELED);
|
||||
getActivity().setResult(Activity.RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
|
||||
if (mTypeToAuthDescription.containsKey(accountType)) {
|
||||
try {
|
||||
AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
|
||||
Context authContext = createPackageContext(desc.packageName, 0);
|
||||
Context authContext = getActivity().createPackageContext(desc.packageName, 0);
|
||||
icon = authContext.getResources().getDrawable(desc.iconId);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// TODO: place holder icon for missing account icons?
|
||||
@@ -219,7 +219,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
|
||||
if (mTypeToAuthDescription.containsKey(accountType)) {
|
||||
try {
|
||||
AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
|
||||
Context authContext = createPackageContext(desc.packageName, 0);
|
||||
Context authContext = getActivity().createPackageContext(desc.packageName, 0);
|
||||
label = authContext.getResources().getText(desc.labelId);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(TAG, "No label name for account type " + accountType);
|
||||
@@ -245,7 +245,7 @@ public class ChooseAccountActivity extends PreferenceActivity {
|
||||
private void finishWithAccountType(String accountType) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(AddAccountSettings.EXTRA_SELECTED_ACCOUNT, accountType);
|
||||
setResult(RESULT_OK, intent);
|
||||
getActivity().setResult(Activity.RESULT_OK, intent);
|
||||
finish();
|
||||
}
|
||||
}
|
@@ -31,7 +31,6 @@ import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -45,6 +44,7 @@ import android.widget.TextView;
|
||||
|
||||
import com.android.settings.AccountPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.location.LocationSettings;
|
||||
|
||||
@@ -146,7 +146,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
private void startAccountSettings(AccountPreference acctPref) {
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(AccountSyncSettings.ACCOUNT_KEY, acctPref.getAccount());
|
||||
((PreferenceActivity) getActivity()).startPreferencePanel(
|
||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
||||
AccountSyncSettings.class.getCanonicalName(), args,
|
||||
R.string.account_sync_settings_title, acctPref.getAccount().name,
|
||||
this, REQUEST_SHOW_SYNC_SETTINGS);
|
||||
@@ -368,7 +368,7 @@ public class ManageAccountsSettings extends AccountPreferenceBase
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
((PreferenceActivity) getActivity()).startPreferencePanel(
|
||||
((SettingsActivity) getActivity()).startPreferencePanel(
|
||||
mClass, null, mTitleRes, null, null, 0);
|
||||
// Hack: announce that the Google account preferences page is launching the location
|
||||
// settings
|
||||
|
@@ -16,22 +16,20 @@
|
||||
|
||||
package com.android.settings.accounts;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.preference.PreferenceActivity;
|
||||
|
||||
import com.android.settings.ChooseLockGeneric.ChooseLockGenericFragment;
|
||||
import com.android.settings.SettingsActivity;
|
||||
|
||||
/**
|
||||
* Launcher activity for the SyncSettings fragment.
|
||||
*
|
||||
*/
|
||||
public class SyncSettingsActivity extends PreferenceActivity {
|
||||
public class SyncSettingsActivity extends SettingsActivity {
|
||||
@Override
|
||||
public Intent getIntent() {
|
||||
Intent modIntent = new Intent(super.getIntent());
|
||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, SyncSettings.class.getName());
|
||||
modIntent.putExtra(EXTRA_NO_HEADERS, true);
|
||||
Intent modIntent = new Intent(getIntent());
|
||||
modIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, SyncSettings.class.getName());
|
||||
modIntent.putExtra(SettingsActivity.EXTRA_NO_HEADERS, true);
|
||||
return modIntent;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user