summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/BaseUi.java23
-rw-r--r--src/com/android/browser/PhoneUi.java119
-rw-r--r--src/com/android/browser/PieControl.java4
-rw-r--r--src/com/android/browser/TitleBarBase.java12
-rw-r--r--src/com/android/browser/TitleBarPhone.java50
-rw-r--r--src/com/android/browser/TitleBarXLarge.java4
-rw-r--r--src/com/android/browser/XLargeUi.java9
7 files changed, 180 insertions, 41 deletions
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index c3549b3..c00e6fc 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -17,10 +17,7 @@
package com.android.browser;
import com.android.browser.Tab.LockIcon;
-import com.android.browser.UI.DropdownChangeListener;
-import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.pm.PackageManager;
@@ -42,7 +39,6 @@ import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebChromeClient;
-import android.webkit.WebSettings.ZoomDensity;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@@ -748,4 +744,23 @@ public abstract class BaseUi implements UI, WebViewFactory {
warning.show();
}
+ protected void captureTab(final Tab tab) {
+ captureTab(tab,
+ (int) mActivity.getResources()
+ .getDimension(R.dimen.qc_thumb_width),
+ (int) mActivity.getResources()
+ .getDimension(R.dimen.qc_thumb_height));
+ }
+
+ protected void captureTab(final Tab tab, int width, int height) {
+ if ((tab == null) || (tab.getWebView() == null)) return;
+ Bitmap sshot = Controller.createScreenshot(tab, width, height);
+ tab.setScreenshot(sshot);
+ }
+
+ void showTitleBarAndEdit() {
+ showTitleBar();
+ getTitleBar().startEditingUrl(false);
+ }
+
}
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index efd6c43..9cc5a2f 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -18,12 +18,10 @@ package com.android.browser;
import android.app.Activity;
import android.content.Context;
-import android.graphics.Bitmap;
import android.graphics.PixelFormat;
import android.os.Handler;
import android.util.Log;
import android.view.ActionMode;
-import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
@@ -31,6 +29,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.webkit.WebView;
+import android.widget.FrameLayout;
/**
* Ui for regular phone screen sizes
@@ -42,6 +41,8 @@ public class PhoneUi extends BaseUi {
private TitleBarPhone mTitleBar;
private ActiveTabsPage mActiveTabsPage;
private TouchProxy mTitleOverlay;
+ private boolean mUseQuickControls;
+ private PieControl mPieControl;
boolean mExtendedMenuOpen;
boolean mOptionsMenuOpen;
@@ -57,6 +58,7 @@ public class PhoneUi extends BaseUi {
// phone
mTitleBar.setProgress(100);
mActivity.getActionBar().hide();
+ setUseQuickControls(BrowserSettings.getInstance().useQuickControls());
}
@Override
@@ -102,6 +104,7 @@ public class PhoneUi extends BaseUi {
@Override
public void onProgressChanged(Tab tab) {
+ if (mUseQuickControls) return;
if (tab.inForeground()) {
int progress = tab.getLoadProgress();
mTitleBar.setProgress(progress);
@@ -118,42 +121,48 @@ public class PhoneUi extends BaseUi {
}
@Override
- public void setActiveTab(Tab tab) {
+ public void setActiveTab(final Tab tab) {
captureTab(mActiveTab);
- super.setActiveTab(tab);
- WebView view = tab.getWebView();
+ super.setActiveTab(tab, true);
+ setActiveTab(tab, true);
+ }
+
+ @Override
+ void setActiveTab(Tab tab, boolean needsAttaching) {
+ BrowserWebView view = (BrowserWebView) tab.getWebView();
// TabControl.setCurrentTab has been called before this,
// so the tab is guaranteed to have a webview
if (view == null) {
Log.e(LOGTAG, "active tab with no webview detected");
return;
}
- view.setEmbeddedTitleBar(getTitleBar());
+ // Request focus on the top window.
+ if (mUseQuickControls) {
+ mPieControl.forceToTop(mContentView);
+ view.setScrollListener(null);
+ } else {
+ // check if title bar is already attached by animation
+ if (mTitleBar.getParent() == null) {
+ view.setEmbeddedTitleBar(mTitleBar);
+ }
+ }
if (tab.isInVoiceSearchMode()) {
- showVoiceTitleBar(tab.getVoiceDisplayTitle(),
- tab.getVoiceSearchResults());
+ showVoiceTitleBar(tab.getVoiceDisplayTitle(), tab.getVoiceSearchResults());
} else {
revertVoiceTitleBar(tab);
}
+ updateLockIconToLatest(tab);
tab.getTopWindow().requestFocus();
}
- public void captureTab(final Tab tab) {
- if (tab == null) return;
- if (tab.getWebView() == null) return;
-
- Display display = mActivity.getWindowManager().getDefaultDisplay();
- float height = mActivity.getResources()
- .getDimension(R.dimen.tab_view_thumbnail_height);
- Bitmap sshot = Controller.createScreenshot(tab,
- display.getWidth(), (int) height);
- tab.setScreenshot(sshot);
- }
-
@Override
protected void showTitleBar() {
if (canShowTitleBar()) {
- setTitleGravity(Gravity.TOP);
+ if (mUseQuickControls) {
+ mContentView.addView(mTitleBar);
+ } else {
+ setTitleGravity(Gravity.TOP);
+ }
super.showTitleBar();
}
}
@@ -161,7 +170,11 @@ public class PhoneUi extends BaseUi {
@Override
protected void hideTitleBar() {
if (isTitleBarShowing()) {
- setTitleGravity(Gravity.NO_GRAVITY);
+ if (mUseQuickControls) {
+ mContentView.removeView(mTitleBar);
+ } else {
+ setTitleGravity(Gravity.NO_GRAVITY);
+ }
super.hideTitleBar();
}
}
@@ -233,7 +246,9 @@ public class PhoneUi extends BaseUi {
@Override
public void onExtendedMenuClosed(boolean inLoad) {
mExtendedMenuOpen = false;
- showTitleBar();
+ if (!mUseQuickControls) {
+ showTitleBar();
+ }
}
@Override
@@ -300,4 +315,62 @@ public class PhoneUi extends BaseUi {
}
}
+ @Override
+ protected void setTitleGravity(int gravity) {
+ if (mUseQuickControls) {
+ FrameLayout.LayoutParams lp =
+ (FrameLayout.LayoutParams) getTitleBar().getLayoutParams();
+ lp.gravity = gravity;
+ getTitleBar().setLayoutParams(lp);
+ } else {
+ super.setTitleGravity(gravity);
+ }
+ }
+
+ private void setUseQuickControls(boolean useQuickControls) {
+ mUseQuickControls = useQuickControls;
+ getTitleBar().setUseQuickControls(mUseQuickControls);
+ if (useQuickControls) {
+// checkTabCount();
+ mPieControl = new PieControl(mActivity, mUiController, this);
+ mPieControl.attachToContainer(mContentView);
+ Tab tab = getActiveTab();
+ if ((tab != null) && (tab.getWebView() != null)) {
+ tab.getWebView().setEmbeddedTitleBar(null);
+ }
+ } else {
+ mActivity.getActionBar().show();
+ if (mPieControl != null) {
+ mPieControl.removeFromContainer(mContentView);
+ }
+ WebView web = mTabControl.getCurrentWebView();
+ if (web != null) {
+ web.setEmbeddedTitleBar(mTitleBar);
+ }
+ setTitleGravity(Gravity.NO_GRAVITY);
+ }
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ if (mUseQuickControls) {
+ menu.setGroupVisible(R.id.NAV_MENU, false);
+ mPieControl.onMenuOpened(menu);
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ @Override
+ protected void captureTab(final Tab tab) {
+ if (mUseQuickControls) {
+ super.captureTab(tab);
+ } else {
+ captureTab(tab,
+ mActivity.getWindowManager().getDefaultDisplay().getWidth(),
+ (int) mActivity.getResources()
+ .getDimension(R.dimen.tab_view_thumbnail_height));
+ }
+ }
}
diff --git a/src/com/android/browser/PieControl.java b/src/com/android/browser/PieControl.java
index 38ed1bb..82e26c4 100644
--- a/src/com/android/browser/PieControl.java
+++ b/src/com/android/browser/PieControl.java
@@ -50,7 +50,7 @@ public class PieControl implements OnClickListener, PieMenu.PieController {
private Activity mActivity;
private UiController mUiController;
- private XLargeUi mUi;
+ private BaseUi mUi;
private PieMenu mPie;
private PieItem mBack;
private PieItem mForward;
@@ -66,7 +66,7 @@ public class PieControl implements OnClickListener, PieMenu.PieController {
private TextView mTabsCount;
private int mItemSize;
- public PieControl(Activity activity, UiController controller, XLargeUi ui) {
+ public PieControl(Activity activity, UiController controller, BaseUi ui) {
mActivity = activity;
mUiController = controller;
mUi = ui;
diff --git a/src/com/android/browser/TitleBarBase.java b/src/com/android/browser/TitleBarBase.java
index 7e8ea1a..d34d18d 100644
--- a/src/com/android/browser/TitleBarBase.java
+++ b/src/com/android/browser/TitleBarBase.java
@@ -84,7 +84,7 @@ public class TitleBarBase extends RelativeLayout
protected ImageButton mAutoLoginCancel;
protected DeviceAccountLogin mAutoLoginHandler;
protected ArrayAdapter<String> mAccountsAdapter;
-
+ protected boolean mUseQuickControls;
public TitleBarBase(Context context, UiController controller, BaseUi ui) {
super(context, null);
@@ -118,6 +118,10 @@ public class TitleBarBase extends RelativeLayout
protected void setupUrlInput() {
}
+ protected void setUseQuickControls(boolean use) {
+ mUseQuickControls = use;
+ }
+
/* package */ void setProgress(int newProgress) {}
/* package */ void setLock(Drawable d) {
@@ -429,4 +433,10 @@ public class TitleBarBase extends RelativeLayout
mUrlInput.registerDropdownChangeListener(d);
}
+ /**
+ * called from the Ui when the user wants to edit
+ * @param clearInput clear the input field
+ */
+ void startEditingUrl(boolean clearInput) {};
+
}
diff --git a/src/com/android/browser/TitleBarPhone.java b/src/com/android/browser/TitleBarPhone.java
index bcf8d53..d6b5f4d 100644
--- a/src/com/android/browser/TitleBarPhone.java
+++ b/src/com/android/browser/TitleBarPhone.java
@@ -26,7 +26,11 @@ import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
+import android.view.ViewGroup;
+import android.widget.AbsoluteLayout;
+import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.RelativeLayout.LayoutParams;
import java.util.List;
@@ -148,6 +152,9 @@ public class TitleBarPhone extends TitleBarBase implements OnFocusChangeListener
}
}
super.onFocusChange(v, hasFocus);
+ if (mUseQuickControls && !hasFocus) {
+ mBaseUi.hideTitleBar();
+ }
}
@Override
@@ -161,4 +168,47 @@ public class TitleBarPhone extends TitleBarBase implements OnFocusChangeListener
}
}
+ @Override
+ void startEditingUrl(boolean clearInput) {
+ // editing takes preference of progress
+ mContainer.setVisibility(View.VISIBLE);
+ if (!mUrlInput.hasFocus()) {
+ mUrlInput.requestFocus();
+ }
+ if (clearInput) {
+ mUrlInput.setText("");
+ } else if (mInVoiceMode) {
+ mUrlInput.showDropDown();
+ }
+ }
+
+ @Override
+ void setTitleGravity(int gravity) {
+ if (mUseQuickControls) {
+ FrameLayout.LayoutParams lp =
+ (FrameLayout.LayoutParams) getLayoutParams();
+ lp.gravity = gravity;
+ setLayoutParams(lp);
+ } else {
+ super.setTitleGravity(gravity);
+ }
+ }
+
+ @Override
+ protected void setUseQuickControls(boolean useQuickControls) {
+ mUseQuickControls = useQuickControls;
+ setLayoutParams(makeLayoutParams());
+ }
+
+ private ViewGroup.LayoutParams makeLayoutParams() {
+ if (mUseQuickControls) {
+ return new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.WRAP_CONTENT);
+ } else {
+ return new AbsoluteLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
+ 0, 0);
+ }
+ }
+
}
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index db36fc0..7a8d984 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -65,7 +65,6 @@ public class TitleBarXLarge extends TitleBarBase
private Drawable mUnfocusDrawable;
private boolean mInLoad;
- private boolean mUseQuickControls;
public TitleBarXLarge(Activity activity, UiController controller,
XLargeUi ui) {
@@ -159,7 +158,8 @@ public class TitleBarXLarge extends TitleBarBase
return height;
}
- void setUseQuickControls(boolean useQuickControls) {
+ @Override
+ protected void setUseQuickControls(boolean useQuickControls) {
mUseQuickControls = useQuickControls;
setLayoutParams(makeLayoutParams());
}
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java
index c763bb0..7e78f0d 100644
--- a/src/com/android/browser/XLargeUi.java
+++ b/src/com/android/browser/XLargeUi.java
@@ -23,7 +23,6 @@ import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.app.ActionBar;
import android.app.Activity;
-import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
@@ -256,14 +255,6 @@ public class XLargeUi extends BaseUi implements ScrollListener {
tab.getTopWindow().requestFocus();
}
- public void captureTab(final Tab tab) {
- Bitmap sshot = Controller.createScreenshot(tab,
- (int) mActivity.getResources()
- .getDimension(R.dimen.qc_thumb_width),
- (int) mActivity.getResources()
- .getDimension(R.dimen.qc_thumb_height));
- tab.setScreenshot(sshot);
- }
@Override
public void updateTabs(List<Tab> tabs) {