diff options
23 files changed, 162 insertions, 93 deletions
diff --git a/res/drawable-hdpi/ic_menuselect_camera_facing_back.png b/res/drawable-hdpi/ic_menuselect_camera_facing_back.png Binary files differnew file mode 100644 index 0000000..53fcd8e --- /dev/null +++ b/res/drawable-hdpi/ic_menuselect_camera_facing_back.png diff --git a/res/drawable-hdpi/ic_menuselect_camera_facing_front.png b/res/drawable-hdpi/ic_menuselect_camera_facing_front.png Binary files differnew file mode 100644 index 0000000..53fcd8e --- /dev/null +++ b/res/drawable-hdpi/ic_menuselect_camera_facing_front.png diff --git a/res/drawable-hdpi/ic_viewfinder_camera_facing_back.png b/res/drawable-hdpi/ic_viewfinder_camera_facing_back.png Binary files differnew file mode 100644 index 0000000..1a53019 --- /dev/null +++ b/res/drawable-hdpi/ic_viewfinder_camera_facing_back.png diff --git a/res/drawable-hdpi/ic_viewfinder_camera_facing_front.png b/res/drawable-hdpi/ic_viewfinder_camera_facing_front.png Binary files differnew file mode 100644 index 0000000..1a53019 --- /dev/null +++ b/res/drawable-hdpi/ic_viewfinder_camera_facing_front.png diff --git a/res/drawable-mdpi/ic_menuselect_camera_facing_back.png b/res/drawable-mdpi/ic_menuselect_camera_facing_back.png Binary files differnew file mode 100644 index 0000000..023a5f7 --- /dev/null +++ b/res/drawable-mdpi/ic_menuselect_camera_facing_back.png diff --git a/res/drawable-mdpi/ic_menuselect_camera_facing_front.png b/res/drawable-mdpi/ic_menuselect_camera_facing_front.png Binary files differnew file mode 100644 index 0000000..023a5f7 --- /dev/null +++ b/res/drawable-mdpi/ic_menuselect_camera_facing_front.png diff --git a/res/drawable-mdpi/ic_viewfinder_camera_facing_back.png b/res/drawable-mdpi/ic_viewfinder_camera_facing_back.png Binary files differnew file mode 100644 index 0000000..49b6ec9 --- /dev/null +++ b/res/drawable-mdpi/ic_viewfinder_camera_facing_back.png diff --git a/res/drawable-mdpi/ic_viewfinder_camera_facing_front.png b/res/drawable-mdpi/ic_viewfinder_camera_facing_front.png Binary files differnew file mode 100644 index 0000000..49b6ec9 --- /dev/null +++ b/res/drawable-mdpi/ic_viewfinder_camera_facing_front.png diff --git a/res/values/strings.xml b/res/values/strings.xml index b78c85b..22ecd0d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -117,6 +117,8 @@ <!-- Settings screen, camera selection dialog title. Users can select a camera from the phone (front-facing or back-facing). [CHAR LIMIT=20] --> <string name="pref_camera_id_title">Select camera</string> + <string name="pref_camera_id_default">0</string> + <!-- In select camera setting, back facing camera. [CHAR LIMIT=14] --> <string name="pref_camera_id_entry_back">Back</string> <!-- In select camera setting, front-facing camera. [CHAR LIMIT=14] --> diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml index b0da97c..6968270 100644 --- a/res/xml/camera_preferences.xml +++ b/res/xml/camera_preferences.xml @@ -75,5 +75,9 @@ camera:title="@string/pref_camera_focusmode_title" camera:entries="@array/pref_camera_focusmode_entries" camera:entryValues="@array/pref_camera_focusmode_entryvalues" /> + <IconListPreference + camera:key="pref_camera_id_key" + camera:defaultValue="@string/pref_camera_id_default" + camera:title="@string/pref_camera_id_title" /> </PreferenceGroup> </PreferenceGroup> diff --git a/res/xml/video_preferences.xml b/res/xml/video_preferences.xml index 6345351..f803c32 100644 --- a/res/xml/video_preferences.xml +++ b/res/xml/video_preferences.xml @@ -54,5 +54,9 @@ camera:title="@string/pref_camera_coloreffect_title" camera:entries="@array/pref_camera_coloreffect_entries" camera:entryValues="@array/pref_camera_coloreffect_entryvalues"/> + <IconListPreference + camera:key="pref_camera_id_key" + camera:defaultValue="@string/pref_camera_id_default" + camera:title="@string/pref_camera_id_title" /> </PreferenceGroup> </PreferenceGroup> diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index e2820fb..16beba0 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -172,7 +172,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, private boolean mPreviewing; private boolean mPausing; - private boolean mSwitching; private boolean mFirstTimeInitialized; private boolean mIsImageCaptureIntent; private boolean mRecordLocation; @@ -359,6 +358,8 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, installIntentFilter(); initializeFocusTone(); initializeZoom(); + mHeadUpDisplay = new CameraHeadUpDisplay(this); + mHeadUpDisplay.setListener(new MyHeadUpDisplayListener()); initializeHeadUpDisplay(); mFirstTimeInitialized = true; changeHeadUpDisplayState(); @@ -438,16 +439,13 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, } private float[] getZoomRatios() { + if(!mParameters.isZoomSupported()) return null; List<Integer> zoomRatios = mParameters.getZoomRatios(); - if (zoomRatios != null) { - float result[] = new float[zoomRatios.size()]; - for (int i = 0, n = result.length; i < n; ++i) { - result[i] = (float) zoomRatios.get(i) / 100f; - } - return result; - } else { - throw new IllegalStateException("cannot get zoom ratios"); + float result[] = new float[zoomRatios.size()]; + for (int i = 0, n = result.length; i < n; ++i) { + result[i] = (float) zoomRatios.get(i) / 100f; } + return result; } private class ZoomGestureListener extends @@ -971,7 +969,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, // becomes landscape. Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE - && !mPausing && !mSwitching && mFirstTimeInitialized) { + && !mPausing && mFirstTimeInitialized) { if (mGLRootView == null) attachHeadUpDisplay(); } else if (mGLRootView != null) { detachHeadUpDisplay(); @@ -998,17 +996,12 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, } private void initializeHeadUpDisplay() { - mHeadUpDisplay = new CameraHeadUpDisplay(this); - CameraSettings settings = new CameraSettings(this, mInitialParams); + CameraSettings settings = new CameraSettings(this, mInitialParams, + CameraHolder.instance().getCameraInfo()); mHeadUpDisplay.initialize(this, - settings.getPreferenceGroup(R.xml.camera_preferences)); - mHeadUpDisplay.setListener(new MyHeadUpDisplayListener()); - } - - private void attachHeadUpDisplay() { - mHeadUpDisplay.setOrientation(mLastOrientation); + settings.getPreferenceGroup(R.xml.camera_preferences), + getZoomRatios(), mLastOrientation); if (mParameters.isZoomSupported()) { - mHeadUpDisplay.setZoomRatios(getZoomRatios()); mHeadUpDisplay.setZoomIndex(mZoomValue); mHeadUpDisplay.setZoomListener(new ZoomControllerListener() { public void onZoomChanged( @@ -1016,13 +1009,18 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, onZoomValueChanged(index); } }); + } else { + mHeadUpDisplay.setZoomListener(null); } + updateSceneModeInHud(); + } + + private void attachHeadUpDisplay() { + mHeadUpDisplay.setOrientation(mLastOrientation); FrameLayout frame = (FrameLayout) findViewById(R.id.frame); mGLRootView = new GLRootView(this); mGLRootView.setContentPane(mHeadUpDisplay); frame.addView(mGLRootView); - - updateSceneModeInHud(); } private void detachHeadUpDisplay() { @@ -1774,7 +1772,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, Log.w(TAG, "invalid exposure: " + exposure); } - if (mGLRootView != null) updateSceneModeInHud(); + if (mHeadUpDisplay != null) updateSceneModeInHud(); if (Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) { // Set flash mode. @@ -2021,22 +2019,19 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, R.string.switch_camera_id) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - switchCameraId(); + switchCameraId((mCameraId + 1) % mNumberOfCameras); return true; } }).setIcon(android.R.drawable.ic_menu_camera); } } - private void switchCameraId() { - mSwitching = true; - - mCameraId = (mCameraId + 1) % mNumberOfCameras; - CameraSettings.writePreferredCameraId(mPreferences, mCameraId); + private void switchCameraId(int cameraId) { + mCameraId = cameraId; + CameraSettings.writePreferredCameraId(mPreferences, cameraId); stopPreview(); closeCamera(); - changeHeadUpDisplayState(); // Remove the messages in the event queue. mHandler.removeMessages(RESTART_PREVIEW); @@ -2049,7 +2044,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, mPreferences.setLocalId(this, mCameraId); CameraSettings.upgradeLocalPreferences(mPreferences.getLocal()); - // Restart the preview. resetExposureCompensation(); if (!restartPreview()) return; @@ -2060,9 +2054,6 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, if (mFirstTimeInitialized) { initializeHeadUpDisplay(); } - - mSwitching = false; - changeHeadUpDisplayState(); } private boolean switchToVideoMode() { @@ -2098,8 +2089,12 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, stopReceivingLocationUpdates(); } } - - setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE); + int cameraId = CameraSettings.readPreferredCameraId(mPreferences); + if (mCameraId != cameraId) { + switchCameraId(cameraId); + } else { + setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE); + } } @Override diff --git a/src/com/android/camera/CameraHolder.java b/src/com/android/camera/CameraHolder.java index fc6e687..ec1a61e 100644 --- a/src/com/android/camera/CameraHolder.java +++ b/src/com/android/camera/CameraHolder.java @@ -18,6 +18,7 @@ package com.android.camera; import static com.android.camera.Util.Assert; +import android.hardware.Camera.CameraInfo; import android.hardware.Camera.Parameters; import android.os.Build; import android.os.Handler; @@ -48,6 +49,7 @@ public class CameraHolder { private final Handler mHandler; private int mUsers = 0; // number of open() - number of release() private int mNumberOfCameras; + private CameraInfo[] mInfo; // We store the camera parameters when we actually open the device, // so we can restore them in the subsequent open() requests by the user. @@ -92,15 +94,10 @@ public class CameraHolder { ht.start(); mHandler = new MyHandler(ht.getLooper()); mNumberOfCameras = android.hardware.Camera.getNumberOfCameras(); - - android.hardware.Camera.CameraInfo info = - new android.hardware.Camera.CameraInfo(); - Log.v(TAG, "# of cameras:" + mNumberOfCameras); + mInfo = new CameraInfo[mNumberOfCameras]; for (int i = 0; i < mNumberOfCameras; i++) { - Log.v(TAG, "camera info #" + i); - android.hardware.Camera.getCameraInfo(i, info); - Log.v(TAG, "facing: " + info.mFacing); - Log.v(TAG, "orientation: " + info.mOrientation); + mInfo[i] = new CameraInfo(); + android.hardware.Camera.getCameraInfo(i, mInfo[i]); } } @@ -108,6 +105,10 @@ public class CameraHolder { return mNumberOfCameras; } + public CameraInfo[] getCameraInfo() { + return mInfo; + } + public synchronized android.hardware.Camera open(int cameraId) throws CameraHardwareException { Assert(mUsers == 0); diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index fa05aa7..6e0c7e1 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -20,6 +20,7 @@ import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import android.hardware.Camera.CameraInfo; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; import android.media.CamcorderProfile; @@ -48,7 +49,7 @@ public class CameraSettings { public static final String KEY_WHITE_BALANCE = "pref_camera_whitebalance_key"; 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"; + public static final String KEY_CAMERA_ID = "pref_camera_id_key"; private static final String VIDEO_QUALITY_HIGH = "high"; private static final String VIDEO_QUALITY_MMS = "mms"; @@ -85,10 +86,13 @@ public class CameraSettings { private final Context mContext; private final Parameters mParameters; + private final CameraInfo[] mCameraInfo; - public CameraSettings(Activity activity, Parameters parameters) { + public CameraSettings(Activity activity, Parameters parameters, + CameraInfo[] cameraInfo) { mContext = activity; mParameters = parameters; + mCameraInfo = cameraInfo; } public PreferenceGroup getPreferenceGroup(int preferenceRes) { @@ -148,6 +152,8 @@ public class CameraSettings { ListPreference flashMode = group.findPreference(KEY_FLASH_MODE); ListPreference focusMode = group.findPreference(KEY_FOCUS_MODE); ListPreference exposure = group.findPreference(KEY_EXPOSURE); + IconListPreference cameraId = + (IconListPreference)group.findPreference(KEY_CAMERA_ID); ListPreference videoFlashMode = group.findPreference(KEY_VIDEOCAMERA_FLASH_MODE); @@ -197,10 +203,8 @@ public class CameraSettings { filterUnsupportedOptions(group, videoFlashMode, mParameters.getSupportedFlashModes()); } - - if (exposure != null) { - buildExposureCompensation(group, exposure); - } + if (exposure != null) buildExposureCompensation(group, exposure); + if (cameraId != null) buildCameraId(group, cameraId); } private void buildExposureCompensation( @@ -228,6 +232,38 @@ public class CameraSettings { exposure.setEntryValues(entryValues); } + private void buildCameraId( + PreferenceGroup group, IconListPreference cameraId) { + int numOfCameras = mCameraInfo.length; + if (numOfCameras < 2) { + removePreference(group, cameraId.getKey()); + return; + } + + CharSequence entries[] = new CharSequence[numOfCameras]; + CharSequence entryValues[] = new CharSequence[numOfCameras]; + int[] iconIds = new int[numOfCameras]; + int[] largeIconIds = new int[numOfCameras]; + for (int i = 0; i < numOfCameras; i++) { + entryValues[i] = Integer.toString(i); + if (mCameraInfo[i].mFacing == CameraInfo.CAMERA_FACING_FRONT) { + entries[i] = mContext.getString( + R.string.pref_camera_id_entry_front); + iconIds[i] = R.drawable.ic_menuselect_camera_facing_front; + largeIconIds[i] = R.drawable.ic_viewfinder_camera_facing_front; + } else { + entries[i] = mContext.getString( + R.string.pref_camera_id_entry_back); + iconIds[i] = R.drawable.ic_menuselect_camera_facing_back; + largeIconIds[i] = R.drawable.ic_viewfinder_camera_facing_back; + } + } + cameraId.setEntries(entries); + cameraId.setEntryValues(entryValues); + cameraId.setIconIds(iconIds); + cameraId.setLargeIconIds(largeIconIds); + } + private static boolean removePreference(PreferenceGroup group, String key) { for (int i = 0, n = group.size(); i < n; i++) { CameraPreference child = group.get(i); @@ -366,13 +402,14 @@ public class CameraSettings { } public static int readPreferredCameraId(SharedPreferences pref) { - return pref.getInt(KEY_CAMERA_ID, 0); + String id = Integer.toString(android.hardware.Camera.CAMERA_ID_DEFAULT); + return Integer.parseInt(pref.getString(KEY_CAMERA_ID, id)); } public static void writePreferredCameraId(SharedPreferences pref, int cameraId) { Editor editor = pref.edit(); - editor.putInt(KEY_CAMERA_ID, cameraId); + editor.putString(KEY_CAMERA_ID, Integer.toString(cameraId)); editor.apply(); } } diff --git a/src/com/android/camera/ComboPreferences.java b/src/com/android/camera/ComboPreferences.java index 1fbfdaa..b2b0d14 100644 --- a/src/com/android/camera/ComboPreferences.java +++ b/src/com/android/camera/ComboPreferences.java @@ -49,8 +49,8 @@ public class ComboPreferences implements SharedPreferences, OnSharedPreferenceCh } } - public void setLocalId(Context context, int id) { - String prefName = context.getPackageName() + "_preferences_" + id; + public void setLocalId(Context context, int cameraId) { + String prefName = context.getPackageName() + "_preferences_" + cameraId; if (mPrefLocal != null) { mPrefLocal.unregisterOnSharedPreferenceChangeListener(this); } diff --git a/src/com/android/camera/IconListPreference.java b/src/com/android/camera/IconListPreference.java index 5a8d383..fc23f6c 100644 --- a/src/com/android/camera/IconListPreference.java +++ b/src/com/android/camera/IconListPreference.java @@ -51,6 +51,14 @@ public class IconListPreference extends ListPreference { return mIconIds; } + public void setLargeIconIds(int[] largeIconIds) { + mLargeIconIds = largeIconIds; + } + + public void setIconIds(int[] iconIds) { + mIconIds = iconIds; + } + private int[] getIconIds(Resources res, int iconsRes) { if (iconsRes == 0) return null; TypedArray array = res.obtainTypedArray(iconsRes); diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index c1a311f..e57615d 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -172,7 +172,6 @@ public class VideoCamera extends NoSearchActivity private int mDesiredPreviewHeight; boolean mPausing = false; - boolean mSwitching; boolean mPreviewing = false; // True if preview is started. private ContentResolver mContentResolver; @@ -390,6 +389,8 @@ public class VideoCamera extends NoSearchActivity // Initialize the HeadUpDiplay after startPreview(). We need mParameters // for HeadUpDisplay and it is initialized in that function. + mHeadUpDisplay = new CamcorderHeadUpDisplay(this); + mHeadUpDisplay.setListener(new MyHeadUpDisplayListener()); initializeHeadUpDisplay(); } @@ -401,7 +402,7 @@ public class VideoCamera extends NoSearchActivity // becomes landscape. Configuration config = getResources().getConfiguration(); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE - && !mPausing && !mSwitching && mGLRootView == null) { + && !mPausing && mGLRootView == null) { attachHeadUpDisplay(); } else if (mGLRootView != null) { detachHeadUpDisplay(); @@ -409,15 +410,14 @@ public class VideoCamera extends NoSearchActivity } private void initializeHeadUpDisplay() { - mHeadUpDisplay = new CamcorderHeadUpDisplay(this, mCaptureTimeLapse); - CameraSettings settings = new CameraSettings(this, mParameters); + CameraSettings settings = new CameraSettings(this, mParameters, + CameraHolder.instance().getCameraInfo()); PreferenceGroup group = settings.getPreferenceGroup(R.xml.video_preferences); if (mIsVideoCaptureIntent) { group = filterPreferenceScreenByIntent(group); } - mHeadUpDisplay.initialize(this, group); - mHeadUpDisplay.setListener(new MyHeadUpDisplayListener()); + mHeadUpDisplay.initialize(this, group, mCaptureTimeLapse); } private void attachHeadUpDisplay() { @@ -1184,7 +1184,7 @@ public class VideoCamera extends NoSearchActivity R.string.switch_camera_id) .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - switchCameraId(); + switchCameraId((mCameraId + 1) % mNumberOfCameras); return true; } }).setIcon(android.R.drawable.ic_menu_camera); @@ -1204,9 +1204,6 @@ public class VideoCamera extends NoSearchActivity private void switchTimeLapseMode() { mCaptureTimeLapse = !mCaptureTimeLapse; - mSwitching = true; - changeHeadUpDisplayState(); - finishRecorderAndCloseCamera(); mHandler.removeMessages(INIT_RECORDER); @@ -1229,20 +1226,13 @@ public class VideoCamera extends NoSearchActivity mHandler.sendEmptyMessage(INIT_RECORDER); } - mSwitching = false; - changeHeadUpDisplayState(); - // Change menu setTimeLapseSwitchTitle(!mCaptureTimeLapse); } - private void switchCameraId() { - mSwitching = true; - - mCameraId = (mCameraId + 1) % mNumberOfCameras; - CameraSettings.writePreferredCameraId(mPreferences, mCameraId); - - changeHeadUpDisplayState(); + private void switchCameraId(int cameraId) { + mCameraId = cameraId; + CameraSettings.writePreferredCameraId(mPreferences, cameraId); finishRecorderAndCloseCamera(); mHandler.removeMessages(INIT_RECORDER); @@ -1259,9 +1249,6 @@ public class VideoCamera extends NoSearchActivity if (mSurfaceHolder != null) { mHandler.sendEmptyMessage(INIT_RECORDER); } - - mSwitching = false; - changeHeadUpDisplayState(); } private PreferenceGroup filterPreferenceScreenByIntent( @@ -1778,7 +1765,14 @@ public class VideoCamera extends NoSearchActivity // If mCameraDevice is not ready then we can set the parameter in // startPreview(). if (mCameraDevice == null) return; - resetCameraParameters(); + + // Check if camera id is changed. + int cameraId = CameraSettings.readPreferredCameraId(mPreferences); + if (mCameraId != cameraId) { + switchCameraId(cameraId); + } else { + resetCameraParameters(); + } } } } diff --git a/src/com/android/camera/ui/BasicIndicator.java b/src/com/android/camera/ui/BasicIndicator.java index bb1102c..7630a8e 100644 --- a/src/com/android/camera/ui/BasicIndicator.java +++ b/src/com/android/camera/ui/BasicIndicator.java @@ -19,7 +19,6 @@ package com.android.camera.ui; import android.content.Context; import com.android.camera.IconListPreference; -import com.android.camera.PreferenceGroup; import com.android.camera.R; import com.android.camera.Util; import com.android.camera.ui.GLListView.OnItemSelectedListener; @@ -34,8 +33,7 @@ class BasicIndicator extends AbstractIndicator { private PreferenceAdapter mModel; private String mOverride; - public BasicIndicator(Context context, - PreferenceGroup group, IconListPreference preference) { + public BasicIndicator(Context context, IconListPreference preference) { super(context); mPreference = preference; mIcon = new ResourceTexture[preference.getLargeIconIds().length]; diff --git a/src/com/android/camera/ui/CamcorderHeadUpDisplay.java b/src/com/android/camera/ui/CamcorderHeadUpDisplay.java index 8c8ed5a..6ddcd4b 100644 --- a/src/com/android/camera/ui/CamcorderHeadUpDisplay.java +++ b/src/com/android/camera/ui/CamcorderHeadUpDisplay.java @@ -29,9 +29,14 @@ public class CamcorderHeadUpDisplay extends HeadUpDisplay { private boolean mCaptureTimeLapse; private OtherSettingsIndicator mOtherSettings; - public CamcorderHeadUpDisplay(Context context, boolean captureTimeLapse) { + public CamcorderHeadUpDisplay(Context context) { super(context); + } + + public void initialize(Context context, PreferenceGroup group, + boolean captureTimeLapse) { mCaptureTimeLapse = captureTimeLapse; + super.initialize(context, group); } @Override @@ -64,5 +69,6 @@ public class CamcorderHeadUpDisplay extends HeadUpDisplay { } else { addIndicator(context, group, CameraSettings.KEY_VIDEO_QUALITY); } + addIndicator(context, group, CameraSettings.KEY_CAMERA_ID); } } diff --git a/src/com/android/camera/ui/CameraHeadUpDisplay.java b/src/com/android/camera/ui/CameraHeadUpDisplay.java index 9bdb68f..473ec2a 100644 --- a/src/com/android/camera/ui/CameraHeadUpDisplay.java +++ b/src/com/android/camera/ui/CameraHeadUpDisplay.java @@ -31,12 +31,21 @@ public class CameraHeadUpDisplay extends HeadUpDisplay { private GpsIndicator mGpsIndicator; private ZoomIndicator mZoomIndicator; private Context mContext; + private float[] mInitialZoomRatios; + private int mInitialOrientation; public CameraHeadUpDisplay(Context context) { super(context); mContext = context; } + public void initialize(Context context, PreferenceGroup group, + float[] initialZoomRatios, int initialOrientation) { + mInitialZoomRatios = initialZoomRatios; + mInitialOrientation = initialOrientation; + super.initialize(context, group); + } + @Override protected void initializeIndicatorBar( Context context, PreferenceGroup group) { @@ -61,12 +70,24 @@ public class CameraHeadUpDisplay extends HeadUpDisplay { mIndicatorBar.addComponent(mOtherSettings); mGpsIndicator = new GpsIndicator( - context, group, (IconListPreference) + context, (IconListPreference) group.findPreference(CameraSettings.KEY_RECORD_LOCATION)); mIndicatorBar.addComponent(mGpsIndicator); addIndicator(context, group, CameraSettings.KEY_WHITE_BALANCE); addIndicator(context, group, CameraSettings.KEY_FLASH_MODE); + + if (mInitialZoomRatios != null) { + mZoomIndicator = new ZoomIndicator(mContext); + mZoomIndicator.setZoomRatios(mInitialZoomRatios); + mIndicatorBar.addComponent(mZoomIndicator); + } else { + mZoomIndicator = null; + } + + addIndicator(context, group, CameraSettings.KEY_CAMERA_ID); + + mIndicatorBar.setOrientation(mInitialOrientation); } public void setZoomListener(ZoomControllerListener listener) { @@ -114,10 +135,6 @@ public class CameraHeadUpDisplay extends HeadUpDisplay { } private void setZoomRatiosLocked(float[] zoomRatios) { - if (mZoomIndicator == null) { - mZoomIndicator = new ZoomIndicator(mContext); - mIndicatorBar.addComponent(mZoomIndicator); - } mZoomIndicator.setZoomRatios(zoomRatios); } } diff --git a/src/com/android/camera/ui/GpsIndicator.java b/src/com/android/camera/ui/GpsIndicator.java index 45f10b3..78a80b8 100644 --- a/src/com/android/camera/ui/GpsIndicator.java +++ b/src/com/android/camera/ui/GpsIndicator.java @@ -20,7 +20,6 @@ import android.content.Context; import com.android.camera.R; import com.android.camera.IconListPreference; -import com.android.camera.PreferenceGroup; class GpsIndicator extends BasicIndicator { @@ -29,9 +28,8 @@ class GpsIndicator extends BasicIndicator { private ResourceTexture mNoSignalIcon; private boolean mHasSignal = false; - public GpsIndicator(Context context, - PreferenceGroup group, IconListPreference preference) { - super(context, group, preference); + public GpsIndicator(Context context, IconListPreference preference) { + super(context, preference); } @Override diff --git a/src/com/android/camera/ui/HeadUpDisplay.java b/src/com/android/camera/ui/HeadUpDisplay.java index 05d575d..6a7c604 100644 --- a/src/com/android/camera/ui/HeadUpDisplay.java +++ b/src/com/android/camera/ui/HeadUpDisplay.java @@ -181,7 +181,10 @@ public class HeadUpDisplay extends GLView { public void initialize(Context context, PreferenceGroup preferenceGroup) { mPreferenceGroup = preferenceGroup; mSharedPrefs = ComboPreferences.get(context); + mPopupWindow = null; + clearComponents(); initializeIndicatorBar(context, preferenceGroup); + requestLayout(); } private void layoutPopupWindow(GLView anchorView) { @@ -329,7 +332,7 @@ public class HeadUpDisplay extends GLView { IconListPreference iconPref = (IconListPreference) group.findPreference(key); if (iconPref == null) return null; - BasicIndicator indicator = new BasicIndicator(context, group, iconPref); + BasicIndicator indicator = new BasicIndicator(context, iconPref); mIndicatorBar.addComponent(indicator); return indicator; } diff --git a/src/com/android/camera/ui/ZoomIndicator.java b/src/com/android/camera/ui/ZoomIndicator.java index ce6bef8..e74cefd 100644 --- a/src/com/android/camera/ui/ZoomIndicator.java +++ b/src/com/android/camera/ui/ZoomIndicator.java @@ -17,6 +17,7 @@ package com.android.camera.ui; import android.content.Context; +import android.util.Log; import com.android.camera.R; import com.android.camera.ui.ZoomControllerListener; @@ -69,7 +70,7 @@ class ZoomIndicator extends AbstractIndicator { if (mDrawIndex != mZoomIndex) { mDrawIndex = mZoomIndex; if (mTitle != null) mTitle.deleteFromGL(); - float value = mZoomRatios == null ? 0 : mZoomRatios[mZoomIndex]; + float value = mZoomRatios[mZoomIndex]; mTitle = StringTexture.newInstance( sZoomFormat.format(value), mFontSize, FONT_COLOR); } @@ -110,7 +111,8 @@ class ZoomIndicator extends AbstractIndicator { public void setZoomRatios(float[] ratios) { mZoomRatios = ratios; - requestLayout(); + mDrawIndex = -1; + invalidate(); } private class MyZoomListener implements ZoomControllerListener { |