|
|
|
|
@ -9,12 +9,8 @@ import android.app.FragmentManager;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.support.v4.graphics.drawable.DrawableCompat;
|
|
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
|
import android.view.Menu;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
|
|
|
|
@ -43,7 +39,6 @@ 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;
|
|
|
|
|
|
|
|
|
|
@ -55,7 +50,7 @@ import timber.log.Timber;
|
|
|
|
|
import static android.text.TextUtils.isEmpty;
|
|
|
|
|
import static org.tasks.dialogs.ThemePickerDialog.newThemePickerDialog;
|
|
|
|
|
|
|
|
|
|
public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implements ThemePickerDialog.ThemePickerCallback, PurchaseHelperCallback {
|
|
|
|
|
public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implements ThemePickerDialog.ThemePickerCallback, PurchaseHelperCallback, Toolbar.OnMenuItemClickListener {
|
|
|
|
|
|
|
|
|
|
private static final String FRAG_TAG_COLOR_PICKER = "frag_tag_color_picker";
|
|
|
|
|
|
|
|
|
|
@ -98,27 +93,23 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
|
|
|
|
|
tagData.setUUID(UUIDHelper.newUUID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
|
ActionBar supportActionBar = getSupportActionBar();
|
|
|
|
|
if (supportActionBar != null) {
|
|
|
|
|
supportActionBar.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
final boolean backButtonSavesTask = preferences.backButtonSavesTask();
|
|
|
|
|
Drawable drawable = DrawableCompat.wrap(getResources().getDrawable(
|
|
|
|
|
backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp));
|
|
|
|
|
DrawableCompat.setTint(drawable, getResources().getColor(android.R.color.white));
|
|
|
|
|
supportActionBar.setHomeAsUpIndicator(drawable);
|
|
|
|
|
supportActionBar.setTitle(isNewTag ? getString(R.string.new_tag) : tagData.getName());
|
|
|
|
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
if (backButtonSavesTask) {
|
|
|
|
|
discard();
|
|
|
|
|
} else {
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
final boolean backButtonSavesTask = preferences.backButtonSavesTask();
|
|
|
|
|
toolbar.setTitle(isNewTag ? getString(R.string.new_tag) : tagData.getName());
|
|
|
|
|
toolbar.setNavigationIcon(getResources().getDrawable(
|
|
|
|
|
backButtonSavesTask ? R.drawable.ic_close_24dp : R.drawable.ic_save_24dp));
|
|
|
|
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
if (backButtonSavesTask) {
|
|
|
|
|
discard();
|
|
|
|
|
} else {
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
toolbar.inflateMenu(R.menu.tag_settings_activity);
|
|
|
|
|
toolbar.setOnMenuItemClickListener(this);
|
|
|
|
|
toolbar.showOverflowMenu();
|
|
|
|
|
|
|
|
|
|
tagName.setText(tagData.getName());
|
|
|
|
|
|
|
|
|
|
@ -127,6 +118,7 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
|
|
|
|
|
tagName.setText(autopopulateName);
|
|
|
|
|
getIntent().removeExtra(TOKEN_AUTOPOPULATE_NAME);
|
|
|
|
|
} else if (isNewTag) {
|
|
|
|
|
toolbar.getMenu().findItem(R.id.delete).setVisible(false);
|
|
|
|
|
tagName.requestFocus();
|
|
|
|
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
imm.showSoftInput(tagName, InputMethodManager.SHOW_IMPLICIT);
|
|
|
|
|
@ -213,16 +205,6 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
|
|
|
|
|
super.finish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
|
getMenuInflater().inflate(R.menu.tag_settings_activity, menu);
|
|
|
|
|
MenuColorizer.colorMenu(this, menu, getResources().getColor(android.R.color.white));
|
|
|
|
|
if (isNewTag) {
|
|
|
|
|
menu.findItem(R.id.delete).setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
return super.onCreateOptionsMenu(menu);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBackPressed() {
|
|
|
|
|
if (preferences.backButtonSavesTask()) {
|
|
|
|
|
@ -232,16 +214,6 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
case R.id.delete:
|
|
|
|
|
deleteTag();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
if (requestCode == REQUEST_PURCHASE) {
|
|
|
|
|
@ -292,19 +264,19 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateTheme() {
|
|
|
|
|
ThemeColor color;
|
|
|
|
|
if (selectedTheme < 0) {
|
|
|
|
|
color = themeColor;
|
|
|
|
|
themeName.setText(R.string.none);
|
|
|
|
|
toolbar.setBackgroundColor(themeColor.getPrimaryColor());
|
|
|
|
|
themeColor.applyStatusBarColor(this);
|
|
|
|
|
clear.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
ThemeColor themeColor = themeCache.getThemeColor(selectedTheme);
|
|
|
|
|
toolbar.setBackgroundColor(themeColor.getPrimaryColor());
|
|
|
|
|
themeColor.applyStatusBarColor(this);
|
|
|
|
|
themeName.setText(themeColor.getName());
|
|
|
|
|
color = themeCache.getThemeColor(selectedTheme);
|
|
|
|
|
themeName.setText(color.getName());
|
|
|
|
|
clear.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
color.apply(toolbar);
|
|
|
|
|
color.applyStatusBarColor(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -325,4 +297,14 @@ public class TagSettingsActivity extends ThemedInjectingAppCompatActivity implem
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
case R.id.delete:
|
|
|
|
|
deleteTag();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|