Browse Source

Updated ProxyUtils to automatically start TOR when needed, more abstraction of BrowserActivity, other cleanup

master
Anthony Restaino 9 years ago
parent
commit
e35b368d50
  1. 2
      app/app.iml
  2. 1
      app/build.gradle
  3. 2
      app/src/LightningPlus/java/acr/browser/lightning/utils/ProxyUtils.java
  4. 45
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  5. 1
      app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java
  6. 1
      app/src/main/java/acr/browser/lightning/activity/MainActivity.java
  7. 2
      app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java
  8. 377
      app/src/main/java/acr/browser/lightning/utils/Utils.java
  9. 4
      app/src/main/res/values/strings.xml
  10. 74
      app/src/main/res/xml/preference_about.xml

2
app/app.iml

@ -93,6 +93,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" />
@ -115,6 +116,7 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="client-0.7" level="project" /> <orderEntry type="library" exported="" name="client-0.7" level="project" />
<orderEntry type="library" exported="" name="palette-v7-22.2.0" level="project" /> <orderEntry type="library" exported="" name="palette-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="design-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" /> <orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />

1
app/build.gradle

@ -46,6 +46,7 @@ android {
dependencies { dependencies {
compile 'com.android.support:palette-v7:22.2.0' compile 'com.android.support:palette-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'org.jsoup:jsoup:1.8.1' compile 'org.jsoup:jsoup:1.8.1'
// Only Lightning Plus needs the proxy libraries // Only Lightning Plus needs the proxy libraries

2
app/src/LightningPlus/java/acr/browser/lightning/utils/ProxyUtils.java

@ -117,7 +117,7 @@ public class ProxyUtils {
case Constants.PROXY_ORBOT: case Constants.PROXY_ORBOT:
if (!OrbotHelper.isOrbotRunning(activity)) if (!OrbotHelper.isOrbotRunning(activity))
OrbotHelper.requestShowOrbotStart(activity); OrbotHelper.requestStartTor(activity);
host = "localhost"; host = "localhost";
port = 8118; port = 8118;
break; break;

45
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -139,7 +139,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
// List // List
private final List<LightningView> mWebViewList = new ArrayList<>(); private final List<LightningView> mWebViewList = new ArrayList<>();
private List<HistoryItem> mBookmarkList; private final List<HistoryItem> mBookmarkList = new ArrayList<>();
private LightningView mCurrentView; private LightningView mCurrentView;
private WebView mWebView; private WebView mWebView;
@ -164,8 +164,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
private Activity mActivity; private Activity mActivity;
// Primatives // Primatives
private boolean mSystemBrowser = false, mIsNewIntent = false, mFullScreen, mColorMode, private boolean mSystemBrowser = false, mIsNewIntent = false, mFullScreen, mColorMode, mDarkTheme;
mDarkTheme;
private int mOriginalOrientation, mBackgroundColor, mIdGenerator; private int mOriginalOrientation, mBackgroundColor, mIdGenerator;
private String mSearchText, mUntitledTitle, mHomepage, mCameraPhotoPath; private String mSearchText, mUntitledTitle, mHomepage, mCameraPhotoPath;
@ -200,6 +199,8 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
public abstract void updateHistory(final String title, final String url); public abstract void updateHistory(final String title, final String url);
abstract void updateCookiePreference();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -318,7 +319,8 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
@Override @Override
public void run() { public void run() {
mBookmarkManager = BookmarkManager.getInstance(mActivity.getApplicationContext()); mBookmarkManager = BookmarkManager.getInstance(mActivity.getApplicationContext());
mBookmarkList = mBookmarkManager.getBookmarks(true); mBookmarkList.clear();
mBookmarkList.addAll(mBookmarkManager.getBookmarks(true));
if (mBookmarkList.size() == 0 && mPreferences.getDefaultBookmarks()) { if (mBookmarkList.size() == 0 && mPreferences.getDefaultBookmarks()) {
for (String[] array : BookmarkManager.DEFAULT_BOOKMARKS) { for (String[] array : BookmarkManager.DEFAULT_BOOKMARKS) {
HistoryItem bookmark = new HistoryItem(array[0], array[1]); HistoryItem bookmark = new HistoryItem(array[0], array[1]);
@ -715,13 +717,6 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
mProxyUtils.updateProxySettings(this); mProxyUtils.updateProxySettings(this);
} }
/*
* Override this if class overrides BrowserActivity
*/
void updateCookiePreference() {
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) { if (keyCode == KeyEvent.KEYCODE_ENTER) {
@ -803,7 +798,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
if (mCurrentView != null && !mCurrentView.getUrl().startsWith(Constants.FILE)) { if (mCurrentView != null && !mCurrentView.getUrl().startsWith(Constants.FILE)) {
HistoryItem bookmark = new HistoryItem(mCurrentView.getUrl(), HistoryItem bookmark = new HistoryItem(mCurrentView.getUrl(),
mCurrentView.getTitle()); mCurrentView.getTitle());
if (mBookmarkManager.addBookmark(bookmark) && mBookmarkList != null) { if (mBookmarkManager.addBookmark(bookmark)) {
mBookmarkList.add(bookmark); mBookmarkList.add(bookmark);
Collections.sort(mBookmarkList, new SortIgnoreCase()); Collections.sort(mBookmarkList, new SortIgnoreCase());
notifyBookmarkDataSetChanged(); notifyBookmarkDataSetChanged();
@ -829,8 +824,6 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
* adapter doesn't always change when notifyDataChanged gets called. * adapter doesn't always change when notifyDataChanged gets called.
*/ */
private void notifyBookmarkDataSetChanged() { private void notifyBookmarkDataSetChanged() {
mBookmarkAdapter.clear();
mBookmarkAdapter.addAll(mBookmarkList);
mBookmarkAdapter.notifyDataSetChanged(); mBookmarkAdapter.notifyDataSetChanged();
} }
@ -1111,8 +1104,10 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
url = intent.getDataString(); url = intent.getDataString();
} }
int num = 0; int num = 0;
String source = null;
if (intent != null && intent.getExtras() != null) { if (intent != null && intent.getExtras() != null) {
num = intent.getExtras().getInt(getPackageName() + ".Origin"); num = intent.getExtras().getInt(getPackageName() + ".Origin");
source = intent.getExtras().getString("SOURCE");
} }
if (num == 1) { if (num == 1) {
mCurrentView.loadUrl(url); mCurrentView.loadUrl(url);
@ -1122,7 +1117,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
url = null; url = null;
} }
newTab(url, true); newTab(url, true);
mIsNewIntent = true; mIsNewIntent = (source == null);
} }
} }
@ -1403,19 +1398,17 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse
if (mCurrentView != null) { if (mCurrentView != null) {
mCurrentView.resumeTimers(); mCurrentView.resumeTimers();
mCurrentView.onResume(); mCurrentView.onResume();
mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext());
mBookmarkList = mBookmarkManager.getBookmarks(true);
notifyBookmarkDataSetChanged();
} }
mHistoryDatabase = HistoryDatabase.getInstance(getApplicationContext());
mBookmarkList.clear();
mBookmarkList.addAll(mBookmarkManager.getBookmarks(true));
notifyBookmarkDataSetChanged();
initializePreferences(); initializePreferences();
if (mWebViewList != null) { for (int n = 0; n < mWebViewList.size(); n++) {
for (int n = 0; n < mWebViewList.size(); n++) { if (mWebViewList.get(n) != null) {
if (mWebViewList.get(n) != null) { mWebViewList.get(n).initializePreferences(this);
mWebViewList.get(n).initializePreferences(this); } else {
} else { mWebViewList.remove(n);
mWebViewList.remove(n);
}
} }
} }

1
app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java

@ -20,7 +20,6 @@ public class IncognitoActivity extends BrowserActivity {
CookieSyncManager.createInstance(this); CookieSyncManager.createInstance(this);
} }
cookieManager.setAcceptCookie(PreferenceManager.getInstance().getIncognitoCookiesEnabled()); cookieManager.setAcceptCookie(PreferenceManager.getInstance().getIncognitoCookiesEnabled());
super.updateCookiePreference();
} }
@Override @Override

1
app/src/main/java/acr/browser/lightning/activity/MainActivity.java

@ -20,7 +20,6 @@ public class MainActivity extends BrowserActivity {
CookieSyncManager.createInstance(this); CookieSyncManager.createInstance(this);
} }
cookieManager.setAcceptCookie(PreferenceManager.getInstance().getCookiesEnabled()); cookieManager.setAcceptCookie(PreferenceManager.getInstance().getCookiesEnabled());
super.updateCookiePreference();
} }
@Override @Override

2
app/src/main/java/acr/browser/lightning/fragment/DisplaySettingsFragment.java

@ -143,7 +143,7 @@ public class DisplaySettingsFragment extends PreferenceFragment implements Prefe
private void themePicker() { private void themePicker() {
AlertDialog.Builder picker = new AlertDialog.Builder(mActivity); AlertDialog.Builder picker = new AlertDialog.Builder(mActivity);
picker.setTitle(getResources().getString(R.string.url_contents)); picker.setTitle(getResources().getString(R.string.theme));
int n = mPreferences.getUseTheme(); int n = mPreferences.getUseTheme();
picker.setSingleChoiceItems(mThemeOptions, n, new DialogInterface.OnClickListener() { picker.setSingleChoiceItems(mThemeOptions, n, new DialogInterface.OnClickListener() {

377
app/src/main/java/acr/browser/lightning/utils/Utils.java

@ -17,9 +17,11 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Environment; import android.os.Environment;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.widget.Toast; import android.widget.Toast;
@ -37,139 +39,146 @@ import acr.browser.lightning.download.DownloadHandler;
public final class Utils { public final class Utils {
private Utils() { private Utils() {
} }
public static void downloadFile(final Activity activity, final String url, public static void downloadFile(final Activity activity, final String url,
final String userAgent, final String contentDisposition) { final String userAgent, final String contentDisposition) {
String fileName = URLUtil.guessFileName(url, null, null); String fileName = URLUtil.guessFileName(url, null, null);
DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null DownloadHandler.onDownloadStart(activity, url, userAgent, contentDisposition, null
); );
Log.i(Constants.TAG, "Downloading" + fileName); Log.i(Constants.TAG, "Downloading" + fileName);
} }
public static Intent newEmailIntent(String address, String subject, public static Intent newEmailIntent(String address, String subject,
String body, String cc) { String body, String cc) {
Intent intent = new Intent(Intent.ACTION_SEND); Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { address }); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{address});
intent.putExtra(Intent.EXTRA_TEXT, body); intent.putExtra(Intent.EXTRA_TEXT, body);
intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_CC, cc); intent.putExtra(Intent.EXTRA_CC, cc);
intent.setType("message/rfc822"); intent.setType("message/rfc822");
return intent; return intent;
} }
public static void createInformativeDialog(Context context, String title, String message) { public static void createInformativeDialog(Context context, String title, String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title); builder.setTitle(title);
builder.setMessage(message) builder.setMessage(message)
.setCancelable(true) .setCancelable(true)
.setPositiveButton(context.getResources().getString(R.string.action_ok), .setPositiveButton(context.getResources().getString(R.string.action_ok),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
} }
}); });
AlertDialog alert = builder.create(); AlertDialog alert = builder.create();
alert.show(); alert.show();
} }
public static void showToast(Context context, String message) { public static void showToast(Context context, String message) {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
} }
public static void showToast(Context context, @StringRes int resource) { public static void showToast(Context context, @StringRes int resource) {
Toast.makeText(context, resource, Toast.LENGTH_SHORT).show(); Toast.makeText(context, resource, Toast.LENGTH_SHORT).show();
} }
/** public static void showSnackBar(View view, String message) {
* Returns the number of pixels corresponding to the passed density pixels Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show();
*/ }
public static int convertDpToPixels(int dp) {
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics(); public static void showSnackBar(View view, @StringRes int resource) {
return (int) (dp * metrics.density + 0.5f); Snackbar.make(view, resource, Snackbar.LENGTH_SHORT).show();
} }
public static String getDomainName(String url) { /**
boolean ssl = url.startsWith(Constants.HTTPS); * Returns the number of pixels corresponding to the passed density pixels
int index = url.indexOf('/', 8); */
if (index != -1) { public static int convertDpToPixels(int dp) {
url = url.substring(0, index); DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
} return (int) (dp * metrics.density + 0.5f);
}
URI uri;
String domain = null; public static String getDomainName(String url) {
try { boolean ssl = url.startsWith(Constants.HTTPS);
uri = new URI(url); int index = url.indexOf('/', 8);
domain = uri.getHost(); if (index != -1) {
} catch (URISyntaxException e) { url = url.substring(0, index);
e.printStackTrace(); }
}
URI uri;
if (domain == null || domain.isEmpty()) { String domain = null;
return url; try {
} uri = new URI(url);
if (ssl) domain = uri.getHost();
return Constants.HTTPS + domain; } catch (URISyntaxException e) {
else e.printStackTrace();
return domain.startsWith("www.") ? domain.substring(4) : domain; }
}
if (domain == null || domain.isEmpty()) {
public static String getProtocol(String url) { return url;
int index = url.indexOf('/'); }
return url.substring(0, index + 2); if (ssl)
} return Constants.HTTPS + domain;
else
public static String[] getArray(String input) { return domain.startsWith("www.") ? domain.substring(4) : domain;
return input.split(Constants.SEPARATOR); }
}
public static String getProtocol(String url) {
public static void trimCache(Context context) { int index = url.indexOf('/');
try { return url.substring(0, index + 2);
File dir = context.getCacheDir(); }
if (dir != null && dir.isDirectory()) { public static String[] getArray(String input) {
deleteDir(dir); return input.split(Constants.SEPARATOR);
} }
} catch (Exception ignored) {
public static void trimCache(Context context) {
} try {
} File dir = context.getCacheDir();
public static boolean deleteDir(File dir) { if (dir != null && dir.isDirectory()) {
if (dir != null && dir.isDirectory()) { deleteDir(dir);
String[] children = dir.list(); }
for (String aChildren : children) { } catch (Exception ignored) {
boolean success = deleteDir(new File(dir, aChildren));
if (!success) { }
return false; }
}
} public static boolean deleteDir(File dir) {
} if (dir != null && dir.isDirectory()) {
// The directory is now empty so delete it String[] children = dir.list();
return dir != null && dir.delete(); for (String aChildren : children) {
} boolean success = deleteDir(new File(dir, aChildren));
if (!success) {
/** return false;
* Creates and returns a new favicon which is the same as the provided }
* favicon but with horizontal or vertical padding of 4dp }
* }
* @param bitmap // The directory is now empty so delete it
* is the bitmap to pad. return dir != null && dir.delete();
* @return the padded bitmap. }
*/
public static Bitmap padFavicon(Bitmap bitmap) { /**
int padding = Utils.convertDpToPixels(4); * Creates and returns a new favicon which is the same as the provided
* favicon but with horizontal or vertical padding of 4dp
Bitmap paddedBitmap = Bitmap.createBitmap(bitmap.getWidth() + padding, bitmap.getHeight() *
+ padding, Bitmap.Config.ARGB_8888); * @param bitmap is the bitmap to pad.
* @return the padded bitmap.
Canvas canvas = new Canvas(paddedBitmap); */
canvas.drawARGB(0x00, 0x00, 0x00, 0x00); // this represents white color public static Bitmap padFavicon(Bitmap bitmap) {
canvas.drawBitmap(bitmap, padding / 2, padding / 2, new Paint(Paint.FILTER_BITMAP_FLAG)); int padding = Utils.convertDpToPixels(4);
return paddedBitmap; Bitmap paddedBitmap = Bitmap.createBitmap(bitmap.getWidth() + padding, bitmap.getHeight()
} + padding, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(paddedBitmap);
canvas.drawARGB(0x00, 0x00, 0x00, 0x00); // this represents white color
canvas.drawBitmap(bitmap, padding / 2, padding / 2, new Paint(Paint.FILTER_BITMAP_FLAG));
return paddedBitmap;
}
public static boolean isColorTooDark(int color) { public static boolean isColorTooDark(int color) {
final byte RED_CHANNEL = 16; final byte RED_CHANNEL = 16;
@ -185,71 +194,71 @@ public final class Utils {
return gray < 0x727272; return gray < 0x727272;
} }
public static int mixTwoColors(int color1, int color2, float amount) { public static int mixTwoColors(int color1, int color2, float amount) {
final byte ALPHA_CHANNEL = 24; final byte ALPHA_CHANNEL = 24;
final byte RED_CHANNEL = 16; final byte RED_CHANNEL = 16;
final byte GREEN_CHANNEL = 8; final byte GREEN_CHANNEL = 8;
//final byte BLUE_CHANNEL = 0; //final byte BLUE_CHANNEL = 0;
final float inverseAmount = 1.0f - amount; final float inverseAmount = 1.0f - amount;
int r = ((int) (((float) (color1 >> RED_CHANNEL & 0xff) * amount) + ((float) (color2 >> RED_CHANNEL & 0xff) * inverseAmount))) & 0xff; int r = ((int) (((float) (color1 >> RED_CHANNEL & 0xff) * amount) + ((float) (color2 >> RED_CHANNEL & 0xff) * inverseAmount))) & 0xff;
int g = ((int) (((float) (color1 >> GREEN_CHANNEL & 0xff) * amount) + ((float) (color2 >> GREEN_CHANNEL & 0xff) * inverseAmount))) & 0xff; int g = ((int) (((float) (color1 >> GREEN_CHANNEL & 0xff) * amount) + ((float) (color2 >> GREEN_CHANNEL & 0xff) * inverseAmount))) & 0xff;
int b = ((int) (((float) (color1 & 0xff) * amount) + ((float) (color2 & 0xff) * inverseAmount))) & 0xff; int b = ((int) (((float) (color1 & 0xff) * amount) + ((float) (color2 & 0xff) * inverseAmount))) & 0xff;
return 0xff << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b; return 0xff << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b;
} }
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
public static File createImageFile() throws IOException { public static File createImageFile() throws IOException {
// Create an image file name // Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_"; String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = Environment File storageDir = Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
return File.createTempFile(imageFileName, /* prefix */ return File.createTempFile(imageFileName, /* prefix */
".jpg", /* suffix */ ".jpg", /* suffix */
storageDir /* directory */ storageDir /* directory */
); );
} }
public static boolean isFlashInstalled(Context context) { public static boolean isFlashInstalled(Context context) {
try { try {
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0); ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
if (ai != null) { if (ai != null) {
return true; return true;
} }
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
return false; return false;
} }
return false; return false;
} }
public static Bitmap getWebpageBitmap(Resources resources, boolean dark) { public static Bitmap getWebpageBitmap(Resources resources, boolean dark) {
if (dark) { if (dark) {
if (mWebIconDark == null) { if (mWebIconDark == null) {
mWebIconDark = BitmapFactory.decodeResource(resources, R.drawable.ic_webpage_dark); mWebIconDark = BitmapFactory.decodeResource(resources, R.drawable.ic_webpage_dark);
} }
return mWebIconDark; return mWebIconDark;
} else { } else {
if (mWebIconLight == null) { if (mWebIconLight == null) {
mWebIconLight = BitmapFactory.decodeResource(resources, R.drawable.ic_webpage); mWebIconLight = BitmapFactory.decodeResource(resources, R.drawable.ic_webpage);
} }
return mWebIconLight; return mWebIconLight;
} }
} }
private static Bitmap mWebIconLight; private static Bitmap mWebIconLight;
private static Bitmap mWebIconDark; private static Bitmap mWebIconDark;
public static void close(Closeable closeable) { public static void close(Closeable closeable) {
if (closeable == null) if (closeable == null)
return; return;
try { try {
closeable.close(); closeable.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

4
app/src/main/res/values/strings.xml

@ -53,7 +53,7 @@
<string name="stock_browser_unavailable">No stock browser detected</string> <string name="stock_browser_unavailable">No stock browser detected</string>
<string name="stock_browser_available">Supported stock browser detected</string> <string name="stock_browser_available">Supported stock browser detected</string>
<string name="fullScreenOption">Hide status bar while browsing</string> <string name="fullScreenOption">Hide status bar while browsing</string>
<string name="clear_cookies">Clear browser cookies</string> <string name="clear_cookies">Clear Browser Cookies</string>
<string name="dialog_image">What would you like to do with this image?</string> <string name="dialog_image">What would you like to do with this image?</string>
<string name="action_download">Download</string> <string name="action_download">Download</string>
<string name="action_open">Open</string> <string name="action_open">Open</string>
@ -110,7 +110,7 @@
<string name="action_auto">Auto</string> <string name="action_auto">Auto</string>
<string name="action_follow_me">Contact Me</string> <string name="action_follow_me">Contact Me</string>
<string name="url_twitter">twitter.com/RestainoAnthony</string> <string name="url_twitter">twitter.com/RestainoAnthony</string>
<string name="clear_cache">Clear cache</string> <string name="clear_cache">Clear Cache</string>
<string name="message_cache_cleared">Cache Cleared</string> <string name="message_cache_cleared">Cache Cleared</string>
<string name="message_import">Bookmarks Were Imported</string> <string name="message_import">Bookmarks Were Imported</string>
<string name="message_clear_history">History Cleared</string> <string name="message_clear_history">History Cleared</string>

74
app/src/main/res/xml/preference_about.xml

@ -3,58 +3,86 @@
<PreferenceCategory android:title="@string/settings_about"> <PreferenceCategory android:title="@string/settings_about">
<Preference <Preference
android:title="@string/action_follow_me" android:summary="@string/url_twitter"
android:summary="@string/url_twitter"> android:title="@string/action_follow_me">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="http://twitter.com/RestainoAnthony" /> android:data="http://twitter.com/RestainoAnthony">
<extra
android:name="SOURCE"
android:value="SELF" />
</intent>
</Preference> </Preference>
<Preference <Preference
android:title="@string/version" android:key="pref_version"
android:key="pref_version" /> android:title="@string/version" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/licenses"> <PreferenceCategory android:title="@string/licenses">
<Preference <Preference
android:title="@string/app_name" android:summary="@string/mpl_license"
android:summary="@string/mpl_license"> android:title="@string/app_name">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="http://www.mozilla.org/MPL/2.0/" /> android:data="http://www.mozilla.org/MPL/2.0/">
<extra
android:name="SOURCE"
android:value="SELF" />
</intent>
</Preference> </Preference>
<Preference <Preference
android:title="@string/android_open_source_project" android:summary="@string/apache"
android:summary="@string/apache"> android:title="@string/android_open_source_project">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="http://www.apache.org/licenses/LICENSE-2.0" /> android:data="http://www.apache.org/licenses/LICENSE-2.0">
<extra
android:name="SOURCE"
android:value="SELF" />
</intent>
</Preference> </Preference>
<Preference <Preference
android:title="@string/hphosts_ad_server_list" android:summary="@string/freeware"
android:summary="@string/freeware"> android:title="@string/hphosts_ad_server_list">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="http://hosts-file.net/" /> android:data="http://hosts-file.net/">
<extra
android:name="SOURCE"
android:value="SELF" />
</intent>
</Preference> </Preference>
<Preference <Preference
android:title="@string/library_netcipher" android:summary="@string/license_gnu"
android:summary="@string/license_gnu"> android:title="@string/library_netcipher">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="http://www.gnu.org/licenses/lgpl.html" /> android:data="http://www.gnu.org/licenses/lgpl.html">
<extra
android:name="SOURCE"
android:value="SELF" />
</intent>
</Preference> </Preference>
<Preference <Preference
android:title="@string/snacktory" android:summary="@string/apache"
android:summary="@string/apache"> android:title="@string/snacktory">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="http://www.apache.org/licenses/LICENSE-2.0" /> android:data="http://www.apache.org/licenses/LICENSE-2.0">
<extra
android:name="SOURCE"
android:value="SELF" />
</intent>
</Preference> </Preference>
<Preference <Preference
android:title="@string/jsoup" android:summary="@string/mit_license"
android:summary="@string/mit_license"> android:title="@string/jsoup">
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:data="http://jsoup.org/license" /> android:data="http://jsoup.org/license">
<extra
android:name="SOURCE"
android:value="SELF" />
</intent>
</Preference> </Preference>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
Loading…
Cancel
Save