Settings: Refactor for new API & remove obsolete setting
Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
@@ -1070,12 +1070,6 @@
|
|||||||
<string name="haptic_feedback_enable_summary_on">Vibrate when pressing soft keys and on certain UI interactions</string>
|
<string name="haptic_feedback_enable_summary_on">Vibrate when pressing soft keys and on certain UI interactions</string>
|
||||||
<!-- Sound settings screen, setting option summary text when check box is clear -->
|
<!-- Sound settings screen, setting option summary text when check box is clear -->
|
||||||
<string name="haptic_feedback_enable_summary_off">Vibrate when pressing soft keys and on certain UI interactions</string>
|
<string name="haptic_feedback_enable_summary_off">Vibrate when pressing soft keys and on certain UI interactions</string>
|
||||||
<!-- Sound settings screen, setting check box label -->
|
|
||||||
<string name="play_media_notification_sounds_enable_title">SD card notifications</string>
|
|
||||||
<!-- Sound settings screen, setting option summary text when check box is selected -->
|
|
||||||
<string name="play_media_notification_sounds_enable_summary_on">Play sound for SD card notifications</string>
|
|
||||||
<!-- Sound settings screen, setting option summary text when check box is clear -->
|
|
||||||
<string name="play_media_notification_sounds_enable_summary_off">Play sound for SD card notifications</string>
|
|
||||||
<!-- Sound settings screen, setting option name checkbox to enable/disable audio recording features that improve audio recording in noisy environments -->
|
<!-- Sound settings screen, setting option name checkbox to enable/disable audio recording features that improve audio recording in noisy environments -->
|
||||||
<string name="audio_record_proc_title">Noise cancellation</string>
|
<string name="audio_record_proc_title">Noise cancellation</string>
|
||||||
<!-- Sound settings screen, setting option summary text -->
|
<!-- Sound settings screen, setting option summary text -->
|
||||||
|
@@ -97,15 +97,6 @@
|
|||||||
android:order="11"
|
android:order="11"
|
||||||
android:defaultValue="true" />
|
android:defaultValue="true" />
|
||||||
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="play_media_notification_sounds"
|
|
||||||
android:title="@string/play_media_notification_sounds_enable_title"
|
|
||||||
android:summaryOn="@string/play_media_notification_sounds_enable_summary_on"
|
|
||||||
android:summaryOff="@string/play_media_notification_sounds_enable_summary_off"
|
|
||||||
android:dependency="silent"
|
|
||||||
android:order="12"
|
|
||||||
android:defaultValue="true" />
|
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="emergency_tone"
|
android:key="emergency_tone"
|
||||||
android:title="@string/emergency_tone_title"
|
android:title="@string/emergency_tone_title"
|
||||||
|
@@ -103,9 +103,13 @@ public class SdCardSettings extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void update() {
|
private void update() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mMassStorage.setChecked(mMountService.getMassStorageEnabled());
|
String path = Environment.getExternalStorageDirectory().getPath();
|
||||||
} catch (RemoteException ex) {
|
mMassStorage.setChecked(
|
||||||
|
mMountService.getVolumeShared(
|
||||||
|
Environment.getExternalStorageDirectory().getPath(), "ums"));
|
||||||
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String status = Environment.getExternalStorageState();
|
String status = Environment.getExternalStorageState();
|
||||||
@@ -153,8 +157,14 @@ public class SdCardSettings extends Activity
|
|||||||
OnClickListener mMassStorageListener = new OnClickListener() {
|
OnClickListener mMassStorageListener = new OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
try {
|
try {
|
||||||
mMountService.setMassStorageEnabled(mMassStorage.isChecked());
|
if (mMassStorage.isChecked()) {
|
||||||
} catch (RemoteException ex) {
|
mMountService.shareVolume(
|
||||||
|
Environment.getExternalStorageDirectory().getPath(), "ums");
|
||||||
|
} else {
|
||||||
|
mMountService.unshareVolume(
|
||||||
|
Environment.getExternalStorageDirectory().getPath(), "ums");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -53,16 +53,12 @@ public class SoundSettings extends PreferenceActivity implements
|
|||||||
private static final String KEY_DTMF_TONE = "dtmf_tone";
|
private static final String KEY_DTMF_TONE = "dtmf_tone";
|
||||||
private static final String KEY_SOUND_EFFECTS = "sound_effects";
|
private static final String KEY_SOUND_EFFECTS = "sound_effects";
|
||||||
private static final String KEY_HAPTIC_FEEDBACK = "haptic_feedback";
|
private static final String KEY_HAPTIC_FEEDBACK = "haptic_feedback";
|
||||||
private static final String KEY_PLAY_MEDIA_NOTIFICATION_SOUNDS =
|
|
||||||
"play_media_notification_sounds";
|
|
||||||
private static final String KEY_EMERGENCY_TONE = "emergency_tone";
|
private static final String KEY_EMERGENCY_TONE = "emergency_tone";
|
||||||
private static final String KEY_SOUND_SETTINGS = "sound_settings";
|
private static final String KEY_SOUND_SETTINGS = "sound_settings";
|
||||||
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
|
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
|
||||||
|
|
||||||
private CheckBoxPreference mSilent;
|
private CheckBoxPreference mSilent;
|
||||||
|
|
||||||
private CheckBoxPreference mPlayMediaNotificationSounds;
|
|
||||||
|
|
||||||
private IMountService mMountService = null;
|
private IMountService mMountService = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -109,7 +105,6 @@ public class SoundSettings extends PreferenceActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
mSilent = (CheckBoxPreference) findPreference(KEY_SILENT);
|
mSilent = (CheckBoxPreference) findPreference(KEY_SILENT);
|
||||||
mPlayMediaNotificationSounds = (CheckBoxPreference) findPreference(KEY_PLAY_MEDIA_NOTIFICATION_SOUNDS);
|
|
||||||
|
|
||||||
mVibrate = (CheckBoxPreference) findPreference(KEY_VIBRATE);
|
mVibrate = (CheckBoxPreference) findPreference(KEY_VIBRATE);
|
||||||
mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE);
|
mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE);
|
||||||
@@ -177,11 +172,6 @@ public class SoundSettings extends PreferenceActivity implements
|
|||||||
mSilent.setChecked(silentOrVibrateMode);
|
mSilent.setChecked(silentOrVibrateMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
mPlayMediaNotificationSounds.setChecked(mMountService.getPlayNotificationSounds());
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean vibrateSetting;
|
boolean vibrateSetting;
|
||||||
if (silentOrVibrateMode) {
|
if (silentOrVibrateMode) {
|
||||||
vibrateSetting = ringerMode == AudioManager.RINGER_MODE_VIBRATE;
|
vibrateSetting = ringerMode == AudioManager.RINGER_MODE_VIBRATE;
|
||||||
@@ -219,11 +209,6 @@ public class SoundSettings extends PreferenceActivity implements
|
|||||||
if (preference == mSilent || preference == mVibrate) {
|
if (preference == mSilent || preference == mVibrate) {
|
||||||
setRingerMode(mSilent.isChecked(), mVibrate.isChecked());
|
setRingerMode(mSilent.isChecked(), mVibrate.isChecked());
|
||||||
if (preference == mSilent) updateState(false);
|
if (preference == mSilent) updateState(false);
|
||||||
} else if (preference == mPlayMediaNotificationSounds) {
|
|
||||||
try {
|
|
||||||
mMountService.setPlayNotificationSounds(mPlayMediaNotificationSounds.isChecked());
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
}
|
|
||||||
} else if (preference == mDtmfTone) {
|
} else if (preference == mDtmfTone) {
|
||||||
Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING,
|
Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING,
|
||||||
mDtmfTone.isChecked() ? 1 : 0);
|
mDtmfTone.isChecked() ? 1 : 0);
|
||||||
|
@@ -26,6 +26,8 @@ import android.os.IBinder;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.IMountService;
|
import android.os.IMountService;
|
||||||
|
import android.os.StorageManager;
|
||||||
|
import android.os.StorageEventListener;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.StatFs;
|
import android.os.StatFs;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
@@ -60,10 +62,17 @@ public class Memory extends PreferenceActivity {
|
|||||||
// Access using getMountService()
|
// Access using getMountService()
|
||||||
private IMountService mMountService = null;
|
private IMountService mMountService = null;
|
||||||
|
|
||||||
|
private StorageManager mStorageManager = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
|
if (mStorageManager == null) {
|
||||||
|
mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
|
||||||
|
mStorageManager.registerListener(mStorageListener);
|
||||||
|
}
|
||||||
|
|
||||||
addPreferencesFromResource(R.xml.device_info_memory);
|
addPreferencesFromResource(R.xml.device_info_memory);
|
||||||
|
|
||||||
mRes = getResources();
|
mRes = getResources();
|
||||||
@@ -77,14 +86,7 @@ public class Memory extends PreferenceActivity {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_REMOVED);
|
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
|
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
|
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_SHARED);
|
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL);
|
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTABLE);
|
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_NOFS);
|
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
|
|
||||||
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
|
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
|
||||||
intentFilter.addDataScheme("file");
|
intentFilter.addDataScheme("file");
|
||||||
registerReceiver(mReceiver, intentFilter);
|
registerReceiver(mReceiver, intentFilter);
|
||||||
@@ -92,6 +94,24 @@ public class Memory extends PreferenceActivity {
|
|||||||
updateMemoryStatus();
|
updateMemoryStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StorageEventListener mStorageListener = new StorageEventListener() {
|
||||||
|
public void onShareAvailabilityChanged(String method, boolean available) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMediaInserted(String label, String path, int major, int minor) {
|
||||||
|
updateMemoryStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onMediaRemoved(String label, String path, int major, int minor, boolean clean) {
|
||||||
|
updateMemoryStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onVolumeStateChanged(
|
||||||
|
String label, String path, String oldState, String newState) {
|
||||||
|
updateMemoryStatus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
Reference in New Issue
Block a user