Bug 1379021 - Rebuild highlights row layout based on ConstraintLayout. r?grisha
MozReview-Commit-ID: 9WHJW9QvlRF
deleted file mode 100644
--- a/mobile/android/app/src/main/res/layout/activity_stream_card_history_item.xml
+++ /dev/null
@@ -1,127 +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/. -->
-<FrameLayout 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">
-
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:background="?android:attr/selectableItemBackground">
-
-
- <!-- 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">
-
- <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_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" />
-
- </FrameLayout>
-
- <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"/>
-
- <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: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" />
-
- <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>
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/layout/activity_stream_highlights_item.xml
@@ -0,0 +1,105 @@
+<?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/. -->
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ 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:background="?android:attr/selectableItemBackground"
+ android:paddingBottom="8dp">
+
+ <FrameLayout
+ android:id="@+id/icon_wrapper"
+ android:layout_width="100dp"
+ android:layout_height="75dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="8dp"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:background="#ff0000">
+
+ <org.mozilla.gecko.widget.FaviconView
+ android:id="@+id/icon"
+ android:layout_width="@dimen/favicon_bg"
+ android:layout_height="@dimen/favicon_bg"
+ android:layout_gravity="center"
+ gecko:enableRoundCorners="false"
+ tools:background="@drawable/favicon_globe"
+ tools:layout_editor_absoluteX="13dp"
+ tools:layout_editor_absoluteY="13dp" />
+
+ </FrameLayout>
+
+ <TextView
+ android:id="@+id/page"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:layout_marginRight="8dp"
+ android:layout_marginTop="8dp"
+ android:ellipsize="end"
+ android:lines="1"
+ android:textSize="12sp"
+ android:textColor="@color/activity_stream_subtitle"
+ app:layout_constraintHorizontal_bias="0.0"
+ app:layout_constraintLeft_toRightOf="@+id/icon_wrapper"
+ app:layout_constraintRight_toLeftOf="@+id/menu"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:text="vimeo" />
+
+ <TextView
+ android:id="@+id/card_history_label"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="8dp"
+ android:layout_marginRight="8dp"
+ android:layout_marginTop="4dp"
+ android:ellipsize="end"
+ android:maxLines="3"
+ android:textColor="#ff000000"
+ android:textSize="14sp"
+ android:textStyle="bold"
+ app:layout_constraintHorizontal_bias="0.0"
+ app:layout_constraintLeft_toRightOf="@+id/icon_wrapper"
+ app:layout_constraintRight_toLeftOf="@+id/menu"
+ app:layout_constraintTop_toBottomOf="@+id/page"
+ tools:text="Should Your Team Buy Or Sell At the MLB Trade Deadline?" />
+
+ <ImageView
+ android:id="@+id/source_icon"
+ android:layout_width="12dp"
+ android:layout_height="12dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="4dp"
+ app:layout_constraintLeft_toRightOf="@+id/icon_wrapper"
+ app:layout_constraintTop_toBottomOf="@+id/card_history_label"
+ tools:src="@drawable/ic_as_bookmarked" />
+
+ <TextView
+ android:id="@+id/card_history_source"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="4dp"
+ android:textColor="@color/activity_stream_subtitle"
+ android:textSize="12sp"
+ app:layout_constraintLeft_toRightOf="@+id/source_icon"
+ app:layout_constraintTop_toBottomOf="@+id/card_history_label"
+ tools:text="Bookmarked" />
+
+ <ImageView
+ android:id="@+id/menu"
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:layout_marginEnd="0dp"
+ android:layout_marginTop="0dp"
+ android:contentDescription="@string/menu"
+ android:padding="16dp"
+ android:src="@drawable/menu"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+</android.support.constraint.ConstraintLayout>
--- 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
@@ -31,40 +31,38 @@ import org.mozilla.gecko.widget.FaviconV
import java.util.concurrent.Future;
import static org.mozilla.gecko.activitystream.ActivityStream.extractLabel;
public class HighlightItem extends StreamItem implements IconCallback {
private static final String LOGTAG = "GeckoHighlightItem";
- public static final int LAYOUT_ID = R.layout.activity_stream_card_history_item;
+ public static final int LAYOUT_ID = R.layout.activity_stream_highlights_item;
private Highlight highlight;
private int position;
private final FaviconView vIconView;
private final TextView vLabel;
- private final TextView vTimeSince;
private final TextView vSourceView;
private final TextView vPageView;
private final ImageView vSourceIconView;
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);
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);
vPageView = (TextView) itemView.findViewById(R.id.page);
vSourceIconView = (ImageView) itemView.findViewById(R.id.source_icon);
final ImageView menuButton = (ImageView) itemView.findViewById(R.id.menu);
menuButton.setImageDrawable(
@@ -99,17 +97,16 @@ public class HighlightItem extends Strea
ViewUtil.enableTouchRipple(menuButton);
}
public void bind(Highlight highlight, int position, int tilesWidth, int tilesHeight) {
this.highlight = highlight;
this.position = position;
vLabel.setText(highlight.getTitle());
- vTimeSince.setText(highlight.getRelativeTimeSpan());
ViewGroup.LayoutParams layoutParams = vIconView.getLayoutParams();
layoutParams.width = tilesWidth - tilesMargin;
layoutParams.height = tilesHeight;
vIconView.setLayoutParams(layoutParams);
updateUiForSource(highlight.getSource());
updatePage();