Bug 1383735 - Activity Stream: Update highlights layout to match latest mocks. r?mcomella draft
authorSebastian Kaspari <s.kaspari@gmail.com>
Mon, 07 Aug 2017 16:30:24 +0200
changeset 642526 7b415395316ad81e1d6213a130610cf006e27b50
parent 641632 47248637eafa9a38dade8dc3aa6c4736177c8d8d
child 642528 b09b1fb08520c141b45bda94a35bfbfb01b054ad
child 642558 c1a3bee3868db60b37ff00308005e6b536b712be
child 642561 51af1c5297861783a87b1cd1e2e5447c9a964d68
child 642574 74be239d1d13f6f92392d79a93456299c24088bc
push id72786
push users.kaspari@gmail.com
push dateTue, 08 Aug 2017 11:59:21 +0000
reviewersmcomella
bugs1383735
milestone57.0a1
Bug 1383735 - Activity Stream: Update highlights layout to match latest mocks. r?mcomella This is a version that does not use ConstraintLayout. Luckily I was able to simplify the layout nevertheless. MozReview-Commit-ID: 36AtqfmjZN0
mobile/android/app/src/australis/res/values/colors.xml
mobile/android/app/src/main/res/layout/activity_stream_card_history_item.xml
mobile/android/app/src/photon/res/values/colors.xml
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/model/Highlight.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
--- a/mobile/android/app/src/australis/res/values/colors.xml
+++ b/mobile/android/app/src/australis/res/values/colors.xml
@@ -158,15 +158,14 @@
   <color name="top_site_default">#FFECF0F3</color>
   <color name="top_site_border">#FFCFD9E1</color>
 
   <color name="private_active_text">#FFFFFF</color>
 
   <color name="action_bar_bg_color">@color/toolbar_grey</color>
 
   <color name="activity_stream_subtitle">#FF919191</color>
-  <color name="activity_stream_timestamp">#FFD3D3D3</color>
   <color name="activity_stream_icon">#FF919191</color>
 
   <color name="tablet_tab_strip_divider_color">#555555</color>
 
   <color name="bookmark_folder_bg_color">#FCFCFC</color>
 </resources>
--- a/mobile/android/app/src/main/res/layout/activity_stream_card_history_item.xml
+++ b/mobile/android/app/src/main/res/layout/activity_stream_card_history_item.xml
@@ -1,128 +1,112 @@
 <?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/. -->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:gecko="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:layout_marginTop="0dp"
-    android:orientation="vertical">
+    android:background="?android:attr/selectableItemBackground"
+    android:orientation="horizontal">
+
+    <!-- On some devices, marginBottom is ignored for Views within a RelativeLayout.
+         Wrapping in a FrameLayout appears to be a sufficient workaround for this issue -->
+    <FrameLayout
+        android:id="@+id/icon_wrapper"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content">
 
-    <RelativeLayout
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:orientation="horizontal"
-        android:background="?android:attr/selectableItemBackground">
+        <org.mozilla.gecko.widget.FaviconView
+            android:id="@+id/icon"
+            android:layout_width="@dimen/favicon_bg"
+            android:layout_height="@dimen/favicon_bg"
+            android:layout_marginBottom="@dimen/activity_stream_base_margin"
+            android:layout_marginLeft="@dimen/activity_stream_base_margin"
+            android:layout_marginStart="@dimen/activity_stream_base_margin"
+            android:layout_marginTop="@dimen/activity_stream_base_margin"
+            gecko:enableRoundCorners="false"
+            tools:background="@drawable/favicon_globe" />
 
+    </FrameLayout>
+
+    <ImageView
+        android:id="@+id/menu"
+        android:layout_width="32dp"
+        android:layout_height="48dp"
+        android:layout_alignParentEnd="true"
+        android:layout_alignParentRight="true"
+        android:layout_alignParentTop="true"
+        android:layout_gravity="right|end|top"
+        android:contentDescription="@string/menu"
+        android:paddingBottom="16dp"
+        android:paddingTop="16dp" />
 
