auto import from //branches/cupcake_rel/...@138607
The Android Open Source Project [Fri, 13 Mar 2009 20:04:24 +0000 (13:04 -0700)]
AndroidManifest.xml
res/layout/agenda_day.xml
res/layout/agenda_item.xml
res/layout/alert_item.xml
res/layout/calendars_item.xml
src/com/android/calendar/AgendaByDayAdapter.java
src/com/android/calendar/AlertReceiver.java
src/com/android/calendar/DeleteEventHelper.java
src/com/android/calendar/DismissAllAlarmsService.java [new file with mode: 0644]
src/com/android/calendar/EditEvent.java

index 7a3a6d3..aa4418b 100644 (file)
@@ -93,6 +93,8 @@
 
         <service android:name="AlertService" />
 
+        <service android:name="DismissAllAlarmsService" />
+
         <activity android:name="CalendarTests" android:label="Calendar Tests">
             <intent-filter>
                  <action android:name="android.intent.action.MAIN" />
index 5332a44..c2a570a 100644 (file)
      limitations under the License.
 -->
 
-    
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="horizontal"
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/date"
     android:layout_height="wrap_content"
     android:layout_width="fill_parent"
     android:background="@color/agenda_day_bar_color"
     android:padding="4dip"
-    >
-    <TextView android:id="@+id/date"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:textStyle="bold"
-        android:textColor="?android:attr/textColorPrimary"
-        />
-    <TextView android:id="@+id/day_of_week"
-        android:layout_height="wrap_content"
-        android:layout_width="wrap_content"
-        android:layout_marginLeft="5dip"
-        android:textColor="?android:attr/textColorPrimary"
-        />
-</LinearLayout>
-    
+    android:textStyle="bold"
+    android:textColor="?android:attr/textColorSecondary"
+/>
index 052b037..5cae988 100644 (file)
@@ -29,7 +29,7 @@
         >
 
         <View android:id="@+id/vertical_stripe"
-            android:layout_width="10dip"
+            android:layout_width="5dip"
             android:layout_height="fill_parent"
             android:layout_marginRight="5dip" />
 
             <TextView android:id="@+id/title"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
+                android:ellipsize="end"
+                android:maxLines="2"
                 android:textStyle="bold"
-                android:textColor="@android:color/black"
+                android:textColor="?android:attr/textColorSecondary"
                 style="?android:attr/textAppearanceMediumInverse"
             />
 
             <TextView android:id="@+id/when"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:ellipsize="end"
+                android:maxLines="2"
                 android:textStyle="bold"
-                android:textColor="@android:color/black"
+                android:textColor="?android:attr/textColorSecondary"
                 style="?android:attr/textAppearanceSmallInverse"
             />
 
             <TextView android:id="@+id/where"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
-                android:textStyle="bold"
-                android:textColor="@android:color/black"
+                android:ellipsize="end"
+                android:maxLines="2"
+                android:textColor="?android:attr/textColorSecondary"
                 style="?android:attr/textAppearanceSmallInverse"
             />
         </LinearLayout>
index 057289c..d46e9f6 100644 (file)
@@ -22,7 +22,7 @@
     android:minHeight="?android:attr/listPreferredItemHeight">
     
     <View android:id="@+id/vertical_stripe"
-        android:layout_width="10dip"
+        android:layout_width="5dip"
         android:layout_height="fill_parent"
         android:layout_marginRight="5dip" />
         
@@ -35,6 +35,8 @@
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
+            android:ellipsize="end"
+            android:maxLines="2"
             android:textStyle="bold"
             android:textColor="@android:color/black"
             style="?android:attr/textAppearanceMediumInverse" />
@@ -59,6 +61,8 @@
                     <TextView android:id="@+id/when"
                         android:layout_width="wrap_content"
                         android:layout_height="fill_parent"
+                        android:ellipsize="end"
+                        android:maxLines="2"
                         android:textStyle="bold"
                         style="?android:attr/textAppearanceSmall" />
 
@@ -82,7 +86,9 @@
             <TextView android:id="@+id/where"
                 android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
-                android:textStyle="bold"
+                android:ellipsize="end"
+                android:maxLines="2"
+                android:textColor="?android:attr/textColorSecondary"
                 style="?android:attr/textAppearanceSmall" />
         </LinearLayout>
     </LinearLayout>
index 1ba2d08..ee3ca6e 100644 (file)
@@ -27,6 +27,9 @@
     <TextView android:id="@+id/calendar_name"
         style="?android:attr/spinnerItemStyle"
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content"/>
+        android:layout_height="wrap_content"
+        android:singleLine="true"
+        android:ellipsize="end"
+            />
 
 </LinearLayout>
