summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeeti Paananen <veeti.paananen@rojekti.fi>2013-11-17 06:42:50 +0200
committerSteve Kondik <steve@cyngn.com>2015-10-18 13:52:38 -0700
commit696028c0230ee80305617df1196f2e3ed2584899 (patch)
tree1b9cbe9e9e7a03767db34eb3e7d1b88bf30d372f
parent0e9cabffc2a262ad2432f28d94d8dae672af87fb (diff)
downloadandroid_packages_apps_Calendar-696028c0230ee80305617df1196f2e3ed2584899.tar.gz
android_packages_apps_Calendar-696028c0230ee80305617df1196f2e3ed2584899.tar.bz2
android_packages_apps_Calendar-696028c0230ee80305617df1196f2e3ed2584899.zip
Add an option for the default view to show on startup
Typically, the Calendar application opens with the previously used view (day, week, ...). This adds an option to select another view as the default when starting the app. Change-Id: I43c549b777ed30f67a18c6a862d2d833c5528d54
-rw-r--r--res/values/arrays.xml14
-rw-r--r--res/values/cm_arrays.xml49
-rw-r--r--res/values/cm_strings.xml34
-rw-r--r--res/values/strings.xml13
-rw-r--r--res/xml/general_preferences.xml6
-rw-r--r--src/com/android/calendar/GeneralPreferences.java10
-rw-r--r--src/com/android/calendar/Utils.java14
7 files changed, 110 insertions, 30 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 1fba624e..b14854a3 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -122,20 +122,6 @@
<item>"10080"</item>
</string-array>
- <string-array name="preferences_default_snooze_delay_values" translatable="false">
- <item>"5"</item>
- <item>"10"</item>
- <item>"15"</item>
- <item>"20"</item>
- <item>"25"</item>
- <item>"30"</item>
- <item>"45"</item>
- <item>"60"</item>
- <item>"120"</item>
- <item>"180"</item>
- <item>"720"</item>
- </string-array>
-
<string-array name="preferences_week_start_day_labels">
<item>Locale default</item>
<item>Saturday</item>
diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml
new file mode 100644
index 00000000..cc85ef0c
--- /dev/null
+++ b/res/values/cm_arrays.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012-2013 The CyanogenMod Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="preferences_default_snooze_delay_values" translatable="false">
+ <item>"5"</item>
+ <item>"10"</item>
+ <item>"15"</item>
+ <item>"20"</item>
+ <item>"25"</item>
+ <item>"30"</item>
+ <item>"45"</item>
+ <item>"60"</item>
+ <item>"120"</item>
+ <item>"180"</item>
+ <item>"720"</item>
+ </string-array>
+
+ <!-- Labels for the default startup page preference. -->
+ <string-array name="default_start_entries">
+ <item>@string/default_start_last</item>
+ <item>@string/day_view</item>
+ <item>@string/week_view</item>
+ <item>@string/month_view</item>
+ <item>@string/agenda_view</item>
+ </string-array>
+
+ <!-- Values for the default startup page preference. See CalendarController.ViewType. -->
+ <string-array name="default_start_values" translatable="false">
+ <item>-2</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>1</item>
+ </string-array>
+</resources>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
new file mode 100644
index 00000000..dda2a801
--- /dev/null
+++ b/res/values/cm_strings.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2012-2013 The CyanogenMod Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="preferences_alerts_custom_snooze_delay_title">Ask for reminder snooze delay</string>
+ <!-- Summaries for using custom snooze delays -->
+ <string name="preferences_alerts_custom_snooze_delay_summary_on">Ask for snooze delay whenever snoozing reminders</string>
+ <string name="preferences_alerts_custom_snooze_delay_summary_off">Always use default snooze delay</string>
+ <!-- Title of custom snooze delay dialog -->
+ <string name="snooze_delay_dialog_title">Set snooze delay</string>
+ <!-- List item label for setting the default snooze delay -->
+ <string name="preferences_default_snooze_delay_title">Default snooze delay time</string>
+ <!-- Title of dialog for setting the default snooze delay -->
+ <string name="preferences_default_snooze_delay_dialog">Default snooze delay</string>
+ <!-- Default value for the default snooze delay (in minutes) -->
+ <string name="preferences_default_snooze_delay_default" translatable="false">5</string>
+
+ <!-- Label values for the default start page preference. -->
+ <string name="default_start_title">Default view</string>
+ <string name="default_start_last">Previously used view</string>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aa3ced67..caec61b5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -542,19 +542,6 @@
<string name="preferences_default_reminder_dialog">Default reminder time</string>
<!-- Default value for the number of reminder minutes -->
<string name="preferences_default_reminder_default">10</string>
- <!-- Check box label for using custom snooze delays -->
- <string name="preferences_alerts_custom_snooze_delay_title">Ask for reminder snooze delay</string>
- <!-- Summaries for using custom snooze delays -->
- <string name="preferences_alerts_custom_snooze_delay_summary_on">Ask for snooze delay whenever snoozing reminders</string>
- <string name="preferences_alerts_custom_snooze_delay_summary_off">Always use default snooze delay</string>
- <!-- Title of custom snooze delay dialog -->
- <string name="snooze_delay_dialog_title">Set snooze delay</string>
- <!-- List item label for setting the default snooze delay -->
- <string name="preferences_default_snooze_delay_title">Default snooze delay time</string>
- <!-- Title of dialog for setting the default snooze delay -->
- <string name="preferences_default_snooze_delay_dialog">Default snooze delay</string>
- <!-- Default value for the default snooze delay (in minutes) -->
- <string name="preferences_default_snooze_delay_default" translatable="false">5</string>
<!-- Settings check box label to keep Calendar in a fixed 'home' time zone [CHAR LIMIT = 18] -->
<string name="preferences_use_home_tz_title">Use home time zone</string>
<!-- Settings description of what setting Calendar to use a fixed 'home' time
diff --git a/res/xml/general_preferences.xml b/res/xml/general_preferences.xml
index 8bffd0e0..fe812a76 100644
--- a/res/xml/general_preferences.xml
+++ b/res/xml/general_preferences.xml
@@ -16,6 +16,12 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/preferences_general_title">
+ <ListPreference
+ android:key="preferences_default_start"
+ android:defaultValue="-2"
+ android:title="@string/default_start_title"
+ android:entries="@array/default_start_entries"
+ android:entryValues="@array/default_start_values" />
<CheckBoxPreference
android:key="preferences_hide_declined"
android:defaultValue="false"
diff --git a/src/com/android/calendar/GeneralPreferences.java b/src/com/android/calendar/GeneralPreferences.java
index 15a6213d..12654bc8 100644
--- a/src/com/android/calendar/GeneralPreferences.java
+++ b/src/com/android/calendar/GeneralPreferences.java
@@ -63,6 +63,7 @@ public class GeneralPreferences extends PreferenceFragment implements
private static final String FRAG_TAG_TIME_ZONE_PICKER = "TimeZonePicker";
// Preference keys
+ public static final String KEY_DEFAULT_START = "preferences_default_start";
public static final String KEY_HIDE_DECLINED = "preferences_hide_declined";
public static final String KEY_WEEK_START_DAY = "preferences_week_start_day";
public static final String KEY_SHOW_WEEK_NUM = "preferences_show_week_num";
@@ -115,6 +116,7 @@ public class GeneralPreferences extends PreferenceFragment implements
static final String KEY_HOME_TZ = "preferences_home_tz";
// Default preference values
+ public static final String DEFAULT_DEFAULT_START = "-2";
public static final int DEFAULT_START_VIEW = CalendarController.ViewType.WEEK;
public static final int DEFAULT_DETAILED_VIEW = CalendarController.ViewType.DAY;
public static final boolean DEFAULT_SHOW_WEEK_NUM = false;
@@ -131,6 +133,8 @@ public class GeneralPreferences extends PreferenceFragment implements
TimeZonePickerUtils mTzPickerUtils;
ListPreference mWeekStart;
ListPreference mDefaultReminder;
+ ListPreference mSnoozeDelay;
+ ListPreference mDefaultStart;
private String mTimeZoneId;
@@ -196,6 +200,8 @@ public class GeneralPreferences extends PreferenceFragment implements
mWeekStart.setSummary(mWeekStart.getEntry());
mDefaultReminder.setSummary(mDefaultReminder.getEntry());
+ mSnoozeDelay.setSummary(mSnoozeDelay.getEntry());
+ mDefaultStart.setSummary(mDefaultStart.getEntry());
// This triggers an asynchronous call to the provider to refresh the data in shared pref
mTimeZoneId = Utils.getTimeZone(activity, null);
@@ -350,6 +356,10 @@ public class GeneralPreferences extends PreferenceFragment implements
} else if (preference == mVibrate) {
mVibrate.setChecked((Boolean) newValue);
return true;
+ } else if (preference == mDefaultStart) {
+ int i = mDefaultStart.findIndexOfValue((String) newValue);
+ mDefaultStart.setSummary(mDefaultStart.getEntries()[i]);
+ return true;
} else {
return true;
}
diff --git a/src/com/android/calendar/Utils.java b/src/com/android/calendar/Utils.java
index 837141a1..a0393857 100644
--- a/src/com/android/calendar/Utils.java
+++ b/src/com/android/calendar/Utils.java
@@ -234,9 +234,17 @@ public class Utils {
}
}
- // Default to the last view
- return prefs.getInt(
- GeneralPreferences.KEY_START_VIEW, GeneralPreferences.DEFAULT_START_VIEW);
+ // Check if the user wants the last view or the default startup view
+ int defaultStart = Integer.valueOf(prefs.getString(GeneralPreferences.KEY_DEFAULT_START,
+ GeneralPreferences.DEFAULT_DEFAULT_START));
+ if (defaultStart == -2) {
+ // Return the last view used
+ return prefs.getInt(
+ GeneralPreferences.KEY_START_VIEW, GeneralPreferences.DEFAULT_START_VIEW);
+ } else {
+ // Return the default view
+ return defaultStart;
+ }
}
/**