OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. |
| 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ |
| 17 |
| 18 package org.adblockplus.android; |
| 19 |
| 20 import org.adblockplus.libadblockplus.Notification; |
| 21 import org.adblockplus.libadblockplus.ShowNotificationCallback; |
| 22 |
| 23 import android.app.NotificationManager; |
| 24 import android.content.Context; |
| 25 import android.support.v4.app.NotificationCompat; |
| 26 import android.util.Log; |
| 27 |
| 28 public class AndroidShowNotificationCallback extends ShowNotificationCallback |
| 29 { |
| 30 private static final String TAG = Utils.getTag(AndroidShowNotificationCallback
.class); |
| 31 |
| 32 private final Context context; |
| 33 |
| 34 public AndroidShowNotificationCallback(final Context context) |
| 35 { |
| 36 this.context = context; |
| 37 } |
| 38 |
| 39 @Override |
| 40 public void showNotificationCallback(final Notification notification) |
| 41 { |
| 42 if (notification != null) |
| 43 { |
| 44 Log.i(TAG, "Received notification: " + notification); |
| 45 |
| 46 final NotificationManager notificationManager = (NotificationManager) this
.context |
| 47 .getSystemService(Context.NOTIFICATION_SERVICE); |
| 48 |
| 49 notificationManager.notify(AdblockPlus.SERVER_NOTIFICATION_ID, |
| 50 new NotificationCompat.Builder(this.context.getApplicationContext()) |
| 51 .setSmallIcon(R.drawable.ic_stat_blocking) |
| 52 .setContentTitle(notification.getTitle()) |
| 53 .setContentText(notification.getMessageString()) |
| 54 .getNotification()); |
| 55 } |
| 56 } |
| 57 } |
OLD | NEW |