Add zen panel to volume dialog again in tuner
Change-Id: Ie74a6bd8ecd7f2d8b16e96cc0087e63796d5f9a2
diff --git a/packages/SystemUI/res/layout/volume_dialog.xml b/packages/SystemUI/res/layout/volume_dialog.xml
index 7617ed4..7cbc55c 100644
--- a/packages/SystemUI/res/layout/volume_dialog.xml
+++ b/packages/SystemUI/res/layout/volume_dialog.xml
@@ -46,6 +46,9 @@
<!-- volume rows added and removed here! :-) -->
<include layout="@layout/volume_zen_footer" />
+
+ <!-- Only shown from Tuner setting -->
+ <include layout="@layout/zen_mode_panel" />
</LinearLayout>
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index de49677..112f801 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -805,6 +805,12 @@
<!-- Interruption level: Alarms only. Optimized for narrow two-line display. [CHAR LIMIT=40] -->
<string name="interruption_level_alarms_twoline">Alarms\nonly</string>
+ <!-- Interruption level: All interruptions. [CHAR LIMIT=40] -->
+ <string name="interruption_level_all">All</string>
+
+ <!-- Interruption level: All interruptions. Optimized for narrow two-line display. [CHAR LIMIT=40] -->
+ <string name="interruption_level_all_twoline">All\n</string>
+
<!-- Indication on the keyguard that is shown when the device is charging. [CHAR LIMIT=40]-->
<string name="keyguard_indication_charging_time">Charging (<xliff:g id="charging_time_left" example="4 hours and 2 minutes">%s</xliff:g> until full)</string>
@@ -1295,4 +1301,9 @@
<!-- User visible title for the the keyboard shortcut that triggers the back action. -->
<string name="keyboard_shortcut_group_system_back">Back</string>
+ <!-- SysUI Tuner: Option to show full do not disturb panel in volume [CHAR LIMIT=60] -->
+ <string name="tuner_full_zen_title">Show do not disturb in volume</string>
+ <!-- SysUI Tuner: Summary of option to show full do not disturb panel in volume [CHAR LIMIT=NONE] -->
+ <string name="tuner_full_zen_summary">Allow full control of do not disturb in the volume dialog.</string>
+
</resources>
diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml
index 11ef735d..0a1f660 100644
--- a/packages/SystemUI/res/xml/tuner_prefs.xml
+++ b/packages/SystemUI/res/xml/tuner_prefs.xml
@@ -113,6 +113,11 @@
android:title="@string/color_transform"
android:fragment="com.android.systemui.tuner.ColorMatrixFragment" />
+ <com.android.systemui.tuner.TunerSwitch
+ android:key="sysui_show_full_zen"
+ android:title="@string/tuner_full_zen_title"
+ android:summary="@string/tuner_full_zen_summary" />
+
<!-- Warning, this goes last. -->
<Preference
android:summary="@string/tuner_persistent_warning"
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
index 0901015..ed6fc9e 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java
@@ -21,7 +21,6 @@
import android.accessibilityservice.AccessibilityServiceInfo;
import android.animation.LayoutTransition;
-import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Dialog;
@@ -62,7 +61,6 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener;
-import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.SeekBar;
@@ -71,6 +69,7 @@
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ZenModeController;
+import com.android.systemui.tuner.TunerService;
import com.android.systemui.volume.VolumeDialogController.State;
import com.android.systemui.volume.VolumeDialogController.StreamState;
@@ -85,9 +84,11 @@
*
* Methods ending in "H" must be called on the (ui) handler.
*/
-public class VolumeDialog {
+public class VolumeDialog implements TunerService.Tunable {
private static final String TAG = Util.logTag(VolumeDialog.class);
+ public static final String SHOW_FULL_ZEN = "sysui_show_full_zen";
+
private static final long USER_ATTEMPT_GRACE_PERIOD = 1000;
private static final int WAIT_FOR_RIPPLE = 200;
@@ -131,6 +132,9 @@
private boolean mHovering = false;
private int mLastActiveStream;
+ private boolean mShowFullZen;
+ private final ZenModePanel mZenPanel;
+
public VolumeDialog(Context context, int windowType, VolumeDialogController controller,
ZenModeController zenModeController, Callback callback) {
mContext = context;
@@ -221,11 +225,23 @@
mExpandButtonAnimationDuration = res.getInteger(R.integer.volume_expand_animation_duration);
mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer);
mZenFooter.init(zenModeController);
+ mZenPanel = (ZenModePanel) mDialog.findViewById(R.id.zen_mode_panel);
+ mZenPanel.addNoneButton();
+ mZenPanel.init(zenModeController);
+ mZenPanel.setCallback(mZenPanelCallback);
mAccessibility.init();
controller.addCallback(mControllerCallbackH, mHandler);
controller.getState();
+ TunerService.get(mContext).addTunable(this, SHOW_FULL_ZEN);
+ }
+
+ @Override
+ public void onTuningChanged(String key, String newValue) {
+ if (SHOW_FULL_ZEN.equals(key)) {
+ mShowFullZen = newValue != null && Integer.parseInt(newValue) != 0;
+ }
}
private ColorStateList loadColorStateList(int colorResId) {
@@ -278,7 +294,7 @@
.getDimensionPixelSize(R.dimen.volume_slider_interspacing);
final LinearLayout.LayoutParams lp =
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, h);
- mDialogContentView.addView(v, mDialogContentView.getChildCount() - 1, lp);
+ mDialogContentView.addView(v, mDialogContentView.getChildCount() - 2, lp);
row.space = v;
}
row.settingsButton.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@@ -306,7 +322,7 @@
}
});
// add new row just before the footer
- mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 1);
+ mDialogContentView.addView(row.view, mDialogContentView.getChildCount() - 2);
mRows.add(row);
}
@@ -655,12 +671,21 @@
if (D.BUG) Log.d(TAG, "updateFooterH");
final boolean wasVisible = mZenFooter.getVisibility() == View.VISIBLE;
final boolean visible = mState.zenMode != Global.ZEN_MODE_OFF
- && (mAudioManager.isStreamAffectedByRingerMode(mActiveStream) || mExpanded);
+ && (mAudioManager.isStreamAffectedByRingerMode(mActiveStream) || mExpanded)
+ && !mShowFullZen;
if (wasVisible != visible && !visible) {
prepareForCollapse();
}
Util.setVisOrGone(mZenFooter, visible);
mZenFooter.update();
+
+ final boolean fullWasVisible = mZenPanel.getVisibility() == View.VISIBLE;
+ final boolean fullVisible = mShowFullZen && (mState.zenMode != Global.ZEN_MODE_OFF
+ || mExpanded);
+ if (fullWasVisible != fullVisible && !fullVisible) {
+ prepareForCollapse();
+ }
+ Util.setVisOrGone(mZenPanel, fullVisible);
}
private void updateVolumeRowH(VolumeRow row) {
@@ -903,6 +928,23 @@
}
};
+ private final ZenModePanel.Callback mZenPanelCallback = new ZenModePanel.Callback() {
+ @Override
+ public void onPrioritySettings() {
+ mCallback.onZenPrioritySettingsClicked();
+ }
+
+ @Override
+ public void onInteraction() {
+ mHandler.sendEmptyMessage(H.RESCHEDULE_TIMEOUT);
+ }
+
+ @Override
+ public void onExpanded(boolean expanded) {
+ // noop.
+ }
+ };
+
private final OnClickListener mClickExpand = new OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
index 38d8de0..f73ba6f 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java
@@ -189,6 +189,12 @@
mZenAlarmWarning = (TextView) findViewById(R.id.zen_alarm_warning);
}
+ public void addNoneButton() {
+ mZenButtons.addButton(R.string.interruption_level_all_twoline,
+ R.string.interruption_level_all,
+ Global.ZEN_MODE_OFF);
+ }
+
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@@ -494,6 +500,7 @@
if (mExpanded && isShown()) {
ensureSelection();
}
+ mZenConditions.setVisibility(mSessionZen != Global.ZEN_MODE_OFF ? View.VISIBLE : View.GONE);
}
private Condition forever() {