Improved move ask dialog

pull/184/head
M66B 4 years ago
parent 6cede265fb
commit dc574e466e

@ -4876,15 +4876,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
Bundle aargs = new Bundle();
aargs.putString("question", getResources()
.getQuantityString(R.plurals.title_moving_messages,
result.size(), result.size(),
getDisplay(result, false),
getDisplay(result, true)));
aargs.putString("notagain", key);
aargs.putParcelableArrayList("result", result);
FragmentDialogAsk ask = new FragmentDialogAsk();
FragmentMoveAsk ask = new FragmentMoveAsk();
ask.setArguments(aargs);
ask.setTargetFragment(FragmentMessages.this, REQUEST_ASKED_MOVE);
ask.show(getParentFragmentManager(), "messages:move");
@ -5078,7 +5073,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}.execute(this, args, "undo:hide");
}
private String getDisplay(ArrayList<MessageTarget> result, boolean dest) {
private static String getDisplay(ArrayList<MessageTarget> result, boolean dest) {
boolean across = false;
for (MessageTarget target : result)
if (target.isAccross())
@ -7534,4 +7529,52 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
.create();
}
}
public static class FragmentMoveAsk extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
String notagain = getArguments().getString("notagain");
ArrayList<MessageTarget> result = getArguments().getParcelableArrayList("result");
View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ask_move, null);
TextView tvMessages = dview.findViewById(R.id.tvMessages);
TextView tvSourceFolders = dview.findViewById(R.id.tvSourceFolders);
TextView tvTargetFolders = dview.findViewById(R.id.tvTargetFolders);
CheckBox cbNotAgain = dview.findViewById(R.id.cbNotAgain);
String question = getResources()
.getQuantityString(R.plurals.title_moving_messages,
result.size(), result.size());
tvMessages.setText(question);
tvSourceFolders.setText(getDisplay(result, false));
tvTargetFolders.setText(getDisplay(result, true));
if (notagain != null)
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefs.edit().putBoolean(notagain, isChecked).apply();
}
});
return new AlertDialog.Builder(getContext())
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sendResult(Activity.RESULT_OK);
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
sendResult(Activity.RESULT_CANCELED);
}
})
.create();
}
}
}

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<eu.faircode.email.ScrollViewEx xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="24dp"
android:scrollbarStyle="outsideOverlay">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<eu.faircode.email.FixedTextView
android:id="@+id/tvMessages"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Messages"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSourceFolders"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="Source folders"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMessages" />
<ImageView
android:id="@+id/ivArrow"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="12dp"
android:tint="?android:attr/textColorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSourceFolders"
app:srcCompat="@drawable/baseline_arrow_downward_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvTargetFolders"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="Target folders"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivArrow" />
<CheckBox
android:id="@+id/cbNotAgain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/title_no_ask_again"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvTargetFolders" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

@ -55,8 +55,8 @@
<item quantity="other">%1$d gesprekken geselecteerd</item>
</plurals>
<plurals name="title_moving_messages">
<item quantity="one">Één bericht verplaatsen van %2$s naar %3$s?</item>
<item quantity="other">%1$d berichten verplaatsen van %2$s naar %3$s?</item>
<item quantity="one">Één bericht verplaatsen?</item>
<item quantity="other">%1$d berichten verplaatsen?</item>
</plurals>
<plurals name="title_deleting_messages">
<item quantity="one">Verwijder één bericht definitief?</item>

@ -71,8 +71,8 @@
</plurals>
<plurals name="title_moving_messages">
<item quantity="one">Move %1$d message from %2$s to %3$s?</item>
<item quantity="other">Move %1$d messages from %2$s to %3$s?</item>
<item quantity="one">Move %1$d message?</item>
<item quantity="other">Move %1$d messages?</item>
</plurals>
<plurals name="title_deleting_messages">

Loading…
Cancel
Save