do not update recent quick action when recording voice mail. fixes #3799

This commit is contained in:
Daniel Gultsch 2020-06-21 16:28:57 +02:00
parent 15489547b7
commit 57135e1a59
1 changed files with 22 additions and 12 deletions

View File

@ -1436,6 +1436,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
public void attachFile(final int attachmentChoice) { public void attachFile(final int attachmentChoice) {
attachFile(attachmentChoice, true);
}
public void attachFile(final int attachmentChoice, final boolean updateRecentlyUsed) {
if (attachmentChoice == ATTACHMENT_CHOICE_RECORD_VOICE) { if (attachmentChoice == ATTACHMENT_CHOICE_RECORD_VOICE) {
if (!hasPermissions(attachmentChoice, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO)) { if (!hasPermissions(attachmentChoice, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO)) {
return; return;
@ -1449,12 +1453,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return; return;
} }
} }
try { if (updateRecentlyUsed) {
activity.getPreferences().edit() storeRecentlyUsedQuickAction(attachmentChoice);
.putString(RECENTLY_USED_QUICK_ACTION, SendButtonAction.of(attachmentChoice).toString())
.apply();
} catch (IllegalArgumentException e) {
//just do not save
} }
final int encryption = conversation.getNextEncryption(); final int encryption = conversation.getNextEncryption();
final int mode = conversation.getMode(); final int mode = conversation.getMode();
@ -1502,6 +1502,16 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
private void storeRecentlyUsedQuickAction(final int attachmentChoice) {
try {
activity.getPreferences().edit()
.putString(RECENTLY_USED_QUICK_ACTION, SendButtonAction.of(attachmentChoice).toString())
.apply();
} catch (IllegalArgumentException e) {
//just do not save
}
}
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (grantResults.length > 0) { if (grantResults.length > 0) {
@ -2135,7 +2145,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
return this.binding != null && scrolledToBottom(this.binding.messagesView); return this.binding != null && scrolledToBottom(this.binding.messagesView);
} }
private void processExtras(Bundle extras) { private void processExtras(final Bundle extras) {
final String downloadUuid = extras.getString(ConversationsActivity.EXTRA_DOWNLOAD_UUID); final String downloadUuid = extras.getString(ConversationsActivity.EXTRA_DOWNLOAD_UUID);
final String text = extras.getString(Intent.EXTRA_TEXT); final String text = extras.getString(Intent.EXTRA_TEXT);
final String nick = extras.getString(ConversationsActivity.EXTRA_NICK); final String nick = extras.getString(ConversationsActivity.EXTRA_NICK);
@ -2181,7 +2191,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
if (ConversationsActivity.POST_ACTION_RECORD_VOICE.equals(postInitAction)) { if (ConversationsActivity.POST_ACTION_RECORD_VOICE.equals(postInitAction)) {
attachFile(ATTACHMENT_CHOICE_RECORD_VOICE); attachFile(ATTACHMENT_CHOICE_RECORD_VOICE, false);
return; return;
} }
final Message message = downloadUuid == null ? null : conversation.findMessageWithFileAndUuid(downloadUuid); final Message message = downloadUuid == null ? null : conversation.findMessageWithFileAndUuid(downloadUuid);
@ -2190,7 +2200,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
private List<Uri> extractUris(Bundle extras) { private List<Uri> extractUris(final Bundle extras) {
final List<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); final List<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
if (uris != null) { if (uris != null) {
return uris; return uris;
@ -2203,7 +2213,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
} }
} }
private List<Uri> cleanUris(List<Uri> uris) { private List<Uri> cleanUris(final List<Uri> uris) {
Iterator<Uri> iterator = uris.iterator(); Iterator<Uri> iterator = uris.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
final Uri uri = iterator.next(); final Uri uri = iterator.next();