Added option to disable confirm moving messages

pull/147/head
M66B 6 years ago
parent ba6e632c60
commit cdb1695faa

@ -1132,10 +1132,8 @@ public class FragmentMessages extends FragmentEx {
if (message != null) {
List<EntityMessage> messages = db.message().getMessageByThread(
message.account, message.thread, threading ? null : id, message.folder);
for (EntityMessage threaded : messages) {
for (EntityMessage threaded : messages)
result.ids.add(threaded.id);
db.message().setMessageUiHide(threaded.id, true);
}
}
}
@ -1873,50 +1871,61 @@ public class FragmentMessages extends FragmentEx {
if (result.target == null)
return;
String title = getResources().getQuantityString(
R.plurals.title_moving_messages, result.ids.size(),
result.ids.size(), result.target.getDisplayName(getContext()));
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(title)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle args = new Bundle();
args.putSerializable("result", result);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
if (prefs.getBoolean("automove", false))
moveAskConfirmed(result);
else {
String title = getResources().getQuantityString(
R.plurals.title_moving_messages, result.ids.size(),
result.ids.size(), result.target.getDisplayName(getContext()));
new DialogBuilderLifecycle(getContext(), getViewLifecycleOwner())
.setMessage(title)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
moveAskConfirmed(result);
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
}
}
// Move messages
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
DB db = DB.getInstance(context);
try {
db.beginTransaction();
private void moveAskConfirmed(MessageTarget result) {
Bundle args = new Bundle();
args.putSerializable("result", result);
for (long id : result.ids) {
EntityMessage message = db.message().getMessage(id);
if (message != null) {
Log.i(Helper.TAG, "Move id=" + id + " target=" + result.target.name);
EntityFolder folder = db.folder().getFolderByName(message.account, result.target.name);
EntityOperation.queue(db, message, EntityOperation.MOVE, folder.id);
}
}
// Move messages
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
DB db = DB.getInstance(context);
try {
MessageTarget result = (MessageTarget) args.getSerializable("result");
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
db.beginTransaction();
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
for (long id : result.ids) {
EntityMessage message = db.message().getMessage(id);
if (message != null) {
Log.i(Helper.TAG, "Move id=" + id + " target=" + result.target.name);
EntityFolder folder = db.folder().getFolderByName(message.account, result.target.name);
EntityOperation.queue(db, message, EntityOperation.MOVE, folder.id);
}
}
})
.setNegativeButton(android.R.string.cancel, null)
.show();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}
private void moveUndo(final MessageTarget result) {

@ -75,6 +75,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
private SwitchCompat swActionbar;
private SwitchCompat swAutoclose;
private SwitchCompat swCollapse;
private SwitchCompat swAutoMove;
private SwitchCompat swConfirm;
private SwitchCompat swSender;
@ -113,6 +114,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
swActionbar = view.findViewById(R.id.swActionbar);
swAutoclose = view.findViewById(R.id.swAutoclose);
swCollapse = view.findViewById(R.id.swCollapse);
swAutoMove = view.findViewById(R.id.swAutoMove);
swConfirm = view.findViewById(R.id.swConfirm);
swSender = view.findViewById(R.id.swSender);
@ -313,6 +315,14 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
}
});
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
swAutoMove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("automove", !checked).apply();
}
});
swConfirm.setChecked(prefs.getBoolean("confirm", false));
swConfirm.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override

@ -371,6 +371,18 @@
app:layout_constraintTop_toBottomOf="@id/tvAutocloseHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoMove"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_automove"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCollapse"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swConfirm"
android:layout_width="match_parent"
@ -380,7 +392,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_confirm"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swCollapse"
app:layout_constraintTop_toBottomOf="@id/swAutoMove"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -125,6 +125,7 @@
<string name="title_advanced_actionbar">Conversation action bar</string>
<string name="title_advanced_autoclose">Automatically close conversations</string>
<string name="title_advanced_collapse">Collapse messages in conversations on \'back\'</string>
<string name="title_advanced_automove">Confirm moving messages</string>
<string name="title_advanced_confirm">Confirm actions that might leak privacy sensitive information</string>
<string name="title_advanced_sender">Allow editing sender address</string>
<string name="title_advanced_download">Automatically download messages and attachments on a metered connection up to</string>

Loading…
Cancel
Save