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

Side by Side Diff: src/org/adblockplus/android/AdblockPlus.java

Issue 5662276015095808: Issue 1540 - Utility method for loading text is at the wrong location (Closed)
Patch Set: Created Nov. 6, 2014, 1:06 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 java.io.BufferedReader;
21 import java.io.File; 20 import java.io.File;
22 import java.io.FileNotFoundException; 21 import java.io.FileNotFoundException;
23 import java.io.IOException; 22 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.InputStreamReader; 23 import java.io.InputStreamReader;
26 import java.util.List; 24 import java.util.List;
27 import java.util.regex.Pattern; 25 import java.util.regex.Pattern;
28 26
29 import org.adblockplus.libadblockplus.FilterEngine.ContentType; 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType;
30 import org.apache.commons.lang.StringUtils; 28 import org.apache.commons.lang.StringUtils;
31 29
32 import android.app.ActivityManager; 30 import android.app.ActivityManager;
33 import android.app.ActivityManager.RunningServiceInfo; 31 import android.app.ActivityManager.RunningServiceInfo;
34 import android.app.Application; 32 import android.app.Application;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 public static String getDeviceName() 134 public static String getDeviceName()
137 { 135 {
138 final String manufacturer = Build.MANUFACTURER; 136 final String manufacturer = Build.MANUFACTURER;
139 final String model = Build.MODEL; 137 final String model = Build.MODEL;
140 if (model.startsWith(manufacturer)) 138 if (model.startsWith(manufacturer))
141 return Utils.capitalizeString(model); 139 return Utils.capitalizeString(model);
142 else 140 else
143 return Utils.capitalizeString(manufacturer) + " " + model; 141 return Utils.capitalizeString(manufacturer) + " " + model;
144 } 142 }
145 143
146 public static void appendRawTextFile(final Context context, final StringBuilde r text, final int id)
147 {
148 // TODO: What about closing the resources?
149 final InputStream inputStream = context.getResources().openRawResource(id);
150 final InputStreamReader in = new InputStreamReader(inputStream);
151 final BufferedReader buf = new BufferedReader(in);
152 String line;
153 try
154 {
155 while ((line = buf.readLine()) != null)
156 text.append(line);
157 }
158 catch (final IOException e)
159 {
160 // TODO: How about real logging?
161 e.printStackTrace();
162 }
163 }
164
165 /** 144 /**
166 * Checks if device has a WiFi connection available. 145 * Checks if device has a WiFi connection available.
167 */ 146 */
168 public static boolean isWiFiConnected(final Context context) 147 public static boolean isWiFiConnected(final Context context)
169 { 148 {
170 final ConnectivityManager connectivityManager = (ConnectivityManager) contex t.getSystemService(Context.CONNECTIVITY_SERVICE); 149 final ConnectivityManager connectivityManager = (ConnectivityManager) contex t.getSystemService(Context.CONNECTIVITY_SERVICE);
171 NetworkInfo networkInfo = null; 150 NetworkInfo networkInfo = null;
172 if (connectivityManager != null) 151 if (connectivityManager != null)
173 { 152 {
174 networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_ WIFI); 153 networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_ WIFI);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 429 }
451 catch (final IOException e) 430 catch (final IOException e)
452 { 431 {
453 Log.e(TAG, e.getMessage(), e); 432 Log.e(TAG, e.getMessage(), e);
454 } 433 }
455 434
456 // Set crash handler 435 // Set crash handler
457 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); 436 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this));
458 } 437 }
459 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld