diff --git a/packages/SystemUI/res/layout/volume_zen_footer.xml b/packages/SystemUI/res/layout/volume_zen_footer.xml index 775b1576b763e..91dc6178cd869 100644 --- a/packages/SystemUI/res/layout/volume_zen_footer.xml +++ b/packages/SystemUI/res/layout/volume_zen_footer.xml @@ -29,6 +29,52 @@ android:layout_marginTop="8dp" android:background="@color/qs_tile_divider" /> + + + + + + + + + + + + "Slide left for %s. - You won’t be disturbed by sounds and vibrations, except from alarms, reminders, events, and callers you specify. + You won’t be disturbed by sounds and vibrations, except from alarms, reminders, events, and callers you specify. You'll still hear anything you choose to play including music, videos, and games. + + + You won’t be disturbed by sounds and vibrations, except from alarms. You'll still hear anything you choose to play including music, videos, and games. Customize @@ -1211,7 +1214,7 @@ %1$s. %2$s - End now + Turn off now Expand diff --git a/packages/SystemUI/src/com/android/systemui/Prefs.java b/packages/SystemUI/src/com/android/systemui/Prefs.java index 1e9cbdc45425c..3cc81dfb45d79 100644 --- a/packages/SystemUI/src/com/android/systemui/Prefs.java +++ b/packages/SystemUI/src/com/android/systemui/Prefs.java @@ -58,6 +58,7 @@ public final class Prefs { String DND_TILE_COMBINED_ICON = "DndTileCombinedIcon"; String DND_CONFIRMED_PRIORITY_INTRODUCTION = "DndConfirmedPriorityIntroduction"; String DND_CONFIRMED_SILENCE_INTRODUCTION = "DndConfirmedSilenceIntroduction"; + String DND_CONFIRMED_ALARM_INTRODUCTION = "DndConfirmedAlarmIntroduction"; String DND_FAVORITE_BUCKET_INDEX = "DndCountdownMinuteIndex"; String DND_NONE_SELECTED = "DndNoneSelected"; String DND_FAVORITE_ZEN = "DndFavoriteZen"; diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java index b8b046b9990d7..8d8931f9989d6 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java @@ -642,7 +642,6 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable { updateVolumeRowSliderTintH(row, isActive); } } - } private void trimObsoleteH() { @@ -695,28 +694,25 @@ public class VolumeDialogImpl implements VolumeDialog, TunerService.Tunable { final boolean visible = mState.zenMode != Global.ZEN_MODE_OFF && (mAudioManager.isStreamAffectedByRingerMode(mActiveStream) || mExpanded) && !mZenPanel.isEditing(); - TransitionManager.beginDelayedTransition(mDialogView, getTransistion()); - if (wasVisible != visible && !visible) { - prepareForCollapse(); + + if (wasVisible != visible) { + mZenFooter.update(); + Util.setVisOrGone(mZenFooter, visible); } - Util.setVisOrGone(mZenFooter, visible); - mZenFooter.update(); final boolean fullWasVisible = mZenPanel.getVisibility() == View.VISIBLE; final boolean fullVisible = mShowFullZen && !visible; - if (fullWasVisible != fullVisible && !fullVisible) { - prepareForCollapse(); - } - Util.setVisOrGone(mZenPanel, fullVisible); - if (fullVisible) { - mZenPanel.setZenState(mState.zenMode); - mZenPanel.setDoneListener(new OnClickListener() { - @Override - public void onClick(View v) { - prepareForCollapse(); - mHandler.sendEmptyMessage(H.UPDATE_FOOTER); - } - }); + if (fullWasVisible != fullVisible) { + Util.setVisOrGone(mZenPanel, fullVisible); + if (fullVisible) { + mZenPanel.setZenState(mState.zenMode); + mZenPanel.setDoneListener(new OnClickListener() { + @Override + public void onClick(View v) { + mHandler.sendEmptyMessage(H.UPDATE_FOOTER); + } + }); + } } } diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java index 10b6ff5cdfdcf..17d98b19277eb 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenFooter.java @@ -20,12 +20,16 @@ import android.animation.ValueAnimator; import android.content.Context; import android.provider.Settings.Global; import android.service.notification.ZenModeConfig; +import android.transition.AutoTransition; +import android.transition.TransitionManager; import android.util.AttributeSet; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; +import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.statusbar.policy.ZenModeController; @@ -44,6 +48,9 @@ public class ZenFooter extends LinearLayout { private TextView mSummaryLine1; private TextView mSummaryLine2; private TextView mEndNowButton; + private View mZenIntroduction; + private View mZenIntroductionConfirm; + private TextView mZenIntroductionMessage; private int mZen = -1; private ZenModeConfig mConfig; private ZenModeController mController; @@ -64,6 +71,17 @@ public class ZenFooter extends LinearLayout { mSummaryLine1 = findViewById(R.id.volume_zen_summary_line_1); mSummaryLine2 = findViewById(R.id.volume_zen_summary_line_2); mEndNowButton = findViewById(R.id.volume_zen_end_now); + mZenIntroduction = findViewById(R.id.zen_introduction); + mZenIntroductionMessage = findViewById(R.id.zen_introduction_message); + mConfigurableTexts.add(mZenIntroductionMessage, R.string.zen_alarms_introduction); + mZenIntroductionConfirm = findViewById(R.id.zen_introduction_confirm); + mZenIntroductionConfirm.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + confirmZenIntroduction(); + } + }); + Util.setVisOrGone(mZenIntroduction, shouldShowIntroduction()); mConfigurableTexts.add(mSummaryLine1); mConfigurableTexts.add(mSummaryLine2); mConfigurableTexts.add(mEndNowButton, R.string.volume_zen_end_now); @@ -73,6 +91,7 @@ public class ZenFooter extends LinearLayout { mEndNowButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { + setZen(Global.ZEN_MODE_OFF); controller.setZen(Global.ZEN_MODE_OFF, null, TAG); } }); @@ -81,6 +100,7 @@ public class ZenFooter extends LinearLayout { mController = controller; mController.addCallback(mZenCallback); update(); + updateIntroduction(); } public void cleanup() { @@ -91,6 +111,7 @@ public class ZenFooter extends LinearLayout { if (mZen == zen) return; mZen = zen; update(); + updateIntroduction(); } private void setConfig(ZenModeConfig config) { @@ -99,8 +120,9 @@ public class ZenFooter extends LinearLayout { update(); } - public boolean isZen() { - return isZenPriority() || isZenAlarms() || isZenNone(); + private void confirmZenIntroduction() { + Prefs.putBoolean(mContext, Prefs.Key.DND_CONFIRMED_ALARM_INTRODUCTION, true); + updateIntroduction(); } private boolean isZenPriority() { @@ -128,6 +150,15 @@ public class ZenFooter extends LinearLayout { mController.getCurrentUser(), true /*shortVersion*/); Util.setText(mSummaryLine2, line2); } + public boolean shouldShowIntroduction() { + final boolean confirmed = Prefs.getBoolean(mContext, + Prefs.Key.DND_CONFIRMED_ALARM_INTRODUCTION, false); + return !confirmed && isZenAlarms(); + } + + public void updateIntroduction() { + Util.setVisOrGone(mZenIntroduction, shouldShowIntroduction()); + } public void onConfigurationChanged() { mConfigurableTexts.update(); diff --git a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java index fffcc087223f5..51fcdbb92c812 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java +++ b/packages/SystemUI/src/com/android/systemui/volume/ZenModePanel.java @@ -284,6 +284,8 @@ public class ZenModePanel extends FrameLayout { return Prefs.Key.DND_CONFIRMED_PRIORITY_INTRODUCTION; case Global.ZEN_MODE_NO_INTERRUPTIONS: return Prefs.Key.DND_CONFIRMED_SILENCE_INTRODUCTION; + case Global.ZEN_MODE_ALARMS: + return Prefs.Key.DND_CONFIRMED_ALARM_INTRODUCTION; default: return null; } @@ -523,16 +525,22 @@ public class ZenModePanel extends FrameLayout { final int zen = getSelectedZen(Global.ZEN_MODE_OFF); final boolean zenImportant = zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS; final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS; + final boolean zenAlarm = zen == Global.ZEN_MODE_ALARMS; final boolean introduction = (zenImportant && !mPrefs.mConfirmedPriorityIntroduction - || zenNone && !mPrefs.mConfirmedSilenceIntroduction); + || zenNone && !mPrefs.mConfirmedSilenceIntroduction + || zenAlarm && !mPrefs.mConfirmedAlarmIntroduction); mZenButtons.setVisibility(mHidden ? GONE : VISIBLE); mZenIntroduction.setVisibility(introduction ? VISIBLE : GONE); if (introduction) { - mConfigurableTexts.add(mZenIntroductionMessage, zenImportant + int message = zenImportant ? R.string.zen_priority_introduction - : mVoiceCapable ? R.string.zen_silence_introduction_voice - : R.string.zen_silence_introduction); + : zenAlarm + ? R.string.zen_alarms_introduction + : mVoiceCapable + ? R.string.zen_silence_introduction_voice + : R.string.zen_silence_introduction; + mConfigurableTexts.add(mZenIntroductionMessage, message); mConfigurableTexts.update(); mZenIntroductionCustomize.setVisibility(zenImportant ? VISIBLE : GONE); } @@ -963,6 +971,7 @@ public class ZenModePanel extends FrameLayout { private int mNoneSelected; private boolean mConfirmedPriorityIntroduction; private boolean mConfirmedSilenceIntroduction; + private boolean mConfirmedAlarmIntroduction; private ZenPrefs() { mNoneDangerousThreshold = mContext.getResources() @@ -972,6 +981,7 @@ public class ZenModePanel extends FrameLayout { updateNoneSelected(); updateConfirmedPriorityIntroduction(); updateConfirmedSilenceIntroduction(); + updateConfirmedAlarmIntroduction(); } public void trackNoneSelected() { @@ -999,6 +1009,7 @@ public class ZenModePanel extends FrameLayout { updateNoneSelected(); updateConfirmedPriorityIntroduction(); updateConfirmedSilenceIntroduction(); + updateConfirmedAlarmIntroduction(); } private void updateMinuteIndex() { @@ -1038,6 +1049,15 @@ public class ZenModePanel extends FrameLayout { if (DEBUG) Log.d(mTag, "Confirmed silence introduction: " + mConfirmedSilenceIntroduction); } + + private void updateConfirmedAlarmIntroduction() { + final boolean confirmed = Prefs.getBoolean(mContext, + Prefs.Key.DND_CONFIRMED_ALARM_INTRODUCTION, false); + if (confirmed == mConfirmedAlarmIntroduction) return; + mConfirmedAlarmIntroduction = confirmed; + if (DEBUG) Log.d(mTag, "Confirmed alarm introduction: " + + mConfirmedAlarmIntroduction); + } } protected final SegmentedButtons.Callback mZenButtonsCallback = new SegmentedButtons.Callback() {