mirror of https://github.com/tasks/tasks
Use material chip for remote list picker
parent
dddfa528d2
commit
61ba538c1b
@ -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()}));
|
||||
}
|
||||
}
|
@ -1,10 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/google_task_list"
|
||||
style="@style/TaskEditTextPrimary"
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/remote_list_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:gravity="start"
|
||||
android:hint="@string/dont_sync"
|
||||
android:textAlignment="viewStart"/>
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dont_sync"
|
||||
style="@style/TaskEditTextPrimary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:gravity="start"
|
||||
android:hint="@string/dont_sync"
|
||||
android:textAlignment="viewStart"/>
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/chip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:closeIconEnabled="true"/>
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue