summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/calendar/AllInOneActivity.java19
-rw-r--r--src/com/android/calendar/CalendarColorPickerDialog.java4
-rw-r--r--src/com/android/calendar/CalendarController.java3
-rw-r--r--src/com/android/calendar/CalendarViewAdapter.java16
-rw-r--r--src/com/android/calendar/TimelyFragment.java151
-rw-r--r--src/com/android/calendar/alerts/AlertActivity.java10
-rw-r--r--src/com/android/calendar/event/EditEventHelper.java2
-rw-r--r--src/com/android/calendar/recurrencepicker/RecurrencePickerDialog.java35
8 files changed, 44 insertions, 196 deletions
diff --git a/src/com/android/calendar/AllInOneActivity.java b/src/com/android/calendar/AllInOneActivity.java
index 1c8fa9c9..d7d553f4 100644
--- a/src/com/android/calendar/AllInOneActivity.java
+++ b/src/com/android/calendar/AllInOneActivity.java
@@ -101,7 +101,6 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
private static final int BUTTON_WEEK_INDEX = 1;
private static final int BUTTON_MONTH_INDEX = 2;
private static final int BUTTON_AGENDA_INDEX = 3;
- private static final int BUTTON_TIMELY_INDEX = 4;
private CalendarController mController;
private static boolean mIsMultipane;
@@ -488,9 +487,6 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
case ViewType.MONTH:
mActionBar.setSelectedNavigationItem(BUTTON_MONTH_INDEX);
break;
- case ViewType.TIMELY:
- mActionBar.setSelectedNavigationItem(BUTTON_TIMELY_INDEX);
- break;
default:
mActionBar.setSelectedNavigationItem(BUTTON_DAY_INDEX);
break;
@@ -900,16 +896,6 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
}
frag = new DayFragment(timeMillis, 1);
break;
- case ViewType.TIMELY:
- // TODO: support tabs for tablets
-// if (mActionBar = null && (mActionBar.getSelectedTab() != mDayTab)) {
-// mActionBar.selectTab(mDayTab);
- // }
- if (mActionBarMenuSpinnerAdapter != null) {
- mActionBar.setSelectedNavigationItem(CalendarViewAdapter.TIMELY_BUTTON_INDEX);
- }
- frag = new TimelyFragment();
- break;
case ViewType.MONTH:
if (mActionBar != null && (mActionBar.getSelectedTab() != mMonthTab)) {
mActionBar.selectTab(mMonthTab);
@@ -1303,11 +1289,6 @@ public class AllInOneActivity extends AbstractCalendarActivity implements EventH
mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.AGENDA);
}
break;
- case CalendarViewAdapter.TIMELY_BUTTON_INDEX:
- if (mCurrentView != ViewType.TIMELY) {
- mController.sendEvent(this, EventType.GO_TO, null, null, -1, ViewType.TIMELY);
- }
- break;
default:
Log.w(TAG, "ItemSelected event from unknown button: " + itemPosition);
Log.w(TAG, "CurrentView:" + mCurrentView + " Button:" + itemPosition +
diff --git a/src/com/android/calendar/CalendarColorPickerDialog.java b/src/com/android/calendar/CalendarColorPickerDialog.java
index 9427610d..e72d1962 100644
--- a/src/com/android/calendar/CalendarColorPickerDialog.java
+++ b/src/com/android/calendar/CalendarColorPickerDialog.java
@@ -173,6 +173,10 @@ public class CalendarColorPickerDialog extends ColorPickerDialog {
}
private void saveColorKeys(Bundle outState) {
+ // No color keys to save, so just return
+ if (mColors == null) {
+ return;
+ }
int[] colorKeys = new int[mColors.length];
for (int i = 0; i < mColors.length; i++) {
colorKeys[i] = mColorKeyMap.get(mColors[i]);
diff --git a/src/com/android/calendar/CalendarController.java b/src/com/android/calendar/CalendarController.java
index bf5b6d36..15733715 100644
--- a/src/com/android/calendar/CalendarController.java
+++ b/src/com/android/calendar/CalendarController.java
@@ -139,8 +139,7 @@ public class CalendarController {
final int WEEK = 3;
final int MONTH = 4;
final int EDIT = 5;
- final int TIMELY = 6;
- final int MAX_VALUE = 6;
+ final int MAX_VALUE = 5;
}
public static class EventInfo {
diff --git a/src/com/android/calendar/CalendarViewAdapter.java b/src/com/android/calendar/CalendarViewAdapter.java
index c82bc9b4..f07d4d8a 100644
--- a/src/com/android/calendar/CalendarViewAdapter.java
+++ b/src/com/android/calendar/CalendarViewAdapter.java
@@ -50,7 +50,6 @@ public class CalendarViewAdapter extends BaseAdapter {
// Week view: show the month + year
// Month view: show the month + year
// Agenda view: show day of the week + full date underneath
- // Timely View: Temporary - show the new timely view
private int mCurrentMainView;
private final LayoutInflater mInflater;
@@ -63,7 +62,6 @@ public class CalendarViewAdapter extends BaseAdapter {
public static final int WEEK_BUTTON_INDEX = 1;
public static final int MONTH_BUTTON_INDEX = 2;
public static final int AGENDA_BUTTON_INDEX = 3;
- public static final int TIMELY_BUTTON_INDEX = 4;
// The current selected event's time, used to calculate the date and day of the week
// for the buttons.
@@ -205,11 +203,6 @@ public class CalendarViewAdapter extends BaseAdapter {
weekDay.setText(buildDayOfWeek());
date.setText(buildFullDate());
break;
- case ViewType.TIMELY:
- weekDay.setVisibility(View.VISIBLE);
- weekDay.setText(buildDayOfWeek());
- date.setText(buildFullDate());
- break;
default:
v = null;
break;
@@ -239,9 +232,6 @@ public class CalendarViewAdapter extends BaseAdapter {
case ViewType.AGENDA:
title.setText(mButtonNames [AGENDA_BUTTON_INDEX]);
break;
- case ViewType.TIMELY:
- title.setText(mButtonNames [TIMELY_BUTTON_INDEX]);
- break;
default:
v = null;
break;
@@ -296,12 +286,6 @@ public class CalendarViewAdapter extends BaseAdapter {
date.setText(buildMonthDayDate());
}
break;
- case TIMELY_BUTTON_INDEX:
- viewType.setText(mButtonNames [TIMELY_BUTTON_INDEX]);
- if (mShowDate) {
- date.setText(buildMonthDayDate());
- }
- break;
default:
v = convertView;
break;
diff --git a/src/com/android/calendar/TimelyFragment.java b/src/com/android/calendar/TimelyFragment.java
deleted file mode 100644
index e3df4944..00000000
--- a/src/com/android/calendar/TimelyFragment.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source 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.
- */
-
-package com.android.calendar;
-
-import android.app.Fragment;
-import android.content.Context;
-import android.graphics.Color;
-import android.graphics.Typeface;
-import android.os.Bundle;
-import android.text.format.Time;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import com.android.calendar.CalendarController.EventInfo;
-import com.android.calendar.CalendarController.EventType;
-
-/**
- * This is the base class for Day and Week Activities.
- */
-public class TimelyFragment extends Fragment implements CalendarController.EventHandler {
-
- ListView mList;
- TimelyAdapter mAdapter;
-
- public TimelyFragment() {
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View v = inflater.inflate(R.layout.timely_fragment, null);
- ListView mList = (ListView)v.findViewById(R.id.timely_list);
- if (mList != null) {
- mAdapter = new TimelyAdapter(getActivity());
- mList.setAdapter(mAdapter);
- }
- return v;
- }
-
-
- private void goTo(Time goToTime, boolean ignoreTime, boolean animateToday) {
- }
-
- @Override
- public void eventsChanged() {
- }
-
- @Override
- public void handleEvent(EventInfo msg) {
- if (msg.eventType == EventType.GO_TO) {
- goTo(msg.selectedTime, (msg.extraLong & CalendarController.EXTRA_GOTO_DATE) != 0,
- (msg.extraLong & CalendarController.EXTRA_GOTO_TODAY) != 0);
- } else if (msg.eventType == EventType.EVENTS_CHANGED) {
- eventsChanged();
- }
- }
-
- @Override
- public long getSupportedEventTypes() {
- return 0;
- }
-
- private class TimelyAdapter extends BaseAdapter {
- private static final int EVENT_NUM = 10000;
- int [] mTypes = new int [EVENT_NUM];
- Context mContext;
-
- public TimelyAdapter(Context c) {
- mContext = c;
- for (int i = 0; i < EVENT_NUM; i++) {
- if (i % 30 == 0) {
- mTypes[i] = 0; // month
- } else {
- if (Math.random() < 0.75) {
- mTypes[i] = 1; // full day
- } else {
- mTypes[i] = 2; //empty day
- }
- }
- }
- }
-
- @Override
- public int getCount() {
- return EVENT_NUM;
- }
-
- @Override
- public Object getItem(int arg0) {
- return null;
- }
-
- @Override
- public long getItemId(int arg0) {
- return arg0;
- }
-
- @Override
- public View getView(int position, View v, ViewGroup arg2) {
- TextView view;
- if (v == null) {
- view = new TextView(mContext);
- } else {
- view = (TextView) v;
- }
- if (mTypes[position] == 0) {
- view.setTextColor(Color.RED);
- view.setHeight(100);
- view.setText(" Month Header");
- view.setTypeface(Typeface.DEFAULT_BOLD);
- view.setTextSize(30);
- } else if (mTypes[position] == 1) {
- view.setTextColor(Color.BLACK);
- view.setHeight(250);
- view.setText(" Day with events");
- view.setTypeface(Typeface.DEFAULT);
- view.setTextSize(30);
- } else {
- view.setTextColor(Color.GRAY);
- view.setHeight(100);
- view.setText(" Empty Day");
- view.setTypeface(Typeface.DEFAULT);
- view.setTextSize(30);
- }
- return view;
- }
- }
-}
diff --git a/src/com/android/calendar/alerts/AlertActivity.java b/src/com/android/calendar/alerts/AlertActivity.java
index 6e9af6de..78733bd4 100644
--- a/src/com/android/calendar/alerts/AlertActivity.java
+++ b/src/com/android/calendar/alerts/AlertActivity.java
@@ -253,7 +253,15 @@ public class AlertActivity extends Activity implements OnClickListener {
@Override
protected void onStop() {
super.onStop();
- AlertService.updateAlertNotification(this);
+ // Can't run updateAlertNotification in main thread
+ AsyncTask task = new AsyncTask<Context, Void, Void>() {
+ @Override
+ protected Void doInBackground(Context ... params) {
+ AlertService.updateAlertNotification(params[0]);
+ return null;
+ }
+ }.execute(this);
+
if (mCursor != null) {
mCursor.deactivate();
diff --git a/src/com/android/calendar/event/EditEventHelper.java b/src/com/android/calendar/event/EditEventHelper.java
index b1105914..d72ab5d3 100644
--- a/src/com/android/calendar/event/EditEventHelper.java
+++ b/src/com/android/calendar/event/EditEventHelper.java
@@ -914,7 +914,7 @@ public class EditEventHelper {
String duration = model.mDuration;
boolean isAllDay = model.mAllDay;
- if (end > start) {
+ if (end >= start) {
if (isAllDay) {
// if it's all day compute the duration in days
long days = (end - start + DateUtils.DAY_IN_MILLIS - 1)
diff --git a/src/com/android/calendar/recurrencepicker/RecurrencePickerDialog.java b/src/com/android/calendar/recurrencepicker/RecurrencePickerDialog.java
index acf48431..73591dd9 100644
--- a/src/com/android/calendar/recurrencepicker/RecurrencePickerDialog.java
+++ b/src/com/android/calendar/recurrencepicker/RecurrencePickerDialog.java
@@ -80,6 +80,10 @@ public class RecurrencePickerDialog extends DialogFragment implements OnItemSele
private static final int COUNT_MAX = 730;
private static final int COUNT_DEFAULT = 5;
+ // Special cases in monthlyByNthDayOfWeek
+ private static final int FIFTH_WEEK_IN_A_MONTH = 5;
+ private static final int LAST_NTH_DAY_OF_WEEK = -1;
+
private DatePickerDialog mDatePickerDialog;
private class RecurrenceModel implements Parcelable {
@@ -166,7 +170,10 @@ public class RecurrencePickerDialog extends DialogFragment implements OnItemSele
/**
* Nth day of the week to repeat. Used when monthlyRepeat ==
- * MONTHLY_BY_NTH_DAY_OF_WEEK 0=undefined, 1=1st, 2=2nd, etc
+ * MONTHLY_BY_NTH_DAY_OF_WEEK 0=undefined, -1=Last, 1=1st, 2=2nd, ..., 5=5th
+ *
+ * We support 5th, just to handle backwards capabilities with old bug, but it
+ * gets converted to -1 once edited.
*/
int monthlyByNthDayOfWeek;
@@ -344,6 +351,12 @@ public class RecurrencePickerDialog extends DialogFragment implements OnItemSele
public RecurrencePickerDialog() {
}
+ static public boolean isSupportedMonthlyByNthDayOfWeek(int num) {
+ // We only support monthlyByNthDayOfWeek when it is greater then 0 but less then 5.
+ // Or if -1 when it is the last monthly day of the week.
+ return (num > 0 && num <= FIFTH_WEEK_IN_A_MONTH) || num == LAST_NTH_DAY_OF_WEEK;
+ }
+
static public boolean canHandleRecurrenceRule(EventRecurrence er) {
switch (er.freq) {
case EventRecurrence.DAILY:
@@ -369,7 +382,7 @@ public class RecurrencePickerDialog extends DialogFragment implements OnItemSele
*/
int numOfByDayNum = 0;
for (int i = 0; i < er.bydayCount; i++) {
- if (er.bydayNum[i] > 0) {
+ if (isSupportedMonthlyByNthDayOfWeek(er.bydayNum[i])) {
++numOfByDayNum;
}
}
@@ -462,8 +475,9 @@ public class RecurrencePickerDialog extends DialogFragment implements OnItemSele
int dayOfWeek = EventRecurrence.day2TimeDay(er.byday[i]);
model.weeklyByDayOfWeek[dayOfWeek] = true;
- if (model.freq == RecurrenceModel.FREQ_MONTHLY && er.bydayNum[i] > 0) {
- // LIMITATION: Can handle only (one) weekDayNum and only
+ if (model.freq == RecurrenceModel.FREQ_MONTHLY &&
+ isSupportedMonthlyByNthDayOfWeek(er.bydayNum[i])) {
+ // LIMITATION: Can handle only (one) weekDayNum in nth or last and only
// when
// monthly
model.monthlyByDayOfWeek = dayOfWeek;
@@ -557,7 +571,7 @@ public class RecurrencePickerDialog extends DialogFragment implements OnItemSele
er.bymonthdayCount = 1;
}
} else if (model.monthlyRepeat == RecurrenceModel.MONTHLY_BY_NTH_DAY_OF_WEEK) {
- if (model.monthlyByNthDayOfWeek <= 0) {
+ if (!isSupportedMonthlyByNthDayOfWeek(model.monthlyByNthDayOfWeek)) {
throw new IllegalStateException("month repeat by nth week but n is "
+ model.monthlyByNthDayOfWeek);
}
@@ -934,13 +948,22 @@ public class RecurrencePickerDialog extends DialogFragment implements OnItemSele
if (mMonthRepeatByDayOfWeekStr == null) {
if (mModel.monthlyByNthDayOfWeek == 0) {
mModel.monthlyByNthDayOfWeek = (mTime.monthDay + 6) / 7;
+ // Since not all months have 5 weeks, we convert 5th NthDayOfWeek to
+ // -1 for last monthly day of the week
+ if (mModel.monthlyByNthDayOfWeek >= FIFTH_WEEK_IN_A_MONTH) {
+ mModel.monthlyByNthDayOfWeek = LAST_NTH_DAY_OF_WEEK;
+ }
mModel.monthlyByDayOfWeek = mTime.weekDay;
}
String[] monthlyByNthDayOfWeekStrs =
mMonthRepeatByDayOfWeekStrs[mModel.monthlyByDayOfWeek];
+
+ // TODO(psliwowski): Find a better way handle -1 indexes
+ int msgIndex = mModel.monthlyByNthDayOfWeek < 0 ? FIFTH_WEEK_IN_A_MONTH :
+ mModel.monthlyByNthDayOfWeek;
mMonthRepeatByDayOfWeekStr =
- monthlyByNthDayOfWeekStrs[mModel.monthlyByNthDayOfWeek - 1];
+ monthlyByNthDayOfWeekStrs[msgIndex - 1];
mRepeatMonthlyByNthDayOfWeek.setText(mMonthRepeatByDayOfWeekStr);
}
break;