Added quick move

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

@ -301,6 +301,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private ImageButton ibArchive;
private ImageButton ibJunk;
private ImageButton ibTrash;
private ImageButton ibMove;
private ImageButton ibMoreSettings;
private FloatingActionButton fabSearch;
private FloatingActionButton fabError;
@ -578,6 +579,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ibArchive = view.findViewById(R.id.ibArchive);
ibJunk = view.findViewById(R.id.ibJunk);
ibTrash = view.findViewById(R.id.ibTrash);
ibMove = view.findViewById(R.id.ibMove);
ibMoreSettings = view.findViewById(R.id.ibMoreSettings);
fabSearch = view.findViewById(R.id.fabSearch);
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() {
@Override
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_junk = prefs.getBoolean("more_junk", true);
boolean more_trash = prefs.getBoolean("more_trash", true);
boolean more_move = prefs.getBoolean("more_move", true);
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());
if (trash)
count++;
@ -5875,6 +5918,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ibArchive.setVisibility(archive ? View.VISIBLE : View.GONE);
ibJunk.setVisibility(junk ? 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);
}
@ -5887,6 +5932,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
fabMore.hide();
tvSelectedCount.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);
}
boolean canMove() {
if (read_only)
return false;
return (accounts.size() > 0);
}
static MoreResult get(Context context, long[] ids, boolean threading, boolean all) {
Map<Long, EntityAccount> accounts = 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 cbJunk = dview.findViewById(R.id.cbJunk);
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));
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));
cbJunk.setChecked(prefs.getBoolean("more_junk", true));
cbTrash.setChecked(prefs.getBoolean("more_trash", true));
cbMove.setChecked(prefs.getBoolean("more_move", true));
return new AlertDialog.Builder(getContext())
.setView(dview)
@ -10247,6 +10301,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
editor.putBoolean("more_archive", cbArchive.isChecked());
editor.putBoolean("more_junk", cbJunk.isChecked());
editor.putBoolean("more_trash", cbTrash.isChecked());
editor.putBoolean("more_move", cbMove.isChecked());
editor.apply();
sendResult(Activity.RESULT_OK);
}

@ -160,5 +160,18 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
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.ScrollViewEx>

@ -661,6 +661,20 @@
app:layout_constraintTop_toTopOf="parent"
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
android:id="@+id/ibMoreSettings"
android:layout_width="wrap_content"
@ -671,7 +685,7 @@
android:paddingVertical="6dp"
android:tint="@color/action_foreground"
android:tooltipText="@string/title_setup"
app:layout_constraintEnd_toStartOf="@id/ibTrash"
app:layout_constraintEnd_toStartOf="@id/ibMove"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/twotone_settings_24" />
</eu.faircode.email.ConstraintLayoutEx>

Loading…
Cancel
Save