mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 891953 - Part 1: Implement empty screen text and icon for reading list. r=sriram
This commit is contained in:
parent
951f4632ea
commit
a97d9c67ab
@ -668,6 +668,7 @@ RES_DRAWABLE_MDPI = \
|
||||
res/drawable-mdpi/icon_most_visited.png \
|
||||
res/drawable-mdpi/icon_most_visited_empty.png \
|
||||
res/drawable-mdpi/icon_pageaction.png \
|
||||
res/drawable-mdpi/icon_reading_list_empty.png \
|
||||
res/drawable-mdpi/progress_spinner.png \
|
||||
res/drawable-mdpi/tab_indicator_divider.9.png \
|
||||
res/drawable-mdpi/tab_indicator_selected.9.png \
|
||||
@ -778,6 +779,7 @@ RES_DRAWABLE_HDPI = \
|
||||
res/drawable-hdpi/icon_most_visited.png \
|
||||
res/drawable-hdpi/icon_most_visited_empty.png \
|
||||
res/drawable-hdpi/icon_pageaction.png \
|
||||
res/drawable-hdpi/icon_reading_list_empty.png \
|
||||
res/drawable-hdpi/tab_indicator_divider.9.png \
|
||||
res/drawable-hdpi/tab_indicator_selected.9.png \
|
||||
res/drawable-hdpi/tab_indicator_selected_focused.9.png \
|
||||
@ -875,6 +877,7 @@ RES_DRAWABLE_XHDPI = \
|
||||
res/drawable-xhdpi/icon_most_visited.png \
|
||||
res/drawable-xhdpi/icon_most_visited_empty.png \
|
||||
res/drawable-xhdpi/icon_pageaction.png \
|
||||
res/drawable-xhdpi/icon_reading_list_empty.png \
|
||||
res/drawable-xhdpi/spinner_default.9.png \
|
||||
res/drawable-xhdpi/spinner_focused.9.png \
|
||||
res/drawable-xhdpi/spinner_pressed.9.png \
|
||||
|
@ -24,8 +24,11 @@ import android.support.v4.widget.CursorAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewStub;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
@ -42,6 +45,12 @@ public class ReadingListPage extends HomeFragment {
|
||||
// The view shown by the fragment
|
||||
private ListView mList;
|
||||
|
||||
// Reference to the View to display when there are no results.
|
||||
private View mEmptyView;
|
||||
|
||||
// Reference to top view.
|
||||
private View mTopView;
|
||||
|
||||
// Callbacks used for the reading list and favicon cursor loaders
|
||||
private CursorLoaderCallbacks mCursorLoaderCallbacks;
|
||||
|
||||
@ -69,14 +78,16 @@ public class ReadingListPage extends HomeFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
mList = (HomeListView) inflater.inflate(R.layout.home_reading_list_page, container, false);
|
||||
return mList;
|
||||
return inflater.inflate(R.layout.home_reading_list_page, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
mTopView = view;
|
||||
|
||||
mList = (ListView) view.findViewById(R.id.list);
|
||||
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
@ -100,6 +111,8 @@ public class ReadingListPage extends HomeFragment {
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
mList = null;
|
||||
mTopView = null;
|
||||
mEmptyView = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,6 +145,23 @@ public class ReadingListPage extends HomeFragment {
|
||||
getLoaderManager().initLoader(LOADER_ID_READING_LIST, null, mCursorLoaderCallbacks);
|
||||
}
|
||||
|
||||
private void updateUiFromCursor(Cursor c) {
|
||||
// We delay setting the empty view until the cursor is actually empty.
|
||||
// This avoids image flashing.
|
||||
if ((c == null || c.getCount() == 0) && mEmptyView == null) {
|
||||
final ViewStub emptyViewStub = (ViewStub) mTopView.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_reading_list_empty);
|
||||
|
||||
final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text);
|
||||
emptyText.setText(R.string.home_reading_list_empty);
|
||||
|
||||
mList.setEmptyView(mEmptyView);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cursor loader for the list of reading list items.
|
||||
*/
|
||||
@ -187,6 +217,8 @@ public class ReadingListPage extends HomeFragment {
|
||||
mAdapter.swapCursor(c);
|
||||
break;
|
||||
}
|
||||
|
||||
updateUiFromCursor(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -276,6 +276,7 @@ size. -->
|
||||
<!ENTITY home_most_recent_title "Most recent">
|
||||
<!ENTITY home_most_recent_empty "Websites you visited most recently show up here.">
|
||||
<!ENTITY home_most_visited_title "Most visited">
|
||||
<!ENTITY home_reading_list_empty "Articles you save for later show up here.">
|
||||
<!ENTITY home_most_visited_empty "Websites you visit most frequently show up here.">
|
||||
<!ENTITY pin_bookmark_dialog_hint "Enter a search keyword">
|
||||
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 972 B |
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
@ -3,7 +3,18 @@
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<org.mozilla.gecko.home.HomeListView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/Widget.ReadingListView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ViewStub android:id="@+id/home_empty_view_stub"
|
||||
android:layout="@layout/home_empty_page"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<org.mozilla.gecko.home.HomeListView android:id="@+id/list"
|
||||
style="@style/Widget.ReadingListView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
@ -259,6 +259,7 @@
|
||||
<string name="home_most_recent_empty">&home_most_recent_empty;</string>
|
||||
<string name="home_most_visited_title">&home_most_visited_title;</string>
|
||||
<string name="home_most_visited_empty">&home_most_visited_empty;</string>
|
||||
<string name="home_reading_list_empty">&home_reading_list_empty;</string>
|
||||
<string name="pin_bookmark_dialog_hint">&pin_bookmark_dialog_hint;</string>
|
||||
|
||||
<string name="filepicker_title">&filepicker_title;</string>
|
||||
|
Loading…
Reference in New Issue
Block a user