Bug 1306609 - Show source label next to highlights (Visited, Bookmarked). r?ahunt
MozReview-Commit-ID: BRGESCA5sbq
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/StreamItem.java
@@ -62,46 +62,67 @@ public abstract class StreamItem extends
}
public static class CompactItem extends StreamItem implements IconCallback {
public static final int LAYOUT_ID = R.layout.activity_stream_card_history_item;
final FaviconView vIconView;
final TextView vLabel;
final TextView vTimeSince;
+ final TextView vSourceView;
private Future<IconResponse> ongoingIconLoad;
public CompactItem(View itemView) {
super(itemView);
vLabel = (TextView) itemView.findViewById(R.id.card_history_label);
vTimeSince = (TextView) itemView.findViewById(R.id.card_history_time_since);
vIconView = (FaviconView) itemView.findViewById(R.id.icon);
+ vSourceView = (TextView) itemView.findViewById(R.id.card_history_source);
}
@Override
public void bind(Cursor cursor) {
final long time = cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.Highlights.DATE));
final String ago = DateUtils.getRelativeTimeSpanString(time, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, 0).toString();
final String url = cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.Combined.URL));
vLabel.setText(cursor.getString(cursor.getColumnIndexOrThrow(BrowserContract.History.TITLE)));
vTimeSince.setText(ago);
+ updateSource(cursor);
+
if (ongoingIconLoad != null) {
ongoingIconLoad.cancel(true);
}
ongoingIconLoad = Icons.with(itemView.getContext())
.pageUrl(url)
.skipNetwork()
.build()
.execute(this);
}
+ private void updateSource(final Cursor cursor) {
+ final boolean isBookmark = -1 != cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.Combined.BOOKMARK_ID));
+ final boolean isHistory = -1 != cursor.getLong(cursor.getColumnIndexOrThrow(BrowserContract.Combined.HISTORY_ID));
+
+ if (isBookmark) {
+ vSourceView.setText(R.string.activity_stream_highlight_label_bookmarked);
+ vSourceView.setVisibility(View.VISIBLE);
+ } else if (isHistory) {
+ vSourceView.setText(R.string.activity_stream_highlight_label_visited);
+ vSourceView.setVisibility(View.VISIBLE);
+ } else {
+ vSourceView.setVisibility(View.INVISIBLE);
+ }
+
+ vSourceView.setText(vSourceView.getText());
+ }
+
@Override
public void onIconResponse(IconResponse response) {
vIconView.updateImage(response);
}
}
public static class HighlightItem extends StreamItem {
public static final int LAYOUT_ID = R.layout.activity_stream_card_highlights_item;
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -828,8 +828,16 @@ just addresses the organization to follo
<!ENTITY helper_first_offline_bookmark_button "Go to Bookmarks">
<!ENTITY helper_triple_readerview_open_title "Available offline">
<!ENTITY helper_triple_readerview_open_message "Bookmark Reader View items to read them offline.">
<!ENTITY helper_triple_readerview_open_button "Add to Bookmarks">
<!ENTITY activity_stream_topsites "Top Sites">
<!ENTITY activity_stream_highlights "Highlights">
+
+<!-- LOCALIZATION NOTE (activity_stream_highlight_label_bookmarked): This label is shown in the Activity
+Stream list for highlights sourced from th user's bookmarks. -->
+<!ENTITY activity_stream_highlight_label_bookmarked "Bookmarked">
+<!-- LOCALIZATION NOTE (activity_stream_highlight_label_visited): This label is shown in the Activity
+Stream list for highlights sourced from th user's bookmarks. -->
+<!ENTITY activity_stream_highlight_label_visited "Visited">
+
--- a/mobile/android/base/resources/layout/activity_stream_card_history_item.xml
+++ b/mobile/android/base/resources/layout/activity_stream_card_history_item.xml
@@ -24,31 +24,49 @@
android:id="@+id/icon"
android:layout_width="@dimen/favicon_bg"
android:layout_height="@dimen/favicon_bg"
tools:background="@drawable/favicon_globe" />
<TextView
android:id="@+id/card_history_label"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="wrap_content"
android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon"
android:maxLines="2"
android:paddingLeft="8dp"
android:paddingStart="8dp"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#ff000000"
tools:text="Descriptive title of a page..." />
- <TextView
- android:id="@+id/card_history_time_since"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:layout_alignParentRight="true"
- android:layout_below="@id/card_history_label"
- android:textSize="12sp"
- android:textColor="#ffd2d2d2"
- tools:text="20m" />
+ android:orientation="horizontal"
+ android:layout_toRightOf="@id/icon"
+ android:paddingLeft="8dp"
+ android:paddingStart="8dp"
+ android:paddingTop="4dp"
+ android:layout_below="@id/card_history_label">
+
+ <TextView
+ android:id="@+id/card_history_source"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:textSize="12sp"
+ android:layout_weight="1"
+ android:textColor="#ff8e8e8e"
+ tools:text="Bookmarked" />
+
+ <TextView
+ android:id="@+id/card_history_time_since"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="12sp"
+ android:textColor="#ffd2d2d2"
+ tools:text="20m" />
+
+ </LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -627,9 +627,11 @@
<string name="helper_first_offline_bookmark_button">&helper_first_offline_bookmark_button;</string>
<string name="helper_triple_readerview_open_title">&helper_triple_readerview_open_title;</string>
<string name="helper_triple_readerview_open_message">&helper_triple_readerview_open_message;</string>
<string name="helper_triple_readerview_open_button">&helper_triple_readerview_open_button;</string>
<string name="activity_stream_topsites">&activity_stream_topsites;</string>
<string name="activity_stream_highlights">&activity_stream_highlights;</string>
+ <string name="activity_stream_highlight_label_bookmarked">&activity_stream_highlight_label_bookmarked;</string>
+ <string name="activity_stream_highlight_label_visited">&activity_stream_highlight_label_visited;</string>
</resources>