Bug 1232866 - Establish clearer IA for panel list items. r=mcomella draft
authorChenxia Liu <liuche@mozilla.com>
Fri, 26 Feb 2016 13:44:07 -0800
changeset 335093 6c36d651f95afbbabc1d97e400407e9b6b8e2d78
parent 335060 bab8e722f1aa7386d1cdcc4f73fdc8141697de76
child 515074 3d45b54020539f007ba7a20cdef1a702c9d79a67
push id11721
push usercliu@mozilla.com
push dateFri, 26 Feb 2016 23:22:59 +0000
reviewersmcomella
bugs1232866
milestone47.0a1
Bug 1232866 - Establish clearer IA for panel list items. r=mcomella MozReview-Commit-ID: 40quuVQxL2K
mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
mobile/android/base/resources/drawable-hdpi/ic_url_bar_star.png
mobile/android/base/resources/drawable-nodpi/bookmarked_star.png
mobile/android/base/resources/drawable-xhdpi/ic_url_bar_star.png
mobile/android/base/resources/layout/two_line_page_row.xml
mobile/android/base/resources/values/dimens.xml
mobile/android/base/resources/values/styles.xml
--- a/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java
@@ -2,16 +2,17 @@
  * 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/. */
 
 package org.mozilla.gecko.home;
 
 import java.lang.ref.WeakReference;
 
+import android.widget.ImageView;
 import org.mozilla.gecko.AboutPages;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.ReaderModeUtils;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.db.BrowserContract.Combined;
 import org.mozilla.gecko.db.BrowserContract.URLColumns;
 import org.mozilla.gecko.favicons.Favicons;
@@ -30,19 +31,19 @@ import android.widget.TextView;
 
 public class TwoLinePageRow extends LinearLayout
                             implements Tabs.OnTabsChangedListener {
 
     protected static final int NO_ICON = 0;
 
     private final TextView mTitle;
     private final TextView mUrl;
+    private final ImageView mStatusIcon;
 
     private int mSwitchToTabIconId;
-    private int mPageTypeIconId;
 
     private final FaviconView mFavicon;
 
     private boolean mShowIcons;
     private int mLoadFaviconJobId = Favicons.NOT_LOADING;
 
     // Only holds a reference to the FaviconView itself, so if the row gets
     // discarded while a task is outstanding, we'll leak less memory.
@@ -85,21 +86,22 @@ public class TwoLinePageRow extends Line
     }
 
     public TwoLinePageRow(Context context, AttributeSet attrs) {
         super(context, attrs);
 
         setGravity(Gravity.CENTER_VERTICAL);
 
         LayoutInflater.from(context).inflate(R.layout.two_line_page_row, this);
+        setPadding(0, 0, (int) getResources().getDimension(R.dimen.page_row_padding_right), 0);
         mTitle = (TextView) findViewById(R.id.title);
         mUrl = (TextView) findViewById(R.id.url);
+        mStatusIcon = (ImageView) findViewById(R.id.status_icon);
 
         mSwitchToTabIconId = NO_ICON;
-        mPageTypeIconId = NO_ICON;
         mShowIcons = true;
 
         mFavicon = (FaviconView) findViewById(R.id.icon);
         mFaviconListener = new UpdateViewFaviconLoadedListener(mFavicon);
     }
 
     @Override
     protected void onAttachedToWindow() {
@@ -168,26 +170,22 @@ public class TwoLinePageRow extends Line
     }
 
     protected void setSwitchToTabIcon(int iconId) {
         if (mSwitchToTabIconId == iconId) {
             return;
         }
 
         mSwitchToTabIconId = iconId;
-        mUrl.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, mPageTypeIconId, 0);
+        mUrl.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, 0, 0);
     }
 
