summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/ui/RotateLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/ui/RotateLayout.java')
-rw-r--r--src/com/android/camera/ui/RotateLayout.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java
index e394aba0b..61bcf2282 100644
--- a/src/com/android/camera/ui/RotateLayout.java
+++ b/src/com/android/camera/ui/RotateLayout.java
@@ -18,6 +18,7 @@ package com.android.camera.ui;
import android.content.Context;
import android.graphics.Matrix;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
@@ -32,6 +33,11 @@ public class RotateLayout extends ViewGroup implements Rotatable {
private int mOrientation;
private Matrix mMatrix = new Matrix();
protected View mChild;
+ private CameraRootView mRootView;
+
+ public interface Child {
+ void onApplyWindowInsets(Rect insets);
+ }
public RotateLayout(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -42,6 +48,10 @@ public class RotateLayout extends ViewGroup implements Rotatable {
setBackgroundResource(android.R.color.transparent);
}
+ public void setRootView(CameraRootView rootView) {
+ mRootView = rootView;
+ }
+
@Override
protected void onFinishInflate() {
setupChild(getChildAt(0));
@@ -52,6 +62,7 @@ public class RotateLayout extends ViewGroup implements Rotatable {
mChild = child;
child.setPivotX(0);
child.setPivotY(0);
+ applyInsetsToChild();
}
}
@@ -145,10 +156,19 @@ public class RotateLayout extends ViewGroup implements Rotatable {
}
}
mOrientation = orientation;
+ applyInsetsToChild();
+
if (mChild != null)
requestLayout();
}
+ private void applyInsetsToChild() {
+ if (mRootView != null && mChild instanceof Child) {
+ Rect insets = mRootView.getInsetsForOrientation(mOrientation);
+ ((Child) mChild).onApplyWindowInsets(insets);
+ }
+ }
+
public int getOrientation() {
return mOrientation;
}