diff --git a/res/drawable-hdpi/ic_insert_drive_file_white_36dp.png b/res/drawable-hdpi/ic_insert_drive_file_white_36dp.png
new file mode 100644
index 0000000000..52c48e639f
Binary files /dev/null and b/res/drawable-hdpi/ic_insert_drive_file_white_36dp.png differ
diff --git a/res/drawable-mdpi/ic_insert_drive_file_white_36dp.png b/res/drawable-mdpi/ic_insert_drive_file_white_36dp.png
new file mode 100644
index 0000000000..84755e4881
Binary files /dev/null and b/res/drawable-mdpi/ic_insert_drive_file_white_36dp.png differ
diff --git a/res/drawable-xhdpi/ic_insert_drive_file_white_36dp.png b/res/drawable-xhdpi/ic_insert_drive_file_white_36dp.png
new file mode 100644
index 0000000000..f3e153b45e
Binary files /dev/null and b/res/drawable-xhdpi/ic_insert_drive_file_white_36dp.png differ
diff --git a/res/drawable-xxhdpi/ic_insert_drive_file_white_36dp.png b/res/drawable-xxhdpi/ic_insert_drive_file_white_36dp.png
new file mode 100644
index 0000000000..06886855a2
Binary files /dev/null and b/res/drawable-xxhdpi/ic_insert_drive_file_white_36dp.png differ
diff --git a/res/drawable-xxxhdpi/ic_insert_drive_file_white_36dp.png b/res/drawable-xxxhdpi/ic_insert_drive_file_white_36dp.png
new file mode 100644
index 0000000000..38b2017f09
Binary files /dev/null and b/res/drawable-xxxhdpi/ic_insert_drive_file_white_36dp.png differ
diff --git a/res/layout/attachment_type_selector.xml b/res/layout/attachment_type_selector.xml
index e2a48e1ebb..71c6404aa6 100644
--- a/res/layout/attachment_type_selector.xml
+++ b/res/layout/attachment_type_selector.xml
@@ -34,14 +34,14 @@
android:src="@drawable/ic_image_white_36dp"
android:scaleType="center"
android:elevation="4dp"
- android:contentDescription="@string/attachment_type_selector__image_description"
+ android:contentDescription="@string/attachment_type_selector__gallery_description"
app:circleColor="@color/purple_400"/>
+ android:text="@string/attachment_type_selector__gallery"/>
@@ -76,20 +76,20 @@
android:orientation="vertical">
+ android:text="@string/attachment_type_selector__document"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 04acc05f4e..31c3090b54 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -702,12 +702,8 @@
- Image
- Image
Audio
Audio
- Video
- Video
Contact
Contact
Camera
@@ -716,6 +712,11 @@
Location
GIF
Gif
+ Image or video
+ Document
+ Gallery
+ Document
+
Toggle attachment drawer
diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java
index 82b4c670e7..2aa88f4c16 100644
--- a/src/org/thoughtcrime/securesms/ConversationActivity.java
+++ b/src/org/thoughtcrime/securesms/ConversationActivity.java
@@ -106,7 +106,6 @@ import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.jobs.MultiDeviceBlockedUpdateJob;
import org.thoughtcrime.securesms.mms.AttachmentManager;
import org.thoughtcrime.securesms.mms.AttachmentManager.MediaType;
-import org.thoughtcrime.securesms.mms.AttachmentTypeSelectorAdapter;
import org.thoughtcrime.securesms.mms.AudioSlide;
import org.thoughtcrime.securesms.mms.LocationSlide;
import org.thoughtcrime.securesms.mms.MediaConstraints;
@@ -189,8 +188,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
public static final String TIMING_EXTRA = "timing";
public static final String LAST_SEEN_EXTRA = "last_seen";
- private static final int PICK_IMAGE = 1;
- private static final int PICK_VIDEO = 2;
+ private static final int PICK_GALLERY = 1;
+ private static final int PICK_DOCUMENT = 2;
private static final int PICK_AUDIO = 3;
private static final int PICK_CONTACT_INFO = 4;
private static final int GROUP_EDIT = 5;
@@ -374,12 +373,19 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
}
switch (reqCode) {
- case PICK_IMAGE:
- boolean isGif = MediaUtil.isGif(MediaUtil.getMimeType(this, data.getData()));
- setMedia(data.getData(), isGif ? MediaType.GIF : MediaType.IMAGE);
+ case PICK_GALLERY:
+ MediaType mediaType;
+
+ String mimeType = MediaUtil.getMimeType(this, data.getData());
+
+ if (MediaUtil.isGif(mimeType)) mediaType = MediaType.GIF;
+ else if (MediaUtil.isVideo(mimeType)) mediaType = MediaType.VIDEO;
+ else mediaType = MediaType.IMAGE;
+
+ setMedia(data.getData(), mediaType);
break;
- case PICK_VIDEO:
- setMedia(data.getData(), MediaType.VIDEO);
+ case PICK_DOCUMENT:
+ setMedia(data.getData(), MediaType.DOCUMENT);
break;
case PICK_AUDIO:
setMedia(data.getData(), MediaType.AUDIO);
@@ -1198,17 +1204,17 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private void addAttachment(int type) {
Log.w("ComposeMessageActivity", "Selected: " + type);
switch (type) {
- case AttachmentTypeSelectorAdapter.ADD_IMAGE:
- AttachmentManager.selectImage(this, PICK_IMAGE); break;
- case AttachmentTypeSelectorAdapter.ADD_VIDEO:
- AttachmentManager.selectVideo(this, PICK_VIDEO); break;
- case AttachmentTypeSelectorAdapter.ADD_SOUND:
+ case AttachmentTypeSelector.ADD_GALLERY:
+ AttachmentManager.selectGallery(this, PICK_GALLERY); break;
+ case AttachmentTypeSelector.ADD_DOCUMENT:
+ AttachmentManager.selectDocument(this, PICK_DOCUMENT); break;
+ case AttachmentTypeSelector.ADD_SOUND:
AttachmentManager.selectAudio(this, PICK_AUDIO); break;
- case AttachmentTypeSelectorAdapter.ADD_CONTACT_INFO:
+ case AttachmentTypeSelector.ADD_CONTACT_INFO:
AttachmentManager.selectContactInfo(this, PICK_CONTACT_INFO); break;
case AttachmentTypeSelector.ADD_LOCATION:
AttachmentManager.selectLocation(this, PICK_LOCATION); break;
- case AttachmentTypeSelectorAdapter.TAKE_PHOTO:
+ case AttachmentTypeSelector.TAKE_PHOTO:
attachmentManager.capturePhoto(this, TAKE_PHOTO); break;
case AttachmentTypeSelector.ADD_GIF:
AttachmentManager.selectGif(this, PICK_GIF, !isSecureText); break;
@@ -1723,7 +1729,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
Intent intent = new Intent();
intent.setData(uri);
- onActivityResult(PICK_IMAGE, RESULT_OK, intent);
+ onActivityResult(PICK_GALLERY, RESULT_OK, intent);
}
}
diff --git a/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java b/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java
index cfb524b9de..febc2d3781 100644
--- a/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java
+++ b/src/org/thoughtcrime/securesms/components/AttachmentTypeSelector.java
@@ -30,8 +30,8 @@ import org.thoughtcrime.securesms.util.ViewUtil;
public class AttachmentTypeSelector extends PopupWindow {
- public static final int ADD_IMAGE = 1;
- public static final int ADD_VIDEO = 2;
+ public static final int ADD_GALLERY = 1;
+ public static final int ADD_DOCUMENT = 2;
public static final int ADD_SOUND = 3;
public static final int ADD_CONTACT_INFO = 4;
public static final int TAKE_PHOTO = 5;
@@ -44,7 +44,7 @@ public class AttachmentTypeSelector extends PopupWindow {
private final @NonNull ImageView imageButton;
private final @NonNull ImageView audioButton;
- private final @NonNull ImageView videoButton;
+ private final @NonNull ImageView documentButton;
private final @NonNull ImageView contactButton;
private final @NonNull ImageView cameraButton;
private final @NonNull ImageView locationButton;
@@ -64,16 +64,16 @@ public class AttachmentTypeSelector extends PopupWindow {
this.listener = listener;
this.imageButton = ViewUtil.findById(layout, R.id.gallery_button);
this.audioButton = ViewUtil.findById(layout, R.id.audio_button);
- this.videoButton = ViewUtil.findById(layout, R.id.video_button);
+ this.documentButton = ViewUtil.findById(layout, R.id.document_button);
this.contactButton = ViewUtil.findById(layout, R.id.contact_button);
this.cameraButton = ViewUtil.findById(layout, R.id.camera_button);
this.locationButton = ViewUtil.findById(layout, R.id.location_button);
this.gifButton = ViewUtil.findById(layout, R.id.giphy_button);
this.closeButton = ViewUtil.findById(layout, R.id.close_button);
- this.imageButton.setOnClickListener(new PropagatingClickListener(ADD_IMAGE));
+ this.imageButton.setOnClickListener(new PropagatingClickListener(ADD_GALLERY));
this.audioButton.setOnClickListener(new PropagatingClickListener(ADD_SOUND));
- this.videoButton.setOnClickListener(new PropagatingClickListener(ADD_VIDEO));
+ this.documentButton.setOnClickListener(new PropagatingClickListener(ADD_DOCUMENT));
this.contactButton.setOnClickListener(new PropagatingClickListener(ADD_CONTACT_INFO));
this.cameraButton.setOnClickListener(new PropagatingClickListener(TAKE_PHOTO));
this.locationButton.setOnClickListener(new PropagatingClickListener(ADD_LOCATION));
@@ -121,7 +121,7 @@ public class AttachmentTypeSelector extends PopupWindow {
animateButtonIn(audioButton, ANIMATION_DURATION / 3);
animateButtonIn(locationButton, ANIMATION_DURATION / 3);
- animateButtonIn(videoButton, ANIMATION_DURATION / 4);
+ animateButtonIn(documentButton, ANIMATION_DURATION / 4);
animateButtonIn(gifButton, ANIMATION_DURATION / 4);
animateButtonIn(contactButton, 0);
animateButtonIn(closeButton, 0);
diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java
index 4b4513662f..3582c44270 100644
--- a/src/org/thoughtcrime/securesms/mms/AttachmentManager.java
+++ b/src/org/thoughtcrime/securesms/mms/AttachmentManager.java
@@ -297,12 +297,12 @@ public class AttachmentManager {
return deck;
}
- public static void selectVideo(Activity activity, int requestCode) {
- selectMediaType(activity, "video/*", requestCode);
+ public static void selectDocument(Activity activity, int requestCode) {
+ selectMediaType(activity, "*/*", requestCode);
}
- public static void selectImage(Activity activity, int requestCode) {
- selectMediaType(activity, "image/*", requestCode);
+ public static void selectGallery(Activity activity, int requestCode) {
+ selectMediaType(activity, "image/* video/*", requestCode);
}
public static void selectAudio(Activity activity, int requestCode) {
diff --git a/src/org/thoughtcrime/securesms/mms/AttachmentTypeSelectorAdapter.java b/src/org/thoughtcrime/securesms/mms/AttachmentTypeSelectorAdapter.java
deleted file mode 100644
index f31ec80d6f..0000000000
--- a/src/org/thoughtcrime/securesms/mms/AttachmentTypeSelectorAdapter.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2008 Esmertec AG.
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.thoughtcrime.securesms.mms;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import org.thoughtcrime.securesms.R;
-import org.thoughtcrime.securesms.util.ResUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class AttachmentTypeSelectorAdapter extends ArrayAdapter {
-
- public static final int ADD_IMAGE = 1;
- public static final int ADD_VIDEO = 2;
- public static final int ADD_SOUND = 3;
- public static final int ADD_CONTACT_INFO = 4;
- public static final int TAKE_PHOTO = 5;
-
- private final Context context;
-
- public AttachmentTypeSelectorAdapter(Context context) {
- super(context, R.layout.icon_list_item, getItemList(context));
- this.context = context;
- }
-
- public int buttonToCommand(int position) {
- return getItem(position).getCommand();
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View view;
-
- if (convertView == null) {
- LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = inflater.inflate(R.layout.icon_list_item, parent, false);
- } else {
- view = convertView;
- }
-
- TextView text = (TextView) view.findViewById(R.id.text1);
- ImageView image = (ImageView) view.findViewById(R.id.icon);
-
- text.setText(getItem(position).getTitle());
- image.setImageResource(getItem(position).getResource());
-
- return view;
- }
-
- private static List getItemList(Context context) {
- List data = new ArrayList<>(4);
- addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_camera), ResUtil.getDrawableRes(context, R.attr.conversation_attach_camera), 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_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_contact), ResUtil.getDrawableRes(context, R.attr.conversation_attach_contact_info), ADD_CONTACT_INFO);
-
- return data;
- }
-
- private static void addItem(List list, String text, int resource, int id) {
- list.add(new IconListItem(text, resource, id));
- }
-
- public static class IconListItem {
- private final String title;
- private final int resource;
- private final int id;
-
- public IconListItem(String title, int resource, int id) {
- this.resource = resource;
- this.title = title;
- this.id = id;
- }
-
- public int getCommand() {
- return id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public int getResource() {
- return resource;
- }
- }
-}
diff --git a/src/org/thoughtcrime/securesms/util/MediaUtil.java b/src/org/thoughtcrime/securesms/util/MediaUtil.java
index 38a175b5bf..621fe5289e 100644
--- a/src/org/thoughtcrime/securesms/util/MediaUtil.java
+++ b/src/org/thoughtcrime/securesms/util/MediaUtil.java
@@ -158,6 +158,10 @@ public class MediaUtil {
return ContentType.isVideoType(attachment.getContentType());
}
+ public static boolean isVideo(String contentType) {
+ return !TextUtils.isEmpty(contentType) && contentType.trim().startsWith("video/");
+ }
+
public static @Nullable String getDiscreteMimeType(@NonNull String mimeType) {
final String[] sections = mimeType.split("/", 2);
return sections.length > 1 ? sections[0] : null;