summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaiyiz <kaiyiz@codeaurora.org>2014-03-18 13:42:18 +0800
committerMatt Garnes <matt@cyngn.com>2014-11-11 17:46:50 -0800
commit67be113ebee4fc9f3b19a1f857bdda9c1358c1ec (patch)
tree541532ae84d36dc30f89f7935a786eab8878eee4
parent033d8e339cd7c61111d3d15890677370abd5c94e (diff)
downloadandroid_packages_apps_Calendar-67be113ebee4fc9f3b19a1f857bdda9c1358c1ec.tar.gz
android_packages_apps_Calendar-67be113ebee4fc9f3b19a1f857bdda9c1358c1ec.tar.bz2
android_packages_apps_Calendar-67be113ebee4fc9f3b19a1f857bdda9c1358c1ec.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/cm_strings.xml4
-rw-r--r--res/values/config.xml2
-rw-r--r--src/com/android/calendar/AllInOneActivity.java64
7 files changed, 89 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/cm_strings.xml b/res/values/cm_strings.xml
index 7ba89664..0997df1f 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -43,4 +43,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 af432828..7567fa4c 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;
+ }
+ }
}