Merge "resolved conflicts for 429e7dcd to master"
This commit is contained in:
committed by
Android (Google) Code Review
commit
52815c3bb4
@@ -41,6 +41,7 @@ import org.xmlpull.v1.XmlSerializer;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
@@ -661,7 +662,7 @@ public class ZenModeConfig implements Parcelable {
|
||||
int userHandle, boolean shortVersion) {
|
||||
final int num;
|
||||
String summary, line1, line2;
|
||||
final CharSequence formattedTime = getFormattedTime(context, time, minutes, userHandle);
|
||||
final CharSequence formattedTime = getFormattedTime(context, time, userHandle);
|
||||
final Resources res = context.getResources();
|
||||
if (minutes < 60) {
|
||||
// display as minutes
|
||||
@@ -694,8 +695,7 @@ public class ZenModeConfig implements Parcelable {
|
||||
|
||||
public static Condition toNextAlarmCondition(Context context, long now, long alarm,
|
||||
int userHandle) {
|
||||
int minutes = Math.round((alarm-now) / (float) MINUTES_MS);
|
||||
final CharSequence formattedTime = getFormattedTime(context, alarm, minutes, userHandle);
|
||||
final CharSequence formattedTime = getFormattedTime(context, alarm, userHandle);
|
||||
final Resources res = context.getResources();
|
||||
final String line1 = res.getString(R.string.zen_mode_alarm, formattedTime);
|
||||
final Uri id = toCountdownConditionId(alarm);
|
||||
@@ -703,11 +703,15 @@ public class ZenModeConfig implements Parcelable {
|
||||
Condition.FLAG_RELEVANT_NOW);
|
||||
}
|
||||
|
||||
private static CharSequence getFormattedTime(Context context, long time, int minutes,
|
||||
int userHandle) {
|
||||
String skeleton = DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma";
|
||||
if (minutes > DAY_MINUTES) {
|
||||
skeleton = "EEE " + (DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma");
|
||||
private static CharSequence getFormattedTime(Context context, long time, int userHandle) {
|
||||
String skeleton = "EEE " + (DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma");
|
||||
GregorianCalendar now = new GregorianCalendar();
|
||||
GregorianCalendar endTime = new GregorianCalendar();
|
||||
endTime.setTimeInMillis(time);
|
||||
if (now.get(Calendar.YEAR) == endTime.get(Calendar.YEAR)
|
||||
&& now.get(Calendar.MONTH) == endTime.get(Calendar.MONTH)
|
||||
&& now.get(Calendar.DATE) == endTime.get(Calendar.DATE)) {
|
||||
skeleton = DateFormat.is24HourFormat(context, userHandle) ? "Hm" : "hma";
|
||||
}
|
||||
final String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
|
||||
return DateFormat.format(pattern, time);
|
||||
|
||||
@@ -79,6 +79,7 @@ public class ZenModePanel extends LinearLayout {
|
||||
private static final int FOREVER_CONDITION_INDEX = 0;
|
||||
private static final int COUNTDOWN_CONDITION_INDEX = 1;
|
||||
private static final int COUNTDOWN_ALARM_CONDITION_INDEX = 2;
|
||||
private static final int COUNTDOWN_CONDITION_COUNT = 2;
|
||||
|
||||
public static final Intent ZEN_SETTINGS
|
||||
= new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
|
||||
@@ -89,7 +90,6 @@ public class ZenModePanel extends LinearLayout {
|
||||
private final LayoutInflater mInflater;
|
||||
private final H mHandler = new H();
|
||||
private final ZenPrefs mPrefs;
|
||||
private final IconPulser mIconPulser;
|
||||
private final TransitionHelper mTransitionHelper = new TransitionHelper();
|
||||
private final Uri mForeverId;
|
||||
private final SpTexts mSpTexts;
|
||||
@@ -126,7 +126,6 @@ public class ZenModePanel extends LinearLayout {
|
||||
mContext = context;
|
||||
mPrefs = new ZenPrefs();
|
||||
mInflater = LayoutInflater.from(mContext.getApplicationContext());
|
||||
mIconPulser = new IconPulser(mContext);
|
||||
mForeverId = Condition.newId(mContext).appendPath("forever").build();
|
||||
mSpTexts = new SpTexts(mContext);
|
||||
mVoiceCapable = Util.isVoiceCapable(mContext);
|
||||
@@ -297,10 +296,6 @@ public class ZenModePanel extends LinearLayout {
|
||||
}
|
||||
if (DEBUG) Log.d(mTag, "Initial bucket index: " + mBucketIndex);
|
||||
|
||||
mTimeUntilAlarmCondition = parseExistingTimeCondition(mContext, mExitCondition);
|
||||
if (mTimeUntilAlarmCondition == null) {
|
||||
mTimeUntilAlarmCondition = getTimeUntilNextAlarmCondition();
|
||||
}
|
||||
mConditions = null; // reset conditions
|
||||
handleUpdateConditions();
|
||||
} else {
|
||||
@@ -311,7 +306,7 @@ public class ZenModePanel extends LinearLayout {
|
||||
public void init(ZenModeController controller) {
|
||||
mController = controller;
|
||||
mCountdownConditionSupported = mController.isCountdownConditionSupported();
|
||||
final int countdownDelta = mCountdownConditionSupported ? 2 : 0;
|
||||
final int countdownDelta = mCountdownConditionSupported ? COUNTDOWN_CONDITION_COUNT : 0;
|
||||
final int minConditions = 1 /*forever*/ + countdownDelta;
|
||||
for (int i = 0; i < minConditions; i++) {
|
||||
mZenConditions.addView(mInflater.inflate(R.layout.zen_mode_condition, this, false));
|
||||
@@ -489,10 +484,13 @@ public class ZenModePanel extends LinearLayout {
|
||||
COUNTDOWN_CONDITION_INDEX);
|
||||
}
|
||||
// countdown until alarm
|
||||
if (mCountdownConditionSupported && mTimeUntilAlarmCondition != null) {
|
||||
bind(mTimeUntilAlarmCondition,
|
||||
mZenConditions.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX),
|
||||
COUNTDOWN_ALARM_CONDITION_INDEX);
|
||||
if (mCountdownConditionSupported) {
|
||||
Condition nextAlarmCondition = getTimeUntilNextAlarmCondition();
|
||||
if (nextAlarmCondition != null) {
|
||||
bind(nextAlarmCondition,
|
||||
mZenConditions.getChildAt(COUNTDOWN_ALARM_CONDITION_INDEX),
|
||||
COUNTDOWN_ALARM_CONDITION_INDEX);
|
||||
}
|
||||
}
|
||||
// ensure something is selected
|
||||
if (mExpanded && isShown()) {
|
||||
|
||||
Reference in New Issue
Block a user