-        <!-- On some devices, marginBottom is ignored for Views within a RelativeLayout.
-             Wrapping in a FrameLayout appears to be a sufficient workaround for this issue -->
-        <FrameLayout
-            android:id="@+id/icon_wrapper"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content">
+    <TextView
+        android:id="@+id/page"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_toEndOf="@id/icon_wrapper"
+        android:layout_toLeftOf="@id/menu"
+        android:layout_toRightOf="@id/icon_wrapper"
+        android:layout_toStartOf="@id/menu"
+        android:paddingLeft="@dimen/activity_stream_base_margin"
+        android:paddingStart="@dimen/activity_stream_base_margin"
+        android:paddingTop="@dimen/activity_stream_base_margin"
+        android:textColor="@color/activity_stream_subtitle"
+        android:textSize="12sp"
+        tools:text="twitter" />
 
-            <org.mozilla.gecko.widget.FaviconView
-                android:id="@+id/icon"
-                android:layout_width="@dimen/favicon_bg"
-                android:layout_height="@dimen/favicon_bg"
-                android:layout_marginStart="@dimen/activity_stream_base_margin"
-                android:layout_marginLeft="@dimen/activity_stream_base_margin"
-                android:layout_marginTop="@dimen/activity_stream_base_margin"
-                android:layout_marginBottom="@dimen/activity_stream_base_margin"
-                android:layout_gravity="center"
-                gecko:enableRoundCorners="false"
-                tools:background="@drawable/favicon_globe" />
+    <TextView
+        android:id="@+id/card_history_label"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/page"
+        android:layout_toEndOf="@id/icon_wrapper"
+        android:layout_toLeftOf="@id/menu"
+        android:layout_toRightOf="@id/icon_wrapper"
+        android:layout_toStartOf="@id/menu"
+        android:ellipsize="end"
+        android:maxLines="3"
+        android:paddingLeft="@dimen/activity_stream_base_margin"
+        android:paddingStart="@dimen/activity_stream_base_margin"
+        android:textColor="#ff000000"
+        android:textSize="14sp"
+        android:textStyle="bold"
+        tools:text="Descriptive title of a page that is veeeeeeery long - maybe even too long?" />
 
-        </FrameLayout>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_below="@id/card_history_label"
+        android:layout_toEndOf="@id/icon_wrapper"
+        android:layout_toRightOf="@id/icon_wrapper"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
+        android:paddingBottom="@dimen/activity_stream_base_margin"
+        android:paddingEnd="@dimen/activity_stream_base_margin"
+        android:paddingLeft="@dimen/activity_stream_base_margin"
+        android:paddingRight="@dimen/activity_stream_base_margin"
+        android:paddingStart="@dimen/activity_stream_base_margin"
+        android:paddingTop="4dp"
+        tools:ignore="UseCompoundDrawables">
 
         <ImageView
-            android:id="@+id/menu"
-            android:layout_width="wrap_content"
-            android:layout_height="36dp"
-            android:layout_margin="2dp"
-            android:layout_alignParentEnd="true"
-            android:layout_alignParentRight="true"
-            android:layout_alignParentTop="true"
-            android:layout_gravity="right|end|top"
-            android:contentDescription="@string/menu"
-            android:src="@drawable/menu"
-            android:padding="@dimen/activity_stream_base_margin" />
-
-        <TextView
-            android:id="@+id/page"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            tools:text="twitter"
-            android:textSize="12sp"
-            android:textColor="@color/activity_stream_subtitle"
-            android:layout_toRightOf="@id/icon_wrapper"
-            android:layout_toEndOf="@id/icon_wrapper"
-            android:layout_toLeftOf="@id/menu"
-            android:layout_toStartOf="@id/menu"
-            android:paddingTop="@dimen/activity_stream_base_margin"
-            android:paddingLeft="@dimen/activity_stream_base_margin"
-            android:paddingStart="@dimen/activity_stream_base_margin"/>
+            android:id="@+id/source_icon"
+            android:layout_width="12dp"
+            android:layout_height="12dp"
+            tools:src="@drawable/ic_as_bookmarked" />
 
         <TextView
