- Added option to open last closed tab (long press on new tab button)
- Added some clarification about flash not working on Android 4.3
This commit is contained in:
Anthony Restaino 2013-07-31 22:01:53 -04:00
parent e0178d7f6e
commit 0e2a2fb8ab
4 changed files with 122 additions and 99 deletions

View File

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="acr.browser.barebones" package="acr.browser.barebones"
android:versionCode="44" android:versionCode="44"
android:versionName="2.5.0.2" > android:versionName="2.5.0.3" >
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"

Binary file not shown.

View File

@ -338,31 +338,38 @@ public class BarebonesActivity extends Activity {
long contentLength) { long contentLength) {
if (url.endsWith(".mp4")) { if (url.endsWith(".mp4")) {
AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT); AlertDialog.Builder builder = new AlertDialog.Builder(CONTEXT);
builder.setTitle("Open as..."); builder.setTitle("Open as...");
builder.setMessage("Do you want to download this video or watch it in an app?") builder.setMessage(
"Do you want to download this video or watch it in an app?")
.setCancelable(true) .setCancelable(true)
.setPositiveButton("Download", .setPositiveButton("Download",
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog,
Utils.downloadFile(CONTEXT, url, contentDisposition, mimetype); int id) {
Utils.downloadFile(CONTEXT, url,
contentDisposition, mimetype);
} }
}).setNegativeButton("Watch", })
.setNegativeButton("Watch",
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog,
Intent intent = new Intent(Intent.ACTION_VIEW); int id) {
intent.setDataAndType(Uri.parse(url),"video/mp4"); Intent intent = new Intent(
intent.putExtra("acr.browser.barebones.Download", 1); Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url),
"video/mp4");
intent.putExtra(
"acr.browser.barebones.Download",
1);
startActivity(intent); startActivity(intent);
} }
}); });
AlertDialog alert = builder.create(); AlertDialog alert = builder.create();
alert.show(); alert.show();
} else { } else {
Utils.downloadFile(CONTEXT, url, contentDisposition, mimetype); Utils.downloadFile(CONTEXT, url, contentDisposition, mimetype);
} }
@ -1182,27 +1189,14 @@ public class BarebonesActivity extends Activity {
return view; return view;
} }
boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (String aChildren : children) {
boolean success = deleteDir(new File(dir, aChildren));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
void deleteTab(final int del) { void deleteTab(final int del) {
if (API >= 11) { if (API >= 11) {
main[del].onPause(); main[del].onPause();
} }
main[del].stopLoading(); main[del].stopLoading();
main[del].clearHistory(); main[del].clearHistory();
edit.putString("oldPage", urlToLoad[del][0]);
edit.commit();
urlToLoad[del][0] = null; urlToLoad[del][0] = null;
urlToLoad[del][1] = null; urlToLoad[del][1] = null;
if (API < 16) { if (API < 16) {
@ -1792,6 +1786,27 @@ public class BarebonesActivity extends Activity {
} }
}); });
newTab.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (settings.getString("oldPage", "").length() > 0) {
newTab(number, settings.getString("oldPage", ""), true,
false);
edit.putString("oldPage", "");
edit.commit();
tabScroll.postDelayed(new Runnable() {
@Override
public void run() {
tabScroll.smoothScrollTo(
urlTitle[pageId].getLeft(), 0);
}
}, 100L);
}
return true;
}
});
refresh = (ImageView) findViewById(R.id.refresh); refresh = (ImageView) findViewById(R.id.refresh);
refreshLayout.setOnClickListener(new OnClickListener() { refreshLayout.setOnClickListener(new OnClickListener() {
@ -2217,7 +2232,8 @@ public class BarebonesActivity extends Activity {
id = -1; id = -1;
} }
try { try {
download = intent.getExtras().getInt("acr.browser.barebones.Download"); download = intent.getExtras().getInt(
"acr.browser.barebones.Download");
} catch (NullPointerException e) { } catch (NullPointerException e) {
download = -1; download = -1;
} }
@ -2468,16 +2484,4 @@ public class BarebonesActivity extends Activity {
main[pageId].loadUrl(query); main[pageId].loadUrl(query);
} }
} }
void trimCache(Context context) {
try {
File dir = context.getCacheDir();
if (dir != null && dir.isDirectory()) {
deleteDir(dir);
}
} catch (Exception ignored) {
}
}
} }

View File

