Browse Source

Updated to 2.2.0

Added full-screen option, fixed problems with videos playing, fixed some
rendering issues
master
Anthony Restaino 12 years ago
parent
commit
7a228d2a8c
  1. 0
      README
  2. BIN
      ic_launcher-web.png
  3. 3
      res/menu-es/menu.xml
  4. 3
      res/menu/menu.xml
  5. 171
      src/acr/browser/barebones/Barebones.java
  6. 8
      src/acr/browser/barebones/Settings.java

0
DESCRIPTION → README

BIN
ic_launcher-web.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

3
res/menu-es/menu.xml

@ -6,6 +6,5 @@
<item android:id="@id/allBookmarks" android:orderInCategory="3" android:title="Marcadores" android:titleCondensed="Marcadores" /> <item android:id="@id/allBookmarks" android:orderInCategory="3" android:title="Marcadores" android:titleCondensed="Marcadores" />
<item android:id="@id/share" android:orderInCategory="4" android:title="Compartir" android:titleCondensed="Compartir" /> <item android:id="@id/share" android:orderInCategory="4" android:title="Compartir" android:titleCondensed="Compartir" />
<item android:id="@id/settings" android:orderInCategory="5" android:title="Ajustes" android:titleCondensed="Ajustes" /> <item android:id="@id/settings" android:orderInCategory="5" android:title="Ajustes" android:titleCondensed="Ajustes" />
<item android:id="@+id/tabs" android:title="Mostrar/ocultar pestanas" android:orderInCategory="5" android:titleCondensed="Mostrar/ocultar"></item> <item android:id="@+id/forward" android:title="Adelante" android:orderInCategory="5" android:titleCondensed="Adelante"></item>
<item android:id="@+id/forward" android:title="Adelante" android:orderInCategory="7" android:titleCondensed="Adelante"></item>
</menu> </menu>

3
res/menu/menu.xml

@ -5,8 +5,7 @@
<item android:id="@+id/allBookmarks" android:titleCondensed="Bookmarks" android:title="Bookmarks" android:orderInCategory="3"></item> <item android:id="@+id/allBookmarks" android:titleCondensed="Bookmarks" android:title="Bookmarks" android:orderInCategory="3"></item>
<item android:id="@+id/share" android:title="Share" android:titleCondensed="Share" android:orderInCategory="4"></item> <item android:id="@+id/share" android:title="Share" android:titleCondensed="Share" android:orderInCategory="4"></item>
<item android:id="@+id/settings" android:title="Settings" android:titleCondensed="Settings" android:orderInCategory="6"></item> <item android:id="@+id/settings" android:title="Settings" android:titleCondensed="Settings" android:orderInCategory="6"></item>
<item android:id="@+id/tabs" android:title="Show/hide tabs" android:orderInCategory="5" android:titleCondensed="Show/hide tabs"></item> <item android:id="@+id/forward" android:title="Forward" android:orderInCategory="5" android:titleCondensed="Forward"></item>
<item android:id="@+id/forward" android:title="Forward" android:orderInCategory="7" android:titleCondensed="Forward"></item>
</menu> </menu>

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

