|
|
|
@ -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,47 +1244,13 @@ 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() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
db.account().setAccountTbd(id);
|
|
|
|
|
|
|
|
|
|
ServiceSynchronize.reload(context, "delete account");
|
|
|
|
|
Bundle aargs = new Bundle();
|
|
|
|
|
aargs.putString("question", getString(R.string.title_account_delete));
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, Void data) {
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Helper.unexpectedError(getFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(FragmentAccount.this, args, "account:delete");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
.show();
|
|
|
|
|
FragmentDialogAsk fragment = new FragmentDialogAsk();
|
|
|
|
|
fragment.setArguments(aargs);
|
|
|
|
|
fragment.setTargetFragment(FragmentAccount.this, REQUEST_DELETE);
|
|
|
|
|
fragment.show(getFragmentManager(), "account:delete");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1317,6 +1270,22 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1329,6 +1298,41 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
vwColor.setBackground(border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onDelete() {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPostExecute(Bundle args) {
|
|
|
|
|
Helper.setViewsEnabled(view, false);
|
|
|
|
|
pbWait.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
db.account().setAccountTbd(id);
|
|
|
|
|
|
|
|
|
|
ServiceSynchronize.reload(context, "delete account");
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(Bundle args, Void data) {
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Helper.unexpectedError(getFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(FragmentAccount.this, args, "account:delete");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setFolders(List<EntityFolder> _folders, EntityAccount account) {
|
|
|
|
|
List<EntityFolder> folders = new ArrayList<>();
|
|
|
|
|
for (EntityFolder folder : _folders)
|
|
|
|
|