Added quick move

pull/207/head
M66B 3 years ago
parent e7ea6e0089
commit 21b5d8a3a4

@ -301,6 +301,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private ImageButton ibArchive; private ImageButton ibArchive;
private ImageButton ibJunk; private ImageButton ibJunk;
private ImageButton ibTrash; private ImageButton ibTrash;
private ImageButton ibMove;
private ImageButton ibMoreSettings; private ImageButton ibMoreSettings;
private FloatingActionButton fabSearch; private FloatingActionButton fabSearch;
private FloatingActionButton fabError; private FloatingActionButton fabError;
@ -578,6 +579,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ibArchive = view.findViewById(R.id.ibArchive); ibArchive = view.findViewById(R.id.ibArchive);
ibJunk = view.findViewById(R.id.ibJunk); ibJunk = view.findViewById(R.id.ibJunk);
ibTrash = view.findViewById(R.id.ibTrash); ibTrash = view.findViewById(R.id.ibTrash);
ibMove = view.findViewById(R.id.ibMove);
ibMoreSettings = view.findViewById(R.id.ibMoreSettings); ibMoreSettings = view.findViewById(R.id.ibMoreSettings);
fabSearch = view.findViewById(R.id.fabSearch); fabSearch = view.findViewById(R.id.fabSearch);
fabError = view.findViewById(R.id.fabError); fabError = view.findViewById(R.id.fabError);
@ -1375,6 +1377,42 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
}); });
ibMove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreResult result = (MoreResult) cardMore.getTag();
if (result.accounts.size() == 1) {
for (EntityAccount account : result.accounts.keySet())
onActionMoveSelectionAccount(account.id, false, result.folders);
} else {
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(v.getContext(), getViewLifecycleOwner(), ibMove);
int order = 0;
for (EntityAccount account : result.accounts.keySet()) {
order++;
popupMenu.getMenu().add(Menu.NONE, order, order, account.name)
.setIntent(new Intent().putExtra("account", account.id));
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem target) {
Intent intent = target.getIntent();
if (intent == null)
return false;
long account = intent.getLongExtra("account", -1);
onActionMoveSelectionAccount(account, false, result.folders);
return true;
}
});
popupMenu.show();
}
}
});
ibMoreSettings.setOnClickListener(new View.OnClickListener() { ibMoreSettings.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -5820,9 +5858,14 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
boolean more_archive = prefs.getBoolean("more_archive", true); boolean more_archive = prefs.getBoolean("more_archive", true);
boolean more_junk = prefs.getBoolean("more_junk", true); boolean more_junk = prefs.getBoolean("more_junk", true);
boolean more_trash = prefs.getBoolean("more_trash", true); boolean more_trash = prefs.getBoolean("more_trash", true);
boolean more_move = prefs.getBoolean("more_move", true);
int count = 0; int count = 0;
boolean move = (more_move && count < MAX_QUICK_ACTIONS && result.canMove());
if (move)
count++;
boolean trash = (more_trash && count < MAX_QUICK_ACTIONS && result.canTrash()); boolean trash = (more_trash && count < MAX_QUICK_ACTIONS && result.canTrash());
if (trash) if (trash)
count++; count++;
@ -5875,6 +5918,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ibArchive.setVisibility(archive ? View.VISIBLE : View.GONE); ibArchive.setVisibility(archive ? View.VISIBLE : View.GONE);
ibJunk.setVisibility(junk ? View.VISIBLE : View.GONE); ibJunk.setVisibility(junk ? View.VISIBLE : View.GONE);
ibTrash.setVisibility(trash ? View.VISIBLE : View.GONE); ibTrash.setVisibility(trash ? View.VISIBLE : View.GONE);
ibMove.setVisibility(move ? View.VISIBLE : View.GONE);
cardMore.setTag(fabMore.isOrWillBeShown() ? result : null);
cardMore.setVisibility(fabMore.isOrWillBeShown() ? View.VISIBLE : View.GONE); cardMore.setVisibility(fabMore.isOrWillBeShown() ? View.VISIBLE : View.GONE);
} }
@ -5887,6 +5932,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fabMore.hide(); fabMore.hide();
tvSelectedCount.setVisibility(View.GONE); tvSelectedCount.setVisibility(View.GONE);
cardMore.setVisibility(View.GONE); cardMore.setVisibility(View.GONE);
cardMore.setTag(null);
} }
} }
@ -9604,6 +9650,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return (!isTrash && hasTrash && !isJunk); return (!isTrash && hasTrash && !isJunk);
} }
boolean canMove() {
if (read_only)
return false;
return (accounts.size() > 0);
}
static MoreResult get(Context context, long[] ids, boolean threading, boolean all) { static MoreResult get(Context context, long[] ids, boolean threading, boolean all) {
Map<Long, EntityAccount> accounts = new HashMap<>(); Map<Long, EntityAccount> accounts = new HashMap<>();
Map<Long, EntityFolder> folders = new HashMap<>(); Map<Long, EntityFolder> folders = new HashMap<>();
@ -10218,6 +10270,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
final CheckBox cbArchive = dview.findViewById(R.id.cbArchive); final CheckBox cbArchive = dview.findViewById(R.id.cbArchive);
final CheckBox cbJunk = dview.findViewById(R.id.cbJunk); final CheckBox cbJunk = dview.findViewById(R.id.cbJunk);
final CheckBox cbTrash = dview.findViewById(R.id.cbTrash); final CheckBox cbTrash = dview.findViewById(R.id.cbTrash);
final CheckBox cbMove = dview.findViewById(R.id.cbMove);
tvHint.setText(getString(R.string.title_quick_actions_hint, MAX_QUICK_ACTIONS)); tvHint.setText(getString(R.string.title_quick_actions_hint, MAX_QUICK_ACTIONS));
cbSeen.setChecked(prefs.getBoolean("more_seen", true)); cbSeen.setChecked(prefs.getBoolean("more_seen", true));
@ -10230,6 +10283,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
cbArchive.setChecked(prefs.getBoolean("more_archive", true)); cbArchive.setChecked(prefs.getBoolean("more_archive", true));
cbJunk.setChecked(prefs.getBoolean("more_junk", true)); cbJunk.setChecked(prefs.getBoolean("more_junk", true));
cbTrash.setChecked(prefs.getBoolean("more_trash", true)); cbTrash.setChecked(prefs.getBoolean("more_trash", true));
cbMove.setChecked(prefs.getBoolean("more_move", true));
return new AlertDialog.Builder(getContext()) return new AlertDialog.Builder(getContext())
.setView(dview) .setView(dview)
@ -10247,6 +10301,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
editor.putBoolean("more_archive", cbArchive.isChecked()); editor.putBoolean("more_archive", cbArchive.isChecked());
editor.putBoolean("more_junk", cbJunk.isChecked()); editor.putBoolean("more_junk", cbJunk.isChecked());
editor.putBoolean("more_trash", cbTrash.isChecked()); editor.putBoolean("more_trash", cbTrash.isChecked());
editor.putBoolean("more_move", cbMove.isChecked());
editor.apply(); editor.apply();
sendResult(Activity.RESULT_OK); sendResult(Activity.RESULT_OK);
} }

