mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
* fix back button behavior for sharing and forwarding (#903)
* fix title in archived chats while sharing content
This commit is contained in:
parent
0ea7181b58
commit
84bdc42c7c
5 changed files with 52 additions and 21 deletions
|
@ -135,7 +135,6 @@
|
|||
|
||||
<activity android:name=".ConversationActivity"
|
||||
android:windowSoftInputMode="stateUnchanged"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||
android:parentActivityName=".ConversationListActivity">
|
||||
<meta-data
|
||||
|
|
|
@ -126,6 +126,7 @@ import static org.thoughtcrime.securesms.TransportOption.Type;
|
|||
import static org.thoughtcrime.securesms.util.RelayUtil.getForwardedMessageIDs;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.getSharedUris;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isForwarding;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isSharing;
|
||||
|
||||
/**
|
||||
|
@ -190,6 +191,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
private final boolean isSecureText = true;
|
||||
private boolean isDefaultSms = true;
|
||||
private boolean isSecurityInitialized = false;
|
||||
private boolean isShareDraftInitialized = false;
|
||||
|
||||
|
||||
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
||||
|
@ -486,8 +488,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
@Override
|
||||
public void onBackPressed() {
|
||||
Log.w(TAG, "onBackPressed()");
|
||||
if (container.isInputOpen()) container.hideCurrentInput(composeText);
|
||||
else super.onBackPressed();
|
||||
if (container.isInputOpen()){
|
||||
container.hideCurrentInput(composeText);
|
||||
} else {
|
||||
handleReturnToConversationList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -509,6 +514,17 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
private void handleReturnToConversationList() {
|
||||
|
||||
if (isRelayingMessageContent(this)) {
|
||||
if (isSharing(this)) {
|
||||
dcContext.setDraft(dcChat.getId(), null);
|
||||
attachmentManager.cleanup();
|
||||
composeText.setText("");
|
||||
}
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent = new Intent(this, (archived ? ConversationListArchiveActivity.class : ConversationListActivity.class));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
|
@ -615,7 +631,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
private void handleSharing() {
|
||||
ArrayList<Uri> uriList = RelayUtil.getSharedUris(this);
|
||||
if (uriList == null || uriList.size() == 0) return;
|
||||
if (uriList == null) return;
|
||||
if (uriList.size() > 1) {
|
||||
String message = String.format(getString(R.string.share_multiple_attachments), uriList.size());
|
||||
new AlertDialog.Builder(this)
|
||||
|
@ -627,9 +643,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
.setPositiveButton(R.string.menu_send, (dialog, which) -> new RelayingTask(this, chatId).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR))
|
||||
.show();
|
||||
} else {
|
||||
if (uriList.size() == 1) {
|
||||
DcMsg message = createMessage(this, uriList.get(0));
|
||||
dcContext.setDraft(chatId, message);
|
||||
initializeDraft();
|
||||
}
|
||||
initializeDraft().addListener(new AssertedSuccessListener<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
isShareDraftInitialized = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -785,7 +808,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
});
|
||||
|
||||
titleView.setOnClickListener(v -> handleConversationSettings());
|
||||
titleView.setOnBackClickedListener(view -> super.onBackPressed());
|
||||
titleView.setOnBackClickedListener(view -> onBackPressed());
|
||||
|
||||
composeText.setOnKeyListener(composeKeyPressedListener);
|
||||
composeText.addTextChangedListener(composeKeyPressedListener);
|
||||
|
@ -967,7 +990,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
protected ListenableFuture<Integer> processComposeControls(int action) {
|
||||
return processComposeControls(action, composeText.getTextTrimmed(),
|
||||
attachmentManager.isAttachmentPresent()?
|
||||
attachmentManager.isAttachmentPresent() ?
|
||||
attachmentManager.buildSlideDeck() : null);
|
||||
}
|
||||
|
||||
|
@ -1192,6 +1215,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
fragment.scrollToBottom();
|
||||
attachmentManager.cleanup();
|
||||
|
||||
if (isShareDraftInitialized) {
|
||||
isShareDraftInitialized = false;
|
||||
setResult(RESULT_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1487,7 +1515,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
|
||||
@Override
|
||||
public void handleEvent(int eventId, Object data1, Object data2) {
|
||||
if (eventId==DcContext.DC_EVENT_CHAT_MODIFIED || eventId==DcContext.DC_EVENT_CONTACTS_CHANGED) {
|
||||
if (eventId == DcContext.DC_EVENT_CHAT_MODIFIED || eventId == DcContext.DC_EVENT_CONTACTS_CHANGED) {
|
||||
dcChat = dcContext.getChat(chatId);
|
||||
titleView.setTitle(glideRequests, dcChat);
|
||||
updateReminders();
|
||||
|
|
|
@ -69,7 +69,6 @@ import org.thoughtcrime.securesms.mms.GlideApp;
|
|||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.util.Debouncer;
|
||||
import org.thoughtcrime.securesms.util.RelayUtil;
|
||||
import org.thoughtcrime.securesms.util.SaveAttachmentTask;
|
||||
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
@ -79,10 +78,10 @@ import java.util.Comparator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.b44t.messenger.DcContact.DC_CONTACT_ID_SELF;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.REQUEST_RELAY;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.setForwardingMessageIds;
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
|
@ -402,8 +401,8 @@ public class ConversationFragment extends Fragment
|
|||
Intent composeIntent = new Intent(getActivity(), ConversationListActivity.class);
|
||||
int[] msgIds = DcMsg.msgSetToIds(messageRecords);
|
||||
setForwardingMessageIds(composeIntent, msgIds);
|
||||
startActivity(composeIntent);
|
||||
Objects.requireNonNull(getActivity()).overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
|
||||
startActivityForResult(composeIntent, REQUEST_RELAY);
|
||||
getActivity().overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
|
||||
}
|
||||
|
||||
private void handleResendMessage(final DcMsg message) {
|
||||
|
|
|
@ -101,10 +101,11 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
|||
if (isRelayingMessageContent(this)) {
|
||||
title.setText(isForwarding(this) ? R.string.forward_to : R.string.chat_share_with_title);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
conversationListFragment.onNewIntent();
|
||||
} else {
|
||||
title.setText(R.string.dc_app_name);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
}
|
||||
conversationListFragment.onNewIntent();
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
|
@ -186,7 +187,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
|||
case R.id.menu_qr_show: handleQrShow(); return true;
|
||||
case R.id.menu_deaddrop: handleDeaddrop(); return true;
|
||||
case R.id.menu_global_map: handleShowMap(); return true;
|
||||
case android.R.id.home: handleResetRelaying(); return true;
|
||||
case android.R.id.home: onBackPressed(); return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -253,6 +254,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
|||
if (searchToolbar.isVisible()) searchToolbar.collapse();
|
||||
else if (isRelayingMessageContent(this)) {
|
||||
handleResetRelaying();
|
||||
finish();
|
||||
} else super.onBackPressed();
|
||||
}
|
||||
|
||||
|
@ -289,6 +291,8 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
|||
case REQUEST_RELAY:
|
||||
if (resultCode == RESULT_OK) {
|
||||
handleResetRelaying();
|
||||
setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -13,6 +13,7 @@ import static org.thoughtcrime.securesms.ConversationActivity.LAST_SEEN_EXTRA;
|
|||
import static org.thoughtcrime.securesms.util.RelayUtil.REQUEST_RELAY;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.acquireRelayMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isSharing;
|
||||
|
||||
public class ConversationListArchiveActivity extends PassphraseRequiredActionBarActivity
|
||||
implements ConversationListFragment.ConversationSelectedListener
|
||||
|
@ -31,7 +32,7 @@ public class ConversationListArchiveActivity extends PassphraseRequiredActionBar
|
|||
protected void onCreate(Bundle icicle, boolean ready) {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
if (isRelayingMessageContent(this)) {
|
||||
getSupportActionBar().setTitle(R.string.forward_to);
|
||||
getSupportActionBar().setTitle(isSharing(this) ? R.string.chat_share_with_title : R.string.forward_to);
|
||||
getSupportActionBar().setSubtitle(R.string.chat_archived_chats_title);
|
||||
} else {
|
||||
getSupportActionBar().setTitle(R.string.chat_archived_chats_title);
|
||||
|
@ -55,7 +56,7 @@ public class ConversationListArchiveActivity extends PassphraseRequiredActionBar
|
|||
super.onOptionsItemSelected(item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.home: super.onBackPressed(); return true;
|
||||
case android.R.id.home: super.onBackPressed(); return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue