Browse Source

2.5.0.2 tweaks

- added option to enable/disable cookies
- added option to enable/disable wide viewport
- added option to enable/disable loading a page in overview mode
- added detection for Adobe Flash and warning if you try to enable flash
and it isn't installed
- added ability to choose between downloading mp4 videos and streaming
them in the android video player
master
Anthony Restaino 11 years ago
parent
commit
11eb2170cc
  1. 4
      AndroidManifest.xml
  2. BIN
      Barebones.apk
  3. 93
      res/layout/advanced_settings.xml
  4. 2
      res/layout/settings.xml
  5. 6
      res/values/strings.xml
  6. 84
      src/acr/browser/barebones/activities/AdvancedSettingsActivity.java
  7. 82
      src/acr/browser/barebones/activities/BarebonesActivity.java
  8. 41
      src/acr/browser/barebones/activities/SettingsActivity.java

4
AndroidManifest.xml

@ -49,10 +49,6 @@ @@ -49,10 +49,6 @@
<!--
For these schemes where any of these particular MIME types
have been supplied, we are a good candidate.
-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />

BIN
Barebones.apk

Binary file not shown.

93
res/layout/advanced_settings.xml

@ -231,7 +231,7 @@ @@ -231,7 +231,7 @@
android:layout_alignParentRight="true"/>
<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
@ -256,10 +256,19 @@ @@ -256,10 +256,19 @@
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="@string/always_incognito"
android:text="@string/cookies"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/recommended"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light" />
<CheckBox
android:id="@+id/cb7"
android:layout_width="wrap_content"
@ -268,7 +277,76 @@ @@ -268,7 +277,76 @@
android:layout_centerVertical="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/r11"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@drawable/blueback"
android:paddingRight="10dp">
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingLeft="10dp"
android:text="@string/wideViewPort"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/recommended"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light" />
<CheckBox
android:id="@+id/cb8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/r12"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@drawable/blueback"
android:paddingRight="10dp">
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingLeft="10dp"
android:text="@string/overViewMode"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/recommended"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light" />
<CheckBox
android:id="@+id/cb9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/r8"
android:layout_width="match_parent"
@ -303,6 +381,17 @@ @@ -303,6 +381,17 @@
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/isImportAvailable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:paddingLeft="10dp"
android:text="text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/light" />
</RelativeLayout>
<RelativeLayout

2
res/layout/settings.xml

@ -272,7 +272,7 @@ @@ -272,7 +272,7 @@
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView14"
android:id="@+id/isImportAvailable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"

6
res/values/strings.xml

@ -32,8 +32,8 @@ @@ -32,8 +32,8 @@
<string name="reflow">Enable text reflow</string>
<string name="block">Block Images</string>
<string name="window">Allow sites to open new windows</string>
<string name="always_incognito">Incognito always on</string>
<string name="importbookmarks">Import bookmarks from Stock Browser (if available)</string>
<string name="cookies">Enable Cookies</string>
<string name="importbookmarks">Import bookmarks from Stock Browser</string>
<string name="size">Text size</string>
<string name="title_activity_advanced_settings">AdvancedSettings</string>
<string name="hello_world">Hello world!</string>
@ -41,5 +41,7 @@ @@ -41,5 +41,7 @@
<string name="weird_look">(Websites may look weird)</string>
<string name="search">Search Engine</string>
<string name="search_hint">Search</string>
<string name="wideViewPort">Use wide viewport</string>
<string name="overViewMode">Load pages in overview mode</string>
</resources>

84
src/acr/browser/barebones/activities/AdvancedSettingsActivity.java

