diff options
6 files changed, 124 insertions, 27 deletions
diff --git a/packages/SystemUI/res/layout/volume_zen_footer.xml b/packages/SystemUI/res/layout/volume_zen_footer.xml index 775b1576b763..91dc6178cd86 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" /> + + <RelativeLayout + android:id="@+id/zen_introduction" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:paddingTop="8dp" + android:paddingBottom="8dp" + android:background="@drawable/zen_introduction_message_background" + android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent.Light"> + + <ImageView + android:id="@+id/zen_introduction_confirm" + android:layout_width="48dp" + android:layout_height="48dp" + android:layout_marginEnd="8dp" + android:layout_alignParentEnd="true" + android:background="@drawable/btn_borderless_rect" + android:clickable="true" + android:contentDescription="@string/accessibility_desc_close" + android:scaleType="center" + android:src="@drawable/ic_close" + android:tint="@android:color/white" /> + + <TextView + android:id="@+id/zen_introduction_message" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="12dp" + android:layout_marginStart="24dp" + android:textDirection="locale" + android:lineSpacingMultiplier="1.20029" + android:layout_toStartOf="@id/zen_introduction_confirm" + android:text="@string/zen_alarms_introduction" + android:textAppearance="@style/TextAppearance.QS.Introduction" /> + + <View + android:layout_width="0dp" + android:layout_height="16dp" + android:layout_below="@id/zen_introduction_message" + android:layout_alignParentEnd="true" /> + + </RelativeLayout> + + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index d15fcaec2b28..64b5f4bd6913 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -838,7 +838,10 @@ <string name="description_direction_left">"Slide left for <xliff:g id="target_description" example="Unlock">%s</xliff:g>.</string> <!-- Zen mode: Priority only introduction message on first use --> - <string name="zen_priority_introduction">You won’t be disturbed by sounds and vibrations, except from alarms, reminders, events, and callers you specify.</string> + <string name="zen_priority_introduction">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.</string> + + <!-- Zen mode: Alarms only introduction message on first use --> + <string name="zen_alarms_introduction">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.</string> <!-- Zen mode: Priority only customization button label --> <string name="zen_priority_customize_button">Customize</string> @@ -1211,7 +1214,7 @@ <string name="zen_mode_and_condition"><xliff:g id="zen_mode" example="Priority interruptions only">%1$s</xliff:g>. <xliff:g id="exit_condition" example="For one hour">%2$s</xliff:g></string> <!-- Button label for ending zen mode in the volume dialog --> - <string name="volume_zen_end_now">End now</string> + <string name="volume_zen_end_now">Turn off now</string> <!-- Content description for accessibility (not shown on the screen): volume dialog expand button. [CHAR LIMIT=NONE] --> <string name="accessibility_volume_expand">Expand</string> diff --git a/packages/SystemUI/src/com/android/systemui/Prefs.java b/packages/SystemUI/src/com/android/systemui/Prefs.java index 1e9cbdc45425..3cc81dfb45d7 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 b8b046b9990d..8d8931f9989d 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 10b6ff5cdfdc..17d98b19277e 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 fffcc087223f..51fcdbb92c81 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() { |