}
@Override
+ public int getPreferredChildModeIndex(int modeIndex) {
+ if (modeIndex == getResources().getInteger(R.integer.camera_mode_photo)) {
+ boolean hdrPlusOn = mSettingsManager.isHdrPlusOn();
+ if (hdrPlusOn && GcamHelper.hasGcamCapture()) {
+ modeIndex = getResources().getInteger(R.integer.camera_mode_gcam);
+ }
+ }
+ return modeIndex;
+ }
+
+ @Override
public void onModeSelected(int modeIndex) {
if (mCurrentModeIndex == modeIndex) {
return;
closeModule(mCurrentModule);
int oldModuleIndex = mCurrentModeIndex;
- // 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_photo)) {
- boolean hdrPlusOn = mSettingsManager.isHdrPlusOn();
- if (hdrPlusOn && GcamHelper.hasGcamCapture()) {
- modeIndex = getResources().getInteger(R.integer.camera_mode_gcam);
- }
- }
-
+ // Select the correct module index from the mode switcher index.
+ modeIndex = getPreferredChildModeIndex(modeIndex);
setModuleFromModeIndex(modeIndex);
mCameraAppUI.resetBottomControls(mCurrentModule, modeIndex);
new ButtonManager.ButtonCallback() {
@Override
public void onStateChanged(int state) {
+ // At the time this callback is fired, the camera id
+ // has be set to the desired camera.
+
if (mPaused || mPendingSwitchCameraId != -1) {
return;
}
+ // If switching to back camera, and HDR+ is still on,
+ // switch back to gcam, otherwise handle callback normally.
+ SettingsManager settingsManager = mActivity.getSettingsManager();
+ if (settingsManager.isCameraBackFacing()) {
+ if (settingsManager.requestsReturnToHdrPlus()) {
+ settingsManager.set(SettingsManager.SETTING_CAMERA_HDR,
+ SettingsManager.VALUE_ON);
+ mHandler.sendEmptyMessage(MSG_SWITCH_TO_GCAM_MODULE);
+ return;
+ }
+ }
+
mPendingSwitchCameraId = state;
Log.v(TAG, "Start to switch camera. cameraId=" + state);
public int getQuickSwitchToModuleId(int currentModuleIndex);
/**
+ * Based on a mode switcher index, choose the correct module index.
+ *
+ * @param modeIndex mode switcher index.
+ * @return module index.
+ */
+ public int getPreferredChildModeIndex(int modeIndex);
+
+ /**
* This gets called when mode is changed.
*
* @param moduleIndex index of the new module to switch to
SettingsManager.SETTING_FLASH_SUPPORTED_BACK_CAMERA);
mKeyMap.put(SettingsManager.KEY_STRICT_UPGRADE_VERSION,
SettingsManager.SETTING_STRICT_UPGRADE_VERSION);
+ mKeyMap.put(SettingsManager.KEY_REQUEST_RETURN_HDR_PLUS,
+ SettingsManager.SETTING_REQUEST_RETURN_HDR_PLUS);
}
/**
return SettingsManager.getStrictUpgradeVersionSetting(mContext);
case SettingsManager.SETTING_FILMSTRIP_PEEK_ANIM_REMAINING_PLAY_TIMES_INDEX:
return SettingsManager.getPeekAnimRemainingTimesSetting(mContext);
+ case SettingsManager.SETTING_REQUEST_RETURN_HDR_PLUS:
+ return SettingsManager.getRequestReturnHdrPlusSetting(mContext);
default:
return mExtraSettings.settingFromId(id);
}
import com.android.camera.ListPreference;
import com.android.camera.app.AppController;
import com.android.camera.app.LocationManager;
+import com.android.camera.util.CameraUtil;
import com.android.camera.util.SettingsHelper;
import com.android.camera2.R;
public static final int SETTING_FLASH_SUPPORTED_BACK_CAMERA = 25;
public static final int SETTING_STRICT_UPGRADE_VERSION = 26;
public static final int SETTING_FILMSTRIP_PEEK_ANIM_REMAINING_PLAY_TIMES_INDEX = 27;
+ // A boolean for requesting to return to HDR plus
+ // as soon as possible, if a user requests a setting/mode option
+ // that forces them to leave HDR plus.
+ public static final int SETTING_REQUEST_RETURN_HDR_PLUS = 28;
// Shared preference keys.
public static final String KEY_RECORD_LOCATION = "pref_camera_recordlocation_key";
public static final String KEY_STRICT_UPGRADE_VERSION = "pref_strict_upgrade_version";
public static final String KEY_FILMSTRIP_PEEK_ANIM_REMAINING_PLAY_TIMES =
"pref_filmstrip_peek_anim_remaining_play_times";
+ public static final String KEY_REQUEST_RETURN_HDR_PLUS = "pref_request_return_hdr_plus";
public static final int WHITE_BALANCE_DEFAULT_INDEX = 2;
return mCameraSettings;
}
if (source.equals(SOURCE_MODULE)) {
- int modeIndex = mAppController.getCurrentModuleIndex();
+ int modeIndex = CameraUtil.getCameraModeParentModeId(
+ mAppController.getCurrentModuleIndex(), mAppController.getAndroidContext());
return getModulePreferences(modeIndex);
}
return null;
KEY_FILMSTRIP_PEEK_ANIM_REMAINING_PLAY_TIMES, null, FLUSH_OFF);
}
+ public static Setting getRequestReturnHdrPlusSetting(Context context) {
+ String defaultValue = context.getString(R.string.setting_none_value);
+ return new Setting(SOURCE_MODULE, TYPE_BOOLEAN, VALUE_OFF,
+ KEY_REQUEST_RETURN_HDR_PLUS, null, FLUSH_OFF);
+ }
+
// Utilities.
/**
}
/**
+ * Returns whether the app should return to hdr plus mode if possible.
+ */
+ public boolean requestsReturnToHdrPlus() {
+ return getBoolean(SettingsManager.SETTING_REQUEST_RETURN_HDR_PLUS);
+ }
+
+ /**
* Returns whether grid lines are set on.
*/
public boolean areGridLinesOn() {