mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Get attachment logic to work.
This commit is contained in:
parent
c6f5adb447
commit
fd9f1b712f
@ -27,7 +27,7 @@
|
|||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:weightSum="4">
|
android:weightSum="2">
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -54,47 +54,77 @@
|
|||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<org.thoughtcrime.securesms.components.CircleColorImageView
|
||||||
|
android:id="@+id/camera_button"
|
||||||
|
android:layout_width="53dp"
|
||||||
|
android:layout_height="53dp"
|
||||||
|
android:src="@drawable/ic_camera_white_24dp"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:contentDescription="@string/attachment_type_selector__camera_description"
|
||||||
|
app:circleColor="@color/green_400"/>
|
||||||
|
|
||||||
|
<TextView android:layout_marginTop="10dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
style="@style/AttachmentTypeLabel"
|
||||||
|
android:text="@string/attachment_type_selector__camera"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.CircleColorImageView
|
<org.thoughtcrime.securesms.components.CircleColorImageView
|
||||||
android:id="@+id/audio_button"
|
android:id="@+id/audio_button"
|
||||||
android:layout_width="53dp"
|
android:layout_width="53dp"
|
||||||
android:layout_height="53dp"
|
android:layout_height="53dp"
|
||||||
android:src="@drawable/ic_headset_white_24dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:contentDescription="@string/attachment_type_selector__audio_description"
|
android:contentDescription="@string/attachment_type_selector__audio_description"
|
||||||
app:circleColor="@color/orange_400"/>
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/ic_headset_white_24dp"
|
||||||
|
app:circleColor="@color/orange_400" />
|
||||||
|
|
||||||
<TextView android:layout_marginTop="10dp"
|
<TextView
|
||||||
|
style="@style/AttachmentTypeLabel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/AttachmentTypeLabel"
|
android:layout_marginTop="10dp"
|
||||||
android:text="@string/attachment_type_selector__audio"/>
|
android:text="@string/attachment_type_selector__audio" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.CircleColorImageView
|
<org.thoughtcrime.securesms.components.CircleColorImageView
|
||||||
android:id="@+id/document_button"
|
android:id="@+id/document_button"
|
||||||
android:layout_width="53dp"
|
android:layout_width="53dp"
|
||||||
android:layout_height="53dp"
|
android:layout_height="53dp"
|
||||||
android:src="@drawable/ic_insert_drive_file_white_24dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:contentDescription="@string/attachment_type_selector__file_description"
|
android:contentDescription="@string/attachment_type_selector__file_description"
|
||||||
app:circleColor="@color/red_400"/>
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/ic_insert_drive_file_white_24dp"
|
||||||
|
app:circleColor="@color/red_400" />
|
||||||
|
|
||||||
<TextView android:layout_marginTop="10dp"
|
<TextView
|
||||||
style="@style/AttachmentTypeLabel"
|
style="@style/AttachmentTypeLabel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/attachment_type_selector__file"/>
|
android:layout_marginTop="10dp"
|
||||||
|
android:text="@string/attachment_type_selector__file" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -102,7 +132,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_weight="1">
|
android:layout_weight="1"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.CircleColorImageView
|
<org.thoughtcrime.securesms.components.CircleColorImageView
|
||||||
android:id="@+id/contact_button"
|
android:id="@+id/contact_button"
|
||||||
@ -130,53 +161,32 @@
|
|||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:weightSum="4">
|
android:weightSum="2">
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/location_linear_layout"
|
||||||
android:layout_weight="1"
|
|
||||||
android:gravity="center"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.CircleColorImageView
|
|
||||||
android:id="@+id/camera_button"
|
|
||||||
android:layout_width="53dp"
|
|
||||||
android:layout_height="53dp"
|
|
||||||
android:src="@drawable/ic_camera_white_24dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:contentDescription="@string/attachment_type_selector__camera_description"
|
|
||||||
app:circleColor="@color/green_400"/>
|
|
||||||
|
|
||||||
<TextView android:layout_marginTop="10dp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="center"
|
|
||||||
style="@style/AttachmentTypeLabel"
|
|
||||||
android:text="@string/attachment_type_selector__camera"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout android:id="@+id/location_linear_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.CircleColorImageView
|
<org.thoughtcrime.securesms.components.CircleColorImageView
|
||||||
android:id="@+id/location_button"
|
android:id="@+id/location_button"
|
||||||
android:layout_width="53dp"
|
android:layout_width="53dp"
|
||||||
android:layout_height="53dp"
|
android:layout_height="53dp"
|
||||||
android:src="@drawable/ic_location_on_white_24dp"
|
|
||||||
android:scaleType="center"
|
|
||||||
android:contentDescription="@string/attachment_type_selector__location_description"
|
android:contentDescription="@string/attachment_type_selector__location_description"
|
||||||
app:circleColor="@color/blue_grey_400"/>
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/ic_location_on_white_24dp"
|
||||||
|
app:circleColor="@color/blue_grey_400" />
|
||||||
|
|
||||||
<TextView android:layout_marginTop="10dp"
|
<TextView
|
||||||
|
style="@style/AttachmentTypeLabel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/AttachmentTypeLabel"
|
android:layout_marginTop="10dp"
|
||||||
android:text="@string/attachment_type_selector__location"/>
|
android:text="@string/attachment_type_selector__location" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -223,7 +233,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
style="@style/AttachmentTypeLabel"
|
style="@style/AttachmentTypeLabel"
|
||||||
android:text=" "/>
|
android:text=""/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<!-- <item android:title="@string/conversation__menu_view_all_media"
|
<item android:title="@string/conversation__menu_view_all_media"
|
||||||
android:id="@+id/menu_view_media" />
|
android:id="@+id/menu_view_media" />
|
||||||
|
|
||||||
<item android:title="@string/conversation__menu_conversation_settings"
|
<!-- <item android:title="@string/conversation__menu_conversation_settings"
|
||||||
android:id="@+id/menu_conversation_settings"/> -->
|
android:id="@+id/menu_conversation_settings"/> -->
|
||||||
|
|
||||||
|
|
||||||
|
@ -792,7 +792,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_call_secure: handleDial(getRecipient(), true); return true;
|
case R.id.menu_call_secure: handleDial(getRecipient(), true); return true;
|
||||||
case R.id.menu_call_insecure: handleDial(getRecipient(), false); return true;
|
case R.id.menu_call_insecure: handleDial(getRecipient(), false); return true;
|
||||||
// case R.id.menu_view_media: handleViewMedia(); return true;
|
case R.id.menu_view_media: handleViewMedia(); return true;
|
||||||
case R.id.menu_add_shortcut: handleAddShortcut(); return true;
|
case R.id.menu_add_shortcut: handleAddShortcut(); return true;
|
||||||
case R.id.menu_search: handleSearch(); return true;
|
case R.id.menu_search: handleSearch(); return true;
|
||||||
case R.id.menu_add_to_contacts: handleAddToContacts(); return true;
|
case R.id.menu_add_to_contacts: handleAddToContacts(); return true;
|
||||||
@ -2408,7 +2408,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (composeText.getText().length() == 0 && !attachmentManager.isAttachmentPresent()) {
|
if (composeText.getText().length() == 0 && !attachmentManager.isAttachmentPresent()) {
|
||||||
buttonToggle.display(sendButton);
|
buttonToggle.display(attachButton);
|
||||||
quickAttachmentToggle.show();
|
quickAttachmentToggle.show();
|
||||||
inlineAttachmentToggle.hide();
|
inlineAttachmentToggle.hide();
|
||||||
} else {
|
} else {
|
||||||
|
@ -473,7 +473,7 @@ public class ConversationItem extends LinearLayout
|
|||||||
|
|
||||||
if (isCaptionlessMms(messageRecord)) {
|
if (isCaptionlessMms(messageRecord)) {
|
||||||
bodyText.setVisibility(View.GONE);
|
bodyText.setVisibility(View.GONE);
|
||||||
} else { ;
|
} else {
|
||||||
Spannable text = MentionUtilities.highlightMentions(linkifyMessageBody(messageRecord.getDisplayBody(context), batchSelected.isEmpty()), messageRecord.isOutgoing(), messageRecord.getThreadId(), context);
|
Spannable text = MentionUtilities.highlightMentions(linkifyMessageBody(messageRecord.getDisplayBody(context), batchSelected.isEmpty()), messageRecord.isOutgoing(), messageRecord.getThreadId(), context);
|
||||||
text = SearchUtil.getHighlightedSpan(locale, () -> new BackgroundColorSpan(Color.YELLOW), text, searchQuery);
|
text = SearchUtil.getHighlightedSpan(locale, () -> new BackgroundColorSpan(Color.YELLOW), text, searchQuery);
|
||||||
text = SearchUtil.getHighlightedSpan(locale, () -> new ForegroundColorSpan(Color.BLACK), text, searchQuery);
|
text = SearchUtil.getHighlightedSpan(locale, () -> new ForegroundColorSpan(Color.BLACK), text, searchQuery);
|
||||||
|
@ -98,7 +98,7 @@ public class MmsSmsDatabase extends Database {
|
|||||||
|
|
||||||
public Cursor getConversation(long threadId, long offset, long limit) {
|
public Cursor getConversation(long threadId, long offset, long limit) {
|
||||||
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
||||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId + " AND LENGTH(" + MmsSmsColumns.BODY + ") > 0";
|
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
||||||
String limitStr = limit > 0 || offset > 0 ? offset + ", " + limit : null;
|
String limitStr = limit > 0 || offset > 0 ? offset + ", " + limit : null;
|
||||||
|
|
||||||
Cursor cursor = queryTables(PROJECTION, selection, order, limitStr);
|
Cursor cursor = queryTables(PROJECTION, selection, order, limitStr);
|
||||||
|
@ -795,6 +795,11 @@ public class PushDecryptJob extends BaseJob implements InjectableType {
|
|||||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||||
database.beginTransaction();
|
database.beginTransaction();
|
||||||
|
|
||||||
|
// Ignore message if it has no body and no attachments or anything
|
||||||
|
if (mediaMessage.getBody().isEmpty() && mediaMessage.getAttachments().isEmpty() && mediaMessage.getSharedContacts().isEmpty() && mediaMessage.getLinkPreviews().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Optional<InsertResult> insertResult;
|
Optional<InsertResult> insertResult;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -77,12 +77,15 @@ public class RetrieveProfileJob extends BaseJob implements InjectableType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun() throws IOException, InvalidKeyException {
|
public void onRun() throws IOException, InvalidKeyException {
|
||||||
|
// Loki - Disable retrieve profile
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
if (recipient.isGroupRecipient()) handleGroupRecipient(recipient);
|
if (recipient.isGroupRecipient()) handleGroupRecipient(recipient);
|
||||||
else handleIndividualRecipient(recipient);
|
else handleIndividualRecipient(recipient);
|
||||||
} catch (InvalidNumberException e) {
|
} catch (InvalidNumberException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,6 +58,7 @@ import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
|
|||||||
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
|
|
||||||
@ -117,10 +118,9 @@ public class MessageSender {
|
|||||||
// Loki - Turn into a GIF message if possible
|
// Loki - Turn into a GIF message if possible
|
||||||
if (message.getLinkPreviews().isEmpty() && message.getAttachments().isEmpty() && LinkPreviewUtil.isWhitelistedMediaUrl(message.getBody())) {
|
if (message.getLinkPreviews().isEmpty() && message.getAttachments().isEmpty() && LinkPreviewUtil.isWhitelistedMediaUrl(message.getBody())) {
|
||||||
new LinkPreviewRepository(context).fetchGIF(context, message.getBody(), attachmentOrNull -> Util.runOnMain(() -> {
|
new LinkPreviewRepository(context).fetchGIF(context, message.getBody(), attachmentOrNull -> Util.runOnMain(() -> {
|
||||||
if (attachmentOrNull.isPresent()) {
|
Attachment attachment = attachmentOrNull.orNull();
|
||||||
Attachment attachment = attachmentOrNull.get();
|
|
||||||
try {
|
try {
|
||||||
message.getAttachments().add(attachment);
|
if (attachment != null) { message.getAttachments().add(attachment); }
|
||||||
long messageID = database.insertMessageOutbox(message, allocatedThreadId, forceSms, insertListener);
|
long messageID = database.insertMessageOutbox(message, allocatedThreadId, forceSms, insertListener);
|
||||||
// Loki - Set the message's friend request status as soon as it has hit the database
|
// Loki - Set the message's friend request status as soon as it has hit the database
|
||||||
if (message.isFriendRequest) {
|
if (message.isFriendRequest) {
|
||||||
@ -131,19 +131,6 @@ public class MessageSender {
|
|||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
// TODO: Handle
|
// TODO: Handle
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
long messageID = database.insertMessageOutbox(message, allocatedThreadId, forceSms, insertListener);
|
|
||||||
// Loki - Set the message's friend request status as soon as it has hit the database
|
|
||||||
if (message.isFriendRequest) {
|
|
||||||
DatabaseFactory.getLokiMessageDatabase(context).setFriendRequestStatus(messageID, LokiMessageFriendRequestStatus.REQUEST_SENDING);
|
|
||||||
}
|
|
||||||
sendMediaMessage(context, recipient, forceSms, messageID, message.getExpiresIn());
|
|
||||||
} catch (MmsException e) {
|
|
||||||
Log.w(TAG, e);
|
|
||||||
// TODO: Handle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user