Remove chip scroll view

pull/757/head
Alex Baker 6 years ago
parent 178d22c7f1
commit e5d31ec750

@ -241,4 +241,8 @@ public class Locale {
public String getCountry() {
return appLocale.getCountry();
}
public boolean isRtl() {
return appDirectionality == View.LAYOUT_DIRECTION_RTL;
}
}

@ -1,6 +1,7 @@
package org.tasks.tasklist;
import static com.google.common.collect.Lists.newArrayList;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybeanMR1;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastKitKat;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
@ -10,9 +11,8 @@ import android.graphics.Paint;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
@ -24,13 +24,13 @@ import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
import com.google.common.collect.Lists;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.activity.MainActivity;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.ui.CheckableImageView;
import java.util.List;
import org.tasks.R;
import org.tasks.locale.Locale;
import org.tasks.preferences.Preferences;
import org.tasks.ui.CheckBoxes;
import org.tasks.ui.ChipProvider;
@ -71,9 +71,6 @@ class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.completeBox)
CheckableImageView completeBox;
@BindView(R.id.chip_scroll)
HorizontalScrollView chipScroll;
@BindView(R.id.chip_group)
ChipGroup chipGroup;
@ -86,6 +83,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
ViewHolder(
Context context,
Locale locale,
ViewGroup view,
Preferences preferences,
int fontSize,
@ -130,10 +128,8 @@ class ViewHolder extends RecyclerView.ViewHolder {
if (atLeastKitKat()) {
rowBody.setPadding(0, rowPadding, 0, rowPadding);
} else {
ViewGroup.MarginLayoutParams layoutParams =
(ViewGroup.MarginLayoutParams) rowBody.getLayoutParams();
layoutParams.setMargins(
layoutParams.leftMargin, rowPadding, layoutParams.rightMargin, rowPadding);
MarginLayoutParams lp = (MarginLayoutParams) rowBody.getLayoutParams();
lp.setMargins(lp.leftMargin, rowPadding, lp.rightMargin, rowPadding);
}
nameView.setTextSize(fontSize);
@ -141,6 +137,14 @@ class ViewHolder extends RecyclerView.ViewHolder {
fontSizeDetails = Math.max(10, fontSize - 2);
dueDate.setTextSize(fontSizeDetails);
if (atLeastJellybeanMR1()) {
chipGroup.setLayoutDirection(
locale.isRtl() ? View.LAYOUT_DIRECTION_LTR : View.LAYOUT_DIRECTION_RTL);
} else {
MarginLayoutParams lp = (MarginLayoutParams) chipGroup.getLayoutParams();
lp.setMargins(lp.rightMargin, lp.topMargin, lp.leftMargin, lp.bottomMargin);
}
view.setTag(this);
for (int i = 0; i < view.getChildCount(); i++) {
view.getChildAt(i).setTag(this);
@ -175,8 +179,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
this.indent = indent;
int indentSize = getIndentSize(indent);
if (atLeastLollipop()) {
ViewGroup.MarginLayoutParams layoutParams =
(ViewGroup.MarginLayoutParams) row.getLayoutParams();
MarginLayoutParams layoutParams = (MarginLayoutParams) row.getLayoutParams();
layoutParams.setMarginStart(indentSize);
} else {
rowBody.setPadding(indentSize, rowBody.getPaddingTop(), 0, rowBody.getPaddingBottom());
@ -264,7 +267,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
List<Chip> chips = chipProvider.getChips(task.getCaldav(), task.getGoogleTaskList(), tagUuids);
if (chips.isEmpty()) {
chipScroll.setVisibility(View.GONE);
chipGroup.setVisibility(View.GONE);
} else {
chipGroup.removeAllViews();
for (Chip chip : chips) {
@ -272,7 +275,7 @@ class ViewHolder extends RecyclerView.ViewHolder {
chip.setOnClickListener(view -> callback.onClick((Filter) view.getTag()));
chipGroup.addView(chip);
}
chipScroll.setVisibility(View.VISIBLE);
chipGroup.setVisibility(View.VISIBLE);
}
}

@ -13,6 +13,7 @@ import com.todoroo.astrid.dao.TaskDao;
import javax.inject.Inject;
import org.tasks.R;
import org.tasks.injection.ForActivity;
import org.tasks.locale.Locale;
import org.tasks.preferences.Preferences;
import org.tasks.ui.CheckBoxes;
import org.tasks.ui.ChipProvider;
@ -23,6 +24,7 @@ public class ViewHolderFactory {
private final int textColorSecondary;
private final int textColorOverdue;
private final Context context;
private final Locale locale;
private final CheckBoxes checkBoxes;
private final ChipProvider chipProvider;
private final int fontSize;
@ -36,11 +38,13 @@ public class ViewHolderFactory {
@Inject
public ViewHolderFactory(
@ForActivity Context context,
Locale locale,
Preferences preferences,
CheckBoxes checkBoxes,
ChipProvider chipProvider,
TaskDao taskDao) {
this.context = context;
this.locale = locale;
this.checkBoxes = checkBoxes;
this.chipProvider = chipProvider;
this.taskDao = taskDao;
@ -58,6 +62,7 @@ public class ViewHolderFactory {
ViewHolder newViewHolder(ViewGroup parent, ViewHolder.ViewHolderCallbacks callbacks) {
return new ViewHolder(
context,
locale,
(ViewGroup)
LayoutInflater.from(context).inflate(R.layout.task_adapter_row_simple, parent, false),
preferences,

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rowBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -88,31 +87,15 @@
android:maxLines="2"
android:textColor="@color/text_secondary"/>
<HorizontalScrollView
android:id="@+id/chip_scroll"
android:layout_width="wrap_content"
<com.google.android.material.chip.ChipGroup
android:id="@+id/chip_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:clipChildren="false"
android:scrollbarThumbHorizontal="@android:color/transparent">
<com.google.android.material.chip.ChipGroup
android:id="@+id/chip_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="@dimen/keyline_first"
android:layout_marginLeft="0dp"
android:layout_marginRight="@dimen/keyline_first"
android:layout_gravity="end"
android:paddingStart="@dimen/keyline_content_inset"
android:paddingLeft="@dimen/keyline_content_inset"
android:clipToPadding="false"
app:singleLine="true">
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
android:paddingTop="2dp"
android:layout_marginStart="@dimen/keyline_first"
android:layout_marginLeft="@dimen/keyline_first"
android:layout_marginRight="@dimen/keyline_content_inset"
android:layout_marginEnd="@dimen/keyline_content_inset"/>
</LinearLayout>
Loading…
Cancel
Save