From a6587a1a1e3672013da6a454c0e478846eced15d Mon Sep 17 00:00:00 2001 From: Erin Dahlgren Date: Mon, 3 Feb 2014 13:24:55 -0800 Subject: [PATCH] Elevate refocus to its own mode, merge craft and camera. Change-Id: I9686db26993319fdaf09f09c0610bb65e00a0e05 --- res/layout/mode_options_bottombar.xml | 8 ---- res/values/arrays.xml | 24 ++++------- res/values/strings.xml | 4 ++ src/com/android/camera/ButtonManager.java | 40 ----------------- src/com/android/camera/CameraActivity.java | 17 ++------ src/com/android/camera/PhotoModule.java | 28 +----------- src/com/android/camera/VideoModule.java | 1 - src/com/android/camera/app/CameraAppUI.java | 50 ++++++++-------------- src/com/android/camera/app/ModuleManagerImpl.java | 13 ++---- src/com/android/camera/module/ModulesInfo.java | 21 --------- .../camera/widget/IndicatorIconController.java | 31 -------------- 11 files changed, 39 insertions(+), 198 deletions(-) diff --git a/res/layout/mode_options_bottombar.xml b/res/layout/mode_options_bottombar.xml index 423cdece9..4dd623239 100644 --- a/res/layout/mode_options_bottombar.xml +++ b/res/layout/mode_options_bottombar.xml @@ -41,11 +41,6 @@ android:visibility="invisible" android:background="#4C000000" > - - 0 1 - 2 + 2 3 4 5 6 7 - 8 @integer/camera_mode_photo @integer/camera_mode_video - @integer/camera_mode_craft + @integer/camera_mode_refocus @integer/camera_mode_panorama @integer/camera_mode_photosphere @integer/camera_mode_timelapse @@ -613,56 +612,51 @@ @color/panorama_mode_color @color/timelapse_mode_color @color/settings_mode_color - @color/craft_mode_color - @color/craft_mode_color + @color/camera_mode_color @string/mode_camera @string/mode_video - @string/mode_advanced_camera + @string/mode_refocus @string/mode_photosphere @string/mode_panorama @string/mode_timelapse @string/mode_settings "" - "" @string/mode_camera_desc @string/mode_video_desc - @string/mode_advanced_camera_desc + @string/mode_refocus_desc @string/mode_photosphere_desc @string/mode_panorama_desc @string/mode_timelapse_desc @string/mode_settings_desc "" - "" @drawable/ic_camera_normal @drawable/ic_video_normal - @drawable/ic_craft_normal + @drawable/ic_refocus_normal @drawable/ic_photo_sphere_normal @drawable/ic_panorama_normal @drawable/ic_timelapse_normal @drawable/ic_settings_normal - @drawable/ic_craft_normal - @drawable/ic_craft_normal + @drawable/ic_camera_normal @drawable/ic_camera_normal @drawable/ic_video_normal - @drawable/ic_camera_normal + @drawable/ic_refocus_normal @null @drawable/ic_panorama_normal @null @null - @drawable/ic_craft_normal - @drawable/ic_craft_normal + @drawable/ic_camera_normal diff --git a/res/values/strings.xml b/res/values/strings.xml index 6751f10de..7f515b5ec 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -682,6 +682,8 @@ CHAR LIMIT=NONE] --> Wide Angle Panorama + + Foreground Focus Open Settings @@ -701,6 +703,8 @@ CHAR LIMIT=NONE] --> Switch to Wideangle Mode Switch to Panorama Mode + + Switch to Foreground Focus Mode diff --git a/src/com/android/camera/ButtonManager.java b/src/com/android/camera/ButtonManager.java index 526ffd454..f5e36f647 100644 --- a/src/com/android/camera/ButtonManager.java +++ b/src/com/android/camera/ButtonManager.java @@ -39,7 +39,6 @@ public class ButtonManager implements SettingsManager.OnSettingChangedListener { public static final int BUTTON_CAMERA = 2; public static final int BUTTON_HDRPLUS = 3; public static final int BUTTON_HDR = 4; - public static final int BUTTON_REFOCUS = 5; public static final int BUTTON_CANCEL = 6; public static final int BUTTON_DONE = 7; public static final int BUTTON_RETAKE = 8; @@ -131,8 +130,6 @@ public class ButtonManager implements SettingsManager.OnSettingChangedListener { = (MultiToggleImageButton) root.findViewById(R.id.flash_toggle_button); mButtonPos3 = (MultiToggleImageButton) root.findViewById(R.id.hdr_plus_toggle_button); - mButtonPos4 - = (MultiToggleImageButton) root.findViewById(R.id.refocus_toggle_button); mButtonCancel = (ImageButton) root.findViewById(R.id.cancel_button); mButtonDone @@ -169,11 +166,6 @@ public class ButtonManager implements SettingsManager.OnSettingChangedListener { button = getButtonOrError(BUTTON_HDRPLUS); break; } - case SettingsManager.SETTING_CAMERA_REFOCUS: { - index = mSettingsManager.getStringValueIndex(id); - button = getButtonOrError(BUTTON_REFOCUS); - break; - } default: { // Do nothing. } @@ -228,11 +220,6 @@ public class ButtonManager implements SettingsManager.OnSettingChangedListener { throw new IllegalStateException("Hdr button could not be found."); } return mButtonPos3; - case BUTTON_REFOCUS: - if (mButtonPos4 == null) { - throw new IllegalStateException("Refocus button could not be found."); - } - return mButtonPos4; default: throw new IllegalArgumentException("button not known by id=" + buttonId); } @@ -302,9 +289,6 @@ public class ButtonManager implements SettingsManager.OnSettingChangedListener { case BUTTON_HDR: enableHdrPlusButton(button, cb, R.array.pref_camera_hdr_icons); break; - case BUTTON_REFOCUS: - enableRefocusButton(button, cb, R.array.refocus_icons); - break; default: throw new IllegalArgumentException("button not known by id=" + buttonId); } @@ -548,28 +532,4 @@ public class ButtonManager implements SettingsManager.OnSettingChangedListener { } }); } - - /** - * Enable a refocus button. - */ - private void enableRefocusButton(MultiToggleImageButton button, - final ButtonCallback cb, int resIdImages) { - - if (resIdImages > 0) { - button.overrideImageIds(resIdImages); - } - - int index = mSettingsManager.getStringValueIndex(SettingsManager.SETTING_CAMERA_REFOCUS); - button.setState(index >= 0 ? index : 0, false); - - button.setOnStateChangeListener(new MultiToggleImageButton.OnStateChangeListener() { - @Override - public void stateChanged(View view, int state) { - mSettingsManager.setStringValueIndex(SettingsManager.SETTING_CAMERA_REFOCUS, state); - if (cb != null) { - cb.onStateChanged(state); - } - } - }); - } } \ No newline at end of file diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 1aee123f0..b6e4b3ba7 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -1107,7 +1107,6 @@ public class CameraActivity extends Activity if (modeIndex == getResources().getInteger(R.integer.camera_mode_photo) || modeIndex == getResources().getInteger(R.integer.camera_mode_video) || modeIndex == getResources().getInteger(R.integer.camera_mode_gcam) - || modeIndex == getResources().getInteger(R.integer.camera_mode_craft) || modeIndex == getResources().getInteger(R.integer.camera_mode_refocus)) { mCameraAppUI.prepareModuleUI(); } @@ -1487,7 +1486,7 @@ public class CameraActivity extends Activity CameraPerformanceTracker.onEvent(CameraPerformanceTracker.MODE_SWITCH_START); // Record last used camera mode for quick switching if (modeIndex == getResources().getInteger(R.integer.camera_mode_photo) - || modeIndex == getResources().getInteger(R.integer.camera_mode_craft)) { + || modeIndex == getResources().getInteger(R.integer.camera_mode_gcam)) { mSettingsManager.setInt(SettingsManager.SETTING_KEY_CAMERA_MODULE_LAST_USED_INDEX, modeIndex); } @@ -1498,18 +1497,10 @@ public class CameraActivity extends Activity // Refocus and Gcam are modes that cannot be selected // from the mode list view, because they are not list items. // Check whether we should interpret MODULE_CRAFT as either. - if (modeIndex == getResources().getInteger(R.integer.camera_mode_craft)) { - boolean refocusOn = mSettingsManager.isRefocusOn(); + if (modeIndex == getResources().getInteger(R.integer.camera_mode_photo)) { boolean hdrPlusOn = mSettingsManager.isHdrPlusOn(); - if (refocusOn && hdrPlusOn) { - throw new IllegalStateException("Refocus and hdr plus cannot be on together."); - } - if (refocusOn) { - modeIndex = getResources().getInteger(R.integer.camera_mode_refocus); - } else if (hdrPlusOn && GcamHelper.hasGcamCapture()) { + if (hdrPlusOn && GcamHelper.hasGcamCapture()) { modeIndex = getResources().getInteger(R.integer.camera_mode_gcam); - } else { - // Do nothing, keep MODULE_CRAFT. } } @@ -1521,12 +1512,10 @@ public class CameraActivity extends Activity if (mCurrentModeIndex == getResources().getInteger(R.integer.camera_mode_photo) || mCurrentModeIndex == getResources().getInteger(R.integer.camera_mode_video) || mCurrentModeIndex == getResources().getInteger(R.integer.camera_mode_gcam) - || mCurrentModeIndex == getResources().getInteger(R.integer.camera_mode_craft) || mCurrentModeIndex == getResources().getInteger(R.integer.camera_mode_refocus)) { if (oldModuleIndex != getResources().getInteger(R.integer.camera_mode_photo) && oldModuleIndex != getResources().getInteger(R.integer.camera_mode_video) && oldModuleIndex != getResources().getInteger(R.integer.camera_mode_gcam) - && oldModuleIndex != getResources().getInteger(R.integer.camera_mode_craft) && oldModuleIndex != getResources().getInteger(R.integer.camera_mode_refocus)) { mCameraAppUI.prepareModuleUI(); } else { diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 7c79dfadd..89a8e98c8 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -232,7 +232,6 @@ public class PhotoModule private FocusOverlayManager mFocusManager; private final int mGcamModeIndex; - private final int mRefocusModeIndex; private String mSceneMode; @@ -328,8 +327,6 @@ public class PhotoModule super(app); mGcamModeIndex = app.getAndroidContext().getResources() .getInteger(R.integer.camera_mode_gcam); - mRefocusModeIndex = app.getAndroidContext().getResources() - .getInteger(R.integer.camera_mode_refocus); } @Override @@ -480,18 +477,6 @@ public class PhotoModule } }; - private final ButtonManager.ButtonCallback mRefocusCallback = - new ButtonManager.ButtonCallback() { - @Override - public void onStateChanged(int state) { - if (state == ButtonManager.OFF) { - throw new IllegalStateException( - "Can't switch refocus off because it should already be off."); - } - mActivity.onModeSelected(mRefocusModeIndex); - } - }; - private final View.OnClickListener mCancelCallback = new View.OnClickListener() { @Override public void onClick(View v) { @@ -526,17 +511,8 @@ public class PhotoModule bottomBarSpec.enableCamera = true; bottomBarSpec.cameraCallback = mCameraCallback; bottomBarSpec.enableFlash = true; - - if (mActivity.getCurrentModuleIndex() == mActivity.getResources() - .getInteger(R.integer.camera_mode_photo)) { - bottomBarSpec.hideHdr = true; - bottomBarSpec.hideRefocus = true; - } else { - bottomBarSpec.enableHdr = true; - bottomBarSpec.hdrCallback = mHdrPlusCallback; - bottomBarSpec.enableRefocus = true; - bottomBarSpec.refocusCallback = mRefocusCallback; - } + bottomBarSpec.enableHdr = true; + bottomBarSpec.hdrCallback = mHdrPlusCallback; if (isImageCaptureIntent()) { bottomBarSpec.showCancel = true; diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index f3e85ad4e..42b1e93eb 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -522,7 +522,6 @@ public class VideoModule extends CameraModule bottomBarSpec.enableTorchFlash = true; bottomBarSpec.flashCallback = mFlashCallback; bottomBarSpec.hideHdr = true; - bottomBarSpec.hideRefocus = true; if (isVideoCaptureIntent()) { bottomBarSpec.showCancel = true; diff --git a/src/com/android/camera/app/CameraAppUI.java b/src/com/android/camera/app/CameraAppUI.java index d89b8db50..a4af75f10 100644 --- a/src/com/android/camera/app/CameraAppUI.java +++ b/src/com/android/camera/app/CameraAppUI.java @@ -231,23 +231,16 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, public boolean enableHdr; /** - * Set true if hdr/hdr+ should not be visible, regardless of + * Set true if flash should not be visible, regardless of * hardware limitations. */ - public boolean hideHdr; - - /** - * Set true if the refocus option should be enabled. - * If not set or false, the refocus option will be disabled. - * - * This option is not constrained by hardware limitations. - */ - public boolean enableRefocus; + public boolean hideFlash; /** - * Set true if refocus should not be visible. + * Set true if hdr/hdr+ should not be visible, regardless of + * hardware limitations. */ - public boolean hideRefocus; + public boolean hideHdr; /** * Set true if the panorama horizontal option should be visible. @@ -1184,17 +1177,21 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, buttonManager.hideButton(ButtonManager.BUTTON_CAMERA); } - if (hardwareSpec.isFlashSupported()) { - if (bottomBarSpec.enableFlash && settingsManager.isCameraBackFacing()) { - buttonManager.enableButton(ButtonManager.BUTTON_FLASH, bottomBarSpec.flashCallback); - } else if (bottomBarSpec.enableTorchFlash && settingsManager.isCameraBackFacing()) { - buttonManager.enableButton(ButtonManager.BUTTON_TORCH, bottomBarSpec.flashCallback); + if (bottomBarSpec.hideFlash) { + buttonManager.hideButton(ButtonManager.BUTTON_FLASH); + } else { + if (hardwareSpec.isFlashSupported()) { + if (bottomBarSpec.enableFlash && settingsManager.isCameraBackFacing()) { + buttonManager.enableButton(ButtonManager.BUTTON_FLASH, bottomBarSpec.flashCallback); + } else if (bottomBarSpec.enableTorchFlash && settingsManager.isCameraBackFacing()) { + buttonManager.enableButton(ButtonManager.BUTTON_TORCH, bottomBarSpec.flashCallback); + } else { + buttonManager.disableButton(ButtonManager.BUTTON_FLASH); + } } else { + // Disable flash icon if not supported by the hardware. buttonManager.disableButton(ButtonManager.BUTTON_FLASH); } - } else { - // Disable flash icon if not supported by the hardware. - buttonManager.disableButton(ButtonManager.BUTTON_FLASH); } if (bottomBarSpec.hideHdr) { @@ -1221,19 +1218,6 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, } } - if (bottomBarSpec.hideRefocus) { - buttonManager.hideButton(ButtonManager.BUTTON_REFOCUS); - } else { - if (bottomBarSpec.enableRefocus) { - buttonManager.enableButton(ButtonManager.BUTTON_REFOCUS, - bottomBarSpec.refocusCallback); - } else { - // Disable refocus icon when not enabled, not dependent - // on hardware spec. - buttonManager.disableButton(ButtonManager.BUTTON_REFOCUS); - } - } - if (bottomBarSpec.enablePanoHorizontal && PhotoSphereHelper.getPanoramaHorizontalDrawableId() > 0) { buttonManager.enablePushButton(ButtonManager.BUTTON_PANO_HORIZONTAL, diff --git a/src/com/android/camera/app/ModuleManagerImpl.java b/src/com/android/camera/app/ModuleManagerImpl.java index 65d1e7706..2b64514a7 100644 --- a/src/com/android/camera/app/ModuleManagerImpl.java +++ b/src/com/android/camera/app/ModuleManagerImpl.java @@ -114,19 +114,14 @@ public class ModuleManagerImpl implements ModuleManager { final int videoModuleId = context.getResources().getInteger(R.integer.camera_mode_video); int quickSwitchTo = moduleId; - if (moduleId == photoModuleId) { - // Quick switch from simple camera to video. + if (moduleId == photoModuleId + || moduleId == context.getResources().getInteger(R.integer.camera_mode_gcam)) { + // Quick switch from camera to video. quickSwitchTo = videoModuleId; } else if (moduleId == videoModuleId) { - // Quick switch from video to last used camera (i.e. simple camera or - // advanced camera). + // Quick switch from video to last used camera (i.e. simple camera or hdr+) quickSwitchTo = settingsManager.getInt( SettingsManager.SETTING_KEY_CAMERA_MODULE_LAST_USED_INDEX); - } else if (moduleId == context.getResources().getInteger(R.integer.camera_mode_craft) - || moduleId == context.getResources().getInteger(R.integer.camera_mode_gcam) - || moduleId == context.getResources().getInteger(R.integer.camera_mode_refocus)) { - // Quick switch from advanced camera to video. - quickSwitchTo = videoModuleId; } if (mRegisteredModuleAgents.get(quickSwitchTo) != null) { diff --git a/src/com/android/camera/module/ModulesInfo.java b/src/com/android/camera/module/ModulesInfo.java index 1bf50a6c5..aceed474f 100644 --- a/src/com/android/camera/module/ModulesInfo.java +++ b/src/com/android/camera/module/ModulesInfo.java @@ -38,8 +38,6 @@ public class ModulesInfo { int photoModuleId = context.getResources().getInteger(R.integer.camera_mode_photo); registerPhotoModule(moduleManager, photoModuleId); moduleManager.setDefaultModuleIndex(photoModuleId); - registerCraftModule(moduleManager, context.getResources() - .getInteger(R.integer.camera_mode_craft)); registerVideoModule(moduleManager, context.getResources() .getInteger(R.integer.camera_mode_video)); if (PhotoSphereHelper.hasLightCycleCapture(context)) { @@ -77,25 +75,6 @@ public class ModulesInfo { }); } - private static void registerCraftModule(ModuleManager moduleManager, final int moduleId) { - moduleManager.registerModule(new ModuleManager.ModuleAgent() { - @Override - public int getModuleId() { - return moduleId; - } - - @Override - public boolean requestAppForCamera() { - return true; - } - - @Override - public ModuleController createModule(AppController app) { - return new PhotoModule(app); - } - }); - } - private static void registerVideoModule(ModuleManager moduleManager, final int moduleId) { moduleManager.registerModule(new ModuleManager.ModuleAgent() { @Override diff --git a/src/com/android/camera/widget/IndicatorIconController.java b/src/com/android/camera/widget/IndicatorIconController.java index 7d9284d20..d628fa25c 100644 --- a/src/com/android/camera/widget/IndicatorIconController.java +++ b/src/com/android/camera/widget/IndicatorIconController.java @@ -48,14 +48,12 @@ public class IndicatorIconController private ImageView mFlashIndicator; private ImageView mHdrIndicator; - private ImageView mRefocusIndicator; private ImageView mPanoramaIndicator; private TypedArray mFlashIndicatorPhotoIcons; private TypedArray mFlashIndicatorVideoIcons; private TypedArray mHdrPlusIndicatorIcons; private TypedArray mHdrIndicatorIcons; - private TypedArray mRefocusIndicatorIcons; private TypedArray mPanoramaIndicatorIcons; private AppController mController; @@ -66,7 +64,6 @@ public class IndicatorIconController mFlashIndicator = (ImageView) root.findViewById(R.id.flash_indicator); mHdrIndicator = (ImageView) root.findViewById(R.id.hdr_indicator); - mRefocusIndicator = (ImageView) root.findViewById(R.id.refocus_indicator); mPanoramaIndicator = (ImageView) root.findViewById(R.id.panorama_indicator); mFlashIndicatorPhotoIcons = context.getResources().obtainTypedArray( @@ -77,8 +74,6 @@ public class IndicatorIconController R.array.pref_camera_hdr_plus_indicator_icons); mHdrIndicatorIcons = context.getResources().obtainTypedArray( R.array.pref_camera_hdr_indicator_icons); - mRefocusIndicatorIcons = context.getResources().obtainTypedArray( - R.array.refocus_indicator_icons); if (PhotoSphereHelper.getPanoramaIndicatorArrayId() > 0) { mPanoramaIndicatorIcons = context.getResources().obtainTypedArray( PhotoSphereHelper.getPanoramaIndicatorArrayId()); @@ -117,10 +112,6 @@ public class IndicatorIconController syncHdrIndicator(); break; } - case ButtonManager.BUTTON_REFOCUS: { - syncRefocusIndicator(); - break; - } case ButtonManager.BUTTON_PANO_HORIZONTAL: { syncPanoramaIndicator(); break; @@ -142,7 +133,6 @@ public class IndicatorIconController public void syncIndicators() { syncFlashIndicator(); syncHdrIndicator(); - syncRefocusIndicator(); syncPanoramaIndicator(); } @@ -195,23 +185,6 @@ public class IndicatorIconController } /** - * Sync the icon and the visibility of the refocus indicator. - */ - private void syncRefocusIndicator() { - ButtonManager buttonManager = mController.getButtonManager(); - // If refocus isn't an enabled and visible option, - // do not show the indicator. - if (buttonManager.isEnabled(ButtonManager.BUTTON_REFOCUS) - && buttonManager.isVisible(ButtonManager.BUTTON_REFOCUS)) { - setIndicatorState(mController.getSettingsManager(), - SettingsManager.SETTING_CAMERA_REFOCUS, - mRefocusIndicator, mRefocusIndicatorIcons, false); - } else { - mRefocusIndicator.setVisibility(View.GONE); - } - } - - /** * Sync the icon and the visibility of the panorama indicator. */ private void syncPanoramaIndicator() { @@ -278,10 +251,6 @@ public class IndicatorIconController syncHdrIndicator(); break; } - case SettingsManager.SETTING_CAMERA_REFOCUS: { - syncRefocusIndicator(); - break; - } case SettingsManager.SETTING_CAMERA_PANO_ORIENTATION: { syncPanoramaIndicator(); break; -- 2.11.0