diff options
author | Gary Kipnis <gkipnis@cyngn.com> | 2016-05-20 15:25:59 -0700 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2016-12-30 21:04:51 +0200 |
commit | 645ed733485dade12b19c681249c9d2512fa399d (patch) | |
tree | cffb183a94fb8364de8cde7ca2a10026434f5cfc /src/com/android/messaging/datamodel/data/AudioListItemData.java | |
parent | 6179387cf79592ecded99eb411605c602c3e20bb (diff) | |
download | android_packages_apps_Messaging-645ed733485dade12b19c681249c9d2512fa399d.tar.gz android_packages_apps_Messaging-645ed733485dade12b19c681249c9d2512fa399d.tar.bz2 android_packages_apps_Messaging-645ed733485dade12b19c681249c9d2512fa399d.zip |
Added support for video and audio mms attachments
Change-Id: I690f941ac80a861e57494028f676a7db658bdce1
Ticket-Id: FEIJ-128, FEIJ-143
Diffstat (limited to 'src/com/android/messaging/datamodel/data/AudioListItemData.java')
-rw-r--r-- | src/com/android/messaging/datamodel/data/AudioListItemData.java | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/com/android/messaging/datamodel/data/AudioListItemData.java b/src/com/android/messaging/datamodel/data/AudioListItemData.java new file mode 100644 index 0000000..e069c80 --- /dev/null +++ b/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; + } +} |