Add description to task list view

pull/757/head
Alex Baker 7 years ago
parent 709e97a66b
commit f7f03e68ac

@ -49,6 +49,8 @@ public class AppearancePreferences extends InjectingPreferenceActivity
setExtraOnChange(R.string.p_fontSize, EXTRA_RESTART); setExtraOnChange(R.string.p_fontSize, EXTRA_RESTART);
setExtraOnChange(R.string.p_rowPadding, EXTRA_RESTART); setExtraOnChange(R.string.p_rowPadding, EXTRA_RESTART);
setExtraOnChange(R.string.p_fullTaskTitle, EXTRA_RESTART); setExtraOnChange(R.string.p_fullTaskTitle, EXTRA_RESTART);
setExtraOnChange(R.string.p_show_description, EXTRA_RESTART);
setExtraOnChange(R.string.p_show_full_description, EXTRA_RESTART);
setExtraOnChange(R.string.p_show_today_filter, EXTRA_FILTERS_CHANGED); setExtraOnChange(R.string.p_show_today_filter, EXTRA_FILTERS_CHANGED);
setExtraOnChange(R.string.p_show_recently_modified_filter, EXTRA_FILTERS_CHANGED); setExtraOnChange(R.string.p_show_recently_modified_filter, EXTRA_FILTERS_CHANGED);
setExtraOnChange(R.string.p_show_not_in_list_filter, EXTRA_FILTERS_CHANGED); setExtraOnChange(R.string.p_show_not_in_list_filter, EXTRA_FILTERS_CHANGED);

