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:
@@ -23,26 +23,21 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.SettingNotFoundException;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
|
||||
public class SoundSettings extends PreferenceActivity implements
|
||||
public class SoundSettings extends SettingsPreferenceFragment implements
|
||||
Preference.OnPreferenceChangeListener {
|
||||
private static final String TAG = "SoundAndDisplaysSettings";
|
||||
|
||||
/** If there is no setting in the provider, use this. */
|
||||
private static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000;
|
||||
private static final int FALLBACK_EMERGENCY_TONE_VALUE = 0;
|
||||
|
||||
private static final String KEY_SILENT = "silent";
|
||||
@@ -90,7 +85,7 @@ public class SoundSettings extends PreferenceActivity implements
|
||||
private PreferenceGroup mSoundSettings;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ContentResolver resolver = getContentResolver();
|
||||
int activePhoneType = TelephonyManager.getDefault().getPhoneType();
|
||||
@@ -137,8 +132,8 @@ public class SoundSettings extends PreferenceActivity implements
|
||||
mSoundSettings = (PreferenceGroup) findPreference(KEY_SOUND_SETTINGS);
|
||||
mNotificationPulse = (CheckBoxPreference)
|
||||
mSoundSettings.findPreference(KEY_NOTIFICATION_PULSE);
|
||||
if (mNotificationPulse != null &&
|
||||
getResources().getBoolean(R.bool.has_intrusive_led) == false) {
|
||||
if (mNotificationPulse != null
|
||||
&& getResources().getBoolean(R.bool.has_intrusive_led) == false) {
|
||||
mSoundSettings.removePreference(mNotificationPulse);
|
||||
} else {
|
||||
try {
|
||||
@@ -153,20 +148,20 @@ public class SoundSettings extends PreferenceActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
updateState(true);
|
||||
|
||||
IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
|
||||
registerReceiver(mReceiver, filter);
|
||||
getActivity().registerReceiver(mReceiver, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
unregisterReceiver(mReceiver);
|
||||
getActivity().unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
private String getPhoneVibrateSettingValue() {
|
||||
|
Reference in New Issue
Block a user