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

Delta Between Two Patch Sets: libadblockplus-android/src/org/adblockplus/libadblockplus/android/Utils.java

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Left Patch Set: removed gradlew.bat - it relates to issue-4324 Created Sept. 16, 2016, 11:27 a.m.
Right Patch Set: changed packages, now using AdblockEngine (original ABPEngine), improved demo app Created Oct. 25, 2016, 11:20 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « libadblockplus-android/src/org/adblockplus/libadblockplus/android/AndroidWebRequest.java ('k') | pom.xml » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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.libadblockplus.android;
19 19
20 import java.io.BufferedReader; 20 import java.io.BufferedReader;
21 import java.io.IOException;
22 import java.io.InputStream;
21 import java.io.InputStreamReader; 23 import java.io.InputStreamReader;
24 import java.net.URI;
25 import java.net.URISyntaxException;
26 import java.util.List;
22 27
23 import org.adblockplus.libadblockplus.JsValue; 28 import org.adblockplus.libadblockplus.JsValue;
24 import org.adblockplus.libadblockplus.Subscription; 29 import org.adblockplus.libadblockplus.Subscription;
25 import org.apache.commons.lang.StringUtils; 30 import org.apache.commons.lang.StringUtils;
31 import org.json.JSONArray;
26 32
27 import android.app.Notification; 33 import android.app.Notification;
28 import android.app.NotificationManager; 34 import android.app.NotificationManager;
29 import android.app.PendingIntent; 35 import android.app.PendingIntent;
30 import android.content.Context; 36 import android.content.Context;
31 import android.content.Intent; 37 import android.content.Intent;
32 38
33 public final class Utils 39 public final class Utils
34 { 40 {
35 private Utils() 41 private Utils()
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 { 79 {
74 buf.close(); 80 buf.close();
75 } 81 }
76 82
77 } 83 }
78 catch (final Exception e) 84 catch (final Exception e)
79 { 85 {
80 // Ignored for now 86 // Ignored for now
81 } 87 }
82 } 88 }
89
90 public static String stringListToJsonArray(List<String> list)
91 {
92 JSONArray array = new JSONArray();
93
94 if (list != null)
95 {
96 for (String eachString : list)
97 {
98 if (eachString != null)
99 {
100 array.put(eachString);
101 }
102 }
103 }
104
105 return array.toString();
106 }
107
108 public static String readAssetAsString(Context context, String filename) throw s IOException
109 {
110 BufferedReader in = null;
111 try {
112 StringBuilder buf = new StringBuilder();
113 InputStream is = context.getAssets().open(filename);
114 in = new BufferedReader(new InputStreamReader(is));
115
116 String str;
117 boolean isFirst = true;
118 while ( (str = in.readLine()) != null ) {
119 if (isFirst)
120 isFirst = false;
121 else
122 buf.append('\n');
123 buf.append(str);
124 }
125 return buf.toString();
126 } finally {
127 if (in != null) {
128 try {
129 in.close();
130 } catch (IOException e) {
131 // ignored
132 }
133 }
134 }
135 }
83 } 136 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld