Refactor settings top level activities to use fragments.

Added a base class SettingsPreferenceFragment from which the settings activities should
be derived so that they can behave like fragments. It contains some commonly called
utility methods and dialog conversion to DialogFragment.

Some of the top-level activities can be launched directly without the left pane.
Settings.java acts as a proxy activity that contains just that settings fragment without
the left pane.

There are still a lot of second and third level activities that need to be fragmentized.
This is just the first pass to test the 2-pane layout.
This commit is contained in:
Amith Yamasani
2010-08-18 13:59:28 -07:00
parent 3a9cf03636
commit d79934731c
31 changed files with 1088 additions and 338 deletions

View File

@@ -22,23 +22,18 @@ import android.app.backup.IBackupManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
/**
* Gesture lock pattern settings.
*/
public class PrivacySettings extends PreferenceActivity implements
public class PrivacySettings extends SettingsPreferenceFragment implements
DialogInterface.OnClickListener {
// Vendor specific
@@ -54,7 +49,7 @@ public class PrivacySettings extends PreferenceActivity implements
private int mDialogType;
@Override
protected void onCreate(Bundle savedInstanceState) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.privacy_settings);
final PreferenceScreen screen = getPreferenceScreen();
@@ -63,7 +58,8 @@ public class PrivacySettings extends PreferenceActivity implements
mAutoRestore = (CheckBoxPreference) screen.findPreference(AUTO_RESTORE);
// Vendor specific
if (getPackageManager().resolveContentProvider(GSETTINGS_PROVIDER, 0) == null) {
if (getActivity().getPackageManager().
resolveContentProvider(GSETTINGS_PROVIDER, 0) == null) {
screen.removePreference(findPreference(BACKUP_CATEGORY));
}
updateToggles();
@@ -110,7 +106,8 @@ public class PrivacySettings extends PreferenceActivity implements
mDialogType = DIALOG_ERASE_BACKUP;
CharSequence msg = getResources().getText(R.string.backup_erase_dialog_message);
mConfirmDialog = new AlertDialog.Builder(this).setMessage(msg)
// TODO: DialogFragment?
mConfirmDialog = new AlertDialog.Builder(getActivity()).setMessage(msg)
.setTitle(R.string.backup_erase_dialog_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.ok, this)