summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
authorpezhan <pezhan@codeaurora.org>2017-01-09 11:19:54 +0800
committerpezhan <pezhan@codeaurora.org>2017-01-11 15:20:31 +0800
commit326822d1e444da7b227be3c86815e3ee6eb6453d (patch)
tree09fa64a75d294bbd63faf5298d861197d5e30478 /src/com/android/camera
parent15f6d966c807c371a12f68bf9f5f4e7447a9ba8e (diff)
downloadandroid_packages_apps_Snap-326822d1e444da7b227be3c86815e3ee6eb6453d.tar.gz
android_packages_apps_Snap-326822d1e444da7b227be3c86815e3ee6eb6453d.tar.bz2
android_packages_apps_Snap-326822d1e444da7b227be3c86815e3ee6eb6453d.zip
SnapdragonCamera:Fix [FR35432] BestPicture function lost.
Add dialog when saving selected BestPicture. Add "X" icon display beside camcorder icon to exit BestPicture mode. Add multiple selections(Three dots beside SAVE)and "X" icon. Add dialog when select "X" icon. Add overflow menu with multiple selections to chose "Save All" or "Delete All" when click overflow menu. Add click for "Save All" to save all 1o pictures. Add click for "Delete All" to pop delete all dialog. Change-Id: I59cdad0f77fde616ea34db4d9d186d322285e394 CRs-Fixed: 1102814, 1102807, 1099428
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/BestpictureActivity.java320
-rw-r--r--src/com/android/camera/CaptureModule.java16
-rwxr-xr-xsrc/com/android/camera/CaptureUI.java15
-rw-r--r--src/com/android/camera/SettingsManager.java5
-rw-r--r--src/com/android/camera/ui/BestPictureActionDialogLayout.java135
-rw-r--r--src/com/android/camera/ui/OneUICameraControls.java8
-rw-r--r--src/com/android/camera/util/CameraUtil.java37
7 files changed, 514 insertions, 22 deletions
diff --git a/src/com/android/camera/BestpictureActivity.java b/src/com/android/camera/BestpictureActivity.java
index 1fec1d82c..45c45ed4b 100644
--- a/src/com/android/camera/BestpictureActivity.java
+++ b/src/com/android/camera/BestpictureActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 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
@@ -28,6 +28,8 @@
*/
package com.android.camera;
+import android.app.AlertDialog;
+import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -42,15 +44,22 @@ import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Display;
+import android.view.Gravity;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.support.v4.app.FragmentActivity;
+import android.widget.CheckBox;
+import android.widget.PopupWindow;
+import android.widget.TextView;
import android.widget.Toast;
import com.android.camera.exif.ExifInterface;
+import com.android.camera.ui.BestPictureActionDialogLayout;
import com.android.camera.ui.DotsView;
import com.android.camera.ui.DotsViewItem;
import com.android.camera.ui.RotateTextToast;
+import com.android.camera.ui.RotateImageView;
import com.android.camera.util.CameraUtil;
import org.codeaurora.snapcam.R;
@@ -61,7 +70,9 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
-public class BestpictureActivity extends FragmentActivity{
+import static android.app.Activity.RESULT_OK;
+
+public class BestpictureActivity extends FragmentActivity {
private static final String TAG = "BestpictureActivity";
public static final String[] NAMES = {
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09"
@@ -81,6 +92,11 @@ public class BestpictureActivity extends FragmentActivity{
private ImageLoadingThread mLoadingThread;
private PhotoModule.NamedImages mNamedImages;
private Uri mPlaceHolderUri;
+ private Dialog mDialog;
+ private AlertDialog.Builder mBuilder;
+ private View mDialogRoot;
+ private CheckBox mshowAgainCheck;
+
public static int BESTPICTURE_ACTIVITY_CODE = 11;
static class ImageItems implements DotsViewItem {
@@ -172,23 +188,303 @@ public class BestpictureActivity extends FragmentActivity{
findViewById(R.id.bestpicture_done).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
- int index = -1;
- for(int i=0; i < mImageItems.mChosen.length; i++) {
+ int choosenCount = 0;
+ for (int i = 0; i < mImageItems.mChosen.length; i++) {
if (mImageItems.mChosen[i]) {
- if(index != -1) {
- new SaveImageTask().execute(mFilesPath + "/" + NAMES[i] + ".jpg");
- } else {
- index = i;
- saveForground(mFilesPath + "/" + NAMES[i] + ".jpg");
- }
+ choosenCount++;
}
}
- setResult(RESULT_OK, new Intent());
- finish();
+ boolean showSaveDialog = CameraUtil.loadDialogShowConfig(BestpictureActivity
+ .this,CameraUtil.KEY_SAVE);
+ if (showSaveDialog) {
+ //add save dialog
+ initSaveDialog(CameraUtil.MODE_TWO_BT, choosenCount);
+ mDialog.show();
+ setDialogLayoutPararms();
+ } else {
+ saveImages(choosenCount, false);
+ }
+ }
+ });
+ findViewById(R.id.delete_best).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+ boolean showDeleteDialog = CameraUtil.loadDialogShowConfig(BestpictureActivity.this
+ ,CameraUtil.KEY_DELETE);
+ if (showDeleteDialog) {
+ initDeleteDialog(CameraUtil.MODE_TWO_BT);
+ mDialog.show();
+ setDialogLayoutPararms();
+ } else {
+ backToViewfinder();
+ }
+ }
+ });
+ RotateImageView moreView = (RotateImageView) findViewById(R.id.best_more);
+ Bitmap mMoreBp = BitmapFactory.decodeResource(getResources(), R.drawable.more_options);
+ mMoreBp = CameraUtil.adjustPhotoRotation(mMoreBp, 90);
+ moreView.setImageBitmap(mMoreBp);
+ moreView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(final View v) {
+ initOverFlow(v);
+ }
+ });
+ }
+
+ private void initOverFlow(View v) {
+ View popView = getLayoutInflater().inflate(R.layout.overflow, null);
+ PopupWindow pop = new PopupWindow(popView, CameraUtil.dip2px(BestpictureActivity.this, 150),
+ CameraUtil.dip2px(BestpictureActivity.this, 100), true);
+ pop.setOutsideTouchable(true);
+ pop.showAtLocation(v, Gravity.RIGHT | Gravity.TOP,
+ CameraUtil.dip2px(BestpictureActivity.this, 5),
+ CameraUtil.dip2px(BestpictureActivity.this, 10));
+ TextView saveAllText = (TextView) popView.findViewById(R.id.overflow_item1);
+ TextView deleteAllText = (TextView) popView.findViewById(R.id.overflow_item2);
+ saveAllText.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ pop.dismiss();
+ saveImages(mImageItems.mChosen.length, true);
+
+ }
+ });
+ deleteAllText.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ pop.dismiss();
+ boolean showDeleteAllDialog = CameraUtil.loadDialogShowConfig(
+ BestpictureActivity.this, CameraUtil.KEY_DELETE_ALL);
+ if (showDeleteAllDialog) {
+ initDeleteAllDialog(CameraUtil.MODE_TWO_BT);
+ mDialog.show();
+ setDialogLayoutPararms();
+ } else {
+ backToViewfinder();
+ }
+ }
+ });
+ }
+
+ private void initDeleteDialog(int mode) {
+ BestPictureActionDialogLayout layout = getDialogLayout(mode);
+ layout.setDialogDataControler(mDialogRoot, new BestPictureActionDialogLayout
+ .IDialogDataControler() {
+ @Override
+ public String getTitleString() {
+ return getResources().getString(R.string.delete_best_dialog_title);
+ }
+
+ @Override
+ public String getContentString() {
+ return getResources().getString(R.string.delete_best_dialog_content);
+ }
+
+ @Override
+ public String getPositionButtonString() {
+ return getResources().getString(R.string.delete_best_dialog_positive_bt);
+ }
+
+ @Override
+ public String getNativeButtonString() {
+ return getResources().getString(R.string.delete_best_dialog_native_bt);
+ }
+
+ @Override
+ public String getOKButtonString() {
+ return "";
+ }
+
+ @Override
+ public void doClickPositionBtAction() {
+ if (mshowAgainCheck.isChecked()) {
+ CameraUtil.saveDialogShowConfig(BestpictureActivity.this,
+ CameraUtil.KEY_DELETE, false);
+ }
+ mDialog.dismiss();
+ backToViewfinder();
+ }
+
+ @Override
+ public void doClickNativeBtAction() {
+ if (mshowAgainCheck.isChecked()) {
+ CameraUtil.saveDialogShowConfig(BestpictureActivity.this,
+ CameraUtil.KEY_DELETE, false);
+ }
+ mDialog.dismiss();
+ }
+
+ @Override
+ public void doClickOKBtAction() {
+ }
+ });
+ }
+
+ private void initDeleteAllDialog(int mode) {
+ BestPictureActionDialogLayout layout = getDialogLayout(mode);
+ layout.setDialogDataControler(mDialogRoot, new BestPictureActionDialogLayout
+ .IDialogDataControler() {
+ @Override
+ public String getTitleString() {
+ return getResources().getString(R.string.delete_all_best_dialog_title);
+ }
+
+ @Override
+ public String getContentString() {
+ return getResources().getString(R.string.delete_all_best_dialog_content);
+ }
+
+ @Override
+ public String getPositionButtonString() {
+ return getResources().getString(R.string.delete_all_best_dialog_positive_bt);
+ }
+
+ @Override
+ public String getNativeButtonString() {
+ return getResources().getString(R.string.delete_all_best_dialog_native_bt);
+ }
+
+ @Override
+ public String getOKButtonString() {
+ return "";
+ }
+
+ @Override
+ public void doClickPositionBtAction() {
+ if (mshowAgainCheck.isChecked()) {
+ CameraUtil.saveDialogShowConfig(BestpictureActivity.this,
+ CameraUtil.KEY_DELETE_ALL, false);
+ }
+ mDialog.dismiss();
+ backToViewfinder();
+ }
+
+ @Override
+ public void doClickNativeBtAction() {
+ if (mshowAgainCheck.isChecked()) {
+ CameraUtil.saveDialogShowConfig(BestpictureActivity.this,
+ CameraUtil.KEY_DELETE_ALL, false);
+ }
+ mDialog.dismiss();
+ }
+
+ @Override
+ public void doClickOKBtAction() {
}
});
}
+ private void initSaveDialog(int mode, int choosenCount) {
+
+ BestPictureActionDialogLayout layout = getDialogLayout(mode);
+ layout.setDialogDataControler(mDialogRoot, new BestPictureActionDialogLayout
+ .IDialogDataControler() {
+
+ @Override
+ public String getTitleString() {
+ return getResources().getString(R.string.save_best_dialog_title);
+ }
+
+ @Override
+ public String getContentString() {
+ return getResources().getString(R.string.save_best_dialog_content, choosenCount);
+ }
+
+ @Override
+ public String getPositionButtonString() {
+ return getResources().getString(R.string.save_best_dialog_positive_bt);
+ }
+
+ @Override
+ public String getNativeButtonString() {
+ return getResources().getString(R.string.save_best_dialog_native_bt);
+ }
+
+ @Override
+ public String getOKButtonString() {
+ return "";
+ }
+
+ @Override
+ public void doClickPositionBtAction() {
+ if (mshowAgainCheck.isChecked()) {
+ CameraUtil.saveDialogShowConfig(BestpictureActivity.this,
+ CameraUtil.KEY_SAVE, false);
+ }
+ mDialog.dismiss();
+ saveImages(choosenCount, false);
+ }
+
+ @Override
+ public void doClickNativeBtAction() {
+ if (mshowAgainCheck.isChecked()) {
+ CameraUtil.saveDialogShowConfig(BestpictureActivity.this,
+ CameraUtil.KEY_SAVE, false);
+ }
+ mDialog.dismiss();
+ }
+
+ @Override
+ public void doClickOKBtAction() {
+ mDialog.dismiss();
+ }
+ });
+ }
+
+ private BestPictureActionDialogLayout getDialogLayout(int mode) {
+ BestPictureActionDialogLayout layout;
+ mBuilder = new AlertDialog.Builder(BestpictureActivity.this);
+ mDialogRoot = LayoutInflater.from(BestpictureActivity.this)
+ .inflate(R.layout.bestpicture_action_dialog, null);
+ mDialogRoot.setTag(mode);
+ mBuilder.setView(mDialogRoot);
+ mDialog = mBuilder.create();
+ layout = (BestPictureActionDialogLayout) mDialogRoot.findViewById(R.id.mlayout);
+ mshowAgainCheck = (CheckBox) mDialogRoot.findViewById(R.id.mcheck);
+ return layout;
+ }
+
+ private void setDialogLayoutPararms() {
+ //measure and layout width and height for dialog.
+ int width = CameraUtil.dip2px(BestpictureActivity.this, 320);
+ int height = CameraUtil.dip2px(BestpictureActivity.this, 250);
+ mDialog.getWindow().setLayout(width, height);
+ }
+
+ private void saveImages(int toSaveCount, boolean saveAll) {
+ int index = -1;
+ for (int i = 0; i < mImageItems.mChosen.length; i++) {
+ if (saveAll) {
+ if (index != -1) {
+ new SaveImageTask().execute(mFilesPath + "/" + NAMES[i] + ".jpg");
+ } else {
+ index = i;
+ saveForground(mFilesPath + "/" + NAMES[i] + ".jpg");
+ }
+ } else {
+ if (mImageItems.mChosen[i]) {
+ if (index != -1) {
+ new SaveImageTask().execute(mFilesPath + "/" + NAMES[i] + ".jpg");
+ } else {
+ index = i;
+ saveForground(mFilesPath + "/" + NAMES[i] + ".jpg");
+ }
+ }
+ }
+ }
+ String toastString = getResources().getString(R.string.save_best_image_toast,
+ toSaveCount);
+ Toast.makeText(BestpictureActivity.this, toastString, Toast.LENGTH_SHORT).show();
+ backToViewfinder();
+ }
+
+ private void backToViewfinder() {
+ setResult(RESULT_OK, new Intent());
+ finish();
+ }
+
+
private class ImageLoadingThread extends Thread {
public void run() {
showProgressDialog();
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 26613786f..84c1e6911 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -554,14 +554,16 @@ public class CaptureModule implements CameraModule, PhotoController,
Face[] faces = result.get(CaptureResult.STATISTICS_FACES);
updateFaceView(faces);
-
- int[] histogramStats = result.get(CaptureModule.histogramStats);
- if (histogramStats != null && mHiston) {
- /*The first element in the array stores max hist value . Stats data begin from second value*/
- synchronized(statsdata) {
- System.arraycopy(histogramStats,0,statsdata,0,1024);
+ if (SettingsManager.getInstance().isHistogramSupport()) {
+ int[] histogramStats = result.get(CaptureModule.histogramStats);
+ if (histogramStats != null && mHiston) {
+ /*The first element in the array stores max hist value . Stats data begin
+ from second value*/
+ synchronized (statsdata) {
+ System.arraycopy(histogramStats, 0, statsdata, 0, 1024);
+ }
+ updateGraghView();
}
- updateGraghView();
}
}
processCaptureResult(result);
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index 8bbbf1753..85d044eeb 100755
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2012 The Android Open Source Project
@@ -101,6 +101,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
private static final int FILTER_MENU_ON = 2;
private static final int ANIMATION_DURATION = 300;
private static final int CLICK_THRESHOLD = 200;
+ private static final int AUTOMATIC_MODE = 0;
private CameraActivity mActivity;
private View mRootView;
private View mPreviewCover;
@@ -199,6 +200,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
private RotateLayout mSceneModeLabelRect;
private LinearLayout mSceneModeLabelView;
private TextView mSceneModeName;
+ private ImageView mExitBestMode;
private ImageView mSceneModeLabelCloseIcon;
private AlertDialog mSceneModeInstructionalDialog = null;
@@ -280,6 +282,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay);
mShutterButton = (ShutterButton) mRootView.findViewById(R.id.shutter_button);
mVideoButton = (ImageView) mRootView.findViewById(R.id.video_button);
+ mExitBestMode = (ImageView) mRootView.findViewById(R.id.exit_best_mode);
mFilterModeSwitcher = mRootView.findViewById(R.id.filter_mode_switcher);
mSceneModeSwitcher = mRootView.findViewById(R.id.scene_mode_switcher);
mFrontBackSwitcher = mRootView.findViewById(R.id.front_back_switcher);
@@ -362,6 +365,14 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
}
});
+ mExitBestMode.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ SettingsManager.getInstance().setValueIndex(SettingsManager.KEY_SCENE_MODE,
+ AUTOMATIC_MODE);
+ }
+ });
+
RotateImageView muteButton = (RotateImageView) mRootView.findViewById(R.id.mute_button);
muteButton.setVisibility(View.GONE);
@@ -840,8 +851,10 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
if ( index > 0 && index < sceneModeNameArray.length ) {
mSceneModeName.setText(sceneModeNameArray[index]);
mSceneModeLabelRect.setVisibility(View.VISIBLE);
+ mExitBestMode.setVisibility(View.VISIBLE);
}else{
mSceneModeLabelRect.setVisibility(View.GONE);
+ mExitBestMode.setVisibility(View.GONE);
}
}
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index 3ce646049..eadc322aa 100644
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -1306,6 +1306,11 @@ public class SettingsManager implements ListMenu.SettingsListener {
return modes;
}
+ public boolean isHistogramSupport(){
+ String value = getValue(KEY_HISTOGRAM);
+ return value != null && value.equals("enable");
+ }
+
public boolean isCamera2HDRSupport(){
String value = getValue(KEY_HDR);
return value != null && value.equals("enable");
diff --git a/src/com/android/camera/ui/BestPictureActionDialogLayout.java b/src/com/android/camera/ui/BestPictureActionDialogLayout.java
new file mode 100644
index 000000000..d0d7d4be1
--- /dev/null
+++ b/src/com/android/camera/ui/BestPictureActionDialogLayout.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2017, 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.
+ */
+package com.android.camera.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import com.android.camera.util.CameraUtil;
+import org.codeaurora.snapcam.R;
+
+
+public class BestPictureActionDialogLayout extends RelativeLayout implements View.OnClickListener {
+
+ private TextView mTitleText;
+ private TextView mContent;
+ private Button mNativeBt;
+ private Button mPositiveBt;
+ private Button mOKButton;
+ int mode;
+ private IDialogDataControler mDialogDataControler;
+
+ public interface IDialogDataControler {
+
+ String getTitleString();
+
+ String getContentString();
+
+ String getPositionButtonString();
+
+ String getNativeButtonString();
+
+ String getOKButtonString();
+
+ void doClickPositionBtAction();
+
+ void doClickNativeBtAction();
+
+ void doClickOKBtAction();
+ }
+
+ public BestPictureActionDialogLayout(Context context) {
+ this(context, null);
+ }
+
+ public BestPictureActionDialogLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public BestPictureActionDialogLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+
+ public void setDialogDataControler(View root, IDialogDataControler dialogDataControler) {
+ mode = (int) root.getTag();
+ mTitleText = (TextView) root.findViewById(R.id.mtitle);
+ mContent = (TextView) root.findViewById(R.id.content);
+ mNativeBt = (Button) root.findViewById(R.id.nativebt);
+ mPositiveBt = (Button) root.findViewById(R.id.positivebt);
+ mNativeBt.setOnClickListener(this);
+ mPositiveBt.setOnClickListener(this);
+ mOKButton = (Button) root.findViewById(R.id.okbt);
+ mOKButton.setOnClickListener(this);
+ mDialogDataControler = dialogDataControler;
+ setViewData();
+ }
+
+ private void setViewData() {
+ mTitleText.setText(mDialogDataControler.getTitleString());
+ mContent.setText(mDialogDataControler.getContentString());
+ if (mode == CameraUtil.MODE_TWO_BT) {
+ mNativeBt.setText(mDialogDataControler.getNativeButtonString());
+ mPositiveBt.setText(mDialogDataControler.getPositionButtonString());
+ mOKButton.setVisibility(View.GONE);
+ mNativeBt.setVisibility(View.VISIBLE);
+ mPositiveBt.setVisibility(View.VISIBLE);
+ } else if (mode == CameraUtil.MODE_ONE_BT) {
+ mOKButton.setText(mDialogDataControler.getOKButtonString());
+ mOKButton.setVisibility(View.VISIBLE);
+ mNativeBt.setVisibility(View.GONE);
+ mPositiveBt.setVisibility(View.GONE);
+ }
+
+ invalidate();
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.positivebt:
+ mDialogDataControler.doClickPositionBtAction();
+ break;
+
+ case R.id.nativebt:
+ mDialogDataControler.doClickNativeBtAction();
+ break;
+
+ case R.id.okbt:
+ mDialogDataControler.doClickOKBtAction();
+ break;
+
+ default:
+ break;
+ }
+ }
+}
diff --git a/src/com/android/camera/ui/OneUICameraControls.java b/src/com/android/camera/ui/OneUICameraControls.java
index a79211c42..85bd1b5ce 100644
--- a/src/com/android/camera/ui/OneUICameraControls.java
+++ b/src/com/android/camera/ui/OneUICameraControls.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -46,6 +46,7 @@ public class OneUICameraControls extends RotatableLayout {
private View mShutter;
private View mVideoShutter;
+ private View mExitBestPhotpMode;
private View mPauseButton;
private View mFlashButton;
private View mMute;
@@ -141,6 +142,7 @@ public class OneUICameraControls extends RotatableLayout {
super.onFinishInflate();
mShutter = findViewById(R.id.shutter_button);
mVideoShutter = findViewById(R.id.video_button);
+ mExitBestPhotpMode = findViewById(R.id.exit_best_mode);
mPauseButton = findViewById(R.id.video_pause);
mFrontBackSwitcher = findViewById(R.id.front_back_switcher);
mTsMakeupSwitcher = findViewById(R.id.ts_makeup_switcher);
@@ -346,6 +348,7 @@ public class OneUICameraControls extends RotatableLayout {
setLocation(mPauseButton, false, 3.15f);
setLocation(mShutter, false , 0.85f);
setLocation(mVideoShutter, false, 2);
+ setLocation(mExitBestPhotpMode ,false, 4);
} else {
setLocation(mFrontBackSwitcher, true, 2);
setLocation(mTsMakeupSwitcher, true, 3);
@@ -361,6 +364,7 @@ public class OneUICameraControls extends RotatableLayout {
setLocation(mPreview, false, 0);
setLocation(mVideoShutter, false, 3.15f);
}
+ setLocation(mExitBestPhotpMode ,false, 4);
}
setLocationCustomBottom(mMakeupSeekBarLayout, 0, 1);
setLocation(mProModeCloseButton, false, 4);
@@ -500,7 +504,7 @@ public class OneUICameraControls extends RotatableLayout {
View[] views = {
mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
mTsMakeupSwitcher, mFlashButton, mPreview, mMute, mShutter, mVideoShutter,
- mMakeupSeekBarLowText, mMakeupSeekBarHighText, mPauseButton
+ mMakeupSeekBarLowText, mMakeupSeekBarHighText, mPauseButton, mExitBestPhotpMode
};
for (View v : views) {
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index cb414bac0..bcecae7f8 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -25,6 +25,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
@@ -87,6 +88,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import static android.content.Context.MODE_PRIVATE;
+
/**
* Collection of utility functions used in this package.
*/
@@ -144,6 +147,12 @@ public class CameraUtil {
public static final int RATIO_16_9 = 1;
public static final int RATIO_4_3 = 2;
public static final int RATIO_3_2 = 3;
+ public static final int MODE_TWO_BT = 1;
+ public static final int MODE_ONE_BT = 0;
+ private static final String DIALOG_CONFIG = "dialog_config";
+ public static final String KEY_SAVE = "save";
+ public static final String KEY_DELETE = "delete";
+ public static final String KEY_DELETE_ALL = "delete_all";
public static boolean isSupported(String value, List<String> supported) {
return supported == null ? false : supported.indexOf(value) >= 0;
@@ -1369,4 +1378,32 @@ public class CameraUtil {
return Collections.unmodifiableList(requestList);
}
+
+ public static int dip2px(Context context, float dpValue) {
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (dpValue * scale + 0.5f);
+ }
+
+ public static void saveDialogShowConfig(Context context, String key, boolean needRequest) {
+ SharedPreferences sp = context.getSharedPreferences(DIALOG_CONFIG, MODE_PRIVATE);
+ SharedPreferences.Editor editor = sp.edit();
+ editor.putBoolean(key, needRequest);
+ editor.apply();
+ }
+
+ public static boolean loadDialogShowConfig(Context context, String key) {
+ SharedPreferences sp = context.getSharedPreferences(DIALOG_CONFIG, MODE_PRIVATE);
+ return sp.getBoolean(key, true);
+ }
+
+ public static Bitmap adjustPhotoRotation(Bitmap bm, final int orientationDegree) {
+ Matrix m = new Matrix();
+ m.setRotate(orientationDegree, (float) bm.getWidth() / 2, (float) bm.getHeight() / 2);
+ try {
+ return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), m, true);
+ } catch (OutOfMemoryError ex) {
+ ex.printStackTrace();
+ }
+ return null;
+ }
}