mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 17:59:39 +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"
|
<activity android:name=".ConversationActivity"
|
||||||
android:windowSoftInputMode="stateUnchanged"
|
android:windowSoftInputMode="stateUnchanged"
|
||||||
android:launchMode="singleTask"
|
|
||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||||
android:parentActivityName=".ConversationListActivity">
|
android:parentActivityName=".ConversationListActivity">
|
||||||
<meta-data
|
<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.getForwardedMessageIDs;
|
||||||
import static org.thoughtcrime.securesms.util.RelayUtil.getSharedUris;
|
import static org.thoughtcrime.securesms.util.RelayUtil.getSharedUris;
|
||||||
import static org.thoughtcrime.securesms.util.RelayUtil.isForwarding;
|
import static org.thoughtcrime.securesms.util.RelayUtil.isForwarding;
|
||||||
|
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||||
import static org.thoughtcrime.securesms.util.RelayUtil.isSharing;
|
import static org.thoughtcrime.securesms.util.RelayUtil.isSharing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -190,6 +191,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
private final boolean isSecureText = true;
|
private final boolean isSecureText = true;
|
||||||
private boolean isDefaultSms = true;
|
private boolean isDefaultSms = true;
|
||||||
private boolean isSecurityInitialized = false;
|
private boolean isSecurityInitialized = false;
|
||||||
|
private boolean isShareDraftInitialized = false;
|
||||||
|
|
||||||
|
|
||||||
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
private final DynamicTheme dynamicTheme = new DynamicTheme();
|
||||||
|
@ -486,8 +488,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
Log.w(TAG, "onBackPressed()");
|
Log.w(TAG, "onBackPressed()");
|
||||||
if (container.isInputOpen()) container.hideCurrentInput(composeText);
|
if (container.isInputOpen()){
|
||||||
else super.onBackPressed();
|
container.hideCurrentInput(composeText);
|
||||||
|
} else {
|
||||||
|
handleReturnToConversationList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -509,6 +514,17 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleReturnToConversationList() {
|
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 intent = new Intent(this, (archived ? ConversationListArchiveActivity.class : ConversationListActivity.class));
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -615,7 +631,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
|
|
||||||
private void handleSharing() {
|
private void handleSharing() {
|
||||||
ArrayList<Uri> uriList = RelayUtil.getSharedUris(this);
|
ArrayList<Uri> uriList = RelayUtil.getSharedUris(this);
|
||||||
if (uriList == null || uriList.size() == 0) return;
|
if (uriList == null) return;
|
||||||
if (uriList.size() > 1) {
|
if (uriList.size() > 1) {
|
||||||
String message = String.format(getString(R.string.share_multiple_attachments), uriList.size());
|
String message = String.format(getString(R.string.share_multiple_attachments), uriList.size());
|
||||||
new AlertDialog.Builder(this)
|
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))
|
.setPositiveButton(R.string.menu_send, (dialog, which) -> new RelayingTask(this, chatId).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR))
|
||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
|
if (uriList.size() == 1) {
|
||||||
DcMsg message = createMessage(this, uriList.get(0));
|
DcMsg message = createMessage(this, uriList.get(0));
|
||||||
dcContext.setDraft(chatId, message);
|
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.setOnClickListener(v -> handleConversationSettings());
|
||||||
titleView.setOnBackClickedListener(view -> super.onBackPressed());
|
titleView.setOnBackClickedListener(view -> onBackPressed());
|
||||||
|
|
||||||
composeText.setOnKeyListener(composeKeyPressedListener);
|
composeText.setOnKeyListener(composeKeyPressedListener);
|
||||||
composeText.addTextChangedListener(composeKeyPressedListener);
|
composeText.addTextChangedListener(composeKeyPressedListener);
|
||||||
|
@ -1192,6 +1215,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
|
|
||||||
fragment.scrollToBottom();
|
fragment.scrollToBottom();
|
||||||
attachmentManager.cleanup();
|
attachmentManager.cleanup();
|
||||||
|
|
||||||
|
if (isShareDraftInitialized) {
|
||||||
|
isShareDraftInitialized = false;
|
||||||
|
setResult(RESULT_OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,6 @@ import org.thoughtcrime.securesms.mms.GlideApp;
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.util.Debouncer;
|
import org.thoughtcrime.securesms.util.Debouncer;
|
||||||
import org.thoughtcrime.securesms.util.RelayUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.SaveAttachmentTask;
|
import org.thoughtcrime.securesms.util.SaveAttachmentTask;
|
||||||
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
|
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
@ -79,10 +78,10 @@ import java.util.Comparator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.b44t.messenger.DcContact.DC_CONTACT_ID_SELF;
|
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;
|
import static org.thoughtcrime.securesms.util.RelayUtil.setForwardingMessageIds;
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@ -402,8 +401,8 @@ public class ConversationFragment extends Fragment
|
||||||
Intent composeIntent = new Intent(getActivity(), ConversationListActivity.class);
|
Intent composeIntent = new Intent(getActivity(), ConversationListActivity.class);
|
||||||
int[] msgIds = DcMsg.msgSetToIds(messageRecords);
|
int[] msgIds = DcMsg.msgSetToIds(messageRecords);
|
||||||
setForwardingMessageIds(composeIntent, msgIds);
|
setForwardingMessageIds(composeIntent, msgIds);
|
||||||
startActivity(composeIntent);
|
startActivityForResult(composeIntent, REQUEST_RELAY);
|
||||||
Objects.requireNonNull(getActivity()).overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
|
getActivity().overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleResendMessage(final DcMsg message) {
|
private void handleResendMessage(final DcMsg message) {
|
||||||
|
|
|
@ -101,10 +101,11 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||||
if (isRelayingMessageContent(this)) {
|
if (isRelayingMessageContent(this)) {
|
||||||
title.setText(isForwarding(this) ? R.string.forward_to : R.string.chat_share_with_title);
|
title.setText(isForwarding(this) ? R.string.forward_to : R.string.chat_share_with_title);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
conversationListFragment.onNewIntent();
|
|
||||||
} else {
|
} else {
|
||||||
|
title.setText(R.string.dc_app_name);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
}
|
}
|
||||||
|
conversationListFragment.onNewIntent();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +187,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||||
case R.id.menu_qr_show: handleQrShow(); return true;
|
case R.id.menu_qr_show: handleQrShow(); return true;
|
||||||
case R.id.menu_deaddrop: handleDeaddrop(); return true;
|
case R.id.menu_deaddrop: handleDeaddrop(); return true;
|
||||||
case R.id.menu_global_map: handleShowMap(); 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;
|
return false;
|
||||||
|
@ -253,6 +254,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||||
if (searchToolbar.isVisible()) searchToolbar.collapse();
|
if (searchToolbar.isVisible()) searchToolbar.collapse();
|
||||||
else if (isRelayingMessageContent(this)) {
|
else if (isRelayingMessageContent(this)) {
|
||||||
handleResetRelaying();
|
handleResetRelaying();
|
||||||
|
finish();
|
||||||
} else super.onBackPressed();
|
} else super.onBackPressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,6 +291,8 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||||
case REQUEST_RELAY:
|
case REQUEST_RELAY:
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
handleResetRelaying();
|
handleResetRelaying();
|
||||||
|
setResult(RESULT_OK);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
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.REQUEST_RELAY;
|
||||||
import static org.thoughtcrime.securesms.util.RelayUtil.acquireRelayMessageContent;
|
import static org.thoughtcrime.securesms.util.RelayUtil.acquireRelayMessageContent;
|
||||||
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||||
|
import static org.thoughtcrime.securesms.util.RelayUtil.isSharing;
|
||||||
|
|
||||||
public class ConversationListArchiveActivity extends PassphraseRequiredActionBarActivity
|
public class ConversationListArchiveActivity extends PassphraseRequiredActionBarActivity
|
||||||
implements ConversationListFragment.ConversationSelectedListener
|
implements ConversationListFragment.ConversationSelectedListener
|
||||||
|
@ -31,7 +32,7 @@ public class ConversationListArchiveActivity extends PassphraseRequiredActionBar
|
||||||
protected void onCreate(Bundle icicle, boolean ready) {
|
protected void onCreate(Bundle icicle, boolean ready) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
if (isRelayingMessageContent(this)) {
|
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);
|
getSupportActionBar().setSubtitle(R.string.chat_archived_chats_title);
|
||||||
} else {
|
} else {
|
||||||
getSupportActionBar().setTitle(R.string.chat_archived_chats_title);
|
getSupportActionBar().setTitle(R.string.chat_archived_chats_title);
|
||||||
|
@ -55,7 +56,7 @@ public class ConversationListArchiveActivity extends PassphraseRequiredActionBar
|
||||||
super.onOptionsItemSelected(item);
|
super.onOptionsItemSelected(item);
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.home: super.onBackPressed(); return true;
|
case android.R.id.home: super.onBackPressed(); return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue