| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 java.util.List; | 20 import java.util.List; |
| 21 import java.util.Locale; | 21 import java.util.Locale; |
| 22 | 22 |
| 23 import org.adblockplus.libadblockplus.AppInfo; | 23 import org.adblockplus.libadblockplus.AppInfo; |
| 24 import org.adblockplus.libadblockplus.Filter; | 24 import org.adblockplus.libadblockplus.Filter; |
| 25 import org.adblockplus.libadblockplus.FilterChangeCallback; | 25 import org.adblockplus.libadblockplus.FilterChangeCallback; |
| 26 import org.adblockplus.libadblockplus.FilterEngine; | 26 import org.adblockplus.libadblockplus.FilterEngine; |
| 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType; | 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType; |
| 28 import org.adblockplus.libadblockplus.JsEngine; | 28 import org.adblockplus.libadblockplus.JsEngine; |
| 29 import org.adblockplus.libadblockplus.LogSystem; | 29 import org.adblockplus.libadblockplus.LogSystem; |
| 30 import org.adblockplus.libadblockplus.Notification; | 30 import org.adblockplus.libadblockplus.ShowNotificationCallback; |
| 31 import org.adblockplus.libadblockplus.Subscription; | 31 import org.adblockplus.libadblockplus.Subscription; |
| 32 import org.adblockplus.libadblockplus.UpdateAvailableCallback; | 32 import org.adblockplus.libadblockplus.UpdateAvailableCallback; |
| 33 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 33 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; |
| 34 | 34 |
| 35 import android.content.Context; | 35 import android.content.Context; |
| 36 import android.content.pm.PackageInfo; | 36 import android.content.pm.PackageInfo; |
| 37 import android.content.pm.PackageManager.NameNotFoundException; | 37 import android.content.pm.PackageManager.NameNotFoundException; |
| 38 import android.os.Build.VERSION; | 38 import android.os.Build.VERSION; |
| 39 import android.util.Log; | 39 import android.util.Log; |
| 40 | 40 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 55 * volatile, this seems to prevent the JNI from 'optimizing away' those object
s (as a volatile | 55 * volatile, this seems to prevent the JNI from 'optimizing away' those object
s (as a volatile |
| 56 * variable might be changed at any time from any thread). | 56 * variable might be changed at any time from any thread). |
| 57 */ | 57 */ |
| 58 private volatile JsEngine jsEngine; | 58 private volatile JsEngine jsEngine; |
| 59 private volatile FilterEngine filterEngine; | 59 private volatile FilterEngine filterEngine; |
| 60 private volatile LogSystem logSystem; | 60 private volatile LogSystem logSystem; |
| 61 private volatile AndroidWebRequest webRequest; | 61 private volatile AndroidWebRequest webRequest; |
| 62 private volatile UpdateAvailableCallback updateAvailableCallback; | 62 private volatile UpdateAvailableCallback updateAvailableCallback; |
| 63 private volatile UpdateCheckDoneCallback updateCheckDoneCallback; | 63 private volatile UpdateCheckDoneCallback updateCheckDoneCallback; |
| 64 private volatile FilterChangeCallback filterChangeCallback; | 64 private volatile FilterChangeCallback filterChangeCallback; |
| 65 private volatile ShowNotificationCallback showNotificationCallback; |
| 65 | 66 |
| 66 private ABPEngine(final Context context) | 67 private ABPEngine(final Context context) |
| 67 { | 68 { |
| 68 this.context = context; | 69 this.context = context; |
| 69 } | 70 } |
| 70 | 71 |
| 71 public static AppInfo generateAppInfo(final Context context) | 72 public static AppInfo generateAppInfo(final Context context) |
| 72 { | 73 { |
| 73 final boolean developmentBuild = !context.getResources().getBoolean(R.bool.d
ef_release); | 74 final boolean developmentBuild = !context.getResources().getBoolean(R.bool.d
ef_release); |
| 74 String version = "0"; | 75 String version = "0"; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 engine.webRequest.updateSubscriptionURLs(engine.filterEngine); | 113 engine.webRequest.updateSubscriptionURLs(engine.filterEngine); |
| 113 | 114 |
| 114 engine.updateAvailableCallback = new AndroidUpdateAvailableCallback(context)
; | 115 engine.updateAvailableCallback = new AndroidUpdateAvailableCallback(context)
; |
| 115 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCallbac
k); | 116 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCallbac
k); |
| 116 engine.filterChangeCallback = new AndroidFilterChangeCallback(context); | 117 engine.filterChangeCallback = new AndroidFilterChangeCallback(context); |
| 117 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback); | 118 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback); |
| 118 | 119 |
| 119 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context)
; | 120 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context)
; |
| 120 | 121 |
| 122 engine.showNotificationCallback = new AndroidShowNotificationCallback(contex
t); |
| 123 engine.filterEngine.setShowNotificationCallback(engine.showNotificationCallb
ack); |
| 124 |
| 121 return engine; | 125 return engine; |
| 122 } | 126 } |
| 123 | 127 |
| 124 public void dispose() | 128 public void dispose() |
| 125 { | 129 { |
| 126 // Safe disposing (just in case) | 130 // Safe disposing (just in case) |
| 127 if (this.filterEngine != null) | 131 if (this.filterEngine != null) |
| 128 { | 132 { |
| 129 this.filterEngine.dispose(); | 133 this.filterEngine.dispose(); |
| 130 this.filterEngine = null; | 134 this.filterEngine = null; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 158 { | 162 { |
| 159 this.updateCheckDoneCallback.dispose(); | 163 this.updateCheckDoneCallback.dispose(); |
| 160 this.updateCheckDoneCallback = null; | 164 this.updateCheckDoneCallback = null; |
| 161 } | 165 } |
| 162 | 166 |
| 163 if (this.filterChangeCallback != null) | 167 if (this.filterChangeCallback != null) |
| 164 { | 168 { |
| 165 this.filterChangeCallback.dispose(); | 169 this.filterChangeCallback.dispose(); |
| 166 this.filterChangeCallback = null; | 170 this.filterChangeCallback = null; |
| 167 } | 171 } |
| 172 |
| 173 if (this.showNotificationCallback != null) |
| 174 { |
| 175 this.showNotificationCallback.dispose(); |
| 176 this.showNotificationCallback = null; |
| 177 } |
| 168 } | 178 } |
| 169 | 179 |
| 170 public boolean isFirstRun() | 180 public boolean isFirstRun() |
| 171 { | 181 { |
| 172 return this.filterEngine.isFirstRun(); | 182 return this.filterEngine.isFirstRun(); |
| 173 } | 183 } |
| 174 | 184 |
| 175 private static org.adblockplus.android.Subscription convertJsSubscription(fina
l Subscription jsSubscription) | 185 private static org.adblockplus.android.Subscription convertJsSubscription(fina
l Subscription jsSubscription) |
| 176 { | 186 { |
| 177 final org.adblockplus.android.Subscription subscription = new org.adblockplu
s.android.Subscription(); | 187 final org.adblockplus.android.Subscription subscription = new org.adblockplu
s.android.Subscription(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 284 } |
| 275 | 285 |
| 276 public void updateSubscriptionStatus(final String url) | 286 public void updateSubscriptionStatus(final String url) |
| 277 { | 287 { |
| 278 final Subscription sub = this.filterEngine.getSubscription(url); | 288 final Subscription sub = this.filterEngine.getSubscription(url); |
| 279 if (sub != null) | 289 if (sub != null) |
| 280 { | 290 { |
| 281 Utils.updateSubscriptionStatus(this.context, sub); | 291 Utils.updateSubscriptionStatus(this.context, sub); |
| 282 } | 292 } |
| 283 } | 293 } |
| 284 | |
| 285 public Notification getNextNotificationToShow(String url) | |
| 286 { | |
| 287 return this.filterEngine.getNextNotificationToShow(url); | |
| 288 } | |
| 289 | |
| 290 public Notification getNextNotificationToShow() | |
| 291 { | |
| 292 return this.filterEngine.getNextNotificationToShow(); | |
| 293 } | |
| 294 } | 294 } |
| OLD | NEW |