Bug 1196387 - Remove unneeded "reading time" code and layouts. r=sebastian
authorJustin Inouye <inouju@gmail.com>
Fri, 28 Aug 2015 01:31:00 +0200
changeset 297563 7be913efcdfb1471ad21c5333951262f366fdaf2
parent 297562 1f677189c1996dba29d3b347e1f211a60390d5d7
child 297564 d21e7e92f11affeab4ef0fcb1de870c5886199f3
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1196387
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1196387 - Remove unneeded "reading time" code and layouts. r=sebastian
mobile/android/base/home/ReadingListRow.java
mobile/android/base/resources/layout/reading_list_item_row.xml
mobile/android/base/resources/layout/reading_list_row_view.xml
--- a/mobile/android/base/home/ReadingListRow.java
+++ b/mobile/android/base/home/ReadingListRow.java
@@ -1,62 +1,45 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * 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 org.mozilla.gecko.R;
-import org.mozilla.gecko.Tab;
-import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.db.BrowserContract.ReadingListItems;
-import org.mozilla.gecko.home.TwoLinePageRow;
 import org.mozilla.gecko.util.StringUtils;
 
 import android.content.Context;
-import android.content.res.Resources;
 import android.database.Cursor;
 import android.text.TextUtils;
 import android.util.AttributeSet;
-import android.view.LayoutInflater;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
 public class ReadingListRow extends LinearLayout {
-
-    private final Resources resources;
-
-    private final TextView title;
-    private final TextView excerpt;
-    private final TextView readTime;
-    private final ImageView indicator;
-
-    // Average reading speed in words per minute.
-    private static final int AVERAGE_READING_SPEED = 250;
-
-    // Length of average word.
-    private static final float AVERAGE_WORD_LENGTH = 5.1f;
-
+    private TextView title;
+    private TextView excerpt;
+    private ImageView indicator;
 
     public ReadingListRow(Context context) {
         this(context, null);
     }
 
     public ReadingListRow(Context context, AttributeSet attrs) {
         super(context, attrs);
-
-        LayoutInflater.from(context).inflate(R.layout.reading_list_row_view, this);
+    }
 
-        resources = context.getResources();
-
+    @Override
+    protected void onFinishInflate() {
+        super.onFinishInflate();
         title = (TextView) findViewById(R.id.title);
         excerpt = (TextView) findViewById(R.id.excerpt);
-        readTime = (TextView) findViewById(R.id.read_time);
         indicator = (ImageView) findViewById(R.id.indicator);
     }
 
     public void updateFromCursor(Cursor cursor) {
         if (cursor == null) {
             return;
         }
 
@@ -68,33 +51,11 @@ public class ReadingListRow extends Line
         title.setText(TextUtils.isEmpty(titleText) ? StringUtils.stripCommonSubdomains(StringUtils.stripScheme(url)) : titleText);
         title.setTextAppearance(getContext(), isUnread ? R.style.Widget_ReadingListRow_Title_Unread : R.style.Widget_ReadingListRow_Title_Read);
 
         final String excerptText = cursor.getString(cursor.getColumnIndexOrThrow(ReadingListItems.EXCERPT));
         excerpt.setText(TextUtils.isEmpty(excerptText) ? url : excerptText);
         excerpt.setTextAppearance(getContext(), isUnread ? R.style.Widget_ReadingListRow_Title_Unread : R.style.Widget_ReadingListRow_Title_Read);
 
         indicator.setImageResource(isUnread ? R.drawable.reading_list_indicator_unread : R.drawable.reading_list_indicator_read);
-
-        /* Disabled until UX issues are fixed (see bug 1110461).
-        final int lengthIndex = cursor.getColumnIndexOrThrow(ReadingListItems.LENGTH);
-        final int minutes = getEstimatedReadTime(cursor.getInt(lengthIndex));
-        if (minutes <= 60) {
-            readTime.setText(resources.getString(R.string.reading_list_time_minutes, minutes));
-        } else {
-            readTime.setText(resources.getString(R.string.reading_list_time_over_an_hour));
-        }
-        */
     }
 
-    /**
-     * Calculates the estimated time to read an article based on its length.
-     *
-     * @param length of the article (in characters)
-     * @return estimated time to read the article (in minutes)
-     */
-    private static int getEstimatedReadTime(int length) {
-        final int minutes = (int) Math.ceil((length / AVERAGE_WORD_LENGTH) / AVERAGE_READING_SPEED);
-
-        // Minimum of one minute.
-        return Math.max(minutes, 1);
-    }
 }
--- a/mobile/android/base/resources/layout/reading_list_item_row.xml
+++ b/mobile/android/base/resources/layout/reading_list_item_row.xml
@@ -1,9 +1,36 @@
 <?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/. -->
 
 <org.mozilla.gecko.home.ReadingListRow xmlns:android="http://schemas.android.com/apk/res/android"
                                        android:layout_width="match_parent"
                                        android:layout_height="@dimen/reading_list_row_height"
-                                       android:layout_gravity="center_vertical"/>
+                                       android:layout_gravity="center_vertical">
+
+    <ImageView android:id="@+id/indicator"
+               android:layout_width="64dp"
+               android:layout_height="match_parent"
+               android:scaleType="center" />
+
+    <LinearLayout android:layout_width="0dip"
+                  android:layout_height="match_parent"
+                  android:layout_weight="1"
+                  android:paddingRight="@dimen/reading_list_row_padding_right"
+                  android:orientation="vertical"
+                  android:gravity="center_vertical">
+
+        <TextView android:id="@+id/title"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  android:paddingBottom="4dp"
+                  style="@style/Widget.ReadingListRow.Title" />
+
+        <TextView android:id="@+id/excerpt"
+                  android:layout_width="match_parent"
+                  android:layout_height="wrap_content"
+                  style="@style/Widget.ReadingListRow.Description" />
+
+    </LinearLayout>
+
+</org.mozilla.gecko.home.ReadingListRow>
deleted file mode 100644
--- a/mobile/android/base/resources/layout/reading_list_row_view.xml
+++ /dev/null
@@ -1,45 +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/. -->
-
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <ImageView
-        android:id="@+id/indicator"
-        android:layout_width="64dp"
-        android:layout_height="match_parent"
-        android:scaleType="center" />
-
-    <LinearLayout
-        android:layout_width="0dip"
-        android:layout_height="match_parent"
-        android:layout_weight="1"
-        android:paddingRight="@dimen/reading_list_row_padding_right"
-        android:orientation="vertical"
-        android:gravity="center_vertical">
-
-        <TextView
-            android:id="@+id/title"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingBottom="4dp"
-            style="@style/Widget.ReadingListRow.Title" />
-
-        <TextView
-            android:id="@+id/excerpt"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            style="@style/Widget.ReadingListRow.Description" />
-
-    </LinearLayout>
-
-    <TextView
-        android:id="@+id/read_time"
-        android:layout_width="64dp"
-        android:layout_height="match_parent"
-        android:gravity="center"
-        android:visibility="gone"
-        style="@style/Widget.ReadingListRow.ReadTime" />
-
-</merge>