Skip to content

Commit

Permalink
Added support for video and audio mms attachments
Browse files Browse the repository at this point in the history
Change-Id: I690f941ac80a861e57494028f676a7db658bdce1
Ticket-Id: FEIJ-128, FEIJ-143
  • Loading branch information
Gary Kipnis authored and Joey Rizzoli committed Oct 17, 2016
1 parent 0011a89 commit 2e6e88f
Show file tree
Hide file tree
Showing 26 changed files with 1,225 additions and 12 deletions.
15 changes: 15 additions & 0 deletions res/drawable/ic_library_music_black_24px.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#000000"
android:pathData="M20 2H8c-1.1 0-2 .9-2 2v12c0 1.1 .9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2
5h-3v5.5c0 1.38-1.12 2.5-2.5 2.5S10 13.88 10 12.5s1.12-2.5 2.5-2.5c.57 0 1.08
.19 1.5 .51 V5h4v2zM4 6H2v14c0 1.1 .9 2 2 2h14v-2H4V6z" />
</vector>
15 changes: 15 additions & 0 deletions res/drawable/ic_library_music_white_24px.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20 2H8c-1.1 0-2 .9-2 2v12c0 1.1 .9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2
5h-3v5.5c0 1.38-1.12 2.5-2.5 2.5S10 13.88 10 12.5s1.12-2.5 2.5-2.5c.57 0 1.08
.19 1.5 .51 V5h4v2zM4 6H2v14c0 1.1 .9 2 2 2h14v-2H4V6z" />
</vector>
14 changes: 14 additions & 0 deletions res/drawable/ic_play_circle_filled_white_24px.xml
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 14.5v-9l6
4.5-6 4.5z" />
</vector>
56 changes: 56 additions & 0 deletions res/layout/audio_list_item_view.xml
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<com.android.messaging.ui.mediapicker.AudioListItemView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/audio_list_item_height"
android:background="@color/gallery_image_default_background"
android:clickable="true">

<FrameLayout
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/audio_list_item_icon_margin"
android:layout_width="@dimen/audio_list_item_icon_size"
android:layout_height="@dimen/audio_list_item_icon_size">

<CheckBox
android:id="@+id/audio_checkbox"
style="@style/GalleryGridItemViewCheckBoxStyle"
android:button="@drawable/gallery_checkbox_selector"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<ImageView
android:id="@+id/audio_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/transparent_button_background"
android:scaleType="fitCenter"
android:src="@drawable/ic_library_music_black_24px"
android:contentDescription="@string/video_thumbnail_view_play_button_content_description"/>

</FrameLayout>

<TextView
android:id="@+id/audio_filename"
android:layout_width="match_parent"
android:layout_height="@dimen/audio_list_item_text_height"
android:layout_marginLeft="@dimen/audio_list_item_text_margin"
android:layout_gravity="center_vertical"
android:textColor="@color/button_text"/>

</com.android.messaging.ui.mediapicker.AudioListItemView>
2 changes: 1 addition & 1 deletion res/layout/gallery_grid_item_view.xml
Expand Up @@ -39,7 +39,7 @@
android:layout_gravity="center"
android:background="@drawable/transparent_button_background"
android:scaleType="fitCenter"
android:src="@drawable/ic_video_play_light"
android:src="@drawable/ic_play_circle_filled_white_24px"
android:contentDescription="@string/video_thumbnail_view_play_button_content_description"/>
</FrameLayout>

Expand Down
39 changes: 39 additions & 0 deletions res/layout/mediapicker_audio_list_chooser.xml
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.android.messaging.ui.mediapicker.AudioListView
android:id="@+id/audio_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="6dp"
android:background="@android:color/white" />

<!-- This view will hide all other views if the required permission is not granted -->
<TextView
android:id="@+id/missing_permission_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/enable_permission_procedure"
android:contentDescription="@string/enable_permission_procedure_description"
android:background="@android:color/white"
android:gravity="center"
android:visibility="gone" />
</FrameLayout>
7 changes: 7 additions & 0 deletions res/values/dimens.xml
Expand Up @@ -92,6 +92,13 @@
<dimen name="multiple_attachment_preview_padding">1dp</dimen>
<dimen name="attachment_preview_more_items_text_size">22sp</dimen>

<dimen name="audio_list_item_height">48dp</dimen>
<dimen name="audio_list_item_icon_size">20dp</dimen>
<dimen name="audio_list_item_icon_margin">26dp</dimen>
<dimen name="audio_list_item_text_margin">26dp</dimen>
<dimen name="audio_list_item_text_height">24dp</dimen>


