summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2016-09-30 17:47:44 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-10-13 16:33:07 -0700
commit0dbfdffc9994a17e60c57b17c3cc5743cc75e155 (patch)
tree211f7564226f8e7a52b2c9344eac5b24812ba779
parent392d833321dd0d05aeb80bd33240394ea9ea5591 (diff)
downloadandroid_packages_apps_Snap-0dbfdffc9994a17e60c57b17c3cc5743cc75e155.tar.gz
android_packages_apps_Snap-0dbfdffc9994a17e60c57b17c3cc5743cc75e155.tar.bz2
android_packages_apps_Snap-0dbfdffc9994a17e60c57b17c3cc5743cc75e155.zip
SnapdragonCamera: Add help menu to camera2
Add help menu to camera2 CRs-Fixed: 1066519 Change-Id: Id15f5ffe8d52ac5a2eabab20791fce65e97bcf43
-rw-r--r--res/layout/capture_module.xml6
-rw-r--r--res/values/attrs.xml3
-rw-r--r--res/values/styles.xml5
-rw-r--r--src/com/android/camera/CaptureUI.java35
-rw-r--r--src/com/android/camera/ui/MenuHelp.java14
-rw-r--r--src/com/android/camera/ui/OneUICameraControls.java3
6 files changed, 59 insertions, 7 deletions
diff --git a/res/layout/capture_module.xml b/res/layout/capture_module.xml
index 4b9a178c0..fc05fd0ca 100644
--- a/res/layout/capture_module.xml
+++ b/res/layout/capture_module.xml
@@ -24,6 +24,7 @@
layout. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
@@ -95,4 +96,9 @@
style="@style/CameraControls"
layout="@layout/one_ui_layout"
android:layout_gravity="center" />
+
+ <include
+ style="@style/CameraControls"
+ layout="@layout/menu_help"
+ android:layout_gravity="center" />
</merge>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index a243e5fa6..bf79746a3 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -45,4 +45,7 @@
<attr name="images" format="reference" />
</declare-styleable>
+ <declare-styleable name="MenuHelp">
+ <attr name="forCamera2" format="boolean"/>
+ </declare-styleable>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 765210fe2..082c5ed8a 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -267,9 +267,8 @@
<item name="android:scaleType">center</item>
</style>
<style name="OneUIMenuButton">
- <item name="android:layout_width">45dp</item>
- <item name="android:layout_height">45dp</item>
- <item name="android:padding">10dp</item>
+ <item name="android:layout_width">25dp</item>
+ <item name="android:layout_height">25dp</item>
<item name="android:scaleType">fitCenter</item>
</style>
<style name="MenuIndicator">
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index 1da363b0b..f1f52247a 100644
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -24,11 +24,13 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.ImageFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.Camera.Face;
+import android.preference.PreferenceManager;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
@@ -57,6 +59,7 @@ import android.widget.TextView;
import com.android.camera.ui.AutoFitSurfaceView;
import com.android.camera.ui.Camera2FaceView;
import com.android.camera.ui.CameraControls;
+import com.android.camera.ui.MenuHelp;
import com.android.camera.ui.OneUICameraControls;
import com.android.camera.ui.CountDownView;
import com.android.camera.ui.FlashToggleButton;
@@ -157,6 +160,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
private FlashToggleButton mFlashButton;
private CountDownView mCountDownView;
private OneUICameraControls mCameraControls;
+ private MenuHelp mMenuHelp;
private PieRenderer mPieRenderer;
private ZoomRenderer mZoomRenderer;
private Allocation mMonoDummyAllocation;
@@ -356,6 +360,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
mActivity.setPreviewGestures(mGestures);
((ViewGroup)mRootView).removeView(mRecordingTimeRect);
+ showFirstTimeHelp();
}
private void toggleMakeup() {
@@ -1109,6 +1114,9 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
public void setOrientation(int orientation, boolean animation) {
mOrientation = orientation;
mCameraControls.setOrientation(orientation, animation);
+ if (mMenuHelp != null) {
+ mMenuHelp.setOrientation(orientation, animation);
+ }
if (mFilterLayout != null) {
ViewGroup vg = (ViewGroup) mFilterLayout.getChildAt(0);
if (vg != null)
@@ -1144,6 +1152,33 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
return mOrientation;
}
+ public void showFirstTimeHelp() {
+ final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
+ boolean isMenuShown = prefs.getBoolean(CameraSettings.KEY_SHOW_MENU_HELP, false);
+ if(!isMenuShown) {
+ showFirstTimeHelp(mTopMargin, mBottomMargin);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(CameraSettings.KEY_SHOW_MENU_HELP, true);
+ editor.apply();
+ }
+ }
+
+ private void showFirstTimeHelp(int topMargin, int bottomMargin) {
+ mMenuHelp = (MenuHelp) mRootView.findViewById(R.id.menu_help);
+ mMenuHelp.setForCamera2(true);
+ mMenuHelp.setVisibility(View.VISIBLE);
+ mMenuHelp.setMargins(topMargin, bottomMargin);
+ mMenuHelp.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (mMenuHelp != null) {
+ mMenuHelp.setVisibility(View.GONE);
+ mMenuHelp = null;
+ }
+ }
+ });
+ }
+
@Override
public void onSingleTapUp(View view, int x, int y) {
mModule.onSingleTapUp(view, x, y);
diff --git a/src/com/android/camera/ui/MenuHelp.java b/src/com/android/camera/ui/MenuHelp.java
index f7eef72e8..4adff0fd6 100644
--- a/src/com/android/camera/ui/MenuHelp.java
+++ b/src/com/android/camera/ui/MenuHelp.java
@@ -31,6 +31,7 @@ package com.android.camera.ui;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Typeface;
@@ -85,6 +86,7 @@ public class MenuHelp extends RotatableLayout {
private static final int WIDTH_GRID = 5;
private static final int HEIGHT_GRID = 7;
private Typeface mTypeface;
+ private boolean forCamera2 = false;
public MenuHelp(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -96,6 +98,10 @@ public class MenuHelp extends RotatableLayout {
this(context, null);
}
+ public void setForCamera2(boolean forCamera2) {
+ this.forCamera2 = forCamera2;
+ }
+
public void setMargins(int top, int bottom) {
mTopMargin = top;
mBottomMargin = bottom;
@@ -120,7 +126,11 @@ public class MenuHelp extends RotatableLayout {
toIndex(mHelp1_0, w, h, rotation, 2, 2, HELP_1_0_INDEX);
if(TsMakeupManager.HAS_TS_MAKEUP)
toIndex(mHelp3_0, w, h, rotation, 3, 1, HELP_3_0_INDEX);
- toIndex(mHelp4_6, w, h, rotation, 3, 4, HELP_4_6_INDEX);
+ if (!forCamera2) {
+ toIndex(mHelp4_6, w, h, rotation, 3, 4, HELP_4_6_INDEX);
+ } else {
+ mHelp4_6.setVisibility(View.GONE);
+ }
toIndex(mOk2_4, w, h, rotation, 1, 5, OK_2_4_INDEX);
fillArrows(w, h, rotation);
}
@@ -155,7 +165,7 @@ public class MenuHelp extends RotatableLayout {
mArrows.addPath(x, y);
}
- {
+ if (!forCamera2) {
toIndex(v1, w, h, rotation, 3, 4, -1);
toIndex(v2, w, h, rotation, 3, 5, -1);
toIndex(v3, w, h, rotation, 4, 6, -1);
diff --git a/src/com/android/camera/ui/OneUICameraControls.java b/src/com/android/camera/ui/OneUICameraControls.java
index 12ce5325b..63e1b5b4d 100644
--- a/src/com/android/camera/ui/OneUICameraControls.java
+++ b/src/com/android/camera/ui/OneUICameraControls.java
@@ -185,8 +185,7 @@ public class OneUICameraControls extends RotatableLayout {
} else {
v.setY(mHeight - mBottom + (mBottom - h) / 2);
}
- int bW = mWidth / 5;
-
+ float bW = mWidth / 5f;
v.setX(bW * idx + (bW - w) / 2);
}