-    private void setPageTypeIcon(int iconId) {
-        if (mPageTypeIconId == iconId) {
-            return;
-        }
-
-        mPageTypeIconId = iconId;
-        mUrl.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, mPageTypeIconId, 0);
+    private void showPageTypeIcon(boolean toShow) {
+        final int visibility = toShow ? VISIBLE : GONE;
+        mStatusIcon.setVisibility(visibility);
     }
 
     /**
      * Stores the page URL, so that we can use it to replace "Switch to tab" if the open
      * tab changes or is closed.
      */
     private void updateDisplayedUrl(String url) {
         mPageUrl = url;
@@ -227,22 +225,22 @@ public class TwoLinePageRow extends Line
         update(title, url, 0);
     }
 
     protected void update(String title, String url, long bookmarkId) {
         if (mShowIcons) {
             // The bookmark id will be 0 (null in database) when the url
             // is not a bookmark.
             if (bookmarkId == 0) {
-                setPageTypeIcon(NO_ICON);
+                showPageTypeIcon(false);
             } else {
-                setPageTypeIcon(R.drawable.ic_url_bar_star);
+                showPageTypeIcon(true);
             }
         } else {
-            setPageTypeIcon(NO_ICON);
+            showPageTypeIcon(false);
         }
 
         // Use the URL instead of an empty title for consistency with the normal URL
         // bar view - this is the equivalent of getDisplayTitle() in Tab.java
         setTitle(TextUtils.isEmpty(title) ? url : title);
 
         // No point updating the below things if URL has not changed. Prevents evil Favicon flicker.
         if (url.equals(mPageUrl)) {
deleted file mode 100644
index bf18ebeb035c34c5fd29a866987abced913c4c5b..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
new file mode 100644
index 0000000000000000000000000000000000000000..641a0e1b5dc2fe2049f3f8ed19576d8ae9602ed8
GIT binary patch
literal 600
zc$@)P0;m0nP)<h;3K|Lk000e1NJLTq001Qb001Ni1^@s64#M-M0006XNkl<Zcmd6r
z0}NYH6o&uVRxoeDY}>ZNc?;%fij&#8XSQwIwzqp;J3F4Y;v^aB-dBCeAGGha-!)*H
z<*y5X_&gNff^wEbN}%)(Ph1kOT+&(OsQO3fkC<+s>{{C9FU6OTG!{C`g7~+ul!UBS
zND8Fa`O5qW>9a^UOP`kp@y}pV5^^*}LQ%Xlq>zM9B4I3lSp=lNhn13W10)3Ec@YUo
z_z2?4=6Bh#NY@APmq?`~3$0#I&OETiviCVaToVheeo#COr1wLy<InIn4e=|GJ__PF
zP}X3OvtCeH`GWK)C_VtCpPB!$xvVs^;&E8Qg&+{0NVrJQ@O`*kX&_CLGE(|0goQjH
zWu%D5;}68slP|?<;Buw)UCUGwrM6+SD;<214o18(@lB@pdxSC~7-Fk<a{{G~V}+F&
zVOiwL0OCCf=+x(Bm57-Au1qqa#jnY(VUf;du>XFQ6-u9pgVbHmZ|8?G<fvj-BK8Lh
za&(D9Um9vtN{@-dBsmwhP<nYBqz>7YIv0oLvusN7hd9*KFPSh6k5PH!H%~n)4<i;j
z>O@-uk?-3bU15Z>`b4~bEwXA!>4|qmI9H7^m6{ml$FE`$w+vjvd@_vG3K&7WDahz~
z2*o{Qs}qWaR%;Mn5AqwQO{KQ@l<qkc50vdqq<F;T+(-JckJuU0tDa^c{oa#no{Tab
m#=;3#ddOK%t|32(Xb9X`rPzV9yB`_=0000<MNUMnLSTa8%@#WV
deleted file mode 100644
index 5f6f96db027d017d004a6c3b333d19fd0537b080..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
--- a/mobile/android/base/resources/layout/two_line_page_row.xml
+++ b/mobile/android/base/resources/layout/two_line_page_row.xml
@@ -9,34 +9,41 @@
        tools:context=".BrowserApp">
 
     <org.mozilla.gecko.widget.FaviconView android:id="@+id/icon"
                                           android:layout_width="@dimen/favicon_bg"
                                           android:layout_height="@dimen/favicon_bg"
                                           android:layout_margin="16dp"
                                           tools:background="@drawable/favicon_globe"/>
 
-    <LinearLayout android:layout_width="match_parent"
+    <LinearLayout android:layout_width="0dp"
                   android:layout_height="wrap_content"
+                  android:layout_weight="1"
                   android:layout_gravity="center_vertical"
-                  android:orientation="vertical"
-                  android:paddingRight="25dp">
+                  android:paddingRight="10dp"
+                  android:orientation="vertical">
 
         <org.mozilla.gecko.widget.FadedSingleColorTextView
                 android:id="@+id/title"
                 style="@style/Widget.TwoLinePageRow.Title"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                gecko:fadeWidth="30dp"
+                gecko:fadeWidth="90dp"
                 tools:text="This is a long test title"/>
 
-        <TextView android:id="@+id/url"
+        <org.mozilla.gecko.widget.FadedSingleColorTextView android:id="@+id/url"
                   style="@style/Widget.TwoLinePageRow.Url"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:drawablePadding="5dp"
                   android:maxLength="1024"
+                  gecko:fadeWidth="90dp"
                   tools:text="http://test.com/test"
-                  tools:drawableLeft="@drawable/ic_url_bar_tab"
-                  tools:drawableRight="@drawable/ic_url_bar_star"/>
+                  tools:drawableLeft="@drawable/ic_url_bar_tab"/>
 
     </LinearLayout>
+    <ImageView android:id="@+id/status_icon"
+               android:layout_width="@dimen/home_status_icon_size"
+               android:layout_height="@dimen/home_status_icon_size"
+               android:layout_gravity="center"
+               android:visibility="gone"
+               android:src="@drawable/bookmarked_star"/>
 </merge>
--- a/mobile/android/base/resources/values/dimens.xml
+++ b/mobile/android/base/resources/values/dimens.xml
@@ -74,22 +74,26 @@
     <dimen name="browser_toolbar_site_security_padding_vertical">7dp</dimen>
     <dimen name="browser_toolbar_site_security_padding_horizontal">7dp</dimen>
 
     <!-- If one of these values changes, they all should. -->
     <dimen name="browser_toolbar_site_security_margin_bottom">.5dp</dimen>
     <dimen name="site_security_unknown_inset_top">1dp</dimen>
     <dimen name="site_security_unknown_inset_bottom">-1dp</dimen>
 
+    <dimen name="page_row_padding_right">15dp</dimen>
+
     <!-- Regular page row on about:home -->
     <dimen name="page_row_height">64dp</dimen>
 
     <!-- Group/heading page row on about:home -->
     <dimen name="page_group_height">56dp</dimen>
 
+    <dimen name="home_status_icon_size">20dp</dimen>
+
     <!-- Reading list row on about:home -->
     <dimen name="reading_list_row_height">128dp</dimen>
     <dimen name="reading_list_row_padding_right">10dp</dimen>
 
     <!-- Remote Tabs static view top padding. Less in landscape on phones. -->
     <dimen name="home_remote_tabs_top_padding">48dp</dimen>
 
     <!-- Remote Tabs Hidden devices row height -->
--- a/mobile/android/base/resources/values/styles.xml
+++ b/mobile/android/base/resources/values/styles.xml
@@ -406,17 +406,19 @@
     </style>
 
     <style name="TextAppearance.Widget.Home" />
 
     <style name="TextAppearance.Widget.Home.Header" parent="TextAppearance.Small">
         <item name="android:textColor">?android:attr/textColorPrimary</item>
     </style>
 
-    <style name="TextAppearance.Widget.Home.ItemTitle" parent="TextAppearance.Medium"/>
+    <style name="TextAppearance.Widget.Home.ItemTitle" parent="TextAppearance">
+        <item name="android:textSize">16dp</item>
+    </style>
 
     <style name="TextAppearance.Widget.Home.ItemDescription" parent="TextAppearance.Micro">
         <item name="android:textColor">@color/tabs_tray_icon_grey</item>
     </style>
 
     <style name="TextAppearance.Widget.HomeBanner" parent="TextAppearance.Small">
         <item name="android:textColor">?android:attr/textColorHint</item>
     </style>