Merge change I82be95f6 into eclair

* changes:
  Feature #2296147	Settings for Car/Desk Dock on certain devices
This commit is contained in:
Android (Google) Code Review
2009-12-02 15:42:48 -08:00
4 changed files with 77 additions and 9 deletions

View File

@@ -18,4 +18,6 @@
<!-- Whether or not there is a notification led that is too intrusive to be pulsing <!-- Whether or not there is a notification led that is too intrusive to be pulsing
constantly --> constantly -->
<bool name="has_intrusive_led">false</bool> <bool name="has_intrusive_led">false</bool>
<!-- Whether or not the dock settings are to be displayed for this device when docked -->
<bool name="has_dock_settings">false</bool>
</resources> </resources>

View File

@@ -894,6 +894,8 @@
<string name="media_volume_title">Media volume</string> <string name="media_volume_title">Media volume</string>
<!-- Sound settings screen, setting option summary text --> <!-- Sound settings screen, setting option summary text -->
<string name="media_volume_summary">Set volume for music and videos</string> <string name="media_volume_summary">Set volume for music and videos</string>
<!-- Sound settings screen, dock settings -->
<string name="dock_settings_title">Dock settings</string>
<!-- Sound settings screen, setting check box label --> <!-- Sound settings screen, setting check box label -->
<string name="dtmf_tone_enable_title">Audible touch tones</string> <string name="dtmf_tone_enable_title">Audible touch tones</string>
<!-- Sound settings screen, setting option summary text when check box is selected --> <!-- Sound settings screen, setting option summary text when check box is selected -->

View File

@@ -25,6 +25,7 @@
android:title="@string/silent_mode_title" android:title="@string/silent_mode_title"
android:summary="@string/silent_mode_summary" android:summary="@string/silent_mode_summary"
android:persistent="false" android:persistent="false"
android:order="1"
android:disableDependentsState="true" /> android:disableDependentsState="true" />
<com.android.settings.RingerVolumePreference <com.android.settings.RingerVolumePreference
@@ -34,6 +35,7 @@
android:dialogTitle="@string/ring_volume_title" android:dialogTitle="@string/ring_volume_title"
android:persistent="false" android:persistent="false"
android:dependency="silent" android:dependency="silent"
android:order="2"
android:streamType="ring" /> android:streamType="ring" />
<VolumePreference <VolumePreference
@@ -42,8 +44,19 @@
android:summary="@string/media_volume_summary" android:summary="@string/media_volume_summary"
android:dialogTitle="@string/media_volume_title" android:dialogTitle="@string/media_volume_title"
android:persistent="false" android:persistent="false"
android:order="3"
android:streamType="music" /> android:streamType="music" />
<PreferenceScreen
android:key="dock_settings"
android:order="4"
android:title="@string/dock_settings_title">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
android:targetClass="com.android.settings.bluetooth.DockSettingsActivity" />
</PreferenceScreen>
<com.android.settings.DefaultRingtonePreference <com.android.settings.DefaultRingtonePreference
android:key="ringtone" android:key="ringtone"
android:title="@string/ringtone_title" android:title="@string/ringtone_title"
@@ -51,12 +64,14 @@
android:dialogTitle="@string/ringtone_title" android:dialogTitle="@string/ringtone_title"
android:persistent="false" android:persistent="false"
android:dependency="silent" android:dependency="silent"
android:order="5"
android:ringtoneType="ringtone" /> android:ringtoneType="ringtone" />
<CheckBoxPreference <CheckBoxPreference
android:key="vibrate" android:key="vibrate"
android:title="@string/vibrate_title" android:title="@string/vibrate_title"
android:summary="@string/vibrate_summary" android:summary="@string/vibrate_summary"
android:order="6"
android:persistent="false" /> android:persistent="false" />
<com.android.settings.DefaultRingtonePreference <com.android.settings.DefaultRingtonePreference
@@ -66,12 +81,14 @@
android:dialogTitle="@string/notification_sound_dialog_title" android:dialogTitle="@string/notification_sound_dialog_title"
android:dependency="silent" android:dependency="silent"
android:persistent="false" android:persistent="false"
android:order="7"
android:ringtoneType="notification" /> android:ringtoneType="notification" />
<CheckBoxPreference <CheckBoxPreference
android:key="notification_pulse" android:key="notification_pulse"
android:title="@string/notification_pulse_title" android:title="@string/notification_pulse_title"
android:summary="@string/notification_pulse_summary" android:summary="@string/notification_pulse_summary"
android:order="8"
android:persistent="false" /> android:persistent="false" />
<CheckBoxPreference <CheckBoxPreference
@@ -80,6 +97,7 @@
android:summaryOn="@string/dtmf_tone_enable_summary_on" android:summaryOn="@string/dtmf_tone_enable_summary_on"
android:summaryOff="@string/dtmf_tone_enable_summary_off" android:summaryOff="@string/dtmf_tone_enable_summary_off"
android:dependency="silent" android:dependency="silent"
android:order="9"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <CheckBoxPreference
@@ -88,6 +106,7 @@
android:summaryOn="@string/sound_effects_enable_summary_on" android:summaryOn="@string/sound_effects_enable_summary_on"
android:summaryOff="@string/sound_effects_enable_summary_off" android:summaryOff="@string/sound_effects_enable_summary_off"
android:dependency="silent" android:dependency="silent"
android:order="10"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <CheckBoxPreference
@@ -96,6 +115,7 @@
android:summaryOn="@string/haptic_feedback_enable_summary_on" android:summaryOn="@string/haptic_feedback_enable_summary_on"
android:summaryOff="@string/haptic_feedback_enable_summary_off" android:summaryOff="@string/haptic_feedback_enable_summary_off"
android:dependency="silent" android:dependency="silent"
android:order="11"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <CheckBoxPreference
@@ -104,6 +124,7 @@
android:summaryOn="@string/play_media_notification_sounds_enable_summary_on" android:summaryOn="@string/play_media_notification_sounds_enable_summary_on"
android:summaryOff="@string/play_media_notification_sounds_enable_summary_off" android:summaryOff="@string/play_media_notification_sounds_enable_summary_off"
android:dependency="silent" android:dependency="silent"
android:order="12"
android:defaultValue="true" /> android:defaultValue="true" />
</PreferenceCategory> </PreferenceCategory>

