forked from CyanogenMod/android_packages_apps_Messaging
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for video and audio mms attachments
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
Showing
26 changed files
with
1,225 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/com/android/messaging/datamodel/AudioBoundCursorLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/com/android/messaging/datamodel/data/AudioListItemData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
Oops, something went wrong.