android:gravity="center"
android:visibility="invisible"
android:background="#4C000000" >
- <ImageButton
- android:id="@+id/pano_horizontal_button"
- style="@style/ModeOption" />
- <ImageButton
- android:id="@+id/pano_vertical_button"
+ <!-- pano image ids and descriptions are added at runtime -->
+ <com.android.camera.MultiToggleImageButton
+ android:id="@+id/pano_orientation_toggle_button"
style="@style/ModeOption" />
<com.android.camera.MultiToggleImageButton
android:id="@+id/grid_lines_toggle_button"
import com.android.camera.app.AppController;
import com.android.camera.module.ModuleController;
import com.android.camera.settings.SettingsManager;
-
+import com.android.camera.util.PhotoSphereHelper;
import com.android.camera2.R;
public static final int BUTTON_DONE = 7;
public static final int BUTTON_RETAKE = 8;
public static final int BUTTON_REVIEW = 9;
- public static final int BUTTON_PANO_HORIZONTAL = 10;
- public static final int BUTTON_PANO_VERTICAL = 11;
- public static final int BUTTON_GRID_LINES = 12;
+ public static final int BUTTON_PANO_ORIENTATION = 10;
+ public static final int BUTTON_GRID_LINES = 11;
/** For two state MultiToggleImageButtons, the off index. */
public static final int OFF = 0;
private MultiToggleImageButton mButtonFlash;
private MultiToggleImageButton mButtonHdr;
private MultiToggleImageButton mButtonGridlines;
- private ImageButton mButtonPanoVertical;
- private ImageButton mButtonPanoHorizontal;
+ private MultiToggleImageButton mButtonPanoOrientation;
/** Intent UI buttons. */
private ImageButton mButtonCancel;
= (MultiToggleImageButton) root.findViewById(R.id.hdr_plus_toggle_button);
mButtonGridlines
= (MultiToggleImageButton) root.findViewById(R.id.grid_lines_toggle_button);
- mButtonPanoVertical
- = (ImageButton) root.findViewById(R.id.pano_vertical_button);
- mButtonPanoHorizontal
- = (ImageButton) root.findViewById(R.id.pano_horizontal_button);
+ mButtonPanoOrientation
+ = (MultiToggleImageButton) root.findViewById(R.id.pano_orientation_toggle_button);
mButtonCancel
= (ImageButton) root.findViewById(R.id.cancel_button);
mButtonDone
button = getButtonOrError(BUTTON_GRID_LINES);
break;
}
+ case SettingsManager.SETTING_CAMERA_PANO_ORIENTATION: {
+ index = mSettingsManager.getStringValueIndex(id);
+ button = getButtonOrError(BUTTON_PANO_ORIENTATION);
+ break;
+ }
default: {
// Do nothing.
}
throw new IllegalStateException("Grid lines button could not be found.");
}
return mButtonGridlines;
+ case BUTTON_PANO_ORIENTATION:
+ if (mButtonPanoOrientation == null) {
+ throw new IllegalStateException("Pano orientation button could not be found.");
+ }
+ return mButtonPanoOrientation;
default:
throw new IllegalArgumentException("button not known by id=" + buttonId);
}
*/
private ImageButton getImageButtonOrError(int buttonId) {
switch (buttonId) {
- case BUTTON_PANO_VERTICAL:
- if (mButtonPanoVertical == null) {
- throw new IllegalStateException("Flash button could not be found.");
- }
- return (ImageButton) mButtonPanoVertical;
- case BUTTON_PANO_HORIZONTAL:
- if (mButtonPanoHorizontal == null) {
- throw new IllegalStateException("Flash button could not be found.");
- }
- return (ImageButton) mButtonPanoHorizontal;
case BUTTON_CANCEL:
if (mButtonCancel == null) {
throw new IllegalStateException("Cancel button could not be found.");
case BUTTON_GRID_LINES:
enableGridLinesButton(button, cb, R.array.grid_lines_icons);
break;
+ case BUTTON_PANO_ORIENTATION:
+ enablePanoOrientationButton(button, cb,
+ PhotoSphereHelper.getPanoramaOrientationOptionArrayId());
+ break;
default:
throw new IllegalArgumentException("button not known by id=" + buttonId);
}
SettingsManager.SETTING_CAMERA_GRID_LINES);
button.setState(index >= 0 ? index : 0, true);
}
+
+ /**
+ * Enable a panorama orientation button.
+ */
+ private void enablePanoOrientationButton(MultiToggleImageButton button,
+ final ButtonCallback cb, int resIdImages) {
+
+ if (resIdImages > 0) {
+ button.overrideImageIds(resIdImages);
+ }
+ button.overrideContentDescriptions(
+ PhotoSphereHelper.getPanoramaOrientationDescriptions());
+ button.setOnStateChangeListener(new MultiToggleImageButton.OnStateChangeListener() {
+ @Override
+ public void stateChanged(View view, int state) {
+ mSettingsManager.setStringValueIndex(
+ SettingsManager.SETTING_CAMERA_PANO_ORIENTATION, state);
+ if (cb != null) {
+ cb.onStateChanged(state);
+ }
+ }
+ });
+
+ int index = mSettingsManager.getStringValueIndex(
+ SettingsManager.SETTING_CAMERA_PANO_ORIENTATION);
+ button.setState(index >= 0 ? index : 0, true);
+ }
}
*/
public void setState(int state, boolean callListener) {
mState = state;
- setImageResource(mImageIds[mState]);
- String oldContentDescription = String.valueOf(getContentDescription());
- String newContentDescription = getResources().getString(mDescIds[mState]);
- if (oldContentDescription != null && !oldContentDescription.isEmpty()
- && !oldContentDescription.equals(newContentDescription)) {
- setContentDescription(newContentDescription);
- String announceChange = getResources().getString(
+ if (mImageIds != null) {
+ setImageResource(mImageIds[mState]);
+ }
+ if (mDescIds != null) {
+ String oldContentDescription = String.valueOf(getContentDescription());
+ String newContentDescription = getResources().getString(mDescIds[mState]);
+ if (oldContentDescription != null && !oldContentDescription.isEmpty()
+ && !oldContentDescription.equals(newContentDescription)) {
+ setContentDescription(newContentDescription);
+ String announceChange = getResources().getString(
R.string.button_change_announcement, newContentDescription);
- announceForAccessibility(announceChange);
+ announceForAccessibility(announceChange);
+ }
}
super.setImageLevel(mLevel);
if (callListener && mOnStateChangeListener != null) {
R.styleable.MultiToggleImageButton,
0, 0);
int imageIds = a.getResourceId(R.styleable.MultiToggleImageButton_imageIds, 0);
- overrideImageIds(imageIds);
-
+ if (imageIds > 0) {
+ overrideImageIds(imageIds);
+ }
int descIds = a.getResourceId(R.styleable.MultiToggleImageButton_contentDescriptionIds, 0);
- overrideContentDescriptions(descIds);
-
+ if (descIds > 0) {
+ overrideContentDescriptions(descIds);
+ }
a.recycle();
}
public boolean hideGridLines;
/**
- * Set true if the panorama horizontal option should be visible.
+ * Set true if the panorama orientation option should be visible.
*
* This option is not constrained by hardware limitations.
*/
- public boolean enablePanoHorizontal;
-
- /**
- * Set true if the panorama vertical option should be visible.
- *
- * This option is not constrained by hardware limitations.
- */
- public boolean enablePanoVertical;
+ public boolean enablePanoOrientation;
/** Intent UI */
/** Mode options callbacks */
/**
- * A {@link android.com.android.camera.ButtonManager.ButtonCallback}
+ * A {@link com.android.camera.ButtonManager.ButtonCallback}
* that will be executed when the camera option is pressed. This
* callback can be null.
*/
public ButtonManager.ButtonCallback cameraCallback;
/**
- * A {@link android.com.android.camera.ButtonManager.ButtonCallback}
+ * A {@link com.android.camera.ButtonManager.ButtonCallback}
* that will be executed when the flash option is pressed. This
* callback can be null.
*/
public ButtonManager.ButtonCallback flashCallback;
/**
- * A {@link android.com.android.camera.ButtonManager.ButtonCallback}
+ * A {@link com.android.camera.ButtonManager.ButtonCallback}
* that will be executed when the hdr/hdr+ option is pressed. This
* callback can be null.
*/
public ButtonManager.ButtonCallback hdrCallback;
/**
- * A {@link android.com.android.camera.ButtonManager.ButtonCallback}
+ * A {@link com.android.camera.ButtonManager.ButtonCallback}
* that will be executed when the grid lines option is pressed. This
* callback can be null.
*/
public ButtonManager.ButtonCallback gridLinesCallback;
/**
- * A {@link android.view.View.OnClickListener} that will execute
- * when the panorama horizontal option is pressed.
- * This callback can be null.
- */
- public View.OnClickListener panoHorizontalCallback;
-
- /**
- * A {@link android.view.View.OnClickListener} that will execute
- * when the panorama vertical option is pressed.
+ * A {@link com.android.camera.ButtonManager.ButtonCallback}
+ * that will execute when the panorama orientation option is pressed.
* This callback can be null.
*/
- public View.OnClickListener panoVerticalCallback;
+ public ButtonManager.ButtonCallback panoOrientationCallback;
/** Intent UI callbacks */
}
}
- if (bottomBarSpec.enablePanoHorizontal
- && PhotoSphereHelper.getPanoramaHorizontalDrawableId() > 0) {
- buttonManager.enablePushButton(ButtonManager.BUTTON_PANO_HORIZONTAL,
- bottomBarSpec.panoHorizontalCallback,
- PhotoSphereHelper.getPanoramaHorizontalDrawableId());
- } else {
- buttonManager.hideButton(ButtonManager.BUTTON_PANO_HORIZONTAL);
- }
-
- if (bottomBarSpec.enablePanoVertical
- && PhotoSphereHelper.getPanoramaVerticalDrawableId() > 0) {
- buttonManager.enablePushButton(ButtonManager.BUTTON_PANO_VERTICAL,
- bottomBarSpec.panoVerticalCallback,
- PhotoSphereHelper.getPanoramaVerticalDrawableId());
+ if (bottomBarSpec.enablePanoOrientation
+ && PhotoSphereHelper.getPanoramaOrientationOptionArrayId() > 0) {
+ buttonManager.enableButton(ButtonManager.BUTTON_PANO_ORIENTATION,
+ bottomBarSpec.panoOrientationCallback);
} else {
- buttonManager.hideButton(ButtonManager.BUTTON_PANO_VERTICAL);
+ buttonManager.hideButton(ButtonManager.BUTTON_PANO_ORIENTATION);
}
/** Intent UI */
return gridLinesOn.equals(SettingsManager.VALUE_ON);
}
+ /**
+ * Returns whether pano orientation is horizontal.
+ */
+ public boolean isPanoOrientationHorizontal() {
+ String orientation = get(SettingsManager.SETTING_CAMERA_PANO_ORIENTATION);
+ String horizontal = mContext.getString(R.string.pano_orientation_horizontal);
+ return orientation.equals(horizontal);
+ }
+
// TODO: refactor this into a separate utils module.
/**
}
/**
- * Get the resource id of the panorama indicator icon array.
+ * Get the resource id of the panorama orientation option icon array.
*/
- public static int getPanoramaIndicatorArrayId() {
+ public static int getPanoramaOrientationOptionArrayId() {
+ return 0;
+ }
+
+ /**
+ * Get the resource id of the panorama orientation descriptions array.
+ */
+ public static int getPanoramaOrientationDescriptions() {
return 0;
}
}