diff --git a/app/src/main/java/org/tasks/ui/ChipProvider.java b/app/src/main/java/org/tasks/ui/ChipProvider.java
new file mode 100644
index 000000000..6dfa3dcb8
--- /dev/null
+++ b/app/src/main/java/org/tasks/ui/ChipProvider.java
@@ -0,0 +1,41 @@
+package org.tasks.ui;
+
+import static org.tasks.preferences.ResourceResolver.getDimen;
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import com.google.android.material.chip.Chip;
+import com.todoroo.astrid.api.Filter;
+import javax.inject.Inject;
+import org.tasks.R;
+import org.tasks.injection.ForActivity;
+import org.tasks.themes.ThemeCache;
+import org.tasks.themes.ThemeColor;
+
+public class ChipProvider {
+
+ private final ThemeCache themeCache;
+ private final int iconAlpha;
+
+ @Inject
+ public ChipProvider(@ForActivity Context context, ThemeCache themeCache) {
+ this.themeCache = themeCache;
+ iconAlpha = (int) (255 * getDimen(context, R.dimen.alpha_secondary));
+ }
+
+ public void apply(Chip chip, Filter filter) {
+ int tint = filter.tint;
+ ThemeColor color = tint >= 0 ? themeCache.getThemeColor(tint) : themeCache.getUntaggedColor();
+ chip.setText(filter.listingTitle);
+ chip.setCloseIconTint(
+ new ColorStateList(new int[][] {new int[] {}}, new int[] {color.getActionBarTint()}));
+ chip.setTextColor(color.getActionBarTint());
+ chip.getChipDrawable().setAlpha(iconAlpha);
+ chip.setChipBackgroundColor(
+ new ColorStateList(
+ new int[][] {
+ new int[] {-android.R.attr.state_checked}, new int[] {android.R.attr.state_checked}
+ },
+ new int[] {color.getPrimaryColor(), color.getPrimaryColor()}));
+ }
+}
diff --git a/app/src/main/java/org/tasks/ui/RemoteListFragment.java b/app/src/main/java/org/tasks/ui/RemoteListFragment.java
index 5b4c3dcad..072d14f66 100644
--- a/app/src/main/java/org/tasks/ui/RemoteListFragment.java
+++ b/app/src/main/java/org/tasks/ui/RemoteListFragment.java
@@ -12,6 +12,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
+import com.google.android.material.chip.Chip;
import com.todoroo.astrid.api.CaldavFilter;
import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.GtasksFilter;
@@ -39,14 +40,18 @@ public class RemoteListFragment extends TaskEditControlFragment {
private static final String EXTRA_SELECTED_LIST = "extra_selected_list";
private static final int REQUEST_CODE_SELECT_LIST = 10101;
- @BindView(R.id.google_task_list)
+ @BindView(R.id.dont_sync)
TextView textView;
+ @BindView(R.id.chip)
+ Chip chip;
+
@Inject GtasksListService gtasksListService;
@Inject GoogleTaskDao googleTaskDao;
@Inject CaldavDao caldavDao;
@Inject DefaultFilterProvider defaultFilterProvider;
@Inject TaskMover taskMover;
+ @Inject ChipProvider chipProvider;
@Nullable private Filter originalList;
@Nullable private Filter selectedList;
@@ -94,10 +99,17 @@ public class RemoteListFragment extends TaskEditControlFragment {
selectedList = originalList;
}
+ chip.setOnCloseIconClickListener(this::clearSelected);
+
refreshView();
return view;
}
+ private void clearSelected(View ignored) {
+ selectedList = null;
+ refreshView();
+ }
+
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -125,7 +137,7 @@ public class RemoteListFragment extends TaskEditControlFragment {
return TAG;
}
- @OnClick(R.id.google_task_list)
+ @OnClick({R.id.remote_list_row, R.id.chip})
void clickGoogleTaskList(View view) {
newRemoteListSupportPicker(selectedList, this, REQUEST_CODE_SELECT_LIST)
.show(getFragmentManager(), FRAG_TAG_GOOGLE_TASK_LIST_SELECTION);
@@ -169,6 +181,13 @@ public class RemoteListFragment extends TaskEditControlFragment {
}
private void refreshView() {
- textView.setText(selectedList == null ? null : selectedList.listingTitle);
+ if (selectedList == null) {
+ textView.setVisibility(View.VISIBLE);
+ chip.setVisibility(View.GONE);
+ } else {
+ textView.setVisibility(View.GONE);
+ chip.setVisibility(View.VISIBLE);
+ chipProvider.apply(chip, selectedList);
+ }
}
}
diff --git a/app/src/main/res/layout/control_set_remote_list.xml b/app/src/main/res/layout/control_set_remote_list.xml
index defa09b63..e07c3ee04 100644
--- a/app/src/main/res/layout/control_set_remote_list.xml
+++ b/app/src/main/res/layout/control_set_remote_list.xml
@@ -1,10 +1,26 @@
-
+ android:orientation="vertical">
+
+
+
+
+