am 6730c3c6: Merge "Fix safe volume warning message flickering" into jb-mr1-dev
* commit '6730c3c69f84d799198365e0692b79be72b0eeb7': Fix safe volume warning message flickering
This commit is contained in:
@@ -214,6 +214,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
private Vibrator mVibrator;
|
private Vibrator mVibrator;
|
||||||
|
|
||||||
private static AlertDialog sConfirmSafeVolumeDialog;
|
private static AlertDialog sConfirmSafeVolumeDialog;
|
||||||
|
private static Object sConfirmSafeVolumeLock = new Object();
|
||||||
|
|
||||||
private static class WarningDialogReceiver extends BroadcastReceiver
|
private static class WarningDialogReceiver extends BroadcastReceiver
|
||||||
implements DialogInterface.OnDismissListener {
|
implements DialogInterface.OnDismissListener {
|
||||||
@@ -230,10 +231,16 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
mDialog.cancel();
|
mDialog.cancel();
|
||||||
|
synchronized (sConfirmSafeVolumeLock) {
|
||||||
|
sConfirmSafeVolumeDialog = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDismiss(DialogInterface unused) {
|
public void onDismiss(DialogInterface unused) {
|
||||||
mContext.unregisterReceiver(this);
|
mContext.unregisterReceiver(this);
|
||||||
|
synchronized (sConfirmSafeVolumeLock) {
|
||||||
|
sConfirmSafeVolumeDialog = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,6 +563,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void postDisplaySafeVolumeWarning() {
|
public void postDisplaySafeVolumeWarning() {
|
||||||
|
if (hasMessages(MSG_DISPLAY_SAFE_VOLUME_WARNING)) return;
|
||||||
obtainMessage(MSG_DISPLAY_SAFE_VOLUME_WARNING, 0, 0).sendToTarget();
|
obtainMessage(MSG_DISPLAY_SAFE_VOLUME_WARNING, 0, 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -828,28 +836,29 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void onDisplaySafeVolumeWarning() {
|
protected void onDisplaySafeVolumeWarning() {
|
||||||
if (sConfirmSafeVolumeDialog != null) {
|
synchronized (sConfirmSafeVolumeLock) {
|
||||||
sConfirmSafeVolumeDialog.dismiss();
|
if (sConfirmSafeVolumeDialog != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sConfirmSafeVolumeDialog = new AlertDialog.Builder(mContext)
|
||||||
|
.setMessage(com.android.internal.R.string.safe_media_volume_warning)
|
||||||
|
.setPositiveButton(com.android.internal.R.string.yes,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
mAudioService.disableSafeMediaVolume();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(com.android.internal.R.string.no, null)
|
||||||
|
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||||
|
.create();
|
||||||
|
final WarningDialogReceiver warning = new WarningDialogReceiver(mContext,
|
||||||
|
sConfirmSafeVolumeDialog);
|
||||||
|
|
||||||
|
sConfirmSafeVolumeDialog.setOnDismissListener(warning);
|
||||||
|
sConfirmSafeVolumeDialog.getWindow().setType(
|
||||||
|
WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
|
||||||
|
sConfirmSafeVolumeDialog.show();
|
||||||
}
|
}
|
||||||
sConfirmSafeVolumeDialog = new AlertDialog.Builder(mContext)
|
|
||||||
.setMessage(com.android.internal.R.string.safe_media_volume_warning)
|
|
||||||
.setPositiveButton(com.android.internal.R.string.yes,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
mAudioService.disableSafeMediaVolume();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(com.android.internal.R.string.no, null)
|
|
||||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
|
||||||
.create();
|
|
||||||
|
|
||||||
final WarningDialogReceiver warning = new WarningDialogReceiver(mContext,
|
|
||||||
sConfirmSafeVolumeDialog);
|
|
||||||
|
|
||||||
sConfirmSafeVolumeDialog.setOnDismissListener(warning);
|
|
||||||
sConfirmSafeVolumeDialog.getWindow().setType(
|
|
||||||
WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
|
|
||||||
sConfirmSafeVolumeDialog.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user