@ -18,6 +18,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -54,8 +55,11 @@ import android.webkit.HttpAuthHandler;
import android.webkit.SslErrorHandler; import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebChromeClient.CustomViewCallback;
import android.webkit.WebIconDatabase; import android.webkit.WebIconDatabase;
import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState; import android.webkit.WebSettings.PluginState;
import android.webkit.WebSettings.RenderPriority;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebView.HitTestResult; import android.webkit.WebView.HitTestResult;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
@ -78,7 +82,7 @@ import android.widget.ZoomButtonsController;
public class Barebones extends Activity implements OnLongClickListener, public class Barebones extends Activity implements OnLongClickListener,
OnTouchListener{ OnTouchListener{
public static final String preferences = "settings"; public static final String preferences = "settings";
int MAX_TABS=50, MAX_BOOKMARKS=50; int MAX_TABS=5, MAX_BOOKMARKS=5;
long lastTime = 0; long lastTime = 0;
EditText getUrl; // edittext that gets the url entered EditText getUrl; // edittext that gets the url entered
String query, userAgent; // query is what is entered into get url, userAgent String query, userAgent; // query is what is entered into get url, userAgent
@ -133,6 +137,8 @@ public class Barebones extends Activity implements OnLongClickListener,
// used // used
// in // in
// settings // settings
View mCustomView = null;
CustomViewCallback mCustomViewCallback;
RelativeLayout barLayout; RelativeLayout barLayout;
boolean fullScreen; boolean fullScreen;
boolean urlBarShows=true; boolean urlBarShows=true;
@ -170,9 +176,9 @@ public class Barebones extends Activity implements OnLongClickListener,
forward();// forward button forward();// forward button
exit(); exit();
// int first = settings.getInt("first", 0); int first = settings.getInt("first", 0);
/* if(first==0){ if(first==0){
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog,
int which) { int which) {
@ -188,14 +194,15 @@ public class Barebones extends Activity implements OnLongClickListener,
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
Barebones.this); // dialog Barebones.this); // dialog
builder.setMessage( builder.setMessage(
"TIPS:\n\nLong-press settings button to show or hide tabs" + "TIPS:\n" +
"\nLong-press a tab to close it\nLong-press back button to exit browser" + "\nLong-press a tab to close it\n\nLong-press back button to exit browser" +
"\nSet your homepage in settings to about:blank to set a blank page as your default" + "\n\nSet your homepage in settings to about:blank to set a blank page as your default\n" +
"\nSet the homepage to about:home to set bookmarks as your homepage") "\nSet the homepage to about:home to set bookmarks as your homepage")
.setPositiveButton("Ok", .setPositiveButton("Ok",
dialogClickListener).show(); dialogClickListener).show();
edit.putInt("first", 1); edit.putInt("first", 1);
}*/ edit.commit();
}
} }
public void init() { public void init() {
@ -617,27 +624,7 @@ public class Barebones extends Activity implements OnLongClickListener,
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
backgroundScroll.requestDisallowInterceptTouchEvent(true);
if(API<=10&&v.hasFocus()==false&&event.getAction()==MotionEvent.ACTION_DOWN){
v.requestFocus();}
if(event.getAction()==MotionEvent.ACTION_DOWN){
}
if(main[pageId].getScrollY()<5&&event.getAction()==MotionEvent.ACTION_UP&&fullScreen){
backgroundScroll.requestDisallowInterceptTouchEvent(true);
backgroundScroll.smoothScrollTo(0, backgroundScroll.getTop());
backgroundScroll.requestDisallowInterceptTouchEvent(true);
}
else if(main[pageId].getScrollY()>=5&&event.getAction()==MotionEvent.ACTION_UP&&fullScreen){
backgroundScroll.requestDisallowInterceptTouchEvent(true);
backgroundScroll.smoothScrollTo(0, backgroundScroll.getBottom());
backgroundScroll.requestDisallowInterceptTouchEvent(true);
}
backgroundScroll.requestDisallowInterceptTouchEvent(true);
if(event.getAction()==MotionEvent.ACTION_UP||event.getAction()==MotionEvent.ACTION_CANCEL){
}
return false; return false;
@ -685,11 +672,40 @@ public class Barebones extends Activity implements OnLongClickListener,
super.flingScroll(vx, vy); super.flingScroll(vx, vy);
} }
@Override @Override
@ExportedProperty protected void onDraw(Canvas canvas) {
public boolean isInTouchMode() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return super.isInTouchMode(); super.onDraw(canvas);
invalidate();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
backgroundScroll.requestDisallowInterceptTouchEvent(true);
if(API<=10&&main[pageId].hasFocus()==false&&event.getAction()==MotionEvent.ACTION_DOWN){
main[pageId].requestFocus();}
if(event.getAction()==MotionEvent.ACTION_DOWN){
}
if(main[pageId].getScrollY()<5&&event.getAction()==MotionEvent.ACTION_UP&&fullScreen){
backgroundScroll.requestDisallowInterceptTouchEvent(true);
backgroundScroll.smoothScrollTo(0, backgroundScroll.getTop());
backgroundScroll.requestDisallowInterceptTouchEvent(true);
}
else if(main[pageId].getScrollY()>=5&&event.getAction()==MotionEvent.ACTION_UP&&fullScreen){
backgroundScroll.requestDisallowInterceptTouchEvent(true);
backgroundScroll.smoothScrollTo(0, backgroundScroll.getBottom());
backgroundScroll.requestDisallowInterceptTouchEvent(true);
}
backgroundScroll.requestDisallowInterceptTouchEvent(true);
if(event.getAction()==MotionEvent.ACTION_UP||event.getAction()==MotionEvent.ACTION_CANCEL){
}
return super.onTouchEvent(event);
} }
@Override @Override
@ -709,6 +725,8 @@ public class Barebones extends Activity implements OnLongClickListener,
} }
private class AnthonyWebViewClient extends WebViewClient { private class AnthonyWebViewClient extends WebViewClient {
@ -742,11 +760,6 @@ public class Barebones extends Activity implements OnLongClickListener,
super.onReceivedLoginRequest(view, realm, account, args); super.onReceivedLoginRequest(view, realm, account, args);
} }
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override @Override
public void onPageStarted(WebView view, String url, Bitmap favicon) { public void onPageStarted(WebView view, String url, Bitmap favicon) {
@ -864,45 +877,49 @@ public class Barebones extends Activity implements OnLongClickListener,
urlTitle[pageId].setText(title); urlTitle[pageId].setText(title);
urlToLoad[pageId][1] = title; urlToLoad[pageId][1] = title;
} }
@Override private Bitmap mDefaultVideoPoster;
public void onShowCustomView(View view, CustomViewCallback callback) { private View mVideoProgressView;
super.onShowCustomView(view, callback);
if (view instanceof FrameLayout){ @Override
FrameLayout frame = (FrameLayout) view; public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback)
if (frame.getFocusedChild() instanceof VideoView){ {
VideoView video = (VideoView) frame.getFocusedChild(); //Log.i(LOGTAG, "here in on ShowCustomView");
frame.removeView(video); main[pageId].setVisibility(View.GONE);
setContentView(video);
video.setOnCompletionListener(new OnCompletionListener(){ // if a view already exists then immediately terminate the new one
if (mCustomView != null) {
callback.onCustomViewHidden();
return;
}
webFrame.removeView(main[pageId]);
webFrame.addView(view);
mCustomView = view;
mCustomView.setVisibility(View.VISIBLE);
mCustomViewCallback = callback;
@Override }
public void onCompletion(MediaPlayer arg0) {
// TODO Auto-generated method stub
onCompletion(arg0);
} @Override
public void onHideCustomView() {
if (mCustomView == null)
return;
}); // Hide the custom view.
video.setOnErrorListener(new OnErrorListener(){ mCustomView.setVisibility(View.GONE);
@Override // Remove the custom view from its container.
public boolean onError(MediaPlayer arg0, int arg1, webFrame.removeView(mCustomView);
int arg2) { mCustomView = null;
// TODO Auto-generated method stub webFrame.addView(main[pageId]);
return false; mCustomViewCallback.onCustomViewHidden();
}
}); main[pageId].setVisibility(View.VISIBLE);
video.start(); main[pageId].goBack();
} //Log.i(LOGTAG, "set it to webVew");
} }
}
} }
public void onCompletion(MediaPlayer mp) {
setContentView(R.layout.activity_main); // displays main xml layout
}
private AnthonyWebView settings(AnthonyWebView view) { private AnthonyWebView settings(AnthonyWebView view) {
java = settings.getBoolean("java", true); java = settings.getBoolean("java", true);
@ -916,6 +933,7 @@ public class Barebones extends Activity implements OnLongClickListener,
view.setFocusableInTouchMode(true); view.setFocusableInTouchMode(true);
view.setSaveEnabled(true); view.setSaveEnabled(true);
view.getSettings().setDomStorageEnabled(true); view.getSettings().setDomStorageEnabled(true);
view.getSettings().setRenderPriority(RenderPriority.HIGH);
view.getSettings().setGeolocationEnabled(true); view.getSettings().setGeolocationEnabled(true);
view.getSettings().setGeolocationDatabasePath( view.getSettings().setGeolocationDatabasePath(
getApplicationContext().getFilesDir().getAbsolutePath()); getApplicationContext().getFilesDir().getAbsolutePath());
@ -937,7 +955,7 @@ public class Barebones extends Activity implements OnLongClickListener,
view.getSettings().setAppCacheEnabled(true); view.getSettings().setAppCacheEnabled(true);
} }
if(API<11){ if(API<11){
view.getSettings().setBuiltInZoomControls(false);} view.getSettings().setBuiltInZoomControls(true);}
view.getSettings().setSupportZoom(true); view.getSettings().setSupportZoom(true);
view.getSettings().setUseWideViewPort(true); view.getSettings().setUseWideViewPort(true);
@ -1289,8 +1307,6 @@ public class Barebones extends Activity implements OnLongClickListener,
case R.id.share: case R.id.share:
share(); share();
return true; return true;
case R.id.tabs:
return true;
case R.id.forward: case R.id.forward:
if(main[pageId].canGoForward()){ if(main[pageId].canGoForward()){
main[pageId].goForward(); main[pageId].goForward();
@ -1366,8 +1382,6 @@ public class Barebones extends Activity implements OnLongClickListener,
case R.id.share: case R.id.share:
share(); share();
return true; return true;
case R.id.tabs:
return true;
case R.id.forward: case R.id.forward:
if(main[pageId].canGoForward()){ if(main[pageId].canGoForward()){
main[pageId].goForward(); main[pageId].goForward();
@ -1533,7 +1547,20 @@ public class Barebones extends Activity implements OnLongClickListener,
urlTitle[pageId].setText(urlToLoad[pageId][1]); urlTitle[pageId].setText(urlToLoad[pageId][1]);
getUrl.setText(urlToLoad[pageId][0]); getUrl.setText(urlToLoad[pageId][0]);
isBookmarkShowing = false; isBookmarkShowing = false;
} else { } else if (mCustomView!=null&&mCustomView.isShown()&&!main[pageId].isShown()){
// Hide the custom view.
mCustomView.setVisibility(View.GONE);
// Remove the custom view from its container.
webFrame.removeView(mCustomView);
mCustomView = null;
webFrame.addView(main[pageId]);
mCustomViewCallback.onCustomViewHidden();
main[pageId].setVisibility(View.VISIBLE);
}else {
if (main[pageId].canGoBack()) { if (main[pageId].canGoBack()) {
main[pageId].goBack(); main[pageId].goBack();
} else { } else {

8
src/acr/browser/barebones/Settings.java

@ -113,7 +113,7 @@ public class Settings extends Activity {
String home; String home;
home = h.getText().toString(); home = h.getText().toString();
if(!home.contains("about:blank")&&!home.contains("about:home")){ if(!home.contains("about:blank")&&!home.contains("about:home")){
if(home.contains("http://")==false){ if(home.contains("http://")==false&&home.contains("https://")==false){
home = "http://"+home; home = "http://"+home;
}} }}
edit.putString("home", home); edit.putString("home", home);
@ -137,7 +137,7 @@ public class Settings extends Activity {
|| actionId == EditorInfo.IME_ACTION_SEND||actionId==EditorInfo.IME_ACTION_SEARCH||event.getAction()==KeyEvent.KEYCODE_ENTER) { || actionId == EditorInfo.IME_ACTION_SEND||actionId==EditorInfo.IME_ACTION_SEARCH||event.getAction()==KeyEvent.KEYCODE_ENTER) {
String home = h.getText().toString(); String home = h.getText().toString();
if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){ if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){
if(h.getText().toString().contains("http://")==false){ if(h.getText().toString().contains("http://")==false&&h.getText().toString().contains("https://")==false){
home = "http://"+h.getText().toString(); home = "http://"+h.getText().toString();
}} }}
edit.putString("home", home); edit.putString("home", home);
@ -193,7 +193,7 @@ public class Settings extends Activity {
} }
String home = h.getText().toString(); String home = h.getText().toString();
if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){ if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){
if(h.getText().toString().contains("http://")==false){ if(h.getText().toString().contains("http://")==false&&h.getText().toString().contains("https://")==false){
home = "http://"+h.getText().toString(); home = "http://"+h.getText().toString();
}} }}
edit.putString("home", home); edit.putString("home", home);
@ -463,7 +463,7 @@ public void full(){
} }
String home = h.getText().toString(); String home = h.getText().toString();
if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){ if(!h.getText().toString().contains("about:blank")&&!h.getText().toString().contains("about:home")){
if(h.getText().toString().contains("http://")==false){ if(h.getText().toString().contains("http://")==false&&h.getText().toString().contains("https://")==false){
home = "http://"+h.getText().toString(); home = "http://"+h.getText().toString();
}} }}
edit.putString("home", home); edit.putString("home", home);

Loading…
Cancel
Save