|
|
|
@ -21,7 +21,6 @@ package eu.faircode.email;
|
|
|
|
|
|
|
|
|
|
import android.app.NotificationManager;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.graphics.drawable.GradientDrawable;
|
|
|
|
@ -142,6 +141,8 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
private int color = Color.TRANSPARENT;
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
|
|
private static final int REQUEST_SAVE = 2;
|
|
|
|
|
private static final int REQUEST_DELETE = 3;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -1026,29 +1027,15 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, Boolean dirty) {
|
|
|
|
|
if (dirty)
|
|
|
|
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
|
|
|
|
.setMessage(R.string.title_ask_save)
|
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
scroll.smoothScrollTo(0, btnSave.getBottom());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
onSave(false);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.show();
|
|
|
|
|
else
|
|
|
|
|
if (dirty) {
|
|
|
|
|
Bundle aargs = new Bundle();
|
|
|
|
|
aargs.putString("question", getString(R.string.title_ask_save));
|
|
|
|
|
|
|
|
|
|
FragmentDialogAsk fragment = new FragmentDialogAsk();
|
|
|
|
|
fragment.setArguments(aargs);
|
|
|
|
|
fragment.setTargetFragment(FragmentAccount.this, REQUEST_SAVE);
|
|
|
|
|
fragment.show(getFragmentManager(), "account:save");
|
|
|
|
|
} else
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1257,11 +1244,61 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onMenuDelete() {
|
|
|
|
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
|
|
|
|
.setMessage(R.string.title_account_delete)
|
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
Bundle aargs = new Bundle();
|
|
|
|
|
aargs.putString("question", getString(R.string.title_account_delete));
|
|
|
|
|
|
|
|
|
|
FragmentDialogAsk fragment = new FragmentDialogAsk();
|
|
|
|
|
fragment.setArguments(aargs);
|
|
|
|
|
fragment.setTargetFragment(FragmentAccount.this, REQUEST_DELETE);
|
|
|
|
|
fragment.show(getFragmentManager(), "account:delete");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
|
|
|
|
|
switch (requestCode) {
|
|
|
|
|
case REQUEST_COLOR:
|
|
|
|
|
if (resultCode == RESULT_OK && data != null) {
|
|
|
|
|
if (!Helper.isPro(getContext())) {
|
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
|
|
|
|
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bundle args = data.getBundleExtra("args");
|
|
|
|
|
setColor(args.getInt("color"));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case REQUEST_SAVE:
|
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
scroll.smoothScrollTo(0, btnSave.getBottom());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
onSave(false);
|
|
|
|
|
} else
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
break;
|
|
|
|
|
case REQUEST_DELETE:
|
|
|
|
|
if (resultCode == RESULT_OK)
|
|
|
|
|
onDelete();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setColor(int color) {
|
|
|
|
|
this.color = color;
|
|
|
|
|
|
|
|
|
|
GradientDrawable border = new GradientDrawable();
|
|
|
|
|
border.setColor(color);
|
|
|
|
|
border.setStroke(1, Helper.resolveColor(getContext(), R.attr.colorSeparator));
|
|
|
|
|
vwColor.setBackground(border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onDelete() {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
|
|
|
|
@ -1295,39 +1332,6 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
}
|
|
|
|
|
}.execute(FragmentAccount.this, args, "account:delete");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
|
|
|
|
|
|
switch (requestCode) {
|
|
|
|
|
case REQUEST_COLOR:
|
|
|
|
|
if (resultCode == RESULT_OK && data != null) {
|
|
|
|
|
if (!Helper.isPro(getContext())) {
|
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
|
|
|
|
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Bundle args = data.getBundleExtra("args");
|
|
|
|
|
setColor(args.getInt("color"));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setColor(int color) {
|
|
|
|
|
this.color = color;
|
|
|
|
|
|
|
|
|
|
GradientDrawable border = new GradientDrawable();
|
|
|
|
|
border.setColor(color);
|
|
|
|
|
border.setStroke(1, Helper.resolveColor(getContext(), R.attr.colorSeparator));
|
|
|
|
|
vwColor.setBackground(border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setFolders(List<EntityFolder> _folders, EntityAccount account) {
|
|
|
|
|
List<EntityFolder> folders = new ArrayList<>();
|
|
|
|
|