Loading AndroidManifest.xml +14 −1 Original line number Diff line number Diff line Loading @@ -155,9 +155,19 @@ android:resource="@xml/task_widget_info" /> </receiver> <!-- Start the Service if applicable on boot --> <receiver android:name="org.dmfs.provider.tasks.handler.AlarmNotificationHandler" > <receiver android:name="org.dmfs.provider.tasks.broadcast.StartAlarmBroadcastHandler" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> <receiver android:name="org.dmfs.provider.tasks.broadcast.DueAlarmBroadcastHandler" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> Loading @@ -176,6 +186,9 @@ <intent-filter> <action android:name="org.dmfs.android.tasks.taskdue" /> </intent-filter> <intent-filter> <action android:name="org.dmfs.android.tasks.taskstart" /> </intent-filter> </receiver> </application> Loading res/values-de/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -158,5 +158,6 @@ <!-- Strings for notification --> <string name="notification_task_due_title">Aufgabe fällig</string> <string name="notification_task_start_title">Aufgabe startet</string> </resources> No newline at end of file res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -158,5 +158,6 @@ <!-- Strings for notification --> <string name="notification_task_due_title">Task due</string> <string name="notification_task_start_title">Task starts</string> </resources> No newline at end of file src/org/dmfs/tasks/AlarmBroadcastReceiver.java +86 −39 Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ package org.dmfs.tasks; import java.net.URI; import org.dmfs.provider.tasks.TaskContract.Tasks; import org.dmfs.provider.tasks.handler.AlarmNotificationHandler; import org.dmfs.provider.tasks.broadcast.DueAlarmBroadcastHandler; import org.dmfs.provider.tasks.broadcast.StartAlarmBroadcastHandler; import android.app.Notification; import android.app.NotificationManager; Loading Loading @@ -38,11 +39,56 @@ public class AlarmBroadcastReceiver extends BroadcastReceiver public void onReceive(Context context, Intent intent) { // continue if alarms where enabled if (intent.getAction().equals(StartAlarmBroadcastHandler.BROADCAST_START_ALARM)) { if (getAlarmPreference(context)) { long taskId = intent.getLongExtra(AlarmNotificationHandler.EXTRA_TASK_ID, 0); long taskId = intent.getLongExtra(StartAlarmBroadcastHandler.EXTRA_TASK_ID, 0); // long dueTime = intent.getLongExtra(AlarmNotificationHandler.EXTRA_TASK_DUE_TIME, System.currentTimeMillis()); String title = intent.getStringExtra(AlarmNotificationHandler.EXTRA_TASK_TITLE); String title = intent.getStringExtra(StartAlarmBroadcastHandler.EXTRA_TASK_TITLE); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // build notification NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_notification_completed) .setContentTitle(context.getString(R.string.notification_task_start_title)).setContentText(title); // dismisses the notification on click mBuilder.setAutoCancel(true); // set status bar test mBuilder.setTicker(title); // enable light, sound and vibration mBuilder.setDefaults(Notification.DEFAULT_ALL); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, ViewTaskActivity.class); resultIntent.setData(getUriForTask(taskId)); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(ViewTaskActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); notificationManager.notify((int) taskId, mBuilder.build()); } } else if (intent.getAction().equals(DueAlarmBroadcastHandler.BROADCAST_DUE_ALARM)) { if (getAlarmPreference(context)) { long taskId = intent.getLongExtra(DueAlarmBroadcastHandler.EXTRA_TASK_ID, 0); // long dueTime = intent.getLongExtra(AlarmNotificationHandler.EXTRA_TASK_DUE_TIME, System.currentTimeMillis()); String title = intent.getStringExtra(DueAlarmBroadcastHandler.EXTRA_TASK_TITLE); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Loading Loading @@ -78,6 +124,7 @@ public class AlarmBroadcastReceiver extends BroadcastReceiver notificationManager.notify((int) taskId, mBuilder.build()); } } } Loading Loading
AndroidManifest.xml +14 −1 Original line number Diff line number Diff line Loading @@ -155,9 +155,19 @@ android:resource="@xml/task_widget_info" /> </receiver> <!-- Start the Service if applicable on boot --> <receiver android:name="org.dmfs.provider.tasks.handler.AlarmNotificationHandler" > <receiver android:name="org.dmfs.provider.tasks.broadcast.StartAlarmBroadcastHandler" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> <receiver android:name="org.dmfs.provider.tasks.broadcast.DueAlarmBroadcastHandler" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver> Loading @@ -176,6 +186,9 @@ <intent-filter> <action android:name="org.dmfs.android.tasks.taskdue" /> </intent-filter> <intent-filter> <action android:name="org.dmfs.android.tasks.taskstart" /> </intent-filter> </receiver> </application> Loading
res/values-de/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -158,5 +158,6 @@ <!-- Strings for notification --> <string name="notification_task_due_title">Aufgabe fällig</string> <string name="notification_task_start_title">Aufgabe startet</string> </resources> No newline at end of file
res/values/strings.xml +1 −0 Original line number Diff line number Diff line Loading @@ -158,5 +158,6 @@ <!-- Strings for notification --> <string name="notification_task_due_title">Task due</string> <string name="notification_task_start_title">Task starts</string> </resources> No newline at end of file
src/org/dmfs/tasks/AlarmBroadcastReceiver.java +86 −39 Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ package org.dmfs.tasks; import java.net.URI; import org.dmfs.provider.tasks.TaskContract.Tasks; import org.dmfs.provider.tasks.handler.AlarmNotificationHandler; import org.dmfs.provider.tasks.broadcast.DueAlarmBroadcastHandler; import org.dmfs.provider.tasks.broadcast.StartAlarmBroadcastHandler; import android.app.Notification; import android.app.NotificationManager; Loading Loading @@ -38,11 +39,56 @@ public class AlarmBroadcastReceiver extends BroadcastReceiver public void onReceive(Context context, Intent intent) { // continue if alarms where enabled if (intent.getAction().equals(StartAlarmBroadcastHandler.BROADCAST_START_ALARM)) { if (getAlarmPreference(context)) { long taskId = intent.getLongExtra(AlarmNotificationHandler.EXTRA_TASK_ID, 0); long taskId = intent.getLongExtra(StartAlarmBroadcastHandler.EXTRA_TASK_ID, 0); // long dueTime = intent.getLongExtra(AlarmNotificationHandler.EXTRA_TASK_DUE_TIME, System.currentTimeMillis()); String title = intent.getStringExtra(AlarmNotificationHandler.EXTRA_TASK_TITLE); String title = intent.getStringExtra(StartAlarmBroadcastHandler.EXTRA_TASK_TITLE); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // build notification NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_notification_completed) .setContentTitle(context.getString(R.string.notification_task_start_title)).setContentText(title); // dismisses the notification on click mBuilder.setAutoCancel(true); // set status bar test mBuilder.setTicker(title); // enable light, sound and vibration mBuilder.setDefaults(Notification.DEFAULT_ALL); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, ViewTaskActivity.class); resultIntent.setData(getUriForTask(taskId)); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(ViewTaskActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); notificationManager.notify((int) taskId, mBuilder.build()); } } else if (intent.getAction().equals(DueAlarmBroadcastHandler.BROADCAST_DUE_ALARM)) { if (getAlarmPreference(context)) { long taskId = intent.getLongExtra(DueAlarmBroadcastHandler.EXTRA_TASK_ID, 0); // long dueTime = intent.getLongExtra(AlarmNotificationHandler.EXTRA_TASK_DUE_TIME, System.currentTimeMillis()); String title = intent.getStringExtra(DueAlarmBroadcastHandler.EXTRA_TASK_TITLE); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Loading Loading @@ -78,6 +124,7 @@ public class AlarmBroadcastReceiver extends BroadcastReceiver notificationManager.notify((int) taskId, mBuilder.build()); } } } Loading