diff options
author | Aravind Asam <aasam@codeaurora.org> | 2014-03-05 19:09:25 -0800 |
---|---|---|
committer | Matt Garnes <matt@cyngn.com> | 2014-11-11 17:46:50 -0800 |
commit | 43f257945f1924256590858725d938519adfb37b (patch) | |
tree | dcf58996cb425a554f0866a0fb428386a69e2e13 /src/com/android/calendar/AllInOneActivity.java | |
parent | 67be113ebee4fc9f3b19a1f857bdda9c1358c1ec (diff) | |
download | android_packages_apps_Calendar-43f257945f1924256590858725d938519adfb37b.tar.gz android_packages_apps_Calendar-43f257945f1924256590858725d938519adfb37b.tar.bz2 android_packages_apps_Calendar-43f257945f1924256590858725d938519adfb37b.zip |
Calendar: Support for deleting events (rest of the features)
* Includes highlight for selected items.
* Spinner-style select all, deselect all.
* Improvements asset files updated.
* Add the TW strings for it.
* Show the delete events menu as the config.
Change-Id: I1781bd8748487bc51da8988f7ae74927c0e179c1
Diffstat (limited to 'src/com/android/calendar/AllInOneActivity.java')
-rw-r--r-- | src/com/android/calendar/AllInOneActivity.java | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java index 7567fa4c..66394591 100644 --- a/src/com/android/calendar/AllInOneActivity.java +++ b/src/com/android/calendar/AllInOneActivity.java @@ -32,13 +32,16 @@ import android.app.DialogFragment; import android.app.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; +import android.app.LoaderManager; import android.content.AsyncQueryHandler; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Context; +import android.content.CursorLoader; import android.content.DialogInterface; +import android.content.Loader; import android.content.Intent; import android.content.ServiceConnection; import android.content.SharedPreferences; @@ -96,6 +99,7 @@ import static android.provider.CalendarContract.EXTRA_EVENT_END_TIME; public class AllInOneActivity extends AbstractCalendarActivity implements EventHandler, OnSharedPreferenceChangeListener, SearchView.OnQueryTextListener, ActionBar.TabListener, + LoaderManager.LoaderCallbacks<Cursor>, ActionBar.OnNavigationListener, OnSuggestionListener { private static final String TAG = "AllInOneActivity"; private static final boolean DEBUG = false; @@ -160,7 +164,6 @@ 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; @@ -781,9 +784,16 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH mControlsMenu.setTitle(mHideControls ? mShowString : mHideString); } - mGoToMenu = menu.findItem(R.id.action_goto); + MenuItem deleteEventsMenu = menu.findItem(R.id.action_delete_events); + if (!getResources().getBoolean(R.bool.show_delete_events_menu)) { + deleteEventsMenu.setVisible(false); + } else { + getLoaderManager().initLoader(0, null, this); + } + + MenuItem goToMenu = menu.findItem(R.id.action_goto); if (!getResources().getBoolean(R.bool.show_goto_menu)) { - mGoToMenu.setVisible(false); + goToMenu.setVisible(false); } MenuItem menuItem = menu.findItem(R.id.action_today); @@ -795,6 +805,7 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH } else { menuItem.setIcon(R.drawable.ic_menu_today_no_date_holo_light); } + return true; } @@ -1380,6 +1391,42 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH return false; } + @Override + public Loader<Cursor> onCreateLoader(int id, Bundle args) { + final String[] PROJECTION = new String[] { + CalendarContract.Events._ID, + CalendarContract.Events.TITLE, + CalendarContract.EventsEntity.DELETED + }; + final String where = CalendarContract.EventsEntity.DELETED + "=0 AND " + + Calendars.CALENDAR_ACCESS_LEVEL + ">=" + Calendars.CAL_ACCESS_CONTRIBUTOR; + return new CursorLoader(this, CalendarContract.EventsEntity.CONTENT_URI, + PROJECTION, where, null, null); + } + + @Override + public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) { + if (mOptionsMenu == null) { + Log.w(TAG, "mOptionsMenu is null"); + return; + } + + MenuItem delEventsMenu = mOptionsMenu.findItem(R.id.action_delete_events); + if (delEventsMenu != null) { + if (cursor.getCount() == 0) { + delEventsMenu.setEnabled(false); + } else { + delEventsMenu.setEnabled(true); + } + } + } + + @Override + public void onLoaderReset(Loader<Cursor> arg0) { + // Do nothing. + return; + } + public static class GoToDialogFragment extends DialogFragment { private static final String KEY_TIMEZONE = "timezone"; |