move subwindow handling to UI
added sub view creation to WebViewFactory
removed WebView from subview layout
use WebVIewFactory for creating the SubWebView
moved layout/view related code to UI
Change-Id: Id5b1905e4c36814fe7cc047cbd97128235d7e65e
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 2a23bb1..5f8944f 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -34,12 +34,15 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.webkit.WebHistoryItem;
import android.webkit.WebView;
import android.widget.FrameLayout;
+import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.Toast;
@@ -164,6 +167,16 @@
return w;
}
+ @Override
+ public WebView createSubWebView(boolean privateBrowsing) {
+ ScrollWebView web = (ScrollWebView) createWebView(privateBrowsing);
+ if (mXLargeScreenSize) {
+ // no scroll listener for subview
+ web.setScrollListener(null);
+ }
+ return web;
+ }
+
void stopWebViewScrolling() {
ScrollWebView web = (ScrollWebView) mUiController.getCurrentWebView();
if (web != null) {
@@ -415,6 +428,33 @@
}
/**
+ * create a sub window container and webview for the tab
+ * Note: this methods operates through side-effects for now
+ * it sets both the subView and subViewContainer for the given tab
+ * @param tab tab to create the sub window for
+ * @param subView webview to be set as a subwindow for the tab
+ */
+ @Override
+ public void createSubWindow(Tab tab, WebView subView) {
+ View subViewContainer = mActivity.getLayoutInflater().inflate(
+ R.layout.browser_subwindow, null);
+ ViewGroup inner = (ViewGroup) subViewContainer
+ .findViewById(R.id.inner_container);
+ inner.addView(subView, new LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.MATCH_PARENT));
+ final ImageButton cancel = (ImageButton) subViewContainer
+ .findViewById(R.id.subwindow_close);
+ final WebView cancelSubView = subView;
+ cancel.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ cancelSubView.getWebChromeClient().onCloseWindow(cancelSubView);
+ }
+ });
+ tab.setSubWebView(subView);
+ tab.setSubViewContainer(subViewContainer);
+ }
+
+ /**
* Remove the sub window from the content view.
*/
@Override
@@ -428,6 +468,10 @@
*/
@Override
public void attachSubWindow(View container) {
+ if (container.getParent() != null) {
+ // already attached, remove first
+ ((ViewGroup) container.getParent()).removeView(container);
+ }
mContentView.addView(container, COVER_SCREEN_PARAMS);
}