Add google task list colors

pull/467/head
Alex Baker 8 years ago
parent dd8972c7b6
commit 52f0db8e52

@ -3,11 +3,12 @@ package org.tasks.activities;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TextInputEditText;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
import com.google.api.services.tasks.model.TaskList;
@ -21,6 +22,7 @@ import com.todoroo.astrid.gtasks.GtasksListService;
import org.tasks.R;
import org.tasks.analytics.Tracker;
import org.tasks.analytics.Tracking;
import org.tasks.dialogs.ColorPickerDialog;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.gtasks.CreateListDialog;
import org.tasks.gtasks.DeleteListDialog;
@ -28,12 +30,16 @@ import org.tasks.gtasks.RenameListDialog;
import org.tasks.injection.ActivityComponent;
import org.tasks.injection.ThemedInjectingAppCompatActivity;
import org.tasks.preferences.Preferences;
import org.tasks.themes.ThemeCache;
import org.tasks.themes.ThemeColor;
import org.tasks.ui.MenuColorizer;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnFocusChange;
import static android.text.TextUtils.isEmpty;
import static org.tasks.gtasks.CreateListDialog.newCreateListDialog;
@ -44,31 +50,38 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
implements Toolbar.OnMenuItemClickListener, CreateListDialog.CreateListDialogCallback,
DeleteListDialog.DeleteListDialogCallback, RenameListDialog.RenameListDialogCallback {
private static final String EXTRA_SELECTED_THEME = "extra_selected_theme";
private static final String FRAG_TAG_CREATE_LIST_DIALOG = "frag_tag_create_list_dialog";
private static final String FRAG_TAG_DELETE_LIST_DIALOG = "frag_tag_delete_list_dialog";
private static final String FRAG_TAG_RENAME_LIST_DIALOG = "frag_tag_rename_list_dialog";
private static final int REQUEST_COLOR_PICKER = 10109;
public static final String EXTRA_STORE_DATA = "extra_store_data";
public static final String ACTION_DELETED = "action_deleted";
public static final String ACTION_RENAMED = "action_renamed";
public static final String ACTION_THEME_CHANGED = "action_theme_changed";
private GtasksList gtasksList;
private boolean isNewList;
private GtasksList gtasksList;
private int selectedTheme;
@Inject StoreObjectDao storeObjectDao;
@Inject DialogBuilder dialogBuilder;
@Inject Preferences preferences;
@Inject GtasksListService gtasksListService;
@Inject Tracker tracker;
@Inject ThemeCache themeCache;
@Inject ThemeColor themeColor;
@BindView(R.id.tag_name) EditText listName;
@BindView(R.id.name) TextInputEditText name;
@BindView(R.id.color) TextInputEditText color;
@BindView(R.id.toolbar) Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.filter_settings_activity);
setContentView(R.layout.activity_google_task_list_settings);
ButterKnife.bind(this);
StoreObject storeObject = getIntent().getParcelableExtra(EXTRA_STORE_DATA);
@ -78,6 +91,11 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
storeObject.setType(GtasksList.TYPE);
}
gtasksList = new GtasksList(storeObject);
if (savedInstanceState == null) {
selectedTheme = gtasksList.getColor();
} else {
selectedTheme = savedInstanceState.getInt(EXTRA_SELECTED_THEME);
}
final boolean backButtonSavesTask = preferences.backButtonSavesTask();
toolbar.setTitle(isNewList ? getString(R.string.new_list) : gtasksList.getName());
@ -94,16 +112,43 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
toolbar.setOnMenuItemClickListener(this);
toolbar.showOverflowMenu();
color.setInputType(InputType.TYPE_NULL);
MenuColorizer.colorToolbar(this, toolbar);
if (isNewList) {
toolbar.getMenu().findItem(R.id.delete).setVisible(false);
listName.requestFocus();
name.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(listName, InputMethodManager.SHOW_IMPLICIT);
imm.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT);
} else {
listName.setText(gtasksList.getName());
name.setText(gtasksList.getName());
}
updateTheme();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(EXTRA_SELECTED_THEME, selectedTheme);
}
@OnFocusChange(R.id.color)
void onFocusChange(boolean focused) {
if (focused) {
color.clearFocus();
showThemePicker();
}
}
@OnClick(R.id.color)
protected void showThemePicker() {
Intent intent = new Intent(GoogleTaskListSettingsActivity.this, ColorPickerActivity.class);
intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS);
intent.putExtra(ColorPickerActivity.EXTRA_SHOW_NONE, true);
startActivityForResult(intent, REQUEST_COLOR_PICKER);
}
@Override
@ -126,6 +171,11 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
newRenameListDialog(gtasksList.getRemoteId(), newName)
.show(getSupportFragmentManager(), FRAG_TAG_RENAME_LIST_DIALOG);
} else {
if (colorChanged()) {
gtasksList.setColor(selectedTheme);
storeObjectDao.persist(gtasksList);
setResult(RESULT_OK, new Intent(ACTION_THEME_CHANGED).putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
}
finish();
}
}
@ -133,7 +183,7 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
@Override
public void finish() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(listName.getWindowToken(), 0);
imm.hideSoftInputFromWindow(name.getWindowToken(), 0);
super.finish();
}
@ -176,14 +226,18 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
}
private String getNewName() {
return listName.getText().toString().trim();
return name.getText().toString().trim();
}
private boolean hasChanges() {
if (isNewList) {
return !isEmpty(getNewName());
return selectedTheme >= 0 || !isEmpty(getNewName());
}
return nameChanged();
return colorChanged() || nameChanged();
}
private boolean colorChanged() {
return selectedTheme != gtasksList.getColor();
}
private boolean nameChanged() {
@ -193,10 +247,11 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
@Override
public void onListCreated(TaskList taskList) {
tracker.reportEvent(Tracking.Events.GTASK_NEW_LIST);
GtasksList list = new GtasksList(taskList.getId());
list.setName(taskList.getTitle());
storeObjectDao.persist(list);
setResult(RESULT_OK, new Intent().putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(list)));
gtasksList = new GtasksList(taskList.getId());
gtasksList.setName(taskList.getTitle());
gtasksList.setColor(selectedTheme);
storeObjectDao.persist(gtasksList);
setResult(RESULT_OK, new Intent().putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
finish();
}
@ -212,13 +267,41 @@ public class GoogleTaskListSettingsActivity extends ThemedInjectingAppCompatActi
public void onListRenamed(TaskList taskList) {
tracker.reportEvent(Tracking.Events.GTASK_RENAME_LIST);
gtasksList.setName(taskList.getTitle());
gtasksList.setColor(selectedTheme);
storeObjectDao.persist(gtasksList);
setResult(RESULT_OK, new Intent(ACTION_RENAMED).putExtra(TaskListActivity.OPEN_FILTER, new GtasksFilter(gtasksList)));
finish();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_COLOR_PICKER) {
if (resultCode == RESULT_OK) {
int index = data.getIntExtra(ColorPickerActivity.EXTRA_THEME_INDEX, 0);
tracker.reportEvent(Tracking.Events.GTASK_SET_COLOR, Integer.toString(index));
selectedTheme = index;
updateTheme();
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void requestFailed() {
Toast.makeText(this, R.string.gtasks_GLA_errorIOAuth, Toast.LENGTH_LONG).show();
}
private void updateTheme() {
ThemeColor themeColor;
if (selectedTheme < 0) {
themeColor = this.themeColor;
color.setText(R.string.none);
} else {
themeColor = themeCache.getThemeColor(selectedTheme);
color.setText(themeColor.getName());
}
themeColor.apply(toolbar);
themeColor.applyStatusBarColor(this);
}
}

@ -10,6 +10,7 @@ import org.tasks.dialogs.DialogBuilder;
import org.tasks.gtasks.GoogleTaskListSelectionHandler;
import org.tasks.injection.InjectingNativeDialogFragment;
import org.tasks.injection.NativeDialogFragmentComponent;
import org.tasks.themes.ThemeCache;
import javax.inject.Inject;
@ -19,12 +20,13 @@ public class NativeGoogleTaskListPicker extends InjectingNativeDialogFragment {
@Inject DialogBuilder dialogBuilder;
@Inject GtasksListService gtasksListService;
@Inject ThemeCache themeCache;
private GoogleTaskListSelectionHandler handler;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return createDialog(dialogBuilder, gtasksListService, list -> handler.selectedList(list));
return createDialog(getActivity(), themeCache, dialogBuilder, gtasksListService, list -> handler.selectedList(list));
}
@Override

@ -2,35 +2,47 @@ package org.tasks.activities;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.todoroo.astrid.gtasks.GtasksList;
import com.todoroo.astrid.gtasks.GtasksListService;
import org.tasks.R;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.gtasks.GoogleTaskListSelectionHandler;
import org.tasks.injection.DialogFragmentComponent;
import org.tasks.injection.InjectingDialogFragment;
import org.tasks.themes.ThemeCache;
import org.tasks.themes.ThemeColor;
import java.util.List;
import javax.inject.Inject;
import static com.google.common.collect.Lists.transform;
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybeanMR1;
public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
@Inject DialogBuilder dialogBuilder;
@Inject GtasksListService gtasksListService;
@Inject ThemeCache themeCache;
private GoogleTaskListSelectionHandler handler;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return createDialog(dialogBuilder, gtasksListService, list -> handler.selectedList(list));
return createDialog(getActivity(), themeCache, dialogBuilder, gtasksListService, list -> handler.selectedList(list));
}
@Override
@ -40,11 +52,30 @@ public class SupportGoogleTaskListPicker extends InjectingDialogFragment {
handler = (GoogleTaskListSelectionHandler) activity;
}
public static AlertDialog createDialog(DialogBuilder dialogBuilder, GtasksListService gtasksListService, final GoogleTaskListSelectionHandler handler) {
public static AlertDialog createDialog(Context context, ThemeCache themeCache, DialogBuilder dialogBuilder, GtasksListService gtasksListService, final GoogleTaskListSelectionHandler handler) {
final List<GtasksList> lists = gtasksListService.getLists();
List<String> listNames = transform(lists, GtasksList::getName);
ArrayAdapter<GtasksList> adapter = new ArrayAdapter<GtasksList>(context, R.layout.simple_list_item_single_choice_themed, lists) {
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView view = (TextView) super.getView(position, convertView, parent);
GtasksList list = lists.get(position);
int color = list.getColor();
ThemeColor themeColor = themeCache.getThemeColor(color >= 0 ? color : 19);
view.setText(list.getName());
Drawable original = ContextCompat.getDrawable(getContext(), R.drawable.ic_cloud_black_24dp);
Drawable wrapped = DrawableCompat.wrap(original.mutate());
DrawableCompat.setTint(wrapped, themeColor.getPrimaryColor());
if (atLeastJellybeanMR1()) {
view.setCompoundDrawablesRelativeWithIntrinsicBounds(wrapped, null, null, null);
} else {
view.setCompoundDrawablesWithIntrinsicBounds(wrapped, null, null, null);
}
return view;
}
};
return dialogBuilder.newDialog()
.setItems(listNames, (dialog, which) -> {
.setSingleChoiceItems(adapter, -1, (dialog, which) -> {
handler.selectedList(lists.get(which));
dialog.dismiss();
})

@ -74,9 +74,11 @@ public class GtasksListFragment extends TaskListFragment {
if (requestCode == REQUEST_LIST_SETTINGS) {
if (resultCode == RESULT_OK) {
TaskListActivity activity = (TaskListActivity) getActivity();
if (GoogleTaskListSettingsActivity.ACTION_DELETED.equals(data.getAction())) {
String action = data.getAction();
if (GoogleTaskListSettingsActivity.ACTION_DELETED.equals(action)) {
activity.onFilterItemClicked(null);
} else if (GoogleTaskListSettingsActivity.ACTION_RENAMED.equals(data.getAction())) {
} else if (GoogleTaskListSettingsActivity.ACTION_RENAMED.equals(action) ||
GoogleTaskListSettingsActivity.ACTION_THEME_CHANGED.equals(action)) {
activity.onFilterItemClicked(data.getParcelableExtra(TaskListActivity.OPEN_FILTER));
}
}

@ -100,7 +100,7 @@ public class GoogleTaskListFragment extends TaskEditControlFragment {
@Override
protected int getIcon() {
return R.drawable.ic_cloud_queue_24dp;
return R.drawable.ic_cloud_black_24dp;
}
@Override

@ -19,7 +19,7 @@ import org.tasks.R;
public class GtasksFilter extends Filter {
private static final int CLOUD = R.drawable.ic_cloud_queue_24dp;
private static final int CLOUD = R.drawable.ic_cloud_black_24dp;
private long storeId;
@ -30,6 +30,7 @@ public class GtasksFilter extends Filter {
public GtasksFilter(GtasksList list) {
super(list.getName(), getQueryTemplate(list), getValuesForNewTasks(list));
storeId = list.getId();
tint = list.getColor();
icon = CLOUD;
}

@ -46,7 +46,7 @@ import timber.log.Timber;
@ApplicationScope
public class Database {
private static final int VERSION = 37;
private static final int VERSION = 38;
private static final String NAME = "database";
private static final Table[] TABLES = new Table[] {
Task.TABLE,
@ -121,6 +121,8 @@ public class Database {
tryExecSQL(addColumnSql(TagData.TABLE, TagData.COLOR, visitor, "-1"));
case 36:
tryExecSQL(addColumnSql(StoreObject.TABLE, StoreObject.DELETION_DATE, visitor, "0"));
case 37:
tryExecSQL(addColumnSql(StoreObject.TABLE, StoreObject.VALUE4, visitor, "-1"));
return true;
}

@ -60,6 +60,10 @@ public class StoreObject extends AbstractModel {
public static final StringProperty VALUE3 = new StringProperty(
TABLE, "value3");
/** Store Value Column 3 */
public static final StringProperty VALUE4 = new StringProperty(
TABLE, "value4");
/** Unixtime Task was deleted. 0 means not deleted */
public static final LongProperty DELETION_DATE = new LongProperty(
TABLE, "deleted", Property.PROP_FLAG_DATE);

@ -64,6 +64,16 @@ public class GtasksList {
storeObject.setValue(StoreObject.VALUE2, Integer.toString(order));
}
public int getColor() {
return storeObject.containsNonNullValue(StoreObject.VALUE4)
? Integer.parseInt(storeObject.getValue(StoreObject.VALUE4))
: -1;
}
public void setColor(int color) {
storeObject.setValue(StoreObject.VALUE4, Integer.toString(color));
}
public long getLastSync() {
return storeObject.containsNonNullValue(StoreObject.VALUE3)
? Long.parseLong(storeObject.getValue(StoreObject.VALUE3))

@ -7,6 +7,7 @@ import org.tasks.R;
import org.tasks.billing.PurchaseHelper;
import org.tasks.billing.PurchaseHelperCallback;
import org.tasks.dialogs.ColorPickerDialog;
import org.tasks.dialogs.ColorPickerDialog.ColorPalette;
import org.tasks.dialogs.DialogBuilder;
import org.tasks.injection.ActivityComponent;
import org.tasks.injection.InjectingAppCompatActivity;
@ -21,6 +22,7 @@ public class ColorPickerActivity extends InjectingAppCompatActivity implements C
private static final int REQUEST_PURCHASE = 1006;
public static final String EXTRA_PALETTE = "extra_palette";
public static final String EXTRA_SHOW_NONE = "extra_show_none";
public static final String EXTRA_THEME_INDEX = "extra_index";
@Inject PurchaseHelper purchaseHelper;
@ -35,7 +37,9 @@ public class ColorPickerActivity extends InjectingAppCompatActivity implements C
protected void onPostResume() {
super.onPostResume();
newColorPickerDialog((ColorPickerDialog.ColorPalette) getIntent().getSerializableExtra(EXTRA_PALETTE))
ColorPalette palette = (ColorPalette) getIntent().getSerializableExtra(EXTRA_PALETTE);
boolean showNone = getIntent().getBooleanExtra(EXTRA_SHOW_NONE, false);
newColorPickerDialog(palette, showNone)
.show(getSupportFragmentManager(), FRAG_TAG_COLOR_PICKER);
}
@ -45,7 +49,7 @@ public class ColorPickerActivity extends InjectingAppCompatActivity implements C
}
@Override
public void themePicked(final ColorPickerDialog.ColorPalette palette, final int index) {
public void themePicked(final ColorPalette palette, final int index) {
Intent data = new Intent();
data.putExtra(EXTRA_PALETTE, palette);
data.putExtra(EXTRA_THEME_INDEX, index);

@ -8,11 +8,11 @@ package org.tasks.activities;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TextInputEditText;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
import com.todoroo.astrid.api.CustomFilter;
@ -45,7 +45,7 @@ public class FilterSettingsActivity extends ThemedInjectingAppCompatActivity imp
@Inject DialogBuilder dialogBuilder;
@Inject Preferences preferences;
@BindView(R.id.tag_name) EditText filterName;
@BindView(R.id.name) TextInputEditText name;
@BindView(R.id.toolbar) Toolbar toolbar;
@Override
@ -72,7 +72,7 @@ public class FilterSettingsActivity extends ThemedInjectingAppCompatActivity imp
toolbar.setOnMenuItemClickListener(this);
MenuColorizer.colorToolbar(this, toolbar);
filterName.setText(filter.listingTitle);
name.setText(filter.listingTitle);
}
@Override
@ -82,7 +82,7 @@ public class FilterSettingsActivity extends ThemedInjectingAppCompatActivity imp
private void save() {
String oldName = filter.listingTitle;
String newName = filterName.getText().toString().trim();
String newName = name.getText().toString().trim();
if (isEmpty(newName)) {
Toast.makeText(this, R.string.name_cannot_be_empty, Toast.LENGTH_LONG).show();
@ -102,7 +102,7 @@ public class FilterSettingsActivity extends ThemedInjectingAppCompatActivity imp
@Override
public void finish() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(filterName.getWindowToken(), 0);
imm.hideSoftInputFromWindow(name.getWindowToken(), 0);
super.finish();
}
@ -127,7 +127,7 @@ public class FilterSettingsActivity extends ThemedInjectingAppCompatActivity imp
}
private void discard() {
String tagName = this.filterName.getText().toString().trim();
String tagName = this.name.getText().toString().trim();
if (filter.listingTitle.equals(tagName)) {
finish();
} else {

@ -8,13 +8,12 @@ package org.tasks.activities;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TextInputEditText;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.todoroo.andlib.sql.Criterion;
@ -44,6 +43,7 @@ import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnFocusChange;
import static android.text.TextUtils.isEmpty;
@ -73,10 +73,9 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
@Inject ThemeColor themeColor;
@Inject Tracker tracker;
@BindView(R.id.tag_name) EditText tagName;
@BindView(R.id.name) TextInputEditText name;
@BindView(R.id.color) TextInputEditText color;
@BindView(R.id.toolbar) Toolbar toolbar;
@BindView(R.id.theme) TextView themeName;
@BindView(R.id.clear) View clear;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -112,17 +111,19 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
toolbar.setOnMenuItemClickListener(this);
toolbar.showOverflowMenu();
tagName.setText(tagData.getName());
color.setInputType(InputType.TYPE_NULL);
name.setText(tagData.getName());
String autopopulateName = getIntent().getStringExtra(TOKEN_AUTOPOPULATE_NAME);
if (!isEmpty(autopopulateName)) {
tagName.setText(autopopulateName);
name.setText(autopopulateName);
getIntent().removeExtra(TOKEN_AUTOPOPULATE_NAME);
} else if (isNewTag) {
toolbar.getMenu().findItem(R.id.delete).setVisible(false);
tagName.requestFocus();
name.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(tagName, InputMethodManager.SHOW_IMPLICIT);
imm.showSoftInput(name, InputMethodManager.SHOW_IMPLICIT);
}
updateTheme();
@ -135,26 +136,29 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
outState.putInt(EXTRA_SELECTED_THEME, selectedTheme);
}
@OnClick(R.id.theme_row)
@OnFocusChange(R.id.color)
void onFocusChange(boolean focused) {
if (focused) {
color.clearFocus();
showThemePicker();
}
}
@OnClick(R.id.color)
protected void showThemePicker() {
Intent intent = new Intent(TagSettingsActivity.this, ColorPickerActivity.class);
intent.putExtra(ColorPickerActivity.EXTRA_PALETTE, ColorPickerDialog.ColorPalette.COLORS);
intent.putExtra(ColorPickerActivity.EXTRA_SHOW_NONE, true);
startActivityForResult(intent, REQUEST_COLOR_PICKER);
}
@OnClick(R.id.clear)
void clearColor() {
selectedTheme = -1;
updateTheme();
}
@Override
public void inject(ActivityComponent component) {
component.inject(this);
}
private String getNewName() {
return tagName.getText().toString().trim();
return name.getText().toString().trim();
}
private boolean clashes(String newName) {
@ -206,7 +210,7 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
@Override
public void finish() {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(tagName.getWindowToken(), 0);
imm.hideSoftInputFromWindow(name.getWindowToken(), 0);
super.finish();
}
@ -260,19 +264,16 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
}
private void updateTheme() {
ThemeColor color;
ThemeColor themeColor;
if (selectedTheme < 0) {
color = themeColor;
themeName.setText(R.string.none);
clear.setVisibility(View.GONE);
themeColor = this.themeColor;
color.setText(R.string.none);
} else {
color = themeCache.getThemeColor(selectedTheme);
themeName.setText(color.getName());
clear.setVisibility(View.VISIBLE);
themeColor = themeCache.getThemeColor(selectedTheme);
color.setText(themeColor.getName());
}
color.apply(toolbar);
color.applyStatusBarColor(this);
themeColor.apply(toolbar);
themeColor.applyStatusBarColor(this);
}
@Override

@ -20,6 +20,7 @@ public class Tracking {
GTASK_NEW_LIST(R.string.tracking_category_google_tasks, R.string.tracking_action_new_list),
GTASK_RENAME_LIST(R.string.tracking_category_google_tasks, R.string.tracking_action_rename_list),
GTASK_DELETE_LIST(R.string.tracking_category_google_tasks, R.string.tracking_action_delete_list),
GTASK_SET_COLOR(R.string.tracking_category_google_tasks, R.string.p_theme_color),
UPGRADE(R.string.tracking_category_event, R.string.tracking_event_upgrade),
LEGACY_TASKER_TRIGGER(R.string.tracking_category_event, R.string.tracking_event_legacy_tasker_trigger),
NIGHT_MODE_MISMATCH(R.string.tracking_category_event, R.string.tracking_event_night_mode_mismatch),

@ -8,6 +8,7 @@ import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.view.LayoutInflater;
@ -31,6 +32,7 @@ import static com.todoroo.andlib.utility.AndroidUtilities.atLeastJellybeanMR1;
public class ColorPickerDialog extends InjectingDialogFragment {
private static final String EXTRA_PALETTE = "extra_palette";
private static final String EXTRA_SHOW_NONE = "extra_show_none";
public enum ColorPalette {THEMES, COLORS, ACCENTS, WIDGET_BACKGROUND, LED}
@ -42,9 +44,12 @@ public class ColorPickerDialog extends InjectingDialogFragment {
void dismissed();
}
public static ColorPickerDialog newColorPickerDialog(ColorPalette palette) {
public static ColorPickerDialog newColorPickerDialog(ColorPalette palette, boolean showNone) {
ColorPickerDialog dialog = new ColorPickerDialog();
dialog.palette = palette;
Bundle args = new Bundle();
args.putSerializable(EXTRA_PALETTE, palette);
args.putBoolean(EXTRA_SHOW_NONE, showNone);
dialog.setArguments(args);
return dialog;
}
@ -57,13 +62,16 @@ public class ColorPickerDialog extends InjectingDialogFragment {
private ColorPalette palette;
private ThemePickerCallback callback;
private ArrayAdapter<String> adapter;
private Dialog dialog;
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
if (savedInstanceState != null) {
palette = (ColorPalette) savedInstanceState.getSerializable(EXTRA_PALETTE);
}
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
Bundle arguments = getArguments();
palette = (ColorPalette) arguments.getSerializable(EXTRA_PALETTE);
boolean showNone = arguments.getBoolean(EXTRA_SHOW_NONE);
if (palette == ColorPickerDialog.ColorPalette.THEMES || palette == ColorPickerDialog.ColorPalette.WIDGET_BACKGROUND) {
theme = theme.withBaseTheme(themeCache.getThemeBase(2));
}
@ -94,7 +102,7 @@ public class ColorPickerDialog extends InjectingDialogFragment {
}
};
return dialogBuilder.newDialog(theme)
AlertDialogBuilder builder = dialogBuilder.newDialog(theme)
.setAdapter(adapter, (dialog, which) -> {
if (preferences.hasPurchase(R.string.p_purchased_themes) || which < getNumFree()) {
callback.themePicked(palette, which);
@ -102,8 +110,17 @@ public class ColorPickerDialog extends InjectingDialogFragment {
callback.initiateThemePurchase();
}
})
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> callback.dismissed())
.show();
.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> callback.dismissed());
if (showNone) {
builder.setNeutralButton(R.string.none, (dialogInterface, i) -> callback.themePicked(palette, -1));
}
dialog = builder.create();
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return dialog;
}
@Override
@ -125,13 +142,6 @@ public class ColorPickerDialog extends InjectingDialogFragment {
callback = (ThemePickerCallback) activity;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putSerializable(EXTRA_PALETTE, palette);
}
@Override
protected void inject(DialogFragmentComponent component) {
component.inject(this);

@ -22,9 +22,9 @@ public abstract class ThemedInjectingAppCompatActivity extends AppCompatActivity
activityComponent = ((InjectingApplication) getApplication()).getComponent().plus(new ActivityModule(this));
inject(activityComponent);
setTitle(null);
super.onCreate(savedInstanceState);
theme.applyTheme(this);
theme.applyStatusBarColor(this);
super.onCreate(savedInstanceState);
}
@Override

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96z"/>
</vector>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<vector xmlns:tools="http://schemas.android.com/tools"
android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="UnusedAttribute">
<path android:fillColor="#FF000000" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM19,18H6c-2.21,0 -4,-1.79 -4,-4s1.79,-4 4,-4h0.71C7.37,7.69 9.48,6 12,6c3.04,0 5.5,2.46 5.5,5.5v0.5H19c1.66,0 3,1.34 3,3s-1.34,3 -3,3z"/>
</vector>

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/asContentBackground"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout style="@style/TagSettingsRow">
<android.support.design.widget.TextInputEditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textFilter"
android:maxLines="1"
android:textColor="?attr/asTextColor" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout style="@style/TagSettingsRow">
<android.support.design.widget.TextInputEditText
android:id="@+id/color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/color"
android:textColor="?attr/asTextColor" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

@ -12,36 +12,28 @@
android:layout_height="wrap_content"
android:layout_gravity="top">
<RelativeLayout
android:layout_width="fill_parent"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp">
<TextView
android:id="@+id/tag_label"
style="@style/TextAppearance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="@string/name" />
<EditText
android:id="@+id/tag_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tag_label"
android:layout_marginTop="16dp"
android:background="#00000000"
android:hint="@string/enter_tag_name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:singleLine="true"
android:gravity="start"
android:textAlignment="viewStart"
android:textColor="?attr/asTextColorHint"
android:textColorHint="?attr/asTextColorHint"
android:textSize="15sp" />
</RelativeLayout>
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout style="@style/TagSettingsRow">
<android.support.design.widget.TextInputEditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences|textFilter"
android:maxLines="1"
android:textColor="?attr/asTextColor" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>

@ -16,7 +16,8 @@
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:layout_height="?android:attr/listPreferredItemHeight"
android:drawablePadding="@dimen/keyline_second"
android:gravity="center_vertical"
android:paddingEnd="@dimen/keyline_first"
android:paddingLeft="@dimen/keyline_first"

@ -18,81 +18,28 @@
android:focusableInTouchMode="true"
android:orientation="vertical">
<RelativeLayout style="@style/TagSettingsRow">
<android.support.design.widget.TextInputLayout style="@style/TagSettingsRow">
<TextView
android:id="@+id/tag_label"
android:layout_width="wrap_content"
<android.support.design.widget.TextInputEditText
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="@string/name"
android:textColor="?android:attr/textColorSecondary"
android:textSize="18sp" />
<EditText
android:id="@+id/tag_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tag_label"
android:layout_marginTop="@dimen/keyline_first"
android:background="@null"
android:hint="@string/enter_tag_name"
android:hint="@string/name"
android:imeOptions="flagNoExtractUi"
android:inputType="textCapSentences"
android:nextFocusLeft="@id/tag_name"
android:nextFocusUp="@id/tag_name"
android:singleLine="true"
android:gravity="start"
android:textAlignment="viewStart"
android:textColor="?android:attr/textColorPrimary"
android:textColorHint="?android:attr/textColorHint"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/theme_row"
style="@style/TagSettingsRow"
android:background="?attr/selectableItemBackground"
android:clickable="true">
android:inputType="textCapSentences|textFilter"
android:maxLines="1"
android:textColor="?attr/asTextColor" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/theme_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="@string/color"
android:textColor="?android:attr/textColorSecondary"
android:textSize="18sp" />
<TextView
android:id="@+id/theme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@id/theme_label"
android:layout_marginTop="@dimen/keyline_first"
android:textColor="?android:attr/textColorPrimary"
android:textSize="18sp" />
<android.support.design.widget.TextInputLayout style="@style/TagSettingsRow">
<ImageView
android:id="@+id/clear"
android:layout_width="wrap_content"
<android.support.design.widget.TextInputEditText
android:id="@+id/color"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/theme_label"
android:layout_gravity="center"
android:layout_marginTop="@dimen/keyline_first"
android:alpha="?attr/alpha_secondary"
android:background="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:src="@drawable/ic_cancel_24dp"
android:tint="?attr/icon_tint" />
</RelativeLayout>
android:hint="@string/color"
android:textColor="?attr/asTextColor" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>

@ -65,7 +65,11 @@
</style>
<style name="TagSettingsRow">
<item name="android:padding">@dimen/keyline_first</item>
<item name="android:paddingLeft">@dimen/keyline_first</item>
<item name="android:paddingRight">@dimen/keyline_first</item>
<item name="android:paddingStart">@dimen/keyline_first</item>
<item name="android:paddingEnd">@dimen/keyline_first</item>
<item name="android:paddingTop">@dimen/keyline_first</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>

Loading…
Cancel
Save