@ -24,11 +24,13 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.ui.CheckableImageView; import com.todoroo.astrid.ui.CheckableImageView;
import java.util.List; import java.util.List;
import org.tasks.R; import org.tasks.R;
import org.tasks.preferences.Preferences;
import org.tasks.ui.CheckBoxes; import org.tasks.ui.CheckBoxes;
class ViewHolder extends RecyclerView.ViewHolder { class ViewHolder extends RecyclerView.ViewHolder {
private final Context context; private final Context context;
private final Preferences preferences;
private final CheckBoxes checkBoxes; private final CheckBoxes checkBoxes;
private final TagFormatter tagFormatter; private final TagFormatter tagFormatter;
private final int textColorSecondary; private final int textColorSecondary;
@ -53,6 +55,9 @@ class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.title) @BindView(R.id.title)
TextView nameView; TextView nameView;
@BindView(R.id.description)
TextView description;
@BindView(R.id.completeBox) @BindView(R.id.completeBox)
CheckableImageView completeBox; CheckableImageView completeBox;
@ -66,7 +71,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
ViewHolder( ViewHolder(
Context context, Context context,
ViewGroup view, ViewGroup view,
boolean showFullTaskTitle, Preferences preferences,
int fontSize, int fontSize,
CheckBoxes checkBoxes, CheckBoxes checkBoxes,
TagFormatter tagFormatter, TagFormatter tagFormatter,
@ -80,6 +85,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
int rowPadding) { int rowPadding) {
super(view); super(view);
this.context = context; this.context = context;
this.preferences = preferences;
this.checkBoxes = checkBoxes; this.checkBoxes = checkBoxes;
this.tagFormatter = tagFormatter; this.tagFormatter = tagFormatter;
this.textColorOverdue = textColorOverdue; this.textColorOverdue = textColorOverdue;
@ -91,12 +97,18 @@ class ViewHolder extends RecyclerView.ViewHolder {
this.selectedColor = selectedColor; this.selectedColor = selectedColor;
ButterKnife.bind(this, view); ButterKnife.bind(this, view);
if (showFullTaskTitle) { if (preferences.getBoolean(R.string.p_fullTaskTitle, false)) {
nameView.setMaxLines(Integer.MAX_VALUE); nameView.setMaxLines(Integer.MAX_VALUE);
nameView.setSingleLine(false); nameView.setSingleLine(false);
nameView.setEllipsize(null); nameView.setEllipsize(null);
} }
if (preferences.getBoolean(R.string.p_show_full_description, false)) {
description.setMaxLines(Integer.MAX_VALUE);
description.setSingleLine(false);
description.setEllipsize(null);
}
if (atLeastKitKat()) { if (atLeastKitKat()) {
rowBody.setPadding(0, rowPadding, 0, rowPadding); rowBody.setPadding(0, rowPadding, 0, rowPadding);
} else { } else {
@ -166,11 +178,14 @@ class ViewHolder extends RecyclerView.ViewHolder {
} }
void bindView(Task task) { void bindView(Task task) {
// TODO: see if this is a performance issue
this.task = task; this.task = task;
setFieldContentsAndVisibility(); setFieldContentsAndVisibility();
setTaskAppearance(); setTaskAppearance();
if (preferences.getBoolean(R.string.p_show_description, true)) {
description.setText(task.getNotes());
description.setVisibility(task.hasNotes() ? View.VISIBLE : View.GONE);
}
} }
/** Helper method to set the contents and visibility of each field */ /** Helper method to set the contents and visibility of each field */

@ -23,13 +23,13 @@ public class ViewHolderFactory {
private final Context context; private final Context context;
private final CheckBoxes checkBoxes; private final CheckBoxes checkBoxes;
private final TagFormatter tagFormatter; private final TagFormatter tagFormatter;
private final boolean showFullTaskTitle;
private final int fontSize; private final int fontSize;
private final TaskDao taskDao; private final TaskDao taskDao;
private final DisplayMetrics metrics; private final DisplayMetrics metrics;
private final int background; private final int background;
private final int selectedColor; private final int selectedColor;
private final int rowPadding; private final int rowPadding;
private final Preferences preferences;
@Inject @Inject
public ViewHolderFactory( public ViewHolderFactory(
@ -42,11 +42,11 @@ public class ViewHolderFactory {
this.checkBoxes = checkBoxes; this.checkBoxes = checkBoxes;
this.tagFormatter = tagFormatter; this.tagFormatter = tagFormatter;
this.taskDao = taskDao; this.taskDao = taskDao;
this.preferences = preferences;
textColorSecondary = getData(context, android.R.attr.textColorSecondary); textColorSecondary = getData(context, android.R.attr.textColorSecondary);
textColorOverdue = getColor(context, R.color.overdue); textColorOverdue = getColor(context, R.color.overdue);
background = getResourceId(context, R.attr.selectableItemBackground); background = getResourceId(context, R.attr.selectableItemBackground);
selectedColor = getData(context, R.attr.colorControlHighlight); selectedColor = getData(context, R.attr.colorControlHighlight);
showFullTaskTitle = preferences.getBoolean(R.string.p_fullTaskTitle, false);
fontSize = preferences.getFontSize(); fontSize = preferences.getFontSize();
metrics = context.getResources().getDisplayMetrics(); metrics = context.getResources().getDisplayMetrics();
rowPadding = convertDpToPixels(metrics, preferences.getInt(R.string.p_rowPadding, 16)); rowPadding = convertDpToPixels(metrics, preferences.getInt(R.string.p_rowPadding, 16));
@ -57,7 +57,7 @@ public class ViewHolderFactory {
context, context,
(ViewGroup) (ViewGroup)
LayoutInflater.from(context).inflate(R.layout.task_adapter_row_simple, parent, false), LayoutInflater.from(context).inflate(R.layout.task_adapter_row_simple, parent, false),
showFullTaskTitle, preferences,
fontSize, fontSize,
checkBoxes, checkBoxes,
tagFormatter, tagFormatter,

@ -9,8 +9,6 @@
android:focusable="true" android:focusable="true"
android:orientation="vertical"> android:orientation="vertical">
<!-- row 1 -->
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -64,7 +62,17 @@
</RelativeLayout> </RelativeLayout>
<!-- row 2 --> <TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/keyline_content_inset"
android:paddingEnd="@dimen/keyline_first"
android:paddingLeft="@dimen/keyline_content_inset"
android:paddingRight="@dimen/keyline_first"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/text_secondary"/>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"

@ -292,4 +292,6 @@
<string name="p_purchases">purchases</string> <string name="p_purchases">purchases</string>
<string name="p_sync_ongoing">sync_ongoing</string> <string name="p_sync_ongoing">sync_ongoing</string>
<string name="p_last_backup">last_backup</string> <string name="p_last_backup">last_backup</string>
<string name="p_show_description">show_description</string>
<string name="p_show_full_description">show_full_description</string>
</resources> </resources>

@ -874,4 +874,6 @@ File %1$s contained %2$s.\n\n
<string name="cannot_access_account">Cannot access account</string> <string name="cannot_access_account">Cannot access account</string>
<string name="reinitialize_account">Reinitialize</string> <string name="reinitialize_account">Reinitialize</string>
<string name="action_create_new_task">Create new task</string> <string name="action_create_new_task">Create new task</string>
<string name="show_description">Show description</string>
<string name="show_full_description">Show full description</string>
</resources> </resources>

@ -23,6 +23,17 @@
android:key="@string/p_fullTaskTitle" android:key="@string/p_fullTaskTitle"
android:title="@string/EPr_fullTask_title"/> android:title="@string/EPr_fullTask_title"/>
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/p_show_description"
android:title="@string/show_description" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/p_show_full_description"
android:dependency="@string/p_show_description"
android:title="@string/show_full_description" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/EPr_edit_screen_options"> <PreferenceCategory android:title="@string/EPr_edit_screen_options">

Loading…
Cancel
Save