Reconcile with jb-release nakasi-factoryrom-release
Change-Id: I0d6a14cf398ec8b8bed5022a40d030aeca8b8006
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0c2e6b3..1831462 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -185,7 +185,8 @@
<activity android:name="AddBookmarkPage" android:label="Save bookmark"
android:theme="@style/DialogWhenLarge"
- android:configChanges="orientation|keyboardHidden|screenSize">
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.INSERT" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/res/layout/custom_screen.xml b/res/layout/custom_screen.xml
index 7a22530..61c455c 100644
--- a/res/layout/custom_screen.xml
+++ b/res/layout/custom_screen.xml
@@ -22,7 +22,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
- <LinearLayout android:orientation="vertical"
+ <com.android.browser.view.CustomScreenLinearLayout
+ android:orientation="vertical"
android:id="@+id/vertical_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -32,10 +33,15 @@
android:layout_height="wrap_content"
/>
+ <FrameLayout android:id="@+id/fixed_titlebar_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ />
+
<FrameLayout android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
- </LinearLayout>
+ </com.android.browser.view.CustomScreenLinearLayout>
</merge>
diff --git a/res/menu/browser.xml b/res/menu/browser.xml
index b0c25ea..9d95e88 100644
--- a/res/menu/browser.xml
+++ b/res/menu/browser.xml
@@ -76,6 +76,9 @@
<group
android:id="@+id/COMBO_MENU">
<item
+ android:id="@+id/close_other_tabs_id"
+ android:title="@string/close_other_tabs" />
+ <item
android:id="@+id/history_menu_id"
android:title="@string/tab_history"
android:alphabeticShortcut="h" />
diff --git a/res/mipmap-hdpi/ic_launcher_browser.png b/res/mipmap-hdpi/ic_launcher_browser.png
index 5680416..4f9377f 100644
--- a/res/mipmap-hdpi/ic_launcher_browser.png
+++ b/res/mipmap-hdpi/ic_launcher_browser.png
Binary files differ
diff --git a/res/mipmap-mdpi/ic_launcher_browser.png b/res/mipmap-mdpi/ic_launcher_browser.png
index 426f4a7..9bc6817 100644
--- a/res/mipmap-mdpi/ic_launcher_browser.png
+++ b/res/mipmap-mdpi/ic_launcher_browser.png
Binary files differ
diff --git a/res/mipmap-xhdpi/ic_launcher_browser.png b/res/mipmap-xhdpi/ic_launcher_browser.png
index 74ffd5b..9412fbe 100644
--- a/res/mipmap-xhdpi/ic_launcher_browser.png
+++ b/res/mipmap-xhdpi/ic_launcher_browser.png
Binary files differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7df2a91..ff396ce 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -197,6 +197,8 @@
<string name="goto_dot">Go</string>
<!-- Menu item to switch to text selection mode for copy and paste. -->
<string name="select_dot">Select text</string>
+ <!-- Menu item to close all other tabs [CHAR LIMIT=40] -->
+ <string name="close_other_tabs">Close other tabs</string>
<!-- Menu item to open the bookmarks page. This is a shorter version that
is displayed with an icon -->
<string name="bookmarks">Bookmarks</string>
@@ -284,7 +286,7 @@
<string name="menu_preferences">Settings</string>
<!-- Settings screen, section title -->
<string name="pref_content_title">Page content</string>
- <!-- Settings label [CHAR LIMIT=40]-->
+ <!-- Settings label [CHAR LIMIT=45]-->
<string name="pref_allow_apptabs">Allow multiple tabs per app</string>
<!-- Settings label -->
<string name="pref_content_load_images">Load images</string>
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index bb44336..e3f5986 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -91,6 +91,7 @@
protected FrameLayout mContentView;
protected FrameLayout mCustomViewContainer;
protected FrameLayout mFullscreenContainer;
+ private FrameLayout mFixedTitlebarContainer;
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
@@ -126,6 +127,8 @@
.getDecorView().findViewById(android.R.id.content);
LayoutInflater.from(mActivity)
.inflate(R.layout.custom_screen, frameLayout);
+ mFixedTitlebarContainer = (FrameLayout) frameLayout.findViewById(
+ R.id.fixed_titlebar_container);
mContentView = (FrameLayout) frameLayout.findViewById(
R.id.main_content);
mCustomViewContainer = (FrameLayout) frameLayout.findViewById(
@@ -844,4 +847,17 @@
}
}
+
+ public void addFixedTitleBar(View view) {
+ mFixedTitlebarContainer.addView(view);
+ }
+
+ public void setContentViewMarginTop(int margin) {
+ LinearLayout.LayoutParams params =
+ (LinearLayout.LayoutParams) mContentView.getLayoutParams();
+ if (params.topMargin != margin) {
+ params.topMargin = margin;
+ mContentView.setLayoutParams(params);
+ }
+ }
}
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 493583d..3b5f812 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1553,6 +1553,10 @@
openIncognitoTab();
break;
+ case R.id.close_other_tabs_id:
+ closeOtherTabs();
+ break;
+
case R.id.goto_menu_id:
editUrl();
break;
@@ -2474,6 +2478,20 @@
}
}
+ /**
+ * Close all tabs except the current one
+ */
+ @Override
+ public void closeOtherTabs() {
+ int inactiveTabs = mTabControl.getTabCount() - 1;
+ for (int i = inactiveTabs; i >= 0; i--) {
+ Tab tab = mTabControl.getTab(i);
+ if (tab != mTabControl.getCurrentTab()) {
+ removeTab(tab);
+ }
+ }
+ }
+
// Called when loading from context menu or LOAD_URL message
protected void loadUrlFromContext(String url) {
Tab tab = getCurrentTab();
diff --git a/src/com/android/browser/DownloadHandler.java b/src/com/android/browser/DownloadHandler.java
index 6e2c786..31212b4 100644
--- a/src/com/android/browser/DownloadHandler.java
+++ b/src/com/android/browser/DownloadHandler.java
@@ -204,6 +204,7 @@
// old percent-encoded url.
String cookies = CookieManager.getInstance().getCookie(url, privateBrowsing);
request.addRequestHeader("cookie", cookies);
+ request.addRequestHeader("User-Agent", userAgent);
request.setNotificationVisibility(
DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
if (mimetype == null) {
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java
index eb6032d..e3c22bd 100644
--- a/src/com/android/browser/PhoneUi.java
+++ b/src/com/android/browser/PhoneUi.java
@@ -182,6 +182,14 @@
if (incognito != null) {
incognito.setVisible(showingNavScreen() || mUseQuickControls);
}
+ MenuItem closeOthers = menu.findItem(R.id.close_other_tabs_id);
+ if (closeOthers != null) {
+ boolean isLastTab = true;
+ if (tab != null) {
+ isLastTab = (mTabControl.getTabCount() <= 1);
+ }
+ closeOthers.setEnabled(!isLastTab);
+ }
if (showingNavScreen()) {
menu.setGroupVisible(R.id.LIVE_MENU, false);
menu.setGroupVisible(R.id.SNAPSHOT_MENU, false);
diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java
index 479b62e..ffe5553 100644
--- a/src/com/android/browser/TitleBar.java
+++ b/src/com/android/browser/TitleBar.java
@@ -45,7 +45,7 @@
private UiController mUiController;
private BaseUi mBaseUi;
- private FrameLayout mParent;
+ private FrameLayout mContentView;
private PageProgressView mProgress;
private AutologinBar mAutoLogin;
@@ -58,15 +58,16 @@
private boolean mInLoad;
private boolean mSkipTitleBarAnimations;
private Animator mTitleBarAnimator;
+ private boolean mIsFixedTitleBar;
public TitleBar(Context context, UiController controller, BaseUi ui,
- FrameLayout parent) {
+ FrameLayout contentView) {
super(context, null);
mUiController = controller;
mBaseUi = ui;
- mParent = parent;
+ mContentView = contentView;
initLayout(context);
- mParent.addView(this, makeLayoutParams());
+ setFixedTitleBar();
}
private void initLayout(Context context) {
@@ -100,10 +101,38 @@
@Override
protected void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
- if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
- if (!mContext.getResources().getBoolean(R.bool.hide_title)) {
- show();
- }
+ setFixedTitleBar();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ if (mIsFixedTitleBar) {
+ int margin = getMeasuredHeight() - calculateEmbeddedHeight();
+ mBaseUi.setContentViewMarginTop(-margin);
+ } else {
+ mBaseUi.setContentViewMarginTop(0);
+ }
+ }
+
+ private void setFixedTitleBar() {
+ boolean isFixed = !mUseQuickControls
+ && !mContext.getResources().getBoolean(R.bool.hide_title);
+ // If getParent() returns null, we are initializing
+ ViewGroup parent = (ViewGroup)getParent();
+ if (mIsFixedTitleBar == isFixed && parent != null) return;
+ mIsFixedTitleBar = isFixed;
+ setSkipTitleBarAnimations(true);
+ show();
+ setSkipTitleBarAnimations(false);
+ if (parent != null) {
+ parent.removeView(this);
+ }
+ if (mIsFixedTitleBar) {
+ mBaseUi.addFixedTitleBar(this);
+ } else {
+ mContentView.addView(this, makeLayoutParams());
+ mBaseUi.setContentViewMarginTop(0);
}
}
@@ -117,6 +146,7 @@
public void setUseQuickControls(boolean use) {
mUseQuickControls = use;
+ setFixedTitleBar();
if (use) {
this.setVisibility(View.GONE);
} else {
@@ -145,23 +175,21 @@
}
void show() {
- if (mUseQuickControls) {
+ cancelTitleBarAnimation(false);
+ if (mUseQuickControls || mSkipTitleBarAnimations) {
this.setVisibility(View.VISIBLE);
this.setTranslationY(0);
} else {
- if (!mSkipTitleBarAnimations) {
- cancelTitleBarAnimation(false);
- int visibleHeight = getVisibleTitleHeight();
- float startPos = (-getEmbeddedHeight() + visibleHeight);
- if (getTranslationY() != 0) {
- startPos = Math.max(startPos, getTranslationY());
- }
- mTitleBarAnimator = ObjectAnimator.ofFloat(this,
- "translationY",
- startPos, 0);
- setupTitleBarAnimator(mTitleBarAnimator);
- mTitleBarAnimator.start();
+ int visibleHeight = getVisibleTitleHeight();
+ float startPos = (-getEmbeddedHeight() + visibleHeight);
+ if (getTranslationY() != 0) {
+ startPos = Math.max(startPos, getTranslationY());
}
+ mTitleBarAnimator = ObjectAnimator.ofFloat(this,
+ "translationY",
+ startPos, 0);
+ setupTitleBarAnimator(mTitleBarAnimator);
+ mTitleBarAnimator.start();
}
mShowing = true;
}
@@ -170,7 +198,7 @@
if (mUseQuickControls) {
this.setVisibility(View.GONE);
} else {
- if (!mContext.getResources().getBoolean(R.bool.hide_title)) return;
+ if (mIsFixedTitleBar) return;
if (!mSkipTitleBarAnimations) {
cancelTitleBarAnimation(false);
int visibleHeight = getVisibleTitleHeight();
@@ -263,7 +291,11 @@
}
public int getEmbeddedHeight() {
- if (mUseQuickControls) return 0;
+ if (mUseQuickControls || mIsFixedTitleBar) return 0;
+ return calculateEmbeddedHeight();
+ }
+
+ private int calculateEmbeddedHeight() {
int height = mNavBar.getHeight();
if (mAutoLogin != null && mAutoLogin.getVisibility() == View.VISIBLE) {
height += mAutoLogin.getHeight();
@@ -397,7 +429,7 @@
}
public void onScrollChanged() {
- if (!mShowing) {
+ if (!mShowing && !mIsFixedTitleBar) {
setTranslationY(getVisibleTitleHeight() - getEmbeddedHeight());
}
}
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index b3d4631..a2946a7 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -59,6 +59,8 @@
void closeTab(Tab tab);
+ void closeOtherTabs();
+
void stopLoading();
Intent createBookmarkCurrentPageIntent(boolean canBeAnEdit);
diff --git a/src/com/android/browser/view/CustomScreenLinearLayout.java b/src/com/android/browser/view/CustomScreenLinearLayout.java
new file mode 100644
index 0000000..f5341e8
--- /dev/null
+++ b/src/com/android/browser/view/CustomScreenLinearLayout.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package com.android.browser.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.LinearLayout;
+
+
+public class CustomScreenLinearLayout extends LinearLayout {
+
+ public CustomScreenLinearLayout(Context context) {
+ super(context);
+ setChildrenDrawingOrderEnabled(true);
+ }
+
+ public CustomScreenLinearLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setChildrenDrawingOrderEnabled(true);
+ }
+
+ public CustomScreenLinearLayout(Context context, AttributeSet attrs,
+ int defStyle) {
+ super(context, attrs, defStyle);
+ setChildrenDrawingOrderEnabled(true);
+ }
+
+ @Override
+ protected int getChildDrawingOrder(int childCount, int i) {
+ return childCount - i - 1;
+ }
+
+}