Display days of week in locale order. am: 0bb60ada96
am: c3997cbae1
Change-Id: Ic8837b2b5c1985910a02edf62316597bdff87122
This commit is contained in:
@@ -32,16 +32,6 @@ import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class ZenModeScheduleDaysSelection extends ScrollView {
|
||||
public static final int[] DAYS = {
|
||||
Calendar.SUNDAY,
|
||||
Calendar.MONDAY,
|
||||
Calendar.TUESDAY,
|
||||
Calendar.WEDNESDAY,
|
||||
Calendar.THURSDAY,
|
||||
Calendar.FRIDAY,
|
||||
Calendar.SATURDAY,
|
||||
};
|
||||
|
||||
// per-instance to ensure we're always using the current locale
|
||||
private final SimpleDateFormat mDayFormat = new SimpleDateFormat("EEEE");
|
||||
private final SparseBooleanArray mDays = new SparseBooleanArray();
|
||||
@@ -61,9 +51,10 @@ public class ZenModeScheduleDaysSelection extends ScrollView {
|
||||
}
|
||||
mLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int[] daysOfWeek = getDaysOfWeekForLocale(c);
|
||||
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||
for (int i = 0; i < DAYS.length; i++) {
|
||||
final int day = DAYS[i];
|
||||
for (int i = 0; i < daysOfWeek.length; i++) {
|
||||
final int day = daysOfWeek[i];
|
||||
final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.zen_schedule_rule_day,
|
||||
this, false);
|
||||
c.set(Calendar.DAY_OF_WEEK, day);
|
||||
@@ -95,6 +86,17 @@ public class ZenModeScheduleDaysSelection extends ScrollView {
|
||||
return rta;
|
||||
}
|
||||
|
||||
protected static int[] getDaysOfWeekForLocale(Calendar c) {
|
||||
int[] daysOfWeek = new int[7];
|
||||
int currentDay = c.getFirstDayOfWeek();
|
||||
for (int i = 0; i < daysOfWeek.length; i++) {
|
||||
if (currentDay > 7) currentDay = 1;
|
||||
daysOfWeek[i] = currentDay;
|
||||
currentDay++;
|
||||
}
|
||||
return daysOfWeek;
|
||||
}
|
||||
|
||||
protected void onChanged(int[] days) {
|
||||
// event hook for subclasses
|
||||
}
|
||||
|
@@ -44,8 +44,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
||||
import static com.android.settings.notification.ZenModeScheduleDaysSelection.DAYS;
|
||||
|
||||
public class ZenModeScheduleRuleSettings extends ZenModeRuleSettingsBase {
|
||||
private static final String KEY_DAYS = "days";
|
||||
private static final String KEY_START_TIME = "start_time";
|
||||
@@ -158,8 +156,9 @@ public class ZenModeScheduleRuleSettings extends ZenModeRuleSettingsBase {
|
||||
if (days != null && days.length > 0) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final Calendar c = Calendar.getInstance();
|
||||
for (int i = 0; i < DAYS.length; i++) {
|
||||
final int day = DAYS[i];
|
||||
int[] daysOfWeek = ZenModeScheduleDaysSelection.getDaysOfWeekForLocale(c);
|
||||
for (int i = 0; i < daysOfWeek.length; i++) {
|
||||
final int day = daysOfWeek[i];
|
||||
for (int j = 0; j < days.length; j++) {
|
||||
if (day == days[j]) {
|
||||
c.set(Calendar.DAY_OF_WEEK, day);
|
||||
|
Reference in New Issue
Block a user