<item name="letter_to_tile_ratio" type="dimen">67%</item>
<item name="sim_identifier_to_tile_ratio" type="dimen">28%</item>
<item name="small_sim_identifier_to_tile_ratio" type="dimen">75%</item>
Expand Down
14 changes: 13 additions & 1 deletion res/values/strings.xml
Expand Up @@ -51,7 +51,9 @@
<string name="contact_list_send_to_text">Send to <xliff:g id="destination">%s</xliff:g></string>

<string name="mediapicker_cameraChooserDescription">Capture pictures or video</string>
<string name="mediapicker_galleryChooserDescription">Choose images from this device</string>
<string name="mediapicker_galleryChooserDescription">Choose images or videos from this
device</string>
<string name="mediapicker_audioListChooserDescription">Choose audios from this device</string>
<string name="mediapicker_audioChooserDescription">Record audio</string>
<string name="mediapicker_gallery_title">Choose photo</string>
<string name="mediapicker_gallery_item_selected_content_description">The media is selected.</string>
Expand All @@ -60,6 +62,16 @@
<!-- example: "image January 17 2015 1 59 pm" -->
<string name="mediapicker_gallery_image_item_description">image <xliff:g id="date">%1$tB %1$te %1$tY %1$tl %1$tM %1$tp</xliff:g></string>
<string name="mediapicker_gallery_image_item_description_no_date">image</string>
<string name="mediapicker_gallery_image_item_attachment_too_large">Can\'t attach video.
Max message size exceeded.</string>
<string name="mediapicker_audio_list_title">Choose audio</string>
<string name="mediapicker_audio_list_item_selected_content_description">The audio is selected
.</string>
<string name="mediapicker_audio_list_item_unselected_content_description">The audio is
unselected
.</string>
<string name="mediapicker_audio_list_title_selection"><xliff:g id="count">%d</xliff:g> selected
</string>
<string name="mediapicker_audio_title">Record audio</string>

<string name="action_share">Share</string>
Expand Down
49 changes: 49 additions & 0 deletions src/com/android/messaging/datamodel/AudioBoundCursorLoader.java
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2016 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 com.android.messaging.datamodel;

import android.content.Context;
import android.net.Uri;
import android.provider.MediaStore.Files;
import android.provider.MediaStore.Files.FileColumns;
import android.provider.MediaStore.Images.Media;
import com.android.messaging.datamodel.data.AudioListItemData;
import com.android.messaging.datamodel.data.MessagePartData;
import com.google.common.base.Joiner;

