Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42ba5efe authored by Sara Ting's avatar Sara Ting
Browse files

Fancy notifications: future and concurrent alerts are now individual...

Fancy notifications: future and concurrent alerts are now individual expandable notifications, with expired ones being in the digest.

Bug: 6282451

Change-Id: I8ebe72fe1cbd41448c4ff3a0b9043bd1a179ff00
parent 216f7f14
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -36,14 +36,6 @@
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarStyle">

        <Button
            android:id="@+id/snooze_all"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/snooze_all_label" />

        <Button
            android:id="@+id/dismiss_all"
            android:layout_width="0dip"
@@ -51,6 +43,5 @@
            android:layout_weight="1"
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/dismiss_all_label" />

    </LinearLayout>
</LinearLayout>
+9 −6
Original line number Diff line number Diff line
@@ -217,8 +217,8 @@

    <!-- The alert toast is not actually being displayed for some reason. -->
    <skip/>
    <!-- the title of the alert/notification activity -->
    <string name="alert_title">Calendar notifications</string>
    <!-- the title of the expired alert/notification activity -->
    <string name="past_alerts_title">Past events</string>
    <!-- Notification window messages: -->
    <skip/>

@@ -349,6 +349,9 @@
    <!-- The button label for dismissing all the current reminder alarms. This
         causes them to disappear from the notification screen. -->
    <string name="dismiss_all_label">"Dismiss all"</string>
    <!-- The button label for making the reminder alarms go away temporarily
         and re-fire in 5 minutes. [CHAR LIMIT=30]-->
    <string name="snooze_5min_label">"Snooze for 5 minutes"</string>

    <!-- Repetition dialog options: -->
    <skip/>
@@ -604,12 +607,12 @@
        <item quantity="other"><xliff:g id="count">%d</xliff:g> events</item>
    </plurals>

    <!-- number of remaining events for an alert in the notification bar [CHAR LIMIT = 30] -->
    <plurals name="N_more_events">
    <!-- number of remaining events for an alert digest in the notification bar [CHAR LIMIT = 30] -->
    <plurals name="N_missed_events">
        <!-- This is the label for 1 event. -->
        <item quantity="one">+1 event</item>
        <item quantity="one">+1 missed event</item>
        <!-- This is the label for 2 or more events. -->
        <item quantity="other">+<xliff:g id="count">%d</xliff:g> events</item>
        <item quantity="other">+<xliff:g id="count">%d</xliff:g> missed events</item>
    </plurals>

    <!-- Description of the selected marker for accessibility support [CHAR LIMIT = NONE]-->
+6 −0
Original line number Diff line number Diff line
@@ -251,4 +251,10 @@
        <item name="android:layout_marginTop">-4dp</item>
        <item name="android:singleLine">true</item>
    </style>

    <style name="NotificationPrimaryText" parent="@android:style/TextAppearance.StatusBar.EventContent.Title" />

    <style name="NotificationSecondaryText" parent="@android:style/TextAppearance.Holo">
        <item name="android:textColor">?android:attr/textColorSecondary</item>
    </style>
</resources>
+11 −50
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.calendar.alerts;

