diff options
4 files changed, 51 insertions, 33 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java index aa2f0d3..3ed18c9 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java @@ -959,6 +959,12 @@ public class VolumeDialog { } }; + public void cleanup() { + mController.removeCallback(mControllerCallbackH); + mZenFooter.cleanup(); + mAccessibility.cleanup(); + } + private final class H extends Handler { private static final int SHOW = 1; private static final int DISMISS = 2; @@ -1081,26 +1087,7 @@ public class VolumeDialog { public void init() { mMgr = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); - mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { - @Override - public void onViewDetachedFromWindow(View v) { - if (D.BUG) Log.d(TAG, "onViewDetachedFromWindow"); - // noop - } - - @Override - public void onViewAttachedToWindow(View v) { - if (D.BUG) Log.d(TAG, "onViewAttachedToWindow"); - updateFeedbackEnabled(); - } - }); - mDialogView.setAccessibilityDelegate(this); - mMgr.addAccessibilityStateChangeListener(new AccessibilityStateChangeListener() { - @Override - public void onAccessibilityStateChanged(boolean enabled) { - updateFeedbackEnabled(); - } - }); + mDialogView.addOnAttachStateChangeListener(mOnAttachStateChangeListener); updateFeedbackEnabled(); } @@ -1111,6 +1098,10 @@ public class VolumeDialog { return super.onRequestSendAccessibilityEvent(host, child, event); } + public void cleanup() { + mDialogView.removeOnAttachStateChangeListener(mOnAttachStateChangeListener); + } + private void updateFeedbackEnabled() { mFeedbackEnabled = computeFeedbackEnabled(); } @@ -1126,6 +1117,21 @@ public class VolumeDialog { } return false; } + + private OnAttachStateChangeListener mOnAttachStateChangeListener = + new OnAttachStateChangeListener() { + @Override + public void onViewDetachedFromWindow(View v) { + if (D.BUG) Log.d(TAG, "onViewDetachedFromWindow"); + // noop + } + + @Override + public void onViewAttachedToWindow(View v) { + if (D.BUG) Log.d(TAG, "onViewAttachedToWindow"); + updateFeedbackEnabled(); + } + }; } private static class VolumeRow { diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java index 1083f40..742b18b 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogComponent.java @@ -43,7 +43,7 @@ public class VolumeDialogComponent implements VolumeComponent { private final Context mContext; private final VolumeDialogController mController; private final ZenModeController mZenModeController; - private final VolumeDialog mDialog; + private VolumeDialog mDialog; private final VolumePolicy mVolumePolicy = new VolumePolicy( true, // volumeDownToEnterSilent true, // volumeUpToExitSilent @@ -138,4 +138,11 @@ public class VolumeDialogComponent implements VolumeComponent { } }; + public void recreateDialog() { + if (mDialog != null) mDialog.cleanup(); + + mDialog = new VolumeDialog(mContext, WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY, + mController, mZenModeController, mVolumeDialogCallback); + applyConfiguration(); + } } diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java index e49ff50..fa0de7d 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java @@ -97,9 +97,8 @@ public class VolumeUI extends SystemUI { getVolumeComponent().onConfigurationChanged(newConfig); if (isThemeChange(newConfig)) { - // TODO: implement initPanel() if needed - //initPanel(); mContext.recreateTheme(); + mVolumeComponent.recreateDialog(); } mConfiguration.setTo(newConfig); } diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java index af7ee08..0fb80c0 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java @@ -69,17 +69,19 @@ public class ZenFooter extends LinearLayout { mSpTexts.add(mEndNowButton); } + private ZenModeController.Callback mZenModeCallback = new ZenModeController.Callback() { + @Override + public void onZenChanged(int zen) { + setZen(zen); + } + @Override + public void onConfigChanged(ZenModeConfig config) { + setConfig(config); + } + }; + public void init(final ZenModeController controller) { - controller.addCallback(new ZenModeController.Callback() { - @Override - public void onZenChanged(int zen) { - setZen(zen); - } - @Override - public void onConfigChanged(ZenModeConfig config) { - setConfig(config); - } - }); + controller.addCallback(mZenModeCallback); mEndNowButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -142,4 +144,8 @@ public class ZenFooter extends LinearLayout { mSpTexts.update(); } + public void cleanup() { + mController.removeCallback(mZenModeCallback); + } + } |