Refactor Bookmark fragment, fixes NPE
Bug: 2926451
This change refactors the BrowserBookmarkPage fragment for better
encapsulation, and updates the CombinedBookmarkHistoryView and
ShortcutActivity. ShortcutActivity now supports folder navigation
as well as toggling list or thumbnail view.
Change-Id: Ie8168467e793d60d75c15746f81318cfa7e9f003
diff --git a/res/layout/bookmarks.xml b/res/layout/bookmarks.xml
index 66a78e8..7a0aa23 100644
--- a/res/layout/bookmarks.xml
+++ b/res/layout/bookmarks.xml
@@ -14,36 +14,49 @@
limitations under the License.
-->
-<FrameLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
- <GridView
- android:id="@+id/grid"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <FrameLayout
+ android:id="@+id/header_container"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:horizontalSpacing="16dip"
- android:verticalSpacing="16dip"
- android:stretchMode="spacingWidth"
- android:scrollbarStyle="insideInset"
- android:listSelector="@android:drawable/gallery_thumb"
- android:drawSelectorOnTop="true"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:numColumns="auto_fit" />
- <ListView
- android:id="@+id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:visibility="gone"/>
- <TextView
- android:id="@android:id/empty"
- android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:text="@string/empty_bookmarks_folder"
android:visibility="gone" />
-</FrameLayout>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <GridView
+ android:id="@+id/grid"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:horizontalSpacing="16dip"
+ android:verticalSpacing="16dip"
+ android:stretchMode="spacingWidth"
+ android:scrollbarStyle="insideInset"
+ android:listSelector="@android:drawable/gallery_thumb"
+ android:drawSelectorOnTop="true"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:numColumns="auto_fit" />
+ <ListView
+ android:id="@+id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:focusable="true"
+ android:focusableInTouchMode="true"
+ android:visibility="gone"/>
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:text="@string/empty_bookmarks_folder"
+ android:visibility="gone" />
+ </FrameLayout>
+
+</LinearLayout>
diff --git a/res/layout/bookmarks_header.xml b/res/layout/bookmarks_header.xml
new file mode 100644
index 0000000..597e629
--- /dev/null
+++ b/res/layout/bookmarks_header.xml
@@ -0,0 +1,49 @@
+<?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.
+-->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="48dip"
+ android:orientation="horizontal">
+
+ <TextView
+ android:id="@+id/root_folder"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:text="@string/defaultBookmarksUpButton"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:gravity="center_vertical"
+ android:visibility="gone"
+ android:paddingLeft="16dip"
+ android:drawableLeft="@drawable/ic_tab_bookmarks_selected"
+ android:drawablePadding="16dip" />
+
+ <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/switch_to_thumbnails"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:gravity="center_vertical" />
+
+</LinearLayout>
diff --git a/res/layout/bookmarks_history.xml b/res/layout/bookmarks_history.xml
index b8ccfe7..a3a5084 100644
--- a/res/layout/bookmarks_history.xml
+++ b/res/layout/bookmarks_history.xml
@@ -22,16 +22,14 @@
android:paddingRight="16dip"
android:orientation="vertical"
android:background="@color/black">
- <RelativeLayout
- android:id="@+id/bar"
+ <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"
- android:paddingLeft="16dip"
- android:paddingRight="16dip">
+ android:layout_height="match_parent">
<TextView
android:id="@+id/historytab"
android:layout_width="wrap_content"
@@ -58,42 +56,34 @@
android:text="@string/bookmarks"
android:drawableLeft="@drawable/ic_tab_bookmarks_selected"
android:drawablePadding="16dip" />
- <com.android.browser.BreadCrumbView
- android:id="@+id/crumbs"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingLeft="16dip"
- android:paddingRight="16dip" />
</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:layout_alignParentRight="true"
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:layout_toLeftOf="@id/addbm"
- android:paddingRight="16dip"
- android:src="@drawable/divider_vert" />
- <TextView
- android:id="@+id/select_bookmark_view"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:text="@string/switch_to_thumbnails"
- android:layout_toLeftOf="@id/seperate_select_add"
- android:paddingRight="16dip"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:background="@null" />
- </RelativeLayout>
+
+ </LinearLayout>
<FrameLayout
android:id="@+id/fragment"
android:paddingTop="8dip"