import com.android.calendar.AllInOneActivity;
import com.android.calendar.AsyncQueryService;
import com.android.calendar.EventInfoActivity;
import com.android.calendar.R;
@@ -75,23 +74,24 @@ public class AlertActivity extends Activity implements OnClickListener {
    public static final int INDEX_STATE = 10;
    public static final int INDEX_ALARM_TIME = 11;

    private static final String SELECTION = CalendarAlerts.STATE + "=?";
    private static final String SELECTION = CalendarAlerts.STATE + "=? AND " +
            CalendarAlerts.END + "<?";
    private static final String[] SELECTIONARG = new String[] {
        Integer.toString(CalendarAlerts.STATE_FIRED)
        Integer.toString(CalendarAlerts.STATE_FIRED), Long.toString(System.currentTimeMillis())
    };

    private AlertAdapter mAdapter;
    private QueryHandler mQueryHandler;
    private Cursor mCursor;
    private ListView mListView;
    private Button mSnoozeAllButton;
    private Button mDismissAllButton;


    private void dismissFiredAlarms() {
    private void dismissFiredAlarmsForPastEvents() {
        ContentValues values = new ContentValues(1 /* size */);
        values.put(PROJECTION[INDEX_STATE], CalendarAlerts.STATE_DISMISSED);
        String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED;
        String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " +
                CalendarAlerts.END + "<" + Long.toString(System.currentTimeMillis());
        mQueryHandler.startUpdate(0, null, CalendarAlerts.CONTENT_URI, values,
                selection, null /* selectionArgs */, Utils.UNDO_DELAY);
    }
@@ -118,7 +118,6 @@ public class AlertActivity extends Activity implements OnClickListener {
                mListView.setSelection(cursor.getCount() - 1);

                // The results are in, enable the buttons
                mSnoozeAllButton.setEnabled(true);
                mDismissAllButton.setEnabled(true);
            } else {
                cursor.close();
@@ -179,7 +178,7 @@ public class AlertActivity extends Activity implements OnClickListener {
        super.onCreate(icicle);

        setContentView(R.layout.alert_activity);
        setTitle(R.string.alert_title);
        setTitle(R.string.past_alerts_title);

        mQueryHandler = new QueryHandler(this);
        mAdapter = new AlertAdapter(this, R.layout.alert_item);
@@ -189,13 +188,10 @@ public class AlertActivity extends Activity implements OnClickListener {
        mListView.setAdapter(mAdapter);
        mListView.setOnItemClickListener(mViewListener);

        mSnoozeAllButton = (Button) findViewById(R.id.snooze_all);
        mSnoozeAllButton.setOnClickListener(this);
        mDismissAllButton = (Button) findViewById(R.id.dismiss_all);
        mDismissAllButton.setOnClickListener(this);

        // Disable the buttons, since they need mCursor, which is created asynchronously
        mSnoozeAllButton.setEnabled(false);
        mDismissAllButton.setEnabled(false);
    }

@@ -220,7 +216,7 @@ public class AlertActivity extends Activity implements OnClickListener {
    @Override
    protected void onStop() {
        super.onStop();
        AlertService.updateAlertNotification(this);
        AlertService.updateAlertNotification(this, false);

        if (mCursor != null) {
            mCursor.deactivate();
@@ -237,47 +233,12 @@ public class AlertActivity extends Activity implements OnClickListener {

    @Override
    public void onClick(View v) {
        if (v == mSnoozeAllButton) {
            long alarmTime = System.currentTimeMillis() + AlertUtils.SNOOZE_DELAY;

            NotificationManager nm =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            nm.cancel(AlertUtils.NOTIFICATION_ID);

            if (mCursor != null) {
                long scheduleAlarmTime = 0;
                mCursor.moveToPosition(-1);
                while (mCursor.moveToNext()) {
                    long eventId = mCursor.getLong(INDEX_EVENT_ID);
                    long begin = mCursor.getLong(INDEX_BEGIN);
                    long end = mCursor.getLong(INDEX_END);

                    // Set the "minutes" to zero to indicate this is a snoozed
                    // alarm.  There is code in AlertService.java that checks
                    // this field.
                    ContentValues values = AlertUtils.makeContentValues(eventId, begin, end,
                            alarmTime, 0 /* minutes */);

                    // Create a new alarm entry in the CalendarAlerts table
                    if (mCursor.isLast()) {
                        scheduleAlarmTime = alarmTime;
                    }
                    mQueryHandler.startInsert(0,
                            scheduleAlarmTime, CalendarAlerts.CONTENT_URI, values,
                            Utils.UNDO_DELAY);
                }
            } else {
                Log.d(TAG, "Cursor object is null. Ignore the Snooze request.");
            }

            dismissFiredAlarms();
            finish();
        } else if (v == mDismissAllButton) {
        if (v == mDismissAllButton) {
            NotificationManager nm =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            nm.cancel(AlertUtils.NOTIFICATION_ID);
            nm.cancel(AlertUtils.EXPIRED_GROUP_NOTIFICATION_ID);

            dismissFiredAlarms();
            dismissFiredAlarmsForPastEvents();

            finish();
        }
+201 −166

File changed.

Preview size limit exceeded, changes collapsed.

Loading