Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/Utils.java

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: changed packages, now using AdblockEngine (original ABPEngine), improved demo app Created Oct. 25, 2016, 11:20 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libadblockplus-android/src/org/adblockplus/libadblockplus/android/AndroidWebRequest.java ('k') | pom.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/src/org/adblockplus/libadblockplus/android/Utils.java
diff --git a/libadblockplus-android/src/org/adblockplus/android/Utils.java b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/Utils.java
similarity index 62%
rename from libadblockplus-android/src/org/adblockplus/android/Utils.java
rename to libadblockplus-android/src/org/adblockplus/libadblockplus/android/Utils.java
index 47b7c663c5adb7458de98766d84eacf463d4af0e..395193ee0913cfd5ebd6f664c8eed838e2ab69d2 100644
--- a/libadblockplus-android/src/org/adblockplus/android/Utils.java
+++ b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/Utils.java
@@ -15,14 +15,20 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-package org.adblockplus.android;
+package org.adblockplus.libadblockplus.android;
import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
import org.adblockplus.libadblockplus.JsValue;
import org.adblockplus.libadblockplus.Subscription;
import org.apache.commons.lang.StringUtils;
+import org.json.JSONArray;
import android.app.Notification;
import android.app.NotificationManager;
@@ -80,4 +86,51 @@ public final class Utils
// Ignored for now
}
}
+
+ public static String stringListToJsonArray(List<String> list)
+ {
+ JSONArray array = new JSONArray();
+
+ if (list != null)
+ {
+ for (String eachString : list)
+ {
+ if (eachString != null)
+ {
+ array.put(eachString);
+ }
+ }
+ }
+
+ return array.toString();
+ }
+
+ public static String readAssetAsString(Context context, String filename) throws IOException
+ {
+ BufferedReader in = null;
+ try {
+ StringBuilder buf = new StringBuilder();
+ InputStream is = context.getAssets().open(filename);
+ in = new BufferedReader(new InputStreamReader(is));
+
+ String str;
+ boolean isFirst = true;
+ while ( (str = in.readLine()) != null ) {
+ if (isFirst)
+ isFirst = false;
+ else
+ buf.append('\n');
+ buf.append(str);
+ }
+ return buf.toString();
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignored
+ }
+ }
+ }
+ }
}
« no previous file with comments | « libadblockplus-android/src/org/adblockplus/libadblockplus/android/AndroidWebRequest.java ('k') | pom.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld