OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.android; | 18 package org.adblockplus.android; |
19 | 19 |
20 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 20 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; |
21 import org.apache.commons.lang.StringUtils; | 21 import org.apache.commons.lang.StringUtils; |
22 | 22 |
23 import android.app.Notification; | |
24 import android.app.NotificationManager; | |
25 import android.content.Context; | 23 import android.content.Context; |
26 | 24 |
27 public class AndroidUpdateCheckDoneCallback extends UpdateCheckDoneCallback | 25 public class AndroidUpdateCheckDoneCallback extends UpdateCheckDoneCallback |
28 { | 26 { |
29 private final Context context; | 27 private final Context context; |
30 | 28 |
31 public AndroidUpdateCheckDoneCallback(final Context context) | 29 public AndroidUpdateCheckDoneCallback(final Context context) |
32 { | 30 { |
33 this.context = context; | 31 this.context = context; |
34 } | 32 } |
35 | 33 |
36 @Override | 34 @Override |
37 public void updateCheckDoneCallback(final String error) | 35 public void updateCheckDoneCallback(final String error) |
38 { | 36 { |
39 // TODO: Check if we need this 'manualUpdate' mechanism (initiated by 'check
ForUpdates()') | 37 if (StringUtils.isNotEmpty(error)) |
40 // if (!error.empty()) | 38 Utils.showUpdateNotification(this.context, null, error); |
41 // { | |
42 // jstring jError = jniEnv->NewStringUTF(error.c_str()); | |
43 // if (mid) | |
44 // jniEnv->CallVoidMethod(jniObject, mid, NULL, jError); | |
45 // jniEnv->DeleteLocalRef(jError); | |
46 // } | |
47 // else if (manualUpdate) | |
48 // { | |
49 // if (mid) | |
50 // jniEnv->CallVoidMethod(jniObject, mid, NULL, NULL); | |
51 // } | |
52 | |
53 final Notification notification = Utils.createUpdateNotification(this.contex
t, null, StringUtils.isEmpty(error) ? null : error); | |
54 final NotificationManager notificationManager = (NotificationManager)this.co
ntext.getSystemService(Context.NOTIFICATION_SERVICE); | |
55 notificationManager.notify(AdblockPlus.UPDATE_NOTIFICATION_ID, notification)
; | |
56 } | 39 } |
57 } | 40 } |
OLD | NEW |