Copy to folder by long pressing

pull/203/head
M66B 3 years ago
parent b5adcbdea8
commit 91de48ad62

@ -181,6 +181,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private void wire() {
view.setOnClickListener(this);
view.setOnLongClickListener(this);
ibExpander.setOnClickListener(this);
if (tvFlagged != null)
tvFlagged.setOnClickListener(this);
@ -188,14 +189,13 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ibFlagged.setOnClickListener(this);
if (ibSync != null)
ibSync.setOnClickListener(this);
if (listener == null)
view.setOnLongClickListener(this);
if (btnHelp != null)
btnHelp.setOnClickListener(this);
}
private void unwire() {
view.setOnClickListener(null);
view.setOnLongClickListener(null);
ibExpander.setOnClickListener(null);
if (tvFlagged != null)
tvFlagged.setOnClickListener(null);
@ -203,8 +203,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ibFlagged.setOnClickListener(null);
if (ibSync != null)
ibSync.setOnClickListener(null);
if (listener == null)
view.setOnLongClickListener(null);
if (btnHelp != null)
btnHelp.setOnClickListener(null);
}
@ -488,6 +486,9 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (folder.tbd != null || folder.local)
return false;
if (listener != null)
return listener.onFolderLongPress(folder);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
boolean debug = prefs.getBoolean("debug", false);
@ -1426,5 +1427,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
interface IFolderSelectedListener {
void onFolderSelected(@NonNull TupleFolderEx folder);
boolean onFolderLongPress(@NonNull TupleFolderEx folder);
}
}

@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/
import static android.app.Activity.RESULT_OK;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
@ -50,8 +52,6 @@ import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import static android.app.Activity.RESULT_OK;
public class FragmentDialogFolder extends FragmentDialogBase {
private int result = 0;
@ -63,9 +63,11 @@ public class FragmentDialogFolder extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final String title = getArguments().getString("title");
final long account = getArguments().getLong("account");
final long[] disabled = getArguments().getLongArray("disabled");
Bundle aargs = getArguments();
final String title = aargs.getString("title");
final long account = aargs.getLong("account");
final long[] disabled = aargs.getLongArray("disabled");
final boolean cancopy = aargs.getBoolean("cancopy");
final Context context = getContext();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -149,6 +151,16 @@ public class FragmentDialogFolder extends FragmentDialogBase {
sendResult(RESULT_OK);
dismiss();
}
@Override
public boolean onFolderLongPress(@NonNull TupleFolderEx folder) {
if (cancopy) {
getArguments().putBoolean("copy", true);
onFolderSelected(folder);
return true;
} else
return false;
}
});
tvFavorite1.setVisibility(View.GONE);

@ -3680,6 +3680,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
args.putString("title", getString(copy ? R.string.title_copy_to : R.string.title_move_to_folder));
args.putLong("account", account);
args.putBoolean("copy", copy);
args.putBoolean("cancopy", true);
args.putLongArray("disabled", Helper.toLongArray(disabled));
FragmentDialogFolder fragment = new FragmentDialogFolder();
@ -3743,9 +3744,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
@Override
protected void onExecuted(Bundle args, ArrayList<MessageTarget> result) {
boolean copy = args.getBoolean("copy");
if (copy)
if (copy) {
moveAskConfirmed(result);
else
ToastEx.makeText(getContext(), R.string.title_copy, Toast.LENGTH_LONG).show();
} else
moveAsk(result, true);
}

Loading…
Cancel
Save