|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
@ -55,6 +56,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
private TextView tvParent;
|
|
|
|
private TextView tvParent;
|
|
|
|
private EditText etName;
|
|
|
|
private EditText etName;
|
|
|
|
private EditText etDisplay;
|
|
|
|
private EditText etDisplay;
|
|
|
|
|
|
|
|
private ViewButtonColor btnColor;
|
|
|
|
private CheckBox cbHide;
|
|
|
|
private CheckBox cbHide;
|
|
|
|
private CheckBox cbUnified;
|
|
|
|
private CheckBox cbUnified;
|
|
|
|
private CheckBox cbNavigation;
|
|
|
|
private CheckBox cbNavigation;
|
|
|
@ -78,6 +80,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
private boolean saving = false;
|
|
|
|
private boolean saving = false;
|
|
|
|
private boolean deletable = false;
|
|
|
|
private boolean deletable = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
|
private static final int REQUEST_SAVE_CHANGES = 101;
|
|
|
|
private static final int REQUEST_SAVE_CHANGES = 101;
|
|
|
|
private static final int REQUEST_DELETE_FOLDER = 102;
|
|
|
|
private static final int REQUEST_DELETE_FOLDER = 102;
|
|
|
|
|
|
|
|
|
|
|
@ -105,6 +108,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
etName = view.findViewById(R.id.etName);
|
|
|
|
etName = view.findViewById(R.id.etName);
|
|
|
|
tvParent = view.findViewById(R.id.tvParent);
|
|
|
|
tvParent = view.findViewById(R.id.tvParent);
|
|
|
|
etDisplay = view.findViewById(R.id.etDisplay);
|
|
|
|
etDisplay = view.findViewById(R.id.etDisplay);
|
|
|
|
|
|
|
|
btnColor = view.findViewById(R.id.btnColor);
|
|
|
|
cbHide = view.findViewById(R.id.cbHide);
|
|
|
|
cbHide = view.findViewById(R.id.cbHide);
|
|
|
|
cbUnified = view.findViewById(R.id.cbUnified);
|
|
|
|
cbUnified = view.findViewById(R.id.cbUnified);
|
|
|
|
cbNavigation = view.findViewById(R.id.cbNavigation);
|
|
|
|
cbNavigation = view.findViewById(R.id.cbNavigation);
|
|
|
@ -122,6 +126,21 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
pbWait = view.findViewById(R.id.pbWait);
|
|
|
|
pbWait = view.findViewById(R.id.pbWait);
|
|
|
|
grpParent = view.findViewById(R.id.grpParent);
|
|
|
|
grpParent = view.findViewById(R.id.grpParent);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
btnColor.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
|
|
args.putInt("color", btnColor.getColor());
|
|
|
|
|
|
|
|
args.putString("title", getString(R.string.title_color));
|
|
|
|
|
|
|
|
args.putBoolean("reset", true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FragmentDialogColor fragment = new FragmentDialogColor();
|
|
|
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
|
|
|
fragment.setTargetFragment(FragmentFolder.this, REQUEST_COLOR);
|
|
|
|
|
|
|
|
fragment.show(getFragmentManager(), "account:color");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
cbSynchronize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
cbSynchronize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
@ -192,6 +211,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
etName.setText(folder == null ? null : folder.name);
|
|
|
|
etName.setText(folder == null ? null : folder.name);
|
|
|
|
etDisplay.setText(folder == null ? null : folder.display);
|
|
|
|
etDisplay.setText(folder == null ? null : folder.display);
|
|
|
|
etDisplay.setHint(folder == null ? null : Helper.localizeFolderName(getContext(), folder.name));
|
|
|
|
etDisplay.setHint(folder == null ? null : Helper.localizeFolderName(getContext(), folder.name));
|
|
|
|
|
|
|
|
btnColor.setColor(folder == null ? null : folder.color);
|
|
|
|
cbHide.setChecked(folder == null ? false : folder.hide);
|
|
|
|
cbHide.setChecked(folder == null ? false : folder.hide);
|
|
|
|
cbUnified.setChecked(folder == null ? false : folder.unified);
|
|
|
|
cbUnified.setChecked(folder == null ? false : folder.unified);
|
|
|
|
cbNavigation.setChecked(folder == null ? false : folder.navigation);
|
|
|
|
cbNavigation.setChecked(folder == null ? false : folder.navigation);
|
|
|
@ -244,6 +264,15 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
switch (requestCode) {
|
|
|
|
switch (requestCode) {
|
|
|
|
|
|
|
|
case REQUEST_COLOR:
|
|
|
|
|
|
|
|
if (resultCode == RESULT_OK && data != null) {
|
|
|
|
|
|
|
|
if (ActivityBilling.isPro(getContext())) {
|
|
|
|
|
|
|
|
Bundle args = data.getBundleExtra("args");
|
|
|
|
|
|
|
|
btnColor.setColor(args.getInt("color"));
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
startActivity(new Intent(getContext(), ActivityBilling.class));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case REQUEST_SAVE_CHANGES:
|
|
|
|
case REQUEST_SAVE_CHANGES:
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
@ -307,6 +336,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
args.putString("parent", parent);
|
|
|
|
args.putString("parent", parent);
|
|
|
|
args.putString("name", etName.getText().toString());
|
|
|
|
args.putString("name", etName.getText().toString());
|
|
|
|
args.putString("display", etDisplay.getText().toString());
|
|
|
|
args.putString("display", etDisplay.getText().toString());
|
|
|
|
|
|
|
|
args.putInt("color", btnColor.getColor());
|
|
|
|
args.putBoolean("hide", cbHide.isChecked());
|
|
|
|
args.putBoolean("hide", cbHide.isChecked());
|
|
|
|
args.putBoolean("unified", cbUnified.isChecked());
|
|
|
|
args.putBoolean("unified", cbUnified.isChecked());
|
|
|
|
args.putBoolean("navigation", cbNavigation.isChecked());
|
|
|
|
args.putBoolean("navigation", cbNavigation.isChecked());
|
|
|
@ -346,6 +376,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
String parent = args.getString("parent");
|
|
|
|
String parent = args.getString("parent");
|
|
|
|
String name = args.getString("name");
|
|
|
|
String name = args.getString("name");
|
|
|
|
String display = args.getString("display");
|
|
|
|
String display = args.getString("display");
|
|
|
|
|
|
|
|
Integer color = args.getInt("color");
|
|
|
|
boolean hide = args.getBoolean("hide");
|
|
|
|
boolean hide = args.getBoolean("hide");
|
|
|
|
boolean unified = args.getBoolean("unified");
|
|
|
|
boolean unified = args.getBoolean("unified");
|
|
|
|
boolean navigation = args.getBoolean("navigation");
|
|
|
|
boolean navigation = args.getBoolean("navigation");
|
|
|
@ -357,8 +388,11 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
String keep = args.getString("keep");
|
|
|
|
String keep = args.getString("keep");
|
|
|
|
boolean auto_delete = args.getBoolean("auto_delete");
|
|
|
|
boolean auto_delete = args.getBoolean("auto_delete");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean pro = ActivityBilling.isPro(context);
|
|
|
|
boolean should = args.getBoolean("should");
|
|
|
|
boolean should = args.getBoolean("should");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (color == Color.TRANSPARENT || !pro)
|
|
|
|
|
|
|
|
color = null;
|
|
|
|
if (TextUtils.isEmpty(display) || display.equals(name))
|
|
|
|
if (TextUtils.isEmpty(display) || display.equals(name))
|
|
|
|
display = null;
|
|
|
|
display = null;
|
|
|
|
|
|
|
|
|
|
|
@ -428,6 +462,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
create.account = aid;
|
|
|
|
create.account = aid;
|
|
|
|
create.name = name;
|
|
|
|
create.name = name;
|
|
|
|
create.display = display;
|
|
|
|
create.display = display;
|
|
|
|
|
|
|
|
create.color = color;
|
|
|
|
create.type = EntityFolder.USER;
|
|
|
|
create.type = EntityFolder.USER;
|
|
|
|
create.unified = unified;
|
|
|
|
create.unified = unified;
|
|
|
|
create.navigation = navigation;
|
|
|
|
create.navigation = navigation;
|
|
|
@ -454,7 +489,7 @@ public class FragmentFolder extends FragmentBase {
|
|
|
|
Log.i("Updating folder=" + folder.name);
|
|
|
|
Log.i("Updating folder=" + folder.name);
|
|
|
|
db.folder().setFolderProperties(id,
|
|
|
|
db.folder().setFolderProperties(id,
|
|
|
|
folder.name.equals(name) ? null : name,
|
|
|
|
folder.name.equals(name) ? null : name,
|
|
|
|
display, unified, navigation, notify, hide,
|
|
|
|
display, color, unified, navigation, notify, hide,
|
|
|
|
synchronize, poll, download,
|
|
|
|
synchronize, poll, download,
|
|
|
|
sync_days, keep_days, auto_delete);
|
|
|
|
sync_days, keep_days, auto_delete);
|
|
|
|
db.folder().setFolderError(id, null);
|
|
|
|
db.folder().setFolderError(id, null);
|
|
|
|