/**
* A BoundCursorLoader that reads local media on the device.
*/
public class AudioBoundCursorLoader extends BoundCursorLoader {
public static final String MEDIA_SCANNER_VOLUME_EXTERNAL = "external";
private static final Uri STORAGE_URI = Files.getContentUri(MEDIA_SCANNER_VOLUME_EXTERNAL);
private static final String SORT_ORDER = Media.DATE_MODIFIED + " DESC";
private static final String TAG = AudioBoundCursorLoader.class.getSimpleName();
private static final String AUDIO_SELECTION = createSelection(
MessagePartData.ACCEPTABLE_AUDIO_TYPES,
new Integer[] {FileColumns.MEDIA_TYPE_AUDIO});

public AudioBoundCursorLoader(final String bindingId, final Context context) {
super(bindingId, context, STORAGE_URI, AudioListItemData.AUDIO_PROJECTION,
AUDIO_SELECTION, null, SORT_ORDER);
}

private static String createSelection(final String[] mimeTypes, Integer[] mediaTypes) {
return Media.MIME_TYPE + " IN ('" + Joiner.on("','").join(mimeTypes) + "') AND "
+ FileColumns.MEDIA_TYPE + " IN (" + Joiner.on(',').join(mediaTypes) + ")";
}
}
3 changes: 3 additions & 0 deletions src/com/android/messaging/datamodel/DataModel.java
Expand Up @@ -25,6 +25,7 @@
import com.android.messaging.datamodel.action.Action;
import com.android.messaging.datamodel.action.ActionService;
import com.android.messaging.datamodel.action.BackgroundWorker;
import com.android.messaging.datamodel.data.AudioListItemData;
import com.android.messaging.datamodel.data.BlockedParticipantsData;
import com.android.messaging.datamodel.data.BlockedParticipantsData.BlockedParticipantsDataListener;
import com.android.messaging.datamodel.data.ContactListItemData;
Expand Down Expand Up @@ -84,6 +85,8 @@ public abstract ContactPickerData createContactPickerData(final Context context,

public abstract GalleryGridItemData createGalleryGridItemData();

public abstract AudioListItemData createAudioListItemData();

public abstract LaunchConversationData createLaunchConversationData(
LaunchConversationDataListener listener);

Expand Down
6 changes: 6 additions & 0 deletions src/com/android/messaging/datamodel/DataModelImpl.java
Expand Up @@ -25,6 +25,7 @@
import com.android.messaging.datamodel.action.BackgroundWorker;
import com.android.messaging.datamodel.action.FixupMessageStatusOnStartupAction;
import com.android.messaging.datamodel.action.ProcessPendingMessagesAction;
import com.android.messaging.datamodel.data.AudioListItemData;
import com.android.messaging.datamodel.data.BlockedParticipantsData;
import com.android.messaging.datamodel.data.BlockedParticipantsData.BlockedParticipantsDataListener;
import com.android.messaging.datamodel.data.ContactListItemData;
Expand Down Expand Up @@ -114,6 +115,11 @@ public GalleryGridItemData createGalleryGridItemData() {
return new GalleryGridItemData();
}

@Override
public AudioListItemData createAudioListItemData() {
return new AudioListItemData();
}

@Override
public LaunchConversationData createLaunchConversationData(
final LaunchConversationDataListener listener) {
Expand Down
Expand Up @@ -33,9 +33,10 @@ public class GalleryBoundCursorLoader extends BoundCursorLoader {
public static final String MEDIA_SCANNER_VOLUME_EXTERNAL = "external";
private static final Uri STORAGE_URI = Files.getContentUri(MEDIA_SCANNER_VOLUME_EXTERNAL);
private static final String SORT_ORDER = Media.DATE_MODIFIED + " DESC";
private static final String TAG = GalleryBoundCursorLoader.class.getSimpleName();
private static final String IMAGE_SELECTION = createSelection(
MessagePartData.ACCEPTABLE_IMAGE_TYPES,
new Integer[] { FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_VIDEO });
new Integer[] { FileColumns.MEDIA_TYPE_IMAGE, FileColumns.MEDIA_TYPE_VIDEO});

public GalleryBoundCursorLoader(final String bindingId, final Context context) {
super(bindingId, context, STORAGE_URI, GalleryGridItemData.IMAGE_PROJECTION,
Expand Down
90 changes: 90 additions & 0 deletions src/com/android/messaging/datamodel/data/AudioListItemData.java
@@ -0,0 +1,90 @@
/*
* Copyright (C) 2016 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 com.android.messaging.datamodel.data;

import android.database.Cursor;
import android.graphics.Rect;
import android.net.Uri;
import android.provider.BaseColumns;
import android.provider.MediaStore.Images.Media;
import android.text.TextUtils;
import com.android.messaging.util.UriUtil;

/**
* Provides data for GalleryGridItemView
*/
public class AudioListItemData {
private static final String TAG = AudioListItemData.class.getSimpleName();
public static final String[] AUDIO_PROJECTION = new String[] {
Media._ID,
Media.DATA,
Media.MIME_TYPE,
Media.DATE_MODIFIED};

public static final String[] SPECIAL_ITEM_COLUMNS = new String[] {
BaseColumns._ID
};

private static final int INDEX_ID = 0;

// For local image gallery.
private static final int INDEX_DATA_PATH = 1;
private static final int INDEX_MIME_TYPE = 2;
private static final int INDEX_DATE_MODIFIED = 3;

private Uri mAudioUri;
private String mContentType;
private long mDateSeconds;

public AudioListItemData() {
}

public void bind(final Cursor cursor) {
mContentType = cursor.getString(INDEX_MIME_TYPE);
final String dateModified = cursor.getString(INDEX_DATE_MODIFIED);
mDateSeconds = !TextUtils.isEmpty(dateModified) ? Long.parseLong(dateModified) : -1;
mAudioUri = UriUtil.getUriForResourceFile(cursor.getString(INDEX_DATA_PATH));
}

public Uri getAudioUri() {
return mAudioUri;
}

public String getAudioFilename() {
if (mAudioUri != null) {
return mAudioUri.getLastPathSegment();
} else {
return "";
}
}

public MessagePartData constructMessagePartData(final Rect startRect) {
return new MediaPickerMessagePartData(startRect, mContentType,
mAudioUri, 0, 0);
}

/**
* @return The date in seconds. This can be negative if we could not retreive date info
*/
public long getDateSeconds() {
return mDateSeconds;
}

public String getContentType() {
return mContentType;
}
}

0 comments on commit 2e6e88f

Please sign in to comment.