diff options
35 files changed, 231 insertions, 140 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4fb98f567..bb54b3e09 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -168,14 +168,7 @@ <data android:scheme="https" /> <data android:scheme="content" /> <data android:scheme="file" /> - <data android:mimeType="image/bmp" /> - <data android:mimeType="image/jpeg" /> - <data android:mimeType="image/gif" /> - <data android:mimeType="image/png" /> - <data android:mimeType="image/webp" /> - <data android:mimeType="image/x-ms-bmp" /> - <data android:mimeType="image/x-MS-bmp" /> - <data android:mimeType="image/vnd.wap.wbmp" /> + <data android:mimeType="image/*" /> <data android:mimeType="application/vnd.google.panorama360+jpg" /> </intent-filter> <intent-filter> diff --git a/res/drawable/tp_mask_toggle.xml b/res/drawable/tp_mask_toggle.xml new file mode 100644 index 000000000..29abd41fc --- /dev/null +++ b/res/drawable/tp_mask_toggle.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (c) 2016, The Linux Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of The Linux Foundation nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:drawable="@android:color/holo_blue_light" android:state_checked="true"></item> + <item android:drawable="@color/cache_placeholder" android:state_checked="false"></item> +</selector>
\ No newline at end of file diff --git a/res/layout/do_not_show_again_dialog.xml b/res/layout/do_not_show_again_dialog.xml index 8ddfdc191..d3d229740 100644 --- a/res/layout/do_not_show_again_dialog.xml +++ b/res/layout/do_not_show_again_dialog.xml @@ -30,19 +30,27 @@ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingTop="8dip" + android:paddingBottom="8dip" + android:paddingEnd="?android:attr/dialogPreferredPadding" + android:paddingStart="?android:attr/dialogPreferredPadding" android:orientation="vertical" > <TextView android:id="@+id/message" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_margin="8dp" /> + style="@android:style/TextAppearance.Material.Subhead" /> + + <Space + android:layout_width="0dp" + android:layout_height="5dp"/> <CheckBox android:id="@+id/do_not_show_chk" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_margin="8dp" + style="@android:style/TextAppearance.Material.Subhead" android:text="@string/do_not_show_again" /> </LinearLayout>
\ No newline at end of file diff --git a/res/layout/filtershow_actionbar_trueportrait_mask.xml b/res/layout/filtershow_actionbar_trueportrait_mask.xml index b922dbd2d..f992e76a8 100644 --- a/res/layout/filtershow_actionbar_trueportrait_mask.xml +++ b/res/layout/filtershow_actionbar_trueportrait_mask.xml @@ -52,15 +52,23 @@ android:id="@+id/maskForeground" android:layout_width="wrap_content" android:layout_height="match_parent" + android:background="@drawable/tp_mask_toggle" + android:textColor="@color/primary_text" android:paddingEnd="16dp" android:paddingStart="16dp" android:textOff="@string/foreground" android:textOn="@string/foreground" /> + <Space + android:layout_width="5dp" + android:layout_height="0dp"/> + <ToggleButton android:id="@+id/maskBackground" android:layout_width="wrap_content" android:layout_height="match_parent" + android:background="@drawable/tp_mask_toggle" + android:textColor="@color/primary_text" android:paddingEnd="16dp" android:paddingStart="16dp" android:textOff="@string/background" diff --git a/res/layout/filtershow_editor_crop_landscape.xml b/res/layout/filtershow_editor_crop_landscape.xml index 414a02422..65be04263 100644..100755 --- a/res/layout/filtershow_editor_crop_landscape.xml +++ b/res/layout/filtershow_editor_crop_landscape.xml @@ -58,11 +58,13 @@ </FrameLayout> <LinearLayout - android:layout_width="360dp" + android:layout_width="match_parent" android:layout_height="@dimen/crop_panel_height_lanscape" android:background="@android:color/transparent" android:layout_gravity="center" android:clickable="true" + android:layout_marginStart="@dimen/category_actionbar_panel_height" + android:layout_marginEnd="@dimen/category_actionbar_panel_height" android:orientation="horizontal"> <LinearLayout diff --git a/res/values-zh-rCN/filtershow_strings.xml b/res/values-zh-rCN/filtershow_strings.xml index 0b624759c..3d73589bf 100644..100755 --- a/res/values-zh-rCN/filtershow_strings.xml +++ b/res/values-zh-rCN/filtershow_strings.xml @@ -157,4 +157,6 @@ <string name="color">滤镜</string> <string name="frames">相框</string> + + <string name="trueportrait_intro">此功能用于增强人像照。你可以将效果应用于照片背景,例如“模糊”和“速写”。你也可以将两张照片拼在一起来给你的人像照创建一个有趣的背景。</string> </resources> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 8edde3884..8e6e553ed 100644..100755 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -472,4 +472,5 @@ <string name="trim_video_exit_title">放弃更改?</string> <string name="trim_video_exit_msg">是否放弃对当前影片的操作?</string> <string name="trim_video_exit_discard">放弃</string> + <string name="do_not_show_again">不再显示</string> </resources> diff --git a/res/values-zh-rHK/filtershow_strings.xml b/res/values-zh-rHK/filtershow_strings.xml index aa07bc5e0..5712e0c26 100644..100755 --- a/res/values-zh-rHK/filtershow_strings.xml +++ b/res/values-zh-rHK/filtershow_strings.xml @@ -153,4 +153,5 @@ <string name="filtershow_exif_f_stop" msgid="6081797865604483139">"光圈孔徑"</string> <string name="filtershow_exif_exposure_time" msgid="4099067062781294115">"曝光時間"</string> <string name="filtershow_exif_copyright" msgid="8801875918803737581">"版權"</string> + <string name="trueportrait_intro">此功能用於增強人像照。你可以將效果應用於照片背景,例如“模糊”和“速寫”。你也可以將兩張照片拼在一起來給你的人像照創建一個有趣的背景。</string> </resources> diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml index 434190b43..5330be458 100755 --- a/res/values-zh-rHK/strings.xml +++ b/res/values-zh-rHK/strings.xml @@ -437,4 +437,5 @@ <item quantity="one" msgid="6949174783125614798">"%1$d 張相片"</item> <item quantity="other" msgid="3813306834113858135">"%1$d 張相片"</item> </plurals> + <string name="do_not_show_again">不再顯示</string> </resources> diff --git a/res/values-zh-rTW/filtershow_strings.xml b/res/values-zh-rTW/filtershow_strings.xml index 004f7a4bf..887f4fda1 100644..100755 --- a/res/values-zh-rTW/filtershow_strings.xml +++ b/res/values-zh-rTW/filtershow_strings.xml @@ -156,4 +156,5 @@ <string name="color">濾鏡</string> <string name="frames">相框</string> + <string name="trueportrait_intro">此功能用於增強人像照。你可以將效果應用於照片背景,例如“模糊”和“速寫”。你也可以將兩張照片拼在一起來給你的人像照創建一個有趣的背景。</string> </resources> diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 7d2cb2158..b5e67c14e 100755 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -454,4 +454,5 @@ <string name="action_viewtype_list">列表视图</string> <string name="tvEmptyAlbum">O 個可用的圖片</string> <string name="tvEmptyVideos">O 個可用的影片</string> + <string name="do_not_show_again">不再顯示</string> </resources> diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml index 81b7ba535..7c0212e7e 100644 --- a/res/values/filtershow_strings.xml +++ b/res/values/filtershow_strings.xml @@ -352,7 +352,7 @@ <string name="fusion_pick_underlay">Pick Underlay</string> <string name="dualcam_no_segment_toast">No segment found at this point</string> <string name="dualcam_filter_not_supported">Dual camera filters not supported for this image</string> - <string name="trueportrait_intro">Allows you to enhance photos of people. You can apply effects to the background, such "blur" and "sketch". You can also merge two photos together to create interesting backgrounds for your portrait photos.</string> + <string name="trueportrait_intro">Allows you to enhance photos of people. You can apply effects to the background, such as \"blur\" and \"sketch\". You can also merge two photos together to create interesting backgrounds for your portrait photos.</string> <string name="trueportrait_no_face">True Portrait effects cannot be applied to this photo. Face not detected.</string> <string name="trueportrait_edit_intro">With the Touch-Up tool, you can edit the foreground and the background. You can user your finger to paint in any areas of the foreground or background that were missed.</string> <string name="trueportrait_edit_foreground_toast">Use your finger to paint in any areas of the foreground that were missed.</string> diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java index 36bde4dbd..baece7023 100755 --- a/src/com/android/gallery3d/app/PhotoDataAdapter.java +++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java @@ -162,7 +162,6 @@ public class PhotoDataAdapter implements PhotoPage.Model { private int mCameraIndex; private boolean mIsPanorama; private boolean mIsStaticCamera; - private boolean mIsFromTimelineScreen; private boolean mIsActive; private boolean mNeedFullImage; private int mFocusHintDirection = FOCUS_HINT_NEXT; @@ -188,7 +187,7 @@ public class PhotoDataAdapter implements PhotoPage.Model { // preview. If cameraIndex < 0, there is no camera preview. public PhotoDataAdapter(AbstractGalleryActivity activity, PhotoView view, MediaSet mediaSet, Path itemPath, int indexHint, int cameraIndex, - boolean isPanorama, boolean isStaticCamera, boolean isFromTimelineScreen) { + boolean isPanorama, boolean isStaticCamera) { mActivity = activity; mSource = Utils.checkNotNull(mediaSet); mPhotoView = Utils.checkNotNull(view); @@ -197,7 +196,6 @@ public class PhotoDataAdapter implements PhotoPage.Model { mCameraIndex = cameraIndex; mIsPanorama = isPanorama; mIsStaticCamera = isStaticCamera; - mIsFromTimelineScreen = isFromTimelineScreen; mThreadPool = activity.getThreadPool(); mNeedFullImage = true; @@ -1309,9 +1307,6 @@ public class PhotoDataAdapter implements PhotoPage.Model { } mDirty = false; - if (mIsFromTimelineScreen) { - mSource.setClusterKind(GalleryActivity.CLUSTER_ALBUMSET_NO_TITLE); - } version = mSource.reload(); //if data is not ready, continue to reload if (version == MediaObject.INVALID_DATA_VERSION) { @@ -1439,10 +1434,7 @@ public class PhotoDataAdapter implements PhotoPage.Model { // Don't change index if mSize == 0 if (mSize > 0) { - // Due to the set identification and new photo, photos - // in the last two positions disappear in the temp info.items. - // Don't change index in such a situation. - if (index >= mSize + 2) index = mSize - 1; + if (index >= mSize) index = mSize - 1; } info.indexHint = index; diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 3000d056b..cdd5742fd 100755 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -501,8 +501,7 @@ public abstract class PhotoPage extends ActivityState implements mActivity, mPhotoView, mMediaSet, itemPath, mCurrentIndex, mAppBridge == null ? -1 : 0, mAppBridge == null ? false : mAppBridge.isPanorama(), - mAppBridge == null ? false : mAppBridge.isStaticCamera(), - mIsFromTimelineScreen); + mAppBridge == null ? false : mAppBridge.isStaticCamera()); mModel = pda; mPhotoView.setModel(mModel); @@ -1661,7 +1660,8 @@ public abstract class PhotoPage extends ActivityState implements } mActivity.getGLRoot().setOrientationSource(null); if (mBottomControls != null) mBottomControls.cleanup(); - + mPhotoView.destroy(); + mPhotoView = null; // Remove all pending messages. mHandler.removeCallbacksAndMessages(null); super.onDestroy(); diff --git a/src/com/android/gallery3d/data/ClusterAlbumSet.java b/src/com/android/gallery3d/data/ClusterAlbumSet.java index 7695bd35c..0d7ce3685 100644..100755 --- a/src/com/android/gallery3d/data/ClusterAlbumSet.java +++ b/src/com/android/gallery3d/data/ClusterAlbumSet.java @@ -139,8 +139,6 @@ public class ClusterAlbumSet extends MediaSet implements ContentListener { album = (ClusterAlbum) dataManager.peekMediaObject(childPath); if (album == null) { album = new ClusterAlbum(childPath, dataManager, this, mKind); - } else { - album.setClusterKind(mKind); } } album.setMediaItems(clustering.getCluster(i)); diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 452f4014c..8ada5af9b 100755 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -291,6 +291,7 @@ DialogInterface.OnDismissListener, PopupMenu.OnDismissListener{ * see this happen. */ mBoundService = null; + ImageFilter.resetStatics(); MasterImage.setMaster(null); } }; diff --git a/src/com/android/gallery3d/filtershow/category/Action.java b/src/com/android/gallery3d/filtershow/category/Action.java index 75982d851..731c07999 100644 --- a/src/com/android/gallery3d/filtershow/category/Action.java +++ b/src/com/android/gallery3d/filtershow/category/Action.java @@ -123,15 +123,6 @@ public class Action implements RenderingRequestCaller { return; } - if(mRepresentation.getOverlayOnly()) { - mImageFrame = imageFrame; - int w = mImageFrame.width(); - int h = mImageFrame.height(); - mImage = MasterImage.getImage().getBitmapCache().getBitmap(w, h, BitmapCache.ICON); - drawOverlay(true); - return; - } - Bitmap temp = MasterImage.getImage().getTemporaryThumbnailBitmap(); if (temp != null) { mImage = temp; @@ -176,17 +167,21 @@ public class Action implements RenderingRequestCaller { float dx = (destination.getWidth() - source.getWidth() * scaleFactor) / 2.0f; float dy = (destination.getHeight() - source.getHeight() * scaleFactor) / 2.0f; - if (mImageFrame.height() > mImageFrame.width()) { - // if portrait - dy -= mTextSize; - } m.setScale(scaleFactor, scaleFactor); m.postTranslate(dx, dy); Canvas canvas = new Canvas(destination); canvas.drawBitmap(source, m, new Paint(Paint.FILTER_BITMAP_FLAG)); } - private void drawOverlay(boolean scale) { + @Override + public void available(RenderingRequest request) { + clearBitmap(); + mImage = request.getBitmap(); + if (mImage == null) { + mImageFrame = null; + return; + } + if (mRepresentation.getOverlayId() != 0 && mOverlayBitmap == null) { mOverlayBitmap = BitmapFactory.decodeResource( mContext.getResources(), @@ -200,21 +195,9 @@ public class Action implements RenderingRequestCaller { } else { Canvas canvas = new Canvas(mImage); canvas.drawARGB(128, 0, 0, 0); - drawCenteredImage(mOverlayBitmap, mImage, scale); + drawCenteredImage(mOverlayBitmap, mImage, false); } } - } - - @Override - public void available(RenderingRequest request) { - clearBitmap(); - mImage = request.getBitmap(); - if (mImage == null) { - mImageFrame = null; - return; - } - - drawOverlay(false); if (mAdapter != null) { mAdapter.notifyDataSetChanged(); diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java index 4c909789d..24912bb24 100644..100755 --- a/src/com/android/gallery3d/filtershow/category/MainPanel.java +++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java @@ -513,6 +513,9 @@ public class MainPanel extends Fragment implements BottomPanel.BottomPanelDelega public void showPanel(int currentPanel) { FilterShowActivity activity = (FilterShowActivity) getActivity(); + if (null == activity) { + return; + } switch (currentPanel) { case LOOKS: { loadCategoryLookPanel(false); diff --git a/src/com/android/gallery3d/filtershow/category/TruePortraitMaskEditorPanel.java b/src/com/android/gallery3d/filtershow/category/TruePortraitMaskEditorPanel.java index 03935edc0..4390b90a7 100644 --- a/src/com/android/gallery3d/filtershow/category/TruePortraitMaskEditorPanel.java +++ b/src/com/android/gallery3d/filtershow/category/TruePortraitMaskEditorPanel.java @@ -33,6 +33,8 @@ package com.android.gallery3d.filtershow.category; import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -69,11 +71,24 @@ public class TruePortraitMaskEditorPanel extends Fragment { boolean skipIntro = GalleryUtils.getBooleanPref(context, context.getString(R.string.pref_trueportrait_edit_intro_show_key), false); if(!skipIntro) { - DoNotShowAgainDialog dialog = new DoNotShowAgainDialog( - R.string.trueportrait_touch_up, R.string.trueportrait_edit_intro, - R.string.pref_trueportrait_edit_intro_show_key); - dialog.setCancelable(false); - dialog.show(getFragmentManager(), "trueportrait_edit_intro"); + FragmentManager fm = getFragmentManager(); + DoNotShowAgainDialog dialog = + (DoNotShowAgainDialog) fm.findFragmentByTag("trueportrait_edit_intro"); + if(dialog == null) { + dialog = new DoNotShowAgainDialog( + R.string.trueportrait_touch_up, R.string.trueportrait_edit_intro, + R.string.pref_trueportrait_edit_intro_show_key); + dialog.setCancelable(false); + dialog.show(fm, "trueportrait_edit_intro"); + } else if (dialog.isDetached()) { + FragmentTransaction ft = fm.beginTransaction(); + ft.attach(dialog); + ft.commit(); + } else if (dialog.isHidden()) { + FragmentTransaction ft = fm.beginTransaction(); + ft.show(dialog); + ft.commit(); + } } } diff --git a/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitFusion.java b/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitFusion.java index cfeea1375..da6118c63 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitFusion.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitFusion.java @@ -37,6 +37,7 @@ import android.content.Context; import android.content.DialogInterface; import android.net.Uri; import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; @@ -46,6 +47,7 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import org.codeaurora.gallery.R; + import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.filters.FilterTruePortraitFusionRepresentation; @@ -171,18 +173,38 @@ public class EditorTruePortraitFusion extends Editor { boolean skipIntro = GalleryUtils.getBooleanPref(mContext, mContext.getString(R.string.pref_trueportrait_fusion_intro_show_key), false); if(!skipIntro) { - DoNotShowAgainDialog dialog = new DoNotShowAgainDialog( - R.string.fusion_pick_background, R.string.trueportrait_fusion_intro, - R.string.pref_trueportrait_fusion_intro_show_key) { - @Override - public void onDismiss(DialogInterface dialog) { - super.onDismiss(dialog); - MasterImage.getImage().getActivity().pickImage(FilterShowActivity.SELECT_FUSION_UNDERLAY); - } - }; FragmentManager fm = ((FilterShowActivity)mContext).getSupportFragmentManager(); - dialog.setCancelable(false); - dialog.show(fm, "trueportrait_fusion_intro"); + DoNotShowAgainDialog dialog = + (DoNotShowAgainDialog) fm.findFragmentByTag("trueportrait_fusion_intro"); + if(dialog == null) { + dialog = new DoNotShowAgainDialog( + R.string.fusion_pick_background, R.string.trueportrait_fusion_intro, + R.string.pref_trueportrait_fusion_intro_show_key) { + @Override + public void onCancel(DialogInterface dialog) { + super.onCancel(dialog); + FilterShowActivity activity = (FilterShowActivity) mContext; + activity.cancelCurrentFilter(); + activity.leaveSeekBarPanel(); + } + }; + dialog.setOnOkButtonClickListener(new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + MasterImage.getImage().getActivity().pickImage(FilterShowActivity.SELECT_FUSION_UNDERLAY); + } + }); + dialog.setCancelable(true); + dialog.show(fm, "trueportrait_fusion_intro"); + } else if (dialog.isDetached()) { + FragmentTransaction ft = fm.beginTransaction(); + ft.attach(dialog); + ft.commit(); + } else if (dialog.isHidden()) { + FragmentTransaction ft = fm.beginTransaction(); + ft.show(dialog); + ft.commit(); + } } } } diff --git a/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitMask.java b/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitMask.java index 7c5842f7f..75f84efd2 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitMask.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorTruePortraitMask.java @@ -193,9 +193,9 @@ public class EditorTruePortraitMask extends Editor { private void showToast() { Toast toast; if(isBackgroundMode()) { - toast = Toast.makeText(mContext, R.string.trueportrait_edit_background_toast, Toast.LENGTH_SHORT); + toast = Toast.makeText(mContext, R.string.trueportrait_edit_background_toast, Toast.LENGTH_LONG); } else { - toast = Toast.makeText(mContext, R.string.trueportrait_edit_foreground_toast, Toast.LENGTH_SHORT); + toast = Toast.makeText(mContext, R.string.trueportrait_edit_foreground_toast, Toast.LENGTH_LONG); } toast.show(); diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java index 4918bee86..bf3d02c12 100755 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java @@ -22,6 +22,7 @@ import android.graphics.Matrix; import android.renderscript.Allocation; import android.widget.Toast; +import com.android.gallery3d.app.GalleryAppImpl; import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils; import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.pipeline.FilterEnvironment; @@ -57,7 +58,7 @@ public abstract class ImageFilter implements Cloneable { @Override public void run() { if (sActivity != null && (!msg.equals(lastMsg) || sToast == null)) { - sToast = Toast.makeText(sActivity.getApplicationContext(), msg, duration); + sToast = Toast.makeText(GalleryAppImpl.getContext(), msg, duration); lastMsg = msg; } if (sToast != null) { @@ -69,9 +70,7 @@ public abstract class ImageFilter implements Cloneable { } void showToast(int resID, int duration) { - if (sActivity != null) { - showToast(sActivity.getResources().getString(resID), duration); - } + showToast(GalleryAppImpl.getContext().getString(resID), duration); } public void freeResources() {} diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTruePortrait.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTruePortrait.java index f070bfc30..b885dc831 100755..100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTruePortrait.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTruePortrait.java @@ -66,7 +66,7 @@ public class ImageFilterTruePortrait extends ImageFilter { @Override public Bitmap apply(Bitmap bitmap, float scaleFactor, int quality) { - if (getParameters() == null) { + if (getParameters() == null || quality == FilterEnvironment.QUALITY_ICON) { return bitmap; } diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageTruePortraitMask.java b/src/com/android/gallery3d/filtershow/imageshow/ImageTruePortraitMask.java index 052035714..43193acab 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageTruePortraitMask.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageTruePortraitMask.java @@ -97,21 +97,25 @@ public class ImageTruePortraitMask extends ImageShow { private void setup() { mMaskPaintForeground.setAntiAlias(true); - mMaskPaintForeground.setColor(Color.RED); - mMaskPaintForeground.setColorFilter(new LightingColorFilter(Color.RED, 1)); - mMaskPaintForeground.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN)); + mMaskPaintForeground.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); + mMaskPaintForeground.setColorFilter(new ColorMatrixColorFilter(new float[] { + // Set color to GREEN + 0,0,0,0,0, + 0,0,0,0,191, + 0,0,0,0,0, + 0,0,0,.5f,0 + })); mMaskPaintBackground.setAntiAlias(true); - mMaskPaintBackground.setColor(Color.GREEN); + mMaskPaintBackground.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); mMaskPaintBackground.setColorFilter(new ColorMatrixColorFilter(new float[] { - // Set color to GREEN and inverse ALPHA channel + // Set color to RED and inverse ALPHA channel // of original mask to get background + 0,0,0,0,191, 0,0,0,0,0, - 0,0,0,0,255, 0,0,0,0,0, - 0,0,0,-1,255 + 0,0,0,-.5f,127 })); - mMaskPaintBackground.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN)); mMaskEditPaint.setAntiAlias(true); mMaskEditPaint.setStyle(Style.STROKE); diff --git a/src/com/android/gallery3d/filtershow/tools/SaveImage.java b/src/com/android/gallery3d/filtershow/tools/SaveImage.java index 87492a335..073aca4cd 100644 --- a/src/com/android/gallery3d/filtershow/tools/SaveImage.java +++ b/src/com/android/gallery3d/filtershow/tools/SaveImage.java @@ -368,6 +368,11 @@ public class SaveImage { if(hasFusion) { previewBmp = flattenFusion(Uri.parse(fusionRep.getUnderlay()), mPreviewImage, Math.max(mPreviewImage.getWidth(), mPreviewImage.getHeight()), 0); + // If we fail to flatten, save original image + if(previewBmp == null) { + previewBmp = mPreviewImage; + hasFusion = false; + } } else { previewBmp = mPreviewImage; } @@ -447,9 +452,10 @@ public class SaveImage { if(hasFusion) { Bitmap underlay = flattenFusion( Uri.parse(fusionRep.getUnderlay()), bitmap, 0, sampleSize); - - bitmap.recycle(); - bitmap = underlay; + if(underlay != null) { + bitmap.recycle(); + bitmap = underlay; + } } updateProgress(); @@ -820,26 +826,27 @@ public class SaveImage { underlay = ImageLoader.loadBitmapWithBackouts(mContext, underlayUri, sampleSize); } - RectF destRect = new RectF(); - Rect imageBounds = MasterImage.getImage().getImageBounds(); - Rect underlayBounds = MasterImage.getImage().getFusionBounds(); - float underlayScaleFactor = (float)underlay.getWidth() - / (float)underlayBounds.width(); - - destRect.left = (imageBounds.left - underlayBounds.left) * underlayScaleFactor; - destRect.right = (imageBounds.right - underlayBounds.left) * underlayScaleFactor; - destRect.top = (imageBounds.top - underlayBounds.top) * underlayScaleFactor; - destRect.bottom = (imageBounds.bottom - underlayBounds.top) * underlayScaleFactor; - - Canvas canvas = new Canvas(underlay); - Paint paint = new Paint(); - paint.reset(); - paint.setAntiAlias(true); - paint.setFilterBitmap(true); - paint.setDither(true); - - canvas.drawBitmap(bitmap, null, destRect, paint); - + if(underlay != null) { + RectF destRect = new RectF(); + Rect imageBounds = MasterImage.getImage().getImageBounds(); + Rect underlayBounds = MasterImage.getImage().getFusionBounds(); + float underlayScaleFactor = (float)underlay.getWidth() + / (float)underlayBounds.width(); + + destRect.left = (imageBounds.left - underlayBounds.left) * underlayScaleFactor; + destRect.right = (imageBounds.right - underlayBounds.left) * underlayScaleFactor; + destRect.top = (imageBounds.top - underlayBounds.top) * underlayScaleFactor; + destRect.bottom = (imageBounds.bottom - underlayBounds.top) * underlayScaleFactor; + + Canvas canvas = new Canvas(underlay); + Paint paint = new Paint(); + paint.reset(); + paint.setAntiAlias(true); + paint.setFilterBitmap(true); + paint.setDither(true); + + canvas.drawBitmap(bitmap, null, destRect, paint); + } return underlay; } } diff --git a/src/com/android/gallery3d/filtershow/tools/TruePortraitNativeEngine.java b/src/com/android/gallery3d/filtershow/tools/TruePortraitNativeEngine.java index 03972638c..16cf27d16 100644 --- a/src/com/android/gallery3d/filtershow/tools/TruePortraitNativeEngine.java +++ b/src/com/android/gallery3d/filtershow/tools/TruePortraitNativeEngine.java @@ -183,20 +183,6 @@ public class TruePortraitNativeEngine { for(StrokeData sd:edits) { drawEdit(canvas, sd); } - - // DEBUG - for(int i = 0; i<mPreviewSize.y; i++) { - StringBuilder sb = new StringBuilder(); - sb.append("[ "); - for(int j = 0; j<mPreviewSize.x; j++) { - int pixel = mUpdateBm.getPixel(j, i); - sb.append(Color.alpha(pixel)); - sb.append(" "); - } - sb.append("]"); - Log.e(TAG, sb.toString()); - } - // return nativeUpdatePreviewMask(mUpdateBm); } diff --git a/src/com/android/gallery3d/filtershow/ui/AlertMsgDialog.java b/src/com/android/gallery3d/filtershow/ui/AlertMsgDialog.java index 2041eb2ce..252e32ca7 100644 --- a/src/com/android/gallery3d/filtershow/ui/AlertMsgDialog.java +++ b/src/com/android/gallery3d/filtershow/ui/AlertMsgDialog.java @@ -51,7 +51,7 @@ public class AlertMsgDialog extends DialogFragment { ab.setTitle(mTitleId); ab.setMessage(mMessageId); ab.setCancelable(false); - ab.setNeutralButton(R.string.ok, null); + ab.setPositiveButton(R.string.ok, null); return ab.create(); } } diff --git a/src/com/android/gallery3d/filtershow/ui/DoNotShowAgainDialog.java b/src/com/android/gallery3d/filtershow/ui/DoNotShowAgainDialog.java index aad403bd1..e9245d540 100644 --- a/src/com/android/gallery3d/filtershow/ui/DoNotShowAgainDialog.java +++ b/src/com/android/gallery3d/filtershow/ui/DoNotShowAgainDialog.java @@ -48,11 +48,13 @@ public class DoNotShowAgainDialog extends DialogFragment { private int mTitleId; private int mMessageId; private CheckBox mDoNotShowAgainChk; + private DialogInterface.OnClickListener mButtonClickListener; public DoNotShowAgainDialog(int titleId, int msgId, int sharedPrefKeyId) { mTitleId = titleId; mMessageId = msgId; mSharedPrefKeyId = sharedPrefKeyId; + mButtonClickListener = null; } @Override @@ -67,13 +69,18 @@ public class DoNotShowAgainDialog extends DialogFragment { ab.setTitle(mTitleId); ab.setView(view); ab.setCancelable(false); - ab.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { + ab.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Context context = getActivity(); GalleryUtils.setBooleanPref(context, context.getString(mSharedPrefKeyId), mDoNotShowAgainChk.isChecked()); + if(mButtonClickListener != null) mButtonClickListener.onClick(dialog, id); } }); return ab.create(); } + + public void setOnOkButtonClickListener(DialogInterface.OnClickListener listener) { + mButtonClickListener = listener; + } } diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java index 4765c6838..04d361a19 100644 --- a/src/com/android/gallery3d/ui/ActionModeHandler.java +++ b/src/com/android/gallery3d/ui/ActionModeHandler.java @@ -138,6 +138,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi } public void startActionMode() { + mMenuExecutor.setLeaving(false); Activity a = mActivity; // mActionMode = a.startActionMode(this); mActionMode = mActivity.getToolbar().startActionMode(this); @@ -213,6 +214,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi if (itemId == R.id.action_select_all) { updateSupportedOperation(); mMenuExecutor.onMenuClicked(itemId, null, false, true); + mSelectionMenu.setLeaving(mMenuExecutor.isLeaving()); } return true; } finally { diff --git a/src/com/android/gallery3d/ui/EdgeView.java b/src/com/android/gallery3d/ui/EdgeView.java index 051de18fa..dc648b457 100644..100755 --- a/src/com/android/gallery3d/ui/EdgeView.java +++ b/src/com/android/gallery3d/ui/EdgeView.java @@ -49,6 +49,10 @@ public class EdgeView extends GLView { } } + public void release () { + mEffect = null; + } + @Override protected void onLayout( boolean changeSize, int left, int top, int right, int bottom) { diff --git a/src/com/android/gallery3d/ui/MenuExecutor.java b/src/com/android/gallery3d/ui/MenuExecutor.java index c57e848e3..8f3409131 100644 --- a/src/com/android/gallery3d/ui/MenuExecutor.java +++ b/src/com/android/gallery3d/ui/MenuExecutor.java @@ -67,6 +67,7 @@ public class MenuExecutor { // wait the operation to finish when we want to stop it. private boolean mWaitOnStop; private boolean mPaused; + private boolean isLeaving = false; private final AbstractGalleryActivity mActivity; private final SelectionManager mSelectionManager; @@ -233,6 +234,14 @@ public class MenuExecutor { return new Intent(action).setDataAndType(manager.getContentUri(path), mimeType); } + public void setLeaving(boolean leaving) { + isLeaving = leaving; + } + + public boolean isLeaving() { + return isLeaving; + } + private void onMenuClicked(int action, ProgressListener listener) { onMenuClicked(action, listener, false, true); } @@ -243,6 +252,7 @@ public class MenuExecutor { switch (action) { case R.id.action_select_all: if (mSelectionManager.inSelectAllMode()) { + isLeaving = true; mSelectionManager.deSelectAll(); } else { mSelectionManager.selectAll(); diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 7ee799c03..68ce55f91 100755 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -1384,6 +1384,11 @@ public class PhotoView extends GLView { hideUndoBar(); } + public void destroy() { + mEdgeView.release(); + mEdgeView = null; + } + public void resume() { mTileView.prepareTextures(); mPositionController.skipToFinalPosition(); diff --git a/src/com/android/gallery3d/ui/SelectionMenu.java b/src/com/android/gallery3d/ui/SelectionMenu.java index 4ee60b437..07815cd80 100644 --- a/src/com/android/gallery3d/ui/SelectionMenu.java +++ b/src/com/android/gallery3d/ui/SelectionMenu.java @@ -31,6 +31,7 @@ public class SelectionMenu implements OnClickListener { private final Context mContext; private final Button mButton; private final PopupList mPopupList; + private boolean isLeaving = false; public SelectionMenu(Context context, Button button, OnPopupItemClickListener listener) { mContext = context; @@ -44,6 +45,7 @@ public class SelectionMenu implements OnClickListener { @Override public void onClick(View v) { + if (isLeaving) return; mPopupList.show(); } @@ -58,4 +60,8 @@ public class SelectionMenu implements OnClickListener { public void setTitle(CharSequence title) { mButton.setText(title); } + + public void setLeaving(boolean leaving) { + isLeaving = leaving; + } } diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java index 16e2fc129..05bc9aff5 100644 --- a/src/com/android/gallery3d/ui/TileImageView.java +++ b/src/com/android/gallery3d/ui/TileImageView.java @@ -90,7 +90,6 @@ public class TileImageView extends GLView { private int mOffsetX; private int mOffsetY; - private int mUploadQuota; private boolean mRenderComplete; private final RectF mSourceRect = new RectF(); @@ -404,7 +403,6 @@ public class TileImageView extends GLView { @Override protected void render(GLCanvas canvas) { - mUploadQuota = UPLOAD_LIMIT; mRenderComplete = true; int level = mLevel; @@ -560,12 +558,10 @@ public class TileImageView extends GLView { @Override public boolean onGLIdle(GLCanvas canvas, boolean renderRequested, long dueTime) { - // Skips uploading if there is a pending rendering request. - // Returns true to keep uploading in next rendering loop. - if (renderRequested) return true; - int quota = UPLOAD_LIMIT; + long now = System.nanoTime(); + long uploadTime = 0; Tile tile = null; - while (quota > 0) { + while (now + uploadTime < dueTime) { synchronized (TileImageView.this) { tile = mUploadQueue.pop(); } @@ -575,8 +571,10 @@ public class TileImageView extends GLView { Utils.assertTrue(tile.mTileState == STATE_DECODED); tile.updateContent(canvas); if (!hasBeenLoaded) tile.draw(canvas, 0, 0); - --quota; } + long t1 = System.nanoTime(); + uploadTime = t1 - now; + now = t1; } if (tile == null) mActive.set(false); return tile != null; @@ -596,13 +594,8 @@ public class TileImageView extends GLView { if (tile != null) { if (!tile.isContentValid()) { if (tile.mTileState == STATE_DECODED) { - if (mUploadQuota > 0) { - --mUploadQuota; - tile.updateContent(canvas); - } else { - mRenderComplete = false; - } - } else if (tile.mTileState != STATE_DECODE_FAIL){ + mRenderComplete = false; + } else if (tile.mTileState != STATE_DECODE_FAIL) { mRenderComplete = false; queueForDecode(tile); } diff --git a/src/com/android/gallery3d/ui/TimeLineSlotView.java b/src/com/android/gallery3d/ui/TimeLineSlotView.java index 329ea75e3..7dcf4ef5f 100644..100755 --- a/src/com/android/gallery3d/ui/TimeLineSlotView.java +++ b/src/com/android/gallery3d/ui/TimeLineSlotView.java @@ -589,7 +589,9 @@ public class TimeLineSlotView extends GLView { if (mSlotCount != null) { Slot begin = getSlotByPosition(0, mScrollPosition, true, false), end = getSlotByPosition(0, mScrollPosition + mHeight, true, true); - if (begin != null && end != null) { + if (begin == null && end != null && end.index == 0) { + setVisibleRange(0, 0); + } else if (begin != null && end != null) { setVisibleRange(begin.index, end.index); } } |
