mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #2667 from deltachat/adb/issue-2594
add more context to dialog title shown after sendToChat()
This commit is contained in:
@@ -21,6 +21,7 @@ import static org.thoughtcrime.securesms.ConversationActivity.STARTING_POSITION_
|
||||
import static org.thoughtcrime.securesms.map.MapDataManager.ALL_CHATS_GLOBAL_MAP;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.acquireRelayMessageContent;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.getDirectSharingChatId;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.getSharedTitle;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isDirectSharing;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isForwarding;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.isRelayingMessageContent;
|
||||
@@ -215,7 +216,16 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
|
||||
public void refreshTitle() {
|
||||
if (isRelayingMessageContent(this)) {
|
||||
title.setText(isForwarding(this) ? R.string.forward_to : R.string.chat_share_with_title);
|
||||
if (isForwarding(this)) {
|
||||
title.setText(R.string.forward_to);
|
||||
} else {
|
||||
String titleStr = getSharedTitle(this);
|
||||
if (titleStr != null) { // sharing from sendToChat
|
||||
title.setText(titleStr);
|
||||
} else { // normal sharing
|
||||
title.setText(R.string.chat_share_with_title);
|
||||
}
|
||||
}
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
} else {
|
||||
title.setText(DcHelper.getConnectivitySummary(this, R.string.app_name));
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.setSharedText;
|
||||
import static org.thoughtcrime.securesms.util.RelayUtil.setSharedTitle;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
@@ -57,6 +58,7 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity implement
|
||||
private static final String TAG = ShareActivity.class.getSimpleName();
|
||||
|
||||
public static final String EXTRA_CHAT_ID = "chat_id";
|
||||
public static final String EXTRA_TITLE = "extra_title";
|
||||
|
||||
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
|
||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
||||
@@ -274,6 +276,12 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity implement
|
||||
|
||||
private Intent getBaseShareIntent(final @NonNull Class<?> target) {
|
||||
final Intent intent = new Intent(this, target);
|
||||
|
||||
String title = getIntent().getStringExtra(EXTRA_TITLE);
|
||||
if (title != null) {
|
||||
setSharedTitle(intent, title);
|
||||
}
|
||||
|
||||
String text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
|
||||
if (text==null) {
|
||||
CharSequence cs = getIntent().getCharSequenceExtra(Intent.EXTRA_TEXT);
|
||||
|
||||
@@ -438,7 +438,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
|
||||
return "provided file is invalid, you need to set both name and base64 content";
|
||||
}
|
||||
|
||||
DcHelper.share(WebxdcActivity.this, data, "application/octet-stream", name, text);
|
||||
DcHelper.sendToChat(WebxdcActivity.this, data, "application/octet-stream", name, text);
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -313,7 +313,7 @@ public class DcHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void share(Context activity, byte[] data, String mimeType, String fileName, String text) {
|
||||
public static void sendToChat(Context activity, byte[] data, String mimeType, String fileName, String text) {
|
||||
Intent intent = new Intent(activity, ShareActivity.class);
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
|
||||
@@ -321,10 +321,14 @@ public class DcHelper {
|
||||
Uri uri = PersistentBlobProvider.getInstance().create(activity, data, mimeType, fileName);
|
||||
intent.setType(mimeType);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||
intent.putExtra(ShareActivity.EXTRA_TITLE, activity.getString(R.string.send_file_to, fileName));
|
||||
}
|
||||
|
||||
if (text != null) {
|
||||
intent.putExtra(Intent.EXTRA_TEXT, text);
|
||||
if (data == null) {
|
||||
intent.putExtra(ShareActivity.EXTRA_TITLE, activity.getString(R.string.send_message_to));
|
||||
}
|
||||
}
|
||||
|
||||
activity.startActivity(intent);
|
||||
|
||||
@@ -14,6 +14,7 @@ public class RelayUtil {
|
||||
private static final String FORWARDED_MESSAGE_IDS = "forwarded_message_ids";
|
||||
private static final String SHARED_URIS = "shared_uris";
|
||||
private static final String IS_SHARING = "is_sharing";
|
||||
private static final String SHARED_TITLE = "shared_title";
|
||||
private static final String DIRECT_SHARING_CHAT_ID = "direct_sharing_chat_id";
|
||||
|
||||
public static boolean isRelayingMessageContent(Activity activity) {
|
||||
@@ -79,6 +80,14 @@ public class RelayUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSharedTitle(Activity activity) {
|
||||
try {
|
||||
return activity.getIntent().getStringExtra(SHARED_TITLE);
|
||||
} catch (NullPointerException npe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void resetRelayingMessageContent(Activity activity) {
|
||||
try {
|
||||
@@ -123,6 +132,10 @@ public class RelayUtil {
|
||||
composeIntent.putExtra(IS_SHARING, true);
|
||||
}
|
||||
|
||||
public static void setSharedTitle(Intent composeIntent, String text) {
|
||||
composeIntent.putExtra(SHARED_TITLE, text);
|
||||
}
|
||||
|
||||
public static void setDirectSharing(Intent composeIntent, int chatId) {
|
||||
composeIntent.putExtra(DIRECT_SHARING_CHAT_ID, chatId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user