diff options
-rw-r--r-- | res/layout-w1024dp/preview_frame.xml | 1 | ||||
-rw-r--r-- | res/layout/preview_frame.xml | 1 | ||||
-rw-r--r-- | res/layout/tap_to_focus_toast.xml | 35 | ||||
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/com/android/camera/Camera.java | 28 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/ComboPreferences.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/ui/RotateLayout.java | 2 |
8 files changed, 72 insertions, 3 deletions
diff --git a/res/layout-w1024dp/preview_frame.xml b/res/layout-w1024dp/preview_frame.xml index 406d6e5..7c92f1d 100644 --- a/res/layout-w1024dp/preview_frame.xml +++ b/res/layout-w1024dp/preview_frame.xml @@ -48,6 +48,7 @@ android:layout_margin="15dp" android:visibility="gone"/> <include layout="@layout/review_control"/> + <include layout="@layout/tap_to_focus_toast"/> </RelativeLayout> <!-- This is the border of preview and the corner is round. If it is the background, preview will be on top and the inner corner will be square, which looks bad. diff --git a/res/layout/preview_frame.xml b/res/layout/preview_frame.xml index f65f197..63887ff 100644 --- a/res/layout/preview_frame.xml +++ b/res/layout/preview_frame.xml @@ -59,5 +59,6 @@ android:layout_height="match_parent" android:layout_centerVertical="true" android:layout_alignParentRight="true"/> + <include layout="@layout/tap_to_focus_toast"/> </RelativeLayout> </com.android.camera.PreviewFrameLayout> diff --git a/res/layout/tap_to_focus_toast.xml b/res/layout/tap_to_focus_toast.xml new file mode 100644 index 0000000..1ea67e7 --- /dev/null +++ b/res/layout/tap_to_focus_toast.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2011, The Android Open Source Project +** +** 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. +*/ +--> +<com.android.camera.ui.RotateLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/tap_to_focus_prompt" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_centerInParent="true" + android:visibility="gone"> + <TextView + android:text="@string/tap_to_focus" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:paddingTop="5dp" + android:paddingBottom="5dp" + android:textAppearance="?android:textAppearanceMedium" + android:background="@color/on_viewfinder_label_background_color" /> +</com.android.camera.ui.RotateLayout>
\ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 8bad5d5..2dc18bd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -270,4 +270,7 @@ <!-- The text shown on the button for starting panorama capturing [CHAR LIMIT=10] --> <string name="pano_capture_start">Start</string> + + <!-- Toast telling users tapping on the viewfinder will trigger autofocus [CHAR LIMIT=24] --> + <string name="tap_to_focus">Tap to focus</string> </resources> diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index fee97cc..5005a1a 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -21,6 +21,7 @@ import com.android.camera.ui.FaceView; import com.android.camera.ui.FocusRectangle; import com.android.camera.ui.IndicatorControl; import com.android.camera.ui.RotateImageView; +import com.android.camera.ui.RotateLayout; import com.android.camera.ui.SharePopup; import com.android.camera.ui.ZoomPicker; @@ -71,6 +72,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; +import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.RelativeLayout; import android.widget.Toast; @@ -103,6 +105,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, private static final int SET_CAMERA_PARAMETERS_WHEN_IDLE = 5; private static final int CHECK_DISPLAY_ROTATION = 6; private static final int RESET_TOUCH_FOCUS = 7; + private static final int DISMISS_TAP_TO_FOCUS_TOAST = 8; // The subset of parameters we need to update in setCameraParameters(). private static final int UPDATE_PARAM_INITIALIZE = 1; @@ -319,6 +322,14 @@ public class Camera extends ActivityBase implements View.OnClickListener, startFaceDetection(); break; } + + case DISMISS_TAP_TO_FOCUS_TOAST: { + View v = findViewById(R.id.tap_to_focus_prompt); + v.setVisibility(View.GONE); + v.setAnimation(AnimationUtils.loadAnimation(Camera.this, + R.anim.on_screen_hint_exit)); + break; + } } } } @@ -394,6 +405,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, initializeFocusTone(); initializeZoom(); startFaceDetection(); + showTapToFocusToastIfNeeded(); mFirstTimeInitialized = true; addIdleHandler(); } @@ -2385,4 +2397,20 @@ public class Camera extends ActivityBase implements View.OnClickListener, public void onFaceDetection(Face[] faces, android.hardware.Camera camera) { mFaceView.setFaces(faces); } + + private void showTapToFocusToastIfNeeded() { + if (mParameters.getMaxNumFocusAreas() > 0 && + mPreferences.getBoolean(CameraSettings.KEY_TAP_TO_FOCUS_PROMPT_SHOWN, true)) { + // Show the toast. + RotateLayout v = (RotateLayout) findViewById(R.id.tap_to_focus_prompt); + v.setOrientation(mOrientationCompensation); + v.startAnimation(AnimationUtils.loadAnimation(this, R.anim.on_screen_hint_enter)); + v.setVisibility(View.VISIBLE); + mHandler.sendEmptyMessageDelayed(DISMISS_TAP_TO_FOCUS_TOAST, 5000); + // Clear the preference. + Editor editor = mPreferences.edit(); + editor.putBoolean(CameraSettings.KEY_TAP_TO_FOCUS_PROMPT_SHOWN, false); + editor.apply(); + } + } } diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 96f439a..50bd9d8 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -49,6 +49,7 @@ public class CameraSettings { public static final String KEY_SCENE_MODE = "pref_camera_scenemode_key"; public static final String KEY_EXPOSURE = "pref_camera_exposure_key"; public static final String KEY_CAMERA_ID = "pref_camera_id_key"; + public static final String KEY_TAP_TO_FOCUS_PROMPT_SHOWN = "pref_tap_to_focus_prompt_shown_key"; public static final String EXPOSURE_DEFAULT_VALUE = "0"; diff --git a/src/com/android/camera/ComboPreferences.java b/src/com/android/camera/ComboPreferences.java index b8705cc..81667a4 100644 --- a/src/com/android/camera/ComboPreferences.java +++ b/src/com/android/camera/ComboPreferences.java @@ -18,7 +18,6 @@ package com.android.camera; import android.content.Context; import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.preference.PreferenceManager; @@ -76,7 +75,8 @@ public class ComboPreferences implements SharedPreferences, OnSharedPreferenceCh private static boolean isGlobal(String key) { return key.equals(CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL) || key.equals(CameraSettings.KEY_CAMERA_ID) - || key.equals(CameraSettings.KEY_RECORD_LOCATION); + || key.equals(CameraSettings.KEY_RECORD_LOCATION) + || key.equals(CameraSettings.KEY_TAP_TO_FOCUS_PROMPT_SHOWN); } public String getString(String key, String defValue) { diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java index c900557..13b475d 100644 --- a/src/com/android/camera/ui/RotateLayout.java +++ b/src/com/android/camera/ui/RotateLayout.java @@ -23,7 +23,7 @@ import android.view.ViewGroup; // A RotateLayout is designed to display a single item and provides the // capabilities to rotate the item. -class RotateLayout extends ViewGroup { +public class RotateLayout extends ViewGroup { private static final String TAG = "RotateLayout"; private int mOrientation; private View mChild; |