summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaiyiz <kaiyiz@codeaurora.org>2014-03-18 13:42:18 +0800
committerAdnan <adnan@cyngn.com>2014-08-26 14:46:52 -0700
commite6e25e45c65ffb9f6a76cfe18606764dd4b6e2c4 (patch)
tree277b5b83deb9a65c789a0bce4a368f1486eadf1d
parent964a990ed4c2d0d51d9f866aaff7b0e6467bc6f1 (diff)
downloadandroid_packages_apps_Calendar-e6e25e45c65ffb9f6a76cfe18606764dd4b6e2c4.tar.gz
android_packages_apps_Calendar-e6e25e45c65ffb9f6a76cfe18606764dd4b6e2c4.tar.bz2
android_packages_apps_Calendar-e6e25e45c65ffb9f6a76cfe18606764dd4b6e2c4.zip
Calendar: Add the "Go to" menu for user to go to any date as select
When user press the menu button, it will show the "Go to" item, and the user could select any date to view. CRs-Fixed: 587493 Change-Id: Ia90f9c5697cf36a753534a0256947fa5e3a58576
-rw-r--r--res/menu-land/all_in_one_title_bar.xml4
-rw-r--r--res/menu-sw600dp-land/all_in_one_title_bar.xml4
-rw-r--r--res/menu-sw600dp/all_in_one_title_bar.xml4
-rw-r--r--res/menu/all_in_one_title_bar.xml9
-rw-r--r--res/values-zh-rCN/cm_strings.xml1
-rw-r--r--res/values-zh-rTW/cm_strings.xml1
-rw-r--r--res/values/cm_strings.xml4
-rw-r--r--res/values/config.xml2
-rw-r--r--src/com/android/calendar/AllInOneActivity.java64
9 files changed, 91 insertions, 2 deletions
diff --git a/res/menu-land/all_in_one_title_bar.xml b/res/menu-land/all_in_one_title_bar.xml
index 03e12b2b..3e9d19e8 100644
--- a/res/menu-land/all_in_one_title_bar.xml
+++ b/res/menu-land/all_in_one_title_bar.xml
@@ -48,6 +48,10 @@
android:title="@string/events_delete"
android:showAsAction="never" />
<item
+ android:id="@+id/action_goto"
+ android:title="@string/go_to"
+ android:showAsAction="never"/>
+ <item
android:id="@+id/action_select_visible_calendars"
android:title="@string/menu_select_visible_calendars"
android:icon="@drawable/ic_menu_select_visible_calendars_holo_light"
diff --git a/res/menu-sw600dp-land/all_in_one_title_bar.xml b/res/menu-sw600dp-land/all_in_one_title_bar.xml
index 8e877e56..97877eb2 100644
--- a/res/menu-sw600dp-land/all_in_one_title_bar.xml
+++ b/res/menu-sw600dp-land/all_in_one_title_bar.xml
@@ -42,6 +42,10 @@
android:actionViewClass="android.widget.SearchView"
android:imeOptions="actionSearch" />
<item
+ android:id="@+id/action_goto"
+ android:title="@string/go_to"
+ android:showAsAction="never"/>
+ <item
android:id="@+id/action_hide_controls"
android:alphabeticShortcut="h"
android:title="@string/hide_controls" />
diff --git a/res/menu-sw600dp/all_in_one_title_bar.xml b/res/menu-sw600dp/all_in_one_title_bar.xml
index 6d88e7ae..1a922a93 100644
--- a/res/menu-sw600dp/all_in_one_title_bar.xml
+++ b/res/menu-sw600dp/all_in_one_title_bar.xml
@@ -42,6 +42,10 @@
android:actionViewClass="android.widget.SearchView"
android:imeOptions="actionSearch" />
<item
+ android:id="@+id/action_goto"
+ android:title="@string/go_to"
+ android:showAsAction="never"/>
+ <item
android:id="@+id/action_hide_controls"
android:alphabeticShortcut="h"
android:title="@string/hide_controls" />
diff --git a/res/menu/all_in_one_title_bar.xml b/res/menu/all_in_one_title_bar.xml
index 3e658705..6349fe74 100644
--- a/res/menu/all_in_one_title_bar.xml
+++ b/res/menu/all_in_one_title_bar.xml
@@ -53,16 +53,21 @@
android:showAsAction="never"
android:orderInCategory="5" />
<item
+ android:id="@+id/action_goto"
+ android:title="@string/go_to"
+ android:showAsAction="never"
+ android:orderInCategory="6" />
+ <item
android:id="@+id/action_select_visible_calendars"
android:title="@string/menu_select_visible_calendars"
android:icon="@drawable/ic_menu_select_visible_calendars_holo_light"
android:showAsAction="never"
- android:orderInCategory="6" />
+ android:orderInCategory="7" />
<item
android:id="@+id/action_settings"
android:alphabeticShortcut="s"
android:title="@string/menu_preferences"
android:icon="@drawable/ic_menu_settings_holo_light"
android:showAsAction="never"
- android:orderInCategory="7" />
+ android:orderInCategory="8" />
</menu>
diff --git a/res/values-zh-rCN/cm_strings.xml b/res/values-zh-rCN/cm_strings.xml
index d50d443e..7bfacd49 100644
--- a/res/values-zh-rCN/cm_strings.xml
+++ b/res/values-zh-rCN/cm_strings.xml
@@ -34,4 +34,5 @@
<string name="evt_del_dlg_msg_selected">删除选择的活动</string>
<string name="evt_del_dlg_msg_all">删除所有活动</string>
<string name="no_events_selected">没有选择活动</string>
+ <string name="go_to">"转到"</string>
</resources>
diff --git a/res/values-zh-rTW/cm_strings.xml b/res/values-zh-rTW/cm_strings.xml
index 93026be5..36ef39db 100644
--- a/res/values-zh-rTW/cm_strings.xml
+++ b/res/values-zh-rTW/cm_strings.xml
@@ -20,4 +20,5 @@
<string name="preferences_alerts_custom_snooze_delay_summary_on">每當重響提醒時要求重響延遲</string>
<string name="preferences_alerts_custom_snooze_delay_summary_off">總是使用預設重響延遲</string>
<string name="snooze_delay_dialog_title">設定重響延遲</string>
+ <string name="go_to">"轉到"</string>
</resources>
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 437f13cd..9f7be438 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -44,4 +44,8 @@
<string name="evt_del_dlg_msg_selected">Selected events will be deleted</string>
<string name="evt_del_dlg_msg_all">All events will be deleted</string>
<string name="no_events_selected">No events selected</string>
+
+ <!-- This is a label on a menu item. Pressing this menu item allows the
+ user to go to the calendars to display [CHAR LIMIT=20] -->
+ <string name="go_to">"Go to"</string>
</resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index e03e64ce..73525931 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -34,4 +34,6 @@
<bool name="tablet_config">false</bool>
<!-- A global var used to set the main layout theme (one pane vs multiple panes) -->
<bool name="multiple_pane_config">false</bool>
+ <!-- A golbal var used to show goto menu -->
+ <bool name="show_goto_menu">false</bool>
</resources>
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java
index ce19b2c7..a8d5a43a 100644
--- a/src/com/android/calendar/AllInOneActivity.java
+++ b/src/com/android/calendar/AllInOneActivity.java
@@ -26,6 +26,9 @@ import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
@@ -35,6 +38,7 @@ import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
@@ -61,6 +65,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
+import android.widget.DatePicker;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
@@ -79,6 +84,7 @@ import com.android.lunar.ILunarService;
import com.android.lunar.LunarUtils;
import java.io.IOException;
+import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
@@ -154,6 +160,7 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
private SearchView mSearchView;
private MenuItem mSearchMenu;
private MenuItem mControlsMenu;
+ private MenuItem mGoToMenu;
private Menu mOptionsMenu;
private CalendarViewAdapter mActionBarMenuSpinnerAdapter;
private QueryHandler mHandler;
@@ -774,6 +781,11 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
mControlsMenu.setTitle(mHideControls ? mShowString : mHideString);
}
+ mGoToMenu = menu.findItem(R.id.action_goto);
+ if (!getResources().getBoolean(R.bool.show_goto_menu)) {
+ mGoToMenu.setVisible(false);
+ }
+
MenuItem menuItem = menu.findItem(R.id.action_today);
if (Utils.isJellybeanOrLater()) {
// replace the default top layer drawable of the today icon with a
@@ -841,6 +853,12 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
} else if (itemId == R.id.action_delete_events) {
startActivity(new Intent(this, DeleteEventsActivity.class));
return true;
+ } else if (itemId == R.id.action_goto) {
+ // Get the current time to display in Dialog.
+ String timeZone = mTimeZone;
+ GoToDialogFragment goToFrg = GoToDialogFragment.newInstance(timeZone);
+ goToFrg.show(getFragmentManager(), "goto");
+ return true;
} else {
return mExtensions.handleItemSelected(item, this);
}
@@ -1361,4 +1379,50 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
}
return false;
}
+
+ public static class GoToDialogFragment extends DialogFragment {
+ private static final String KEY_TIMEZONE = "timezone";
+
+ public static GoToDialogFragment newInstance(String timeZone) {
+ GoToDialogFragment goToFrg = new GoToDialogFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(KEY_TIMEZONE, timeZone);
+ goToFrg.setArguments(bundle);
+ return goToFrg;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ final String timeZone = getArguments().getString(KEY_TIMEZONE);
+ final CalendarController controller = CalendarController.getInstance(getActivity());
+ Time t = null;
+ t = new Time(timeZone);
+ Calendar calendar = Calendar.getInstance();
+ t.year = calendar.get(Calendar.YEAR);
+ t.month = calendar.get(Calendar.MONTH);
+ t.monthDay = calendar.get(Calendar.DATE);
+ DatePickerDialog dialog = new DatePickerDialog(getActivity(), null,
+ t.year, t.month, t.monthDay) {
+ };
+ final DatePicker datePicker = dialog.getDatePicker();
+ dialog.setButton(DialogInterface.BUTTON_POSITIVE,
+ getResources().getString(R.string.save_label),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Time t = null;
+ t = new Time(timeZone);
+ int year = datePicker.getYear();
+ int monthOfYear = datePicker.getMonth();
+ int dayOfMonth = datePicker.getDayOfMonth();
+ t.set(dayOfMonth, monthOfYear, year);
+ t.set(t.toMillis(false));
+ controller.sendEvent(this, EventType.GO_TO, null, null, t, -1,
+ ViewType.CURRENT, CalendarController.EXTRA_GOTO_TIME,
+ null, null);
+ }
+ });
+ return dialog;
+ }
+ }
}