From 77bee7afda91d4229e361b00731d6fa5871407e5 Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Fri, 6 Mar 2015 10:56:23 +0800 Subject: Gallery2: Pause video when dialog shows The live stream will be pause by server timeout dialog but start by surface change callback later. Check whether the dialog shows before start media player. Change-Id: I77e8e2b6f84cb0957571d86d9eef2cfb997f1074 CRs-Fixed: 802294 --- src/com/android/gallery3d/app/MoviePlayer.java | 8 ++++++++ src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index e6702b583..a65586e7a 100755 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -1356,6 +1356,12 @@ public class MoviePlayer implements } }) + .setOnCancelListener(new OnCancelListener() { + public void onCancel(DialogInterface dialog) { + mController.showEnded(); + onCompletion(); + } + }) .create(); mServerTimeoutDialog.setOnDismissListener(new OnDismissListener() { @@ -1363,6 +1369,7 @@ public class MoviePlayer implements if (LOG) { Log.v(TAG, "mServerTimeoutDialog.onDismiss()"); } + mVideoView.setDialogShowState(false); mIsShowDialog = false; } @@ -1373,6 +1380,7 @@ public class MoviePlayer implements if (LOG) { Log.v(TAG, "mServerTimeoutDialog.onShow()"); } + mVideoView.setDialogShowState(true); mIsShowDialog = true; } 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; -- cgit v1.2.3 From 665c07e9daab541e767e44bf72e5806e9f42ab68 Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Fri, 6 Mar 2015 14:17:34 +0800 Subject: Gallery2: set the progress bar when we pause the video The progress bar isn't set when we pause the video. Set the progress bar when we pause the video. Change-Id: I46d2890111a7e085ffc6787fe29f2e34977ce4f2 CRs-Fixed: 801770 --- src/com/android/gallery3d/app/MoviePlayer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index e6702b583..713b32d6c 100755 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -637,6 +637,7 @@ public class MoviePlayer implements } mTState = TState.PAUSED; mVideoView.pause(); + setProgress(); mController.showPaused(); } -- cgit v1.2.3 From 7e23452f005201ee01f84de4a82da61996bd7da9 Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Fri, 6 Mar 2015 10:56:23 +0800 Subject: Gallery2: Pause video when dialog shows The live stream will be pause by server timeout dialog but start by surface change callback later. Check whether the dialog shows before start media player. Change-Id: I77e8e2b6f84cb0957571d86d9eef2cfb997f1074 CRs-Fixed: 802294 --- src/com/android/gallery3d/app/MoviePlayer.java | 8 ++++++++ src/org/codeaurora/gallery3d/video/CodeauroraVideoView.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 4c0df84cc..509201640 100755 --- a/src/com/android/gallery3d/app/MoviePlayer.java +++ b/src/com/android/gallery3d/app/MoviePlayer.java @@ -1356,6 +1356,12 @@ public class MoviePlayer implements } }) + .setOnCancelListener(new OnCancelListener() { + public void onCancel(DialogInterface dialog) { + mController.showEnded(); + onCompletion(); + } + }) .create(); mServerTimeoutDialog.setOnDismissListener(new OnDismissListener() { @@ -1363,6 +1369,7 @@ public class MoviePlayer implements if (LOG) { Log.v(TAG, "mServerTimeoutDialog.onDismiss()"); } + mVideoView.setDialogShowState(false); mIsShowDialog = false; } @@ -1373,6 +1380,7 @@ public class MoviePlayer implements if (LOG) { Log.v(TAG, "mServerTimeoutDialog.onShow()"); } + mVideoView.setDialogShowState(true); mIsShowDialog = true; } 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; -- cgit v1.2.3 From 2317c969f87f9d5dce040cde4f2317d547b69dd9 Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Thu, 12 Mar 2015 16:50:03 +0800 Subject: Gallery2: Set video view visible The video view is set invisible when do OnPause in movie player. Cancel the video view set in doOnPause. Change-Id: I56616ad838024bba52727122c71d3cde26546cd4 CRs-Fixed: 801784 --- src/com/android/gallery3d/app/MoviePlayer.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/com/android/gallery3d/app/MoviePlayer.java b/src/com/android/gallery3d/app/MoviePlayer.java index 509201640..89ff7cbf2 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(); -- cgit v1.2.3 From 6ac840c51366287279e0c3b3f61ffd9e2c8f218b Mon Sep 17 00:00:00 2001 From: Byunghun Jeon Date: Thu, 26 Feb 2015 14:47:47 -0800 Subject: Gallery2: Gallery2 resources for beautification feature Change-Id: I2da57ec1bf807d89494abd84b5bb7a7f3a9f5e51 --- res/drawable-hdpi/ic_photoeditor_makeup.png | Bin 0 -> 2181 bytes res/drawable-hdpi/ic_ts_makeup_bigeye.png | Bin 0 -> 3908 bytes res/drawable-hdpi/ic_ts_makeup_soften.png | Bin 0 -> 3180 bytes res/drawable-hdpi/ic_ts_makeup_trimface.png | Bin 0 -> 3648 bytes res/drawable-hdpi/ic_ts_makeup_whiten.png | Bin 0 -> 4523 bytes res/drawable-mdpi/ic_photoeditor_makeup.png | Bin 0 -> 1728 bytes res/drawable-mdpi/ic_ts_makeup_bigeye.png | Bin 0 -> 4756 bytes res/drawable-mdpi/ic_ts_makeup_soften.png | Bin 0 -> 4224 bytes res/drawable-mdpi/ic_ts_makeup_trimface.png | Bin 0 -> 4543 bytes res/drawable-mdpi/ic_ts_makeup_whiten.png | Bin 0 -> 5074 bytes res/drawable-xhdpi/ic_photoeditor_makeup.png | Bin 0 -> 2650 bytes res/drawable-xhdpi/ic_ts_makeup_bigeye.png | Bin 0 -> 7118 bytes res/drawable-xhdpi/ic_ts_makeup_soften.png | Bin 0 -> 5782 bytes res/drawable-xhdpi/ic_ts_makeup_trimface.png | Bin 0 -> 6552 bytes res/drawable-xhdpi/ic_ts_makeup_whiten.png | Bin 0 -> 7779 bytes res/drawable-xxhdpi/ic_photoeditor_makeup_xx.png | Bin 0 -> 3798 bytes 16 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 res/drawable-hdpi/ic_photoeditor_makeup.png create mode 100644 res/drawable-hdpi/ic_ts_makeup_bigeye.png create mode 100644 res/drawable-hdpi/ic_ts_makeup_soften.png create mode 100644 res/drawable-hdpi/ic_ts_makeup_trimface.png create mode 100644 res/drawable-hdpi/ic_ts_makeup_whiten.png create mode 100644 res/drawable-mdpi/ic_photoeditor_makeup.png create mode 100644 res/drawable-mdpi/ic_ts_makeup_bigeye.png create mode 100644 res/drawable-mdpi/ic_ts_makeup_soften.png create mode 100644 res/drawable-mdpi/ic_ts_makeup_trimface.png create mode 100644 res/drawable-mdpi/ic_ts_makeup_whiten.png create mode 100644 res/drawable-xhdpi/ic_photoeditor_makeup.png create mode 100644 res/drawable-xhdpi/ic_ts_makeup_bigeye.png create mode 100644 res/drawable-xhdpi/ic_ts_makeup_soften.png create mode 100644 res/drawable-xhdpi/ic_ts_makeup_trimface.png create mode 100644 res/drawable-xhdpi/ic_ts_makeup_whiten.png create mode 100644 res/drawable-xxhdpi/ic_photoeditor_makeup_xx.png 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 Binary files /dev/null and b/res/drawable-hdpi/ic_photoeditor_makeup.png 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 Binary files /dev/null and b/res/drawable-hdpi/ic_ts_makeup_bigeye.png 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 Binary files /dev/null and b/res/drawable-hdpi/ic_ts_makeup_soften.png 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 Binary files /dev/null and b/res/drawable-hdpi/ic_ts_makeup_trimface.png 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 Binary files /dev/null and b/res/drawable-hdpi/ic_ts_makeup_whiten.png 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 Binary files /dev/null and b/res/drawable-mdpi/ic_photoeditor_makeup.png 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 Binary files /dev/null and b/res/drawable-mdpi/ic_ts_makeup_bigeye.png 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 Binary files /dev/null and b/res/drawable-mdpi/ic_ts_makeup_soften.png 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 Binary files /dev/null and b/res/drawable-mdpi/ic_ts_makeup_trimface.png 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 Binary files /dev/null and b/res/drawable-mdpi/ic_ts_makeup_whiten.png 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 Binary files /dev/null and b/res/drawable-xhdpi/ic_photoeditor_makeup.png 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 Binary files /dev/null and b/res/drawable-xhdpi/ic_ts_makeup_bigeye.png 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 Binary files /dev/null and b/res/drawable-xhdpi/ic_ts_makeup_soften.png 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 Binary files /dev/null and b/res/drawable-xhdpi/ic_ts_makeup_trimface.png 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 Binary files /dev/null and b/res/drawable-xhdpi/ic_ts_makeup_whiten.png 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 Binary files /dev/null and b/res/drawable-xxhdpi/ic_photoeditor_makeup_xx.png differ -- cgit v1.2.3 From 5e2719da005e8f5f42c838019f300432c3170a2f Mon Sep 17 00:00:00 2001 From: mqi Date: Tue, 17 Mar 2015 13:07:18 +0800 Subject: Gallery2: Add "No faces" strings Gallery shows "Untagged" when grouping pictures by faces if no faces were tagged. Change "Untagged" to "No faces". Change-Id: I7cde7a26e7340bdd95706d34480d8e8f61683138 CRs-Fixed: 807429 --- res/values-zh-rCN/strings.xml | 1 + res/values-zh-rHK/strings.xml | 1 + res/values-zh-rTW/strings.xml | 1 + res/values/strings.xml | 4 ++++ src/com/android/gallery3d/data/FaceClustering.java | 2 +- 5 files changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 res/values-zh-rCN/strings.xml mode change 100644 => 100755 res/values-zh-rHK/strings.xml mode change 100644 => 100755 res/values-zh-rTW/strings.xml mode change 100644 => 100755 res/values/strings.xml mode change 100644 => 100755 src/com/android/gallery3d/data/FaceClustering.java diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml old mode 100644 new mode 100755 index 4de380467..ccb28f423 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -105,6 +105,7 @@ "按大小分组" "未加标签" "无位置信息" + "无人物信息" "出现网络问题,系统无法识别某些位置。" "无法下载此相册中的照片,请稍后重试。" "仅限图片" diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml old mode 100644 new mode 100755 index 68317d582..434190b43 --- a/res/values-zh-rHK/strings.xml +++ b/res/values-zh-rHK/strings.xml @@ -105,6 +105,7 @@ "依大小分類" "無標記" "無地點資訊" + "無人物資訊" "網絡發生問題,因此部分位置無法辨別。" "無法下載這本相簿中的相片,請稍後再試。" "僅顯示相片" diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml old mode 100644 new mode 100755 index edb7f696d..de49fb45e --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -105,6 +105,7 @@ "依大小分類" "無標記" "無位置資訊" + "無人物資訊" "網路發生問題,因此無法辨識部分位置。" "無法下載這個相簿中的相片,請稍後再試。" "僅顯示圖片" diff --git a/res/values/strings.xml b/res/values/strings.xml old mode 100644 new mode 100755 index 82b286b32..875a6e32d --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -236,6 +236,10 @@ have location information in them [CHAR LIMIT=20]--> No location + + No faces + Some locations couldn\'t be identified due to network problems. diff --git a/src/com/android/gallery3d/data/FaceClustering.java b/src/com/android/gallery3d/data/FaceClustering.java old mode 100644 new mode 100755 index 819915edb..a0d567902 --- 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; } -- cgit v1.2.3 From 38478f2cfc651b58dd88274c9a3bb7526c91116b Mon Sep 17 00:00:00 2001 From: Zhang Zhenzhen Date: Tue, 10 Mar 2015 16:40:13 +0800 Subject: Modify:Gallery2 for branch Gallery2 Conflicts: res/values-zh-rCN/strings.xml res/values/strings.xml Change-Id: I6b760469290ca154f223f94a3c284fca7a513121 --- Android.mk | 11 +++ .../gallery3d/filtershow/editors/EditorMakeup.java | 44 +++++++++++ .../filters/ImageFilterMakeupBigeye.java | 54 ++++++++++++++ .../filters/ImageFilterMakeupSoften.java | 52 +++++++++++++ .../filters/ImageFilterMakeupTrimface.java | 55 ++++++++++++++ .../filters/ImageFilterMakeupWhiten.java | 53 +++++++++++++ .../filters/SimpleMakeupImageFilter.java | 82 ++++++++++++++++++++ .../hz/selfportrait/detect/FaceDetect.java | 79 ++++++++++++++++++++ .../hz/selfportrait/detect/FaceInfo.java | 39 ++++++++++ .../selfportrait/makeup/engine/MakeupEngine.java | 87 ++++++++++++++++++++++ proguard.flags | 4 + res/layout-land/filtershow_main_panel.xml | 10 +++ res/layout/filtershow_main_panel.xml | 13 +++- res/values-zh-rCN/strings.xml | 4 + res/values/filtershow_ids.xml | 1 + res/values/strings.xml | 5 ++ .../gallery3d/filtershow/FilterShowActivity.java | 46 +++++++++++- .../filtershow/category/CategoryAdapter.java | 3 + .../filtershow/category/CategoryPanel.java | 11 ++- .../gallery3d/filtershow/category/MainPanel.java | 41 +++++++++- .../gallery3d/filtershow/editors/EditorPanel.java | 2 + .../filtershow/filters/BaseFiltersManager.java | 21 +++++- .../filtershow/filters/FilterRepresentation.java | 1 + .../gallery3d/filtershow/imageshow/ImageShow.java | 2 +- .../filtershow/imageshow/MasterImage.java | 4 + .../filtershow/pipeline/ProcessingService.java | 2 + 26 files changed, 716 insertions(+), 10 deletions(-) create mode 100644 Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java create mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java create mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java create mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java create mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java create mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java create mode 100644 Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java create mode 100644 Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java create mode 100644 Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java diff --git a/Android.mk b/Android.mk index 0edfca54d..661dac6ae 100755 --- a/Android.mk +++ b/Android.mk @@ -39,6 +39,11 @@ LOCAL_OVERRIDES_PACKAGES := Gallery Gallery3D GalleryNew3D LOCAL_JNI_SHARED_LIBRARIES := libjni_eglfence libjni_filtershow_filters librsjni libjni_jpegstream +ifeq ($(TARGET_TS_MAKEUP), true) + LOCAL_JNI_SHARED_LIBRARIES := libts_detected_face_jni libts_face_beautify_jni + LOCAL_REQUIRED_MODULES := libts_detected_face_jni libts_face_beautify_jni +endif + LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_MULTILIB := 32 @@ -47,6 +52,12 @@ include $(BUILD_PACKAGE) ifeq ($(strip $(LOCAL_PACKAGE_OVERRIDES)),) +ifeq ($(TARGET_TS_MAKEUP), true) +include $(CLEAR_VARS) + LOCAL_PREBUILT_LIBS := jni_makeup_libs/libts_detected_face_jni.so jni_makeup_libs/libts_face_beautify_jni.so +include $(BUILD_MULTI_PREBUILT) +endif + # Use the following include to make gallery test apk include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java b/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java new file mode 100644 index 000000000..331d31b57 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java new file mode 100644 index 000000000..64067881e --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java new file mode 100644 index 000000000..8587158c3 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java new file mode 100644 index 000000000..4b0499036 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java new file mode 100644 index 000000000..e60be84d7 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java new file mode 100644 index 000000000..584074c02 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java new file mode 100644 index 000000000..a5c7fb043 --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java new file mode 100644 index 000000000..eee51f71b --- /dev/null +++ b/Gallery2/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/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java b/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java new file mode 100644 index 000000000..8d58bcfef --- /dev/null +++ b/Gallery2/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/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/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"/> + 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"/> + + - \ No newline at end of file + diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 4de380467..22e1b9eee 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -444,4 +444,8 @@ "3D 音效" "音效" “插入耳机体验音效” + 美白 + 磨皮 + 瘦脸 + 大眼 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 @@ + diff --git a/res/values/strings.xml b/res/values/strings.xml index 82b286b32..c7ce4d517 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1152,4 +1152,9 @@ CHAR LIMIT = NONE] --> Drm license info This file can not be played Rights will be consumed for playing this media + Whiten + Soften + Trimface + Bigeye + diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index f00117702..67fd3fe32 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 mVersions = new Vector(); @@ -380,6 +384,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL fillTools(); fillEffects(); fillVersions(); + fillMakeup(); } public void setupStatePanel() { @@ -468,6 +473,25 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } + private void fillMakeup() { + if(!SimpleMakeupImageFilter.HAS_TS_MAKEUP) { + return; + } + + FiltersManager filtersManager = FiltersManager.getManager(); + ArrayList 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 filtersRepresentations = filtersManager.getTools(); @@ -529,6 +553,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() { @@ -583,6 +608,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL return mCategoryBordersAdapter; } + public CategoryAdapter getCategoryMakeupAdapter() { + return mCategoryMakeupAdapter; + } + public CategoryAdapter getCategoryGeometryAdapter() { return mCategoryGeometryAdapter; } @@ -736,16 +765,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(); } @@ -758,6 +787,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(); @@ -785,6 +815,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public LoadBitmapTask() { mBitmapSize = getScreenImageSize(); + Log.d(LOGTAG, "FilterShowActivity.LoadBtimapTask(): mBitmapSize is " + mBitmapSize); } @Override @@ -841,6 +872,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(); @@ -849,6 +881,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mCategoryBordersAdapter.imageLoaded(); mCategoryGeometryAdapter.imageLoaded(); mCategoryFiltersAdapter.imageLoaded(); + if(mCategoryMakeupAdapter != null) { + mCategoryMakeupAdapter.imageLoaded(); + } mLoadBitmapTask = null; MasterImage.getImage().warnListeners(); @@ -1022,6 +1057,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 { 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/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 mBorders = new ArrayList(); protected ArrayList mTools = new ArrayList(); protected ArrayList mEffects = new ArrayList(); + protected ArrayList mMakeup = new ArrayList(); 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 getLooks() { @@ -158,8 +165,11 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface { return mEffects; } - public void addBorders(Context context) { + public ArrayList 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/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() { -- cgit v1.2.3 From 692eabb9f888c384bb8520dfb9f5b3fe3ba02e24 Mon Sep 17 00:00:00 2001 From: Jay Wang Date: Thu, 12 Mar 2015 13:39:08 -0700 Subject: Gallery2: Move files to the correct location Change-Id: Ife7f7a2fa656cba06e2f713b27dcdadc720a021d --- Android.mk | 6 -- .../gallery3d/filtershow/editors/EditorMakeup.java | 44 ----------- .../filters/ImageFilterMakeupBigeye.java | 54 -------------- .../filters/ImageFilterMakeupSoften.java | 52 ------------- .../filters/ImageFilterMakeupTrimface.java | 55 -------------- .../filters/ImageFilterMakeupWhiten.java | 53 ------------- .../filters/SimpleMakeupImageFilter.java | 82 -------------------- .../hz/selfportrait/detect/FaceDetect.java | 79 -------------------- .../hz/selfportrait/detect/FaceInfo.java | 39 ---------- .../selfportrait/makeup/engine/MakeupEngine.java | 87 ---------------------- .../gallery3d/filtershow/editors/EditorMakeup.java | 44 +++++++++++ .../filters/ImageFilterMakeupBigeye.java | 54 ++++++++++++++ .../filters/ImageFilterMakeupSoften.java | 52 +++++++++++++ .../filters/ImageFilterMakeupTrimface.java | 55 ++++++++++++++ .../filters/ImageFilterMakeupWhiten.java | 53 +++++++++++++ .../filters/SimpleMakeupImageFilter.java | 82 ++++++++++++++++++++ .../hz/selfportrait/detect/FaceDetect.java | 79 ++++++++++++++++++++ .../hz/selfportrait/detect/FaceInfo.java | 39 ++++++++++ .../selfportrait/makeup/engine/MakeupEngine.java | 87 ++++++++++++++++++++++ 19 files changed, 545 insertions(+), 551 deletions(-) delete mode 100644 Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java delete mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java delete mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java delete mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java delete mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java delete mode 100644 Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java delete mode 100644 Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java delete mode 100644 Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java delete mode 100644 Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java create mode 100644 src/com/android/gallery3d/filtershow/editors/EditorMakeup.java create mode 100644 src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java create mode 100644 src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java create mode 100644 src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java create mode 100644 src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java create mode 100644 src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java create mode 100644 src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java create mode 100644 src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java create mode 100644 src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java diff --git a/Android.mk b/Android.mk index 661dac6ae..f515ac03f 100755 --- a/Android.mk +++ b/Android.mk @@ -52,12 +52,6 @@ include $(BUILD_PACKAGE) ifeq ($(strip $(LOCAL_PACKAGE_OVERRIDES)),) -ifeq ($(TARGET_TS_MAKEUP), true) -include $(CLEAR_VARS) - LOCAL_PREBUILT_LIBS := jni_makeup_libs/libts_detected_face_jni.so jni_makeup_libs/libts_face_beautify_jni.so -include $(BUILD_MULTI_PREBUILT) -endif - # Use the following include to make gallery test apk include $(call all-makefiles-under, $(LOCAL_PATH)) diff --git a/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java b/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java deleted file mode 100644 index 331d31b57..000000000 --- a/Gallery2/src/com/android/gallery3d/filtershow/editors/EditorMakeup.java +++ /dev/null @@ -1,44 +0,0 @@ -/* -* 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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java deleted file mode 100644 index 64067881e..000000000 --- a/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupBigeye.java +++ /dev/null @@ -1,54 +0,0 @@ -/* -* 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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java deleted file mode 100644 index 8587158c3..000000000 --- a/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupSoften.java +++ /dev/null @@ -1,52 +0,0 @@ -/* -* 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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java deleted file mode 100644 index 4b0499036..000000000 --- a/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupTrimface.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -* 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/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java deleted file mode 100644 index e60be84d7..000000000 --- a/Gallery2/src/com/android/gallery3d/filtershow/filters/ImageFilterMakeupWhiten.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -* 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/Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java b/Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java deleted file mode 100644 index 584074c02..000000000 --- a/Gallery2/src/com/android/gallery3d/filtershow/filters/SimpleMakeupImageFilter.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -* 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/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java deleted file mode 100644 index a5c7fb043..000000000 --- a/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceDetect.java +++ /dev/null @@ -1,79 +0,0 @@ -/* -* 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/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java b/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java deleted file mode 100644 index eee51f71b..000000000 --- a/Gallery2/src/com/thundersoft/hz/selfportrait/detect/FaceInfo.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -* 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/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java b/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java deleted file mode 100644 index 8d58bcfef..000000000 --- a/Gallery2/src/com/thundersoft/hz/selfportrait/makeup/engine/MakeupEngine.java +++ /dev/null @@ -1,87 +0,0 @@ -/* -* 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/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/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/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); +} -- cgit v1.2.3 From 1d8eeb0086952877ff11bc6d9c3e31f85384ae24 Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Fri, 20 Mar 2015 14:42:21 +0800 Subject: Gallery2: Remove the 'Make available offline' The 'Make available offline' is not availiable Remove this item in menu Change-Id: Ia4e79b48b321c09ffefa30c7d12ee6bbec9094bd CRs-Fixed: 810360 --- res/menu/albumset.xml | 1 + 1 file changed, 1 insertion(+) 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" /> Date: Sat, 21 Mar 2015 09:29:23 +0800 Subject: Gallery2: Remove wait when notify dirty When notify Dirty from photo data adapter, where is a operation of waiting, but this Object.wait is locked by ReloadTask. Remove the wait when notify dirty, which notify all right away. And do the delete operation after last picture's deletion is done. Change-Id: I3c322c8d01944d1e41d784346da930b907efdb1c CRs-Fixed: 808799 --- src/com/android/gallery3d/app/PhotoDataAdapter.java | 6 ------ src/com/android/gallery3d/ui/PhotoView.java | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java index c7dd48b1e..1b6f3def3 100755 --- a/src/com/android/gallery3d/app/PhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java @@ -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/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 5647e36af..c55f84a21 100755 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -1133,6 +1133,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(); -- cgit v1.2.3 From 8c3144c8e7763fa7f24e3f0d20d035cb3bdd22a2 Mon Sep 17 00:00:00 2001 From: Jay Wang Date: Sun, 22 Mar 2015 02:46:26 -0700 Subject: Gallery2: Don't bundle beautification libraries Remove beautification libararies from LOCAL_JNI_SHARED_LIBRARIES as they are not planned to be bundled with Gallery2 apk Change-Id: I7508d775644a480ce5248cddf02b3a853b200cfb --- Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/Android.mk b/Android.mk index f515ac03f..0b471b641 100755 --- a/Android.mk +++ b/Android.mk @@ -40,7 +40,6 @@ LOCAL_OVERRIDES_PACKAGES := Gallery Gallery3D GalleryNew3D LOCAL_JNI_SHARED_LIBRARIES := libjni_eglfence libjni_filtershow_filters librsjni libjni_jpegstream ifeq ($(TARGET_TS_MAKEUP), true) - LOCAL_JNI_SHARED_LIBRARIES := libts_detected_face_jni libts_face_beautify_jni LOCAL_REQUIRED_MODULES := libts_detected_face_jni libts_face_beautify_jni endif -- cgit v1.2.3 From d1c76bf95773acfe97e534f94d7bc4436c837f9c Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Mon, 23 Mar 2015 15:49:12 +0800 Subject: Gallery2: Fix wake up the screen, the video does not continue to play. When security is set to none and wake up the screen,gallery lack of a broadcast to make video continue playing. Add receiver to processing video continue playing when wake up screen. Change-Id: I053f44f17178c3baa79ceea871cd66ec2683a743 CRs-Fixed: 809777 --- src/com/android/gallery3d/app/MovieActivity.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index 0b0341ad1..1afbc5fae 100644 --- a/src/com/android/gallery3d/app/MovieActivity.java +++ b/src/com/android/gallery3d/app/MovieActivity.java @@ -563,7 +563,7 @@ public class MovieActivity extends Activity { AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); super.onStart(); mMovieHooker.onStart(); - registerScreenOff(); + registerScreenReceiver(); } @Override @@ -576,7 +576,7 @@ public class MovieActivity extends Activity { mControlResumed = false; } mMovieHooker.onStop(); - unregisterScreenOff(); + unregisterScreenReceiver(); } @Override @@ -697,7 +697,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 +711,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() { -- cgit v1.2.3 From 6793597161676e452c2a09dc59a5aae816cddfde Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Mon, 2 Mar 2015 15:54:50 +0800 Subject: Gallery2: Modify the action of rewind and forward button When change to arabic language, the rewind and forward button should exchange their behavior due to the direction of progress bar is changed. Change default behavior of the media button for RTL. Change-Id: I5254fbf8329d74344e7c2f159c55473169c5c2ae --- .../android/gallery3d/app/MovieControllerOverlay.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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(); + } } } -- cgit v1.2.3 From 849de852ab4d470a5ad371de8ac1cf2d1537ecf9 Mon Sep 17 00:00:00 2001 From: kaiyiz Date: Wed, 1 Apr 2015 17:19:41 +0800 Subject: Gallery2: The spinner icon display different on Gallery home page and other page in RTL mode. The Spinner use RTL layout,which leads to the interface button direction is inconsisten. Cancel the spinner RTL layout patterns, modified into regular pattern. Change-Id: If400f06028604675596f4dd6c15e1491595c0cdf CRs-Fixed: 816286 --- res/layout/action_mode.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/layout/action_mode.xml b/res/layout/action_mode.xml index f107c26ee..c3a5a774a 100644 --- a/res/layout/action_mode.xml +++ b/res/layout/action_mode.xml @@ -24,7 +24,7 @@ - -- cgit v1.2.3 From c12b8b10bc4c033ba6855a400f14c3aae52ec143 Mon Sep 17 00:00:00 2001 From: Paramananda Date: Tue, 24 Mar 2015 17:51:29 +0530 Subject: Gallery2 : Uses internal Drm image decoder api in Gallery app - Remove all previous drm implementation which is basically uses base bitmap decode apis to decode drm image files. - Introduced new hidden apis on BitmapFactory and BitmapRegionDecoder specific to DRM content which is more practical to DRM framework. - Uses DrmHelper a utility drm api library to code reusability. - This approch will fix the issue on sharing images from Third party application. CRs-fixed : 804191 Change-Id: I2e9489800c57df4fdeeb21f1548fbccc6dfbd3f9 --- res/layout/appwidget_photo_item.xml | 8 + res/values-es-rUS/strings.xml | 5 + src/com/android/gallery3d/app/AlbumPage.java | 115 +----------- src/com/android/gallery3d/app/AlbumSetPage.java | 79 -------- src/com/android/gallery3d/app/GalleryActivity.java | 82 +-------- src/com/android/gallery3d/app/MovieActivity.java | 47 ++--- .../android/gallery3d/app/PhotoDataAdapter.java | 6 +- src/com/android/gallery3d/app/PhotoPage.java | 201 ++++----------------- src/com/android/gallery3d/app/SlideshowPage.java | 16 +- src/com/android/gallery3d/app/Wallpaper.java | 1 - src/com/android/gallery3d/data/DecodeUtils.java | 22 +-- src/com/android/gallery3d/data/FilterTypeSet.java | 3 +- .../android/gallery3d/data/ImageCacheRequest.java | 44 ++--- src/com/android/gallery3d/data/LocalImage.java | 75 ++++---- src/com/android/gallery3d/data/LocalVideo.java | 45 +++-- src/com/android/gallery3d/data/MediaObject.java | 10 +- src/com/android/gallery3d/data/UriImage.java | 80 ++++---- src/com/android/gallery3d/data/UriSource.java | 15 ++ .../gallery3d/filtershow/crop/CropActivity.java | 6 - .../gallery3d/glrenderer/NinePatchTexture.java | 2 +- .../gallery3d/glrenderer/ResourceTexture.java | 13 +- .../gallery3d/ui/AlbumSetSlidingWindow.java | 14 -- .../android/gallery3d/ui/AlbumSetSlotRenderer.java | 4 - .../android/gallery3d/ui/AlbumSlidingWindow.java | 13 -- src/com/android/gallery3d/ui/MenuExecutor.java | 31 ++-- src/com/android/gallery3d/ui/PhotoView.java | 28 +++ .../codeaurora/gallery3d/ext/MovieListLoader.java | 11 +- 27 files changed, 274 insertions(+), 702 deletions(-) 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" /> + + + 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 @@ "%1$d foto" "%1$d fotos" + + Los archivos DRM no pueden compartirse. + Información de licencia Drm + No puede reproducirse este archivo. + Se agotarán los derechos para reproducir este multimedia. diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 7824bf763..932865a06 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"; @@ -120,8 +101,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; @@ -330,6 +310,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) { @@ -342,65 +328,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(); @@ -434,7 +361,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()); @@ -443,29 +369,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); @@ -508,8 +411,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 b181b59fe..068ac33a0 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..1be5e73c8 100644 --- a/src/com/android/gallery3d/app/GalleryActivity.java +++ b/src/com/android/gallery3d/app/GalleryActivity.java @@ -18,19 +18,11 @@ 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; @@ -42,14 +34,12 @@ 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"; @@ -213,77 +203,7 @@ 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()); diff --git a/src/com/android/gallery3d/app/MovieActivity.java b/src/com/android/gallery3d/app/MovieActivity.java index 1afbc5fae..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(); diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java index 1b6f3def3..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 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/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 { 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 { @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 { } 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..c4524854d 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,37 @@ 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())) { + 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_SHARE | SUPPORT_CROP | SUPPORT_PRINT | SUPPORT_SETAS; - if (BitmapUtils.isRotationSupported(mimeType)) { - operation |= SUPPORT_ROTATE; - } + if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) { + operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT; + } + + 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 +340,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 +378,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..98ae18d0b 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 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,15 @@ 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; + int operation = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO | SUPPORT_TRIM | SUPPORT_MUTE; + if (DrmHelper.isDrmFile(getFilePath())) { + operation |= 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 supported; + return operation; } @Override @@ -232,6 +227,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..0cc1140c6 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 { @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; - if (isSharable()) supported |= SUPPORT_SHARE; - } - - if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) { - supported |= SUPPORT_FULL_IMAGE; + if (isSharable()) + supported |= SUPPORT_SHARE | SUPPORT_PRINT | SUPPORT_SETAS; + 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/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/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 c55f84a21..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; 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("'", "''"); -- cgit v1.2.3 From f68c8e1803fb79b44f340fb5c4ca66e5880fcedf Mon Sep 17 00:00:00 2001 From: Paramananda Date: Tue, 24 Mar 2015 18:02:37 +0530 Subject: Gallery2 : GIF animated drm file can be visible in Gallery app CRs-fixed : 804192 Change-Id: I0d62ebc31b54d5369e9530089e7c47088fc8d92f --- src/com/android/gallery3d/util/GIFView.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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) { -- cgit v1.2.3 From 7facb7dad8ab167a4af70263b789b348303e08ae Mon Sep 17 00:00:00 2001 From: Paramananda Date: Tue, 24 Mar 2015 18:04:23 +0530 Subject: Gallery2 : Drm lock icon added on Photo widget for drm content CRs-fixed : 804180 Change-Id: I11c969f0156dba6db75c924a568eaa0733395208 --- res/layout/appwidget_drm_empty_item.xml | 48 ++++++++++++++++++++++ .../gallery3d/gadget/PhotoAppWidgetProvider.java | 2 +- .../gallery3d/gadget/WidgetClickHandler.java | 2 - .../android/gallery3d/gadget/WidgetService.java | 35 +++++++++++++++- 4 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 res/layout/appwidget_drm_empty_item.xml 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 @@ + + + + + + + + +s + \ No newline at end of file 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; } -- cgit v1.2.3 From 03d43a0b10b14882936e4083dab53516e69aaaae Mon Sep 17 00:00:00 2001 From: wangjing Date: Fri, 3 Apr 2015 14:42:17 +0800 Subject: Gallery2: Gallery2 can't show the newest picture Camera give Gallery2 the newest picture's index is wrong in RTL mode. Give the newest picture's index in RTL mode. Change-Id: I6c23da7699f177b901b15abe859ce07ebb409c16 CRs-Fixed: 816284 --- src/com/android/gallery3d/app/GalleryActivity.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/com/android/gallery3d/app/GalleryActivity.java b/src/com/android/gallery3d/app/GalleryActivity.java index d918e1457..4ce0d8405 100644 --- a/src/com/android/gallery3d/app/GalleryActivity.java +++ b/src/com/android/gallery3d/app/GalleryActivity.java @@ -37,6 +37,8 @@ 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; @@ -61,6 +63,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; @@ -289,6 +292,13 @@ public final class GalleryActivity extends AbstractGalleryActivity implements On 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 -- cgit v1.2.3 From e45ba22d0350a0ba7ab382bde1f0dbd72ec70675 Mon Sep 17 00:00:00 2001 From: Paramananda Date: Tue, 24 Mar 2015 18:06:39 +0530 Subject: Gallery2 : Drm file can be set as wallpaper - Only DRM FL file can be set as device wallpaper. Other licenseable files like CD and SD can not be allow for wallpaper because after license expaired we can not revert wallpaper to default. CRs-Fixed: 804190 Change-Id: I42f501b6a06a057765f80a6a124970bec6619e85 --- src/com/android/gallery3d/data/LocalImage.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index c4524854d..67e8071d3 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -257,6 +257,10 @@ public class LocalImage extends LocalMediaItem { public int getSupportedOperations() { 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; -- cgit v1.2.3 From b6d1df6f74493f4ca7586fe1f755c38488e025f2 Mon Sep 17 00:00:00 2001 From: Paramananda Date: Mon, 13 Apr 2015 15:51:51 +0530 Subject: Gallery2 : Delete and Details options are not visible on Camera preview Added SUPPORT_DELETE and SUPPRT_INFO option on option item of image preview screen. CRs-Fixed: 819964 Change-Id: If8bbc702073d7193afb445feaa08d766886d3f22 --- src/com/android/gallery3d/data/LocalImage.java | 4 ++-- src/com/android/gallery3d/data/UriImage.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index c4524854d..3d2ee9bb0 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -262,8 +262,8 @@ public class LocalImage extends LocalMediaItem { operation |= SUPPORT_SHARE; } } else { - operation = SUPPORT_SHARE | SUPPORT_CROP | SUPPORT_PRINT | SUPPORT_SETAS; - + operation = SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_CROP + | SUPPORT_SETAS | SUPPORT_PRINT | SUPPORT_INFO; if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) { operation |= SUPPORT_FULL_IMAGE | SUPPORT_EDIT; } diff --git a/src/com/android/gallery3d/data/UriImage.java b/src/com/android/gallery3d/data/UriImage.java index 0cc1140c6..13176e4aa 100644 --- a/src/com/android/gallery3d/data/UriImage.java +++ b/src/com/android/gallery3d/data/UriImage.java @@ -233,8 +233,8 @@ public class UriImage extends MediaItem { supported |= SUPPORT_SHARE; } } else { - if (isSharable()) - supported |= SUPPORT_SHARE | SUPPORT_PRINT | SUPPORT_SETAS; + supported = SUPPORT_PRINT | SUPPORT_SETAS; + if (isSharable()) supported |= SUPPORT_SHARE; if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) { supported |= SUPPORT_EDIT | SUPPORT_FULL_IMAGE; } -- cgit v1.2.3 From 62ea8820f20d39767fd8472d8f1458edca3dcf0f Mon Sep 17 00:00:00 2001 From: Paramananda Date: Thu, 16 Apr 2015 11:32:34 +0530 Subject: Gallery2 : Video share option is not working - Issue is due to OMA DRM integration on the platform. - Added video share option on local video supported operation list. CRs-Fixed: 822784 Change-Id: Ia2a81b5f08ac02b98dd365b788d766ae3b57020e --- src/com/android/gallery3d/data/LocalVideo.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/android/gallery3d/data/LocalVideo.java b/src/com/android/gallery3d/data/LocalVideo.java index 98ae18d0b..7fafe97ae 100644 --- a/src/com/android/gallery3d/data/LocalVideo.java +++ b/src/com/android/gallery3d/data/LocalVideo.java @@ -190,15 +190,17 @@ public class LocalVideo extends LocalMediaItem { @Override public int getSupportedOperations() { - int operation = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO | SUPPORT_TRIM | SUPPORT_MUTE; if (DrmHelper.isDrmFile(getFilePath())) { - operation |= SUPPORT_DRM_INFO; + int operation = SUPPORT_DELETE | SUPPORT_PLAY | SUPPORT_INFO + | SUPPORT_DRM_INFO; if (DrmHelper.isShareableDrmFile(getFilePath())) { operation |= SUPPORT_SHARE; } + return operation; } - return operation; + return SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_PLAY | SUPPORT_INFO + | SUPPORT_TRIM | SUPPORT_MUTE; } @Override -- cgit v1.2.3