Merge "Zen: Add new user introduction msg for "Priority only"."

This commit is contained in:
John Spurlock
2015-04-14 20:00:16 +00:00
committed by Android (Google) Code Review
16 changed files with 283 additions and 62 deletions

View File

@@ -41,8 +41,6 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="4dp"
android:paddingEnd="4dp"
android:paddingStart="4dp"
android:paddingTop="6dp" >
<!-- volume rows added and removed here! :-) -->

View File

@@ -16,6 +16,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:clipChildren="false" >
<TextView

View File

@@ -24,6 +24,8 @@
android:id="@+id/volume_zen_switch_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/volume_button_size"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:clickable="true"
android:orientation="horizontal" >
@@ -49,6 +51,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginEnd="11dp" />
</LinearLayout>
<RelativeLayout
@@ -56,8 +59,8 @@
android:layout_width="match_parent"
android:layout_height="@dimen/volume_button_size"
android:layout_marginStart="@dimen/volume_button_size"
android:paddingEnd="3dp"
android:paddingStart="3dp" >
android:paddingEnd="7dp"
android:paddingStart="7dp" >
<TextView
android:id="@+id/volume_zen_panel_summary_line_1"
@@ -79,6 +82,8 @@
android:id="@+id/volume_zen_mode_panel_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:gravity="end" >
<TextView

View File

@@ -19,7 +19,6 @@
android:id="@+id/zen_mode_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="35dp"
android:clipChildren="false"
android:orientation="vertical" >
@@ -28,6 +27,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="8dp"
android:layout_marginStart="39dp"
android:elevation="4dp"
android:background="@drawable/qs_background_secondary" >
@@ -46,15 +46,13 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:visibility="gone"
android:layout_marginStart="@dimen/qs_panel_padding"
android:layout_marginEnd="@dimen/qs_panel_padding"
android:layout_marginBottom="@dimen/qs_panel_padding"
android:background="#4dffffff" />
<RelativeLayout
android:id="@+id/zen_subhead"
android:layout_width="match_parent"
android:layout_height="62dp"
android:layout_marginStart="39dp"
android:gravity="center_vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
@@ -98,10 +96,60 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/zen_introduction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:background="@color/zen_introduction_message_background" >
<ImageView
android:id="@+id/zen_introduction_confirm"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:background="@drawable/btn_borderless_rect"
android:clickable="true"
android:contentDescription="@string/accessibility_desc_confirm"
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="55dp"
android:lineSpacingMultiplier="1.20029"
android:layout_toStartOf="@id/zen_introduction_confirm"
android:text="@string/zen_priority_introduction"
android:textAppearance="@style/TextAppearance.QS.VolumeSuppressor" />
<TextView
android:id="@+id/zen_introduction_customize"
style="@style/QSBorderlessButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="4dp"
android:layout_below="@id/zen_introduction_message"
android:clickable="true"
android:focusable="true"
android:text="@string/zen_priority_customize_button"
android:textAppearance="@style/TextAppearance.QS.DetailButton.White" />
</RelativeLayout>
<LinearLayout
android:id="@+id/zen_conditions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="4dp"
android:layout_marginStart="39dp"
android:orientation="vertical"
android:paddingBottom="@dimen/zen_mode_condition_detail_bottom_padding" />

View File

@@ -44,6 +44,7 @@
<color name="qs_subhead">#99FFFFFF</color><!-- 60% white -->
<color name="qs_detail_empty">#24B0BEC5</color><!-- 14% blue grey 200 -->
<color name="qs_detail_button">#FFB0BEC5</color><!-- 100% blue grey 200 -->
<color name="qs_detail_button_white">#B3FFFFFF</color><!-- 70% white -->
<color name="qs_detail_transition">#66FFFFFF</color>
<color name="qs_detail_progress_track">#99009688</color><!-- 60% deep teal 500 -->
<color name="data_usage_secondary">#99FFFFFF</color><!-- 60% white -->
@@ -137,4 +138,6 @@
<color name="light_mode_icon_color_single_tone">#ffffff</color>
<color name="light_mode_icon_color_dual_tone_background">#4dffffff</color>
<color name="light_mode_icon_color_dual_tone_fill">#ffffff</color>
<color name="zen_introduction_message_background">#ff009688</color><!-- deep teal 500 -->
</resources>

View File

