Tint textfield underline

pull/322/head
Alex Baker 9 years ago
parent d918cc73d4
commit f82cbeee42

@ -24,7 +24,7 @@ import org.joda.time.DateTime;
import org.tasks.R;
import org.tasks.dialogs.MyDatePickerDialog;
import org.tasks.dialogs.MyTimePickerDialog;
import org.tasks.preferences.Preferences;
import org.tasks.preferences.ActivityPreferences;
import java.util.ArrayList;
import java.util.List;
@ -34,7 +34,6 @@ import static com.todoroo.andlib.utility.AndroidUtilities.atLeastHoneycomb;
import static java.util.Arrays.asList;
import static org.tasks.date.DateTimeUtils.newDate;
import static org.tasks.date.DateTimeUtils.newDateTime;
import static org.tasks.preferences.ResourceResolver.getResource;
public class DeadlineControlSet extends TaskEditControlSetBase {
@ -57,6 +56,7 @@ public class DeadlineControlSet extends TaskEditControlSetBase {
private final String tomorrowString;
private FragmentActivity activity;
private ActivityPreferences preferences;
private Spinner dueDateSpinner;
private Spinner dueTimeSpinner;
private View clearButton;
@ -65,9 +65,10 @@ public class DeadlineControlSet extends TaskEditControlSetBase {
private long date = 0;
private int time = -1;
public DeadlineControlSet(FragmentActivity activity, Preferences preferences) {
public DeadlineControlSet(FragmentActivity activity, ActivityPreferences preferences) {
super(activity, R.layout.control_set_deadline);
this.activity = activity;
this.preferences = preferences;
dateShortcutMorning = preferences.getDateShortcutMorning();
dateShortcutAfternoon = preferences.getDateShortcutAfternoon();
dateShortcutEvening = preferences.getDateShortcutEvening();
@ -184,26 +185,26 @@ public class DeadlineControlSet extends TaskEditControlSetBase {
if (atLeastHoneycomb()) {
if (date == 0) {
dueDateSpinner.setAlpha(0.5f);
dueDateSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueDateSpinner.setBackground(getThemedUnderline());
} else {
dueDateSpinner.setAlpha(1.0f);
if (date < newDateTime().withMillisOfDay(0).getMillis()) {
dueDateSpinner.setBackground(getRedTextfieldUnderline());
dueDateSpinner.setBackground(getRedUnderline());
tv.setTextColor(activity.getResources().getColor(R.color.overdue));
} else {
dueDateSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueDateSpinner.setBackground(getThemedUnderline());
tv.setTextColor(themeColor);
}
}
} else {
if (date == 0) {
dueDateSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueDateSpinner.setBackground(getThemedUnderline());
tv.setTextColor(unsetColor);
} else if (date < newDateTime().withMillisOfDay(0).getMillis()) {
dueDateSpinner.setBackground(getRedTextfieldUnderline());
dueDateSpinner.setBackground(getRedUnderline());
tv.setTextColor(activity.getResources().getColor(R.color.overdue));
} else {
dueDateSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueDateSpinner.setBackground(getThemedUnderline());
tv.setTextColor(themeColor);
}
}
@ -245,26 +246,26 @@ public class DeadlineControlSet extends TaskEditControlSetBase {
if (atLeastHoneycomb()) {
if (time == -1) {
dueTimeSpinner.setAlpha(0.5f);
dueTimeSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueTimeSpinner.setBackground(getThemedUnderline());
} else {
dueTimeSpinner.setAlpha(1.0f);
if (newDateTime(date).withMillisOfDay(time).isBeforeNow()) {
dueTimeSpinner.setBackground(getRedTextfieldUnderline());
dueTimeSpinner.setBackground(getRedUnderline());
tv.setTextColor(activity.getResources().getColor(R.color.overdue));
} else {
dueTimeSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueTimeSpinner.setBackground(getThemedUnderline());
tv.setTextColor(themeColor);
}
}
} else {
if (time == -1) {
dueTimeSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueTimeSpinner.setBackground(getThemedUnderline());
tv.setTextColor(unsetColor);
} else if (newDateTime(date).withMillisOfDay(time).isBeforeNow()) {
dueTimeSpinner.setBackground(getRedTextfieldUnderline());
dueTimeSpinner.setBackground(getRedUnderline());
tv.setTextColor(activity.getResources().getColor(R.color.overdue));
} else {
dueTimeSpinner.setBackgroundResource(getResource(activity, R.attr.textfield_underline));
dueTimeSpinner.setBackground(getThemedUnderline());
tv.setTextColor(themeColor);
}
}
@ -391,11 +392,18 @@ public class DeadlineControlSet extends TaskEditControlSetBase {
});
}
private Drawable getRedTextfieldUnderline() {
Drawable normalDrawable = activity.getResources().getDrawable(R.drawable.textfield_underline_black);
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
DrawableCompat.setTint(wrapDrawable, activity.getResources().getColor(R.color.overdue));
return wrapDrawable;
private Drawable getThemedUnderline() {
Drawable drawable = DrawableCompat.wrap(activity.getResources().getDrawable(R.drawable.textfield_underline_black));
DrawableCompat.setTint(drawable, activity.getResources().getColor(preferences.isDarkTheme()
? android.R.color.white
: android.R.color.black));
return drawable;
}
private Drawable getRedUnderline() {
Drawable drawable = DrawableCompat.wrap(activity.getResources().getDrawable(R.drawable.textfield_underline_black));
DrawableCompat.setTint(drawable, activity.getResources().getColor(R.color.overdue));
return drawable;
}
private void setDate(long millis) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

@ -15,7 +15,7 @@
android:id="@+id/due_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/textfield_underline" />
android:background="@null" />
<Spinner
android:id="@+id/due_time"
@ -23,7 +23,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:background="?attr/textfield_underline" />
android:background="@null" />
</LinearLayout>

@ -29,7 +29,6 @@
<attr name="toolbarSeparatorHeight" format="dimension" />
<attr name="separatorHeight" format="dimension" />
<attr name="popup_theme" format="reference" />
<attr name="textfield_underline" format="reference" />
<declare-styleable name="DateAndTimePicker">
<attr name="shortcutLabels" format="reference" />

@ -39,7 +39,6 @@
<item name="asListDividerColor">#dddddd</item>
<item name="asThemeTextColor">@color/dark_blue_theme_color</item>
<item name="importance_background_selected">@drawable/importance_background_selected</item>
<item name="textfield_underline">@drawable/textfield_underline_white</item>
<item name="android:spinnerItemStyle">@style/SpinnerNoPadding</item>
</style>

@ -38,7 +38,6 @@
<item name="fab_tint">@android:color/white</item>
<item name="importance_background_selected">@drawable/importance_background_selected</item>
<item name="task_edit_divider">@color/task_edit_divider</item>
<item name="textfield_underline">@drawable/textfield_underline_black</item>
<item name="android:spinnerItemStyle">@style/SpinnerNoPadding</item>
</style>

Loading…
Cancel
Save