Bug 1131119 - Unified empty panel hints r+sebastian
--- a/mobile/android/base/java/org/mozilla/gecko/home/HistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/HistoryPanel.java
@@ -326,17 +326,17 @@ public class HistoryPanel extends HomeFr
emptyHint.setVisibility(View.GONE);
}
mList.setEmptyView(mEmptyView);
}
}
/**
- * Make Span that is clickable, italicized, and underlined
+ * Make Span that is clickable, and underlined
* between the string markers <code>FORMAT_S1</code> and
* <code>FORMAT_S2</code>.
*
* @param text String to format
* @return formatted SpannableStringBuilder, or null if there
* is not any text to format.
*/
private SpannableStringBuilder formatHintText(String text) {
@@ -346,19 +346,16 @@ public class HistoryPanel extends HomeFr
// Check that there is text to be formatted.
if (underlineStart >= underlineEnd) {
return null;
}
final SpannableStringBuilder ssb = new SpannableStringBuilder(text);
- // Set italicization.
- ssb.setSpan(new StyleSpan(Typeface.ITALIC), 0, ssb.length(), 0);
-
// Set clickable text.
final ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View widget) {
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.PANEL, "hint-private-browsing");
try {
final JSONObject json = new JSONObject();
json.put("type", "Menu:Open");
--- a/mobile/android/base/java/org/mozilla/gecko/home/ReadingListPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/ReadingListPanel.java
@@ -9,17 +9,16 @@ import java.util.EnumSet;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.R;
import org.mozilla.gecko.ReaderModeUtils;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserContract.ReadingListItems;
import org.mozilla.gecko.db.BrowserContract.URLColumns;
-import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.db.ReadingListAccessor;
import org.mozilla.gecko.home.HomeContextMenuInfo.RemoveItemType;
import org.mozilla.gecko.home.HomePager.OnUrlOpenListener;
import org.mozilla.gecko.util.HardwareUtils;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
@@ -28,16 +27,17 @@ import android.support.v4.widget.CursorA
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ImageSpan;
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.TextView;
/**
* Fragment that displays reading list contents in a ListView.
*/
public class ReadingListPanel extends HomeFragment {
// Cursor loader ID for reading list
@@ -58,17 +58,17 @@ public class ReadingListPanel extends Ho
// Reference to top view.
private View mTopView;
// Callbacks used for the reading list and favicon cursor loaders
private CursorLoaderCallbacks mCursorLoaderCallbacks;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.home_reading_list_panel, container, false);
+ return inflater.inflate(R.layout.home_list_panel, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mTopView = view;
@@ -154,37 +154,47 @@ public class ReadingListPanel extends Ho
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 TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text);
+ emptyText.setText(R.string.home_reading_list_empty);
+
+ final ImageView emptyImage = (ImageView) mEmptyView.findViewById(R.id.home_empty_image);
+ emptyImage.setImageResource(R.drawable.icon_reading_list_empty);
+
final TextView emptyHint = (TextView) mEmptyView.findViewById(R.id.home_empty_hint);
if (HardwareUtils.isLowMemoryPlatform()) {
emptyHint.setVisibility(View.GONE);
} else {
- String readingListHint = emptyHint.getText().toString();
+ String readingListHint = getString(R.string.home_reading_list_hint);
+ String readingListDesc = getString(R.string.home_reading_list_hint_accessible);
+ emptyHint.setText(readingListHint);
+ emptyHint.setContentDescription(readingListDesc);
// Use an ImageSpan to include the reader icon in the "Tip".
int imageSpanIndex = readingListHint.indexOf(MATCH_STRING);
if (imageSpanIndex != -1) {
final ImageSpan readingListIcon = new ImageSpan(getActivity(), R.drawable.reader_cropped, ImageSpan.ALIGN_BOTTOM);
final SpannableStringBuilder hintBuilder = new SpannableStringBuilder(readingListHint);
// Add additional spacing.
hintBuilder.insert(imageSpanIndex + MATCH_STRING.length(), " ");
hintBuilder.insert(imageSpanIndex, " ");
// Add icon.
hintBuilder.setSpan(readingListIcon, imageSpanIndex + 1, imageSpanIndex + MATCH_STRING.length() + 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
emptyHint.setText(hintBuilder, TextView.BufferType.SPANNABLE);
}
+ emptyHint.setVisibility(View.VISIBLE);
}
mList.setEmptyView(mEmptyView);
}
}
/**
* Cursor loader for the list of reading list items.
--- a/mobile/android/base/java/org/mozilla/gecko/home/RecentTabsPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/RecentTabsPanel.java
@@ -100,17 +100,17 @@ public class RecentTabsPanel extends Hom
public static final int TYPE_LAST_TIME = 1;
public static final int TYPE_CLOSED = 2;
public static final int TYPE_OPEN_ALL_LAST_TIME = 3;
public static final int TYPE_OPEN_ALL_CLOSED = 4;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.home_recent_tabs_panel, container, false);
+ return inflater.inflate(R.layout.home_list_panel, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
mList = (HomeListView) view.findViewById(R.id.list);
mList.setTag(HomePager.LIST_TAG_RECENT_TABS);
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -525,20 +525,20 @@ size. -->
<!-- Localization note (home_most_recent_emptyhint2): "Psst" is a sound that might be used to attract someone's attention unobtrusively, and intended to hint at Private Browsing to the user.
The placeholders &formatS1; and &formatS2; are used to mark the location of text underlining. -->
<!ENTITY home_most_recent_emptyhint2 "Psst: using a &formatS1;New Private Tab&formatS2; won\'t save your history.">
<!ENTITY home_reading_list_empty "Articles you save for later show up here.">
<!-- Localization note (home_reading_list_hint3): The "TIP" string is synonymous to "hint", "clue", etc. This string is displayed
as an advisory message on how to add content to the reading list when the reading list empty.
The placeholder &formatI; will be replaced by a small image of the icon described, and can be moved to wherever
it is applicable. -->
-<!ENTITY home_reading_list_hint3 "TIP: Save articles to your reading list by long pressing the &formatI; icon when it appears in the URL bar.">
+<!ENTITY home_reading_list_hint3 "Tip: Save articles to your reading list by long pressing the &formatI; icon when it appears in the URL bar.">
<!-- Localization note (home_reading_list_hint_accessible2): This string is used
as alternate text for accessibility. It is not visible in the UI. -->
-<!ENTITY home_reading_list_hint_accessible2 "TIP: Save articles to your reading list by long pressing the reader mode button when it appears in the URL bar.">
+<!ENTITY home_reading_list_hint_accessible2 "Tip: Save articles to your reading list by long pressing the reader mode button when it appears in the URL bar.">
<!-- Localization note (home_default_empty): This string is used as the default text when there
is no data to show in an about:home panel that was created by an add-on. -->
<!ENTITY home_default_empty "No content could be found for this panel.">
<!-- Localization note (home_move_up_to_filter): The variable is replaced by the name of the
previous location in the navigation, such as the previous folder -->
<!ENTITY home_move_up_to_filter "Up to &formatS;">
deleted file mode 100644
--- a/mobile/android/base/resources/layout/home_empty_reading_panel.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - 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/. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/home_empty_view"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:gravity="center">
-
- <!-- Empty spacer view -->
- <View android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1"/>
-
- <ImageView android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="top|center"
- android:scaleType="center"
- android:src="@drawable/icon_reading_list_empty"
- android:paddingBottom="10dp"/>
-
- <TextView android:layout_width="match_parent"
- android:layout_height="0dip"
- android:gravity="top|center"
- android:text="@string/home_reading_list_empty"
- android:textAppearance="@style/TextAppearance.EmptyMessage"
- android:paddingLeft="50dp"
- android:paddingRight="50dp"
- android:layout_weight="3"/>
-
- <ImageView android:src="@drawable/divider_horizontal"
- android:layout_width="match_parent"
- android:layout_height="1dip"
- android:paddingLeft="25dp"
- android:paddingRight="25dp"/>
-
- <TextView android:id="@+id/home_empty_hint"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:gravity="bottom"
- android:text="@string/home_reading_list_hint"
- android:textAppearance="@style/TextAppearance.Small"
- android:contentDescription="@string/home_reading_list_hint_accessible"
- android:paddingTop="20dp"
- android:paddingBottom="15dp"
- android:paddingLeft="25dp"
- android:paddingRight="40dp"/>
-
-</LinearLayout>
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/resources/layout/home_list_panel.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - 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/. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <include layout="@layout/home_list"/>
+
+</LinearLayout>
deleted file mode 100644
--- a/mobile/android/base/resources/layout/home_reading_list_panel.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - 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/. -->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <ViewStub android:id="@+id/home_empty_view_stub"
- android:layout="@layout/home_empty_reading_panel"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-
- <org.mozilla.gecko.home.HomeListView android:id="@+id/list"
- style="@style/Widget.ReadingListView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"/>
-</LinearLayout>
deleted file mode 100644
--- a/mobile/android/base/resources/layout/home_recent_tabs_panel.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - 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/. -->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
-
- <include layout="@layout/home_list"/>
-
-</LinearLayout>
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -362,16 +362,17 @@
<item name="android:textColorHighlight">@color/text_color_highlight_inverse</item>
<item name="android:textColorLink">?android:attr/textColorLink</item>
</style>
<style name="TextAppearance.EmptyMessage" parent="TextAppearance.Large"/>
<style name="TextAppearance.EmptyHint" parent="TextAppearance.Medium">
<item name="android:textColor">#FFA62F</item>
+ <item name="android:textStyle">italic</item>
</style>
<style name="TextAppearance.Micro">
<item name="android:textSize">12sp</item>
<item name="android:textColor">?android:attr/textColorTertiary</item>
</style>
<style name="TextAppearance.Micro.Inverse">