|
|
@ -21,7 +21,6 @@ package eu.faircode.email;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.NotificationManager;
|
|
|
|
import android.app.NotificationManager;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.drawable.GradientDrawable;
|
|
|
|
import android.graphics.drawable.GradientDrawable;
|
|
|
@ -142,6 +141,8 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
private int color = Color.TRANSPARENT;
|
|
|
|
private int color = Color.TRANSPARENT;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
|
private static final int REQUEST_COLOR = 1;
|
|
|
|
|
|
|
|
private static final int REQUEST_SAVE = 2;
|
|
|
|
|
|
|
|
private static final int REQUEST_DELETE = 3;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
@ -1026,29 +1027,15 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void onExecuted(Bundle args, Boolean dirty) {
|
|
|
|
protected void onExecuted(Bundle args, Boolean dirty) {
|
|
|
|
if (dirty)
|
|
|
|
if (dirty) {
|
|
|
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
|
|
|
Bundle aargs = new Bundle();
|
|
|
|
.setMessage(R.string.title_ask_save)
|
|
|
|
aargs.putString("question", getString(R.string.title_ask_save));
|
|
|
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
FragmentDialogAsk fragment = new FragmentDialogAsk();
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
fragment.setArguments(aargs);
|
|
|
|
new Handler().post(new Runnable() {
|
|
|
|
fragment.setTargetFragment(FragmentAccount.this, REQUEST_SAVE);
|
|
|
|
@Override
|
|
|
|
fragment.show(getFragmentManager(), "account:save");
|
|
|
|
public void run() {
|
|
|
|
} else
|
|
|
|
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
|
|
|
|
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
getFragmentManager().popBackStack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1257,47 +1244,13 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onMenuDelete() {
|
|
|
|
private void onMenuDelete() {
|
|
|
|
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
|
|
|
|
Bundle aargs = new Bundle();
|
|
|
|
.setMessage(R.string.title_account_delete)
|
|
|
|
aargs.putString("question", getString(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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
FragmentDialogAsk fragment = new FragmentDialogAsk();
|
|
|
|
}
|
|
|
|
fragment.setArguments(aargs);
|
|
|
|
|
|
|
|
fragment.setTargetFragment(FragmentAccount.this, REQUEST_DELETE);
|
|
|
|
@Override
|
|
|
|
fragment.show(getFragmentManager(), "account:delete");
|
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -1317,6 +1270,22 @@ public class FragmentAccount extends FragmentBase {
|
|
|
|
setColor(args.getInt("color"));
|
|
|
|
setColor(args.getInt("color"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
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);
|
|
|
|
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) {
|
|
|
|
private void setFolders(List<EntityFolder> _folders, EntityAccount account) {
|
|
|
|
List<EntityFolder> folders = new ArrayList<>();
|
|
|
|
List<EntityFolder> folders = new ArrayList<>();
|
|
|
|
for (EntityFolder folder : _folders)
|
|
|
|
for (EntityFolder folder : _folders)
|
|
|
|