-            android:id="@+id/card_history_label"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_toEndOf="@id/icon_wrapper"
-            android:layout_toRightOf="@id/icon_wrapper"
-            android:maxLines="3"
-            android:ellipsize="end"
-            android:paddingLeft="@dimen/activity_stream_base_margin"
-            android:paddingStart="@dimen/activity_stream_base_margin"
-            android:textSize="14sp"
-            android:textStyle="bold"
-            android:textColor="#ff000000"
-            android:layout_below="@id/page"
-            android:layout_toLeftOf="@id/menu"
-            android:layout_toStartOf="@id/menu"
-            tools:text="Descriptive title of a page that is veeeeeeery long - maybe even too long?" />
-
-        <LinearLayout
-            android:layout_width="match_parent"
+            android:id="@+id/card_history_source"
+            android:layout_width="0dp"
             android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:layout_toRightOf="@id/icon_wrapper"
-            android:layout_toEndOf="@id/icon_wrapper"
-            android:layout_alignParentBottom="true"
-            android:paddingLeft="@dimen/activity_stream_base_margin"
-            android:paddingStart="@dimen/activity_stream_base_margin"
-            android:paddingRight="@dimen/activity_stream_base_margin"
-            android:paddingEnd="@dimen/activity_stream_base_margin"
-            android:paddingTop="4dp"
-            android:paddingBottom="@dimen/activity_stream_base_margin"
-            android:gravity="center_vertical"
-            android:layout_below="@id/card_history_label">
-
-            <ImageView
-                android:id="@+id/source_icon"
-                android:layout_width="12dp"
-                android:layout_height="12dp" />
+            android:layout_marginLeft="2dp"
+            android:layout_weight="1"
+            android:textColor="@color/activity_stream_subtitle"
+            android:textSize="12sp"
+            tools:text="Bookmarked" />
 
-            <TextView
-                android:id="@+id/card_history_source"
-                android:layout_width="0dp"
-                android:layout_height="wrap_content"
-                android:layout_marginLeft="2dp"
-                android:textSize="12sp"
-                android:layout_weight="1"
-                android:textColor="@color/activity_stream_subtitle"
-                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="@color/activity_stream_timestamp"
-                tools:text="20m" />
-
-        </LinearLayout>
-    </RelativeLayout>
-</FrameLayout>
+    </LinearLayout>
+</RelativeLayout>
--- a/mobile/android/app/src/photon/res/values/colors.xml
+++ b/mobile/android/app/src/photon/res/values/colors.xml
@@ -270,15 +270,14 @@
     <color name="top_site_default">#FFECF0F3</color>
     <color name="top_site_border">#FFCFD9E1</color>
 
     <color name="private_active_text">#FFFFFF</color>
 
     <color name="action_bar_bg_color">@color/toolbar_grey</color>
 
     <color name="activity_stream_subtitle">#FF919191</color>
