mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-29 01:40:46 +00:00
parent
7593918006
commit
a44a4bc759
@ -108,7 +108,8 @@
|
|||||||
android:src="?quick_camera_icon"
|
android:src="?quick_camera_icon"
|
||||||
android:background="@drawable/touch_highlight_background"
|
android:background="@drawable/touch_highlight_background"
|
||||||
android:contentDescription="@string/conversation_activity__quick_attachment_drawer_toggle_description"
|
android:contentDescription="@string/conversation_activity__quick_attachment_drawer_toggle_description"
|
||||||
android:padding="10dp"/>
|
android:visibility="gone"
|
||||||
|
android:padding="10dp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.AnimatingToggle
|
<org.thoughtcrime.securesms.components.AnimatingToggle
|
||||||
|
@ -160,6 +160,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private static final int PICK_AUDIO = 3;
|
private static final int PICK_AUDIO = 3;
|
||||||
private static final int PICK_CONTACT_INFO = 4;
|
private static final int PICK_CONTACT_INFO = 4;
|
||||||
private static final int GROUP_EDIT = 5;
|
private static final int GROUP_EDIT = 5;
|
||||||
|
private static final int TAKE_PHOTO = 6;
|
||||||
|
|
||||||
private MasterSecret masterSecret;
|
private MasterSecret masterSecret;
|
||||||
protected ComposeText composeText;
|
protected ComposeText composeText;
|
||||||
@ -285,7 +286,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
Log.w(TAG, "onActivityResult called: " + reqCode + ", " + resultCode + " , " + data);
|
Log.w(TAG, "onActivityResult called: " + reqCode + ", " + resultCode + " , " + data);
|
||||||
super.onActivityResult(reqCode, resultCode, data);
|
super.onActivityResult(reqCode, resultCode, data);
|
||||||
|
|
||||||
if (data == null || resultCode != RESULT_OK) return;
|
if (data == null && reqCode != TAKE_PHOTO || resultCode != RESULT_OK) return;
|
||||||
|
|
||||||
switch (reqCode) {
|
switch (reqCode) {
|
||||||
case PICK_IMAGE:
|
case PICK_IMAGE:
|
||||||
@ -306,6 +307,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
setBlockedUserState(recipients);
|
setBlockedUserState(recipients);
|
||||||
supportInvalidateOptionsMenu();
|
supportInvalidateOptionsMenu();
|
||||||
break;
|
break;
|
||||||
|
case TAKE_PHOTO:
|
||||||
|
if (attachmentManager.getCaptureUri() != null) {
|
||||||
|
addAttachmentImage(masterSecret, attachmentManager.getCaptureUri());
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,6 +814,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
||||||
|
|
||||||
attachButton.setOnClickListener(new AttachButtonListener());
|
attachButton.setOnClickListener(new AttachButtonListener());
|
||||||
|
quickAttachmentToggle.setEnabled(false);
|
||||||
sendButton.setOnClickListener(sendButtonListener);
|
sendButton.setOnClickListener(sendButtonListener);
|
||||||
sendButton.setEnabled(true);
|
sendButton.setEnabled(true);
|
||||||
sendButton.addOnTransportChangedListener(new OnTransportChangedListener() {
|
sendButton.addOnTransportChangedListener(new OnTransportChangedListener() {
|
||||||
@ -963,6 +970,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
AttachmentManager.selectAudio(this, PICK_AUDIO); break;
|
AttachmentManager.selectAudio(this, PICK_AUDIO); break;
|
||||||
case AttachmentTypeSelectorAdapter.ADD_CONTACT_INFO:
|
case AttachmentTypeSelectorAdapter.ADD_CONTACT_INFO:
|
||||||
AttachmentManager.selectContactInfo(this, PICK_CONTACT_INFO); break;
|
AttachmentManager.selectContactInfo(this, PICK_CONTACT_INFO); break;
|
||||||
|
case AttachmentTypeSelectorAdapter.TAKE_PHOTO:
|
||||||
|
attachmentManager.capturePhoto(this, TAKE_PHOTO); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -41,6 +42,7 @@ import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|||||||
import org.thoughtcrime.securesms.providers.CaptureProvider;
|
import org.thoughtcrime.securesms.providers.CaptureProvider;
|
||||||
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class AttachmentManager {
|
public class AttachmentManager {
|
||||||
@ -92,7 +94,8 @@ public class AttachmentManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
if (captureUri != null) CaptureProvider.getInstance(context).delete(captureUri);
|
// if (captureUri != null) CaptureProvider.getInstance(context).delete(captureUri);
|
||||||
|
if (captureUri != null) new File(captureUri.getPath()).delete();
|
||||||
captureUri = null;
|
captureUri = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +157,24 @@ public class AttachmentManager {
|
|||||||
activity.startActivityForResult(intent, requestCode);
|
activity.startActivityForResult(intent, requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Uri getCaptureUri() {
|
||||||
|
return captureUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void capturePhoto(Activity activity, int requestCode) {
|
||||||
|
try {
|
||||||
|
Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
if (captureIntent.resolveActivity(activity.getPackageManager()) != null) {
|
||||||
|
File captureFile = File.createTempFile(String.valueOf(System.currentTimeMillis()), ".jpg", activity.getExternalFilesDir(null));
|
||||||
|
captureUri = Uri.fromFile(captureFile);
|
||||||
|
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, captureUri);
|
||||||
|
activity.startActivityForResult(captureIntent, requestCode);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
Log.w(TAG, ioe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void selectMediaType(Activity activity, String type, int requestCode) {
|
private static void selectMediaType(Activity activity, String type, int requestCode) {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setType(type);
|
intent.setType(type);
|
||||||
|
@ -37,6 +37,7 @@ public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSe
|
|||||||
public static final int ADD_VIDEO = 2;
|
public static final int ADD_VIDEO = 2;
|
||||||
public static final int ADD_SOUND = 3;
|
public static final int ADD_SOUND = 3;
|
||||||
public static final int ADD_CONTACT_INFO = 4;
|
public static final int ADD_CONTACT_INFO = 4;
|
||||||
|
public static final int TAKE_PHOTO = 5;
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSe
|
|||||||
|
|
||||||
private static List<IconListItem> getItemList(Context context) {
|
private static List<IconListItem> getItemList(Context context) {
|
||||||
List<IconListItem> data = new ArrayList<>(4);
|
List<IconListItem> data = new ArrayList<>(4);
|
||||||
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_take_photo), ResUtil.getDrawableRes(context, R.attr.conversation_attach_contact_info), TAKE_PHOTO);
|
||||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_picture), ResUtil.getDrawableRes(context, R.attr.conversation_attach_image), ADD_IMAGE);
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_picture), ResUtil.getDrawableRes(context, R.attr.conversation_attach_image), ADD_IMAGE);
|
||||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_video), ResUtil.getDrawableRes(context, R.attr.conversation_attach_video), ADD_VIDEO);
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_video), ResUtil.getDrawableRes(context, R.attr.conversation_attach_video), ADD_VIDEO);
|
||||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_audio), ResUtil.getDrawableRes(context, R.attr.conversation_attach_sound), ADD_SOUND);
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_audio), ResUtil.getDrawableRes(context, R.attr.conversation_attach_sound), ADD_SOUND);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user