Increase checkbox touch target

gtask_related_email
Alex Baker 5 years ago
parent 1e991bc49f
commit 861f99b22f

@ -13,8 +13,8 @@ import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.widget.TextViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -44,6 +44,7 @@ public class ViewHolder extends RecyclerView.ViewHolder {
private final DisplayMetrics metrics;
private final int background;
private final int selectedColor;
private final int rowPadding;
private final Linkify linkify;
private final int textColorOverdue;
private final ChipProvider chipProvider;
@ -71,9 +72,6 @@ public class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.chip_group)
ChipGroup chipGroup;
@BindView(R.id.hidden_status)
ImageView hidden;
private int indent;
private boolean selected;
private boolean moving;
@ -106,6 +104,7 @@ public class ViewHolder extends RecyclerView.ViewHolder {
this.metrics = metrics;
this.background = background;
this.selectedColor = selectedColor;
this.rowPadding = rowPadding;
this.linkify = linkify;
ButterKnife.bind(this, view);
@ -122,7 +121,8 @@ public class ViewHolder extends RecyclerView.ViewHolder {
}
if (atLeastKitKat()) {
rowBody.setPadding(0, rowPadding, 0, rowPadding);
setTopPadding(rowPadding, nameView, completeBox);
setBottomPadding(rowPadding, completeBox);
} else {
MarginLayoutParams lp = (MarginLayoutParams) rowBody.getLayoutParams();
lp.setMargins(lp.leftMargin, rowPadding, lp.rightMargin, rowPadding);
@ -139,6 +139,18 @@ public class ViewHolder extends RecyclerView.ViewHolder {
}
}
private void setTopPadding(int padding, View... views) {
for (View v : views) {
v.setPadding(v.getPaddingLeft(), padding, v.getPaddingRight(), v.getPaddingBottom());
}
}
private void setBottomPadding(int padding, View... views) {
for (View v : views) {
v.setPadding(v.getPaddingLeft(), v.getPaddingTop(), v.getPaddingRight(), padding);
}
}
boolean isMoving() {
return moving;
}
@ -188,7 +200,8 @@ public class ViewHolder extends RecyclerView.ViewHolder {
this.indent = task.indent;
nameView.setText(task.getTitle());
hidden.setVisibility(task.isHidden() ? View.VISIBLE : View.GONE);
TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
nameView, task.isHidden() ? R.drawable.ic_outline_visibility_off_24px : 0, 0, 0, 0);
setupTitleAndCheckbox();
setupDueDate();
if (preferences.getBoolean(R.string.p_show_list_indicators, true)) {
@ -206,6 +219,17 @@ public class ViewHolder extends RecyclerView.ViewHolder {
description.setOnClickListener(view -> onRowBodyClick());
description.setOnLongClickListener(view -> onRowBodyLongClick());
}
if (atLeastKitKat()) {
if (chipGroup.getVisibility() == View.VISIBLE) {
setBottomPadding(rowPadding, chipGroup);
setBottomPadding(0, description, nameView);
} else if (description.getVisibility() == View.VISIBLE) {
setBottomPadding(rowPadding, description);
setBottomPadding(0, nameView);
} else {
setBottomPadding(rowPadding, nameView);
}
}
}
private void setupTitleAndCheckbox() {

@ -35,27 +35,13 @@
android:singleLine="true"
android:textSize="14sp"/>
<ImageView
android:id="@+id/hidden_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_toEndOf="@id/completeBox"
android:layout_toRightOf="@id/completeBox"
android:paddingEnd="2dp"
android:paddingRight="2dp"
android:alpha="@dimen/alpha_secondary"
android:src="@drawable/ic_outline_visibility_off_24px"
android:tint="@color/icon_tint"
android:visibility="gone"/>
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/hidden_status"
android:layout_toEndOf="@id/completeBox"
android:layout_toLeftOf="@id/due_date"
android:layout_toRightOf="@id/hidden_status"
android:layout_toRightOf="@id/completeBox"
android:layout_toStartOf="@id/due_date"
android:paddingStart="0dp"
android:paddingEnd="@dimen/keyline_first"
@ -67,7 +53,9 @@
android:singleLine="true"
android:textAlignment="viewStart"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/task_edit_text_size"/>
android:textSize="@dimen/task_edit_text_size"
android:drawablePadding="2dp"
app:drawableTint="@color/icon_tint_with_alpha"/>
<TextView
android:id="@+id/description"

@ -4,6 +4,7 @@
<color name="content_background">@color/grey_800</color>
<color name="dialog_background">@color/grey_800</color>
<color name="icon_tint">@color/icon_tint_dark</color>
<color name="icon_tint_with_alpha">@color/icon_tint_dark_alpha</color>
<color name="drawer_color">@color/drawer_background_dark</color>
<color name="drawer_color_selected">@color/drawer_background_dark_selected</color>
<color name="text_secondary">@color/white_70</color>

@ -101,6 +101,8 @@
<color name="widget_background_black">#000000</color>
<color name="icon_tint_light">@android:color/black</color>
<color name="icon_tint_dark">@android:color/white</color>
<color name="icon_tint_light_alpha">@color/black_54</color>
<color name="icon_tint_dark_alpha">@color/white_70</color>
<color name="drawer_background_light">#f9f9f9</color>
<color name="drawer_background_light_selected">#e8e8e8</color>
@ -126,6 +128,7 @@
<color name="content_background">@android:color/white</color>
<color name="dialog_background">@android:color/white</color>
<color name="icon_tint">@color/icon_tint_light</color>
<color name="icon_tint_with_alpha">@color/icon_tint_light_alpha</color>
<color name="drawer_color">@color/drawer_background_light</color>
<color name="drawer_color_selected">@color/drawer_background_light_selected</color>
<color name="text_secondary">@color/black_54</color>

Loading…
Cancel
Save