fix dock audio enable dialog
The dock audio enable setting is not saved if the user dismisses the dialog without checking or unchecking the check box. The dialog is then displayed each time the device is docked until the user checks/unchecks the dialog or goes to sound settings to enable or disable dock audio. Bug 7518165. Change-Id: Ifbc6179e78b64b5b7577ac750acf9846525e47c5
This commit is contained in:
@@ -120,6 +120,8 @@ public final class DockService extends Service implements ServiceListener {
|
|||||||
private int mPendingTurnOnStartId = INVALID_STARTID;
|
private int mPendingTurnOnStartId = INVALID_STARTID;
|
||||||
private int mPendingTurnOffStartId = INVALID_STARTID;
|
private int mPendingTurnOffStartId = INVALID_STARTID;
|
||||||
|
|
||||||
|
private CheckBox mAudioMediaCheckbox;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
if (DEBUG) Log.d(TAG, "onCreate");
|
if (DEBUG) Log.d(TAG, "onCreate");
|
||||||
@@ -499,6 +501,8 @@ public final class DockService extends Service implements ServiceListener {
|
|||||||
View view;
|
View view;
|
||||||
LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||||
|
|
||||||
|
mAudioMediaCheckbox = null;
|
||||||
|
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
// Device in a new dock.
|
// Device in a new dock.
|
||||||
boolean firstTime =
|
boolean firstTime =
|
||||||
@@ -528,14 +532,14 @@ public final class DockService extends Service implements ServiceListener {
|
|||||||
ab.setTitle(getString(R.string.bluetooth_dock_settings_title));
|
ab.setTitle(getString(R.string.bluetooth_dock_settings_title));
|
||||||
|
|
||||||
view = inflater.inflate(R.layout.dock_audio_media_enable_dialog, null);
|
view = inflater.inflate(R.layout.dock_audio_media_enable_dialog, null);
|
||||||
CheckBox audioMediaCheckbox =
|
mAudioMediaCheckbox =
|
||||||
(CheckBox) view.findViewById(R.id.dock_audio_media_enable_cb);
|
(CheckBox) view.findViewById(R.id.dock_audio_media_enable_cb);
|
||||||
|
|
||||||
boolean checked = Settings.Global.getInt(getContentResolver(),
|
boolean checked = Settings.Global.getInt(getContentResolver(),
|
||||||
Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, 0) == 1;
|
Settings.Global.DOCK_AUDIO_MEDIA_ENABLED, 0) == 1;
|
||||||
|
|
||||||
audioMediaCheckbox.setChecked(checked);
|
mAudioMediaCheckbox.setChecked(checked);
|
||||||
audioMediaCheckbox.setOnCheckedChangeListener(mCheckedChangeListener);
|
mAudioMediaCheckbox.setOnCheckedChangeListener(mCheckedChangeListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
float pixelScaleFactor = getResources().getDisplayMetrics().density;
|
float pixelScaleFactor = getResources().getDisplayMetrics().density;
|
||||||
@@ -601,8 +605,8 @@ public final class DockService extends Service implements ServiceListener {
|
|||||||
private final DialogInterface.OnClickListener mClickListener =
|
private final DialogInterface.OnClickListener mClickListener =
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == DialogInterface.BUTTON_POSITIVE
|
if (which == DialogInterface.BUTTON_POSITIVE) {
|
||||||
&& mDevice != null) {
|
if (mDevice != null) {
|
||||||
if (!LocalBluetoothPreferences
|
if (!LocalBluetoothPreferences
|
||||||
.hasDockAutoConnectSetting(
|
.hasDockAutoConnectSetting(
|
||||||
DockService.this,
|
DockService.this,
|
||||||
@@ -614,6 +618,11 @@ public final class DockService extends Service implements ServiceListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyBtSettings(mDevice, mStartIdAssociatedWithDialog);
|
applyBtSettings(mDevice, mStartIdAssociatedWithDialog);
|
||||||
|
} else if (mAudioMediaCheckbox != null) {
|
||||||
|
Settings.Global.putInt(getContentResolver(),
|
||||||
|
Settings.Global.DOCK_AUDIO_MEDIA_ENABLED,
|
||||||
|
mAudioMediaCheckbox.isChecked() ? 1 : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user