diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e36470f..5113ab7 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -47,12 +47,8 @@ @@ -125,4 +121,4 @@ - + \ No newline at end of file diff --git a/Barebones.apk b/Barebones.apk index 367b556..c30a7bc 100644 Binary files a/Barebones.apk and b/Barebones.apk differ diff --git a/res/layout/advanced_settings.xml b/res/layout/advanced_settings.xml index 932064b..e2f5964 100644 --- a/res/layout/advanced_settings.xml +++ b/res/layout/advanced_settings.xml @@ -231,7 +231,7 @@ android:layout_alignParentRight="true"/> - + + + + + + + + + + + + + + + + + + Enable text reflow Block Images Allow sites to open new windows - Incognito always on - Import bookmarks from Stock Browser (if available) + Enable Cookies + Import bookmarks from Stock Browser Text size AdvancedSettings Hello world! @@ -41,5 +41,7 @@ (Websites may look weird) Search Engine Search + Use wide viewport + Load pages in overview mode \ No newline at end of file diff --git a/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java b/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java index 1a93608..417b80c 100644 --- a/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java +++ b/src/acr/browser/barebones/activities/AdvancedSettingsActivity.java @@ -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; 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 { 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 { 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 { 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 { 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 { 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 { 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 { @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 { }); } + 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 { } void r9(RelativeLayout view) { + view.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { + importFromStockBrowser(); + } }); @@ -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); diff --git a/src/acr/browser/barebones/activities/BarebonesActivity.java b/src/acr/browser/barebones/activities/BarebonesActivity.java index 226f08c..5f7ae6e 100644 --- a/src/acr/browser/barebones/activities/BarebonesActivity.java +++ b/src/acr/browser/barebones/activities/BarebonesActivity.java @@ -128,7 +128,7 @@ public class BarebonesActivity extends Activity { QuotaUpdater quotaUpdater) { quotaUpdater.updateQuota(quota + requiredStorage); } - + @Override public Bitmap getDefaultVideoPoster() { if (mDefaultVideoPoster == null) { @@ -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 { 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); + } } } @@ -828,9 +858,9 @@ public class BarebonesActivity extends Activity { case DialogInterface.BUTTON_NEUTRAL: { if (API > 8) { String url = result.getExtra(); - + Utils.downloadFile(CONTEXT, url, null, null); - + } break; } @@ -1014,8 +1044,6 @@ public class BarebonesActivity extends Activity { } - - @SuppressLint("SetJavaScriptEnabled") CustomWebView browserSettings(CustomWebView view) { view.setAnimationCacheEnabled(false); @@ -1044,10 +1072,10 @@ public class BarebonesActivity extends Activity { // or // disable } - + 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; @@ -1064,10 +1092,9 @@ public class BarebonesActivity extends Activity { webViewSettings.setTextSize(WebSettings.TextSize.SMALLEST); break; } - - } - else{ - switch(settings.getInt("textsize", 3)){ + + } else { + switch (settings.getInt("textsize", 3)) { case 1: webViewSettings.setTextZoom(200); break; @@ -1106,7 +1133,6 @@ public class BarebonesActivity extends Activity { default: break; } - if (API < 18) { if (settings.getBoolean("passwords", false)) { @@ -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); @@ -1147,8 +1175,9 @@ public class BarebonesActivity extends Activity { } else { 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 { 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 { 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 { 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 { 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; @@ -2273,9 +2313,7 @@ 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 { 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; diff --git a/src/acr/browser/barebones/activities/SettingsActivity.java b/src/acr/browser/barebones/activities/SettingsActivity.java index 185e9c1..405a1c4 100644 --- a/src/acr/browser/barebones/activities/SettingsActivity.java +++ b/src/acr/browser/barebones/activities/SettingsActivity.java @@ -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; 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; 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 { 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 { } 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 { } 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(); + } }