summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-01-14 11:01:05 -0800
committerJohn Reck <jreck@google.com>2011-01-14 17:37:01 -0800
commitb3417f0a68a1efc64604ea354ae7f856ce79cb16 (patch)
tree455c87606f0f1a97c2c06c7338a5aa29715880e8
parent231f751049febdb0877ead6364d33d130286cff1 (diff)
downloadpackages_apps_Browser-b3417f0a68a1efc64604ea354ae7f856ce79cb16.zip
packages_apps_Browser-b3417f0a68a1efc64604ea354ae7f856ce79cb16.tar.gz
packages_apps_Browser-b3417f0a68a1efc64604ea354ae7f856ce79cb16.tar.bz2
Bookmark UI update
Change-Id: Ibdf7f93f7c5863d7108044dcd40d3866ff02518a
-rw-r--r--res/drawable-mdpi/bookmarks_widget_thumb_selector_longpressed.9.pngbin0 -> 278 bytes
-rw-r--r--res/drawable-nodpi/bg_browser.pngbin0 -> 49620 bytes
-rw-r--r--res/drawable-nodpi/bg_browsertabs.png (renamed from res/drawable-mdpi/bg_browsertabs.png)bin3826 -> 3826 bytes
-rw-r--r--res/drawable/bookmark_list_favicon_bg.xml26
-rw-r--r--res/drawable/bookmark_thumb_selector.xml5
-rw-r--r--res/drawable/bookmark_thumb_selector_transition.xml (renamed from res/menu/bookmark_view.xml)11
-rw-r--r--res/drawable/bookmark_widget_thumb_selector.xml3
-rw-r--r--res/layout/bookmark_list.xml11
-rw-r--r--res/layout/bookmark_thumbnail.xml42
-rw-r--r--res/layout/bookmarks.xml13
-rw-r--r--res/layout/bookmarks_header.xml24
-rw-r--r--res/layout/bookmarks_history.xml100
-rw-r--r--res/layout/bookmarkthumbnailwidget.xml3
-rw-r--r--res/menu/bookmark.xml37
-rw-r--r--res/mipmap-xlarge/ic_launcher_browser.pngbin7531 -> 0 bytes
-rw-r--r--res/mipmap-xlarge/ic_launcher_shortcut_browser_bookmark.pngbin3328 -> 0 bytes
-rw-r--r--res/values-xlarge-port/dimensions.xml2
-rw-r--r--res/values-xlarge/dimensions.xml4
-rw-r--r--res/values/colors.xml1
-rw-r--r--src/com/android/browser/BaseUi.java9
-rw-r--r--src/com/android/browser/BreadCrumbView.java30
-rw-r--r--src/com/android/browser/BrowserActivity.java2
-rw-r--r--src/com/android/browser/BrowserBookmarksAdapter.java19
-rw-r--r--src/com/android/browser/BrowserBookmarksPage.java64
-rw-r--r--src/com/android/browser/BrowserHistoryPage.java1
-rw-r--r--src/com/android/browser/CombinedBookmarkHistoryView.java183
-rw-r--r--src/com/android/browser/Controller.java32
-rw-r--r--src/com/android/browser/OptionsMenuHandler.java27
-rw-r--r--src/com/android/browser/UI.java3
-rw-r--r--src/com/android/browser/UiController.java3
-rw-r--r--src/com/android/browser/XLargeUi.java15
31 files changed, 404 insertions, 266 deletions
diff --git a/res/drawable-mdpi/bookmarks_widget_thumb_selector_longpressed.9.png b/res/drawable-mdpi/bookmarks_widget_thumb_selector_longpressed.9.png
new file mode 100644
index 0000000..2aee937
--- /dev/null
+++ b/res/drawable-mdpi/bookmarks_widget_thumb_selector_longpressed.9.png
Binary files differ
diff --git a/res/drawable-nodpi/bg_browser.png b/res/drawable-nodpi/bg_browser.png
new file mode 100644
index 0000000..c7907d7
--- /dev/null
+++ b/res/drawable-nodpi/bg_browser.png
Binary files differ
diff --git a/res/drawable-mdpi/bg_browsertabs.png b/res/drawable-nodpi/bg_browsertabs.png
index 9d0ff07..15d3365 100644
--- a/res/drawable-mdpi/bg_browsertabs.png
+++ b/res/drawable-nodpi/bg_browsertabs.png
Binary files differ
diff --git a/res/drawable/bookmark_list_favicon_bg.xml b/res/drawable/bookmark_list_favicon_bg.xml
new file mode 100644
index 0000000..3d362e4
--- /dev/null
+++ b/res/drawable/bookmark_list_favicon_bg.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@color/bookmarkListFaviconBackground" />
+ <padding
+ android:left="5dip"
+ android:right="5dip"
+ android:top="5dip"
+ android:bottom="5dip" />
+ <corners android:radius="3dip" />
+</shape>
diff --git a/res/drawable/bookmark_thumb_selector.xml b/res/drawable/bookmark_thumb_selector.xml
index 5219d90..59d9405 100644
--- a/res/drawable/bookmark_thumb_selector.xml
+++ b/res/drawable/bookmark_thumb_selector.xml
@@ -14,8 +14,9 @@
limitations under the License.
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_pressed="true" android:drawable="@drawable/frame_bookmark_thumb_pressed" />
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:exitFadeDuration="@android:integer/config_mediumAnimTime">
+ <item android:state_pressed="true" android:drawable="@drawable/bookmark_thumb_selector_transition" />
<item android:drawable="@android:color/transparent" />
</selector>
diff --git a/res/menu/bookmark_view.xml b/res/drawable/bookmark_thumb_selector_transition.xml
index fdfd672..07ad281 100644
--- a/res/menu/bookmark_view.xml
+++ b/res/drawable/bookmark_thumb_selector_transition.xml
@@ -14,9 +14,8 @@
limitations under the License.
-->
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/thumbnail_view"
- android:title="@string/bookmark_thumbnail_view"/>
- <item android:id="@+id/list_view"
- android:title="@string/bookmark_list_view"/>
-</menu>
+<transition xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:drawable="@drawable/bookmarks_widget_thumb_selector_pressed" />
+ <item android:drawable="@drawable/bookmarks_widget_thumb_selector_longpressed" />
+</transition>
+
diff --git a/res/drawable/bookmark_widget_thumb_selector.xml b/res/drawable/bookmark_widget_thumb_selector.xml
index d9b8171..d34a55d 100644
--- a/res/drawable/bookmark_widget_thumb_selector.xml
+++ b/res/drawable/bookmark_widget_thumb_selector.xml
@@ -14,7 +14,8 @@
limitations under the License.
-->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:state_pressed="true" android:drawable="@drawable/bookmarks_widget_thumb_selector_pressed" />
<item android:drawable="@android:color/transparent" />
</selector>
diff --git a/res/layout/bookmark_list.xml b/res/layout/bookmark_list.xml
index 720685b..7413ca8 100644
--- a/res/layout/bookmark_list.xml
+++ b/res/layout/bookmark_list.xml
@@ -21,20 +21,21 @@
android:layout_height="match_parent"
android:minHeight="@dimen/widgetItemMinHeight"
android:orientation="horizontal"
- android:padding="8dip">
+ android:paddingLeft="16dip">
<ImageView
android:id="@+id/favicon"
- android:layout_height="24dp"
- android:layout_width="24dp"
+ android:layout_height="32dip"
+ android:layout_width="32dip"
android:layout_gravity="center_vertical"
- android:scaleType="fitXY"/>
+ android:background="@drawable/bookmark_list_favicon_bg"
+ android:scaleType="fitXY" />
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceMedium"
- android:padding="8dip"
+ android:paddingLeft="16dip"
android:maxLines="1"
android:scrollHorizontally="true"
android:ellipsize="marquee"/>
diff --git a/res/layout/bookmark_thumbnail.xml b/res/layout/bookmark_thumbnail.xml
index 91d8db7..c545fa4 100644
--- a/res/layout/bookmark_thumbnail.xml
+++ b/res/layout/bookmark_thumbnail.xml
@@ -21,32 +21,42 @@
android:padding="0dip"
>
- <ImageView android:id="@+id/thumb"
+ <ImageView
+ android:id="@+id/thumb"
android:src="@drawable/browser_thumbnail"
android:scaleType="centerCrop"
android:layout_height="@dimen/bookmarkThumbnailHeight"
android:layout_width="@dimen/bookmarkThumbnailWidth"
- android:layout_gravity="center"
+ android:layout_centerHorizontal="true"
+ android:background="@drawable/border_thumb_bookmarks_widget_holo"
+ />
+
+ <ImageView
+ android:id="@+id/divider"
+ android:src="?android:attr/dividerVertical"
+ android:layout_width="wrap_content"
+ android:layout_height="24dip"
+ android:layout_below="@+id/thumb"
+ android:layout_alignLeft="@+id/thumb"
+ android:scaleType="fitXY"
+ android:layout_marginTop="12dip"
/>
<TextView android:id="@+id/label"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="bold"
- android:textColor="@color/white"
- android:maxLines="1"
- android:paddingLeft="2dip"
+ android:layout_height="match_parent"
+ android:layout_toRightOf="@id/divider"
+ android:layout_alignTop="@id/divider"
+ android:layout_alignBottom="@id/divider"
+ android:layout_alignRight="@+id/thumb"
+ android:paddingLeft="8dip"
android:paddingRight="2dip"
- android:paddingTop="0dip"
- android:paddingBottom="0dip"
- android:layout_marginTop="0dip"
- android:scrollHorizontally="true"
+ android:gravity="center_vertical"
+ android:singleLine="true"
android:ellipsize="marquee"
- android:layout_below="@+id/thumb"
- android:layout_alignLeft="@+id/thumb"
- android:layout_alignRight="@+id/thumb"
+ android:typeface="sans"
+ android:textSize="14sp"
+ android:textColor="#AAAAAA"
/>
</RelativeLayout>
diff --git a/res/layout/bookmarks.xml b/res/layout/bookmarks.xml
index 28f83e4..a4a4e04 100644
--- a/res/layout/bookmarks.xml
+++ b/res/layout/bookmarks.xml
@@ -31,21 +31,24 @@
android:layout_height="match_parent">
<GridView
android:id="@+id/grid"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_height="match_parent"
- android:horizontalSpacing="16dip"
- android:verticalSpacing="16dip"
- android:stretchMode="spacingWidth"
+ android:layout_gravity="center_horizontal"
+ android:horizontalSpacing="@dimen/combo_horizontalSpacing"
+ android:verticalSpacing="40dip"
android:scrollbarStyle="insideInset"
android:listSelector="@drawable/bookmark_thumb_selector"
android:drawSelectorOnTop="true"
android:focusable="true"
android:focusableInTouchMode="true"
- android:numColumns="auto_fit" />
+ android:numColumns="auto_fit"
+ android:stretchMode="spacingWidth" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:listSelector="@drawable/bookmark_thumb_selector"
+ android:drawSelectorOnTop="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:visibility="gone"/>
diff --git a/res/layout/bookmarks_header.xml b/res/layout/bookmarks_header.xml
index 5d83892..ba8cf2c 100644
--- a/res/layout/bookmarks_header.xml
+++ b/res/layout/bookmarks_header.xml
@@ -13,25 +13,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<LinearLayout
+
+<com.android.browser.BreadCrumbView
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/crumbs"
android:layout_width="match_parent"
- android:layout_height="48dip"
- android:orientation="horizontal">
-
- <com.android.browser.BreadCrumbView
- android:id="@+id/crumbs"
- android:layout_width="0dip"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:paddingLeft="16dip" />
-
- <TextView
- android:id="@+id/select_bookmark_view"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:text="@string/bookmark_thumbnail_view"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical" />
-
-</LinearLayout>
+ android:layout_height="match_parent" />
diff --git a/res/layout/bookmarks_history.xml b/res/layout/bookmarks_history.xml
index 3294434..9961d6f 100644
--- a/res/layout/bookmarks_history.xml
+++ b/res/layout/bookmarks_history.xml
@@ -13,100 +13,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<LinearLayout
+<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingTop="8dip"
- android:orientation="vertical"
- android:background="@color/black">
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="48dip">
-
- <LinearLayout
- android:id="@+id/tabs"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- style="@style/ActionBarStyle">
- <TextView
- android:id="@+id/bmtab"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="32dip"
- android:paddingRight="32dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:text="@string/bookmarks"
- android:drawableLeft="@drawable/ic_tab_bookmarks_selected"
- android:drawablePadding="16dip"
- android:background="@drawable/tab_background" />
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingTop="8dp"
- android:paddingBottom="8dp"
- android:src="@drawable/divider_vert" />
- <TextView
- android:id="@+id/historytab"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="32dip"
- android:paddingRight="32dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:text="@string/tab_history"
- android:drawableLeft="@drawable/ic_tab_history_selected"
- android:drawablePadding="16dip"
- android:background="@drawable/tab_background" />
- </LinearLayout>
-
- <FrameLayout
- android:id="@+id/header_container"
- android:layout_width="0dip"
- android:layout_weight="1"
- android:layout_height="match_parent" />
-
- <ImageView
- android:id="@+id/seperate_select_add"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingRight="16dip"
- android:paddingLeft="16dip"
- android:src="@drawable/divider_vert" />
-
- <TextView
- android:id="@+id/addbm"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:text="@string/add_new_bookmark"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:background="@null"
- android:drawableLeft="@drawable/ic_favorite_off_normal"
- android:drawablePadding="16dip" />
-
- <ImageView
- android:id="@+id/seperate_select_add"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="16dip"
- android:src="@drawable/divider_vert" />
-
- <ImageView
- android:id="@+id/home"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:src="@drawable/ic_home"
- android:paddingRight="16dip"
- android:paddingLeft="16dip"
- android:scaleType="center" />
-
- </LinearLayout>
- <FrameLayout
- android:id="@+id/fragment"
- android:paddingTop="8dip"
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1.0" />
-</LinearLayout>
+ android:paddingTop="@dimen/combo_paddingTop"
+ android:paddingLeft="@dimen/combo_paddingLeftRight"
+ android:paddingRight="@dimen/combo_paddingLeftRight"
+ android:background="@drawable/bg_browser" />
diff --git a/res/layout/bookmarkthumbnailwidget.xml b/res/layout/bookmarkthumbnailwidget.xml
index e312a2a..12191e8 100644
--- a/res/layout/bookmarkthumbnailwidget.xml
+++ b/res/layout/bookmarkthumbnailwidget.xml
@@ -34,7 +34,8 @@
android:verticalSpacing="@dimen/widgetVerticalSpacing"
android:drawSelectorOnTop="true"
android:listSelector="@drawable/bookmark_widget_thumb_selector"
- android:fadingEdgeLength="24dp" />
+ android:fadingEdgeLength="24dp"
+ android:scrollbarStyle="outsideOverlay" />
<ImageButton
android:id="@+id/app_shortcut"
diff --git a/res/menu/bookmark.xml b/res/menu/bookmark.xml
new file mode 100644
index 0000000..4055b5e
--- /dev/null
+++ b/res/menu/bookmark.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item
+ android:id="@+id/add_bookmark"
+ android:icon="@drawable/ic_favorite_off_normal"
+ android:title="@string/add_new_bookmark"
+ android:showAsAction="always|withText" />
+ <item
+ android:id="@+id/go_home"
+ android:icon="@drawable/ic_home"
+ android:showAsAction="always" />
+ <item
+ android:id="@+id/thumbnail_view"
+ android:title="@string/bookmark_thumbnail_view"/>
+ <item
+ android:id="@+id/list_view"
+ android:title="@string/bookmark_list_view"/>
+ <item
+ android:id="@+id/preferences_menu_id"
+ android:title="@string/menu_preferences"
+ android:alphabeticShortcut="p" />
+</menu>
diff --git a/res/mipmap-xlarge/ic_launcher_browser.png b/res/mipmap-xlarge/ic_launcher_browser.png
deleted file mode 100644
index 2ca92c8..0000000
--- a/res/mipmap-xlarge/ic_launcher_browser.png
+++ /dev/null
Binary files differ
diff --git a/res/mipmap-xlarge/ic_launcher_shortcut_browser_bookmark.png b/res/mipmap-xlarge/ic_launcher_shortcut_browser_bookmark.png
deleted file mode 100644
index 7b2c680..0000000
--- a/res/mipmap-xlarge/ic_launcher_shortcut_browser_bookmark.png
+++ /dev/null
Binary files differ
diff --git a/res/values-xlarge-port/dimensions.xml b/res/values-xlarge-port/dimensions.xml
index e6b59ce..f891396 100644
--- a/res/values-xlarge-port/dimensions.xml
+++ b/res/values-xlarge-port/dimensions.xml
@@ -14,4 +14,6 @@
<dimen name="widgetThumbnailHeight">84dip</dimen>
<dimen name="widgetHorizontalSpacing">10dip</dimen>
<dimen name="widgetVerticalSpacing">10dip</dimen>
+ <dimen name="combo_paddingLeftRight">16dip</dimen>
+ <dimen name="combo_horizontalSpacing">8dip</dimen>
</resources>
diff --git a/res/values-xlarge/dimensions.xml b/res/values-xlarge/dimensions.xml
index 6aa83d2..05a4087 100644
--- a/res/values-xlarge/dimensions.xml
+++ b/res/values-xlarge/dimensions.xml
@@ -22,4 +22,8 @@
<dimen name="mv_item_width">231dp</dimen>
<dimen name="mv_item_width_portrait">213dp</dimen>
<dimen name="mv_border_width">3dp</dimen>
+ <!-- For the combined Bookmarks History view -->
+ <dimen name="combo_paddingTop">50dip</dimen>
+ <dimen name="combo_paddingLeftRight">134dip</dimen>
+ <dimen name="combo_horizontalSpacing">20dip</dimen>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 834bead..835f3ba 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -32,4 +32,5 @@
<color name="qc_slice_normal">#E0A0A0A0</color>
<color name="qc_slice_active">#E02090FF</color>
<color name="bookmarkWidgetFaviconBackground">#23ffffff</color>
+ <color name="bookmarkListFaviconBackground">#23ffffff</color>
</resources>
diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java
index 7e0c5da..5ccfdda 100644
--- a/src/com/android/browser/BaseUi.java
+++ b/src/com/android/browser/BaseUi.java
@@ -30,7 +30,6 @@ import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@@ -38,7 +37,6 @@ import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebChromeClient;
-import android.webkit.WebHistoryItem;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@@ -455,6 +453,7 @@ public abstract class BaseUi implements UI, WebViewFactory {
if (mActiveTab != null) {
mActiveTab.putInForeground();
}
+ mActivity.invalidateOptionsMenu();
}
@Override
@@ -638,12 +637,6 @@ public abstract class BaseUi implements UI, WebViewFactory {
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
- @Override
- public void onPrepareOptionsMenu(Menu menu) {
- final MenuItem newtab = menu.findItem(R.id.new_tab_menu_id);
- newtab.setEnabled(mUiController.getTabControl().canCreateNewTab());
- }
-
// -------------------------------------------------------------------------
// Helper function for WebChromeClient
// -------------------------------------------------------------------------
diff --git a/src/com/android/browser/BreadCrumbView.java b/src/com/android/browser/BreadCrumbView.java
index 113d55b..b8409f0 100644
--- a/src/com/android/browser/BreadCrumbView.java
+++ b/src/com/android/browser/BreadCrumbView.java
@@ -17,6 +17,7 @@
package com.android.browser;
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -37,6 +38,7 @@ import java.util.List;
* Use pushView, popView, clear, and getTopData to change/access the view stack
*/
public class BreadCrumbView extends LinearLayout implements OnClickListener {
+ private static final int DIVIDER_PADDING = 12; // dips
interface Controller {
public void onTop(int level, Object data);
@@ -47,6 +49,7 @@ public class BreadCrumbView extends LinearLayout implements OnClickListener {
private List<Crumb> mCrumbs;
private boolean mUseBackButton;
private Drawable mSeparatorDrawable;
+ private float mDividerPadding;
private int mMaxVisible = -1;
/**
@@ -79,8 +82,10 @@ public class BreadCrumbView extends LinearLayout implements OnClickListener {
private void init(Context ctx) {
mUseBackButton = false;
mCrumbs = new ArrayList<Crumb>();
- mSeparatorDrawable = ctx.getResources().getDrawable(
- R.drawable.crumb_divider);
+ TypedArray a = ctx.obtainStyledAttributes(com.android.internal.R.styleable.Theme);
+ mSeparatorDrawable = a.getDrawable(com.android.internal.R.styleable.Theme_dividerVertical);
+ a.recycle();
+ mDividerPadding = DIVIDER_PADDING * ctx.getResources().getDisplayMetrics().density;
addBackButton();
}
@@ -176,13 +181,26 @@ public class BreadCrumbView extends LinearLayout implements OnClickListener {
}
private void addSeparator() {
- ImageView sep = new ImageView(mContext);
- sep.setImageDrawable(mSeparatorDrawable);
- sep.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
- LayoutParams.MATCH_PARENT));
+ View sep = makeDividerView();
+ sep.setLayoutParams(makeDividerLayoutParams());
addView(sep);
}
+ private ImageView makeDividerView() {
+ ImageView result = new ImageView(mContext);
+ result.setImageDrawable(mSeparatorDrawable);
+ result.setScaleType(ImageView.ScaleType.FIT_XY);
+ return result;
+ }
+
+ private LayoutParams makeDividerLayoutParams() {
+ LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
+ LayoutParams.MATCH_PARENT);
+ params.topMargin = (int) mDividerPadding;
+ params.bottomMargin = (int) mDividerPadding;
+ return params;
+ }
+
private void pop(boolean notify) {
int n = mCrumbs.size();
if (n > 0) {
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 018744d..a67b4e6 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -252,7 +252,7 @@ public class BrowserActivity extends Activity {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
- return mController.prepareOptionsMenu(menu);
+ return mController.onPrepareOptionsMenu(menu);
}
@Override
diff --git a/src/com/android/browser/BrowserBookmarksAdapter.java b/src/com/android/browser/BrowserBookmarksAdapter.java
index c680a88..26ba62c 100644
--- a/src/com/android/browser/BrowserBookmarksAdapter.java
+++ b/src/com/android/browser/BrowserBookmarksAdapter.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.drawable.PaintDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -30,6 +31,7 @@ import android.widget.TextView;
class BrowserBookmarksAdapter extends CursorAdapter {
LayoutInflater mInflater;
int mCurrentView;
+ PaintDrawable mFaviconBackground;
/**
* Create a new BrowserBookmarksAdapter.
@@ -37,9 +39,16 @@ class BrowserBookmarksAdapter extends CursorAdapter {
public BrowserBookmarksAdapter(Context context, int defaultView) {
// Make sure to tell the CursorAdapter to avoid the observer and auto-requery
// since the Loader will do that for us.
- super(context, null);
+ super(context, null, 0);
mInflater = LayoutInflater.from(context);
selectView(defaultView);
+ float density = context.getResources().getDisplayMetrics().density;
+ mFaviconBackground = new PaintDrawable();
+ int padding = (int) (5 * density);
+ mFaviconBackground.setPadding(padding, padding, padding, padding);
+ mFaviconBackground.getPaint().setColor(context.getResources()
+ .getColor(R.color.bookmarkListFaviconBackground));
+ mFaviconBackground.setCornerRadius(3 * density);
}
@Override
@@ -58,7 +67,8 @@ class BrowserBookmarksAdapter extends CursorAdapter {
tv.setText(cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE));
if (cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0) {
// folder
- thumb.setImageResource(R.drawable.ic_folder);
+ thumb.setImageResource(R.drawable.thumb_bookmark_widget_folder_holo);
+ thumb.setBackgroundDrawable(null);
} else {
byte[] thumbData = cursor.getBlob(BookmarksLoader.COLUMN_INDEX_THUMBNAIL);
Bitmap thumbBitmap = null;
@@ -71,6 +81,7 @@ class BrowserBookmarksAdapter extends CursorAdapter {
} else {
thumb.setImageBitmap(thumbBitmap);
}
+ thumb.setBackgroundResource(R.drawable.border_thumb_bookmarks_widget_holo);
}
}
@@ -82,6 +93,7 @@ class BrowserBookmarksAdapter extends CursorAdapter {
if (cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0) {
// folder
favicon.setImageResource(R.drawable.ic_folder_bookmark_widget_holo_dark);
+ favicon.setBackgroundDrawable(null);
} else {
byte[] faviconData = cursor.getBlob(BookmarksLoader.COLUMN_INDEX_FAVICON);
Bitmap faviconBitmap = null;
@@ -94,6 +106,9 @@ class BrowserBookmarksAdapter extends CursorAdapter {
} else {
favicon.setImageBitmap(faviconBitmap);
}
+ //favicon.setBackgroundResource(R.drawable.bookmark_list_favicon_bg);
+ // TODO: Switch to above instead of below once b/3353813 is fixed
+ favicon.setBackgroundDrawable(mFaviconBackground);
}
}
diff --git a/src/com/android/browser/BrowserBookmarksPage.java b/src/com/android/browser/BrowserBookmarksPage.java
index d5a5182..2df0561 100644
--- a/src/com/android/browser/BrowserBookmarksPage.java
+++ b/src/com/android/browser/BrowserBookmarksPage.java
@@ -33,6 +33,8 @@ import android.content.Intent;
import android.content.Loader;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -47,10 +49,10 @@ import android.text.TextUtils;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
+import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebIconDatabase.IconListener;
import android.widget.Adapter;
@@ -60,7 +62,6 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.PopupMenu.OnMenuItemClickListener;
-import android.widget.TextView;
import android.widget.Toast;
interface BookmarksPageCallbacks {
@@ -76,7 +77,7 @@ interface BookmarksPageCallbacks {
*/
public class BrowserBookmarksPage extends Fragment implements View.OnCreateContextMenuListener,
LoaderManager.LoaderCallbacks<Cursor>, OnItemClickListener, IconListener,
- OnItemSelectedListener, BreadCrumbView.Controller, OnClickListener, OnMenuItemClickListener {
+ OnItemSelectedListener, BreadCrumbView.Controller, OnMenuItemClickListener {
static final String LOGTAG = "browser";
@@ -108,7 +109,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
View mHeader;
ViewGroup mHeaderContainer;
BreadCrumbView mCrumbs;
- TextView mSelectBookmarkView;
int mCrumbVisibility = View.VISIBLE;
int mCrumbMaxVisible = -1;
boolean mCrumbBackButton = false;
@@ -339,6 +339,11 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
};
@Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ inflater.inflate(R.menu.bookmark, menu);
+ }
+
+ @Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Cursor cursor = mAdapter.getItem(info.position);
@@ -401,6 +406,8 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ setHasOptionsMenu(true);
+
Bundle args = getArguments();
mDisableNewWindow = args == null ? false : args.getBoolean(EXTRA_DISABLE_WINDOW, false);
}
@@ -438,19 +445,12 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
if (mCallbacks != null) {
mCallbacks.onFolderChanged(1, BrowserContract.Bookmarks.CONTENT_URI_DEFAULT_FOLDER);
}
- mSelectBookmarkView = (TextView) mHeader.findViewById(R.id.select_bookmark_view);
- mSelectBookmarkView.setOnClickListener(this);
// Start the loaders
LoaderManager lm = getLoaderManager();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
mCurrentView =
prefs.getInt(PREF_SELECTED_VIEW, BrowserBookmarksPage.VIEW_THUMBNAILS);
- if (mCurrentView == BrowserBookmarksPage.VIEW_THUMBNAILS) {
- mSelectBookmarkView.setText(R.string.bookmark_list_view);
- } else {
- mSelectBookmarkView.setText(R.string.bookmark_thumbnail_view);
- }
mAdapter = new BrowserBookmarksAdapter(getActivity(), mCurrentView);
String accountType = prefs.getString(PREF_ACCOUNT_TYPE, DEFAULT_ACCOUNT);
String accountName = prefs.getString(PREF_ACCOUNT_NAME, DEFAULT_ACCOUNT);
@@ -650,16 +650,39 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
cm.setPrimaryClip(ClipData.newRawUri(null, null, Uri.parse(text.toString())));
}
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.thumbnail_view:
+ selectView(VIEW_THUMBNAILS);
+ return true;
+ case R.id.list_view:
+ selectView(VIEW_LIST);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ Resources res = getActivity().getResources();
+ int horizontalSpacing = (int) res.getDimension(R.dimen.combo_horizontalSpacing);
+ mGrid.setHorizontalSpacing(horizontalSpacing);
+ }
+
+ @Override
+ public void onPrepareOptionsMenu(Menu menu) {
+ super.onPrepareOptionsMenu(menu);
+ menu.findItem(R.id.list_view).setVisible(mCurrentView != VIEW_LIST);
+ menu.findItem(R.id.thumbnail_view).setVisible(mCurrentView != VIEW_THUMBNAILS);
+ }
+
void selectView(int view) {
if (view == mCurrentView) {
return;
}
mCurrentView = view;
- if (mCurrentView == BrowserBookmarksPage.VIEW_THUMBNAILS) {
- mSelectBookmarkView.setText(R.string.bookmark_list_view);
- } else {
- mSelectBookmarkView.setText(R.string.bookmark_thumbnail_view);
- }
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
Editor edit = prefs.edit();
edit.putInt(PREF_SELECTED_VIEW, mCurrentView);
@@ -716,15 +739,6 @@ public class BrowserBookmarksPage extends Fragment implements View.OnCreateConte
}
@Override
- public void onClick(View view) {
- if (mSelectBookmarkView == view) {
- selectView(mCurrentView == BrowserBookmarksPage.VIEW_LIST
- ? BrowserBookmarksPage.VIEW_THUMBNAILS
- : BrowserBookmarksPage.VIEW_LIST);
- }
- }
-
- @Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.list_view:
diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java
index 41d3749..87649d4 100644
--- a/src/com/android/browser/BrowserHistoryPage.java
+++ b/src/com/android/browser/BrowserHistoryPage.java
@@ -41,7 +41,6 @@ import android.preference.PreferenceManager;
import android.provider.Browser;
import android.provider.BrowserContract;
import android.provider.BrowserContract.Combined;
-import android.text.TextUtils;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
diff --git a/src/com/android/browser/CombinedBookmarkHistoryView.java b/src/com/android/browser/CombinedBookmarkHistoryView.java
index 0f12353..f4b2e9c 100644
--- a/src/com/android/browser/CombinedBookmarkHistoryView.java
+++ b/src/com/android/browser/CombinedBookmarkHistoryView.java
@@ -17,10 +17,13 @@
package com.android.browser;
+import android.app.ActionBar;
+import android.app.ActionBar.Tab;
+import android.app.ActionBar.TabListener;
import android.app.Activity;
-import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
@@ -28,16 +31,18 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Browser;
+import android.view.Gravity;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.webkit.WebIconDatabase;
import android.webkit.WebIconDatabase.IconListener;
+import android.widget.FrameLayout;
import android.widget.LinearLayout;
-import android.widget.TextView;
import java.util.HashMap;
import java.util.Vector;
@@ -48,7 +53,7 @@ interface BookmarksHistoryCallbacks {
}
public class CombinedBookmarkHistoryView extends LinearLayout
- implements OnClickListener, OnTouchListener {
+ implements OnTouchListener, TabListener, OptionsMenuHandler {
final static String STARTING_FRAGMENT = "fragment";
@@ -57,18 +62,15 @@ public class CombinedBookmarkHistoryView extends LinearLayout
private UiController mUiController;
private Activity mActivity;
+ private ActionBar mActionBar;
private Bundle mExtras;
- long mCurrentFragment;
+ int mCurrentFragment;
- View mTabs;
- TextView mTabBookmarks;
- TextView mTabHistory;
- TextView mAddBookmark;
- View mSeperateSelectAdd;
+ ActionBar.Tab mTabBookmarks;
+ ActionBar.Tab mTabHistory;
ViewGroup mBookmarksHeader;
- View mHome;
BrowserBookmarksPage mBookmarks;
BrowserHistoryPage mHistory;
@@ -116,27 +118,22 @@ public class CombinedBookmarkHistoryView extends LinearLayout
mUiController = controller;
mActivity = activity;
mExtras = extras;
+ mActionBar = mActivity.getActionBar();
+
View v = LayoutInflater.from(activity).inflate(R.layout.bookmarks_history, this);
v.setOnTouchListener(this);
Resources res = activity.getResources();
// setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
- mTabs = findViewById(R.id.tabs);
- mBookmarksHeader = (ViewGroup) findViewById(R.id.header_container);
-
- mTabBookmarks = (TextView) findViewById(R.id.bmtab);
- mTabHistory = (TextView) findViewById(R.id.historytab);
- mAddBookmark = (TextView) findViewById(R.id.addbm);
- mSeperateSelectAdd = findViewById(R.id.seperate_select_add);
- mHome = findViewById(R.id.home);
- mAddBookmark.setOnClickListener(this);
- mTabHistory.setOnClickListener(this);
- mTabBookmarks.setOnClickListener(this);
- mHome.setOnClickListener(this);
+ mBookmarksHeader = new FrameLayout(mActivity);
+ mBookmarksHeader.setLayoutParams(new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.WRAP_CONTENT,
+ FrameLayout.LayoutParams.MATCH_PARENT,
+ Gravity.CENTER_VERTICAL));
+
// Start up the default fragment
initFragments(mExtras);
- loadFragment(startingFragment, mExtras, false);
// XXX: Must do this before launching the AsyncTask to avoid a
// potential crash if the icon database has not been created.
@@ -153,6 +150,36 @@ public class CombinedBookmarkHistoryView extends LinearLayout
}
}).execute();
+ setupActionBar(startingFragment);
+ mUiController.registerOptionsMenuHandler(this);
+ }
+
+ void setupActionBar(int startingFragment) {
+ mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME
+ | ActionBar.DISPLAY_USE_LOGO);
+ mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ mActionBar.removeAllTabs();
+ mTabBookmarks = mActionBar.newTab();
+ mTabBookmarks.setText(R.string.tab_bookmarks);
+ mTabBookmarks.setTabListener(this);
+ mActionBar.addTab(mTabBookmarks, FRAGMENT_ID_BOOKMARKS == startingFragment);
+ mTabHistory = mActionBar.newTab();
+ mTabHistory.setText(R.string.tab_history);
+ mTabHistory.setTabListener(this);
+ mActionBar.addTab(mTabHistory, FRAGMENT_ID_HISTORY == startingFragment);
+ mActionBar.setCustomView(mBookmarksHeader);
+
+ }
+
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ Resources res = mContext.getResources();
+ int paddingLeftRight = (int) res.getDimension(R.dimen.combo_paddingLeftRight);
+ int paddingTop = (int) res.getDimension(R.dimen.combo_paddingTop);
+ findViewById(R.id.fragment).setPadding(paddingLeftRight, paddingTop,
+ paddingLeftRight, 0);
}
private BookmarksPageCallbacks mBookmarkCallbackWrapper = new BookmarksPageCallbacks() {
@@ -173,13 +200,15 @@ public class CombinedBookmarkHistoryView extends LinearLayout
@Override
public void onFolderChanged(int level, Uri uri) {
+ final int toggleFlags = ActionBar.DISPLAY_SHOW_CUSTOM
+ | ActionBar.DISPLAY_HOME_AS_UP;
// 1 is "bookmarks" root folder
if (level <= 1) {
- mTabs.setVisibility(View.VISIBLE);
- mBookmarks.setBreadCrumbVisibility(View.INVISIBLE);
+ mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ mActionBar.setDisplayOptions(0, toggleFlags);
} else {
- mTabs.setVisibility(View.GONE);
- mBookmarks.setBreadCrumbVisibility(View.VISIBLE);
+ mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
+ mActionBar.setDisplayOptions(toggleFlags, toggleFlags);
}
}
};
@@ -188,39 +217,24 @@ public class CombinedBookmarkHistoryView extends LinearLayout
mBookmarks = BrowserBookmarksPage.newInstance(mBookmarkCallbackWrapper,
extras, mBookmarksHeader);
mBookmarks.setBreadCrumbMaxVisible(2);
- mBookmarks.setBreadCrumbUseBackButton(true);
+ mBookmarks.setBreadCrumbUseBackButton(false);
mHistory = BrowserHistoryPage.newInstance(mUiController, extras);
}
- private void loadFragment(int id, Bundle extras, boolean notify) {
- String fragmentClassName;
- Fragment fragment = null;
+ private void loadFragment(int id, FragmentTransaction ft) {
+ if (mCurrentFragment == id) return;
+
switch (id) {
case FRAGMENT_ID_BOOKMARKS:
- fragment = mBookmarks;
- mSeperateSelectAdd.setVisibility(View.VISIBLE);
- mBookmarksHeader.setVisibility(View.VISIBLE);
- mAddBookmark.setVisibility(View.VISIBLE);
- mTabBookmarks.setActivated(true);
- mTabHistory.setActivated(false);
+ ft.replace(R.id.fragment, mBookmarks);
break;
case FRAGMENT_ID_HISTORY:
- fragment = mHistory;
- mBookmarksHeader.setVisibility(View.INVISIBLE);
- mSeperateSelectAdd.setVisibility(View.INVISIBLE);
- mAddBookmark.setVisibility(View.INVISIBLE);
- mTabBookmarks.setActivated(false);
- mTabHistory.setActivated(true);
+ ft.replace(R.id.fragment, mHistory);
break;
default:
throw new IllegalArgumentException();
}
mCurrentFragment = id;
-
- FragmentManager fm = mActivity.getFragmentManager();
- FragmentTransaction transaction = fm.openTransaction();
- transaction.replace(R.id.fragment, fragment);
- transaction.commit();
}
@Override
@@ -234,22 +248,7 @@ public class CombinedBookmarkHistoryView extends LinearLayout
transaction.remove(mHistory);
}
transaction.commit();
- }
-
- @Override
- public void onClick(View view) {
- if ((mTabHistory == view) && (mCurrentFragment != FRAGMENT_ID_HISTORY)) {
- loadFragment(FRAGMENT_ID_HISTORY, mExtras, false);
- } else if (mTabBookmarks == view) {
- if (mCurrentFragment != FRAGMENT_ID_BOOKMARKS) {
- loadFragment(FRAGMENT_ID_BOOKMARKS, mExtras, true);
- }
- } else if (mAddBookmark == view) {
- mUiController.bookmarkCurrentPage(mBookmarks.getFolderId());
- } else if (mHome == view) {
- BrowserSettings settings = BrowserSettings.getInstance();
- mUiController.onUrlSelected(settings.getHomePage(), false);
- }
+ mUiController.unregisterOptionsMenuHandler(this);
}
/**
@@ -270,4 +269,58 @@ public class CombinedBookmarkHistoryView extends LinearLayout
public boolean onTouch(View v, MotionEvent event) {
return true;
}
+
+ @Override
+ public void onTabReselected(Tab tab, FragmentTransaction ft) {
+ // Ignore
+ }
+
+ @Override
+ public void onTabSelected(Tab tab, FragmentTransaction ft) {
+ if (tab == mTabBookmarks) {
+ loadFragment(FRAGMENT_ID_BOOKMARKS, ft);
+ } else if (tab == mTabHistory) {
+ loadFragment(FRAGMENT_ID_HISTORY, ft);
+ }
+ }
+
+ @Override
+ public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+ // Ignore
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Handled by fragment
+ return false;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ // Handled by fragment
+ return false;
+ }
+
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ mUiController.getUi().onBackKey();
+ return true;
+ case R.id.go_home:
+ BrowserSettings settings = BrowserSettings.getInstance();
+ mUiController.onUrlSelected(settings.getHomePage(), false);
+ return true;
+ case R.id.add_bookmark:
+ mUiController.bookmarkCurrentPage(mBookmarks.getFolderId());
+ return true;
+ }
+
+ switch (mCurrentFragment) {
+ case FRAGMENT_ID_BOOKMARKS:
+ return mBookmarks.onOptionsItemSelected(item);
+ case FRAGMENT_ID_HISTORY:
+ return mHistory.onOptionsItemSelected(item);
+ }
+ return false;
+ }
}
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index fe19927..6c6fe0b 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -137,6 +137,7 @@ public class Controller
private TabControl mTabControl;
private BrowserSettings mSettings;
private WebViewFactory mFactory;
+ private OptionsMenuHandler mOptionsMenuHandler = null;
private WakeLock mWakeLock;
@@ -1186,6 +1187,10 @@ public class Controller
// TODO: maybe put into separate handler
protected boolean onCreateOptionsMenu(Menu menu) {
+ if (mOptionsMenuHandler != null) {
+ return mOptionsMenuHandler.onCreateOptionsMenu(menu);
+ }
+
if (mMenuState == EMPTY_MENU) {
return false;
}
@@ -1379,7 +1384,10 @@ public class Controller
}
}
- boolean prepareOptionsMenu(Menu menu) {
+ boolean onPrepareOptionsMenu(Menu menu) {
+ if (mOptionsMenuHandler != null) {
+ return mOptionsMenuHandler.onPrepareOptionsMenu(menu);
+ }
// This happens when the user begins to hold down the menu key, so
// allow them to chord to get a shortcut.
mCanChord = true;
@@ -1436,8 +1444,8 @@ public class Controller
counter.setVisible(showDebugSettings);
counter.setEnabled(showDebugSettings);
- // allow the ui to adjust state based settings
- mUi.onPrepareOptionsMenu(menu);
+ final MenuItem newtab = menu.findItem(R.id.new_tab_menu_id);
+ newtab.setEnabled(getTabControl().canCreateNewTab());
break;
}
@@ -1446,6 +1454,11 @@ public class Controller
}
public boolean onOptionsItemSelected(MenuItem item) {
+ if (mOptionsMenuHandler != null &&
+ mOptionsMenuHandler.onOptionsItemSelected(item)) {
+ return true;
+ }
+
if (item.getGroupId() != R.id.CONTEXT_MENU) {
// menu remains active, so ensure comboview is dismissed
// if main menu option is selected
@@ -2517,4 +2530,17 @@ public class Controller
mAutoFillSetupMessage = message;
mActivity.startActivityForResult(intent, AUTOFILL_SETUP);
}
+
+ @Override
+ public void registerOptionsMenuHandler(OptionsMenuHandler handler) {
+ mOptionsMenuHandler = handler;
+ }
+
+ @Override
+ public void unregisterOptionsMenuHandler(OptionsMenuHandler handler) {
+ if (mOptionsMenuHandler == handler) {
+ mOptionsMenuHandler = null;
+ }
+ }
+
}
diff --git a/src/com/android/browser/OptionsMenuHandler.java b/src/com/android/browser/OptionsMenuHandler.java
new file mode 100644
index 0000000..d602c7d
--- /dev/null
+++ b/src/com/android/browser/OptionsMenuHandler.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 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;
+
+import android.view.Menu;
+import android.view.MenuItem;
+
+public interface OptionsMenuHandler {
+
+ boolean onCreateOptionsMenu(Menu menu);
+ boolean onPrepareOptionsMenu(Menu menu);
+ boolean onOptionsItemSelected(MenuItem item);
+}
diff --git a/src/com/android/browser/UI.java b/src/com/android/browser/UI.java
index e2f76f1..4738522 100644
--- a/src/com/android/browser/UI.java
+++ b/src/com/android/browser/UI.java
@@ -88,9 +88,6 @@ public interface UI {
public void revertVoiceTitleBar(Tab tab);
- // allow the ui to update state
- public void onPrepareOptionsMenu(Menu menu);
-
public void onOptionsMenuOpened();
public void onExtendedMenuOpened();
diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java
index 68a32d3..ae38cff 100644
--- a/src/com/android/browser/UiController.java
+++ b/src/com/android/browser/UiController.java
@@ -79,4 +79,7 @@ public interface UiController extends BookmarksHistoryCallbacks {
void shareCurrentPage();
+ void registerOptionsMenuHandler(OptionsMenuHandler handler);
+
+ void unregisterOptionsMenuHandler(OptionsMenuHandler handler);
}
diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java
index 1e607a7..9b344ec 100644
--- a/src/com/android/browser/XLargeUi.java
+++ b/src/com/android/browser/XLargeUi.java
@@ -20,7 +20,6 @@ import com.android.browser.ScrollWebView.ScrollListener;
import android.app.ActionBar;
import android.app.Activity;
-import android.graphics.Bitmap;
import android.util.Log;
import android.view.ActionMode;
import android.view.Gravity;
@@ -61,9 +60,21 @@ public class XLargeUi extends BaseUi implements ScrollListener {
mFakeTitleBar.setEditable(true);
mTabBar = new TabBar(mActivity, mUiController, this);
mActionBar = mActivity.getActionBar();
+ setupActionBar();
+ setUseQuickControls(BrowserSettings.getInstance().useQuickControls());
+ }
+
+ private void setupActionBar() {
+ mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
mActionBar.setCustomView(mTabBar);
- setUseQuickControls(BrowserSettings.getInstance().useQuickControls());
+ }
+
+ @Override
+ public void hideComboView() {
+ super.hideComboView();
+ // ComboView changes the action bar, set it back up to what we want
+ setupActionBar();
}
private void setUseQuickControls(boolean useQuickControls) {