-    <color name="activity_stream_timestamp">#FFD3D3D3</color>
     <color name="activity_stream_icon">#FF919191</color>
 
     <color name="tablet_tab_strip_divider_color">#414146</color>
 
     <color name="bookmark_folder_bg_color">#FCFCFC</color>
 </resources>
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/model/Highlight.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/model/Highlight.java
@@ -30,17 +30,16 @@ public class Highlight implements Item {
 
     // A pattern matching a json object containing the key "description_length" and extracting the value: this
     // regex should perfectly match values in json without whitespace.
     private static final Pattern FAST_DESCRIPTION_LENGTH_PATTERN = Pattern.compile("\"description_length\":([0-9]+)");
 
     private final String title;
     private final String url;
     private final Utils.HighlightSource source;
-    private final long time;
 
     private long historyId;
 
     private @Nullable Metadata metadata; // lazily-loaded.
     private @Nullable final String metadataJSON;
     private @Nullable String fastImageURL;
     private int fastDescriptionLength;
 
@@ -50,17 +49,16 @@ public class Highlight implements Item {
     public static Highlight fromCursor(final Cursor cursor, final HighlightCandidateCursorIndices cursorIndices) {
         return new Highlight(cursor, cursorIndices);
     }
 
     private Highlight(final Cursor cursor, final HighlightCandidateCursorIndices cursorIndices) {
         title = cursor.getString(cursorIndices.titleColumnIndex);
         url = cursor.getString(cursorIndices.urlColumnIndex);
         source = Utils.highlightSource(cursor, cursorIndices);
-        time = cursor.getLong(cursorIndices.highlightsDateColumnIndex);
 
         historyId = cursor.getLong(cursorIndices.historyIDColumnIndex);
 
         metadataJSON = cursor.getString(cursorIndices.metadataColumnIndex);
         fastImageURL = initFastImageURL(metadataJSON);
         fastDescriptionLength = initFastDescriptionLength(metadataJSON);
 
         updateState();
@@ -189,21 +187,16 @@ public class Highlight implements Item {
         this.isBookmarked = bookmarked;
     }
 
     @Override
     public void updatePinned(boolean pinned) {
         this.isPinned = pinned;
     }
 
-    public String getRelativeTimeSpan() {
-        return DateUtils.getRelativeTimeSpanString(
-                        time, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, 0).toString();
-    }
-
     public Utils.HighlightSource getSource() {
         return source;
     }
 
     public long getHistoryId() {
         return historyId;
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
@@ -39,33 +39,31 @@ public class HighlightItem extends Strea
 
     public static final int LAYOUT_ID = R.layout.activity_stream_card_history_item;
 
     private Highlight highlight;
     private int position;
 
     private final FaviconView pageIconView;
     private final TextView pageTitleView;
-    private final TextView vTimeSince;
     private final TextView pageSourceView;
     private final TextView pageDomainView;
     private final ImageView pageSourceIconView;
 
     private Future<IconResponse> ongoingIconLoad;
     private int tilesMargin;
 
     public HighlightItem(final View itemView,
                          final HomePager.OnUrlOpenListener onUrlOpenListener,
                          final HomePager.OnUrlOpenInBackgroundListener onUrlOpenInBackgroundListener) {
         super(itemView);
 
         tilesMargin = itemView.getResources().getDimensionPixelSize(R.dimen.activity_stream_base_margin);
 
         pageTitleView = (TextView) itemView.findViewById(R.id.card_history_label);
-        vTimeSince = (TextView) itemView.findViewById(R.id.card_history_time_since);
         pageIconView = (FaviconView) itemView.findViewById(R.id.icon);
         pageSourceView = (TextView) itemView.findViewById(R.id.card_history_source);
         pageDomainView = (TextView) itemView.findViewById(R.id.page);
         pageSourceIconView = (ImageView) itemView.findViewById(R.id.source_icon);
 
         final ImageView menuButton = (ImageView) itemView.findViewById(R.id.menu);
 
         menuButton.setImageDrawable(
@@ -102,17 +100,16 @@ public class HighlightItem extends Strea
 
     public void bind(Highlight highlight, int position, int tilesWidth, int tilesHeight) {
         this.highlight = highlight;
         this.position = position;
 
         final String backendHightlightTitle = highlight.getTitle();
         final String uiHighlightTitle = !TextUtils.isEmpty(backendHightlightTitle) ? backendHightlightTitle : highlight.getUrl();
         pageTitleView.setText(uiHighlightTitle);
-        vTimeSince.setText(highlight.getRelativeTimeSpan());
 
         ViewGroup.LayoutParams layoutParams = pageIconView.getLayoutParams();
         layoutParams.width = tilesWidth - tilesMargin;
         layoutParams.height = tilesHeight;
         pageIconView.setLayoutParams(layoutParams);
 
         updateUiForSource(highlight.getSource());
         updatePageDomain();