Pre-release tweaks
- added ability to have the browser ignore old tabs you closed when long-pressing the back button - layout tweaks
This commit is contained in:
parent
0e2a2fb8ab
commit
8edc7aa3a1
@ -2,7 +2,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="acr.browser.barebones"
|
||||
android:versionCode="44"
|
||||
android:versionName="2.5.0.3" >
|
||||
android:versionName="2.5.0.4" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
@ -22,7 +22,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="acr.browser.barebones.activities.BarebonesActivity"
|
||||
android:name=".activities.BarebonesActivity"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/app_name"
|
||||
@ -88,7 +88,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="acr.browser.barebones.activities.IncognitoModeActivity"
|
||||
android:name=".activities.IncognitoModeActivity"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/app_name"
|
||||
@ -100,7 +100,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="acr.browser.barebones.activities.SettingsActivity"
|
||||
android:name=".activities.SettingsActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
@ -110,7 +110,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="acr.browser.barebones.activities.AdvancedSettingsActivity"
|
||||
android:name=".activities.AdvancedSettingsActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/title_activity_advanced_settings" >
|
||||
<intent-filter>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 987 B After Width: | Height: | Size: 976 B |
Binary file not shown.
Before Width: | Height: | Size: 943 B After Width: | Height: | Size: 936 B |
@ -17,7 +17,7 @@
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/tabScroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="32dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
@ -44,8 +44,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/newTab"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:src="@drawable/new_tab" />
|
||||
|
||||
</LinearLayout>
|
||||
@ -119,7 +119,6 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:indeterminate="true"
|
||||
/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<MultiAutoCompleteTextView
|
||||
@ -137,6 +136,8 @@
|
||||
android:inputType="textUri"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/dark" />
|
||||
|
||||
@ -148,6 +149,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_below="@+id/urlBar" >
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
@ -346,6 +346,30 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/r13"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:background="@drawable/blueback"
|
||||
android:paddingRight="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="@string/restore"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cb10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<RelativeLayout
|
||||
android:id="@+id/r8"
|
||||
@ -354,7 +378,7 @@
|
||||
android:background="@drawable/blueback" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView9"
|
||||
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
@ -372,7 +396,6 @@
|
||||
android:background="@drawable/blueback" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
@ -401,7 +424,6 @@
|
||||
android:background="@drawable/blueback" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView11"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
|
@ -43,5 +43,6 @@
|
||||
<string name="search_hint">Search</string>
|
||||
<string name="wideViewPort">Use wide viewport</string>
|
||||
<string name="overViewMode">Load pages in overview mode</string>
|
||||
<string name="restore">Restore lost tabs on start</string>
|
||||
|
||||
</resources>
|
@ -3,9 +3,9 @@ package acr.browser.barebones.activities;
|
||||
import java.io.File;
|
||||
|
||||
import acr.browser.barebones.R;
|
||||
import acr.browser.barebones.variables.BookmarkPageVariables;
|
||||
import acr.browser.barebones.variables.FinalVariables;
|
||||
import acr.browser.barebones.variables.Utils;
|
||||
import acr.browser.barebones.utilities.BookmarkPageVariables;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import acr.browser.barebones.utilities.Utils;
|
||||
import acr.browser.barebones.activities.BarebonesActivity;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Browser;
|
||||
@ -40,8 +40,8 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
static final String preferences = "settings";
|
||||
static SharedPreferences settings;
|
||||
static SharedPreferences.Editor edit;
|
||||
static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12;
|
||||
static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9;
|
||||
static RelativeLayout r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13;
|
||||
static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, cb9, cb10;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -66,6 +66,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
r10 = (RelativeLayout) findViewById(R.id.r10);
|
||||
r11 = (RelativeLayout) findViewById(R.id.r11);
|
||||
r12 = (RelativeLayout) findViewById(R.id.r12);
|
||||
r13 = (RelativeLayout) findViewById(R.id.r13);
|
||||
|
||||
cb1 = (CheckBox) findViewById(R.id.cb1);
|
||||
cb2 = (CheckBox) findViewById(R.id.cb2);
|
||||
@ -76,6 +77,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
cb7 = (CheckBox) findViewById(R.id.cb7);
|
||||
cb8 = (CheckBox) findViewById(R.id.cb8);
|
||||
cb9 = (CheckBox) findViewById(R.id.cb9);
|
||||
cb10 = (CheckBox) findViewById(R.id.cb10);
|
||||
|
||||
cb1.setChecked(settings.getBoolean("passwords", true));
|
||||
cb2.setChecked(settings.getBoolean("cache", false));
|
||||
@ -86,6 +88,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
cb7.setChecked(settings.getBoolean("cookies", true));
|
||||
cb8.setChecked(settings.getBoolean("wideviewport", true));
|
||||
cb9.setChecked(settings.getBoolean("overviewmode", true));
|
||||
cb10.setChecked(settings.getBoolean("restoreclosed", true));
|
||||
|
||||
r1(r1);
|
||||
r2(r2);
|
||||
@ -99,6 +102,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
r10(r10);
|
||||
r11(r11);
|
||||
r12(r12);
|
||||
r13(r13);
|
||||
cb1(cb1);
|
||||
cb2(cb2);
|
||||
cb3(cb3);
|
||||
@ -108,6 +112,7 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
cb7(cb7);
|
||||
cb8(cb8);
|
||||
cb9(cb9);
|
||||
cb10(cb10);
|
||||
back();
|
||||
|
||||
TextView importBookmarks = (TextView)findViewById(R.id.isImportAvailable);
|
||||
@ -247,6 +252,19 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void cb10(CheckBox view) {
|
||||
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView,
|
||||
boolean isChecked) {
|
||||
edit.putBoolean("restoreclosed", isChecked);
|
||||
edit.commit();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void r1(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@ -402,6 +420,18 @@ public class AdvancedSettingsActivity extends Activity {
|
||||
});
|
||||
}
|
||||
|
||||
void r13(RelativeLayout view) {
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
cb10.setChecked(!cb10.isChecked());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void clearHistory() {
|
||||
CookieManager c = CookieManager.getInstance();
|
||||
|
@ -8,6 +8,7 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -16,10 +17,10 @@ import acr.browser.barebones.R;
|
||||
import acr.browser.barebones.customwebview.CustomWebView;
|
||||
import acr.browser.barebones.databases.DatabaseHandler;
|
||||
import acr.browser.barebones.databases.SpaceTokenizer;
|
||||
import acr.browser.barebones.variables.BookmarkPageVariables;
|
||||
import acr.browser.barebones.variables.FinalVariables;
|
||||
import acr.browser.barebones.variables.HistoryPageVariables;
|
||||
import acr.browser.barebones.variables.Utils;
|
||||
import acr.browser.barebones.utilities.BookmarkPageVariables;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import acr.browser.barebones.utilities.HistoryPageVariables;
|
||||
import acr.browser.barebones.utilities.Utils;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@ -123,6 +124,13 @@ public class BarebonesActivity extends Activity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
|
||||
|
||||
super.onProgressChanged(view, newProgress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
|
||||
QuotaUpdater quotaUpdater) {
|
||||
@ -336,7 +344,7 @@ public class BarebonesActivity extends Activity {
|
||||
public void onDownloadStart(final String url, String userAgent,
|
||||
final String contentDisposition, final String mimetype,
|
||||
long contentLength) {
|
||||
if (url.endsWith(".mp4")) {
|
||||
if (url.endsWith(".mp4")||url.endsWith(".m4a")) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT);
|
||||
builder.setTitle("Open as...");
|
||||
@ -468,6 +476,7 @@ public class BarebonesActivity extends Activity {
|
||||
view.invalidate();
|
||||
progressBar.setVisibility(View.GONE);
|
||||
refresh.setVisibility(View.VISIBLE);
|
||||
|
||||
if (showFullScreen && uBar.isShown()) {
|
||||
uBar.startAnimation(slideUp);
|
||||
}
|
||||
@ -494,7 +503,6 @@ public class BarebonesActivity extends Activity {
|
||||
if (view.isShown()) {
|
||||
refresh.setVisibility(View.INVISIBLE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
|
||||
setUrlText(url);
|
||||
}
|
||||
|
||||
@ -1031,7 +1039,7 @@ public class BarebonesActivity extends Activity {
|
||||
public static Drawable active;
|
||||
|
||||
public static LinearLayout tabLayout;
|
||||
|
||||
|
||||
public static String[] GetArray(String input) {
|
||||
return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|");
|
||||
}
|
||||
@ -1055,7 +1063,6 @@ public class BarebonesActivity extends Activity {
|
||||
CustomWebView browserSettings(CustomWebView view) {
|
||||
view.setAnimationCacheEnabled(false);
|
||||
view.setDrawingCacheEnabled(true);
|
||||
|
||||
view.setBackgroundColor(getResources().getColor(android.R.color.white));
|
||||
view.setDrawingCacheBackgroundColor(getResources().getColor(
|
||||
android.R.color.white));
|
||||
@ -1079,7 +1086,7 @@ public class BarebonesActivity extends Activity {
|
||||
// or
|
||||
// disable
|
||||
}
|
||||
|
||||
|
||||
webViewSettings.setAllowFileAccess(true);
|
||||
if (API < 14) {
|
||||
switch (settings.getInt("textsize", 3)) {
|
||||
@ -1166,9 +1173,8 @@ public class BarebonesActivity extends Activity {
|
||||
.getAbsolutePath() + "/databases");
|
||||
|
||||
webViewSettings.setUserAgentString(userAgent);
|
||||
|
||||
webViewSettings.setBuiltInZoomControls(true);
|
||||
webViewSettings.setSupportZoom(true);
|
||||
webViewSettings.setBuiltInZoomControls(true);
|
||||
webViewSettings.setUseWideViewPort(settings.getBoolean("wideviewport",
|
||||
true));
|
||||
webViewSettings.setLoadWithOverviewMode(settings.getBoolean(
|
||||
@ -1596,6 +1602,7 @@ public class BarebonesActivity extends Activity {
|
||||
cookieManager.setAcceptCookie(settings.getBoolean("cookies", true));
|
||||
|
||||
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
|
||||
|
||||
if (API >= 11) {
|
||||
progressBar.setIndeterminateDrawable(getResources().getDrawable(
|
||||
R.drawable.ics_animation));
|
||||
@ -2214,6 +2221,11 @@ public class BarebonesActivity extends Activity {
|
||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if(!settings.getBoolean("restoreclosed", true)){
|
||||
for(int n = 0; n<MAX_TABS; n++){
|
||||
urlToLoad[n][0] = null;
|
||||
}
|
||||
}
|
||||
finish();
|
||||
return true;
|
||||
} else
|
||||
|
@ -16,9 +16,9 @@ import acr.browser.barebones.R;
|
||||
import acr.browser.barebones.customwebview.IncognitoWebView;
|
||||
import acr.browser.barebones.databases.DatabaseHandler;
|
||||
import acr.browser.barebones.databases.SpaceTokenizer;
|
||||
import acr.browser.barebones.variables.BookmarkPageVariables;
|
||||
import acr.browser.barebones.variables.FinalVariables;
|
||||
import acr.browser.barebones.variables.HistoryPageVariables;
|
||||
import acr.browser.barebones.utilities.BookmarkPageVariables;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import acr.browser.barebones.utilities.HistoryPageVariables;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
|
@ -4,8 +4,8 @@ import acr.browser.barebones.R;
|
||||
import acr.browser.barebones.R.drawable;
|
||||
import acr.browser.barebones.R.id;
|
||||
import acr.browser.barebones.R.layout;
|
||||
import acr.browser.barebones.variables.FinalVariables;
|
||||
import acr.browser.barebones.variables.Utils;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import acr.browser.barebones.utilities.Utils;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@ -382,7 +382,7 @@ public class SettingsActivity extends Activity {
|
||||
Utils.createInformativeDialog(
|
||||
SettingsActivity.this,
|
||||
"Warning",
|
||||
"Adobe Flash does not support Android 4.3 and will"
|
||||
"Adobe Flash does not support Android 4.3 and will "
|
||||
+ "crash the browser, please do not report crashes that occur if you enable flash.");
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package acr.browser.barebones.customwebview;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import acr.browser.barebones.activities.BarebonesActivity;
|
||||
import acr.browser.barebones.variables.FinalVariables;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
@ -26,18 +26,18 @@ public final class CustomWebView extends WebView {
|
||||
super(context);
|
||||
this.setBackgroundResource(0);
|
||||
|
||||
getControls();
|
||||
//getControls();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
if (zoomShouldDie) {
|
||||
/*if (zoomShouldDie) {
|
||||
try {
|
||||
zoomControl.getZoomControls().setVisibility(View.INVISIBLE);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
}*/
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN: {
|
||||
first = true;
|
||||
@ -73,13 +73,14 @@ public final class CustomWebView extends WebView {
|
||||
}
|
||||
super.onWindowVisibilityChanged(visibility);
|
||||
}
|
||||
|
||||
/*
|
||||
private void getControls() {
|
||||
if (API < 11) {
|
||||
try {
|
||||
Class<?> webview = Class.forName("android.webkit.WebView");
|
||||
Method method = webview.getMethod("getZoomButtonsController");
|
||||
zoomControl = (ZoomButtonsController) method.invoke(this, (Object) null);
|
||||
|
||||
zoomControl = (ZoomButtonsController) method.invoke(this, (Object[])null);
|
||||
if (zoomControl != null) {
|
||||
zoomShouldDie = true;
|
||||
}
|
||||
@ -88,5 +89,5 @@ public final class CustomWebView extends WebView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package acr.browser.barebones.customwebview;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import acr.browser.barebones.activities.IncognitoModeActivity;
|
||||
import acr.browser.barebones.variables.FinalVariables;
|
||||
import acr.browser.barebones.utilities.FinalVariables;
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -0,0 +1,24 @@
|
||||
package acr.browser.barebones.utilities;
|
||||
|
||||
public class BookmarkPageVariables {
|
||||
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
|
||||
+ "<head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />"
|
||||
+ "<title>Bookmarks</title></head><style>"
|
||||
+ "div.shadow{-moz-box-shadow: 0px 0px 6px #111;-webkit-box-shadow: 0px 0px 6px #111;box-shadow: 0px 0px 6px #111;}"
|
||||
+ "body{color: gray;text-size: 10px}"
|
||||
+ "div {vertical-align: middle;background-color: #ffffff;}"
|
||||
+ "div.clickable {position:relative;}"
|
||||
+ "p.font{font-size: 1em;font-family: \"Lucida Console\"}"
|
||||
+ "div.clickable a {position:absolute;width:100%;height:100%;top:0;left:0;text-decoration:none; z-index:10; background-color:white;opacity: 0; filter: alpha(opacity=1);}"
|
||||
+ "div.space {height: 0.7em;}"
|
||||
+ "p{padding-top: 0.5em;padding-bottom: 0.5em;padding-right: 0.5em;padding-left: 0.5em;}"
|
||||
+ "img{padding-left: 0em;padding-right: 0.5em;}"
|
||||
+ "</style><body bgcolor = #f2f2f2>";
|
||||
public static final String Part1 = "<div class=\"clickable\">"
|
||||
+ "<div class=\"shadow\">" + "<p class=\"font\">" + "<a href=\"";
|
||||
public static final String Part2 = "\"></a>"+
|
||||
"<img height=\"15px\" width=\"15px\" src='https://www.google.com/s2/favicons?domain=";
|
||||
public static final String Part3 = "'/>";
|
||||
public static final String Part4 = "</p></div></div>";
|
||||
public static final String End = "</body></html>";
|
||||
}
|
26
src/acr/browser/barebones/utilities/FinalVariables.java
Normal file
26
src/acr/browser/barebones/utilities/FinalVariables.java
Normal file
@ -0,0 +1,26 @@
|
||||
package acr.browser.barebones.utilities;
|
||||
|
||||
import android.os.Environment;
|
||||
|
||||
|
||||
public class FinalVariables {
|
||||
|
||||
public static final int MAX_TABS = 5;
|
||||
public static final int MAX_BOOKMARKS = 50;
|
||||
public static final boolean PAID_VERSION = false;
|
||||
public static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/20 Safari/537.17";
|
||||
public static final String MOBILE_USER_AGENT = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7";
|
||||
public static final int API = android.os.Build.VERSION.SDK_INT;
|
||||
public static final String YAHOO_SEARCH = "http://search.yahoo.com/search?p=";
|
||||
public static final String GOOGLE_SEARCH = "https://www.google.com/search?client=lightning&q=";
|
||||
public static final String BING_SEARCH = "http://www.bing.com/search?q=";
|
||||
public static final String DUCK_SEARCH = "https://duckduckgo.com/?t=lightning&q=";
|
||||
public static final String STARTPAGE_SEARCH = "https://startpage.com/do/metasearch.pl?language=english&cat=web&query=";
|
||||
public static final String HOMEPAGE = "https://www.google.com/";
|
||||
public static final String SETTINGS_INTENT = "android.intent.action.SETTINGS";
|
||||
public static final String INCOGNITO_INTENT = "android.intent.action.BAREBONESINCOGNITO";
|
||||
public static final String DOWNLOAD_LOCATION = Environment.getExternalStorageDirectory().toString()+Environment.DIRECTORY_DOWNLOADS;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package acr.browser.barebones.utilities;
|
||||
|
||||
public class HistoryPageVariables {
|
||||
public static final String Heading = "<!DOCTYPE html><html xmlns=\"http://www.w3.org/1999/xhtml\">"
|
||||
+ "<head><meta content=\"en-us\" http-equiv=\"Content-Language\" /><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" /><title>History</title></head><style>"
|
||||
+ "div.shadow {-moz-box-shadow: 0px 0px 6px #111;-webkit-box-shadow: 0px 0px 6px #111;box-shadow: 0px 0px 6px #111;}"
|
||||
+ "body{color: gray;text-size: 10px}div.space {height: 0.7em;} div.extra{text-align: center;}div {vertical-align: middle;}"
|
||||
+ "div {background-color: #ffffff;}div.clickable {position:relative;}p.black{color: black;font-size: 1em;font-family: \"Lucida Console\"}"
|
||||
+ "p.font{font-size: 1em;font-family: \"Lucida Console\"}p.black{padding-left: 0.5em;padding-right: 0.5em;padding-top: 0.5em;padding-bottom: 0em;}"
|
||||
+ "p.font{padding-left: 0.5em;padding-right: 0.5em;padding-top: 0em;padding-bottom: 0.5em;}"
|
||||
+ "div.clickable a {position:absolute; width:100%;height:100%;top:0;left:0;text-decoration:none; z-index:10; background-color:white;opacity: 0;filter: alpha(opacity=1);}"
|
||||
+ "</style><body bgcolor = #f2f2f2>";
|
||||
|
||||
public static final String Part1 = "<div class=\"clickable\"><div class=\"shadow\"><a href=\"";
|
||||
public static final String Part2 = "\"></a><p class=\"black\">";
|
||||
public static final String Part3 = "</p><p class=\"font\">";
|
||||
public static final String Part4 = "</p></div></div>";
|
||||
public static final String End = "</body></html>";
|
||||
}
|
180
src/acr/browser/barebones/utilities/Utils.java
Normal file
180
src/acr/browser/barebones/utilities/Utils.java
Normal file
@ -0,0 +1,180 @@
|
||||
package acr.browser.barebones.utilities;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import acr.browser.barebones.databases.DatabaseHandler;
|
||||
import acr.browser.barebones.databases.HistoryItem;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.Browser;
|
||||
import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static DatabaseHandler historyHandler;
|
||||
public static SQLiteDatabase history;
|
||||
|
||||
public static void createInformativeDialog(Context context, String title,
|
||||
String message) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(title);
|
||||
builder.setMessage(message)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton("Ok",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.show();
|
||||
}
|
||||
|
||||
public static void addBookmark(Context context, String title, String url) {
|
||||
File book = new File(context.getFilesDir(), "bookmarks");
|
||||
File bookUrl = new File(context.getFilesDir(), "bookurl");
|
||||
try {
|
||||
BufferedReader readUrlRead = new BufferedReader(new FileReader(
|
||||
bookUrl));
|
||||
String u;
|
||||
int n = 0;
|
||||
while ((u = readUrlRead.readLine()) != null
|
||||
&& n < FinalVariables.MAX_BOOKMARKS) {
|
||||
if (u.contentEquals(url)) {
|
||||
readUrlRead.close();
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
readUrlRead.close();
|
||||
|
||||
} catch (FileNotFoundException ignored) {
|
||||
} catch (IOException ignored) {
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
try {
|
||||
BufferedWriter bookWriter = new BufferedWriter(new FileWriter(book,
|
||||
true));
|
||||
BufferedWriter urlWriter = new BufferedWriter(new FileWriter(
|
||||
bookUrl, true));
|
||||
bookWriter.write(title);
|
||||
urlWriter.write(url);
|
||||
bookWriter.newLine();
|
||||
urlWriter.newLine();
|
||||
bookWriter.close();
|
||||
urlWriter.close();
|
||||
} catch (FileNotFoundException ignored) {
|
||||
} catch (IOException ignored) {
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateHistory(final Context context,
|
||||
final ContentResolver content, final boolean noStockBrowser,
|
||||
final String url, final String title) {
|
||||
Runnable update = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!noStockBrowser) {
|
||||
try {
|
||||
Browser.updateVisitedHistory(content, url, true);
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder("url" + " = ");
|
||||
DatabaseUtils.appendEscapedSQLString(sb, url);
|
||||
historyHandler = new DatabaseHandler(
|
||||
context);
|
||||
history = historyHandler.getReadableDatabase();
|
||||
Cursor cursor = history.query("history", new String[] { "id",
|
||||
"url", "title" }, sb.toString(), null, null, null,
|
||||
null);
|
||||
if (!cursor.moveToFirst()) {
|
||||
historyHandler.addHistoryItem(new HistoryItem(url,
|
||||
title));
|
||||
} else {
|
||||
historyHandler.delete(url);
|
||||
historyHandler.addHistoryItem(new HistoryItem(url,
|
||||
title));
|
||||
}
|
||||
historyHandler.close();
|
||||
cursor.close();
|
||||
history.close();
|
||||
} catch (IllegalStateException e) {
|
||||
Log.e("Barebones", "IllegalStateException in updateHistory");
|
||||
} catch (NullPointerException e) {
|
||||
Log.e("Barebones", "NullPointerException in updateHistory");
|
||||
} catch (SQLiteException e) {
|
||||
Log.e("Barebones", "SQLiteException in updateHistory");
|
||||
}
|
||||
}
|
||||
};
|
||||
if (url != null) {
|
||||
if (!url.startsWith("file://")) {
|
||||
new Thread(update).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
|
||||
public static void downloadFile(final Context context, final String url, final String contentDisposition, final String mimetype){
|
||||
try {
|
||||
Thread downloader = new Thread(new Runnable() {
|
||||
@SuppressLint("InlinedApi")
|
||||
@Override
|
||||
public void run() {
|
||||
DownloadManager download = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
Uri nice = Uri.parse(url);
|
||||
DownloadManager.Request it = new DownloadManager.Request(
|
||||
nice);
|
||||
String fileName = URLUtil.guessFileName(url,
|
||||
contentDisposition, mimetype);
|
||||
if (FinalVariables.API >= 11) {
|
||||
it.allowScanningByMediaScanner();
|
||||
it.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
}
|
||||
|
||||
it.setDestinationInExternalPublicDir(
|
||||
Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
Log.i("Barebones", "Downloading" + fileName);
|
||||
download.enqueue(it);
|
||||
}
|
||||
});
|
||||
downloader.run();
|
||||
} catch (NullPointerException e) {
|
||||
Log.e("Barebones", "Problem downloading");
|
||||
Toast.makeText(context, "Error Downloading File",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e("Barebones", "Problem downloading");
|
||||
Toast.makeText(context, "Error Downloading File",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} catch (SecurityException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user