View File

@@ -60,11 +60,15 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
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 static final String KEY_DOCK_SETTINGS = "dock_settings";
private CheckBoxPreference mSilent; private CheckBoxPreference mSilent;
private CheckBoxPreference mPlayMediaNotificationSounds; private CheckBoxPreference mPlayMediaNotificationSounds;
private Preference mDockSettings;
private boolean mHasDockSettings;
private IMountService mMountService = null; private IMountService mMountService = null;
/* /*
@@ -90,10 +94,16 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
private BroadcastReceiver mReceiver = new BroadcastReceiver() { private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
updateState(false); updateState(false);
} else if (intent.getAction().equals(Intent.ACTION_DOCK_EVENT)) {
handleDockChange(intent);
}
} }
}; };
private PreferenceGroup mSoundSettings;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -147,12 +157,12 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
emergencyTonePreference.setOnPreferenceChangeListener(this); emergencyTonePreference.setOnPreferenceChangeListener(this);
} }
PreferenceGroup soundSettings = (PreferenceGroup) findPreference(KEY_SOUND_SETTINGS); mSoundSettings = (PreferenceGroup) findPreference(KEY_SOUND_SETTINGS);
mNotificationPulse = (CheckBoxPreference) mNotificationPulse = (CheckBoxPreference)
soundSettings.findPreference(KEY_NOTIFICATION_PULSE); mSoundSettings.findPreference(KEY_NOTIFICATION_PULSE);
if (mNotificationPulse != null && soundSettings != null && if (mNotificationPulse != null &&
getResources().getBoolean(R.bool.has_intrusive_led) == false) { getResources().getBoolean(R.bool.has_intrusive_led) == false) {
soundSettings.removePreference(mNotificationPulse); mSoundSettings.removePreference(mNotificationPulse);
} else { } else {
try { try {
mNotificationPulse.setChecked(Settings.System.getInt(resolver, mNotificationPulse.setChecked(Settings.System.getInt(resolver,
@@ -162,6 +172,8 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found"); Log.e(TAG, Settings.System.NOTIFICATION_LIGHT_PULSE + " not found");
} }
} }
initDockSettings();
} }
@Override @Override
@@ -171,6 +183,12 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
updateState(true); updateState(true);
IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION); IntentFilter filter = new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION);
if (mHasDockSettings) {
if (mDockSettings != null) {
mSoundSettings.removePreference(mDockSettings);
}
filter.addAction(Intent.ACTION_DOCK_EVENT);
}
registerReceiver(mReceiver, filter); registerReceiver(mReceiver, filter);
} }
@@ -181,6 +199,31 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
unregisterReceiver(mReceiver); unregisterReceiver(mReceiver);
} }
private void initDockSettings() {
mDockSettings = mSoundSettings.findPreference(KEY_DOCK_SETTINGS);
mHasDockSettings = getResources().getBoolean(R.bool.has_dock_settings);
if (mDockSettings != null) {
mSoundSettings.removePreference(mDockSettings);
// Don't care even if we dock
if (getResources().getBoolean(R.bool.has_dock_settings) == false) {
mDockSettings = null;
}
}
}
private void handleDockChange(Intent intent) {
if (mHasDockSettings && mDockSettings != null) {
int dockState = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, 0);
if (dockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
// Show dock settings item
mSoundSettings.addPreference(mDockSettings);
} else {
// Remove dock settings item
mSoundSettings.removePreference(mDockSettings);
}
}
}
private void updateState(boolean force) { private void updateState(boolean force) {
final int ringerMode = mAudioManager.getRingerMode(); final int ringerMode = mAudioManager.getRingerMode();
final boolean silentOrVibrateMode = final boolean silentOrVibrateMode =