index d774efb..140eb72 100644 (file)
@@ -93,7 +93,6 @@ public class AgendaByDayAdapter extends BaseAdapter {
 
     private static class ViewHolder {
         TextView dateView;
-        TextView dayOfWeekView;
     }
 
     public View getView(int position, View convertView, ViewGroup parent) {
@@ -112,7 +111,6 @@ public class AgendaByDayAdapter extends BaseAdapter {
                 holder = new ViewHolder();
                 agendaDayView = mInflater.inflate(R.layout.agenda_day, parent, false);
                 holder.dateView = (TextView) agendaDayView.findViewById(R.id.date);
-                holder.dayOfWeekView = (TextView) agendaDayView.findViewById(R.id.day_of_week);
                 agendaDayView.setTag(holder);
             } else {
                 agendaDayView = convertView;
@@ -122,16 +120,18 @@ public class AgendaByDayAdapter extends BaseAdapter {
             // Re-use the member variable "mTime" which is set to the local timezone.
             Time date = mTime;
             long millis = date.setJulianDay(row.mData);
-            int flags = DateUtils.FORMAT_NUMERIC_DATE;
-            holder.dateView.setText(DateUtils.formatDateRange(mContext, millis, millis, flags));
-
+            int flags = DateUtils.FORMAT_SHOW_YEAR
+                    | DateUtils.FORMAT_SHOW_DATE;
+            
             if (row.mData == mTodayJulianDay) {
-                holder.dayOfWeekView.setText(R.string.agenda_today);
+                String dayText = mContext.getResources().getText(R.string.agenda_today) + ", ";
+                holder.dateView.setText(dayText + DateUtils.formatDateTime(mContext, millis, flags));
             } else {
-                int weekDay = date.weekDay + Calendar.SUNDAY;
-                holder.dayOfWeekView.setText(DateUtils.getDayOfWeekString(weekDay,
-                        DateUtils.LENGTH_LONG));
+                flags |= DateUtils.FORMAT_SHOW_WEEKDAY;
+                holder.dateView.setText(DateUtils.formatDateTime(mContext, millis, flags));
             }
+
+
             return agendaDayView;
         } else if (row.mType == TYPE_MEETING) {
             return mAgendaAdapter.getView(row.mData, convertView, parent);
index 20f065c..9988f26 100644 (file)
@@ -53,13 +53,6 @@ public class AlertReceiver extends BroadcastReceiver {
     
     private static final String DELETE_ACTION = "delete";
     
-    private static final String[] PROJECTION = new String[] { 
-        CalendarAlerts._ID,              // 0
-        CalendarAlerts.STATE,            // 1
-    };
-    
-    public static final int INDEX_STATE = 1;
-    
     static final Object mStartingServiceSync = new Object();
     static PowerManager.WakeLock mStartingService;
     
@@ -70,7 +63,9 @@ public class AlertReceiver extends BroadcastReceiver {
             /* The user has clicked the "Clear All Notifications"
              * buttons so dismiss all Calendar alerts.
              */
-            dismissAllEvents(context);
+            // TODO Grab a wake lock here?
+            Intent serviceIntent = new Intent(context, DismissAllAlarmsService.class);
+            context.startService(serviceIntent);
         } else {
             Intent i = new Intent();
             i.setClass(context, AlertService.class);
@@ -94,21 +89,6 @@ public class AlertReceiver extends BroadcastReceiver {
             beginStartingService(context, i);
         }
     }
-    
-    private void dismissAllEvents(Context context) {
-        Uri uri = CalendarAlerts.CONTENT_URI_BY_INSTANCE;
-        String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.FIRED;
-        ContentResolver resolver = context.getContentResolver();
-        Cursor cursor = resolver.query(uri, PROJECTION, selection, null, null);
-        if (cursor != null) {
-            cursor.moveToPosition(-1);
-            while (cursor.moveToNext()) {
-                cursor.updateInt(INDEX_STATE, CalendarAlerts.DISMISSED);
-            }
-            cursor.commitUpdates();
-            cursor.close();
-        }
-    }
 
     /**
      * Start the service to process the current event notifications, acquiring
index 90cd3ff..d0693fa 100644 (file)
@@ -236,10 +236,12 @@ public class DeleteEventHelper {
             .show();
             mAlertDialog = dialog;
             
-            // Disable the "Ok" button until the user selects which events to
-            // delete.
-            Button ok = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
-            ok.setEnabled(false);
+            if (which == -1) {
+                // Disable the "Ok" button until the user selects which events
+                // to delete.
+                Button ok = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
+                ok.setEnabled(false);
+            }
         }
     }
     
diff --git a/src/com/android/calendar/DismissAllAlarmsService.java b/src/com/android/calendar/DismissAllAlarmsService.java
new file mode 100644 (file)
index 0000000..d342106
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 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.Service;
+import android.content.ContentResolver;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.IBinder;
+import android.provider.Calendar.CalendarAlerts;
+
+/**
+ * Service for marking all fired alarms as dismissed. 
+ */
+public class DismissAllAlarmsService extends Service {
+    private static final String[] PROJECTION = new String[] {
+            CalendarAlerts._ID,
+            CalendarAlerts.STATE,
+    };
+    private static final int COLUMN_INDEX_STATE = 1;  
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return null;
+    }
+
+    @SuppressWarnings("deprecation")
+    @Override
+    public void onStart(Intent intent, int startId) {
+        // Mark all fired alarms as dismissed
+        Uri uri = CalendarAlerts.CONTENT_URI_BY_INSTANCE;
+        String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.FIRED;
+        ContentResolver resolver = getContentResolver();
+        Cursor cursor = resolver.query(uri, PROJECTION, selection, null, null);
+        if (cursor != null) {
+            cursor.moveToPosition(-1);
+            while (cursor.moveToNext()) {
+                cursor.updateInt(COLUMN_INDEX_STATE, CalendarAlerts.DISMISSED);
+            }
+            cursor.commitUpdates();
+            cursor.close();
+        }
+
+        // Stop this service
+        stopSelf();
+    }
+}
index f020a7c..6497aad 100644 (file)
@@ -795,11 +795,6 @@ public class EditEvent extends Activity implements View.OnClickListener,
                                     mEndDateButton.setEnabled(false);
                                 } else if (mModification == MODIFY_SELECTED) {
                                     mRepeatsSpinner.setEnabled(false);
-                                } else {
-                                    // We could allow changing the Rrule for
-                                    // all following instances but we'll
-                                    // keep it simple for now.
-                                    mRepeatsSpinner.setEnabled(false);
                                 }
                             }
                         })