@ -147,7 +147,6 @@ public class SettingsActivity extends Activity {
Switch fullScreen = new Switch(this); Switch fullScreen = new Switch(this);
Switch flash = new Switch(this); Switch flash = new Switch(this);
r1.addView(location); r1.addView(location);
r2.addView(fullScreen); r2.addView(fullScreen);
r3.addView(flash); r3.addView(flash);
@ -160,8 +159,8 @@ public class SettingsActivity extends Activity {
} }
initSwitch(location, fullScreen, flash); initSwitch(location, fullScreen, flash);
clickListenerForSwitches( clickListenerForSwitches(layoutLocation, layoutFullScreen,
layoutLocation, layoutFullScreen, layoutFlash, location, fullScreen, flash); layoutFlash, location, fullScreen, flash);
} else { } else {
CheckBox location = new CheckBox(this); CheckBox location = new CheckBox(this);
@ -180,8 +179,8 @@ public class SettingsActivity extends Activity {
flash.setChecked(false); flash.setChecked(false);
} }
initCheckBox(location, fullScreen, flash); initCheckBox(location, fullScreen, flash);
clickListenerForCheckBoxes( clickListenerForCheckBoxes(layoutLocation, layoutFullScreen,
layoutLocation, layoutFullScreen, layoutFlash, location, fullScreen, flash); layoutFlash, location, fullScreen, flash);
} }
RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent); RelativeLayout agent = (RelativeLayout) findViewById(R.id.layoutUserAgent);
@ -211,7 +210,8 @@ public class SettingsActivity extends Activity {
AlertDialog.Builder picker = new AlertDialog.Builder( AlertDialog.Builder picker = new AlertDialog.Builder(
SettingsActivity.this); SettingsActivity.this);
picker.setTitle("Search Engine"); picker.setTitle("Search Engine");
CharSequence[] chars = { "Google (Suggested)", "Bing", "Yahoo", "StartPage", "DuckDuckGo (Privacy)" }; CharSequence[] chars = { "Google (Suggested)", "Bing", "Yahoo",
"StartPage", "DuckDuckGo (Privacy)" };
int n = settings.getInt("search", 1); int n = settings.getInt("search", 1);
@ -257,8 +257,8 @@ public class SettingsActivity extends Activity {
}); });
} }
public void clickListenerForCheckBoxes( public void clickListenerForCheckBoxes(RelativeLayout one,
RelativeLayout one, RelativeLayout two, RelativeLayout three, final CheckBox loc, RelativeLayout two, RelativeLayout three, final CheckBox loc,
final CheckBox full, final CheckBox flash) { final CheckBox full, final CheckBox flash) {
one.setOnClickListener(new OnClickListener() { one.setOnClickListener(new OnClickListener() {
@ -286,8 +286,8 @@ public class SettingsActivity extends Activity {
}); });
} }
public void clickListenerForSwitches( public void clickListenerForSwitches(RelativeLayout one,
RelativeLayout one, RelativeLayout two, RelativeLayout three, final Switch loc, RelativeLayout two, RelativeLayout three, final Switch loc,
final Switch full, final Switch flash) { final Switch full, final Switch flash) {
one.setOnClickListener(new OnClickListener() { one.setOnClickListener(new OnClickListener() {
@ -327,8 +327,8 @@ public class SettingsActivity extends Activity {
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} }
if (egg == 15) { if (egg == 15) {
Toast.makeText(SettingsActivity.this, "Easter Egg goes here", Toast.makeText(SettingsActivity.this,
Toast.LENGTH_SHORT).show(); "Easter Egg goes here", Toast.LENGTH_SHORT).show();
egg = 0; egg = 0;
} }
@ -363,18 +363,27 @@ public class SettingsActivity extends Activity {
boolean flashInstalled = false; boolean flashInstalled = false;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0); ApplicationInfo ai = pm.getApplicationInfo(
"com.adobe.flashplayer", 0);
if (ai != null) if (ai != null)
flashInstalled = true; flashInstalled = true;
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
flashInstalled = false; flashInstalled = false;
} }
if(!flashInstalled){ if (!flashInstalled && isChecked) {
Utils.createInformativeDialog(SettingsActivity.this, "Warning", "Adobe Flash Player was not detected.\n" + Utils.createInformativeDialog(SettingsActivity.this,
"Please install Flash Player."); "Warning", "Adobe Flash Player was not detected.\n"
+ "Please install Flash Player.");
buttonView.setChecked(false); buttonView.setChecked(false);
edit.putInt("enableflash", 0); edit.putInt("enableflash", 0);
edit.commit(); edit.commit();
} else if ((API > 17) && isChecked) {
Utils.createInformativeDialog(
SettingsActivity.this,
"Warning",
"Adobe Flash does not support Android 4.3 and will"
+ "crash the browser, please do not report crashes that occur if you enable flash.");
} }
} }
@ -392,7 +401,8 @@ public class SettingsActivity extends Activity {
}); });
} }
public void initCheckBox(CheckBox location, CheckBox fullscreen, CheckBox flash) { public void initCheckBox(CheckBox location, CheckBox fullscreen,
CheckBox flash) {
location.setOnCheckedChangeListener(new OnCheckedChangeListener() { location.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -418,18 +428,27 @@ public class SettingsActivity extends Activity {
boolean flashInstalled = false; boolean flashInstalled = false;
try { try {
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0); ApplicationInfo ai = pm.getApplicationInfo(
"com.adobe.flashplayer", 0);
if (ai != null) if (ai != null)
flashInstalled = true; flashInstalled = true;
} catch (NameNotFoundException e) { } catch (NameNotFoundException e) {
flashInstalled = false; flashInstalled = false;
} }
if(!flashInstalled){ if (!flashInstalled && isChecked) {
Utils.createInformativeDialog(SettingsActivity.this, "Warning", "Adobe Flash Player was not detected.\n" + Utils.createInformativeDialog(SettingsActivity.this,
"Please install Flash Player."); "Warning", "Adobe Flash Player was not detected.\n"
+ "Please install Flash Player.");
buttonView.setChecked(false); buttonView.setChecked(false);
edit.putInt("enableflash", 0); edit.putInt("enableflash", 0);
edit.commit(); edit.commit();
} else if ((API > 17) && isChecked) {
Utils.createInformativeDialog(
SettingsActivity.this,
"Warning",
"Adobe Flash does not support Android 4.3 and will"
+ "crash the browser, please do not report crashes that occur if you enable flash.");
} }
} }