Settings: Refactor for new API & remove obsolete setting

Signed-off-by: San Mehat <san@google.com>
This commit is contained in:
San Mehat
2010-01-29 06:09:06 -08:00
parent 48090d4066
commit 4a3d713f3a
5 changed files with 43 additions and 43 deletions

View File

@@ -1070,12 +1070,6 @@
<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 -->
<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 -->
<string name="audio_record_proc_title">Noise cancellation</string>
<!-- Sound settings screen, setting option summary text -->

View File

@@ -97,15 +97,6 @@
android:order="11"
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
android:key="emergency_tone"
android:title="@string/emergency_tone_title"

View File

@@ -103,9 +103,13 @@ public class SdCardSettings extends Activity
}
private void update() {
try {
mMassStorage.setChecked(mMountService.getMassStorageEnabled());
} catch (RemoteException ex) {
String path = Environment.getExternalStorageDirectory().getPath();
mMassStorage.setChecked(
mMountService.getVolumeShared(
Environment.getExternalStorageDirectory().getPath(), "ums"));
} catch (Exception ex) {
}
String status = Environment.getExternalStorageState();
@@ -153,8 +157,14 @@ public class SdCardSettings extends Activity
OnClickListener mMassStorageListener = new OnClickListener() {
public void onClick(View v) {
try {
mMountService.setMassStorageEnabled(mMassStorage.isChecked());
} catch (RemoteException ex) {
if (mMassStorage.isChecked()) {
mMountService.shareVolume(
Environment.getExternalStorageDirectory().getPath(), "ums");
} else {
mMountService.unshareVolume(
Environment.getExternalStorageDirectory().getPath(), "ums");
}
} catch (Exception ex) {
}
}
};

View File

@@ -53,16 +53,12 @@ public class SoundSettings extends PreferenceActivity implements
private static final String KEY_DTMF_TONE = "dtmf_tone";
private static final String KEY_SOUND_EFFECTS = "sound_effects";
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_SOUND_SETTINGS = "sound_settings";
private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
private CheckBoxPreference mSilent;
private CheckBoxPreference mPlayMediaNotificationSounds;
private IMountService mMountService = null;
/*
@@ -109,7 +105,6 @@ public class SoundSettings extends PreferenceActivity implements
}
mSilent = (CheckBoxPreference) findPreference(KEY_SILENT);
mPlayMediaNotificationSounds = (CheckBoxPreference) findPreference(KEY_PLAY_MEDIA_NOTIFICATION_SOUNDS);
mVibrate = (CheckBoxPreference) findPreference(KEY_VIBRATE);
mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE);
@@ -177,11 +172,6 @@ public class SoundSettings extends PreferenceActivity implements
mSilent.setChecked(silentOrVibrateMode);
}
try {
mPlayMediaNotificationSounds.setChecked(mMountService.getPlayNotificationSounds());
} catch (RemoteException e) {
}
boolean vibrateSetting;
if (silentOrVibrateMode) {
vibrateSetting = ringerMode == AudioManager.RINGER_MODE_VIBRATE;
@@ -219,11 +209,6 @@ public class SoundSettings extends PreferenceActivity implements
if (preference == mSilent || preference == mVibrate) {
setRingerMode(mSilent.isChecked(), mVibrate.isChecked());
if (preference == mSilent) updateState(false);
} else if (preference == mPlayMediaNotificationSounds) {
try {
mMountService.setPlayNotificationSounds(mPlayMediaNotificationSounds.isChecked());
} catch (RemoteException e) {
}
} else if (preference == mDtmfTone) {
Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING,
mDtmfTone.isChecked() ? 1 : 0);

View File

@@ -26,6 +26,8 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.os.Environment;
import android.os.IMountService;
import android.os.StorageManager;
import android.os.StorageEventListener;
import android.os.ServiceManager;
import android.os.StatFs;
import android.preference.Preference;
@@ -60,10 +62,17 @@ public class Memory extends PreferenceActivity {
// Access using getMountService()
private IMountService mMountService = null;
private StorageManager mStorageManager = null;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (mStorageManager == null) {
mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
mStorageManager.registerListener(mStorageListener);
}
addPreferencesFromResource(R.xml.device_info_memory);
mRes = getResources();
@@ -77,20 +86,31 @@ public class Memory extends PreferenceActivity {
protected void onResume() {
super.onResume();
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_REMOVED);
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 intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_STARTED);
intentFilter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
intentFilter.addDataScheme("file");
registerReceiver(mReceiver, intentFilter);
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
protected void onPause() {