@ -15,6 +15,7 @@ import android.content.Context; @@ -15,6 +15,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
@ -27,6 +28,7 @@ import android.widget.CompoundButton; @@ -27,6 +28,7 @@ import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class AdvancedSettingsActivity extends Activity {
@ -38,8 +40,8 @@ public class AdvancedSettingsActivity extends Activity { @@ -38,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;
static CheckBox cb1, cb2, cb3, cb4, cb5, cb6, cb7;
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;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -62,6 +64,8 @@ public class AdvancedSettingsActivity extends Activity { @@ -62,6 +64,8 @@ public class AdvancedSettingsActivity extends Activity {
r8 = (RelativeLayout) findViewById(R.id.r8);
r9 = (RelativeLayout) findViewById(R.id.r9);
r10 = (RelativeLayout) findViewById(R.id.r10);
r11 = (RelativeLayout) findViewById(R.id.r11);
r12 = (RelativeLayout) findViewById(R.id.r12);
cb1 = (CheckBox) findViewById(R.id.cb1);
cb2 = (CheckBox) findViewById(R.id.cb2);
@ -70,6 +74,8 @@ public class AdvancedSettingsActivity extends Activity { @@ -70,6 +74,8 @@ public class AdvancedSettingsActivity extends Activity {
cb5 = (CheckBox) findViewById(R.id.cb5);
cb6 = (CheckBox) findViewById(R.id.cb6);
cb7 = (CheckBox) findViewById(R.id.cb7);
cb8 = (CheckBox) findViewById(R.id.cb8);
cb9 = (CheckBox) findViewById(R.id.cb9);
cb1.setChecked(settings.getBoolean("passwords", true));
cb2.setChecked(settings.getBoolean("cache", false));
@ -77,7 +83,9 @@ public class AdvancedSettingsActivity extends Activity { @@ -77,7 +83,9 @@ public class AdvancedSettingsActivity extends Activity {
cb4.setChecked(settings.getBoolean("textreflow", false));
cb5.setChecked(settings.getBoolean("blockimages", false));
cb6.setChecked(settings.getBoolean("newwindows", true));
cb7.setChecked(settings.getBoolean("alwaysincognito", false));
cb7.setChecked(settings.getBoolean("cookies", true));
cb8.setChecked(settings.getBoolean("wideviewport", true));
cb9.setChecked(settings.getBoolean("overviewmode", true));
r1(r1);
r2(r2);
@ -89,6 +97,8 @@ public class AdvancedSettingsActivity extends Activity { @@ -89,6 +97,8 @@ public class AdvancedSettingsActivity extends Activity {
r8(r8);
r9(r9);
r10(r10);
r11(r11);
r12(r12);
cb1(cb1);
cb2(cb2);
cb3(cb3);
@ -96,7 +106,18 @@ public class AdvancedSettingsActivity extends Activity { @@ -96,7 +106,18 @@ public class AdvancedSettingsActivity extends Activity {
cb5(cb5);
cb6(cb6);
cb7(cb7);
cb8(cb8);
cb9(cb9);
back();
TextView importBookmarks = (TextView)findViewById(R.id.isImportAvailable);
if(BarebonesActivity.noStockBrowser){
importBookmarks.setText("(No Browser Available)");
}
else{
importBookmarks.setText("(Supported Browser Detected)");
}
}
void back() {
@ -195,7 +216,32 @@ public class AdvancedSettingsActivity extends Activity { @@ -195,7 +216,32 @@ public class AdvancedSettingsActivity extends Activity {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
edit.putBoolean("alwaysincognito", isChecked);
edit.putBoolean("cookies", isChecked);
edit.commit();
}
});
}
void cb8(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
edit.putBoolean("wideviewport", isChecked);
edit.commit();
}
});
}
void cb9(CheckBox view) {
view.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
edit.putBoolean("overviewmode", isChecked);
edit.commit();
}
@ -331,6 +377,31 @@ public class AdvancedSettingsActivity extends Activity { @@ -331,6 +377,31 @@ public class AdvancedSettingsActivity extends Activity {
});
}
void r11(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
cb8.setChecked(!cb8.isChecked());
}
});
}
void r12(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
cb9.setChecked(!cb9.isChecked());
}
});
}
@SuppressWarnings("deprecation")
public void clearHistory() {
CookieManager c = CookieManager.getInstance();
@ -356,11 +427,14 @@ public class AdvancedSettingsActivity extends Activity { @@ -356,11 +427,14 @@ public class AdvancedSettingsActivity extends Activity {
}
void r9(RelativeLayout view) {
view.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
importFromStockBrowser();
}
});
@ -373,7 +447,7 @@ public class AdvancedSettingsActivity extends Activity { @@ -373,7 +447,7 @@ public class AdvancedSettingsActivity extends Activity {
public void onClick(View v) {
AlertDialog.Builder picker = new AlertDialog.Builder(
AdvancedSettingsActivity.this);
picker.setTitle("Search Engine");
picker.setTitle("Text Size");
CharSequence[] chars = { "Largest", "Large", "Normal", "Small", "Smallest"};
int n = settings.getInt("textsize", 3);

82
src/acr/browser/barebones/activities/BarebonesActivity.java

@ -244,7 +244,8 @@ public class BarebonesActivity extends Activity { @@ -244,7 +244,8 @@ public class BarebonesActivity extends Activity {
if (title != null && title.length() != 0) {
urlTitle[numberPage].setText(title);
urlToLoad[numberPage][1] = title;
Utils.updateHistory(CONTEXT, getContentResolver(), noStockBrowser, urlToLoad[numberPage][0], title);
Utils.updateHistory(CONTEXT, getContentResolver(),
noStockBrowser, urlToLoad[numberPage][0], title);
}
super.onReceivedTitle(view, title);
}
@ -335,7 +336,36 @@ public class BarebonesActivity extends Activity { @@ -335,7 +336,36 @@ public class BarebonesActivity extends Activity {
public void onDownloadStart(final String url, String userAgent,
final String contentDisposition, final String mimetype,
long contentLength) {
Utils.downloadFile(CONTEXT, url, contentDisposition, mimetype);
if (url.endsWith(".mp4")) {
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT);
builder.setTitle("Open as...");
builder.setMessage("Do you want to download this video or watch it in an app?")
.setCancelable(true)
.setPositiveButton("Download",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
Utils.downloadFile(CONTEXT, url, contentDisposition, mimetype);
}
}).setNegativeButton("Watch",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url),"video/mp4");
intent.putExtra("acr.browser.barebones.Download", 1);
startActivity(intent);
}
});
AlertDialog alert = builder.create();
alert.show();
} else {
Utils.downloadFile(CONTEXT, url, contentDisposition, mimetype);
}
}
}
@ -1014,8 +1044,6 @@ public class BarebonesActivity extends Activity { @@ -1014,8 +1044,6 @@ public class BarebonesActivity extends Activity {
}
@SuppressLint("SetJavaScriptEnabled")
CustomWebView browserSettings(CustomWebView view) {
view.setAnimationCacheEnabled(false);
@ -1046,8 +1074,8 @@ public class BarebonesActivity extends Activity { @@ -1046,8 +1074,8 @@ public class BarebonesActivity extends Activity {
}
webViewSettings.setAllowFileAccess(true);
if(API<14){
switch(settings.getInt("textsize", 3)){
if (API < 14) {
switch (settings.getInt("textsize", 3)) {
case 1:
webViewSettings.setTextSize(WebSettings.TextSize.LARGEST);
break;
@ -1065,9 +1093,8 @@ public class BarebonesActivity extends Activity { @@ -1065,9 +1093,8 @@ public class BarebonesActivity extends Activity {
break;
}
}
else{
switch(settings.getInt("textsize", 3)){
} else {
switch (settings.getInt("textsize", 3)) {
case 1:
webViewSettings.setTextZoom(200);
break;
@ -1107,7 +1134,6 @@ public class BarebonesActivity extends Activity { @@ -1107,7 +1134,6 @@ public class BarebonesActivity extends Activity {
break;
}
if (API < 18) {
if (settings.getBoolean("passwords", false)) {
webViewSettings.setSavePassword(true);
@ -1136,8 +1162,10 @@ public class BarebonesActivity extends Activity { @@ -1136,8 +1162,10 @@ public class BarebonesActivity extends Activity {
webViewSettings.setBuiltInZoomControls(true);
webViewSettings.setSupportZoom(true);
webViewSettings.setUseWideViewPort(true);
webViewSettings.setLoadWithOverviewMode(true);
webViewSettings.setUseWideViewPort(settings.getBoolean("wideviewport",
true));
webViewSettings.setLoadWithOverviewMode(settings.getBoolean(
"overviewmode", true));
if (API >= 11) {
webViewSettings.setDisplayZoomControls(false);
webViewSettings.setAllowContentAccess(true);
@ -1148,7 +1176,8 @@ public class BarebonesActivity extends Activity { @@ -1148,7 +1176,8 @@ public class BarebonesActivity extends Activity {
webViewSettings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
}
webViewSettings.setBlockNetworkImage(settings.getBoolean("blockimages", false));
webViewSettings.setBlockNetworkImage(settings.getBoolean("blockimages",
false));
webViewSettings.setLoadsImagesAutomatically(true);
return view;
}
@ -1570,7 +1599,7 @@ public class BarebonesActivity extends Activity { @@ -1570,7 +1599,7 @@ public class BarebonesActivity extends Activity {
historyHandler = new DatabaseHandler(this);
cookieManager = CookieManager.getInstance();
CookieSyncManager.createInstance(CONTEXT);
cookieManager.setAcceptCookie(true);
cookieManager.setAcceptCookie(settings.getBoolean("cookies", true));
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
if (API >= 11) {
@ -1587,9 +1616,11 @@ public class BarebonesActivity extends Activity { @@ -1587,9 +1616,11 @@ public class BarebonesActivity extends Activity {
slideUp = AnimationUtils.loadAnimation(this, R.anim.slide_up);
slideDown = AnimationUtils.loadAnimation(this, R.anim.slide_down);
fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
fadeOut.setDuration(250);
fadeIn = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
mShortAnimationDuration = getResources().getInteger(
android.R.integer.config_mediumAnimTime);
// mShortAnimationDuration = getResources().getInteger(
// android.R.integer.config_mediumAnimTime);
mShortAnimationDuration = 250;
slideUp.setAnimationListener(new AnimationListener() {
@Override
@ -2179,14 +2210,22 @@ public class BarebonesActivity extends Activity { @@ -2179,14 +2210,22 @@ public class BarebonesActivity extends Activity {
String url = intent.getDataString();
int id = -1;
int download = -1;
try {
id = intent.getExtras().getInt("acr.browser.barebones.Origin") - 1;
} catch (NullPointerException e) {
id = -1;
}
try {
download = intent.getExtras().getInt("acr.browser.barebones.Download");
} catch (NullPointerException e) {
download = -1;
}
if (id >= 0) {
main[id].loadUrl(url);
} else if (url != null) {
} else if (download == 1){
Utils.downloadFile(CONTEXT, url, null, null);
} else if(url != null) {
newTab(number, url, true, false);
}
@ -2203,7 +2242,8 @@ public class BarebonesActivity extends Activity { @@ -2203,7 +2242,8 @@ public class BarebonesActivity extends Activity {
case R.id.bookmark:
if (urlToLoad[pageId][1] != null) {
if (!urlToLoad[pageId][1].equals("Bookmarks")) {
Utils.addBookmark(CONTEXT, urlToLoad[pageId][1],urlToLoad[pageId][0]);
Utils.addBookmark(CONTEXT, urlToLoad[pageId][1],
urlToLoad[pageId][0]);
}
}
return true;
@ -2274,8 +2314,6 @@ public class BarebonesActivity extends Activity { @@ -2274,8 +2314,6 @@ public class BarebonesActivity extends Activity {
void openBookmarks(CustomWebView view) {
String bookmarkHtml = BookmarkPageVariables.Heading;
for (int n = 0; n < MAX_BOOKMARKS; n++) {
if (bUrl[n] != null) {
bookmarkHtml += (BookmarkPageVariables.Part1 + bUrl[n]
@ -2328,7 +2366,9 @@ public class BarebonesActivity extends Activity { @@ -2328,7 +2366,9 @@ public class BarebonesActivity extends Activity {
if (urlToLoad[pageId][1] != null) {
if (!urlToLoad[pageId][1]
.equals("Bookmarks")) {
Utils.addBookmark(CONTEXT, urlToLoad[pageId][1],urlToLoad[pageId][0]);
Utils.addBookmark(CONTEXT,
urlToLoad[pageId][1],
urlToLoad[pageId][0]);
}
}
return true;

41
src/acr/browser/barebones/activities/SettingsActivity.java

@ -5,6 +5,7 @@ import acr.browser.barebones.R.drawable; @@ -5,6 +5,7 @@ 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 android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
@ -14,11 +15,15 @@ import android.app.AlertDialog; @@ -14,11 +15,15 @@ import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
@ -27,6 +32,7 @@ import android.widget.ImageView; @@ -27,6 +32,7 @@ import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
@ -321,7 +327,7 @@ public class SettingsActivity extends Activity { @@ -321,7 +327,7 @@ public class SettingsActivity extends Activity {
Toast.LENGTH_SHORT).show();
}
if (egg == 15) {
Toast.makeText(SettingsActivity.this, "Easter Egg",
Toast.makeText(SettingsActivity.this, "Easter Egg goes here",
Toast.LENGTH_SHORT).show();
egg = 0;
}
@ -354,7 +360,22 @@ public class SettingsActivity extends Activity { @@ -354,7 +360,22 @@ public class SettingsActivity extends Activity {
}
edit.putInt("enableflash", n);
edit.commit();
boolean flashInstalled = false;
try {
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
if (ai != null)
flashInstalled = true;
} catch (NameNotFoundException e) {
flashInstalled = false;
}
if(!flashInstalled){
Utils.createInformativeDialog(SettingsActivity.this, "Warning", "Adobe Flash Player was not detected.\n" +
"Please install Flash Player.");
buttonView.setChecked(false);
edit.putInt("enableflash", 0);
edit.commit();
}
}
});
@ -394,6 +415,22 @@ public class SettingsActivity extends Activity { @@ -394,6 +415,22 @@ public class SettingsActivity extends Activity {
}
edit.putInt("enableflash", n);
edit.commit();
boolean flashInstalled = false;
try {
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
if (ai != null)
flashInstalled = true;
} catch (NameNotFoundException e) {
flashInstalled = false;
}
if(!flashInstalled){
Utils.createInformativeDialog(SettingsActivity.this, "Warning", "Adobe Flash Player was not detected.\n" +
"Please install Flash Player.");
buttonView.setChecked(false);
edit.putInt("enableflash", 0);
edit.commit();
}
}

Loading…
Cancel
Save