Browse Source

Fixed crash for devices without AOSP browser

master
Anthony Restaino 12 years ago
parent
commit
3c1627bfd8
  1. BIN
      Barebones.apk
  2. 192
      src/acr/browser/barebones/Barebones.java
  3. 10
      src/acr/browser/barebones/CustomWebView.java
  4. 168
      src/acr/browser/barebones/IncognitoMode.java
  5. 10
      src/acr/browser/barebones/IncognitoWebView.java

BIN
Barebones.apk

Binary file not shown.

192
src/acr/browser/barebones/Barebones.java

@ -99,10 +99,10 @@ public class Barebones extends Activity {
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
public class CustomChromeClient extends WebChromeClient { public class CustomChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster; public Bitmap mDefaultVideoPoster;
private View mVideoProgressView; public View mVideoProgressView;
private FrameLayout fullScreenContainer; public FrameLayout fullScreenContainer;
private int orientation; public int orientation;
@Override @Override
public void onExceededDatabaseQuota(String url, public void onExceededDatabaseQuota(String url,
@ -316,7 +316,7 @@ public class Barebones extends Activity {
} }
} }
private class CustomDownloadListener implements DownloadListener { public class CustomDownloadListener implements DownloadListener {
@Override @Override
public void onDownloadStart(final String url, String userAgent, public void onDownloadStart(final String url, String userAgent,
@ -362,7 +362,7 @@ public class Barebones extends Activity {
} }
private class CustomWebViewClient extends WebViewClient { public class CustomWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
@ -494,7 +494,7 @@ public class Barebones extends Activity {
} }
} }
private void generateHistory(final CustomWebView view) { public void generateHistory(final CustomWebView view) {
Thread history = new Thread(new Runnable() { Thread history = new Thread(new Runnable() {
@ -571,7 +571,7 @@ public class Barebones extends Activity {
history.run(); history.run();
} }
private void setUrlText(String url) { public void setUrlText(String url) {
if (!url.contains("file:///" + getBaseContext().getFilesDir() if (!url.contains("file:///" + getBaseContext().getFilesDir()
+ "/bookmarks.html") + "/bookmarks.html")
&& !url.contains("file:///" + getBaseContext().getFilesDir() && !url.contains("file:///" + getBaseContext().getFilesDir()
@ -582,7 +582,7 @@ public class Barebones extends Activity {
} }
} }
private class TabTouchListener implements OnTouchListener { public class TabTouchListener implements OnTouchListener {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
@ -668,7 +668,7 @@ public class Barebones extends Activity {
} }
private void removeView(WebView view) { public void removeView(WebView view) {
if (!showFullScreen) { if (!showFullScreen) {
view.startAnimation(fadeOut); view.startAnimation(fadeOut);
} }
@ -676,7 +676,7 @@ public class Barebones extends Activity {
uBar.bringToFront(); uBar.bringToFront();
} }
private void deleteBookmark(String url) { public void deleteBookmark(String url) {
File book = new File(getBaseContext().getFilesDir(), "bookmarks"); File book = new File(getBaseContext().getFilesDir(), "bookmarks");
File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl");
int n = 0; int n = 0;
@ -720,7 +720,7 @@ public class Barebones extends Activity {
openBookmarks(main[pageId]); openBookmarks(main[pageId]);
} }
private class WebPageLongClickListener implements OnLongClickListener { public class WebPageLongClickListener implements OnLongClickListener {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
@ -902,107 +902,107 @@ public class Barebones extends Activity {
} }
// variables to differentiate free from paid // variables to differentiate free from paid
private static final int MAX_TABS = FinalVars.MAX_TABS; public static final int MAX_TABS = FinalVars.MAX_TABS;
private static final int MAX_BOOKMARKS = FinalVars.MAX_BOOKMARKS; public static final int MAX_BOOKMARKS = FinalVars.MAX_BOOKMARKS;
private static final boolean PAID_VERSION = FinalVars.PAID_VERSION; public static final boolean PAID_VERSION = FinalVars.PAID_VERSION;
private final Context CONTEXT = Barebones.this; public final Context CONTEXT = Barebones.this;
private static final String HOMEPAGE = FinalVars.HOMEPAGE; public static final String HOMEPAGE = FinalVars.HOMEPAGE;
private static final String SEARCH = FinalVars.GOOGLE_SEARCH; public static final String SEARCH = FinalVars.GOOGLE_SEARCH;
private static SimpleAdapter adapter; public static SimpleAdapter adapter;
private static MultiAutoCompleteTextView getUrl; public static MultiAutoCompleteTextView getUrl;
private static final TextView[] urlTitle = new TextView[MAX_TABS]; public static final TextView[] urlTitle = new TextView[MAX_TABS];
private static final CustomWebView[] main = new CustomWebView[MAX_TABS]; public static final CustomWebView[] main = new CustomWebView[MAX_TABS];
private static Rect bounds; public static Rect bounds;
private static ValueCallback<Uri> mUploadMessage; public static ValueCallback<Uri> mUploadMessage;
private static ImageView refresh; public static ImageView refresh;
private static ProgressBar progressBar; public static ProgressBar progressBar;
private static Drawable webpageOther; public static Drawable webpageOther;
private static Drawable incognitoPage; public static Drawable incognitoPage;
private static Drawable exitTab; public static Drawable exitTab;
private static int numberPage; public static int numberPage;
private static final int fuzz = 10; public static final int fuzz = 10;
private static int number; public static int number;
private static int pageId = 0; public static int pageId = 0;
private static int agentPicker; public static int agentPicker;
private static int enableFlash; public static int enableFlash;
private static int height32; public static int height32;
private static int height; public static int height;
private static int width; public static int width;
private static int pixels; public static int pixels;
private static int leftPad; public static int leftPad;
private static int rightPad; public static int rightPad;
private static final int API = FinalVars.API; public static final int API = FinalVars.API;
private static int mShortAnimationDuration; public static int mShortAnimationDuration;
private static int id; public static int id;
private static int tenPad; public static int tenPad;
private static int urlColumn; public static int urlColumn;
private static int titleColumn; public static int titleColumn;
private static int closeWindow; public static int closeWindow;
private static View mCustomView = null; public static View mCustomView = null;
private static CustomViewCallback mCustomViewCallback; public static CustomViewCallback mCustomViewCallback;
private static final boolean[] incognito = new boolean[MAX_TABS]; public static final boolean[] incognito = new boolean[MAX_TABS];
private static boolean isPhone = false; public static boolean isPhone = false;
private static boolean pageIsLoading = false; public static boolean pageIsLoading = false;
private static boolean allowLocation; public static boolean allowLocation;
private static boolean savePasswords; public static boolean savePasswords;
private static boolean deleteHistory; public static boolean deleteHistory;
private static boolean saveTabs; public static boolean saveTabs;
static boolean showFullScreen; static boolean showFullScreen;
private static boolean noStockBrowser = true; public static boolean noStockBrowser = true;
private static SharedPreferences settings; public static SharedPreferences settings;
private static SharedPreferences.Editor edit; public static SharedPreferences.Editor edit;
private static String desktop; public static String desktop;
private static String mobile; public static String mobile;
private static String user; public static String user;
private static String urlA; public static String urlA;
private static String title; public static String title;
private static String[] memoryURL = new String[MAX_TABS]; public static String[] memoryURL = new String[MAX_TABS];
private static final String[] bUrl = new String[MAX_BOOKMARKS]; public static final String[] bUrl = new String[MAX_BOOKMARKS];
private static final String[] bTitle = new String[MAX_BOOKMARKS]; public static final String[] bTitle = new String[MAX_BOOKMARKS];
private static String[] columns; public static String[] columns;
private static String homepage; public static String homepage;
private static String str; public static String str;
private static final String preferences = "settings"; public static final String preferences = "settings";
private static String query; public static String query;
private static String userAgent; public static String userAgent;
private static final String[][] urlToLoad = new String[MAX_TABS][2]; public static final String[][] urlToLoad = new String[MAX_TABS][2];
private static FrameLayout background; public static FrameLayout background;
static RelativeLayout uBar; static RelativeLayout uBar;
private static HorizontalScrollView tabScroll; public static HorizontalScrollView tabScroll;
static Animation slideUp; static Animation slideUp;
static Animation slideDown; static Animation slideDown;
private static Animation fadeOut; public static Animation fadeOut;
private static Animation fadeIn; public static Animation fadeIn;
private static TextView txt; public static TextView txt;
private static CookieManager cookieManager; public static CookieManager cookieManager;
private static Uri bookmarks; public static Uri bookmarks;
private static List<Map<String, String>> list; public static List<Map<String, String>> list;
private static Map<String, String> map; public static Map<String, String> map;
private static Handler handler, browserHandler; public static Handler handler, browserHandler;
private static DatabaseHandler historyHandler; public static DatabaseHandler historyHandler;
private static StringBuilder sb; public static StringBuilder sb;
private static Runnable update; public static Runnable update;
private static SQLiteDatabase s; public static SQLiteDatabase s;
private static Drawable inactive; public static Drawable inactive;
private static Drawable active; public static Drawable active;
private static LinearLayout tabLayout; public static LinearLayout tabLayout;
private static String[] GetArray(String input) { public static String[] GetArray(String input) {
return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|"); return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|");
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static void setFavicon(int id, Bitmap favicon) { public static void setFavicon(int id, Bitmap favicon) {
Drawable icon = null; Drawable icon = null;
icon = new BitmapDrawable(null, favicon); icon = new BitmapDrawable(null, favicon);
icon.setBounds(0, 0, width / 2, height / 2); icon.setBounds(0, 0, width / 2, height / 2);
@ -1356,7 +1356,9 @@ public class Barebones extends Activity {
noStockBrowser = true; noStockBrowser = true;
Log.e("Barebones", "did not detect AOSP browser"); Log.e("Barebones", "did not detect AOSP browser");
} }
if (c != null) {
c.close(); c.close();
}
try { try {
managedCursor = null; managedCursor = null;
@ -1807,7 +1809,7 @@ public class Barebones extends Activity {
} }
} }
private CustomWebView makeTab(final int pageToView, final String Url, public CustomWebView makeTab(final int pageToView, final String Url,
final boolean display) { final boolean display) {
CustomWebView view = new CustomWebView(CONTEXT); CustomWebView view = new CustomWebView(CONTEXT);
view.setId(pageToView); view.setId(pageToView);

10
src/acr/browser/barebones/CustomWebView.java

@ -12,11 +12,11 @@ import android.widget.ZoomButtonsController;
public final class CustomWebView extends WebView { public final class CustomWebView extends WebView {
private float location; private float location;
private boolean first = false; private boolean first = false;
private final int API = FinalVars.API; final int API = FinalVars.API;
private final boolean showFullScreen = Barebones.showFullScreen; final boolean showFullScreen = Barebones.showFullScreen;
private final View uBar = Barebones.uBar; final View uBar = Barebones.uBar;
private final Animation slideUp = Barebones.slideUp; final Animation slideUp = Barebones.slideUp;
private final Animation slideDown = Barebones.slideDown; final Animation slideDown = Barebones.slideDown;
private ZoomButtonsController zoomControl; private ZoomButtonsController zoomControl;
public CustomWebView(Context context) { public CustomWebView(Context context) {
super(context); super(context);

168
src/acr/browser/barebones/IncognitoMode.java

@ -97,10 +97,10 @@ public class IncognitoMode extends Activity {
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
public class CustomChromeClient extends WebChromeClient { public class CustomChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster; public Bitmap mDefaultVideoPoster;
private View mVideoProgressView; public View mVideoProgressView;
private FrameLayout fullScreenContainer; public FrameLayout fullScreenContainer;
private int orientation; public int orientation;
@Override @Override
public void onExceededDatabaseQuota(String url, public void onExceededDatabaseQuota(String url,
@ -303,7 +303,7 @@ public class IncognitoMode extends Activity {
} }
} }
private class CustomDownloadListener implements DownloadListener { public class CustomDownloadListener implements DownloadListener {
@Override @Override
public void onDownloadStart(final String url, String userAgent, public void onDownloadStart(final String url, String userAgent,
@ -349,7 +349,7 @@ public class IncognitoMode extends Activity {
} }
private class IncognitoWebViewClient extends WebViewClient { public class IncognitoWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
@ -475,7 +475,7 @@ public class IncognitoMode extends Activity {
} }
} }
private void generateHistory(final IncognitoWebView view) { public void generateHistory(final IncognitoWebView view) {
Thread history = new Thread(new Runnable() { Thread history = new Thread(new Runnable() {
@ -552,7 +552,7 @@ public class IncognitoMode extends Activity {
history.run(); history.run();
} }
private void setUrlText(String url) { public void setUrlText(String url) {
if (!url.contains("file:///" + getBaseContext().getFilesDir() if (!url.contains("file:///" + getBaseContext().getFilesDir()
+ "/bookmarks.html") + "/bookmarks.html")
&& !url.contains("file:///" + getBaseContext().getFilesDir() && !url.contains("file:///" + getBaseContext().getFilesDir()
@ -563,7 +563,7 @@ public class IncognitoMode extends Activity {
} }
} }
private class TabTouchListener implements OnTouchListener { public class TabTouchListener implements OnTouchListener {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
@ -649,7 +649,7 @@ public class IncognitoMode extends Activity {
} }
private void removeView(WebView view) { public void removeView(WebView view) {
if (!showFullScreen) { if (!showFullScreen) {
view.startAnimation(fadeOut); view.startAnimation(fadeOut);
} }
@ -657,7 +657,7 @@ public class IncognitoMode extends Activity {
uBar.bringToFront(); uBar.bringToFront();
} }
private void deleteBookmark(String url) { public void deleteBookmark(String url) {
File book = new File(getBaseContext().getFilesDir(), "bookmarks"); File book = new File(getBaseContext().getFilesDir(), "bookmarks");
File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl"); File bookUrl = new File(getBaseContext().getFilesDir(), "bookurl");
int n = 0; int n = 0;
@ -701,7 +701,7 @@ public class IncognitoMode extends Activity {
openBookmarks(main[pageId]); openBookmarks(main[pageId]);
} }
private class WebPageLongClickListener implements OnLongClickListener { public class WebPageLongClickListener implements OnLongClickListener {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
@ -883,90 +883,90 @@ public class IncognitoMode extends Activity {
} }
// variables to differentiate free from paid // variables to differentiate free from paid
private static final int MAX_TABS = FinalVars.MAX_TABS; public static final int MAX_TABS = FinalVars.MAX_TABS;
private static final int MAX_BOOKMARKS = FinalVars.MAX_BOOKMARKS; public static final int MAX_BOOKMARKS = FinalVars.MAX_BOOKMARKS;
private static final boolean PAID_VERSION = FinalVars.PAID_VERSION; public static final boolean PAID_VERSION = FinalVars.PAID_VERSION;
private final Context CONTEXT = IncognitoMode.this; public final Context CONTEXT = IncognitoMode.this;
private static final String HOMEPAGE = FinalVars.HOMEPAGE; public static final String HOMEPAGE = FinalVars.HOMEPAGE;
private static final String SEARCH = FinalVars.GOOGLE_SEARCH; public static final String SEARCH = FinalVars.GOOGLE_SEARCH;
private static SimpleAdapter adapter; public static SimpleAdapter adapter;
private static MultiAutoCompleteTextView getUrl; public static MultiAutoCompleteTextView getUrl;
private static final TextView[] urlTitle = new TextView[MAX_TABS]; public static final TextView[] urlTitle = new TextView[MAX_TABS];
private static final IncognitoWebView[] main = new IncognitoWebView[MAX_TABS]; public static final IncognitoWebView[] main = new IncognitoWebView[MAX_TABS];
private static Rect bounds; public static Rect bounds;
private static ValueCallback<Uri> mUploadMessage; public static ValueCallback<Uri> mUploadMessage;
private static ImageView refresh; public static ImageView refresh;
private static ProgressBar progressBar; public static ProgressBar progressBar;
private static Drawable webpageOther; public static Drawable webpageOther;
private static Drawable incognitoPage; public static Drawable incognitoPage;
private static Drawable exitTab; public static Drawable exitTab;
private static int numberPage; public static int numberPage;
private static final int fuzz = 10; public static final int fuzz = 10;
private static int number; public static int number;
private static int pageId = 0; public static int pageId = 0;
private static int agentPicker; public static int agentPicker;
private static int enableFlash; public static int enableFlash;
private static int height32; public static int height32;
private static int height; public static int height;
private static int width; public static int width;
private static int pixels; public static int pixels;
private static int leftPad; public static int leftPad;
private static int rightPad; public static int rightPad;
private static final int API = FinalVars.API; public static final int API = FinalVars.API;
private static int mShortAnimationDuration; public static int mShortAnimationDuration;
private static int id; public static int id;
private static int tenPad; public static int tenPad;
private static int urlColumn; public static int urlColumn;
private static int titleColumn; public static int titleColumn;
private static int closeWindow; public static int closeWindow;
private static View mCustomView = null; public static View mCustomView = null;
private static CustomViewCallback mCustomViewCallback; public static CustomViewCallback mCustomViewCallback;
private static boolean isPhone = false; public static boolean isPhone = false;
private static boolean pageIsLoading = false; public static boolean pageIsLoading = false;
private static boolean allowLocation; public static boolean allowLocation;
static boolean showFullScreen; static boolean showFullScreen;
private static SharedPreferences settings; public static SharedPreferences settings;
private static SharedPreferences.Editor edit; public static SharedPreferences.Editor edit;
private static String desktop; public static String desktop;
private static String mobile; public static String mobile;
private static String user; public static String user;
private static String urlA; public static String urlA;
private static String title; public static String title;
private static final String[] bUrl = new String[MAX_BOOKMARKS]; public static final String[] bUrl = new String[MAX_BOOKMARKS];
private static final String[] bTitle = new String[MAX_BOOKMARKS]; public static final String[] bTitle = new String[MAX_BOOKMARKS];
private static String[] columns; public static String[] columns;
private static String homepage; public static String homepage;
private static String str; public static String str;
private static final String preferences = "settings"; public static final String preferences = "settings";
private static String query; public static String query;
private static String userAgent; public static String userAgent;
private static final String[][] urlToLoad = new String[MAX_TABS][2]; public static final String[][] urlToLoad = new String[MAX_TABS][2];
private static FrameLayout background; public static FrameLayout background;
static RelativeLayout uBar; static RelativeLayout uBar;
private static HorizontalScrollView tabScroll; public static HorizontalScrollView tabScroll;
static Animation slideUp; static Animation slideUp;
static Animation slideDown; static Animation slideDown;
private static Animation fadeOut; public static Animation fadeOut;
private static Animation fadeIn; public static Animation fadeIn;
private static TextView txt; public static TextView txt;
private static CookieManager cookieManager; public static CookieManager cookieManager;
private static List<Map<String, String>> list; public static List<Map<String, String>> list;
private static Map<String, String> map; public static Map<String, String> map;
private static Handler handler, browserHandler; public static Handler handler, browserHandler;
private static DatabaseHandler historyHandler; public static DatabaseHandler historyHandler;
private static Drawable inactive; public static Drawable inactive;
private static Drawable active; public static Drawable active;
private static LinearLayout tabLayout; public static LinearLayout tabLayout;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static void setFavicon(int id, Bitmap favicon) { public static void setFavicon(int id, Bitmap favicon) {
Drawable icon = null; Drawable icon = null;
icon = new BitmapDrawable(null, favicon); icon = new BitmapDrawable(null, favicon);
icon.setBounds(0, 0, width / 2, height / 2); icon.setBounds(0, 0, width / 2, height / 2);
@ -1684,7 +1684,7 @@ public class IncognitoMode extends Activity {
} }
private IncognitoWebView makeTab(final int pageToView, final String Url, public IncognitoWebView makeTab(final int pageToView, final String Url,
final boolean display) { final boolean display) {
IncognitoWebView view = new IncognitoWebView(CONTEXT); IncognitoWebView view = new IncognitoWebView(CONTEXT);
view.setId(pageToView); view.setId(pageToView);

10
src/acr/browser/barebones/IncognitoWebView.java

@ -12,11 +12,11 @@ import android.widget.ZoomButtonsController;
public final class IncognitoWebView extends WebView { public final class IncognitoWebView extends WebView {
private float location; private float location;
private boolean first = false; private boolean first = false;
private final int API = FinalVars.API; final int API = FinalVars.API;
private final boolean showFullScreen = IncognitoMode.showFullScreen; final boolean showFullScreen = IncognitoMode.showFullScreen;
private final View uBar = IncognitoMode.uBar; final View uBar = IncognitoMode.uBar;
private final Animation slideUp = IncognitoMode.slideUp; final Animation slideUp = IncognitoMode.slideUp;
private final Animation slideDown = IncognitoMode.slideDown; final Animation slideDown = IncognitoMode.slideDown;
private ZoomButtonsController zoomControl; private ZoomButtonsController zoomControl;
public IncognitoWebView(Context context) { public IncognitoWebView(Context context) {
super(context); super(context);

Loading…
Cancel
Save