summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/CaptureAnimManager.java7
-rw-r--r--src/com/android/camera/PhotoMenu.java74
-rw-r--r--src/com/android/camera/PhotoModule.java11
-rw-r--r--src/com/android/camera/PhotoUI.java28
-rw-r--r--src/com/android/camera/PieController.java12
-rw-r--r--src/com/android/camera/VideoMenu.java58
-rw-r--r--src/com/android/camera/VideoModule.java6
-rw-r--r--src/com/android/camera/VideoUI.java6
-rw-r--r--src/com/android/camera/ui/CameraControls.java53
-rw-r--r--src/com/android/camera/ui/CameraSwitcher.java38
-rw-r--r--src/com/android/camera/ui/PieItem.java15
-rw-r--r--src/com/android/camera/ui/PieRenderer.java60
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java39
-rw-r--r--src/com/android/gallery3d/filtershow/category/Action.java10
-rw-r--r--src/com/android/gallery3d/filtershow/category/CategoryView.java14
-rw-r--r--src/com/android/gallery3d/filtershow/editors/ParametricEditor.java2
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java2
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java9
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java14
-rw-r--r--src/com/android/gallery3d/filtershow/state/State.java10
-rw-r--r--src/com/android/gallery3d/filtershow/state/StateAdapter.java37
-rw-r--r--src/com/android/gallery3d/filtershow/state/StatePanelTrack.java28
-rw-r--r--src/com/android/gallery3d/filtershow/state/StateView.java1
-rw-r--r--src/com/android/gallery3d/ui/ActionModeHandler.java2
-rw-r--r--src/com/android/photos/data/PhotoDatabase.java9
25 files changed, 341 insertions, 204 deletions
diff --git a/src/com/android/camera/CaptureAnimManager.java b/src/com/android/camera/CaptureAnimManager.java
index b820ac9fa..f6e112d7e 100644
--- a/src/com/android/camera/CaptureAnimManager.java
+++ b/src/com/android/camera/CaptureAnimManager.java
@@ -19,7 +19,6 @@ package com.android.camera;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.SystemClock;
-import android.util.Log;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
@@ -68,6 +67,10 @@ public class CaptureAnimManager {
private int mSize;
private Resources mResources;
+ public static int getAnimationDuration() {
+ return TIME_SLIDE2;
+ }
+
/* preview: camera preview view.
* review: view of picture just taken.
*/
@@ -124,7 +127,7 @@ public class CaptureAnimManager {
break;
case 90: // Preview is below.
mHoldX = x + mMarginTop;
- mHoldY = y + mMarginRight + mSize;
+ mHoldY = y + mMarginRight;
break;
case 180: // Preview on the right.
mHoldX = x + mMarginRight;
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index 31fe670ff..f29ed4a8b 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -36,16 +36,6 @@ public class PhotoMenu extends PieController
ListPrefSettingPopup.Listener {
private static String TAG = "CAM_photomenu";
- private static final int POS_HDR = 0;
- private static final int POS_EXP = 1;
- private static final int POS_MORE = 2;
- private static final int POS_FLASH = 3;
- private static final int POS_SWITCH = 4;
- private static final int POS_LOCATION = 1;
- private static final int POS_WB = 3;
- private static final int POS_SET = 2;
- private static final int POS_SCENE = 4;
-
private final String mSettingOff;
private PhotoUI mUI;
@@ -69,21 +59,32 @@ public class PhotoMenu extends PieController
mSecondPopup = null;
PieItem item = null;
final Resources res = mActivity.getResources();
- // flash
- if (group.findPreference(CameraSettings.KEY_FLASH_MODE) != null) {
- item = makeItem(CameraSettings.KEY_FLASH_MODE, POS_FLASH, 5);
- item.setLabel(res.getString(R.string.pref_camera_flashmode_label));
+ // the order is from left to right in the menu
+
+ // hdr
+ if (group.findPreference(CameraSettings.KEY_CAMERA_HDR) != null) {
+ item = makeSwitchItem(CameraSettings.KEY_CAMERA_HDR, true);
mRenderer.addItem(item);
}
// exposure compensation
if (group.findPreference(CameraSettings.KEY_EXPOSURE) != null) {
- item = makeItem(CameraSettings.KEY_EXPOSURE, POS_EXP, 5);
+ item = makeItem(CameraSettings.KEY_EXPOSURE);
item.setLabel(res.getString(R.string.pref_exposure_label));
mRenderer.addItem(item);
}
+ // more settings
+ PieItem more = makeItem(R.drawable.ic_settings_holo_light);
+ more.setLabel(res.getString(R.string.camera_menu_more_label));
+ mRenderer.addItem(more);
+ // flash
+ if (group.findPreference(CameraSettings.KEY_FLASH_MODE) != null) {
+ item = makeItem(CameraSettings.KEY_FLASH_MODE);
+ item.setLabel(res.getString(R.string.pref_camera_flashmode_label));
+ mRenderer.addItem(item);
+ }
// camera switcher
if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) {
- item = makeSwitchItem(CameraSettings.KEY_CAMERA_ID, POS_SWITCH, 5, false);
+ item = makeSwitchItem(CameraSettings.KEY_CAMERA_ID, false);
final PieItem fitem = item;
item.setOnClickListener(new OnClickListener() {
@Override
@@ -103,33 +104,9 @@ public class PhotoMenu extends PieController
});
mRenderer.addItem(item);
}
- // hdr
- if (group.findPreference(CameraSettings.KEY_CAMERA_HDR) != null) {
- item = makeSwitchItem(CameraSettings.KEY_CAMERA_HDR, POS_HDR, 5, true);
- mRenderer.addItem(item);
- }
- // more settings
- PieItem more = makeItem(R.drawable.ic_settings_holo_light);
- more.setPosition(POS_MORE, 5);
- more.setLabel(res.getString(R.string.camera_menu_more_label));
- mRenderer.addItem(more);
- // white balance
- if (group.findPreference(CameraSettings.KEY_WHITE_BALANCE) != null) {
- item = makeItem(CameraSettings.KEY_WHITE_BALANCE, POS_WB, 5);
- item.setLabel(res.getString(R.string.pref_camera_whitebalance_label));
- more.addItem(item);
- }
// location
if (group.findPreference(CameraSettings.KEY_RECORD_LOCATION) != null) {
- item = makeSwitchItem(CameraSettings.KEY_RECORD_LOCATION, POS_LOCATION, 5, true);
- more.addItem(item);
- }
- // scene mode
- if (group.findPreference(CameraSettings.KEY_SCENE_MODE) != null) {
- IconListPreference pref = (IconListPreference) group.findPreference(
- CameraSettings.KEY_SCENE_MODE);
- pref.setUseSingleIcon(true);
- item = makeItem(CameraSettings.KEY_SCENE_MODE, POS_SCENE, 5);
+ item = makeSwitchItem(CameraSettings.KEY_RECORD_LOCATION, true);
more.addItem(item);
}
// settings popup
@@ -141,7 +118,6 @@ public class PhotoMenu extends PieController
};
item = makeItem(R.drawable.ic_settings_holo_light);
item.setLabel(res.getString(R.string.camera_menu_settings_label));
- item.setPosition(POS_SET, 5);
item.setOnClickListener(new OnClickListener() {
@Override
public void onClick(PieItem item) {
@@ -152,6 +128,20 @@ public class PhotoMenu extends PieController
}
});
more.addItem(item);
+ // white balance
+ if (group.findPreference(CameraSettings.KEY_WHITE_BALANCE) != null) {
+ item = makeItem(CameraSettings.KEY_WHITE_BALANCE);
+ item.setLabel(res.getString(R.string.pref_camera_whitebalance_label));
+ more.addItem(item);
+ }
+ // scene mode
+ if (group.findPreference(CameraSettings.KEY_SCENE_MODE) != null) {
+ IconListPreference pref = (IconListPreference) group.findPreference(
+ CameraSettings.KEY_SCENE_MODE);
+ pref.setUseSingleIcon(true);
+ item = makeItem(CameraSettings.KEY_SCENE_MODE);
+ more.addItem(item);
+ }
}
@Override
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 4d3f7fb22..5b352719f 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -105,6 +105,7 @@ public class PhotoModule
private static final int START_PREVIEW_DONE = 10;
private static final int OPEN_CAMERA_FAIL = 11;
private static final int CAMERA_DISABLED = 12;
+ private static final int CAPTURE_ANIMATION_DONE = 13;
// The subset of parameters we need to update in setCameraParameters().
private static final int UPDATE_PARAM_INITIALIZE = 1;
@@ -398,6 +399,10 @@ public class PhotoModule
R.string.camera_disabled);
break;
}
+ case CAPTURE_ANIMATION_DONE: {
+ mUI.enablePreviewThumb(false);
+ break;
+ }
}
}
}
@@ -809,7 +814,10 @@ public class PhotoModule
if (ApiHelper.HAS_SURFACE_TEXTURE && !mIsImageCaptureIntent
&& mActivity.mShowCameraAppView) {
// Finish capture animation
+ mHandler.removeMessages(CAPTURE_ANIMATION_DONE);
((CameraScreenNail) mActivity.mCameraScreenNail).animateSlide();
+ mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
+ CaptureAnimManager.getAnimationDuration());
}
mFocusManager.updateFocusUI(); // Ensure focus indicator is hidden.
if (!mIsImageCaptureIntent) {
@@ -968,6 +976,9 @@ public class PhotoModule
&& mActivity.mShowCameraAppView) {
// Start capture animation.
((CameraScreenNail) mActivity.mCameraScreenNail).animateFlash(mDisplayRotation);
+ mUI.enablePreviewThumb(true);
+ mHandler.sendEmptyMessageDelayed(CAPTURE_ANIMATION_DONE,
+ CaptureAnimManager.getAnimationDuration());
}
}
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index e2b78197f..bc43f4763 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -92,6 +92,7 @@ public class PhotoUI implements PieListener,
private int mPreviewWidth = 0;
private int mPreviewHeight = 0;
+ private View mPreviewThumb;
private OnLayoutChangeListener mLayoutListener = new OnLayoutChangeListener() {
@Override
@@ -173,6 +174,7 @@ public class PhotoUI implements PieListener,
mGestures.setRenderOverlay(mRenderOverlay);
mGestures.addTouchReceiver(mMenuButton);
mGestures.addUnclickableArea(mBlocker);
+ enablePreviewThumb(false);
// make sure to add touch targets for image capture
if (mController.isImageCaptureIntent()) {
if (mReviewCancelButton != null) {
@@ -201,6 +203,13 @@ public class PhotoUI implements PieListener,
public void initializeControlByIntent() {
mBlocker = mActivity.findViewById(R.id.blocker);
+ mPreviewThumb = mActivity.findViewById(R.id.preview_thumb);
+ mPreviewThumb.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mActivity.gotoGallery();
+ }
+ });
mMenuButton = mActivity.findViewById(R.id.menu);
mMenuButton.setOnClickListener(new OnClickListener() {
@Override
@@ -306,16 +315,11 @@ public class PhotoUI implements PieListener,
wbIndex = pref.getCurrentIndex();
}
mOnScreenIndicators.updateWBIndicator(wbIndex);
- boolean location = false;
- pref = group.findPreference(CameraSettings.KEY_RECORD_LOCATION);
- if (pref != null) {
- location = !(pref.getCurrentIndex() == 0);
- }
+ boolean location = RecordLocationPreference.get(
+ prefs, mActivity.getContentResolver());
mOnScreenIndicators.updateLocationIndicator(location);
}
-
-
public void setCameraState(int state) {
}
@@ -372,6 +376,16 @@ public class PhotoUI implements PieListener,
if (!full && mCountDownView != null) mCountDownView.cancelCountDown();
}
+ public void enablePreviewThumb(boolean enabled) {
+ if (enabled) {
+ mGestures.addTouchReceiver(mPreviewThumb);
+ mPreviewThumb.setVisibility(View.VISIBLE);
+ } else {
+ mGestures.removeTouchReceiver(mPreviewThumb);
+ mPreviewThumb.setVisibility(View.GONE);
+ }
+ }
+
public boolean removeTopLevelPopup() {
// Remove the top level popup or dialog box and return true if there's any
if (mPopup != null) {
diff --git a/src/com/android/camera/PieController.java b/src/com/android/camera/PieController.java
index d2d9c7f0f..3cbcb4bf5 100644
--- a/src/com/android/camera/PieController.java
+++ b/src/com/android/camera/PieController.java
@@ -89,7 +89,7 @@ public class PieController {
return new PieItem(drawable, 0);
}
- public PieItem makeItem(String prefKey, int position, int count) {
+ public PieItem makeItem(String prefKey) {
final IconListPreference pref =
(IconListPreference) mPreferenceGroup.findPreference(prefKey);
if (pref == null) return null;
@@ -104,7 +104,6 @@ public class PieController {
resid = pref.getSingleIcon();
}
PieItem item = makeItem(resid);
- item.setPosition(position, count);
item.setLabel(pref.getTitle().toUpperCase());
mPreferences.add(pref);
mPreferenceMap.put(pref, item);
@@ -117,7 +116,6 @@ public class PieController {
} else {
inner = makeItem(pref.getEntries()[i]);
}
- inner.setPosition(i, nOfEntries);
inner.setLabel(pref.getLabels()[i]);
item.addItem(inner);
final int index = i;
@@ -134,8 +132,7 @@ public class PieController {
return item;
}
- public PieItem makeSwitchItem(final String prefKey, int position, int count,
- boolean addListener) {
+ public PieItem makeSwitchItem(final String prefKey, boolean addListener) {
final IconListPreference pref =
(IconListPreference) mPreferenceGroup.findPreference(prefKey);
if (pref == null) return null;
@@ -150,7 +147,6 @@ public class PieController {
resid = pref.getSingleIcon();
}
PieItem item = makeItem(resid);
- item.setPosition(position, count);
item.setLabel(pref.getLabels()[index]);
item.setImageResource(mActivity, resid);
mPreferences.add(pref);
@@ -183,8 +179,8 @@ public class PieController {
return item;
}
- public void addItem(String prefKey, int position, int count) {
- PieItem item = makeItem(prefKey, position, count);
+ public void addItem(String prefKey) {
+ PieItem item = makeItem(prefKey);
mRenderer.addItem(item);
}
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
index fee7665fa..9bfcdea5d 100644
--- a/src/com/android/camera/VideoMenu.java
+++ b/src/com/android/camera/VideoMenu.java
@@ -34,10 +34,6 @@ public class VideoMenu extends PieController
TimeIntervalPopup.Listener {
private static String TAG = "CAM_VideoMenu";
- private static final int POS_WB = 0;
- private static final int POS_SET = 1;
- private static final int POS_FLASH = 3;
- private static final int POS_SWITCH = 2;
private VideoUI mUI;
private String[] mOtherKeys;
@@ -60,20 +56,34 @@ public class VideoMenu extends PieController
mPopup = null;
mPopupStatus = POPUP_NONE;
PieItem item = null;
- // flash
- if (group.findPreference(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE) != null) {
- item = makeItem(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE, POS_FLASH, 4);
- mRenderer.addItem(item);
- }
// white balance
if (group.findPreference(CameraSettings.KEY_WHITE_BALANCE) != null) {
- item = makeItem(CameraSettings.KEY_WHITE_BALANCE, POS_WB, 4);
+ item = makeItem(CameraSettings.KEY_WHITE_BALANCE);
mRenderer.addItem(item);
}
+ // settings popup
+ mOtherKeys = new String[] {
+ CameraSettings.KEY_VIDEO_EFFECT,
+ CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL,
+ CameraSettings.KEY_VIDEO_QUALITY,
+ CameraSettings.KEY_RECORD_LOCATION
+ };
+ item = makeItem(R.drawable.ic_settings_holo_light);
+ item.setLabel(mActivity.getResources().getString(R.string.camera_menu_settings_label));
+ item.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(PieItem item) {
+ if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) {
+ initializePopup();
+ mPopupStatus = POPUP_FIRST_LEVEL;
+ }
+ mUI.showPopup(mPopup);
+ }
+ });
+ mRenderer.addItem(item);
// camera switcher
if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) {
item = makeItem(R.drawable.ic_switch_back);
- item.setPosition(POS_SWITCH, 4);
IconListPreference lpref = (IconListPreference) group.findPreference(
CameraSettings.KEY_CAMERA_ID);
item.setLabel(lpref.getLabel());
@@ -103,27 +113,11 @@ public class VideoMenu extends PieController
});
mRenderer.addItem(item);
}
- // settings popup
- mOtherKeys = new String[] {
- CameraSettings.KEY_VIDEO_EFFECT,
- CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL,
- CameraSettings.KEY_VIDEO_QUALITY,
- CameraSettings.KEY_RECORD_LOCATION
- };
- item = makeItem(R.drawable.ic_settings_holo_light);
- item.setPosition(POS_SET, 4);
- item.setLabel(mActivity.getResources().getString(R.string.camera_menu_settings_label));
- item.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(PieItem item) {
- if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) {
- initializePopup();
- mPopupStatus = POPUP_FIRST_LEVEL;
- }
- mUI.showPopup(mPopup);
- }
- });
- mRenderer.addItem(item);
+ // flash
+ if (group.findPreference(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE) != null) {
+ item = makeItem(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE);
+ mRenderer.addItem(item);
+ }
}
@Override
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 54d9f3633..0bcdbabb5 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -417,7 +417,7 @@ public class VideoModule implements CameraModule,
initializeVideoControl();
mPendingSwitchCameraId = -1;
- mUI.updateOnScreenIndicators(mParameters);
+ mUI.updateOnScreenIndicators(mParameters, mPreferences);
// Disable the shutter button if effects are ON since it might take
// a little more time for the effects preview to be ready. We do not
@@ -2008,7 +2008,7 @@ public class VideoModule implements CameraModule,
} else {
setCameraParameters();
}
- mUI.updateOnScreenIndicators(mParameters);
+ mUI.updateOnScreenIndicators(mParameters, mPreferences);
}
}
@@ -2046,7 +2046,7 @@ public class VideoModule implements CameraModule,
// onFrameAvailable from the old camera may already exist.
mHandler.sendEmptyMessage(SWITCH_CAMERA_START_ANIMATION);
}
- mUI.updateOnScreenIndicators(mParameters);
+ mUI.updateOnScreenIndicators(mParameters, mPreferences);
}
// Preview texture has been copied. Now camera can be released and the
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index e55de9e6d..0afcd8a8d 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -251,8 +251,12 @@ public class VideoUI implements SurfaceHolder.Callback, PieRenderer.PieListener,
mLabelsLinearLayout = (LinearLayout) mRootView.findViewById(R.id.labels);
}
- public void updateOnScreenIndicators(Parameters param) {
+ public void updateOnScreenIndicators(Parameters param, ComboPreferences prefs) {
mOnScreenIndicators.updateFlashOnScreenIndicator(param.getFlashMode());
+ boolean location = RecordLocationPreference.get(
+ prefs, mActivity.getContentResolver());
+ mOnScreenIndicators.updateLocationIndicator(location);
+
}
public void setAspectRatio(double ratio) {
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 668b49467..f7af52c28 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -21,7 +21,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
@@ -38,6 +37,7 @@ public class CameraControls extends RotatableLayout {
private View mSwitcher;
private View mMenu;
private View mIndicators;
+ private View mPreview;
public CameraControls(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -61,20 +61,47 @@ public class CameraControls extends RotatableLayout {
mShutter = findViewById(R.id.shutter_button);
mMenu = findViewById(R.id.menu);
mIndicators = findViewById(R.id.on_screen_indicators);
+ mPreview = findViewById(R.id.preview_thumb);
}
@Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
int orientation = getResources().getConfiguration().orientation;
int rotation = Util.getDisplayRotation((Activity) getContext());
+ int size = getResources().getDimensionPixelSize(R.dimen.camera_controls_size);
rotation = correctRotation(rotation, orientation);
super.onLayout(changed, l, t, r, b);
Rect shutter = new Rect();
+ topRight(mPreview, l, t, r, b, orientation, rotation);
+ if (size > 0) {
+ // restrict controls to size
+ switch (rotation) {
+ case 0:
+ case 180:
+ l = (l + r - size) / 2;
+ r = l + size;
+ break;
+ case 90:
+ case 270:
+ t = (t + b - size) / 2;
+ b = t + size;
+ break;
+ }
+ }
center(mShutter, l, t, r, b, orientation, rotation, shutter);
center(mBackgroundView, l, t, r, b, orientation, rotation, new Rect());
toLeft(mSwitcher, l, t, r, b, orientation, rotation, shutter);
toRight(mMenu, l, t, r, b, orientation, rotation, shutter);
toRight(mIndicators, l, t, r, b, orientation, rotation, shutter);
+ View retake = findViewById(R.id.btn_retake);
+ if (retake != null) {
+ Rect retakeRect = new Rect();
+ center(retake, l, t, r, b, orientation, rotation, retakeRect);
+ View cancel = findViewById(R.id.btn_cancel);
+ toLeft(cancel, l, t, r, b, orientation, rotation, shutter);
+ View done = findViewById(R.id.btn_done);
+ toRight(done, l, t, r, b, orientation, rotation, shutter);
+ }
}
private int correctRotation(int rotation, int orientation) {
@@ -87,6 +114,7 @@ public class CameraControls extends RotatableLayout {
}
return rotation;
}
+
private void center(View v, int l, int t, int r, int b, int orientation, int rotation, Rect result) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
int tw = lp.leftMargin + v.getMeasuredWidth() + lp.rightMargin;
@@ -94,8 +122,8 @@ public class CameraControls extends RotatableLayout {
switch (rotation) {
case 0:
// phone portrait; controls bottom
- result.left = (r - l) / 2 - tw / 2 + lp.leftMargin;
- result.right = (r - l) / 2 + tw / 2 - lp.rightMargin;
+ result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
+ result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
result.bottom = b - lp.bottomMargin;
result.top = b - th + lp.topMargin;
break;
@@ -103,13 +131,13 @@ public class CameraControls extends RotatableLayout {
// phone landscape: controls right
result.right = r - lp.rightMargin;
result.left = r - tw + lp.leftMargin;
- result.top = (b - t) / 2 - th / 2 + lp.topMargin;
- result.bottom = (b - t) / 2 + th / 2 - lp.bottomMargin;
+ result.top = (b + t) / 2 - th / 2 + lp.topMargin;
+ result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
break;
case 180:
// phone upside down: controls top
- result.left = (r - l) / 2 - tw / 2 + lp.leftMargin;
- result.right = (r - l) / 2 + tw / 2 - lp.rightMargin;
+ result.left = (r + l) / 2 - tw / 2 + lp.leftMargin;
+ result.right = (r + l) / 2 + tw / 2 - lp.rightMargin;
result.top = t + lp.topMargin;
result.bottom = t + th - lp.bottomMargin;
break;
@@ -117,8 +145,8 @@ public class CameraControls extends RotatableLayout {
// reverse landscape: controls left
result.left = l + lp.leftMargin;
result.right = l + tw - lp.rightMargin;
- result.top = (b - t) / 2 - th / 2 + lp.topMargin;
- result.bottom = (b - t) / 2 + th / 2 - lp.bottomMargin;
+ result.top = (b + t) / 2 - th / 2 + lp.topMargin;
+ result.bottom = (b + t) / 2 + th / 2 - lp.bottomMargin;
break;
}
v.layout(result.left, result.top, result.right, result.bottom);
@@ -200,6 +228,13 @@ public class CameraControls extends RotatableLayout {
v.layout(result.left, result.top, result.right, result.bottom);
}
+ private void topRight(View v, int l, int t, int r, int b, int orientation, int rotation) {
+ // layout using the specific margins; the rotation code messes up the others
+ int mt = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_top);
+ int mr = getContext().getResources().getDimensionPixelSize(R.dimen.capture_margin_right);
+ v.layout(r - v.getMeasuredWidth() - mr, t + mt, r - mr, t + mt + v.getMeasuredHeight());
+ }
+
// In reverse landscape and reverse portrait, camera controls will be laid out
// on the wrong side of the screen. We need to make adjustment to move the controls
// to the USB side
diff --git a/src/com/android/camera/ui/CameraSwitcher.java b/src/com/android/camera/ui/CameraSwitcher.java
index fee28a376..537577fb5 100644
--- a/src/com/android/camera/ui/CameraSwitcher.java
+++ b/src/com/android/camera/ui/CameraSwitcher.java
@@ -25,7 +25,6 @@ import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
-import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -202,6 +201,8 @@ public class CameraSwitcher extends RotateImageView
}
content.addView(item, new LinearLayout.LayoutParams(mItemSize, mItemSize));
}
+ mPopup.measure(MeasureSpec.makeMeasureSpec(mParent.getWidth(), MeasureSpec.AT_MOST),
+ MeasureSpec.makeMeasureSpec(mParent.getHeight(), MeasureSpec.AT_MOST));
}
public boolean showsPopup() {
@@ -244,6 +245,7 @@ public class CameraSwitcher extends RotateImageView
if (mPopup == null) {
initPopup();
}
+ layoutPopup();
mPopup.setVisibility(View.VISIBLE);
if (!animateShowPopup()) {
setVisibility(View.INVISIBLE);
@@ -274,20 +276,34 @@ public class CameraSwitcher extends RotateImageView
}
}
- private void updateInitialTranslations() {
+ private void layoutPopup() {
int orientation = Util.getDisplayRotation((Activity) getContext());
+ int w = mPopup.getMeasuredWidth();
+ int h = mPopup.getMeasuredHeight();
if (orientation == 0) {
- mTranslationX = -getWidth() / 2;
- mTranslationY = getHeight();
+ mPopup.layout(getRight() - w, getBottom() - h, getRight(), getBottom());
+ mTranslationX = 0;
+ mTranslationY = h / 3;
} else if (orientation == 90) {
- mTranslationX = getWidth();
- mTranslationY = getHeight() / 2;
+ mTranslationX = w / 3;
+ mTranslationY = - h / 3;
+ mPopup.layout(getRight() - w, getTop(), getRight(), getTop() + h);
} else if (orientation == 180) {
- mTranslationX = getWidth();
- mTranslationY = -getHeight() / 2;
+ mTranslationX = - w / 3;
+ mTranslationY = - h / 3;
+ mPopup.layout(getLeft(), getTop(), getLeft() + w, getTop() + h);
} else {
- mTranslationX = -getWidth();
- mTranslationY = -getHeight() / 2;
+ mTranslationX = - w / 3;
+ mTranslationY = h - getHeight();
+ mPopup.layout(getLeft(), getBottom() - h, getLeft() + w, getBottom());
+ }
+ }
+
+ @Override
+ public void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ if (mPopup != null) {
+ layoutPopup();
}
}
@@ -295,7 +311,7 @@ public class CameraSwitcher extends RotateImageView
if (!ApiHelper.HAS_VIEW_PROPERTY_ANIMATOR) {
return;
}
- updateInitialTranslations();
+ layoutPopup();
mPopup.setScaleX(0.3f);
mPopup.setScaleY(0.3f);
mPopup.setTranslationX(mTranslationX);
diff --git a/src/com/android/camera/ui/PieItem.java b/src/com/android/camera/ui/PieItem.java
index 6dbcb85d5..47fe06758 100644
--- a/src/com/android/camera/ui/PieItem.java
+++ b/src/com/android/camera/ui/PieItem.java
@@ -35,8 +35,6 @@ public class PieItem {
private Drawable mDrawable;
private int level;
- private int mPosition;
- private int mCount;
private boolean mSelected;
private boolean mEnabled;
@@ -68,19 +66,6 @@ public class PieItem {
return mLabel;
}
- public void setPosition(int pos, int count) {
- mPosition = pos;
- mCount = count;
- }
-
- public int getPosition() {
- return mPosition;
- }
-
- public int getCount() {
- return mCount;
- }
-
public boolean hasItems() {
return mItems != null;
}
diff --git a/src/com/android/camera/ui/PieRenderer.java b/src/com/android/camera/ui/PieRenderer.java
index a4e7eb044..dcd6350e2 100644
--- a/src/com/android/camera/ui/PieRenderer.java
+++ b/src/com/android/camera/ui/PieRenderer.java
@@ -370,10 +370,12 @@ public class PieRenderer extends OverlayRenderer
Path path = makeSlice(getDegrees(0) + extend, getDegrees(SWEEP_ARC) - extend,
mArcRadius, mArcRadius + mRadiusInc + mRadiusInc / 4,
mPieCenterX, mArcCenterY - level * mRadiusInc);
+ final int count = items.size();
+ int pos = 0;
for (PieItem item : items) {
// shared between items
item.setPath(path);
- float angle = getArcCenter(item);
+ float angle = getArcCenter(item, pos, count);
int w = item.getIntrinsicWidth();
int h = item.getIntrinsicHeight();
// move views to outer border
@@ -386,6 +388,7 @@ public class PieRenderer extends OverlayRenderer
if (item.hasItems()) {
layoutItems(level + 1, item.getItems());
}
+ pos++;
}
}
@@ -403,14 +406,14 @@ public class PieRenderer extends OverlayRenderer
return path;
}
- private float getArcCenter(PieItem item) {
- return getCenter(item.getPosition(), item.getCount(), SWEEP_ARC);
+ private float getArcCenter(PieItem item, int pos, int count) {
+ return getCenter(pos, count, SWEEP_ARC);
}
- private float getSliceCenter(PieItem item) {
+ private float getSliceCenter(PieItem item, int pos, int count) {
float center = (getCenterAngle() - CENTER) * 0.5f + CENTER;
- return center + (item.getCount() - 1) * SWEEP_SLICE / 2f
- - item.getPosition() * SWEEP_SLICE;
+ return center + (count - 1) * SWEEP_SLICE / 2f
+ - pos * SWEEP_SLICE;
}
private float getCenter(int pos, int count, float sweep) {
@@ -520,20 +523,28 @@ public class PieRenderer extends OverlayRenderer
if (!hasOpenItem() || (mXFade != null)) {
// draw base menu
drawArc(canvas, getLevel(), getParent());
+ List<PieItem> items = getParent().getItems();
+ final int count = items.size();
+ int pos = 0;
for (PieItem item : getParent().getItems()) {
- drawItem(Math.max(0, mOpen.size() - 2), canvas, item, alpha);
+ drawItem(Math.max(0, mOpen.size() - 2), pos, count, canvas, item, alpha);
+ pos++;
}
mLabel.draw(canvas);
}
if (hasOpenItem()) {
int level = getLevel();
drawArc(canvas, level, getOpenItem());
- for (PieItem inner : getOpenItem().getItems()) {
+ List<PieItem> items = getOpenItem().getItems();
+ final int count = items.size();
+ int pos = 0;
+ for (PieItem inner : items) {
if (mFadeOut != null) {
- drawItem(level, canvas, inner, alpha);
+ drawItem(level, pos, count, canvas, inner, alpha);
} else {
- drawItem(level, canvas, inner, (mXFade != null) ? (1 - 0.5f * alpha) : 1);
+ drawItem(level, pos, count, canvas, inner, (mXFade != null) ? (1 - 0.5f * alpha) : 1);
}
+ pos++;
}
mLabel.draw(canvas);
}
@@ -543,19 +554,9 @@ public class PieRenderer extends OverlayRenderer
private void drawArc(Canvas canvas, int level, PieItem item) {
// arc
if (mState == STATE_PIE) {
- int min = Integer.MAX_VALUE;
- int max = Integer.MIN_VALUE;
- int count = 0;
- for (PieItem child : item.getItems()) {
- final int p = child.getPosition();
- count = child.getCount();
- if (p < min) min = p;
- if (p > max) max = p;
- }
- float start = mCenterAngle + (count - 1) * SWEEP_ARC / 2f - min * SWEEP_ARC
- + SWEEP_ARC / 2f;
- float end = mCenterAngle + (count - 1) * SWEEP_ARC / 2f - max * SWEEP_ARC
- - SWEEP_ARC / 2f;
+ final int count = item.getItems().size();
+ float start = mCenterAngle + (count * SWEEP_ARC / 2f);
+ float end = mCenterAngle - (count * SWEEP_ARC / 2f);
int cy = mArcCenterY - level * mRadiusInc;
canvas.drawArc(new RectF(mPieCenterX - mArcRadius, cy - mArcRadius,
mPieCenterX + mArcRadius, cy + mArcRadius),
@@ -563,14 +564,14 @@ public class PieRenderer extends OverlayRenderer
}
}
- private void drawItem(int level, Canvas canvas, PieItem item, float alpha) {
+ private void drawItem(int level, int pos, int count, Canvas canvas, PieItem item, float alpha) {
if (mState == STATE_PIE) {
if (item.getPath() != null) {
int y = mArcCenterY - level * mRadiusInc;
if (item.isSelected()) {
Paint p = mSelectedPaint;
int state = canvas.save();
- float angle = getArcCenter(item) - SWEEP_ARC / 2f;
+ float angle = getArcCenter(item, pos, count) - SWEEP_ARC / 2f;
angle = getDegrees(angle);
canvas.rotate(angle, mPieCenterX, y);
if (mFadeOut != null) {
@@ -679,8 +680,8 @@ public class PieRenderer extends OverlayRenderer
return polarCoords.y < mArcRadius - mRadiusInc;
}
- private boolean inside(PointF polar, PieItem item) {
- float start = getSliceCenter(item) - SWEEP_SLICE / 2f;
+ private boolean inside(PointF polar, PieItem item, int pos, int count) {
+ float start = getSliceCenter(item, pos, count) - SWEEP_SLICE / 2f;
boolean res = (mArcRadius < polar.y)
&& (start < polar.x)
&& (start + SWEEP_SLICE > polar.x)
@@ -801,10 +802,13 @@ public class PieRenderer extends OverlayRenderer
private PieItem findItem(PointF polar) {
// find the matching item:
List<PieItem> items = getOpenItem().getItems();
+ final int count = items.size();
+ int pos = 0;
for (PieItem item : items) {
- if (inside(polar, item)) {
+ if (inside(polar, item, pos, count)) {
return item;
}
+ pos++;
}
return null;
}
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index d26a58a34..9e1d0be86 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -165,18 +165,39 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
public void loadEditorPanel(FilterRepresentation representation,
- Editor currentEditor) {
+ final Editor currentEditor) {
if (representation.getEditorId() == ImageOnlyEditor.ID) {
currentEditor.getImageShow().select();
currentEditor.reflectCurrentFilter();
return;
}
- EditorPanel panel = new EditorPanel();
- panel.setEditor(currentEditor.getID());
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
- transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
- transaction.commit();
+ final int currentId = currentEditor.getID();
+ Runnable showEditor = new Runnable() {
+ @Override
+ public void run() {
+ EditorPanel panel = new EditorPanel();
+ panel.setEditor(currentId);
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG));
+ transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG);
+ transaction.commit();
+ }
+ };
+ Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG);
+ boolean doAnimation = false;
+ if (mShowingImageStatePanel
+ && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
+ doAnimation = true;
+ }
+ if (doAnimation && main != null && main instanceof MainPanel) {
+ MainPanel mainPanel = (MainPanel) main;
+ View container = mainPanel.getView().findViewById(R.id.category_panel_container);
+ View bottom = mainPanel.getView().findViewById(R.id.bottom_panel);
+ int panelHeight = container.getHeight() + bottom.getHeight();
+ mainPanel.getView().animate().translationY(panelHeight).withEndAction(showEditor).start();
+ } else {
+ showEditor.run();
+ }
}
private void loadXML() {
@@ -353,7 +374,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
if (representation.getTextId() != 0) {
representation.setName(getString(representation.getTextId()));
}
- mCategoryBordersAdapter.add(new Action(this, representation));
+ mCategoryBordersAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
}
@@ -738,7 +759,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mCategoryLooksAdapter = new CategoryAdapter(this);
int verticalItemHeight = (int) getResources().getDimension(R.dimen.action_item_height);
mCategoryLooksAdapter.setItemHeight(verticalItemHeight);
- mCategoryLooksAdapter.add(new Action(this, nullFx, Action.CROP_VIEW));
+ mCategoryLooksAdapter.add(new Action(this, nullFx, Action.FULL_VIEW));
for (FilterRepresentation representation : filtersRepresentations) {
mCategoryLooksAdapter.add(new Action(this, representation, Action.FULL_VIEW));
}
diff --git a/src/com/android/gallery3d/filtershow/category/Action.java b/src/com/android/gallery3d/filtershow/category/Action.java
index 667a897fe..4f2c12868 100644
--- a/src/com/android/gallery3d/filtershow/category/Action.java
+++ b/src/com/android/gallery3d/filtershow/category/Action.java
@@ -149,7 +149,15 @@ public class Action implements RenderingRequestCaller {
mRepresentation.getOverlayId());
}
if (mOverlayBitmap != null) {
- drawCenteredImage(mOverlayBitmap, mImage, false);
+ if (getRepresentation().getPriority() == FilterRepresentation.TYPE_BORDER) {
+ Canvas canvas = new Canvas(mImage);
+ canvas.drawBitmap(mOverlayBitmap, new Rect(0, 0, mOverlayBitmap.getWidth(), mOverlayBitmap.getHeight()),
+ new Rect(0, 0, mImage.getWidth(), mImage.getHeight()), new Paint());
+ } else {
+ Canvas canvas = new Canvas(mImage);
+ canvas.drawARGB(128, 0, 0, 0);
+ drawCenteredImage(mOverlayBitmap, mImage, false);
+ }
}
if (mAdapter != null) {
mAdapter.notifyDataSetChanged();
diff --git a/src/com/android/gallery3d/filtershow/category/CategoryView.java b/src/com/android/gallery3d/filtershow/category/CategoryView.java
index 5467841c4..c101f983f 100644
--- a/src/com/android/gallery3d/filtershow/category/CategoryView.java
+++ b/src/com/android/gallery3d/filtershow/category/CategoryView.java
@@ -62,11 +62,8 @@ public class CategoryView extends View implements View.OnClickListener {
return;
}
text = text.toUpperCase();
- mPaint.reset();
- mPaint.setColor(mTextColor);
mPaint.setTextSize(sTextSize);
mPaint.setTypeface(Typeface.DEFAULT_BOLD);
- mPaint.setAntiAlias(true);
float textWidth = mPaint.measureText(text);
mPaint.getTextBounds(text, 0, text.length(), mTextBounds);
int x = (int) (canvas.getWidth() - textWidth - sMargin);
@@ -77,13 +74,22 @@ public class CategoryView extends View implements View.OnClickListener {
public void onDraw(Canvas canvas) {
canvas.drawColor(mBackgroundColor);
if (mAction != null) {
- drawText(canvas, mAction.getName());
+ mPaint.reset();
+ mPaint.setAntiAlias(true);
if (mAction.getImage() == null) {
mAction.setImageFrame(new Rect(0, 0, canvas.getWidth(), canvas.getHeight()));
} else {
Bitmap bitmap = mAction.getImage();
canvas.drawBitmap(bitmap, 0, 0, mPaint);
}
+ mPaint.setColor(mBackgroundColor);
+ mPaint.setStyle(Paint.Style.STROKE);
+ mPaint.setStrokeWidth(3);
+ drawText(canvas, mAction.getName());
+ mPaint.setColor(mTextColor);
+ mPaint.setStyle(Paint.Style.FILL);
+ mPaint.setStrokeWidth(1);
+ drawText(canvas, mAction.getName());
}
}
diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
index c23b90b33..9ec858ca5 100644
--- a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
+++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java
@@ -181,8 +181,6 @@ public class ParametricEditor extends Editor {
mControl = (Control) c.newInstance();
p.setController(mControl);
mControl.setUp((ViewGroup) editControl, p, this);
-
-
} catch (Exception e) {
Log.e(LOGTAG, "Error in loading Control ", e);
}
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 5bb0e5733..82012b992 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -117,7 +117,7 @@ public class FilterRepresentation implements Cloneable {
}
public boolean supportsPartialRendering() {
- return mSupportsPartialRendering;
+ return false && mSupportsPartialRendering; // disable for now
}
public void setSupportsPartialRendering(boolean value) {
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index e19a7554f..b833cf858 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -307,7 +307,12 @@ public class ImageShow extends View implements OnGestureListener,
scalingMatrix.mapRect(unscaledClipRect, unscaledClipRect);
canvas.save();
- if (!unscaledClipRect.isEmpty()) {
+
+ boolean enablePartialRendering = false;
+
+ // For now, partial rendering is disabled for all filters,
+ // so no need to clip.
+ if (enablePartialRendering && !unscaledClipRect.isEmpty()) {
canvas.clipRect(unscaledClipRect);
}
@@ -466,7 +471,7 @@ public class ImageShow extends View implements OnGestureListener,
canvas.drawBitmap(mBackgroundImage, s, d, mPaint);
}
} else {
- canvas.drawColor(mBackgroundColor);
+ canvas.drawARGB(0, 0, 0, 0);
}
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 3530935e1..ed0a72a33 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -554,20 +554,24 @@ public class ImagePreset {
if (imageStateAdapter == null) {
return;
}
- imageStateAdapter.clear();
- imageStateAdapter.addOriginal();
+ Vector<State> states = new Vector<State>();
// TODO: supports Geometry representations in the state panel.
if (false && mGeoData != null && mGeoData.hasModifications()) {
State geo = new State("Geometry");
geo.setFilterRepresentation(mGeoData);
- imageStateAdapter.add(geo);
+ states.add(geo);
+ }
+ for (FilterRepresentation filter : mFilters) {
+ State state = new State(filter.getName());
+ state.setFilterRepresentation(filter);
+ states.add(state);
}
- imageStateAdapter.addAll(mFilters);
if (mBorder != null) {
State border = new State(mBorder.getName());
border.setFilterRepresentation(mBorder);
- imageStateAdapter.add(border);
+ states.add(border);
}
+ imageStateAdapter.fill(states);
}
public void setPartialRendering(boolean partialRendering, Rect bounds) {
diff --git a/src/com/android/gallery3d/filtershow/state/State.java b/src/com/android/gallery3d/filtershow/state/State.java
index a853371e7..29bbf9109 100644
--- a/src/com/android/gallery3d/filtershow/state/State.java
+++ b/src/com/android/gallery3d/filtershow/state/State.java
@@ -31,11 +31,19 @@ public class State {
this(text, StateView.DEFAULT);
}
- State(String text, int type) {
+ public State(String text, int type) {
mText = text;
mType = type;
}
+ public boolean equals(State state) {
+ if (mFilterRepresentation.getFilterClass()
+ != state.mFilterRepresentation.getFilterClass()) {
+ return false;
+ }
+ return true;
+ }
+
public boolean isDraggable() {
return mFilterRepresentation != null;
}
diff --git a/src/com/android/gallery3d/filtershow/state/StateAdapter.java b/src/com/android/gallery3d/filtershow/state/StateAdapter.java
index 58f9a7fa6..522585280 100644
--- a/src/com/android/gallery3d/filtershow/state/StateAdapter.java
+++ b/src/com/android/gallery3d/filtershow/state/StateAdapter.java
@@ -17,6 +17,7 @@
package com.android.gallery3d.filtershow.state;
import android.content.Context;
+import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@@ -30,8 +31,8 @@ import java.util.Vector;
public class StateAdapter extends ArrayAdapter<State> {
+ private static final String LOGTAG = "StateAdapter";
private int mOrientation;
- private PanelTrack mListener;
private String mOriginalText;
private String mResultText;
@@ -76,28 +77,32 @@ public class StateAdapter extends ArrayAdapter<State> {
mOrientation = orientation;
}
- @Override
- public void notifyDataSetChanged() {
- if (mListener != null) {
- mListener.fillContent(false);
- }
- }
-
public void addOriginal() {
add(new State(mOriginalText));
}
- public void addAll(Vector<FilterRepresentation> filters) {
- for (FilterRepresentation filter : filters) {
- State state = new State(filter.getName());
- state.setFilterRepresentation(filter);
- add(state);
+ public boolean same(Vector<State> states) {
+ // we have the original state in addition
+ if (states.size() + 1 != getCount()) {
+ return false;
}
- notifyDataSetChanged();
+ for (int i = 1; i < getCount(); i++) {
+ State state = getItem(i);
+ if (!state.equals(states.elementAt(i-1))) {
+ return false;
+ }
+ }
+ return true;
}
- void setListener(PanelTrack listener) {
- mListener = listener;
+ public void fill(Vector<State> states) {
+ if (same(states)) {
+ return;
+ }
+ clear();
+ addOriginal();
+ addAll(states);
+ notifyDataSetChanged();
}
@Override
diff --git a/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java b/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java
index 4fb1b11c5..fff7e7f5f 100644
--- a/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java
+++ b/src/com/android/gallery3d/filtershow/state/StatePanelTrack.java
@@ -19,6 +19,8 @@ package com.android.gallery3d.filtershow.state;
import android.animation.LayoutTransition;
import android.content.Context;
import android.content.res.TypedArray;
+import android.database.DataSetObserver;
+import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
@@ -56,6 +58,19 @@ public class StatePanelTrack extends LinearLayout implements PanelTrack {
private long mTouchTime;
private int mMaxTouchDelay = 300; // 300ms delay for touch
private static final boolean ALLOWS_DRAG = false;
+ private DataSetObserver mObserver = new DataSetObserver() {
+ @Override
+ public void onChanged() {
+ super.onChanged();
+ fillContent(false);
+ }
+
+ @Override
+ public void onInvalidated() {
+ super.onInvalidated();
+ fillContent(false);
+ }
+ };
public StatePanelTrack(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -112,7 +127,7 @@ public class StatePanelTrack extends LinearLayout implements PanelTrack {
public void setAdapter(StateAdapter adapter) {
mAdapter = adapter;
- mAdapter.setListener(this);
+ mAdapter.registerDataSetObserver(mObserver);
mAdapter.setOrientation(getOrientation());
fillContent(false);
requestLayout();
@@ -236,17 +251,22 @@ public class StatePanelTrack extends LinearLayout implements PanelTrack {
&& event.getActionMasked() == MotionEvent.ACTION_UP
&& System.currentTimeMillis() - mTouchTime < mMaxTouchDelay) {
FilterRepresentation representation = mCurrentView.getState().getFilterRepresentation();
+ mCurrentView.setSelected(true);
if (representation != MasterImage.getImage().getCurrentFilterRepresentation()) {
FilterShowActivity activity = (FilterShowActivity) getContext();
activity.showRepresentation(representation);
- }
- if (representation.getEditorId() != ImageOnlyEditor.ID) {
- mCurrentView.setSelected(true);
+ mCurrentView.setSelected(false);
}
}
if (event.getActionMasked() == MotionEvent.ACTION_UP
|| (!mStartedDrag && event.getActionMasked() == MotionEvent.ACTION_CANCEL)) {
checkEndState();
+ if (mCurrentView != null) {
+ FilterRepresentation representation = mCurrentView.getState().getFilterRepresentation();
+ if (representation.getEditorId() == ImageOnlyEditor.ID) {
+ mCurrentView.setSelected(false);
+ }
+ }
}
return true;
}
diff --git a/src/com/android/gallery3d/filtershow/state/StateView.java b/src/com/android/gallery3d/filtershow/state/StateView.java
index 45ca38248..9353a430a 100644
--- a/src/com/android/gallery3d/filtershow/state/StateView.java
+++ b/src/com/android/gallery3d/filtershow/state/StateView.java
@@ -145,6 +145,7 @@ public class StateView extends View {
public void onDraw(Canvas canvas) {
canvas.drawARGB(0, 0, 0, 0);
+ mPaint.reset();
mPath.reset();
float w = canvas.getWidth();
diff --git a/src/com/android/gallery3d/ui/ActionModeHandler.java b/src/com/android/gallery3d/ui/ActionModeHandler.java
index c8a1977ca..6b4f10312 100644
--- a/src/com/android/gallery3d/ui/ActionModeHandler.java
+++ b/src/com/android/gallery3d/ui/ActionModeHandler.java
@@ -53,7 +53,7 @@ public class ActionModeHandler implements Callback, PopupList.OnPopupItemClickLi
@SuppressWarnings("unused")
private static final String TAG = "ActionModeHandler";
- private static final int MAX_SELECTED_ITEMS_FOR_SHARE_INTENT = 100;
+ private static final int MAX_SELECTED_ITEMS_FOR_SHARE_INTENT = 300;
private static final int MAX_SELECTED_ITEMS_FOR_PANORAMA_SHARE_INTENT = 10;
private static final int SUPPORT_MULTIPLE_MASK = MediaObject.SUPPORT_DELETE
diff --git a/src/com/android/photos/data/PhotoDatabase.java b/src/com/android/photos/data/PhotoDatabase.java
index fd9cd0790..1f15c5bdc 100644
--- a/src/com/android/photos/data/PhotoDatabase.java
+++ b/src/com/android/photos/data/PhotoDatabase.java
@@ -101,6 +101,15 @@ public class PhotoDatabase extends SQLiteOpenHelper {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ recreate(db);
+ }
+
+ @Override
+ public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ recreate(db);
+ }
+
+ private void recreate(SQLiteDatabase db) {
dropTable(db, Metadata.TABLE);
dropTable(db, Photos.TABLE);
dropTable(db, Albums.TABLE);