summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Garnes <matt@cyngn.com>2015-04-30 11:01:17 -0700
committerMatt Garnes <matt@cyngn.com>2015-05-05 10:43:36 -0700
commitfbab7f32d2014c2bdae4eccf99d31ca76d0bf8f6 (patch)
tree4b71b113c9c910bd4cb95efe81e84517634b3aa9
parent3fcec525d3dc64e34539734bbcaf3471f40ec2db (diff)
parent725da2fbd78bf38ff71bdbe9e1f27667dbf0fa73 (diff)
downloadandroid_packages_apps_Gallery2-caf/cm-12.1.tar.gz
android_packages_apps_Gallery2-caf/cm-12.1.tar.bz2
android_packages_apps_Gallery2-caf/cm-12.1.zip
Merge remote-tracking branch 'caf/LA.BR.1.2.3' into caf/cm-12.1caf/cm-12.1
Conflicts: res/layout/action_mode.xml Change-Id: Id4005a098134f089e904ed090acec7ca6f786ad1
-rwxr-xr-xAndroid.mk4
-rw-r--r--proguard.flags4
-rw-r--r--res/drawable-hdpi/ic_photoeditor_makeup.pngbin0 -> 2181 bytes
-rw-r--r--res/drawable-hdpi/ic_ts_makeup_bigeye.pngbin0 -> 3908 bytes
-rw-r--r--res/drawable-hdpi/ic_ts_makeup_soften.pngbin0 -> 3180 bytes
-rw-r--r--res/drawable-hdpi/ic_ts_makeup_trimface.pngbin0 -> 3648 bytes
-rw-r--r--res/drawable-hdpi/ic_ts_makeup_whiten.pngbin0 -> 4523 bytes
-rw-r--r--res/drawable-mdpi/ic_photoeditor_makeup.pngbin0 -> 1728 bytes
-rw-r--r--res/drawable-mdpi/ic_ts_makeup_bigeye.pngbin0 -> 4756 bytes
-rw-r--r--res/drawable-mdpi/ic_ts_makeup_soften.pngbin0 -> 4224 bytes
-rw-r--r--res/drawable-mdpi/ic_ts_makeup_trimface.pngbin0 -> 4543 bytes
-rw-r--r--res/drawable-mdpi/ic_ts_makeup_whiten.pngbin0 -> 5074 bytes
-rw-r--r--res/drawable-xhdpi/ic_photoeditor_makeup.pngbin0 -> 2650 bytes
-rw-r--r--res/drawable-xhdpi/ic_ts_makeup_bigeye.pngbin0 -> 7118 bytes
-rw-r--r--res/drawable-xhdpi/ic_ts_makeup_soften.pngbin0 -> 5782 bytes
-rw-r--r--res/drawable-xhdpi/ic_ts_makeup_trimface.pngbin0 -> 6552 bytes
-rw-r--r--res/drawable-xhdpi/ic_ts_makeup_whiten.pngbin0 -> 7779 bytes
-rw-r--r--res/drawable-xxhdpi/ic_photoeditor_makeup_xx.pngbin0 -> 3798 bytes
-rw-r--r--res/layout-land/filtershow_main_panel.xml10
-rw-r--r--res/layout/action_mode.xml47
-rw-r--r--res/layout/appwidget_drm_empty_item.xml48
-rw-r--r--res/layout/appwidget_photo_item.xml8
-rw-r--r--res/layout/filtershow_main_panel.xml13
-rw-r--r--res/menu/albumset.xml1
-rw-r--r--res/values-es-rUS/strings.xml5
-rwxr-xr-x[-rw-r--r--]res/values-zh-rCN/strings.xml5
-rwxr-xr-x[-rw-r--r--]res/values-zh-rHK/strings.xml1
-rwxr-xr-x[-rw-r--r--]res/values-zh-rTW/strings.xml1
-rw-r--r--res/values/filtershow_ids.xml1
-rwxr-xr-x[-rw-r--r--]res/values/strings.xml9
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java115
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java79
-rw-r--r--src/com/android/gallery3d/app/GalleryActivity.java92
-rw-r--r--src/com/android/gallery3d/app/MovieActivity.java67
-rw-r--r--src/com/android/gallery3d/app/MovieControllerOverlay.java16
-rwxr-xr-xsrc/com/android/gallery3d/app/MoviePlayer.java11
-rwxr-xr-xsrc/com/android/gallery3d/app/PhotoDataAdapter.java12
-rwxr-xr-xsrc/com/android/gallery3d/app/PhotoPage.java201
-rw-r--r--src/com/android/gallery3d/app/SlideshowPage.java16
-rw-r--r--src/com/android/gallery3d/app/Wallpaper.java1
-rw-r--r--src/com/android/gallery3d/data/DecodeUtils.java22
-rwxr-xr-x[-rw-r--r--]src/com/android/gallery3d/data/FaceClustering.java2
-rw-r--r--src/com/android/gallery3d/data/FilterTypeSet.java3
-rw-r--r--src/com/android/gallery3d/data/ImageCacheRequest.java44
-rw-r--r--src/com/android/gallery3d/data/LocalImage.java79
-rw-r--r--src/com/android/gallery3d/data/LocalVideo.java47
-rw-r--r--src/com/android/gallery3d/data/MediaObject.java10
-rw-r--r--src/com/android/gallery3d/data/UriImage.java78
-rw-r--r--src/com/android/gallery3d/data/UriSource.java15
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java46
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryAdapter.java3
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryPanel.java11
-rw-r--r--src/com/android/gallery3d/filtershow/category/MainPanel.java41
-rw-r--r--src/com/android/gallery3d/filtershow/crop/CropActivity.java6
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorMakeup.java44
-rw-r--r--src/com/android/gallery3d/filtershow/editors/EditorPanel.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java21
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java1
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java54
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java52
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java55
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java53
-rw-r--r--src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java82
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java2
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java4
-rw-r--r--src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java2
-rw-r--r--src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java2
-rw-r--r--src/com/android/gallery3d/gadget/WidgetClickHandler.java2
-rw-r--r--src/com/android/gallery3d/gadget/WidgetService.java35
-rw-r--r--src/com/android/gallery3d/glrenderer/NinePatchTexture.java2
-rw-r--r--src/com/android/gallery3d/glrenderer/ResourceTexture.java13
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java14
-rw-r--r--src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java4
-rw-r--r--src/com/android/gallery3d/ui/AlbumSlidingWindow.java13
-rw-r--r--src/com/android/gallery3d/ui/MenuExecutor.java31
-rwxr-xr-xsrc/com/android/gallery3d/ui/PhotoView.java29
-rwxr-xr-xsrc/com/android/gallery3d/util/GIFView.java20
-rw-r--r--src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java79
-rw-r--r--src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java39
-rw-r--r--src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java87
-rw-r--r--src/org/codeaurora/gallery3d/ext/MovieListLoader.java11
-rwxr-xr-xsrc/org/codeaurora/gallery3d/video/CodeauroraVideoView.java6
82 files changed, 1183 insertions, 750 deletions
diff --git a/Android.mk b/Android.mk
index 216c9d693..8721c36da 100755
--- a/Android.mk
+++ b/Android.mk
@@ -28,6 +28,10 @@ LOCAL_OVERRIDES_PACKAGES := Gallery Gallery3D GalleryNew3D
LOCAL_JNI_SHARED_LIBRARIES := libjni_eglfence libjni_filtershow_filters librsjni libjni_jpegstream
+ifeq ($(TARGET_TS_MAKEUP), true)
+ LOCAL_REQUIRED_MODULES := libts_detected_face_jni libts_face_beautify_jni
+endif
+
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_MULTILIB := 32
diff --git a/proguard.flags b/proguard.flags
index fc5aef3b7..d190434b7 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -88,3 +88,7 @@
-keep class com.android.gallery3d.jpegstream.JPEGOutputStream { *; }
-keep class com.android.gallery3d.jpegstream.JPEGInputStream { *; }
-keep class com.android.gallery3d.jpegstream.StreamUtils { *; }
+
+-keep class com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine{
+ *;
+}
diff --git a/res/drawable-hdpi/ic_photoeditor_makeup.png b/res/drawable-hdpi/ic_photoeditor_makeup.png
new file mode 100644
index 000000000..06913d638
--- /dev/null
+++ b/res/drawable-hdpi/ic_photoeditor_makeup.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_ts_makeup_bigeye.png b/res/drawable-hdpi/ic_ts_makeup_bigeye.png
new file mode 100644
index 000000000..bf7b6f5ab
--- /dev/null
+++ b/res/drawable-hdpi/ic_ts_makeup_bigeye.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_ts_makeup_soften.png b/res/drawable-hdpi/ic_ts_makeup_soften.png
new file mode 100644
index 000000000..caa645158
--- /dev/null
+++ b/res/drawable-hdpi/ic_ts_makeup_soften.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_ts_makeup_trimface.png b/res/drawable-hdpi/ic_ts_makeup_trimface.png
new file mode 100644
index 000000000..3ac43f793
--- /dev/null
+++ b/res/drawable-hdpi/ic_ts_makeup_trimface.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_ts_makeup_whiten.png b/res/drawable-hdpi/ic_ts_makeup_whiten.png
new file mode 100644
index 000000000..a12560f09
--- /dev/null
+++ b/res/drawable-hdpi/ic_ts_makeup_whiten.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_photoeditor_makeup.png b/res/drawable-mdpi/ic_photoeditor_makeup.png
new file mode 100644
index 000000000..606f591af
--- /dev/null
+++ b/res/drawable-mdpi/ic_photoeditor_makeup.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_ts_makeup_bigeye.png b/res/drawable-mdpi/ic_ts_makeup_bigeye.png
new file mode 100644
index 000000000..8d8da29c1
--- /dev/null
+++ b/res/drawable-mdpi/ic_ts_makeup_bigeye.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_ts_makeup_soften.png b/res/drawable-mdpi/ic_ts_makeup_soften.png
new file mode 100644
index 000000000..a36d189c7
--- /dev/null
+++ b/res/drawable-mdpi/ic_ts_makeup_soften.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_ts_makeup_trimface.png b/res/drawable-mdpi/ic_ts_makeup_trimface.png
new file mode 100644
index 000000000..e27370f92
--- /dev/null
+++ b/res/drawable-mdpi/ic_ts_makeup_trimface.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_ts_makeup_whiten.png b/res/drawable-mdpi/ic_ts_makeup_whiten.png
new file mode 100644
index 000000000..7ac882312
--- /dev/null
+++ b/res/drawable-mdpi/ic_ts_makeup_whiten.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_photoeditor_makeup.png b/res/drawable-xhdpi/ic_photoeditor_makeup.png
new file mode 100644
index 000000000..834c899b7
--- /dev/null
+++ b/res/drawable-xhdpi/ic_photoeditor_makeup.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_ts_makeup_bigeye.png b/res/drawable-xhdpi/ic_ts_makeup_bigeye.png
new file mode 100644
index 000000000..f4b85005c
--- /dev/null
+++ b/res/drawable-xhdpi/ic_ts_makeup_bigeye.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_ts_makeup_soften.png b/res/drawable-xhdpi/ic_ts_makeup_soften.png
new file mode 100644
index 000000000..cdd699569
--- /dev/null
+++ b/res/drawable-xhdpi/ic_ts_makeup_soften.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_ts_makeup_trimface.png b/res/drawable-xhdpi/ic_ts_makeup_trimface.png
new file mode 100644
index 000000000..e419c19a6
--- /dev/null
+++ b/res/drawable-xhdpi/ic_ts_makeup_trimface.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_ts_makeup_whiten.png b/res/drawable-xhdpi/ic_ts_makeup_whiten.png
new file mode 100644
index 000000000..6fc305f36
--- /dev/null
+++ b/res/drawable-xhdpi/ic_ts_makeup_whiten.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_photoeditor_makeup_xx.png b/res/drawable-xxhdpi/ic_photoeditor_makeup_xx.png
new file mode 100644
index 000000000..3db1df26c
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_photoeditor_makeup_xx.png
Binary files differ
diff --git a/res/layout-land/filtershow_main_panel.xml b/res/layout-land/filtershow_main_panel.xml
index 6a36de2d7..e508e767b 100644
--- a/res/layout-land/filtershow_main_panel.xml
+++ b/res/layout-land/filtershow_main_panel.xml
@@ -83,6 +83,16 @@
android:padding="2dip"
android:scaleType="centerInside"
android:src="@drawable/ic_photoeditor_color"/>
+ <ImageButton
+ android:id="@+id/makeupButton"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:background="@drawable/filtershow_button_background"
+ android:padding="2dip"
+ android:scaleType="centerInside"
+ android:visibility="gone"
+ android:src="@drawable/ic_photoeditor_makeup"/>
</LinearLayout>
diff --git a/res/layout/action_mode.xml b/res/layout/action_mode.xml
index 096187b95..b1f774ce2 100644
--- a/res/layout/action_mode.xml
+++ b/res/layout/action_mode.xml
@@ -14,22 +14,35 @@
limitations under the License.
-->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/navigation_bar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="horizontal">
+
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
android:layout_height="match_parent">
- <Button android:id="@+id/selection_menu"
- style="?android:attr/actionButtonStyle"
- android:divider="?android:attr/listDividerAlertDialog"
- android:textAppearance="?android:attr/textAppearanceLargePopupMenu"
- android:textColor="?android:attr/actionMenuTextColor"
- android:singleLine="true"
- android:gravity="left|center_vertical"
- android:paddingRight="25dip"
+ <ImageView android:layout_gravity="right"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:src="@drawable/dropdown_ic_arrow" />
+ <Button android:id="@+id/selection_menu"
+ style="?android:attr/actionButtonStyle"
+ android:divider="?android:attr/listDividerAlertDialog"
+ android:textAppearance="?android:attr/textAppearanceLargePopupMenu"
+ android:textColor="?android:attr/actionMenuTextColor"
+ android:singleLine="true"
+ android:gravity="left|center_vertical"
+ android:paddingEnd="25dip"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent" />
+ </FrameLayout>
+ <ImageView android:layout_marginStart="16dip"
+ android:layout_marginEnd="8dip"
android:layout_width="wrap_content"
- android:layout_height="match_parent" />
- <ImageView android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:src="@drawable/dropdown_ic_arrow"
- android:layout_toRightOf="@id/selection_menu"/>
-
-</RelativeLayout>
+ android:layout_height="match_parent"
+ android:gravity="bottom"
+ android:src="@drawable/cab_divider_vertical_dark" />
+</LinearLayout>
diff --git a/res/layout/appwidget_drm_empty_item.xml b/res/layout/appwidget_drm_empty_item.xml
new file mode 100644
index 000000000..8261dbe77
--- /dev/null
+++ b/res/layout/appwidget_drm_empty_item.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/appwidget_photo_border" >
+
+ <RelativeLayout
+ android:layout_width="@dimen/stack_photo_width"
+ android:layout_height="@dimen/stack_photo_height"
+ android:background="@android:color/darker_gray" >
+
+ <ImageView
+ android:id="@+id/drm_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:background="@drawable/drm_image" />
+ </RelativeLayout>
+s
+</FrameLayout> \ No newline at end of file
diff --git a/res/layout/appwidget_photo_item.xml b/res/layout/appwidget_photo_item.xml
index a56a6d7a5..25e88f5fb 100644
--- a/res/layout/appwidget_photo_item.xml
+++ b/res/layout/appwidget_photo_item.xml
@@ -24,4 +24,12 @@
android:layout_width="wrap_content"
android:scaleType="fitCenter"
android:adjustViewBounds="true" />
+
+ <ImageView
+ android:id="@+id/drm_icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:background="@drawable/drm_image" />
+
</FrameLayout>
diff --git a/res/layout/filtershow_main_panel.xml b/res/layout/filtershow_main_panel.xml
index d3400fae5..f8b26b088 100644
--- a/res/layout/filtershow_main_panel.xml
+++ b/res/layout/filtershow_main_panel.xml
@@ -95,8 +95,19 @@
android:scaleType="centerInside"
android:src="@drawable/ic_photoeditor_color"/>
+ <ImageButton
+ android:id="@+id/makeupButton"
+ android:layout_width="@dimen/thumbnail_size"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:padding="2dip"
+ android:background="@drawable/filtershow_button_background"
+ android:scaleType="centerInside"
+ android:visibility="gone"
+ android:src="@drawable/ic_photoeditor_makeup"/>
+
</LinearLayout>
</com.android.gallery3d.filtershow.CenteredLinearLayout>
-</LinearLayout> \ No newline at end of file
+</LinearLayout>
diff --git a/res/menu/albumset.xml b/res/menu/albumset.xml
index 7d2f67624..182e83cd4 100644
--- a/res/menu/albumset.xml
+++ b/res/menu/albumset.xml
@@ -26,6 +26,7 @@
android:showAsAction="never" />
<item android:id="@+id/action_manage_offline"
android:title="@string/make_available_offline"
+ android:visible="false"
android:showAsAction="never" />
<item android:id="@+id/action_sync_picasa_albums"
android:title="@string/sync_picasa_albums"
diff --git a/res/values-es-rUS/strings.xml b/res/values-es-rUS/strings.xml
index e639fd4c5..2c4ab5166 100644
--- a/res/values-es-rUS/strings.xml
+++ b/res/values-es-rUS/strings.xml
@@ -436,4 +436,9 @@
<item quantity="one" msgid="6949174783125614798">"%1$d foto"</item>
<item quantity="other" msgid="3813306834113858135">"%1$d fotos"</item>
</plurals>
+
+ <string name="no_permission_for_drm">Los archivos DRM no pueden compartirse.</string>
+ <string name="drm_license_info">Información de licencia Drm</string>
+ <string name="mimetype_not_supported">No puede reproducirse este archivo.</string>
+ <string name="action_consumes_rights">Se agotarán los derechos para reproducir este multimedia.</string>
</resources>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 4de380467..23bcb4508 100644..100755
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -105,6 +105,7 @@
<string name="group_by_size" msgid="153766174950394155">"按大小分组"</string>
<string name="untagged" msgid="7281481064509590402">"未加标签"</string>
<string name="no_location" msgid="4043624857489331676">"无位置信息"</string>
+ <string name="no_faces">"无人物信息"</string>
<string name="no_connectivity" msgid="7164037617297293668">"出现网络问题,系统无法识别某些位置。"</string>
<string name="sync_album_error" msgid="1020688062900977530">"无法下载此相册中的照片,请稍后重试。"</string>
<string name="show_images_only" msgid="7263218480867672653">"仅限图片"</string>
@@ -444,4 +445,8 @@
<string name="virtualizer_strength" msgid="5035111173763913313">"3D 音效"</string>
<string name="audio_effects" msgid="612896145300512593">"音效"</string>
<string name="headset_plug">“插入耳机体验音效”</string>
+ <string name="text_makeup_whiten">美白</string>
+ <string name="text_makeup_Soften">磨皮</string>
+ <string name="text_makeup_trimface">瘦脸</string>
+ <string name="text_makeup_bigeye">大眼</string>
</resources>
diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml
index 68317d582..434190b43 100644..100755
--- a/res/values-zh-rHK/strings.xml
+++ b/res/values-zh-rHK/strings.xml
@@ -105,6 +105,7 @@
<string name="group_by_size" msgid="153766174950394155">"依大小分類"</string>
<string name="untagged" msgid="7281481064509590402">"無標記"</string>
<string name="no_location" msgid="4043624857489331676">"無地點資訊"</string>
+ <string name="no_faces">"無人物資訊"</string>
<string name="no_connectivity" msgid="7164037617297293668">"網絡發生問題,因此部分位置無法辨別。"</string>
<string name="sync_album_error" msgid="1020688062900977530">"無法下載這本相簿中的相片,請稍後再試。"</string>
<string name="show_images_only" msgid="7263218480867672653">"僅顯示相片"</string>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index edb7f696d..de49fb45e 100644..100755
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -105,6 +105,7 @@
<string name="group_by_size" msgid="153766174950394155">"依大小分類"</string>
<string name="untagged" msgid="7281481064509590402">"無標記"</string>
<string name="no_location" msgid="4043624857489331676">"無位置資訊"</string>
+ <string name="no_faces">"無人物資訊"</string>
<string name="no_connectivity" msgid="7164037617297293668">"網路發生問題,因此無法辨識部分位置。"</string>
<string name="sync_album_error" msgid="1020688062900977530">"無法下載這個相簿中的相片,請稍後再試。"</string>
<string name="show_images_only" msgid="7263218480867672653">"僅顯示圖片"</string>
diff --git a/res/values/filtershow_ids.xml b/res/values/filtershow_ids.xml
index 460da61aa..58f16dcd1 100644
--- a/res/values/filtershow_ids.xml
+++ b/res/values/filtershow_ids.xml
@@ -50,4 +50,5 @@
<item type="id" name="editorParametric" />
<item type="id" name="editorGrad" />
<item type="id" name="editorChanSat" />
+ <item type="id" name="editorMakeup" />
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 82b286b32..1fef507dd 100644..100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -236,6 +236,10 @@
have location information in them [CHAR LIMIT=20]-->
<string name="no_location">No location</string>
+ <!-- When grouping photos by peoples, the label used for photos that don't
+ have people information in them [CHAR LIMIT=20]-->
+ <string name="no_faces">No faces</string>
+
<!-- This toast message is shown when network connection is lost while doing clustering -->
<string name="no_connectivity">Some locations couldn\'t be identified due to network problems.</string>
@@ -1152,4 +1156,9 @@ CHAR LIMIT = NONE] -->
<string name="drm_license_info">Drm license info</string>
<string name="mimetype_not_supported">This file can not be played</string>
<string name="action_consumes_rights">Rights will be consumed for playing this media</string>
+ <string name="text_makeup_whiten">Whiten</string>
+ <string name="text_makeup_Soften">Soften</string>
+ <string name="text_makeup_trimface">Trimface</string>
+ <string name="text_makeup_bigeye">Bigeye</string>
+
</resources>
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index d0056fcfd..629e88210 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -18,24 +18,14 @@ package com.android.gallery3d.app;
import android.app.Activity;
import android.content.Context;
-import android.content.ContentValues;
import android.content.Intent;
-import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmRights;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
-import android.graphics.BitmapFactory;
-import android.graphics.BitmapFactory.Options;
+import android.drm.DrmHelper;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
-import android.text.TextUtils;
import android.text.TextUtils;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
@@ -47,7 +37,6 @@ import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
-import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaDetails;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -74,20 +63,12 @@ import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.MediaSetUtils;
import java.util.Locale;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Random;
-
public class AlbumPage extends ActivityState implements GalleryActionBar.ClusterRunner,
SelectionManager.SelectionListener, MediaSet.SyncListener, GalleryActionBar.OnAlbumModeSelectedListener {
@SuppressWarnings("unused")
private static final String TAG = "AlbumPage";
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
-
public static final String KEY_MEDIA_PATH = "media-path";
public static final String KEY_PARENT_MEDIA_PATH = "parent-media-path";
public static final String KEY_SET_CENTER = "set-center";
@@ -121,8 +102,7 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
private boolean mGetContent;
private boolean mShowClusterMenu;
- private boolean mIsWallpaper;
- private boolean mIsContactPhoto;
+
private ActionModeHandler mActionModeHandler;
private int mFocusIndex = 0;
private DetailsHelper mDetailsHelper;
@@ -331,6 +311,12 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
if (isLayoutRtl && item == null) {
return; // Item not ready yet, ignore the click
}
+ if (DrmHelper.isDrmFile(DrmHelper.getFilePath(
+ mActivity.getAndroidContext(), item.getContentUri()))) {
+ Toast.makeText(mActivity, R.string.no_permission_for_drm,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
onGetContent(item);
} else if (mLaunchedFromPhotoPage) {
if (isLayoutRtl && item == null) {
@@ -343,65 +329,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
transitions.put(PhotoPage.KEY_INDEX_HINT, slotIndex);
onBackPressed();
} else {
- Context context = (Context) mActivity;
- Uri uri = item.getContentUri();
- Log.d(TAG, "pickPhoto:uri=" + item.getContentUri());
- String path = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- path = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = context.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- path = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.d(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- Log.d(TAG, "pickPhoto:path = " + path);
- if (path != null && (path.endsWith(".dcf") || path.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(context);
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- int status = -1;
- Log.d(TAG, "pickPhoto:item type = " + Integer.toString(item.getMediaType()));
-
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- status = drmClient.checkRightsStatus(path, Action.DISPLAY);
- } else {
- status = drmClient.checkRightsStatus(path, Action.PLAY);
- }
- Log.d(TAG, "pickPhoto:status fron drmClient.checkRightsStatus is "
- + Integer.toString(status));
-
- ContentValues values = drmClient.getMetadata(path);
- if (RightsStatus.RIGHTS_VALID!= status) {
- String address = values.getAsString("Rights-Issuer");
- Log.d(TAG, "pickPhoto:address = " + address);
- Intent intent = new Intent(BUY_LICENSE);
- intent.putExtra("DRM_FILE_PATH", address);
- context.sendBroadcast(intent);
- return;
- }
-
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "onSingleTapUp:drm-type = " + Integer.toString(drmType));
- if (drmType > DrmDeliveryType.FORWARD_LOCK) {
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- item.setConsumeRights(true);
- }
- Toast.makeText(context, R.string.action_consumes_rights,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- }
-
// Get into the PhotoPage.
// mAlbumView.savePositions(PositionRepository.getInstance(mActivity));
Bundle data = new Bundle();
@@ -435,7 +362,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
Activity activity = mActivity;
if (mData.getString(GalleryActivity.EXTRA_CROP) != null) {
Uri uri = dm.getContentUri(item.getPath());
-
Intent intent = new Intent(CropActivity.CROP_ACTION, uri)
.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.putExtras(getData());
@@ -444,29 +370,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
}
activity.startActivity(intent);
activity.finish();
- } else if (mIsWallpaper != true && mIsContactPhoto != true) {
- String path = null;
- if (item instanceof LocalMediaItem) {
- path = ((LocalMediaItem)item).filePath;
- }
- if (path != null && (path.endsWith(".dcf") || path.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper((Context) mActivity);
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- ContentValues values = drmClient.getMetadata(path);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "onGetContent:DRM-TYPE = " + Integer.toString(drmType));
- if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) {
- activity.setResult(Activity.RESULT_OK, new Intent(null, item.getContentUri()));
- } else {
- Toast.makeText((Context) mActivity, R.string.no_permission_for_drm,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- } else {
- activity.setResult(Activity.RESULT_OK,
- new Intent(null, item.getContentUri()));
- }
- activity.finish();
} else {
Intent intent = new Intent(null, item.getContentUri())
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@@ -509,8 +412,6 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
initializeViews();
initializeData(data);
mGetContent = data.getBoolean(GalleryActivity.KEY_GET_CONTENT, false);
- mIsWallpaper = data.getBoolean("com.android.gallery3d.IsWallpaper", false);
- mIsContactPhoto = data.getBoolean("isContactPhoto", false);
mShowClusterMenu = data.getBoolean(KEY_SHOW_CLUSTER_MENU, false);
mDetailsSource = new MyDetailsSource();
Context context = mActivity.getAndroidContext();
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index 288472793..a08b77b1b 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -21,21 +21,12 @@ package com.android.gallery3d.app;
import android.app.Activity;
import android.content.Context;
-import android.content.ContentValues;
import android.content.Intent;
-import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmRights;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
import android.graphics.Rect;
import android.net.Uri;
-import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
-import android.provider.MediaStore.Video.VideoColumns;
import android.view.HapticFeedbackConstants;
import android.view.Menu;
import android.view.MenuInflater;
@@ -72,13 +63,8 @@ import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.HelpUtils;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
-import java.util.Random;
public class AlbumSetPage extends ActivityState implements
SelectionManager.SelectionListener, GalleryActionBar.ClusterRunner,
@@ -88,8 +74,6 @@ public class AlbumSetPage extends ActivityState implements
private static final int MSG_PICK_ALBUM = 1;
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
-
public static final String KEY_MEDIA_PATH = "media-path";
public static final String KEY_SET_TITLE = "set-title";
public static final String KEY_SET_SUBTITLE = "set-subtitle";
@@ -258,69 +242,6 @@ public class AlbumSetPage extends ActivityState implements
if (!mIsActive) return;
MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex);
- if (targetSet.getTotalMediaItemCount() == 1) {
- MediaItem item = null;
- item = targetSet.getCoverMediaItem();
- Uri uri = item.getContentUri();
- Context context = (Context) mActivity;
-
- Log.d(TAG, "pickAlbum:uri=" + item.getContentUri());
- String path = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- path = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = context.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- path = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- Log.d(TAG, "pickAlbum:path = " + path);
- if (path != null && (path.endsWith(".dcf") || path.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(context);
- int status = -1;
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- Log.d(TAG, "pickAlbum:item type = " + Integer.toString(item.getMediaType()));
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- status = drmClient.checkRightsStatus(path, Action.DISPLAY);
- } else {
- status = drmClient.checkRightsStatus(path, Action.PLAY);
- }
- Log.d(TAG, "pickAlbum:status fron drmClient.checkRightsStatus is "
- + Integer.toString(status));
-
- ContentValues values = drmClient.getMetadata(path);
-
- if (RightsStatus.RIGHTS_VALID != status) {
- String address = values.getAsString("Rights-Issuer");
- Log.d(TAG, "pickAlbum:address = " + address);
- Intent intent = new Intent(BUY_LICENSE);
- intent.putExtra("DRM_FILE_PATH", address);
- context.sendBroadcast(intent);
- return;
- }
-
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "pickAlbum:drm-type = " + Integer.toString(drmType));
- if (drmType > DrmDeliveryType.FORWARD_LOCK) {
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- item.setConsumeRights(true);
- }
- Toast.makeText(context, R.string.action_consumes_rights,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- }
- }
if (targetSet == null) return; // Content is dirty, we shall reload soon
if (targetSet.getTotalMediaItemCount() == 0) {
showEmptyAlbumToast(Toast.LENGTH_SHORT);
diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java
index d918e1457..c1c6148ad 100644
--- a/src/com/android/gallery3d/app/GalleryActivity.java
+++ b/src/com/android/gallery3d/app/GalleryActivity.java
@@ -18,38 +18,30 @@ package com.android.gallery3d.app;
import android.app.Dialog;
import android.content.ContentResolver;
-import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
-import android.database.Cursor;
-import android.drm.DrmManagerClient;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
import android.net.Uri;
import android.os.Bundle;
-import android.provider.MediaStore.Video.VideoColumns;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
+import android.text.TextUtils;
+import java.util.Locale;
import com.android.gallery3d.R;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
-import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.picasasource.PicasaSource;
import com.android.gallery3d.util.GalleryUtils;
public final class GalleryActivity extends AbstractGalleryActivity implements OnCancelListener {
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
public static final String EXTRA_SLIDESHOW = "slideshow";
public static final String EXTRA_DREAM = "dream";
public static final String EXTRA_CROP = "crop";
@@ -61,6 +53,7 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
public static final String KEY_MEDIA_TYPES = "mediaTypes";
public static final String KEY_DISMISS_KEYGUARD = "dismiss-keyguard";
public static final String KEY_FROM_SNAPCAM = "from-snapcam";
+ public static final String KEY_TOTAL_NUMBER = "total-number";
private static final String TAG = "GalleryActivity";
private Dialog mVersionCheckDialog;
@@ -213,82 +206,19 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On
startDefaultPage();
}
} else {
- Path itemPath = null;
- String imagePath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- imagePath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = this.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- imagePath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.d(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
- String mime_Type = intent.getType();
- if (imagePath != null
- && (imagePath.endsWith(".dcf") || imagePath.endsWith(".dm"))
- && "*/*".equals(mime_Type)) {
- imagePath = imagePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- DrmManagerClient drmClient = new DrmManagerClient(this);
- mime_Type = drmClient.getOriginalMimeType(imagePath);
- if (drmClient != null) drmClient.release();
- }
-
- Log.d(TAG, "DRM mime_Type==" + mime_Type);
- itemPath = getDataManager().findPathByUri(uri, mime_Type);
- Log.d(TAG, "itemPath=" + itemPath);
- // If item path not correct, just finish starting the gallery
- if (itemPath == null) {
- finish();
- return;
- }
-
- Log.d(TAG,"imagePath=" + imagePath);
- if (intent.getBooleanExtra("WidgetClick", false) == true) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(this);
- int status = drmClient.checkRightsStatus(imagePath, Action.DISPLAY);
- if (RightsStatus.RIGHTS_VALID != status) {
- ContentValues values = drmClient.getMetadata(imagePath);
- String address = values.getAsString("Rights-Issuer");
- Intent buyIntent = new Intent(BUY_LICENSE);
- buyIntent.putExtra("DRM_FILE_PATH", address);
- sendBroadcast(buyIntent);
- Log.d(TAG, "startViewAction:WidgetClick, intent sent");
- }
- if (drmClient != null) drmClient.release();
- }
-
- if (imagePath != null
- && (imagePath.endsWith(".dcf") || imagePath.endsWith(".dm"))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(this);
- imagePath = imagePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- ContentValues values = drmClient.getMetadata(imagePath);
- int drmType = values.getAsInteger("DRM-TYPE");
- if (drmType > DrmDeliveryType.FORWARD_LOCK) {
- MediaItem mediaItem = (MediaItem) getDataManager()
- .getMediaObject(itemPath);
- if (mediaItem.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE) {
- mediaItem.setConsumeRights(true);
- }
- Toast.makeText(this, R.string.action_consumes_rights,
- Toast.LENGTH_LONG).show();
- }
- if (drmClient != null) drmClient.release();
- }
-
+ Path itemPath = dm.findPathByUri(uri, contentType);
Path albumPath = dm.getDefaultSetOf(itemPath);
data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString());
if (!intent.getBooleanExtra(KEY_FROM_SNAPCAM, false)) {
data.putBoolean(PhotoPage.KEY_READONLY, true);
+ } else {
+ int hintIndex = 0;
+ if (View.LAYOUT_DIRECTION_RTL == TextUtils
+ .getLayoutDirectionFromLocale(Locale.getDefault())) {
+ hintIndex = intent.getIntExtra(KEY_TOTAL_NUMBER, 1) - 1;
+ }
+ data.putInt(PhotoPage.KEY_INDEX_HINT, hintIndex);
}
// TODO: Make the parameter "SingleItemOnly" public so other
diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java
index 0b0341ad1..9be74f4a5 100644
--- a/src/com/android/gallery3d/app/MovieActivity.java
+++ b/src/com/android/gallery3d/app/MovieActivity.java
@@ -27,9 +27,6 @@ import android.bluetooth.BluetoothDevice;
import android.content.AsyncQueryHandler;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.DialogInterface;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -38,8 +35,7 @@ import android.content.res.Configuration;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.DrmDeliveryType;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager;
@@ -53,7 +49,6 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
import android.provider.OpenableColumns;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -245,6 +240,16 @@ public class MovieActivity extends Activity {
initEffects(mp.getAudioSessionId());
}
});
+
+ // DRM validation
+ Uri original = intent.getData();
+ String mimeType = intent.getType();
+ String filepath = DrmHelper.getFilePath(this, original);
+ if (DrmHelper.isDrmFile(filepath)) {
+ if (!DrmHelper.validateLicense(this, filepath, mimeType)) {
+ finish();
+ }
+ }
}
private void setActionBarLogoFromIntent(Intent intent) {
@@ -312,36 +317,6 @@ public class MovieActivity extends Activity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
- String path = null;
- String scheme = mUri.getScheme();
- if ("file".equals(scheme)) {
- path = mUri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = getContentResolver().query(mUri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- path = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.d(TAG, "cannot get path from: " + mUri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
- Log.d(TAG, "onCreateOptionsMenu= " + path);
- if ((path != null) && ((path.endsWith(".dcf") || path.endsWith(".dm")))) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(this);
- ContentValues values = drmClient.getMetadata(path);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "onCreateOptionsMenu:DRM-TYPE = " + Integer.toString(drmType));
- if (drmType != DrmDeliveryType.SEPARATE_DELIVERY) {
- return true;
- }
- if (drmClient != null) drmClient.release();
- }
-
getMenuInflater().inflate(R.menu.movie, menu);
MenuItem shareMenu = menu.findItem(R.id.action_share);
ShareActionProvider provider = (ShareActionProvider) shareMenu.getActionProvider();
@@ -563,7 +538,7 @@ public class MovieActivity extends Activity {
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
super.onStart();
mMovieHooker.onStart();
- registerScreenOff();
+ registerScreenReceiver();
}
@Override
@@ -576,7 +551,7 @@ public class MovieActivity extends Activity {
mControlResumed = false;
}
mMovieHooker.onStop();
- unregisterScreenOff();
+ unregisterScreenReceiver();
}
@Override
@@ -697,7 +672,7 @@ public class MovieActivity extends Activity {
}
// we do not stop live streaming when other dialog overlays it.
- private BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
+ private BroadcastReceiver mScreenReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -711,19 +686,25 @@ public class MovieActivity extends Activity {
mPlayer.onStop();
mControlResumed = false;
}
+ } else if (Intent.ACTION_USER_PRESENT.equals(intent.getAction())) {
+ if (!mControlResumed) {
+ mPlayer.onResume();
+ mControlResumed = true;
+ }
}
}
};
- private void registerScreenOff() {
+ private void registerScreenReceiver() {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
- registerReceiver(mScreenOffReceiver, filter);
+ filter.addAction(Intent.ACTION_USER_PRESENT);
+ registerReceiver(mScreenReceiver, filter);
}
- private void unregisterScreenOff() {
- unregisterReceiver(mScreenOffReceiver);
+ private void unregisterScreenReceiver() {
+ unregisterReceiver(mScreenReceiver);
}
private boolean isKeyguardLocked() {
diff --git a/src/com/android/gallery3d/app/MovieControllerOverlay.java b/src/com/android/gallery3d/app/MovieControllerOverlay.java
index bb25882c8..168cbe102 100644
--- a/src/com/android/gallery3d/app/MovieControllerOverlay.java
+++ b/src/com/android/gallery3d/app/MovieControllerOverlay.java
@@ -22,6 +22,7 @@ import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Handler;
+import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -50,6 +51,7 @@ import org.codeaurora.gallery3d.video.ExtensionHelper;
import org.codeaurora.gallery3d.video.ScreenModeManager;
import org.codeaurora.gallery3d.video.ScreenModeManager.ScreenModeListener;
+import java.util.Locale;
/**
* The playback controller for the Movie Player.
@@ -840,10 +842,20 @@ public class MovieControllerOverlay extends CommonControllerOverlay implements
mListenerForRewind.onStopVideo();
} else if (v == mRewind) {
Log.v(TAG, "ControllerRewindAndForwardExt onClick mRewind");
- mListenerForRewind.onRewind();
+ if (TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())
+ == View.LAYOUT_DIRECTION_RTL) {
+ mListenerForRewind.onForward();
+ } else {
+ mListenerForRewind.onRewind();
+ }
} else if (v == mForward) {
Log.v(TAG, "ControllerRewindAndForwardExt onClick mForward");
- mListenerForRewind.onForward();
+ if (TextUtils.getLayoutDirectionFromLocale(Locale.getDefault())
+ == View.LAYOUT_DIRECTION_RTL) {
+ mListenerForRewind.onRewind();
+ } else {
+ mListenerForRewind.onForward();
+ }
}
}
diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java
index 4c0df84cc..c52c4b0f9 100755
--- a/src/com/android/gallery3d/app/MoviePlayer.java
+++ b/src/com/android/gallery3d/app/MoviePlayer.java
@@ -470,8 +470,6 @@ public class MoviePlayer implements
mVideoView.suspend();
mResumeableTime = System.currentTimeMillis() + RESUMEABLE_TIMEOUT;
mVideoView.setResumed(false);// avoid start after surface created
- // Workaround for last-seek frame difference
- mVideoView.setVisibility(View.INVISIBLE);
long end2 = System.currentTimeMillis();
// TODO comments by sunlei
mOverlayExt.clearBuffering();
@@ -637,6 +635,7 @@ public class MoviePlayer implements
}
mTState = TState.PAUSED;
mVideoView.pause();
+ setProgress();
mController.showPaused();
}
@@ -1356,6 +1355,12 @@ public class MoviePlayer implements
}
})
+ .setOnCancelListener(new OnCancelListener() {
+ public void onCancel(DialogInterface dialog) {
+ mController.showEnded();
+ onCompletion();
+ }
+ })
.create();
mServerTimeoutDialog.setOnDismissListener(new OnDismissListener() {
@@ -1363,6 +1368,7 @@ public class MoviePlayer implements
if (LOG) {
Log.v(TAG, "mServerTimeoutDialog.onDismiss()");
}
+ mVideoView.setDialogShowState(false);
mIsShowDialog = false;
}
@@ -1373,6 +1379,7 @@ public class MoviePlayer implements
if (LOG) {
Log.v(TAG, "mServerTimeoutDialog.onShow()");
}
+ mVideoView.setDialogShowState(true);
mIsShowDialog = true;
}
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index c7dd48b1e..3ab948772 100755
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -522,9 +522,9 @@ public class PhotoDataAdapter implements PhotoPage.Model {
@Override
public boolean isVideo(int offset) {
MediaItem item = getItem(mCurrentIndex + offset);
- return (item == null)
- ? false
- : item.getMediaType() == MediaItem.MEDIA_TYPE_VIDEO;
+ return (item == null) ? false
+ : item.getMediaType() == MediaItem.MEDIA_TYPE_VIDEO
+ || item.getMediaType() == MediaItem.MEDIA_TYPE_DRM_VIDEO;
}
@Override
@@ -1208,12 +1208,6 @@ public class PhotoDataAdapter implements PhotoPage.Model {
}
public synchronized void notifyDirty() {
- while (mDirty) {
- try {
- wait(NOTIFY_DIRTY_WAIT_TIME);
- } catch (Exception ex) {
- }
- }
mDirty = true;
notifyAll();
}
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 7bc9c9d4f..65c26278a 100755
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -20,18 +20,11 @@ import android.annotation.TargetApi;
import android.app.ActionBar.OnMenuVisibilityListener;
import android.app.Activity;
import android.content.ActivityNotFoundException;
-import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
-import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.DrmDeliveryType;
-import android.drm.DrmStore.RightsStatus;
-import android.graphics.BitmapFactory;
-import android.graphics.BitmapFactory.Options;
+import android.drm.DrmHelper;
import android.graphics.Rect;
import android.media.MediaFile;
import android.net.Uri;
@@ -42,8 +35,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
-import android.provider.MediaStore;
-import android.provider.MediaStore.Video.VideoColumns;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
@@ -54,7 +45,6 @@ import android.widget.Toast;
import com.android.gallery3d.R;
import com.android.gallery3d.common.ApiHelper;
-import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.ComboAlbum;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.FilterDeleteSet;
@@ -87,11 +77,6 @@ import com.android.gallery3d.util.GalleryUtils;
import com.android.gallery3d.util.UsageStatistics;
import com.android.gallery3d.util.ViewGifImage;
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.IOException;
-
import java.util.ArrayList;
import java.util.Locale;
@@ -100,8 +85,6 @@ public abstract class PhotoPage extends ActivityState implements
PhotoPageBottomControls.Delegate, GalleryActionBar.OnAlbumModeSelectedListener {
private static final String TAG = "PhotoPage";
- public static final String BUY_LICENSE = "android.drmservice.intent.action.BUY_LICENSE";
-
private static final int MSG_HIDE_BARS = 1;
private static final int MSG_ON_FULL_SCREEN_CHANGED = 4;
private static final int MSG_UPDATE_ACTION_BAR = 5;
@@ -590,16 +573,6 @@ public abstract class PhotoPage extends ActivityState implements
PhotoPage.this);
}
}
- MediaItem item = mModel.getMediaItem(0);
- if (item != null
- && item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE
- && item.getConsumeRights() == true) {
- Log.d(TAG, "onDestroy,consume rights = true");
- item.setConsumeRights(false);
- Uri uri = item.getContentUri();
- Log.d(TAG, "onDestroy:uri=" + uri);
- consumeRights(uri);
- }
}
@Override
@@ -639,40 +612,6 @@ public abstract class PhotoPage extends ActivityState implements
});
}
- private void consumeRights(Uri uri) {
- Log.d(TAG, "consumeRights:uri=" + uri);
- String filepath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- filepath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mActivity.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- filepath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
- Options options = new Options();
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(new File(filepath));
- FileDescriptor fd = fis.getFD();
- Log.d(TAG, "onLoadingFinished:calling decodeFileDescriptor with true");
- BitmapFactory.decodeFileDescriptor(fd, new Rect(), options, true);
- } catch(IOException e) {
- Log.w(TAG, "IOException");
- } finally {
- Utils.closeSilently(fis);
- }
- }
-
@Override
public void onPictureCenter(boolean isCamera) {
isCamera = isCamera || (mHasCameraScreennailOrPlaceholder && mAppBridge == null);
@@ -748,40 +687,6 @@ public abstract class PhotoPage extends ActivityState implements
private Intent createShareIntent(MediaObject mediaObject) {
int type = mediaObject.getMediaType();
- Uri uri = mediaObject.getContentUri();
- Log.d(TAG, "updateShareURI:uri:" + uri);
- String filepath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- filepath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mApplication.getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- filepath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- if (filepath != null && filepath.endsWith(".dcf")) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mActivity.getAndroidContext());
- filepath = filepath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- ContentValues values = drmClient.getMetadata(filepath);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "updateShareURI:drmType returned= " + Integer.toString(drmType)
- + " for path= " + filepath);
- if (drmType != DrmDeliveryType.SEPARATE_DELIVERY) {
- return null;
- }
- if (drmClient != null) drmClient.release();
- }
-
return new Intent(Intent.ACTION_SEND)
.setType(MenuExecutor.getMimeType(type))
.putExtra(Intent.EXTRA_STREAM, mediaObject.getContentUri())
@@ -899,6 +804,20 @@ public abstract class PhotoPage extends ActivityState implements
requestDeferredUpdate();
} else {
updateUIForCurrentPhoto();
+
+ // Manage DRM rights while image selection changed. this
+ // flow will comes for both image and video, but here
+ // we will consume rights for image files only.
+ // Do not consume rights of a GIF image and video here.
+ // ViewGifImage will take care of GIF rights consumption stub.
+ // MediaPlayer will handle the video rights consumption stub.
+ String mime = mCurrentPhoto.getMimeType();
+ if (!TextUtils.isEmpty(mime) && !mime.equals("image/gif")
+ && !mime.startsWith("video/")) {
+ DrmHelper.manageDrmLicense(mActivity.getAndroidContext(),
+ mHandler, mCurrentPhoto.getFilePath(),
+ mCurrentPhoto.getMimeType());
+ }
}
}
@@ -1255,32 +1174,10 @@ public abstract class PhotoPage extends ActivityState implements
mMenuExecutor.onMenuClicked(item, confirmMsg, mConfirmDialogListener);
return true;
case R.id.action_drm_info:
- Uri uri = manager.getContentUri(path);
- Log.d(TAG, "executeuri:" + uri);
- String filepath = null;
- String scheme = uri.getScheme();
- if ("file".equals(scheme)) {
- filepath = uri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mActivity.getAndroidContext().getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- filepath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
+ String filepath = current.getFilePath();
+ if (DrmHelper.isDrmFile(filepath)) {
+ DrmHelper.showDrmInfo(mActivity.getAndroidContext(), filepath);
}
- filepath = filepath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- Intent drmintent = new Intent("android.drmservice.intent.action.SHOW_PROPERTIES");
- drmintent.putExtra("DRM_FILE_PATH", filepath);
- drmintent.putExtra("DRM_TYPE", "OMAV1");
- Log.d(TAG,"-----filepath===" + path);
- mActivity.getAndroidContext().sendBroadcast(drmintent);
return true;
default :
return false;
@@ -1417,37 +1314,6 @@ public abstract class PhotoPage extends ActivityState implements
public void playVideo(Activity activity, Uri uri, String title) {
try {
- String scheme = uri.getScheme();
- Log.d(TAG, "playVideo:uri= " + uri);
- String path = null;
- if (scheme.equals("content")) {
- Cursor c = activity.getContentResolver().query(uri,
- new String[] { MediaStore.Images.ImageColumns.DATA }, null, null, null);
- if (c != null && c.getCount() > 0) {
- c.moveToFirst();
- path = c.getString(c.getColumnIndex(MediaStore.Images.ImageColumns.DATA));
- Log.d(TAG, "playVideo:path= " + path);
- }
- if (c != null) c.close();
- } else {
- path = uri.getPath();
- }
- if (path.endsWith(".dcf")) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(activity);
- path = path.replace("/storage/emulated/0", "/storage/emulated/legacy");
- int status = drmClient.checkRightsStatus(path, Action.PLAY);
- if (RightsStatus.RIGHTS_VALID != status) {
- ContentValues values = drmClient.getMetadata(path);
- String address = values.getAsString("Rights-Issuer");
- Log.d(TAG, "playVideo, address= " + address);
- Intent intent = new Intent(BUY_LICENSE);
- intent.putExtra("DRM_FILE_PATH", address);
- activity.sendBroadcast(intent);
- return;
- }
- if (drmClient != null) drmClient.release();
- }
-
Intent intent = new Intent(Intent.ACTION_VIEW)
.setDataAndType(uri, "video/*")
.putExtra(Intent.EXTRA_TITLE, title)
@@ -1552,17 +1418,6 @@ public abstract class PhotoPage extends ActivityState implements
@Override
public void onCurrentImageUpdated() {
- if (mSetPathString == null) {
- MediaItem item = mModel.getMediaItem(0);
- if (item.getMediaType() == MediaObject.MEDIA_TYPE_IMAGE
- && item.getConsumeRights() == true) {
- Log.d(TAG, "onCurrentImageUpdated,consume rights = true");
- item.setConsumeRights(false);
- Uri uri = item.getContentUri();
- Log.d(TAG, "onCurrentImageUpdated:uri=" + uri);
- consumeRights(uri);
- }
- }
mActivity.getGLRoot().unfreeze();
}
@@ -1590,6 +1445,23 @@ public abstract class PhotoPage extends ActivityState implements
UsageStatistics.onContentViewChanged(
UsageStatistics.COMPONENT_CAMERA, "Unknown"); // TODO
}
+
+ // Manage DRM rights while image selection changed. this
+ // flow will comes for both image and video, but here
+ // we will consume rights for image files only.
+ // Do not consume rights of a GIF image and video here.
+ // ViewGifImage will take care of GIF rights consumption stub.
+ // MediaPlayer will handle the video rights consumption stub.
+ if ((mMediaSet != null && mMediaSet.getMediaItemCount() > 1)
+ || !(this instanceof SinglePhotoPage)) {
+ String mime = mCurrentPhoto.getMimeType();
+ if (!TextUtils.isEmpty(mime) && !mime.equals("image/gif")
+ && !mime.startsWith("video/")) {
+ DrmHelper.manageDrmLicense(mActivity.getAndroidContext(),
+ mHandler, mCurrentPhoto.getFilePath(),
+ mCurrentPhoto.getMimeType());
+ }
+ }
}
}
@@ -1784,6 +1656,9 @@ public abstract class PhotoPage extends ActivityState implements
private static void viewAnimateGif(Activity activity, Uri uri) {
Intent intent = new Intent(ViewGifImage.VIEW_GIF_ACTION, uri);
+ if (DrmHelper.isDrmFile(uri.toString())) {
+ intent.setDataAndType(uri, "image/gif");
+ }
activity.startActivity(intent);
}
}
diff --git a/src/com/android/gallery3d/app/SlideshowPage.java b/src/com/android/gallery3d/app/SlideshowPage.java
index 174058dc8..2b15ab96e 100644
--- a/src/com/android/gallery3d/app/SlideshowPage.java
+++ b/src/com/android/gallery3d/app/SlideshowPage.java
@@ -16,8 +16,12 @@
package com.android.gallery3d.app;
+import java.util.ArrayList;
+import java.util.Random;
+
import android.app.Activity;
import android.content.Intent;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
@@ -38,9 +42,6 @@ import com.android.gallery3d.ui.SynchronizedHandler;
import com.android.gallery3d.util.Future;
import com.android.gallery3d.util.FutureListener;
-import java.util.ArrayList;
-import java.util.Random;
-
public class SlideshowPage extends ActivityState {
private static final String TAG = "SlideshowPage";
@@ -338,6 +339,15 @@ public class SlideshowPage extends ActivityState {
mData = mMediaSet.getMediaItem(index, DATA_SIZE);
mDataStart = index;
dataEnd = index + mData.size();
+
+ // Consume license once in each element of the slide-show
+ // This is a non-blocking loop operation
+ for (int i = 0; i < mData.size(); i++) {
+ String path = mData.get(i).getFilePath();
+ if (DrmHelper.isDrmFile(path)) {
+ DrmHelper.consumeDrmRights(path, "image/*");
+ }
+ }
}
return (index < mDataStart || index >= dataEnd) ? null : mData.get(index - mDataStart);
diff --git a/src/com/android/gallery3d/app/Wallpaper.java b/src/com/android/gallery3d/app/Wallpaper.java
index f9bbc1301..5c19d9016 100644
--- a/src/com/android/gallery3d/app/Wallpaper.java
+++ b/src/com/android/gallery3d/app/Wallpaper.java
@@ -97,7 +97,6 @@ public class Wallpaper extends Activity {
Intent request = new Intent(Intent.ACTION_GET_CONTENT)
.setClass(this, DialogPicker.class)
.setType(IMAGE_TYPE);
- request.putExtra("com.android.gallery3d.IsWallpaper", true);
startActivityForResult(request, STATE_PHOTO_PICKED);
return;
}
diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java
index b92e87712..fa709157d 100644
--- a/src/com/android/gallery3d/data/DecodeUtils.java
+++ b/src/com/android/gallery3d/data/DecodeUtils.java
@@ -85,7 +85,7 @@ public class DecodeUtils {
jc.setCancelListener(new DecodeCanceller(options));
setOptionsMutable(options);
return ensureGLCompatibleBitmap(
- BitmapFactory.decodeByteArray(bytes, offset, length, options, false));
+ BitmapFactory.decodeByteArray(bytes, offset, length, options));
}
public static void decodeBounds(JobContext jc, byte[] bytes, int offset,
@@ -93,7 +93,7 @@ public class DecodeUtils {
Utils.assertTrue(options != null);
options.inJustDecodeBounds = true;
jc.setCancelListener(new DecodeCanceller(options));
- BitmapFactory.decodeByteArray(bytes, offset, length, options, false);
+ BitmapFactory.decodeByteArray(bytes, offset, length, options);
options.inJustDecodeBounds = false;
}
@@ -118,7 +118,7 @@ public class DecodeUtils {
jc.setCancelListener(new DecodeCanceller(options));
options.inJustDecodeBounds = true;
- BitmapFactory.decodeFileDescriptor(fd, null, options, false);
+ BitmapFactory.decodeFileDescriptor(fd, null, options);
if (jc.isCancelled()) return null;
int w = options.outWidth;
@@ -146,7 +146,7 @@ public class DecodeUtils {
options.inJustDecodeBounds = false;
setOptionsMutable(options);
- Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options, false);
+ Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options);
if (result == null) return null;
// We need to resize down if the decoder does not support inSampleSize
@@ -172,7 +172,7 @@ public class DecodeUtils {
jc.setCancelListener(new DecodeCanceller(options));
options.inJustDecodeBounds = true;
- BitmapFactory.decodeByteArray(data, 0, data.length, options, false);
+ BitmapFactory.decodeByteArray(data, 0, data.length, options);
if (jc.isCancelled()) return null;
if (options.outWidth < targetSize || options.outHeight < targetSize) {
return null;
@@ -182,16 +182,8 @@ public class DecodeUtils {
options.inJustDecodeBounds = false;
setOptionsMutable(options);
- Bitmap bitmap = null;
-
- try {
- bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options, false);
-
- } catch (OutOfMemoryError ex) {
- bitmap = null;
- Log.e(TAG, "OutOfMemoryError : image is too large");
- }
- return ensureGLCompatibleBitmap(bitmap);
+ return ensureGLCompatibleBitmap(
+ BitmapFactory.decodeByteArray(data, 0, data.length, options));
}
// TODO: This function should not be called directly from
diff --git a/src/com/android/gallery3d/data/FaceClustering.java b/src/com/android/gallery3d/data/FaceClustering.java
index 819915edb..a0d567902 100644..100755
--- a/src/com/android/gallery3d/data/FaceClustering.java
+++ b/src/com/android/gallery3d/data/FaceClustering.java
@@ -83,7 +83,7 @@ public class FaceClustering extends Clustering {
}
public FaceClustering(Context context) {
- mUntaggedString = context.getResources().getString(R.string.untagged);
+ mUntaggedString = context.getResources().getString(R.string.no_faces);
mContext = context;
}
diff --git a/src/com/android/gallery3d/data/FilterTypeSet.java b/src/com/android/gallery3d/data/FilterTypeSet.java
index 477ef73ad..e778ceb12 100644
--- a/src/com/android/gallery3d/data/FilterTypeSet.java
+++ b/src/com/android/gallery3d/data/FilterTypeSet.java
@@ -102,7 +102,8 @@ public class FilterTypeSet extends MediaSet implements ContentListener {
mBaseSet.enumerateMediaItems(new MediaSet.ItemConsumer() {
@Override
public void consume(int index, MediaItem item) {
- if (item.getMediaType() == mMediaType) {
+ if (item.getMediaType() == mMediaType
+ || item.getMediaType() == MediaObject.MEDIA_TYPE_DRM_IMAGE) {
if (index < 0 || index >= total) return;
Path path = item.getPath();
buf[index] = path;
diff --git a/src/com/android/gallery3d/data/ImageCacheRequest.java b/src/com/android/gallery3d/data/ImageCacheRequest.java
index 8fb418dd7..faca5d7d8 100644
--- a/src/com/android/gallery3d/data/ImageCacheRequest.java
+++ b/src/com/android/gallery3d/data/ImageCacheRequest.java
@@ -16,11 +16,10 @@
package com.android.gallery3d.data;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.Action;
-import android.drm.DrmStore.RightsStatus;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.text.TextUtils;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.common.BitmapUtils;
@@ -40,16 +39,22 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
private long mTimeModified;
public ImageCacheRequest(GalleryApp application,
- Path path, long timeModified, int type, int targetSize, String filePath, String mimetype) {
+ Path path, long timeModified, int type, int targetSize) {
mApplication = application;
mPath = path;
mType = type;
mTargetSize = targetSize;
- mFilePath = filePath;
- mMimeType = mimetype;
mTimeModified = timeModified;
}
+ public ImageCacheRequest(GalleryApp application,
+ Path path, long timeModified, int type, int targetSize, String filepath, String mimeType) {
+ this(application, path, timeModified, type,
+ targetSize);
+ mFilePath = filepath;
+ mMimeType = mimeType;
+ }
+
private String debugTag() {
return mPath + "," + mTimeModified + "," +
((mType == MediaItem.TYPE_THUMBNAIL) ? "THUMB" :
@@ -58,28 +63,16 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
@Override
public Bitmap run(JobContext jc) {
- ImageCacheService cacheService = mApplication.getImageCacheService();
-
- if (mFilePath != null && mFilePath.endsWith(".dcf")) {
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext());
- mFilePath = mFilePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- int statusDisplay = drmClient.checkRightsStatus(mFilePath, Action.DISPLAY);
- int statusPlay = drmClient.checkRightsStatus(mFilePath, Action.PLAY);
- if (mMimeType == null) {
- if ((RightsStatus.RIGHTS_VALID != statusDisplay)
- && (RightsStatus.RIGHTS_VALID != statusPlay)) {
- return null;
- }
- } else if (mMimeType.startsWith("video/")
- && RightsStatus.RIGHTS_VALID != statusPlay) {
- return null;
- } else if (mMimeType.startsWith("image/")
- && RightsStatus.RIGHTS_VALID != statusDisplay) {
- return null;
+ if (!TextUtils.isEmpty(mFilePath) && !TextUtils.isEmpty(mMimeType)
+ && !mMimeType.startsWith("video/")) {
+ if (DrmHelper.isDrmFile(mFilePath)
+ && mType != MediaItem.TYPE_MICROTHUMBNAIL) {
+ return onDecodeOriginal(jc, mType);
}
- if (drmClient != null) drmClient.release();
}
+ ImageCacheService cacheService = mApplication.getImageCacheService();
+
BytesBuffer buffer = MediaItem.getBytesBufferPool().get();
try {
boolean found = cacheService.getImageData(mPath, mTimeModified, mType, buffer);
@@ -103,6 +96,7 @@ abstract class ImageCacheRequest implements Job<Bitmap> {
} finally {
MediaItem.getBytesBufferPool().recycle(buffer);
}
+
Bitmap bitmap = onDecodeOriginal(jc, mType);
if (jc.isCancelled()) return null;
diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java
index 96ab3e3a1..1b0384548 100644
--- a/src/com/android/gallery3d/data/LocalImage.java
+++ b/src/com/android/gallery3d/data/LocalImage.java
@@ -20,8 +20,7 @@ import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.DrmDeliveryType;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
@@ -182,9 +181,16 @@ public class LocalImage extends LocalMediaItem {
private String mLocalFilePath;
LocalImageRequest(GalleryApp application, Path path, long timeModified,
- int type, String localFilePath, String mimetype) {
+ int type, String localFilePath) {
super(application, path, timeModified, type,
- MediaItem.getTargetSize(type), localFilePath, mimetype);
+ MediaItem.getTargetSize(type));
+ mLocalFilePath = localFilePath;
+ }
+
+ LocalImageRequest(GalleryApp application, Path path, long timeModified,
+ int type, String localFilePath, String mimeType) {
+ super(application, path, timeModified, type,
+ MediaItem.getTargetSize(type),localFilePath, mimeType);
mLocalFilePath = localFilePath;
}
@@ -192,6 +198,12 @@ public class LocalImage extends LocalMediaItem {
public Bitmap onDecodeOriginal(JobContext jc, final int type) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+
+ if (DrmHelper.isDrmFile(mLocalFilePath)) {
+ return DecodeUtils.ensureGLCompatibleBitmap(DrmHelper
+ .getBitmap(mLocalFilePath, options));
+ }
+
int targetSize = MediaItem.getTargetSize(type);
// try to decode from JPEG EXIF
@@ -232,38 +244,41 @@ public class LocalImage extends LocalMediaItem {
@Override
public BitmapRegionDecoder run(JobContext jc) {
+ if (DrmHelper.isDrmFile(mLocalFilePath)) {
+ return DrmHelper.createBitmapRegionDecoder(mLocalFilePath,
+ false);
+ }
+
return DecodeUtils.createBitmapRegionDecoder(jc, mLocalFilePath, false);
}
}
@Override
public int getSupportedOperations() {
- int operation = SUPPORT_DELETE | SUPPORT_SETAS | SUPPORT_INFO;
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- filePath = filePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- operation |= SUPPORT_DRM_INFO;
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext());
- ContentValues values = drmClient.getMetadata(filePath);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "getSupportedOperations:drmType returned= "
- + Integer.toString(drmType) + " for path= " + filePath);
- if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) {
+ int operation = SUPPORT_DELETE | SUPPORT_INFO;
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ if (DrmHelper.isDrmFLBlocking(mApplication.getAndroidContext(),
+ getFilePath())) {
+ operation |= SUPPORT_SETAS;
+ }
+ operation |= SUPPORT_DRM_INFO | SUPPORT_FULL_IMAGE;
+ if (DrmHelper.isShareableDrmFile(getFilePath())) {
operation |= SUPPORT_SHARE;
}
- if (drmClient != null) drmClient.release();
} else {
- operation |= SUPPORT_SHARE | SUPPORT_EDIT | SUPPORT_CROP | SUPPORT_PRINT;
- }
- if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
- operation |= SUPPORT_FULL_IMAGE;
- }
+ operation = SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_CROP
+ | SUPPORT_SETAS | SUPPORT_PRINT | SUPPORT_INFO;
+ if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) {
+ operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT;
+ }
- if (BitmapUtils.isRotationSupported(mimeType)) {
- operation |= SUPPORT_ROTATE;
- }
+ if (BitmapUtils.isRotationSupported(mimeType)) {
+ operation |= SUPPORT_ROTATE;
+ }
- if (GalleryUtils.isValidLocation(latitude, longitude)) {
- operation |= SUPPORT_SHOW_ON_MAP;
+ if (GalleryUtils.isValidLocation(latitude, longitude)) {
+ operation |= SUPPORT_SHOW_ON_MAP;
+ }
}
return operation;
}
@@ -329,6 +344,10 @@ public class LocalImage extends LocalMediaItem {
@Override
public int getMediaType() {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return MEDIA_TYPE_DRM_IMAGE;
+ }
+
return MEDIA_TYPE_IMAGE;
}
@@ -363,14 +382,4 @@ public class LocalImage extends LocalMediaItem {
public String getFilePath() {
return filePath;
}
-
- @Override
- public void setConsumeRights(boolean flag) {
- consumeRights = flag;
- }
-
- @Override
- public boolean getConsumeRights() {
- return consumeRights;
- }
}
diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java
index 12b3c7acd..7fafe97ae 100644
--- a/src/com/android/gallery3d/data/LocalVideo.java
+++ b/src/com/android/gallery3d/data/LocalVideo.java
@@ -17,10 +17,8 @@
package com.android.gallery3d.data;
import android.content.ContentResolver;
-import android.content.ContentValues;
import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.DrmDeliveryType;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapRegionDecoder;
import android.net.Uri;
@@ -155,18 +153,24 @@ public class LocalVideo extends LocalMediaItem {
@Override
public Job<Bitmap> requestImage(int type) {
- // Drm start
- return new LocalVideoRequest(mApplication, getPath(), dateModifiedInSec,type, filePath, mimeType);
- // Drm end
+ return new LocalVideoRequest(mApplication, getPath(), dateModifiedInSec,
+ type, filePath, mimeType);
}
public static class LocalVideoRequest extends ImageCacheRequest {
private String mLocalFilePath;
LocalVideoRequest(GalleryApp application, Path path, long timeModified,
- int type, String localFilePath, String mimetype) {
+ int type, String localFilePath) {
super(application, path, timeModified, type,
- MediaItem.getTargetSize(type),localFilePath, mimetype);
+ MediaItem.getTargetSize(type));
+ mLocalFilePath = localFilePath;
+ }
+
+ LocalVideoRequest(GalleryApp application, Path path, long timeModified,
+ int type, String localFilePath, String mimeType) {
+ super(application, path, timeModified, type,
+ MediaItem.getTargetSize(type), localFilePath, mimeType);
mLocalFilePath = localFilePath;
}
@@ -186,24 +190,17 @@ public class LocalVideo extends LocalMediaItem {
@Override
public int getSupportedOperations() {
- int supported = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO;
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- supported |= SUPPORT_DRM_INFO;
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext());
- ContentValues values = drmClient.getMetadata(filePath);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d("LocalVideo", "getSupportedOperations:drmType returned= "
- + Integer.toString(drmType) + " for path= " + filePath);
- if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) {
- supported |= SUPPORT_SHARE;
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ int operation = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO
+ | SUPPORT_DRM_INFO;
+ if (DrmHelper.isShareableDrmFile(getFilePath())) {
+ operation |= SUPPORT_SHARE;
}
- if (drmClient != null) drmClient.release();
- } else {
- Log.e("LocalVideo", "yy:share added for path= " + filePath);
- supported |= SUPPORT_SHARE;
+ return operation;
}
- return supported;
+ return SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_PLAY | SUPPORT_INFO
+ | SUPPORT_TRIM | SUPPORT_MUTE;
}
@Override
@@ -232,6 +229,10 @@ public class LocalVideo extends LocalMediaItem {
@Override
public int getMediaType() {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return MEDIA_TYPE_DRM_VIDEO;
+ }
+
return MEDIA_TYPE_VIDEO;
}
diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java
index 68a58ea70..6e3867647 100644
--- a/src/com/android/gallery3d/data/MediaObject.java
+++ b/src/com/android/gallery3d/data/MediaObject.java
@@ -69,7 +69,7 @@ public abstract class MediaObject {
public static final int CACHE_STATUS_CACHED_FULL = 3;
private static long sVersionSerial = 0;
- protected boolean consumeRights = false;
+
protected long mDataVersion;
protected final Path mPath;
@@ -148,14 +148,6 @@ public abstract class MediaObject {
throw new UnsupportedOperationException();
}
- public void setConsumeRights(boolean flag) {
- throw new UnsupportedOperationException();
- }
-
- public boolean getConsumeRights() {
- throw new UnsupportedOperationException();
- }
-
public static synchronized long nextVersionNumber() {
return ++MediaObject.sVersionSerial;
}
diff --git a/src/com/android/gallery3d/data/UriImage.java b/src/com/android/gallery3d/data/UriImage.java
index b9a12e7b7..13176e4aa 100644
--- a/src/com/android/gallery3d/data/UriImage.java
+++ b/src/com/android/gallery3d/data/UriImage.java
@@ -17,17 +17,13 @@
package com.android.gallery3d.data;
import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.drm.DrmManagerClientWrapper;
-import android.drm.DrmStore.DrmDeliveryType;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory.Options;
import android.graphics.BitmapRegionDecoder;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
-import android.provider.MediaStore.Video.VideoColumns;
import com.android.gallery3d.app.GalleryApp;
import com.android.gallery3d.app.PanoramaMetadataSupport;
@@ -63,12 +59,14 @@ public class UriImage extends MediaItem {
private PanoramaMetadataSupport mPanoramaMetadata = new PanoramaMetadataSupport(this);
private GalleryApp mApplication;
+ private String mFilePath;
public UriImage(GalleryApp application, Path path, Uri uri, String contentType) {
super(path, nextVersionNumber());
mUri = uri;
mApplication = Utils.checkNotNull(application);
mContentType = contentType;
+ mFilePath = DrmHelper.getFilePath(mApplication.getAndroidContext(), uri);
}
@Override
@@ -176,6 +174,14 @@ public class UriImage extends MediaItem {
private class RegionDecoderJob implements Job<BitmapRegionDecoder> {
@Override
public BitmapRegionDecoder run(JobContext jc) {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ BitmapRegionDecoder decoder = DrmHelper
+ .createBitmapRegionDecoder(getFilePath(), false);
+ mWidth = decoder.getWidth();
+ mHeight = decoder.getHeight();
+ return decoder;
+ }
+
if (!prepareInputFile(jc)) return null;
BitmapRegionDecoder decoder = DecodeUtils.createBitmapRegionDecoder(
jc, mFileDescriptor.getFileDescriptor(), false);
@@ -194,6 +200,10 @@ public class UriImage extends MediaItem {
@Override
public Bitmap run(JobContext jc) {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return DecodeUtils.ensureGLCompatibleBitmap(DrmHelper.getBitmap(getFilePath()));
+ }
+
if (!prepareInputFile(jc)) return null;
int targetSize = MediaItem.getTargetSize(mType);
Options options = new Options();
@@ -216,45 +226,18 @@ public class UriImage extends MediaItem {
@Override
public int getSupportedOperations() {
- int supported = SUPPORT_SETAS;
- String filePath = null;
- String scheme = mUri.getScheme();
- if ("file".equals(scheme)) {
- filePath = mUri.getPath();
- } else {
- Cursor cursor = null;
- try {
- cursor = mApplication.getContentResolver().query(mUri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- filePath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + mUri);
- } finally {
- if (cursor != null) cursor.close();
- }
- }
-
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- supported |= SUPPORT_DRM_INFO;
- filePath = filePath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- DrmManagerClientWrapper drmClient = new DrmManagerClientWrapper(mApplication.getAndroidContext());
- ContentValues values = drmClient.getMetadata(filePath);
- int drmType = values.getAsInteger("DRM-TYPE");
- Log.d(TAG, "getSupportedOperations:drmType returned= "
- + Integer.toString(drmType) + " for path= " + filePath);
- if (drmType == DrmDeliveryType.SEPARATE_DELIVERY) {
- if (isSharable()) supported |= SUPPORT_SHARE;
+ int supported = 0;
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ supported |= SUPPORT_DRM_INFO | SUPPORT_FULL_IMAGE;
+ if (DrmHelper.isShareableDrmFile(getFilePath())) {
+ supported |= SUPPORT_SHARE;
}
- if (drmClient != null) drmClient.release();
} else {
- supported |= SUPPORT_EDIT | SUPPORT_PRINT;
+ supported = SUPPORT_PRINT | SUPPORT_SETAS;
if (isSharable()) supported |= SUPPORT_SHARE;
- }
-
- if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
- supported |= SUPPORT_FULL_IMAGE;
+ if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
+ supported |= SUPPORT_EDIT | SUPPORT_FULL_IMAGE;
+ }
}
return supported;
}
@@ -279,6 +262,10 @@ public class UriImage extends MediaItem {
@Override
public int getMediaType() {
+ if (DrmHelper.isDrmFile(getFilePath())) {
+ return MEDIA_TYPE_DRM_IMAGE;
+ }
+
return MEDIA_TYPE_IMAGE;
}
@@ -337,12 +324,7 @@ public class UriImage extends MediaItem {
}
@Override
- public void setConsumeRights(boolean flag) {
- consumeRights = flag;
- }
-
- @Override
- public boolean getConsumeRights() {
- return consumeRights;
+ public String getFilePath() {
+ return mFilePath;
}
}
diff --git a/src/com/android/gallery3d/data/UriSource.java b/src/com/android/gallery3d/data/UriSource.java
index f66bacd7b..b4bb16072 100644
--- a/src/com/android/gallery3d/data/UriSource.java
+++ b/src/com/android/gallery3d/data/UriSource.java
@@ -17,7 +17,9 @@
package com.android.gallery3d.data;
import android.content.ContentResolver;
+import android.drm.DrmHelper;
import android.net.Uri;
+import android.text.TextUtils;
import android.webkit.MimeTypeMap;
import com.android.gallery3d.app.GalleryApp;
@@ -73,6 +75,19 @@ class UriSource extends MediaSource {
@Override
public Path findPathByUri(Uri uri, String type) {
String mimeType = getMimeType(uri);
+ if (DrmHelper.isDrmMimeType(mimeType)) {
+ String path = DrmHelper.getFilePath(
+ mApplication.getAndroidContext(), uri);
+ if (!TextUtils.isEmpty(path)) {
+ try {
+ return Path.fromString("/uri/"
+ + URLEncoder.encode(path, CHARSET_UTF_8) + "/"
+ + URLEncoder.encode(type, CHARSET_UTF_8));
+ } catch (UnsupportedEncodingException e) {
+ throw new AssertionError(e);
+ }
+ }
+ }
// Try to find a most specific type but it has to be started with "image/"
if ((type == null) || (IMAGE_TYPE_ANY.equals(type)
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index f80b28e5c..dcd0c927d 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -84,6 +84,7 @@ import com.android.gallery3d.filtershow.editors.EditorColorBorder;
import com.android.gallery3d.filtershow.editors.EditorCrop;
import com.android.gallery3d.filtershow.editors.EditorDraw;
import com.android.gallery3d.filtershow.editors.EditorGrad;
+import com.android.gallery3d.filtershow.editors.EditorMakeup;
import com.android.gallery3d.filtershow.editors.EditorManager;
import com.android.gallery3d.filtershow.editors.EditorMirror;
import com.android.gallery3d.filtershow.editors.EditorPanel;
@@ -100,6 +101,7 @@ import com.android.gallery3d.filtershow.filters.FilterStraightenRepresentation;
import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation;
import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
+import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter;
import com.android.gallery3d.filtershow.history.HistoryItem;
import com.android.gallery3d.filtershow.history.HistoryManager;
import com.android.gallery3d.filtershow.imageshow.ImageShow;
@@ -120,6 +122,7 @@ import com.android.gallery3d.filtershow.ui.ExportDialog;
import com.android.gallery3d.filtershow.ui.FramedTextButton;
import com.android.gallery3d.util.GalleryUtils;
import com.android.photos.data.GalleryBitmapPool;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
import java.io.File;
import java.io.FileDescriptor;
@@ -178,6 +181,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private CategoryAdapter mCategoryGeometryAdapter = null;
private CategoryAdapter mCategoryFiltersAdapter = null;
private CategoryAdapter mCategoryVersionsAdapter = null;
+ private CategoryAdapter mCategoryMakeupAdapter = null;
private int mCurrentPanel = MainPanel.LOOKS;
private Vector<FilterUserPresetRepresentation> mVersions =
new Vector<FilterUserPresetRepresentation>();
@@ -378,6 +382,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
fillTools();
fillEffects();
fillVersions();
+ fillMakeup();
}
public void setupStatePanel() {
@@ -466,6 +471,25 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
}
+ private void fillMakeup() {
+ if(!SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ return;
+ }
+
+ FiltersManager filtersManager = FiltersManager.getManager();
+ ArrayList<FilterRepresentation> makeups = filtersManager.getMakeup();
+ if (mCategoryMakeupAdapter != null) {
+ mCategoryMakeupAdapter.clear();
+ }
+ mCategoryMakeupAdapter = new CategoryAdapter(this);
+ for (FilterRepresentation makeup : makeups) {
+ if (makeup.getTextId() != 0) {
+ makeup.setName(getString(makeup.getTextId()));
+ }
+ mCategoryMakeupAdapter.add(new Action(this, makeup));
+ }
+ }
+
private void fillTools() {
FiltersManager filtersManager = FiltersManager.getManager();
ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getTools();
@@ -527,6 +551,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mEditorPlaceHolder.addEditor(new EditorMirror());
mEditorPlaceHolder.addEditor(new EditorRotate());
mEditorPlaceHolder.addEditor(new EditorStraighten());
+ mEditorPlaceHolder.addEditor(new EditorMakeup());
}
private void setDefaultValues() {
@@ -581,6 +606,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
return mCategoryBordersAdapter;
}
+ public CategoryAdapter getCategoryMakeupAdapter() {
+ return mCategoryMakeupAdapter;
+ }
+
public CategoryAdapter getCategoryGeometryAdapter() {
return mCategoryGeometryAdapter;
}
@@ -734,16 +763,16 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
MasterImage master = MasterImage.getImage();
Rect originalBounds = master.getOriginalBounds();
if (master.supportsHighRes()) {
- int highresPreviewSize = master.getOriginalBitmapLarge().getWidth() * 2;
- if (highresPreviewSize > originalBounds.width()) {
- highresPreviewSize = originalBounds.width();
- }
+ int highresPreviewSize = Math.min(MasterImage.MAX_BITMAP_DIM, getScreenImageSize());
+ Log.d(LOGTAG, "FilterShowActivity.LoadHighresBitmapTask.doInBackground(): after, highresPreviewSize is " + highresPreviewSize);
Rect bounds = new Rect();
Bitmap originalHires = ImageLoader.loadOrientedConstrainedBitmap(master.getUri(),
master.getActivity(), highresPreviewSize,
master.getOrientation(), bounds);
master.setOriginalBounds(bounds);
master.setOriginalBitmapHighres(originalHires);
+ Log.d(LOGTAG, "FilterShowActivity.LoadHighresBitmapTask.doInBackground(): originalHires.WH is (" + originalHires.getWidth()
+ + ", " + originalHires.getHeight() +"), bounds is " + bounds.toString());
mBoundService.setOriginalBitmapHighres(originalHires);
master.warnListeners();
}
@@ -756,6 +785,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
if (highresBitmap != null) {
float highResPreviewScale = (float) highresBitmap.getWidth()
/ (float) MasterImage.getImage().getOriginalBounds().width();
+ Log.d(LOGTAG, "FilterShowActivity.LoadHighresBitmapTask.onPostExecute(): highResPreviewScale is " + highResPreviewScale);
mBoundService.setHighresPreviewScaleFactor(highResPreviewScale);
}
MasterImage.getImage().warnListeners();
@@ -783,6 +813,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
public LoadBitmapTask() {
mBitmapSize = getScreenImageSize();
+ Log.d(LOGTAG, "FilterShowActivity.LoadBtimapTask(): mBitmapSize is " + mBitmapSize);
}
@Override
@@ -839,6 +870,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
float previewScale = (float) largeBitmap.getWidth()
/ (float) MasterImage.getImage().getOriginalBounds().width();
+ Log.d(LOGTAG, "FilterShowActivity.LoadBitmapTask.onPostExecute(): previewScale is " + previewScale);
mBoundService.setPreviewScaleFactor(previewScale);
if (!mShowingTinyPlanet) {
mCategoryFiltersAdapter.removeTinyPlanet();
@@ -847,6 +879,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mCategoryBordersAdapter.imageLoaded();
mCategoryGeometryAdapter.imageLoaded();
mCategoryFiltersAdapter.imageLoaded();
+ if(mCategoryMakeupAdapter != null) {
+ mCategoryMakeupAdapter.imageLoaded();
+ }
mLoadBitmapTask = null;
MasterImage.getImage().warnListeners();
@@ -1020,6 +1055,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
if (mShareActionProvider != null) {
mShareActionProvider.setOnShareTargetSelectedListener(this);
}
+ if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ MakeupEngine.getMakeupObj().setContext(getBaseContext());
+ }
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
index 09f02dd37..50f0e9436 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java
@@ -79,6 +79,9 @@ public class CategoryAdapter extends ArrayAdapter<Action> {
mSelectedPosition = 0;
mAddButtonText = getContext().getString(R.string.filtershow_add_button_looks);
}
+// if (category == MainPanel.MAKEUP) {
+// mSelectedPosition = 0;
+// }
if (category == MainPanel.BORDERS) {
mSelectedPosition = 0;
}
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
index fb51bf5ad..66b352ffb 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryPanel.java
@@ -29,7 +29,7 @@ import android.widget.ListView;
import android.widget.TextView;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
-
+import android.util.Log;
public class CategoryPanel extends Fragment implements View.OnClickListener {
public static final String FRAGMENT_TAG = "CategoryPanel";
@@ -89,6 +89,13 @@ public class CategoryPanel extends Fragment implements View.OnClickListener {
}
break;
}
+ case MainPanel.MAKEUP: {
+ mAdapter = activity.getCategoryMakeupAdapter();
+ if (mAdapter != null) {
+ mAdapter.initializeSelection(MainPanel.MAKEUP);
+ }
+ break;
+ }
}
updateAddButtonVisibility();
}
@@ -148,7 +155,7 @@ public class CategoryPanel extends Fragment implements View.OnClickListener {
return;
}
FilterShowActivity activity = (FilterShowActivity) getActivity();
- if (activity.isShowingImageStatePanel() && mAdapter.showAddButton()) {
+ if (activity.isShowingImageStatePanel() && mAdapter != null && mAdapter.showAddButton()) {
mAddButton.setVisibility(View.VISIBLE);
if (mAdapter != null) {
mAddButton.setText(mAdapter.getAddButtonText());
diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java
index 082bf143a..1dbe42083 100644
--- a/src/com/android/gallery3d/filtershow/category/MainPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java
@@ -24,9 +24,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
-
+import android.util.Log;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.FilterShowActivity;
+import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
import com.android.gallery3d.filtershow.state.StatePanel;
@@ -39,6 +40,7 @@ public class MainPanel extends Fragment {
private ImageButton bordersButton;
private ImageButton geometryButton;
private ImageButton filtersButton;
+ private ImageButton makeupButton;
public static final String FRAGMENT_TAG = "MainPanel";
public static final int LOOKS = 0;
@@ -46,6 +48,7 @@ public class MainPanel extends Fragment {
public static final int GEOMETRY = 2;
public static final int FILTERS = 3;
public static final int VERSIONS = 4;
+ public static final int MAKEUP = 5;
private int mCurrentSelected = -1;
private int mPreviousToggleVersions = -1;
@@ -72,6 +75,12 @@ public class MainPanel extends Fragment {
filtersButton.setSelected(value);
break;
}
+ case MAKEUP: {
+ if(makeupButton != null) {
+ makeupButton.setSelected(value);
+ }
+ break;
+ }
}
}
@@ -97,6 +106,19 @@ public class MainPanel extends Fragment {
bordersButton = (ImageButton) mMainView.findViewById(R.id.borderButton);
geometryButton = (ImageButton) mMainView.findViewById(R.id.geometryButton);
filtersButton = (ImageButton) mMainView.findViewById(R.id.colorsButton);
+ if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ makeupButton = (ImageButton) mMainView.findViewById(R.id.makeupButton);
+ makeupButton.setVisibility(View.VISIBLE);
+ }
+
+ if(makeupButton != null) {
+ makeupButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showPanel(MAKEUP);
+ }
+ });
+ }
looksButton.setOnClickListener(new View.OnClickListener() {
@Override
@@ -173,6 +195,19 @@ public class MainPanel extends Fragment {
selection(mCurrentSelected, true);
}
+ public void loadCategoryMakeupPanel() {
+ if (makeupButton == null || mCurrentSelected == MAKEUP) {
+ return;
+ }
+ boolean fromRight = isRightAnimation(MAKEUP);
+ selection(mCurrentSelected, false);
+ CategoryPanel categoryPanel = new CategoryPanel();
+ categoryPanel.setAdapter(MAKEUP);
+ setCategoryFragment(categoryPanel, fromRight);
+ mCurrentSelected = MAKEUP;
+ selection(mCurrentSelected, true);
+ }
+
public void loadCategoryGeometryPanel() {
if (mCurrentSelected == GEOMETRY) {
return;
@@ -239,6 +274,10 @@ public class MainPanel extends Fragment {
loadCategoryVersionsPanel();
break;
}
+ case MAKEUP: {
+ loadCategoryMakeupPanel();
+ break;
+ }
}
}
diff --git a/src/com/android/gallery3d/filtershow/crop/CropActivity.java b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
index 21b283eed..94c859333 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropActivity.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropActivity.java
@@ -115,12 +115,6 @@ public class CropActivity extends Activity {
@Override
public void onClick(View view) {
startFinishOutput();
- if (mCropExtras != null && mCropExtras.getSetAsWallpaper()) {
- Intent intent = new Intent("android.drmservice.intent.action.SET_WALLPAPER");
- intent.putExtra("DRM_TYPE", "OMAV1");
- intent.putExtra("DRM_FILE_PATH", mSourceUri.toString());
- CropActivity.this.sendBroadcast(intent);
- }
}
});
}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java b/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java
new file mode 100644
index 000000000..331d31b57
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java
@@ -0,0 +1,44 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.gallery3d.filtershow.editors;
+
+import android.view.View;
+import android.widget.SeekBar;
+
+import com.android.gallery3d.R;
+
+public class EditorMakeup extends BasicEditor {
+ public static int ID = R.id.editorMakeup;
+ private final String LOGTAG = "EditorMakeup";
+
+ public EditorMakeup() {
+ super(ID, R.layout.filtershow_default_editor, R.id.basicEditor);
+ }
+
+ @Override
+ public void setUtilityPanelUI(View actionButton, View editControl) {
+ super.setUtilityPanelUI(actionButton, editControl);
+ mSeekBar = (SeekBar) editControl.findViewById(R.id.primarySeekBar);
+ if (mSeekBar != null) {
+ mSeekBar.setVisibility(View.INVISIBLE);
+ }
+ }
+
+
+
+}
diff --git a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
index a60b6722c..0581835f4 100644
--- a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
+++ b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java
@@ -20,6 +20,7 @@ import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -50,6 +51,7 @@ public class EditorPanel extends Fragment {
super.onAttach(activity);
FilterShowActivity filterShowActivity = (FilterShowActivity) activity;
mEditor = filterShowActivity.getEditor(mEditorID);
+ Log.d(LOGTAG, "EditorPanle.onAttach(): mEditorID is " + mEditorID + ", mEditor is " + mEditor);
}
public void cancelCurrentFilter() {
diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
index 8350ff356..e93175a92 100644
--- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
+++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java
@@ -36,6 +36,7 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
protected ArrayList<FilterRepresentation> mBorders = new ArrayList<FilterRepresentation>();
protected ArrayList<FilterRepresentation> mTools = new ArrayList<FilterRepresentation>();
protected ArrayList<FilterRepresentation> mEffects = new ArrayList<FilterRepresentation>();
+ protected ArrayList<FilterRepresentation> mMakeup = new ArrayList<FilterRepresentation>();
private static int mImageBorderSize = 4; // in percent
protected void init() {
@@ -140,6 +141,12 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
filters.add(ImageFilterFx.class);
filters.add(ImageFilterBorder.class);
filters.add(ImageFilterColorBorder.class);
+ if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ filters.add(ImageFilterMakeupWhiten.class);
+ filters.add(ImageFilterMakeupSoften.class);
+ filters.add(ImageFilterMakeupTrimface.class);
+ filters.add(ImageFilterMakeupBigeye.class);
+ }
}
public ArrayList<FilterRepresentation> getLooks() {
@@ -158,8 +165,11 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
return mEffects;
}
- public void addBorders(Context context) {
+ public ArrayList<FilterRepresentation> getMakeup() {
+ return mMakeup;
+ }
+ public void addBorders(Context context) {
// Do not localize
String[] serializationNames = {
"FRAME_4X5",
@@ -305,6 +315,15 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface {
mEffects.add(getRepresentation(ImageFilterKMeans.class));
}
+ public void addMakeups(Context context) {
+ if(SimpleMakeupImageFilter.HAS_TS_MAKEUP) {
+ mMakeup.add(getRepresentation(ImageFilterMakeupWhiten.class));
+ mMakeup.add(getRepresentation(ImageFilterMakeupSoften.class));
+ mMakeup.add(getRepresentation(ImageFilterMakeupTrimface.class));
+ mMakeup.add(getRepresentation(ImageFilterMakeupBigeye.class));
+ }
+ }
+
public void addTools(Context context) {
int[] textId = {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 0fb157d7b..36675b71b 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -47,6 +47,7 @@ public class FilterRepresentation {
public static final byte TYPE_NORMAL = 5;
public static final byte TYPE_TINYPLANET = 6;
public static final byte TYPE_GEOMETRY = 7;
+ public static final byte TYPE_MAKEUP = 8;
protected static final String NAME_TAG = "Name";
public FilterRepresentation(String name) {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java
new file mode 100644
index 000000000..64067881e
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java
@@ -0,0 +1,54 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupBigeye extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "BIGEYE";
+
+ public ImageFilterMakeupBigeye() {
+ mName = "Bigeye";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Bigeye");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupBigeye.class);
+ representation.setTextId(R.string.text_makeup_bigeye);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_bigeye);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height,
+ int value) {
+ MakeupEngine.doWarpFace(bitmap, bitmap, width, height, faceInfo.eye1, faceInfo.eye2,
+ faceInfo.mouth, value, 0);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java
new file mode 100644
index 000000000..8587158c3
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java
@@ -0,0 +1,52 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupSoften extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "SOFTEN";
+
+ public ImageFilterMakeupSoften() {
+ mName = "Soften";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Soften");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupSoften.class);
+ representation.setTextId(R.string.text_makeup_Soften);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_soften);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height, int value) {
+ MakeupEngine.doProcessBeautify(bitmap, bitmap, width, height, faceInfo.face, value, 0);
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java
new file mode 100644
index 000000000..4b0499036
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java
@@ -0,0 +1,55 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupTrimface extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "TRIMFACE";
+
+ public ImageFilterMakeupTrimface() {
+ mName = "Trimface";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Trimface");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupTrimface.class);
+ representation.setTextId(R.string.text_makeup_trimface);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_trimface);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height,
+ int value) {
+ MakeupEngine.doWarpFace(bitmap, bitmap, width, height, faceInfo.eye1, faceInfo.eye2,
+ faceInfo.mouth, 0, value);
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java
new file mode 100644
index 000000000..e60be84d7
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java
@@ -0,0 +1,53 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+import com.thundersoft.hz.selfportrait.makeup.engine.MakeupEngine;
+
+public class ImageFilterMakeupWhiten extends SimpleMakeupImageFilter {
+ private static final String SERIALIZATION_NAME = "WHITEN";
+
+ public ImageFilterMakeupWhiten() {
+ mName = "Whiten";
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation =
+ (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Whiten");
+ representation.setSerializationName(SERIALIZATION_NAME);
+ representation.setFilterClass(ImageFilterMakeupWhiten.class);
+ representation.setTextId(R.string.text_makeup_whiten);
+ representation.setOverlayOnly(true);
+ representation.setOverlayId(R.drawable.ic_ts_makeup_whiten);
+ representation.setMinimum(0);
+ representation.setMaximum(100);
+ representation.setSupportsPartialRendering(true);
+ return representation;
+ }
+
+ protected void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height, int value) {
+ MakeupEngine.doProcessBeautify(bitmap, bitmap, width, height, faceInfo.face, 0, value);
+ }
+
+}
diff --git a/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java b/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java
new file mode 100644
index 000000000..584074c02
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java
@@ -0,0 +1,82 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.util.Log;
+
+import com.thundersoft.hz.selfportrait.detect.FaceDetect;
+import com.thundersoft.hz.selfportrait.detect.FaceInfo;
+
+public abstract class SimpleMakeupImageFilter extends SimpleImageFilter {
+ private static final String LOGTAG = "SimpleMakeupImageFilter";
+ protected static final int MAKEUP_INTENSITY = 50;
+
+ public static final boolean HAS_TS_MAKEUP = android.os.SystemProperties.getBoolean("persist.ts.postmakeup", false);
+
+ public SimpleMakeupImageFilter() {
+ }
+
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterRepresentation representation = new FilterBasicRepresentation("Default", 0,
+ MAKEUP_INTENSITY, 100);
+ representation.setShowParameterValue(true);
+ return representation;
+ }
+
+ protected FaceInfo detectFaceInfo(Bitmap bitmap) {
+ FaceDetect faceDetect = new FaceDetect();
+ faceDetect.initialize();
+ FaceInfo[] faceInfos = faceDetect.dectectFeatures(bitmap);
+ faceDetect.uninitialize();
+
+ Log.v(LOGTAG, "SimpleMakeupImageFilter.detectFaceInfo(): detect faceNum is "
+ + (faceInfos != null ? faceInfos.length : "NULL"));
+ if (faceInfos == null || faceInfos.length <= 0) {
+ return null;
+ }
+
+ return faceInfos[0];
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) {
+ if (getParameters() == null) {
+ return bitmap;
+ }
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
+ if(w % 2 != 0 || h % 2 != 0) {
+ return bitmap;
+ }
+ int value = getParameters().getValue();
+ applyHelper(bitmap, w, h, value);
+ return bitmap;
+ }
+
+ private void applyHelper(Bitmap bitmap, int w, int h, int value) {
+ FaceInfo faceInfo = detectFaceInfo(bitmap);
+ if(faceInfo != null) {
+ doMakeupEffect(bitmap, faceInfo, w, h, value);
+ }
+ }
+
+ abstract void doMakeupEffect(Bitmap bitmap, FaceInfo faceInfo, int width, int height,
+ int value);
+
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 2022ffd7e..d7c2eb4f8 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -288,7 +288,7 @@ public class ImageShow extends View implements OnGestureListener,
drawImageAndAnimate(canvas, highresPreview);
}
- drawHighresImage(canvas, fullHighres);
+// drawHighresImage(canvas, fullHighres);
drawCompareImage(canvas, getGeometryOnlyImage());
canvas.restore();
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 4b43d7672..5e27f4213 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -25,6 +25,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.net.Uri;
+import android.util.Log;
import com.android.gallery3d.exif.ExifTag;
import com.android.gallery3d.filtershow.FilterShowActivity;
@@ -211,6 +212,9 @@ public class MasterImage implements RenderingRequestCaller {
int sh = (int) (sw * (float) mOriginalBitmapLarge.getHeight() / mOriginalBitmapLarge
.getWidth());
mOriginalBitmapSmall = Bitmap.createScaledBitmap(mOriginalBitmapLarge, sw, sh, true);
+ Log.d(LOGTAG, "MasterImage.loadBitmap(): OriginalBitmapLarge.WH is (" + mOriginalBitmapLarge.getWidth() + ", "
+ + mOriginalBitmapLarge.getHeight() + "), OriginalBitmapSmall.WH is (" + sw + ", " + sh + "), originalBounds is "
+ + originalBounds.toString());
mZoomOrientation = mOrientation;
warnListeners();
return true;
diff --git a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
index e5736d43c..e334e8798 100644
--- a/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
+++ b/src/com/android/gallery3d/filtershow/pipeline/ProcessingService.java
@@ -304,12 +304,14 @@ public class ProcessingService extends Service {
filtersManager.addBorders(this);
filtersManager.addTools(this);
filtersManager.addEffects();
+ filtersManager.addMakeups(this);
FiltersManager highresFiltersManager = FiltersManager.getHighresManager();
highresFiltersManager.addLooks(this);
highresFiltersManager.addBorders(this);
highresFiltersManager.addTools(this);
highresFiltersManager.addEffects();
+// highresFiltersManager.addMakeups(this);
}
private void tearDownPipeline() {
diff --git a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
index 1dfbe3ff8..58466bf01 100644
--- a/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
+++ b/src/com/android/gallery3d/gadget/PhotoAppWidgetProvider.java
@@ -106,7 +106,7 @@ public class PhotoAppWidgetProvider extends AppWidgetProvider {
context.getPackageName(), R.layout.photo_frame);
try {
byte[] data = entry.imageData;
- Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, false);
+ Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
views.setImageViewBitmap(R.id.photo, bitmap);
} catch (Throwable t) {
Log.w(TAG, "cannot load widget image: " + appWidgetId, t);
diff --git a/src/com/android/gallery3d/gadget/WidgetClickHandler.java b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
index 642f3d650..e5b0a376c 100644
--- a/src/com/android/gallery3d/gadget/WidgetClickHandler.java
+++ b/src/com/android/gallery3d/gadget/WidgetClickHandler.java
@@ -57,8 +57,6 @@ public class WidgetClickHandler extends Activity {
Intent intent;
if (isValidDataUri(uri)) {
intent = new Intent(Intent.ACTION_VIEW, uri);
- intent.putExtra("WidgetClick", true);
-
// Used for checking whether it is from widget
intent.putExtra(PhotoPage.KEY_IS_FROM_WIDGET, true);
if (tediousBack) {
diff --git a/src/com/android/gallery3d/gadget/WidgetService.java b/src/com/android/gallery3d/gadget/WidgetService.java
index fc54fb6e8..b240ded46 100644
--- a/src/com/android/gallery3d/gadget/WidgetService.java
+++ b/src/com/android/gallery3d/gadget/WidgetService.java
@@ -19,8 +19,10 @@ package com.android.gallery3d.gadget;
import android.annotation.TargetApi;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.net.Uri;
+import android.view.View;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
@@ -117,7 +119,31 @@ public class WidgetService extends RemoteViewsService {
@Override
public RemoteViews getViewAt(int position) {
Bitmap bitmap = mSource.getImage(position);
- if (bitmap == null) return getLoadingView();
+
+ boolean isDrm = false;
+ if (DrmHelper.isDrmFile(DrmHelper.getFilePath(
+ mApp.getAndroidContext(), mSource.getContentUri(position)))) {
+ isDrm = true;
+ }
+
+ if (isDrm) {
+ if (bitmap == null) {
+ RemoteViews rv = new RemoteViews(mApp.getAndroidContext()
+ .getPackageName(),
+ R.layout.appwidget_drm_empty_item);
+ rv.setOnClickFillInIntent(
+ R.id.appwidget_photo_item,
+ new Intent().setFlags(
+ Intent.FLAG_ACTIVITY_CLEAR_TOP).setData(
+ mSource.getContentUri(position)));
+ return rv;
+ }
+ } else {
+ if (bitmap == null) {
+ return getLoadingView();
+ }
+ }
+
RemoteViews views = new RemoteViews(
mApp.getAndroidContext().getPackageName(),
R.layout.appwidget_photo_item);
@@ -125,6 +151,13 @@ public class WidgetService extends RemoteViewsService {
views.setOnClickFillInIntent(R.id.appwidget_photo_item, new Intent()
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
.setData(mSource.getContentUri(position)));
+
+ if (isDrm) {
+ views.setViewVisibility(R.id.drm_icon, View.VISIBLE);
+ } else {
+ views.setViewVisibility(R.id.drm_icon, View.GONE);
+ }
+
return views;
}
diff --git a/src/com/android/gallery3d/glrenderer/NinePatchTexture.java b/src/com/android/gallery3d/glrenderer/NinePatchTexture.java
index 2353f8b9b..d0ddc46c3 100644
--- a/src/com/android/gallery3d/glrenderer/NinePatchTexture.java
+++ b/src/com/android/gallery3d/glrenderer/NinePatchTexture.java
@@ -50,7 +50,7 @@ public class NinePatchTexture extends ResourceTexture {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeResource(
- mContext.getResources(), mResId, options, false);
+ mContext.getResources(), mResId, options);
mBitmap = bitmap;
setSize(bitmap.getWidth(), bitmap.getHeight());
byte[] chunkData = bitmap.getNinePatchChunk();
diff --git a/src/com/android/gallery3d/glrenderer/ResourceTexture.java b/src/com/android/gallery3d/glrenderer/ResourceTexture.java
index d60a16c5a..eb8e8a517 100644
--- a/src/com/android/gallery3d/glrenderer/ResourceTexture.java
+++ b/src/com/android/gallery3d/glrenderer/ResourceTexture.java
@@ -19,7 +19,6 @@ package com.android.gallery3d.glrenderer;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.util.Log;
import junit.framework.Assert;
@@ -27,7 +26,6 @@ import junit.framework.Assert;
// By default ResourceTexture is not opaque.
public class ResourceTexture extends UploadedTexture {
- private static final String TAG = "ResourceTexture";
protected final Context mContext;
protected final int mResId;
@@ -42,15 +40,8 @@ public class ResourceTexture extends UploadedTexture {
protected Bitmap onGetBitmap() {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
- Bitmap bitmap = null;
- try {
- bitmap = BitmapFactory.decodeResource(mContext.getResources(), mResId, options, false);
- } catch (OutOfMemoryError ex) {
- Log.e(TAG, "BitmapFactory decode resource out of memory");
- ex.printStackTrace();
- return null;
- }
- return bitmap;
+ return BitmapFactory.decodeResource(
+ mContext.getResources(), mResId, options);
}
@Override
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
index 641115138..8149df4b3 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlidingWindow.java
@@ -24,7 +24,6 @@ import com.android.gallery3d.app.AbstractGalleryActivity;
import com.android.gallery3d.app.AlbumSetDataLoader;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.DataSourceType;
-import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
import com.android.gallery3d.data.MediaSet;
@@ -81,7 +80,6 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
public Path setPath;
public String title;
public int totalCount;
- public int mediaType;
public int sourceType;
public int cacheFlag;
public int cacheStatus;
@@ -277,18 +275,6 @@ public class AlbumSetSlidingWindow implements AlbumSetDataLoader.DataListener {
if (getDataVersion(cover) != entry.coverDataVersion) {
entry.coverDataVersion = getDataVersion(cover);
entry.rotation = (cover == null) ? 0 : cover.getRotation();
-
- if (cover instanceof LocalMediaItem) {
- String filePath = ((LocalMediaItem) cover).filePath;
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- if (entry.mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_IMAGE;
- } else if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_VIDEO;
- }
- }
- }
-
if (entry.coverLoader != null) {
entry.coverLoader.recycle();
entry.coverLoader = null;
diff --git a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
index 37f9b4339..46daf1451 100644
--- a/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
+++ b/src/com/android/gallery3d/ui/AlbumSetSlotRenderer.java
@@ -183,10 +183,6 @@ public class AlbumSetSlotRenderer extends AbstractSlotRenderer {
((FadeInTexture) content).isAnimating()) {
renderRequestFlags |= SlotView.RENDER_MORE_FRAME;
}
- if ((entry.mediaType == MediaObject.MEDIA_TYPE_DRM_VIDEO)
- || (entry.mediaType == MediaObject.MEDIA_TYPE_DRM_IMAGE)) {
- drawDrmOverlay(canvas, width, height, entry.mediaType);
- }
return renderRequestFlags;
}
diff --git a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
index a534c6add..fec7d1e92 100644
--- a/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
+++ b/src/com/android/gallery3d/ui/AlbumSlidingWindow.java
@@ -24,7 +24,6 @@ import com.android.gallery3d.app.AlbumDataLoader;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
-import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaObject.PanoramaSupportCallback;
import com.android.gallery3d.data.Path;
import com.android.gallery3d.glrenderer.Texture;
@@ -268,18 +267,6 @@ public class AlbumSlidingWindow implements AlbumDataLoader.DataListener {
entry.mediaType = (item == null)
? MediaItem.MEDIA_TYPE_UNKNOWN
: entry.item.getMediaType();
-
- if (item instanceof LocalMediaItem) {
- String filePath = ((LocalMediaItem)item).filePath;
- if (filePath != null && (filePath.endsWith(".dcf") || filePath.endsWith(".dm"))) {
- if (entry.mediaType == MediaObject.MEDIA_TYPE_IMAGE) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_IMAGE;
- } else if (entry.mediaType == MediaObject.MEDIA_TYPE_VIDEO) {
- entry.mediaType = MediaObject.MEDIA_TYPE_DRM_VIDEO;
- }
- }
- }
-
entry.path = (item == null) ? null : item.getPath();
entry.rotation = (item == null) ? 0 : item.getRotation();
entry.contentLoader = new ThumbnailLoader(slotIndex, entry.item);
diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java
index 00a1459b0..9b2c3259c 100644
--- a/src/com/android/gallery3d/ui/MenuExecutor.java
+++ b/src/com/android/gallery3d/ui/MenuExecutor.java
@@ -24,11 +24,10 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
-import android.database.Cursor;
+import android.drm.DrmHelper;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
-import android.provider.MediaStore.Video.VideoColumns;
import android.support.v4.print.PrintHelper;
import android.view.Menu;
import android.view.MenuItem;
@@ -258,6 +257,14 @@ public class MenuExecutor {
Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_ATTACH_DATA)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra("mimeType", intent.getType());
+
+ // DRM files can be set as wallpaper only. Don't show other options
+ // to set as.
+ Uri uri = intent.getData();
+ if (DrmHelper.isDrmFile(DrmHelper.getFilePath(mActivity, uri))) {
+ intent.setPackage("com.android.gallery3d");
+ }
+
Activity activity = mActivity;
activity.startActivity(Intent.createChooser(
intent, activity.getString(R.string.set_as)));
@@ -279,30 +286,14 @@ public class MenuExecutor {
DataManager manager = mActivity.getDataManager();
Path path = getSingleSelectedPath();
Uri uri = manager.getContentUri(path);
- Log.d(TAG, "onMenuClicked:" + uri);
String filepath = null;
String scheme = uri.getScheme();
if ("file".equals(scheme)) {
filepath = uri.getPath();
} else {
- Cursor cursor = null;
- try {
- cursor = mActivity.getAndroidContext().getContentResolver().query(uri,
- new String[] {VideoColumns.DATA}, null, null, null);
- if (cursor != null && cursor.moveToNext()) {
- filepath = cursor.getString(0);
- }
- } catch (Throwable t) {
- Log.w(TAG, "cannot get path from: " + uri);
- } finally {
- if (cursor != null) cursor.close();
- }
+ filepath = DrmHelper.getFilePath(mActivity, uri);
}
- Intent drmintent = new Intent("android.drmservice.intent.action.SHOW_PROPERTIES");
- filepath = filepath.replace("/storage/emulated/0", "/storage/emulated/legacy");
- drmintent.putExtra("DRM_FILE_PATH", filepath);
- drmintent.putExtra("DRM_TYPE", "OMAV1");
- mActivity.getAndroidContext().sendBroadcast(drmintent);
+ DrmHelper.showDrmInfo(mActivity, filepath);
title = R.string.drm_license_info;
break;
default:
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 5647e36af..1fff4ea3e 100755
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -18,6 +18,7 @@ package com.android.gallery3d.ui;
import android.content.Context;
import android.content.res.Configuration;
+import android.drm.DrmHelper;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Rect;
@@ -204,6 +205,7 @@ public class PhotoView extends GLView {
private EdgeView mEdgeView;
private UndoBarView mUndoBar;
private Texture mVideoPlayIcon;
+ private Texture mDrmIcon;
private SynchronizedHandler mHandler;
@@ -307,6 +309,7 @@ public class PhotoView extends GLView {
}
});
mVideoPlayIcon = new ResourceTexture(mContext, R.drawable.ic_control_play);
+ mDrmIcon = new ResourceTexture(mContext, R.drawable.drm_image);
for (int i = -SCREEN_NAIL_MAX; i <= SCREEN_NAIL_MAX; i++) {
if (i == 0) {
mPictures.put(i, new FullPicture());
@@ -741,6 +744,15 @@ public class PhotoView extends GLView {
drawLoadingFailMessage(canvas);
}
+ if (getFilmMode()) {
+ MediaItem item = mModel.getMediaItem(0);
+ if (item != null) {
+ if (DrmHelper.isDrmFile(item.getFilePath())) {
+ drawDrmIcon(canvas, s);
+ }
+ }
+ }
+
// Draw a debug indicator showing which picture has focus (index ==
// 0).
//canvas.fillRect(-10, -10, 20, 20, 0x80FF00FF);
@@ -858,9 +870,18 @@ public class PhotoView extends GLView {
if (mModel.isVideo(mIndex) || mModel.isGif(mIndex)) {
drawVideoPlayIcon(canvas, s);
}
+
if (mLoadingState == Model.LOADING_FAIL ) {
drawLoadingFailMessage(canvas);
}
+
+ MediaItem item = mModel.getMediaItem(mIndex);
+ if (item != null) {
+ if (DrmHelper.isDrmFile(item.getFilePath())) {
+ drawDrmIcon(canvas, s);
+ }
+ }
+
canvas.restore();
}
@@ -927,6 +948,13 @@ public class PhotoView extends GLView {
mVideoPlayIcon.draw(canvas, -s / 2, -s / 2, s, s);
}
+ // Draw the Drm lock icon (in the place where the spinner was)
+ private void drawDrmIcon(GLCanvas canvas, int side) {
+ int s = side / ICON_RATIO;
+ // Draw the Drm lock icon at the center
+ mDrmIcon.draw(canvas, -s / 2, -s / 2, s, s);
+ }
+
// Draw the "no thumbnail" message
private void drawLoadingFailMessage(GLCanvas canvas) {
StringTexture m = mNoThumbnailText;
@@ -1133,6 +1161,7 @@ public class PhotoView extends GLView {
}
private void deleteAfterAnimation(int duration) {
+ if (mHandler.hasMessages(MSG_DELETE_ANIMATION_DONE)) return;
MediaItem item = mModel.getMediaItem(mTouchBoxIndex);
if (item == null) return;
mListener.onCommitDeleteImage();
diff --git a/src/com/android/gallery3d/util/GIFView.java b/src/com/android/gallery3d/util/GIFView.java
index 86003fb31..c80625b41 100755
--- a/src/com/android/gallery3d/util/GIFView.java
+++ b/src/com/android/gallery3d/util/GIFView.java
@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.ContentResolver;
import android.content.res.AssetManager;
import android.database.Cursor;
+import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -45,6 +46,19 @@ public class GIFView extends ImageView implements GifAction {
}
mUri = uri;
+ // Let decode the GIF image from byte stream instead of file stream
+ String filepath = DrmHelper.getFilePath(mContext, mUri);
+ if (DrmHelper.isDrmFile(filepath)) {
+ byte[] bytes = DrmHelper.getDrmImageBytes(filepath);
+ DrmHelper.manageDrmLicense(mContext, this.getHandler(), filepath,
+ "image/gif");
+ if (bytes == null) {
+ return false;
+ }
+ startDecode(bytes);
+ return true;
+ }
+
InputStream is = getInputStream(uri);
if (is == null || (getFileSize (is) == 0)) {
return false;
@@ -92,6 +106,12 @@ public class GIFView extends ImageView implements GifAction {
mGifDecoder.start();
}
+ private void startDecode(byte[] bytes) {
+ freeGifDecoder();
+ mGifDecoder = new GifDecoder(bytes, this);
+ mGifDecoder.start();
+ }
+
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mGifDecoder == null) {
diff --git a/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java b/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java
new file mode 100644
index 000000000..a5c7fb043
--- /dev/null
+++ b/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java
@@ -0,0 +1,79 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.thundersoft.hz.selfportrait.detect;
+
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.util.Log;
+
+public class FaceDetect {
+ private static final String TAG = "FaceDetect";
+
+ private int mHandle = 0;
+
+ static {
+ try {
+ System.loadLibrary("ts_detected_face_jni");
+ } catch (UnsatisfiedLinkError e) {
+ e.printStackTrace();
+ Log.e(TAG, "ts_detected_face_jni library not found!");
+ }
+ }
+
+ /**
+ * initialize method,MUST called at first time.
+ */
+ public void initialize() {
+ mHandle = native_create();
+ }
+
+ /**
+ * uninitialize method,MUST called at last time.
+ */
+
+ public void uninitialize() {
+ native_destroy(mHandle);
+ }
+
+ /**
+ * dectectFeatures method,MUST called after initialize method and before
+ * uninitialize method.
+ *
+ * @param bmp, Android Bitmap instance,MUST not null.
+ * @return FaceInfo array if success, otherwise return null.
+ */
+ public FaceInfo[] dectectFeatures(Bitmap bmp) {
+ int count = native_detect(mHandle, bmp);
+ if (count < 1) {
+ return null;
+ }
+ FaceInfo[] res = new FaceInfo[count];
+ for (int i = 0; i < count; i++) {
+ FaceInfo face = new FaceInfo();
+ native_face_info(mHandle, i, face.face, face.eye1, face.eye2, face.mouth);
+ res[i] = face;
+ }
+ return res;
+ }
+
+ private static native int native_create();
+ private static native void native_destroy(int handle);
+ private static native int native_detect(int handle, Bitmap bmp);
+ private static native int native_face_info(int handle, int index, Rect face, Rect eye1,
+ Rect eye2, Rect mouth);
+}
diff --git a/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java b/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java
new file mode 100644
index 000000000..eee51f71b
--- /dev/null
+++ b/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.thundersoft.hz.selfportrait.detect;
+
+import android.graphics.Rect;
+
+public class FaceInfo {
+ /**
+ * face rectangle
+ */
+ public Rect face = new Rect();
+ /**
+ * left eye rectangle
+ */
+ public Rect eye1 = new Rect();
+ /**
+ * right eye rectangle
+ */
+ public Rect eye2 = new Rect();
+ /**
+ * mount rectangle
+ */
+ public Rect mouth = new Rect();
+}
diff --git a/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java b/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java
new file mode 100644
index 000000000..8d58bcfef
--- /dev/null
+++ b/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java
@@ -0,0 +1,87 @@
+/*
+* Copyright (C) 2014,2015 Thundersoft Corporation
+* All rights Reserved
+*
+* 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.thundersoft.hz.selfportrait.makeup.engine;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.util.Log;
+
+public class MakeupEngine {
+ static {
+ try {
+ System.loadLibrary("ts_face_beautify_jni");
+ } catch (UnsatisfiedLinkError e) {
+ e.printStackTrace();
+ Log.e(MakeupEngine.class.getName(), "ts_face_beautify_jni library not found!");
+ }
+ }
+
+ private static MakeupEngine mInstance;
+
+ private MakeupEngine() {
+
+ }
+
+ public static MakeupEngine getMakeupObj() {
+ if(mInstance == null) {
+ mInstance = new MakeupEngine();
+ }
+
+ return mInstance;
+ }
+
+ private Context mContext;
+
+ public void setContext(Context context) {
+ mContext = context;
+ }
+
+ public Context getContext() {
+ return mContext;
+ }
+
+ /**
+ * FUNCTION: doProcessBeautify
+ * Do process face region clean and whiten.
+ * @param inBitmap, the Bitmap instance which have face region, MUST not null.
+ * @param outBitmap, the result of process, MUST not null.
+ * @param frameWidth,frameHeight, the size of inBitmap.
+ * @param faceRect, the face region in inBitmap.
+ * @param cleanLevel, the level of clean.(0-100)
+ * @param whiteLevel, the level of white.(0-100)
+ */
+ public static native boolean doProcessBeautify(Bitmap inBitmap, Bitmap outBitmap, int frameWidth, int frameHeight,
+ Rect faceRect, int cleanLevel, int beautyLevel);
+
+ /**
+ * FUNCTION: doWarpFace
+ * Do process face region warp and big eye.
+ * @param inBitmap, the Bitmap instance which have face region, MUST not null.
+ * @param outBitmap, the result of process, MUST not null.
+ * @param frameWidth, the size of inBitmap.
+ * @param frameHeight, the size of inBitmap.
+ * @param leftEye, the left eye rectangle
+ * @param rightEye, the right eye rectangle
+ * @param mouth, the mouth rectangle
+ * @param bigEyeLevel, the level of big eye.(0-100)
+ * @param trimFaceLevel, the level of trim face.(0-100)
+ */
+ public static native boolean doWarpFace(Bitmap inBitmap, Bitmap outBitmap, int frameWidth, int frameHeight,
+ Rect leftEye, Rect rightEye, Rect mouth, int bigEyeLevel, int trimFaceLevel);
+}
diff --git a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java
index 94e6afd86..910c00a29 100644
--- a/src/org/codeaurora/gallery3d/ext/MovieListLoader.java
+++ b/src/org/codeaurora/gallery3d/ext/MovieListLoader.java
@@ -172,9 +172,14 @@ public class MovieListLoader implements IMovieListLoader {
}
cursor.close();
}
- long curId = Long.parseLong(uri.getPathSegments().get(3));
- movieList = fillUriList(MediaStore.Video.Media.BUCKET_ID + "=? ",
- new String[]{String.valueOf(bucketId)}, curId, params[0]);
+ try {
+ long curId = Long.parseLong(uri.getPathSegments().get(3));
+ movieList = fillUriList(MediaStore.Video.Media.BUCKET_ID + "=? ",
+ new String[]{String.valueOf(bucketId)}, curId, params[0]);
+ } catch (Exception e) {
+ Log.e(TAG, "Exception while creating movie list. " + e);
+ return null;
+ }
} else if (uristr.toLowerCase().startsWith("file://")) {
String data = Uri.decode(uri.toString());
data = data.replaceAll("'", "''");
diff --git a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java
index 20d14f900..41fd09c53 100755
--- a/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java
+++ b/src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java
@@ -94,6 +94,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr
private boolean mNeedWaitLayout = false;
private boolean mHasGotMetaData = false;
private boolean mOnResumed;
+ private boolean mIsShowDialog = false;
private final Handler mHandler = new Handler() {
public void handleMessage(final Message msg) {
@@ -746,8 +747,13 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr
}
}
+ public void setDialogShowState(boolean isDialogShow) {
+ mIsShowDialog = isDialogShow;
+ }
+
@Override
public void start() {
+ if (mIsShowDialog) return;
if (isInPlaybackState()) {
mMediaPlayer.start();
mCurrentState = STATE_PLAYING;