зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1196387 - Remove unneeded "reading time" code and layouts. r=sebastian
This commit is contained in:
Родитель
863f6acc48
Коммит
d536f8c730
|
@ -6,37 +6,21 @@
|
|||
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);
|
||||
|
@ -44,14 +28,13 @@ public class ReadingListRow extends LinearLayout {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -73,28 +56,6 @@ public class ReadingListRow extends LinearLayout {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,4 +6,31 @@
|
|||
<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>
|
||||
|
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче