Tue, 10 Feb 2015 18:12:00 +0100
Import initial revisions of existing project AndroidCaldavSyncAdapater,
forked from upstream repository at 27e8a0f8495c92e0780d450bdf0c7cec77a03a55.
michael@0 | 1 | package org.gege.caldavsyncadapter.syncadapter.notifications; |
michael@0 | 2 | |
michael@0 | 3 | import org.gege.caldavsyncadapter.R; |
michael@0 | 4 | |
michael@0 | 5 | import android.app.NotificationManager; |
michael@0 | 6 | //import android.app.PendingIntent; |
michael@0 | 7 | import android.content.Context; |
michael@0 | 8 | //import android.content.Intent; |
michael@0 | 9 | import android.support.v4.app.NotificationCompat; |
michael@0 | 10 | //import android.support.v4.app.TaskStackBuilder; |
michael@0 | 11 | |
michael@0 | 12 | public class NotificationsHelper { |
michael@0 | 13 | |
michael@0 | 14 | /*static SyncLog currentSyncLog = new SyncLog(); |
michael@0 | 15 | doesn't exist */ |
michael@0 | 16 | |
michael@0 | 17 | public static void signalSyncErrors(Context context, String title, String text) { |
michael@0 | 18 | NotificationCompat.Builder mBuilder = |
michael@0 | 19 | new NotificationCompat.Builder(context) |
michael@0 | 20 | .setSmallIcon(R.drawable.icon) |
michael@0 | 21 | .setContentTitle(title) |
michael@0 | 22 | .setContentText(text); |
michael@0 | 23 | |
michael@0 | 24 | // Creates an explicit intent for an Activity in your app |
michael@0 | 25 | /* Intent resultIntent = new Intent(context, SyncStatusReportActivity.class); |
michael@0 | 26 | |
michael@0 | 27 | // The stack builder object will contain an artificial back stack for the |
michael@0 | 28 | // started Activity. |
michael@0 | 29 | // This ensures that navigating backward from the Activity leads out of |
michael@0 | 30 | // your application to the Home screen. |
michael@0 | 31 | TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); |
michael@0 | 32 | // Adds the back stack for the Intent (but not the Intent itself) |
michael@0 | 33 | stackBuilder.addParentStack(SyncStatusReportActivity.class); |
michael@0 | 34 | // Adds the Intent that starts the Activity to the top of the stack |
michael@0 | 35 | stackBuilder.addNextIntent(resultIntent); |
michael@0 | 36 | PendingIntent resultPendingIntent = |
michael@0 | 37 | stackBuilder.getPendingIntent( |
michael@0 | 38 | 0, |
michael@0 | 39 | PendingIntent.FLAG_UPDATE_CURRENT |
michael@0 | 40 | ); |
michael@0 | 41 | mBuilder.setContentIntent(resultPendingIntent); |
michael@0 | 42 | */ |
michael@0 | 43 | |
michael@0 | 44 | NotificationManager mNotificationManager = |
michael@0 | 45 | (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); |
michael@0 | 46 | |
michael@0 | 47 | // mId allows you to update the notification later on. |
michael@0 | 48 | int mId = 0; |
michael@0 | 49 | mNotificationManager.notify(mId, mBuilder.build()); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | /*public static SyncLog getCurrentSyncLog() { |
michael@0 | 53 | return currentSyncLog; |
michael@0 | 54 | }*/ |
michael@0 | 55 | |
michael@0 | 56 | } |