diff options
-rw-r--r-- | res/layout-w1024dp/preview_frame.xml | 18 | ||||
-rw-r--r-- | res/layout/preview_frame.xml | 15 | ||||
-rw-r--r-- | res/layout/priority_indicators.xml | 34 | ||||
-rw-r--r-- | res/values/styles.xml | 7 | ||||
-rw-r--r-- | src/com/android/camera/Camera.java | 84 | ||||
-rw-r--r-- | src/com/android/camera/CameraSettings.java | 11 |
6 files changed, 110 insertions, 59 deletions
diff --git a/res/layout-w1024dp/preview_frame.xml b/res/layout-w1024dp/preview_frame.xml index 7c92f1d..f6afd9a 100644 --- a/res/layout-w1024dp/preview_frame.xml +++ b/res/layout-w1024dp/preview_frame.xml @@ -28,25 +28,11 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone"/> - <com.android.camera.ui.FocusRectangle - android:id="@+id/focus_rectangle" + <com.android.camera.ui.FocusRectangle android:id="@+id/focus_rectangle" android:layout_width="180dp" android:layout_height="180dp" android:layout_centerInParent="true"/> - <ImageView style="@style/OnScreenGpsIndicator" - android:id="@+id/onscreen_gps_indicator_no_signal" - android:src="@drawable/ic_viewfinder_gps_no_signal" - android:layout_alignParentRight="true" - android:layout_alignParentBottom="true" - android:layout_margin="15dp" - android:visibility="gone"/> - <ImageView style="@style/OnScreenGpsIndicator" - android:id="@+id/onscreen_gps_indicator_on" - android:src="@drawable/ic_viewfinder_gps_on" - android:layout_alignParentRight="true" - android:layout_alignParentBottom="true" - android:layout_margin="15dp" - android:visibility="gone"/> + <include layout="@layout/priority_indicators"/> <include layout="@layout/review_control"/> <include layout="@layout/tap_to_focus_toast"/> </RelativeLayout> diff --git a/res/layout/preview_frame.xml b/res/layout/preview_frame.xml index 1bf621a..b7685bf 100644 --- a/res/layout/preview_frame.xml +++ b/res/layout/preview_frame.xml @@ -39,20 +39,7 @@ android:layout_width="120dp" android:layout_height="120dp" android:layout_centerInParent="true"/> - <ImageView style="@style/OnScreenGpsIndicator" - android:id="@+id/onscreen_gps_indicator_no_signal" - android:src="@drawable/ic_viewfinder_gps_no_signal" - android:layout_alignParentLeft="true" - android:layout_alignParentBottom="true" - android:layout_margin="5dp" - android:visibility="gone"/> - <ImageView style="@style/OnScreenGpsIndicator" - android:id="@+id/onscreen_gps_indicator_on" - android:src="@drawable/ic_viewfinder_gps_on" - android:layout_alignParentLeft="true" - android:layout_alignParentBottom="true" - android:layout_margin="5dp" - android:visibility="gone"/> + <include layout="@layout/priority_indicators"/> <include layout="@layout/tap_to_focus_toast"/> <include layout="@layout/indicator_bar" /> </RelativeLayout> diff --git a/res/layout/priority_indicators.xml b/res/layout/priority_indicators.xml new file mode 100644 index 0000000..4926484 --- /dev/null +++ b/res/layout/priority_indicators.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 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. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_alignParentLeft="true" + android:layout_alignParentTop="true" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="8dp"> + <ImageView style="@style/OnScreenIndicator" + android:id="@+id/onscreen_gps_indicator_no_signal" + android:src="@drawable/ic_viewfinder_gps_no_signal"/> + <ImageView style="@style/OnScreenIndicator" + android:id="@+id/onscreen_gps_indicator_on" + android:src="@drawable/ic_viewfinder_gps_on"/> + <TextView style="@style/OnScreenIndicator" + android:id="@+id/onscreen_exposure_indicator" + android:gravity="center_vertical" + android:textSize="15dp" + android:textColor="@android:color/white"/> +</LinearLayout> diff --git a/res/values/styles.xml b/res/values/styles.xml index e299915..80d1a56 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -96,10 +96,13 @@ <item name="android:paddingRight">8dp</item> <item name="android:background">@drawable/setting_picker</item> </style> - <style name="OnScreenGpsIndicator"> - <item name="android:layout_height">wrap_content</item> + <style name="OnScreenIndicator"> + <item name="android:layout_height">28dp</item> <item name="android:layout_width">wrap_content</item> + <item name="android:layout_gravity">center_vertical</item> <item name="android:focusable">false</item> + <item name="android:visibility">gone</item> + <item name="android:layout_marginRight">8dp</item> </style> <style name="OnViewfinderLabel"> <item name="android:gravity">center</item> diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 952fbc9..3eafd65 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -74,6 +74,7 @@ import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.widget.Button; import android.widget.RelativeLayout; +import android.widget.TextView; import android.widget.Toast; import java.io.File; @@ -85,6 +86,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.Formatter; import java.util.List; /** The Camera activity which can preview and take pictures. */ @@ -177,9 +179,14 @@ public class Camera extends ActivityBase implements View.OnClickListener, private String mCropValue; private Uri mSaveUri; - // GPS on-screen indicator - private View mGpsNoSignalView; - private View mGpsHasSignalView; + // On-screen indicator + private View mGpsNoSignalIndicator; + private View mGpsHasSignalIndicator; + private TextView mExposureIndicator; + + private final StringBuilder mBuilder = new StringBuilder(); + private final Formatter mFormatter = new Formatter(mBuilder); + private final Object[] mFormatterArgs = new Object[1]; /** * An unpublished intent flag requesting to return as soon as capturing @@ -375,7 +382,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, getSystemService(Context.LOCATION_SERVICE); mRecordLocation = RecordLocationPreference.get( mPreferences, getContentResolver()); - initGpsOnScreenIndicator(); + initOnScreenIndicator(); if (mRecordLocation) startReceivingLocationUpdates(); keepMediaProviderInstance(); @@ -617,24 +624,50 @@ public class Camera extends ActivityBase implements View.OnClickListener, } }; - private void initGpsOnScreenIndicator() { - mGpsNoSignalView = findViewById(R.id.onscreen_gps_indicator_no_signal); - mGpsHasSignalView = findViewById(R.id.onscreen_gps_indicator_on); + private void initOnScreenIndicator() { + mGpsNoSignalIndicator = findViewById(R.id.onscreen_gps_indicator_no_signal); + mGpsHasSignalIndicator = findViewById(R.id.onscreen_gps_indicator_on); + mExposureIndicator = (TextView) findViewById(R.id.onscreen_exposure_indicator); } private void showGpsOnScreenIndicator(boolean hasSignal) { if (hasSignal) { - if (mGpsNoSignalView != null) mGpsNoSignalView.setVisibility(View.GONE); - if (mGpsHasSignalView != null) mGpsHasSignalView.setVisibility(View.VISIBLE); + if (mGpsNoSignalIndicator != null) { + mGpsNoSignalIndicator.setVisibility(View.GONE); + } + if (mGpsHasSignalIndicator != null) { + mGpsHasSignalIndicator.setVisibility(View.VISIBLE); + } } else { - if (mGpsNoSignalView != null) mGpsNoSignalView.setVisibility(View.VISIBLE); - if (mGpsHasSignalView != null) mGpsHasSignalView.setVisibility(View.GONE); + if (mGpsNoSignalIndicator != null) { + mGpsNoSignalIndicator.setVisibility(View.VISIBLE); + } + if (mGpsHasSignalIndicator != null) { + mGpsHasSignalIndicator.setVisibility(View.GONE); + } } } private void hideGpsOnScreenIndicator() { - if (mGpsNoSignalView != null) mGpsNoSignalView.setVisibility(View.GONE); - if (mGpsHasSignalView != null) mGpsHasSignalView.setVisibility(View.GONE); + if (mGpsNoSignalIndicator != null) mGpsNoSignalIndicator.setVisibility(View.GONE); + if (mGpsHasSignalIndicator != null) mGpsHasSignalIndicator.setVisibility(View.GONE); + } + + private void updateExposureOnScreenIndicator(int value) { + if (mExposureIndicator == null) return; + + if (value == 0) { + mExposureIndicator.setText(""); + mExposureIndicator.setVisibility(View.GONE); + } else { + float step = mParameters.getExposureCompensationStep(); + mFormatterArgs[0] = value * step; + mBuilder.delete(0, mBuilder.length()); + mFormatter.format("%+1.1f", mFormatterArgs); + String exposure = mFormatter.toString(); + mExposureIndicator.setText(exposure); + mExposureIndicator.setVisibility(View.VISIBLE); + } } private class LocationListener @@ -1462,6 +1495,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, mDidRegister = false; } stopReceivingLocationUpdates(); + updateExposureOnScreenIndicator(0); if (mFocusToneGenerator != null) { mFocusToneGenerator.release(); @@ -1979,20 +2013,13 @@ public class Camera extends ActivityBase implements View.OnClickListener, // still supported by latest driver, if not, ignore the settings. // Set exposure compensation - String exposure = mPreferences.getString( - CameraSettings.KEY_EXPOSURE, - getString(R.string.pref_exposure_default)); - try { - int value = Integer.parseInt(exposure); - int max = mParameters.getMaxExposureCompensation(); - int min = mParameters.getMinExposureCompensation(); - if (value >= min && value <= max) { - mParameters.setExposureCompensation(value); - } else { - Log.w(TAG, "invalid exposure range: " + exposure); - } - } catch (NumberFormatException e) { - Log.w(TAG, "invalid exposure: " + exposure); + int value = CameraSettings.readExposure(mPreferences); + int max = mParameters.getMaxExposureCompensation(); + int min = mParameters.getMinExposureCompensation(); + if (value >= min && value <= max) { + mParameters.setExposureCompensation(value); + } else { + Log.w(TAG, "invalid exposure range: " + value); } if (Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) { @@ -2307,6 +2334,9 @@ public class Camera extends ActivityBase implements View.OnClickListener, } else { setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE); } + + int exposureValue = CameraSettings.readExposure(mPreferences); + updateExposureOnScreenIndicator(exposureValue); } @Override diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 50bd9d8..06a8d95 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -364,6 +364,17 @@ public class CameraSettings { editor.apply(); } + public static int readExposure(ComboPreferences preferences) { + String exposure = preferences.getString( + CameraSettings.KEY_EXPOSURE, + EXPOSURE_DEFAULT_VALUE); + try { + return Integer.parseInt(exposure); + } catch (Exception ex) { + Log.e(TAG, "Invalid exposure: " + exposure); + } + return 0; + } public static void restorePreferences(Context context, ComboPreferences preferences, Parameters parameters) { |