| Index: libadblockplus-android/src/org/adblockplus/android/Utils.java | 
| diff --git a/libadblockplus-android/src/org/adblockplus/android/Utils.java b/libadblockplus-android/src/org/adblockplus/android/Utils.java | 
| index 47b7c663c5adb7458de98766d84eacf463d4af0e..1554ae90c9948ec56a213b207f77ae9ad8b3da6f 100644 | 
| --- a/libadblockplus-android/src/org/adblockplus/android/Utils.java | 
| +++ b/libadblockplus-android/src/org/adblockplus/android/Utils.java | 
| @@ -18,11 +18,17 @@ | 
| package org.adblockplus.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,66 @@ 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(); | 
| + } | 
| + | 
| + /** | 
| + * Extract domain from URL | 
| + * @param url valid URL (with scheme) | 
| + * @return domain | 
| + * @throws URISyntaxException | 
| + */ | 
| + public static String getDomain(String url) throws URISyntaxException | 
| + { | 
| + URI uri = new URI(url); | 
| + String domain = uri.getHost(); | 
| + if (domain == null) | 
| + throw new URISyntaxException(url, "Invalid url"); | 
| + return domain.startsWith("www.") ? domain.substring(4) : domain; | 
| + } | 
| + | 
| + 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 | 
| + } | 
| + } | 
| + } | 
| + } | 
| } |