diff options
author | Doris Liu <tianliu@google.com> | 2013-04-02 17:48:56 -0700 |
---|---|---|
committer | Doris Liu <tianliu@google.com> | 2013-04-03 13:32:48 -0700 |
commit | bbee3bfe85ab29acda2e13c422459d3cb96b1917 (patch) | |
tree | eabb0c5bc398e25ccb1d98afd63bafd131595394 /src/com/android/camera/ui/RotatableLayout.java | |
parent | 5a58fb2146ec75061cc2a9a038628a6b7f340b34 (diff) | |
download | android_packages_apps_Snap-bbee3bfe85ab29acda2e13c422459d3cb96b1917.tar.gz android_packages_apps_Snap-bbee3bfe85ab29acda2e13c422459d3cb96b1917.tar.bz2 android_packages_apps_Snap-bbee3bfe85ab29acda2e13c422459d3cb96b1917.zip |
Improve black bar to keep camera controls in place
Bug: 8340996
Change-Id: Ibca4a9f1ed84bd59e29cc988df346f1567de2a5b
Diffstat (limited to 'src/com/android/camera/ui/RotatableLayout.java')
-rw-r--r-- | src/com/android/camera/ui/RotatableLayout.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/com/android/camera/ui/RotatableLayout.java b/src/com/android/camera/ui/RotatableLayout.java index 4edec5dd7..6836b39b2 100644 --- a/src/com/android/camera/ui/RotatableLayout.java +++ b/src/com/android/camera/ui/RotatableLayout.java @@ -39,6 +39,10 @@ public class RotatableLayout extends FrameLayout { private static final String TAG = "RotatableLayout"; private int mPrevRotation; + private RotationListener mListener = null; + public interface RotationListener { + public void onRotation(int rotation); + } public RotatableLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @@ -53,12 +57,15 @@ public class RotatableLayout extends FrameLayout { @Override public void onFinishInflate() { // get initial orientation + super.onFinishInflate(); mPrevRotation = Util.getDisplayRotation((Activity) getContext()); } @Override public void onConfigurationChanged(Configuration config) { super.onConfigurationChanged(config); + int rotation = Util.getDisplayRotation((Activity) getContext()); + boolean clockwise = isClockWiseRotation(mPrevRotation, rotation); // Change the size of the layout ViewGroup.LayoutParams lp = getLayoutParams(); int width = lp.width; @@ -66,15 +73,33 @@ public class RotatableLayout extends FrameLayout { lp.height = width; lp.width = height; setLayoutParams(lp); + // rotate all the children - int rotation = Util.getDisplayRotation((Activity) getContext()); - boolean clockwise = isClockWiseRotation(mPrevRotation, rotation); mPrevRotation = rotation; + rotateChildren(clockwise); + } + + protected void rotateChildren(boolean clockwise) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View child = getChildAt(i); rotate(child, clockwise); } + if (mListener != null) mListener.onRotation(clockwise ? 90 : 270); + } + + protected void flipChildren() { + mPrevRotation = Util.getDisplayRotation((Activity) getContext()); + int childCount = getChildCount(); + for (int i = 0; i < childCount; i++) { + View child = getChildAt(i); + flip(child); + } + if (mListener != null) mListener.onRotation(180); + } + + public void setRotationListener(RotationListener listener) { + mListener = listener; } public static boolean isClockWiseRotation(int prevRotation, int currentRotation) { @@ -181,4 +206,10 @@ public class RotatableLayout extends FrameLayout { lp.height = width; view.setLayoutParams(lp); } + + // Rotate a given view 180 degrees + public static void flip(View view) { + rotateClockwise(view); + rotateClockwise(view); + } }
\ No newline at end of file |