@@ -410,6 +410,8 @@
<string name="accessibility_desc_settings">Settings</string>
<!-- Content description for the recent apps panel (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_recent_apps">Overview.</string>
<!-- Content description for the confirm button in the zen mode panel introduction message. [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_confirm">Confirm</string>
<!-- Content description of the user tile in quick settings (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_user">User <xliff:g id="user" example="John Doe">%s</xliff:g>.</string>
@@ -723,6 +725,12 @@
<!-- Zen mode: No interruptions title, with a warning about alarms. [CHAR LIMIT=60] -->
<string name="zen_no_interruptions_with_warning">No interruptions. Not even alarms.</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>
<!-- Zen mode: Priority only customization button label -->
<string name="zen_priority_customize_button">Customize</string>
<!-- Zen mode: No interruptions. [CHAR LIMIT=40] -->
<string name="zen_no_interruptions">No interruptions</string>

View File

@@ -151,6 +151,10 @@
<item name="android:gravity">center</item>
</style>
<style name="TextAppearance.QS.DetailButton.White">
<item name="android:textColor">@color/qs_detail_button_white</item>
</style>
<style name="TextAppearance.QS.DetailEmpty">
<item name="android:textSize">@dimen/qs_detail_empty_text_size</item>
<item name="android:textColor">@color/qs_subhead</item>

View File

@@ -35,7 +35,10 @@ public final class Prefs {
Key.HOTSPOT_TILE_LAST_USED,
Key.COLOR_INVERSION_TILE_LAST_USED,
Key.DND_TILE_VISIBLE,
Key.DND_TILE_COMBINED_ICON
Key.DND_TILE_COMBINED_ICON,
Key.DND_CONFIRMED_PRIORITY_INTRODUCTION,
Key.DND_FAVORITE_BUCKET_INDEX,
Key.DND_NONE_SELECTED,
})
public @interface Key {
String SEARCH_APP_WIDGET_ID = "searchAppWidgetId";
@@ -44,6 +47,9 @@ public final class Prefs {
String COLOR_INVERSION_TILE_LAST_USED = "ColorInversionTileLastUsed";
String DND_TILE_VISIBLE = "DndTileVisible";
String DND_TILE_COMBINED_ICON = "DndTileCombinedIcon";
String DND_CONFIRMED_PRIORITY_INTRODUCTION = "DndConfirmedPriorityIntroduction";
String DND_FAVORITE_BUCKET_INDEX = "DndCountdownMinuteIndex";
String DND_NONE_SELECTED = "DndNoneSelected";
}
public static boolean getBoolean(Context context, @Key String key, boolean defaultValue) {

View File

@@ -107,20 +107,22 @@ public class VolumeDialog {
private boolean mShowing;
private boolean mExpanded;
private int mActiveStream;
private boolean mShowHeaders = Prefs.DEFAULT_SHOW_HEADERS;
private boolean mShowFooter = Prefs.DEFAULT_SHOW_FOOTER;
private boolean mShowZenFooter = Prefs.DEFAULT_ZEN_FOOTER;
private boolean mAutomute = Prefs.DEFAULT_ENABLE_AUTOMUTE;
private boolean mSilentMode = Prefs.DEFAULT_ENABLE_SILENT_MODE;
private boolean mShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS;
private boolean mShowFooter = VolumePrefs.DEFAULT_SHOW_FOOTER;
private boolean mShowZenFooter = VolumePrefs.DEFAULT_ZEN_FOOTER;
private boolean mAutomute = VolumePrefs.DEFAULT_ENABLE_AUTOMUTE;
private boolean mSilentMode = VolumePrefs.DEFAULT_ENABLE_SILENT_MODE;
private State mState;
private int mExpandButtonRes;
private boolean mExpanding;
private SafetyWarningDialog mSafetyWarning;
private Callback mCallback;
public VolumeDialog(Context context, VolumeDialogController controller,
ZenModeController zenModeController) {
ZenModeController zenModeController, Callback callback) {
mContext = context;
mController = controller;
mCallback = callback;
mSpTexts = new SpTexts(mContext);
mKeyguard = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
@@ -421,14 +423,6 @@ public class VolumeDialog {
mHandler.obtainMessage(H.DISMISS, reason, 0).sendToTarget();
}
protected void onSettingsClickedH() {
// hook for subclasses
}
protected void onZenSettingsClickedH() {
// hook for subclasses
}
private void showH(int reason) {
mHandler.removeMessages(H.SHOW);
mHandler.removeMessages(H.DISMISS);
@@ -885,7 +879,9 @@ public class VolumeDialog {
@Override
public void run() {
Events.writeEvent(Events.EVENT_SETTINGS_CLICK);
onSettingsClickedH();
if (mCallback != null) {
mCallback.onSettingsClicked();
}
}
}, WAIT_FOR_RIPPLE);
}
@@ -912,13 +908,23 @@ public class VolumeDialog {
@Override
public void onSettingsClicked() {
dismiss(Events.DISMISS_REASON_SETTINGS_CLICKED);
onZenSettingsClickedH();
if (mCallback != null) {
mCallback.onZenSettingsClicked();
}
}
@Override
public void onDoneClicked() {
dismiss(Events.DISMISS_REASON_DONE_CLICKED);
}
@Override
public void onPrioritySettingsClicked() {
dismiss(Events.DISMISS_REASON_SETTINGS_CLICKED);
if (mCallback != null) {
mCallback.onZenPrioritySettingsClicked();
}
}
};
private final class H extends Handler {
@@ -1052,10 +1058,16 @@ public class VolumeDialog {
private boolean important;
private int cachedIconRes;
private int iconState; // from Events
private boolean cachedShowHeaders = Prefs.DEFAULT_SHOW_HEADERS;
private boolean cachedShowHeaders = VolumePrefs.DEFAULT_SHOW_HEADERS;
private int cachedExpandButtonRes;
private ObjectAnimator anim; // slider progress animation for non-touch-related updates
private int animTargetProgress;
private int lastAudibleLevel = 1;
}
public interface Callback {
void onSettingsClicked();
void onZenSettingsClicked();
void onZenPrioritySettingsClicked();
}
}

View File

@@ -17,11 +17,13 @@
package com.android.systemui.volume;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.media.VolumePolicy;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import com.android.systemui.SystemUI;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -53,12 +55,7 @@ public class VolumeDialogComponent implements VolumeComponent {
}
};
mZenModeController = zen;
mDialog = new VolumeDialog(context, mController, zen) {
@Override
protected void onZenSettingsClickedH() {
startZenSettings();
}
};
mDialog = new VolumeDialog(context, mController, zen, mVolumeDialogCallback);
applyConfiguration();
}
@@ -113,8 +110,26 @@ public class VolumeDialogComponent implements VolumeComponent {
mDialog.dump(pw);
}
private void startZenSettings() {
mSysui.getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(
ZenModePanel.ZEN_SETTINGS, true /* onlyProvisioned */, true /* dismissShade */);
private void startSettings(Intent intent) {
mSysui.getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(intent,
true /* onlyProvisioned */, true /* dismissShade */);
}
private final VolumeDialog.Callback mVolumeDialogCallback = new VolumeDialog.Callback() {
@Override
public void onSettingsClicked() {
startSettings(new Intent(Settings.ACTION_NOTIFICATION_SETTINGS));
}
@Override
public void onZenSettingsClicked() {
startSettings(ZenModePanel.ZEN_SETTINGS);
}
@Override
public void onZenPrioritySettingsClicked() {
startSettings(ZenModePanel.ZEN_PRIORITY_SETTINGS);
}
};
}

View File

@@ -427,6 +427,13 @@ public class VolumePanel extends Handler implements DemoMode {
}
}
@Override
public void onPrioritySettings() {
if (mCallback != null) {
mCallback.onZenPrioritySettings();
}
}
@Override
public void onInteraction() {
resetTimeout();
@@ -1524,6 +1531,7 @@ public class VolumePanel extends Handler implements DemoMode {
public interface Callback {
void onZenSettings();
void onZenPrioritySettings();
void onInteraction();
void onVisible(boolean visible);
}

View File

@@ -17,6 +17,7 @@
package com.android.systemui.volume;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.media.AudioManager;
import android.media.IRemoteVolumeController;
@@ -73,6 +74,12 @@ public class VolumePanelComponent implements VolumeComponent {
mHandler.post(mStartZenSettings);
}
@Override
public void onZenPrioritySettings() {
mHandler.removeCallbacks(mStartZenPrioritySettings);
mHandler.post(mStartZenPrioritySettings);
}
@Override
public void onInteraction() {
final KeyguardViewMediator kvm = mSysui.getComponent(KeyguardViewMediator.class);
@@ -126,12 +133,23 @@ public class VolumePanelComponent implements VolumeComponent {
mPanel.postDismiss(0);
}
private void startSettings(Intent intent) {
mSysui.getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(intent,
true /* onlyProvisioned */, true /* dismissShade */);
mPanel.postDismiss(mDismissDelay);
}
private final Runnable mStartZenSettings = new Runnable() {
@Override
public void run() {
mSysui.getComponent(PhoneStatusBar.class).startActivityDismissingKeyguard(
ZenModePanel.ZEN_SETTINGS, true /* onlyProvisioned */, true /* dismissShade */);
mPanel.postDismiss(mDismissDelay);
startSettings(ZenModePanel.ZEN_SETTINGS);
}
};
private final Runnable mStartZenPrioritySettings = new Runnable() {
@Override
public void run() {
startSettings(ZenModePanel.ZEN_PRIORITY_SETTINGS);
}
};

View File

@@ -24,7 +24,7 @@ import android.preference.PreferenceManager;
/**
* Configuration for the volume dialog + related policy.
*/
public class Prefs {
public class VolumePrefs {
public static final String PREF_ENABLE_PROTOTYPE = "pref_enable_prototype"; // not persistent
public static final String PREF_SHOW_ALARMS = "pref_show_alarms";

View File

@@ -36,6 +36,7 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
import com.android.systemui.qs.tiles.DndTile;
@@ -172,18 +173,40 @@ public class VolumeUI extends SystemUI {
private static final String DISABLE = "com.android.systemui.vui.DISABLE";
private static final String EXTRA_COMPONENT = "component";
private static final String PREF = "com.android.systemui.PREF";
private static final String EXTRA_KEY = "key";
private static final String EXTRA_VALUE = "value";
public void start() {
final IntentFilter filter = new IntentFilter();
filter.addAction(ENABLE);
filter.addAction(DISABLE);
filter.addAction(PREF);
mContext.registerReceiver(this, filter, null, mHandler);
}
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (PREF.equals(action)) {
final String key = intent.getStringExtra(EXTRA_KEY);
if (key != null && intent.getExtras() != null) {
final Object value = intent.getExtras().get(EXTRA_VALUE);
if (value == null) {
Prefs.remove(mContext, key);
} else if (value instanceof Boolean) {
Prefs.putBoolean(mContext, key, (Boolean) value);
} else if (value instanceof Integer) {
Prefs.putInt(mContext, key, (Integer) value);
} else if (value instanceof Long) {
Prefs.putLong(mContext, key, (Long) value);
}
}
return;
}
final ComponentName component = intent.getParcelableExtra(EXTRA_COMPONENT);
final boolean current = component.equals(mVolumeControllerService.getComponent());
final boolean current = component != null
&& component.equals(mVolumeControllerService.getComponent());
if (ENABLE.equals(action) && component != null) {
if (!current) {
showServiceActivationDialog(component);

View File

@@ -99,6 +99,7 @@ public class ZenFooter extends LinearLayout {
mController = controller;
mZenModePanel.init(controller);
mZenModePanel.setEmbedded(true);
mZenModePanel.setCallback(mZenModePanelCallback);
mSwitch.setOnCheckedChangeListener(mCheckedListener);
mController.addCallback(new ZenModeController.Callback() {
@Override
@@ -212,6 +213,32 @@ public class ZenFooter extends LinearLayout {
Util.setText(mSummaryLine2, line2);
}
private final ZenModePanel.Callback mZenModePanelCallback = new ZenModePanel.Callback() {
@Override
public void onMoreSettings() {
if (mCallback != null) {
mCallback.onSettingsClicked();
}
}
@Override
public void onPrioritySettings() {
if (mCallback != null) {
mCallback.onPrioritySettingsClicked();
}
}
@Override
public void onInteraction() {
// noop
}
@Override
public void onExpanded(boolean expanded) {
// noop
}
};
private final OnCheckedChangeListener mCheckedListener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -230,5 +257,6 @@ public class ZenFooter extends LinearLayout {
void onFooterExpanded();
void onSettingsClicked();
void onDoneClicked();
void onPrioritySettingsClicked();
}
}

View File

@@ -50,6 +50,7 @@ import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ZenModeController;
@@ -74,12 +75,15 @@ public class ZenModePanel extends LinearLayout {
private static final int FOREVER_CONDITION_INDEX = 0;
private static final int COUNTDOWN_CONDITION_INDEX = 1;
public static final Intent ZEN_SETTINGS = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
public static final Intent ZEN_SETTINGS
= new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
public static final Intent ZEN_PRIORITY_SETTINGS
= new Intent(Settings.ACTION_ZEN_MODE_PRIORITY_SETTINGS);
private final Context mContext;
private final LayoutInflater mInflater;
private final H mHandler = new H();
private final Prefs mPrefs;
private final ZenPrefs mPrefs;
private final IconPulser mIconPulser;
private final int mSubheadWarningColor;
private final int mSubheadColor;
@@ -96,6 +100,9 @@ public class ZenModePanel extends LinearLayout {
private TextView mZenSubheadExpanded;
private View mZenEmbeddedDivider;
private View mMoreSettings;
private View mZenIntroduction;
private View mZenIntroductionConfirm;
private View mZenIntroductionCustomize;
private LinearLayout mZenConditions;
private Callback mCallback;
@@ -121,7 +128,7 @@ public class ZenModePanel extends LinearLayout {
public ZenModePanel(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
mPrefs = new Prefs();
mPrefs = new ZenPrefs();
mInflater = LayoutInflater.from(mContext.getApplicationContext());
mIconPulser = new IconPulser(mContext);
mSubheadWarningColor = context.getColor(R.color.system_warning_color);
@@ -202,11 +209,36 @@ public class ZenModePanel extends LinearLayout {
});
Interaction.register(mMoreSettings, mInteractionCallback);
mZenIntroduction = findViewById(R.id.zen_introduction);
mZenIntroductionConfirm = findViewById(R.id.zen_introduction_confirm);
mZenIntroductionConfirm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
confirmZenIntroduction();
}
});
mZenIntroductionCustomize = findViewById(R.id.zen_introduction_customize);
mZenIntroductionCustomize.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
confirmZenIntroduction();
if (mCallback != null) {
mCallback.onPrioritySettings();
}
}
});
mZenConditions = (LinearLayout) findViewById(R.id.zen_conditions);
setLayoutTransition(newLayoutTransition(mTransitionHelper));
}
private void confirmZenIntroduction() {
if (DEBUG) Log.d(TAG, "confirmZenIntroduction");
Prefs.putBoolean(mContext, Prefs.Key.DND_CONFIRMED_PRIORITY_INTRODUCTION, true);
mHandler.sendEmptyMessage(H.UPDATE_WIDGETS);
}
private LayoutTransition newLayoutTransition(TransitionListener listener) {
final LayoutTransition transition = new LayoutTransition();
transition.disableTransitionType(LayoutTransition.DISAPPEARING);
@@ -452,13 +484,15 @@ public class ZenModePanel extends LinearLayout {
final boolean zenImportant = zen == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
final boolean zenNone = zen == Global.ZEN_MODE_NO_INTERRUPTIONS;
final boolean expanded = !mHidden && mExpanded;
final boolean conditions = mEmbedded || !zenOff && expanded;
final boolean introduction = conditions && zenImportant && !mPrefs.mConfirmedIntroduction;
mZenButtons.setVisibility(mHidden ? GONE : VISIBLE);
mZenSubhead.setVisibility(!mHidden && !zenOff && !mEmbedded ? VISIBLE : GONE);
mZenSubheadExpanded.setVisibility(expanded ? VISIBLE : GONE);
mZenSubheadCollapsed.setVisibility(!expanded ? VISIBLE : GONE);
mMoreSettings.setVisibility(zenImportant && expanded ? VISIBLE : GONE);
mZenConditions.setVisibility(mEmbedded || !zenOff && expanded ? VISIBLE : GONE);
mZenConditions.setVisibility(conditions ? VISIBLE : GONE);
if (zenNone) {
mZenSubheadExpanded.setText(R.string.zen_no_interruptions_with_warning);
@@ -469,6 +503,7 @@ public class ZenModePanel extends LinearLayout {
}
mZenSubheadExpanded.setTextColor(zenNone && mPrefs.isNoneDangerous()
? mSubheadWarningColor : mSubheadColor);
mZenIntroduction.setVisibility(introduction ? VISIBLE : GONE);
}
private static Condition parseExistingTimeCondition(Context context, Condition condition) {
@@ -835,6 +870,7 @@ public class ZenModePanel extends LinearLayout {
private final class H extends Handler {
private static final int UPDATE_CONDITIONS = 1;
private static final int MANUAL_RULE_CHANGED = 2;
private static final int UPDATE_WIDGETS = 3;
private H() {
super(Looper.getMainLooper());
@@ -842,16 +878,17 @@ public class ZenModePanel extends LinearLayout {
@Override
public void handleMessage(Message msg) {
if (msg.what == UPDATE_CONDITIONS) {
handleUpdateConditions((Condition[]) msg.obj);
} else if (msg.what == MANUAL_RULE_CHANGED) {
handleUpdateManualRule((ZenRule) msg.obj);
switch (msg.what) {
case UPDATE_CONDITIONS: handleUpdateConditions((Condition[]) msg.obj); break;
case MANUAL_RULE_CHANGED: handleUpdateManualRule((ZenRule) msg.obj); break;
case UPDATE_WIDGETS: updateWidgets(); break;
}
}
}
public interface Callback {
void onMoreSettings();
void onPrioritySettings();
void onInteraction();
void onExpanded(boolean expanded);
}
@@ -865,21 +902,20 @@ public class ZenModePanel extends LinearLayout {
Condition condition;
}
private final class Prefs implements OnSharedPreferenceChangeListener {
private static final String KEY_MINUTE_INDEX = "minuteIndex";
private static final String KEY_NONE_SELECTED = "noneSelected";
private final class ZenPrefs implements OnSharedPreferenceChangeListener {
private final int mNoneDangerousThreshold;
private int mMinuteIndex;
private int mNoneSelected;
private boolean mConfirmedIntroduction;
private Prefs() {
private ZenPrefs() {
mNoneDangerousThreshold = mContext.getResources()
.getInteger(R.integer.zen_mode_alarm_warning_threshold);
prefs().registerOnSharedPreferenceChangeListener(this);
Prefs.registerListener(mContext, this);
updateMinuteIndex();
updateNoneSelected();
updateConfirmedIntroduction();
}
public boolean isNoneDangerous() {
@@ -890,7 +926,7 @@ public class ZenModePanel extends LinearLayout {
mNoneSelected = clampNoneSelected(mNoneSelected + 1);
if (DEBUG) Log.d(mTag, "Setting none selected: " + mNoneSelected + " threshold="
+ mNoneDangerousThreshold);
prefs().edit().putInt(KEY_NONE_SELECTED, mNoneSelected).apply();
Prefs.putInt(mContext, Prefs.Key.DND_NONE_SELECTED, mNoneSelected);
}
public int getMinuteIndex() {
@@ -902,21 +938,19 @@ public class ZenModePanel extends LinearLayout {
if (minuteIndex == mMinuteIndex) return;
mMinuteIndex = clampIndex(minuteIndex);
if (DEBUG) Log.d(mTag, "Setting favorite minute index: " + mMinuteIndex);
prefs().edit().putInt(KEY_MINUTE_INDEX, mMinuteIndex).apply();
Prefs.putInt(mContext, Prefs.Key.DND_FAVORITE_BUCKET_INDEX, mMinuteIndex);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
updateMinuteIndex();
updateNoneSelected();
}
private SharedPreferences prefs() {
return mContext.getSharedPreferences(mContext.getPackageName(), 0);
updateConfirmedIntroduction();
}
private void updateMinuteIndex() {
mMinuteIndex = clampIndex(prefs().getInt(KEY_MINUTE_INDEX, DEFAULT_BUCKET_INDEX));
mMinuteIndex = clampIndex(Prefs.getInt(mContext,
Prefs.Key.DND_FAVORITE_BUCKET_INDEX, DEFAULT_BUCKET_INDEX));
if (DEBUG) Log.d(mTag, "Favorite minute index: " + mMinuteIndex);
}
@@ -925,13 +959,22 @@ public class ZenModePanel extends LinearLayout {
}
private void updateNoneSelected() {
mNoneSelected = clampNoneSelected(prefs().getInt(KEY_NONE_SELECTED, 0));
mNoneSelected = clampNoneSelected(Prefs.getInt(mContext,
Prefs.Key.DND_NONE_SELECTED, 0));
if (DEBUG) Log.d(mTag, "None selected: " + mNoneSelected);
}
private int clampNoneSelected(int noneSelected) {
return MathUtils.constrain(noneSelected, 0, Integer.MAX_VALUE);
}
private void updateConfirmedIntroduction() {
final boolean confirmed = Prefs.getBoolean(mContext,
Prefs.Key.DND_CONFIRMED_PRIORITY_INTRODUCTION, false);
if (confirmed == mConfirmedIntroduction) return;
mConfirmedIntroduction = confirmed;
if (DEBUG) Log.d(mTag, "Confirmed introduction: " + mConfirmedIntroduction);
}
}
private final SegmentedButtons.Callback mZenButtonsCallback = new SegmentedButtons.Callback() {