@ -160,5 +160,18 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbJunk" /> app:layout_constraintTop_toBottomOf="@id/cbJunk" />
<CheckBox
android:id="@+id/cbMove"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_drive_file_move_24"
android:drawablePadding="6dp"
android:text="@string/title_move"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbTrash" />
</eu.faircode.email.ConstraintLayoutEx> </eu.faircode.email.ConstraintLayoutEx>
</eu.faircode.email.ScrollViewEx> </eu.faircode.email.ScrollViewEx>

@ -661,6 +661,20 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_delete_24" /> app:srcCompat="@drawable/twotone_delete_24" />
<eu.faircode.email.FixedImageButton
android:id="@+id/ibMove"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_move_to"
android:padding="6dp"
android:scaleType="fitCenter"
android:tint="@color/action_foreground"
android:tooltipText="@string/title_move_to"
app:layout_constraintEnd_toStartOf="@id/ibTrash"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_drive_file_move_24" />
<eu.faircode.email.FixedImageButton <eu.faircode.email.FixedImageButton
android:id="@+id/ibMoreSettings" android:id="@+id/ibMoreSettings"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -671,7 +685,7 @@
android:paddingVertical="6dp" android:paddingVertical="6dp"
android:tint="@color/action_foreground" android:tint="@color/action_foreground"
android:tooltipText="@string/title_setup" android:tooltipText="@string/title_setup"
app:layout_constraintEnd_toStartOf="@id/ibTrash" app:layout_constraintEnd_toStartOf="@id/ibMove"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_settings_24" /> app:srcCompat="@drawable/twotone_settings_24" />
</eu.faircode.email.ConstraintLayoutEx> </eu.faircode.email.ConstraintLayoutEx>

Loading…
Cancel
Save