diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 2bf6155554e..989822ff454 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -635,6 +635,7 @@ RES_DRAWABLE_MDPI = \ res/drawable-mdpi/ic_url_bar_search.png \ res/drawable-mdpi/ic_url_bar_star.png \ res/drawable-mdpi/ic_url_bar_tab.png \ + res/drawable-mdpi/icon_bookmarks_empty.png \ res/drawable-mdpi/icon_last_tabs.png \ res/drawable-mdpi/icon_last_tabs_empty.png \ res/drawable-mdpi/icon_most_recent.png \ @@ -752,6 +753,7 @@ RES_DRAWABLE_HDPI = \ res/drawable-hdpi/ic_url_bar_search.png \ res/drawable-hdpi/ic_url_bar_star.png \ res/drawable-hdpi/ic_url_bar_tab.png \ + res/drawable-hdpi/icon_bookmarks_empty.png \ res/drawable-hdpi/icon_last_tabs.png \ res/drawable-hdpi/icon_last_tabs_empty.png \ res/drawable-hdpi/icon_most_recent.png \ @@ -855,6 +857,7 @@ RES_DRAWABLE_XHDPI = \ res/drawable-xhdpi/ic_url_bar_search.png \ res/drawable-xhdpi/ic_url_bar_star.png \ res/drawable-xhdpi/ic_url_bar_tab.png \ + res/drawable-xhdpi/icon_bookmarks_empty.png \ res/drawable-xhdpi/icon_last_tabs.png \ res/drawable-xhdpi/icon_last_tabs_empty.png \ res/drawable-xhdpi/icon_most_recent.png \ diff --git a/mobile/android/base/home/BookmarksPage.java b/mobile/android/base/home/BookmarksPage.java index cc762cf8d66..7b647d1c1e2 100644 --- a/mobile/android/base/home/BookmarksPage.java +++ b/mobile/android/base/home/BookmarksPage.java @@ -20,7 +20,10 @@ import android.support.v4.app.LoaderManager.LoaderCallbacks; import android.support.v4.content.Loader; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewStub; import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; /** * A page in about:home that displays a ListView of bookmarks. @@ -40,6 +43,9 @@ public class BookmarksPage extends HomeFragment { // Adapter for list of bookmarks. private BookmarksListAdapter mListAdapter; + // Reference to the View to display when there are no results. + private View mEmptyView; + // Callback for cursor loaders. private CursorLoaderCallbacks mLoaderCallbacks; @@ -102,6 +108,7 @@ public class BookmarksPage extends HomeFragment { public void onDestroyView() { mList = null; mListAdapter = null; + mEmptyView = null; super.onDestroyView(); } @@ -130,6 +137,22 @@ public class BookmarksPage extends HomeFragment { getLoaderManager().initLoader(LOADER_ID_BOOKMARKS_LIST, null, mLoaderCallbacks); } + private void updateUiFromCursor(Cursor c) { + if ((c == null || c.getCount() == 0) && mEmptyView == null) { + // Set empty page view. We delay this so that the empty view won't flash. + final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub); + mEmptyView = emptyViewStub.inflate(); + + final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image); + emptyIcon.setImageResource(R.drawable.icon_bookmarks_empty); + + final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text); + emptyText.setText(R.string.home_bookmarks_empty); + + mList.setEmptyView(mEmptyView); + } + } + /** * Loader for the list for bookmarks. */ @@ -167,6 +190,7 @@ public class BookmarksPage extends HomeFragment { @Override public void onLoadFinished(Loader loader, Cursor c) { mListAdapter.swapCursor(c); + updateUiFromCursor(c); } @Override diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 547ce6f7b1b..e2bd1ce42a4 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -275,6 +275,7 @@ size. --> + diff --git a/mobile/android/base/resources/drawable-hdpi/icon_bookmarks_empty.png b/mobile/android/base/resources/drawable-hdpi/icon_bookmarks_empty.png new file mode 100644 index 00000000000..4bd9cd7ba96 Binary files /dev/null and b/mobile/android/base/resources/drawable-hdpi/icon_bookmarks_empty.png differ diff --git a/mobile/android/base/resources/drawable-mdpi/icon_bookmarks_empty.png b/mobile/android/base/resources/drawable-mdpi/icon_bookmarks_empty.png new file mode 100644 index 00000000000..3ee46dfe989 Binary files /dev/null and b/mobile/android/base/resources/drawable-mdpi/icon_bookmarks_empty.png differ diff --git a/mobile/android/base/resources/drawable-xhdpi/icon_bookmarks_empty.png b/mobile/android/base/resources/drawable-xhdpi/icon_bookmarks_empty.png new file mode 100644 index 00000000000..4ea238ec6f6 Binary files /dev/null and b/mobile/android/base/resources/drawable-xhdpi/icon_bookmarks_empty.png differ diff --git a/mobile/android/base/resources/layout/home_bookmarks_page.xml b/mobile/android/base/resources/layout/home_bookmarks_page.xml index 740fc62e373..0d48abb5bae 100644 --- a/mobile/android/base/resources/layout/home_bookmarks_page.xml +++ b/mobile/android/base/resources/layout/home_bookmarks_page.xml @@ -7,6 +7,11 @@ android:layout_width="fill_parent" android:layout_height="fill_parent"> + + &home_top_sites_title; &home_top_sites_add; &home_history_title; + &home_bookmarks_empty; &home_last_tabs_title; &home_last_tabs_open; &home_last_tabs_empty;