New top-level Dock in Settings and a Dock Settings screen with Audio item. #2367275

Add a new top-level setting for car/desktop dock settings.
Sub menu contains one item - Audio (settings)
Sub text for Audio shows current docked status and launches either the
 audio settings or a dialog saying that you're not docked and you need to
 buy a new dock from Google (kidding).
This commit is contained in:
Amith Yamasani
2010-01-14 16:12:21 -08:00
parent 01a868d73b
commit 0e2ab4f884
8 changed files with 198 additions and 60 deletions

View File

@@ -18,8 +18,6 @@ package com.android.settings;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import com.android.settings.bluetooth.DockEventReceiver;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -63,15 +61,11 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
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 static final String KEY_DOCK_SETTINGS = "dock_settings";
private CheckBoxPreference mSilent;
private CheckBoxPreference mPlayMediaNotificationSounds;
private Preference mDockSettings;
private boolean mHasDockSettings;
private IMountService mMountService = null;
/*
@@ -99,16 +93,12 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(AudioManager.RINGER_MODE_CHANGED_ACTION)) {
updateState(false);
} else if (intent.getAction().equals(Intent.ACTION_DOCK_EVENT)) {
handleDockChange(intent);
}
}
};
private PreferenceGroup mSoundSettings;
private Intent mDockIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -178,7 +168,6 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
}
}
initDockSettings();
}
@Override
@@ -188,12 +177,6 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
updateState(true);
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);
}
@@ -204,34 +187,6 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
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);
// Save the intent to send to the activity
mDockIntent = intent;
} else {
// Remove dock settings item
mSoundSettings.removePreference(mDockSettings);
}
}
}
private void updateState(boolean force) {
final int ringerMode = mAudioManager.getRingerMode();
final boolean silentOrVibrateMode =
@@ -354,11 +309,6 @@ public class SoundAndDisplaySettings extends PreferenceActivity implements
boolean value = mNotificationPulse.isChecked();
Settings.System.putInt(getContentResolver(),
Settings.System.NOTIFICATION_LIGHT_PULSE, value ? 1 : 0);
} else if (preference == mDockSettings) {
Intent i = new Intent(mDockIntent);
i.setAction(DockEventReceiver.ACTION_DOCK_SHOW_UI);
i.setClass(this, DockEventReceiver.class);
sendBroadcast(i);
}
return true;