summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-01-14 11:36:38 +0100
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-01-15 01:47:05 -0800
commit2233950e703e2532b01f9f2893d9f7d8f5845cb1 (patch)
tree7557bf4eee6074750db8913fc4aa008de36c2280
parent607a2f0b99886cb07b2d2b042d38bfb26da0f166 (diff)
downloadandroid_packages_apps_Snap-2233950e703e2532b01f9f2893d9f7d8f5845cb1.tar.gz
android_packages_apps_Snap-2233950e703e2532b01f9f2893d9f7d8f5845cb1.tar.bz2
android_packages_apps_Snap-2233950e703e2532b01f9f2893d9f7d8f5845cb1.zip
CameraActivity: Don't hide navigation bar
* Make it transparent instead. Change-Id: I08b06ac72d88aaf62ae7f52a3dde9ba865bc3542
-rw-r--r--res/layout/camera_filmstrip.xml3
-rw-r--r--res/layout/filmstrip_bottom_controls.xml1
-rw-r--r--res/values/styles.xml1
-rw-r--r--src/com/android/camera/CameraActivity.java10
-rw-r--r--src/com/android/camera/ui/CameraControls.java24
-rw-r--r--src/com/android/camera/ui/CameraRootView.java108
-rw-r--r--src/com/android/camera/ui/RenderOverlay.java26
7 files changed, 64 insertions, 109 deletions
diff --git a/res/layout/camera_filmstrip.xml b/res/layout/camera_filmstrip.xml
index 2075a94f4..df6b7a267 100644
--- a/res/layout/camera_filmstrip.xml
+++ b/res/layout/camera_filmstrip.xml
@@ -23,7 +23,8 @@
<com.android.camera.ui.FilmStripView
android:id="@+id/filmstrip_view"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ android:clipToPadding="false" />
<!--com.android.camera.ui.FitSystemUiFrameLayout-->
<FrameLayout
diff --git a/res/layout/filmstrip_bottom_controls.xml b/res/layout/filmstrip_bottom_controls.xml
index 1ad07aee9..019ae32fd 100644
--- a/res/layout/filmstrip_bottom_controls.xml
+++ b/res/layout/filmstrip_bottom_controls.xml
@@ -22,6 +22,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:padding="10dp"
+ android:fitsSystemWindows="true"
android:visibility="visible" >
<ImageButton
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8d212b611..d014382b4 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -25,6 +25,7 @@
<item name="android:windowTitleSize">0dp</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@android:color/black</item>
+ <item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="android:colorBackgroundCacheHint">@android:color/black</item>
<item name="android:actionBarStyle">@style/Material.ActionBar</item>
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 09cb46707..8e0c144c1 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -100,6 +100,7 @@ import com.android.camera.data.MediaDetails;
import com.android.camera.data.SimpleViewData;
import com.android.camera.exif.ExifInterface;
import com.android.camera.tinyplanet.TinyPlanetFragment;
+import com.android.camera.ui.CameraRootView;
import com.android.camera.ui.ModuleSwitcher;
import com.android.camera.ui.DetailsDialog;
import com.android.camera.ui.FilmStripView;
@@ -189,7 +190,7 @@ public class CameraActivity extends Activity
private int mCurrentModuleIndex;
private CameraModule mCurrentModule;
private FrameLayout mAboveFilmstripControlLayout;
- private View mCameraModuleRootView;
+ private CameraRootView mCameraModuleRootView;
private FilmStripView mFilmStripView;
private ProgressBar mBottomProgress;
private View mPanoStitchingPanel;
@@ -632,7 +633,6 @@ public class CameraActivity extends Activity
| (visible ? View.SYSTEM_UI_FLAG_VISIBLE :
View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
if (newSystemUIVisibility != currentSystemUIVisibility) {
decorView.setSystemUiVisibility(newSystemUIVisibility);
@@ -1414,7 +1414,7 @@ public class CameraActivity extends Activity
LayoutInflater inflater = getLayoutInflater();
View rootLayout = inflater.inflate(R.layout.camera, null, false);
- mCameraModuleRootView = rootLayout.findViewById(R.id.camera_app_root);
+ mCameraModuleRootView = (CameraRootView) rootLayout.findViewById(R.id.camera_app_root);
int moduleIndex = -1;
if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction())
@@ -1932,6 +1932,10 @@ public class CameraActivity extends Activity
private void openModule(CameraModule module) {
module.init(this, mCameraModuleRootView);
+ // Re-apply the last fitSystemWindows() run. Our views rely on this, but
+ // the framework's ActionBarOverlayLayout effectively prevents this if the
+ // actual insets haven't changed.
+ mCameraModuleRootView.redoFitSystemWindows();
module.onResumeBeforeSuper();
module.onResumeAfterSuper();
}
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index b6e31ada2..15836353e 100644
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -23,9 +23,8 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.Paint;
import android.graphics.Path;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
@@ -82,6 +81,7 @@ public class CameraControls extends RotatableLayout {
private LinearLayout mRemainingPhotos;
private TextView mRemainingPhotosText;
private int mOrientation;
+ private final Rect mInsets = new Rect();
private int mPreviewRatio;
private static int mTopMargin = 0;
@@ -240,6 +240,12 @@ public class CameraControls extends RotatableLayout {
}
@Override
+ protected boolean fitSystemWindows(Rect insets) {
+ mInsets.set(insets);
+ return false;
+ }
+
+ @Override
public void onLayout(boolean changed, int l, int t, int r, int b) {
int orientation = getResources().getConfiguration().orientation;
int size = getResources().getDimensionPixelSize(R.dimen.camera_controls_size);
@@ -247,18 +253,24 @@ public class CameraControls extends RotatableLayout {
adjustBackground();
// As l,t,r,b are positions relative to parents, we need to convert them
// to child's coordinates
- r = r - l;
- b = b - t;
+ r = r - l - mInsets.right;
+ b = b - t - mInsets.bottom;
l = 0;
t = 0;
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
- v.layout(l, t, r, b);
+ if (v == mBackgroundView) {
+ v.layout(l, t, r + mInsets.right, b + mInsets.bottom);
+ } else {
+ v.layout(l, t, r, b);
+ }
}
+
Rect shutter = new Rect();
center(mShutter, l, t, r, b, orientation, rotation, shutter, SHUTTER_INDEX);
mSize = (int) (Math.max(shutter.right - shutter.left, shutter.bottom - shutter.top) * 1.2f);
- center(mBackgroundView, l, t, r, b, orientation, rotation, new Rect(), -1);
+ center(mBackgroundView, l, t, r + mInsets.right, b + mInsets.bottom,
+ orientation, rotation, new Rect(), -1);
mBackgroundView.setVisibility(View.GONE);
setLocation(r - l, b - t);
diff --git a/src/com/android/camera/ui/CameraRootView.java b/src/com/android/camera/ui/CameraRootView.java
index 42eebaa98..cd30e8e4f 100644
--- a/src/com/android/camera/ui/CameraRootView.java
+++ b/src/com/android/camera/ui/CameraRootView.java
@@ -17,9 +17,7 @@
package com.android.camera.ui;
import android.annotation.SuppressLint;
-import android.app.Activity;
import android.content.Context;
-import android.content.res.Configuration;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
@@ -28,7 +26,6 @@ import android.view.View;
import android.widget.FrameLayout;
import com.android.camera.util.ApiHelper;
-import com.android.camera.util.CameraUtil;
@SuppressLint("NewApi")
public class CameraRootView extends FrameLayout {
@@ -37,10 +34,9 @@ public class CameraRootView extends FrameLayout {
private int mBottomMargin = 0;
private int mLeftMargin = 0;
private int mRightMargin = 0;
- private final Rect mCurrentInsets = new Rect(0, 0, 0, 0);
- private int mOffset = 0;
private Object mDisplayListener;
private MyDisplayListener mListener;
+ private Rect mLastInsets = new Rect();
public interface MyDisplayListener {
public void onDisplayChanged();
@@ -51,26 +47,18 @@ public class CameraRootView extends FrameLayout {
initDisplayListener();
}
- @Override
- protected boolean fitSystemWindows(Rect insets) {
- // insets include status bar, navigation bar, etc
- // In this case, we are only concerned with the size of nav bar
- if (mCurrentInsets.equals(insets)) {
- // Local copy of the insets is up to date. No need to do anything.
- return false;
+ public void redoFitSystemWindows() {
+ if (mLastInsets.left != 0 || mLastInsets.right != 0
+ || mLastInsets.top != 0 || mLastInsets.bottom != 0) {
+ Rect insets = new Rect(mLastInsets);
+ fitSystemWindows(insets);
}
+ }
- if (mOffset == 0) {
- if (insets.bottom > 0) {
- mOffset = insets.bottom;
- } else if (insets.right > 0) {
- mOffset = insets.right;
- }
- }
- mCurrentInsets.set(insets);
- // Make sure onMeasure will be called to adapt to the new insets.
- requestLayout();
- return false;
+ @Override
+ protected boolean fitSystemWindows(Rect insets) {
+ mLastInsets.set(insets);
+ return super.fitSystemWindows(insets);
}
public void initDisplayListener() {
@@ -118,78 +106,4 @@ public class CameraRootView extends FrameLayout {
.unregisterDisplayListener((DisplayListener) mDisplayListener);
}
}
-/*
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int rotation = CameraUtil.getDisplayRotation((Activity) getContext());
- // all the layout code assumes camera device orientation to be portrait
- // adjust rotation for landscape
- int orientation = getResources().getConfiguration().orientation;
- int camOrientation = (rotation % 180 == 0) ? Configuration.ORIENTATION_PORTRAIT
- : Configuration.ORIENTATION_LANDSCAPE;
- if (camOrientation != orientation) {
- rotation = (rotation + 90) % 360;
- }
- // calculate margins
- mLeftMargin = 0;
- mRightMargin = 0;
- mBottomMargin = 0;
- mTopMargin = 0;
- switch (rotation) {
- case 0:
- mBottomMargin += mOffset;
- break;
- case 90:
- mRightMargin += mOffset;
- break;
- case 180:
- mTopMargin += mOffset;
- break;
- case 270:
- mLeftMargin += mOffset;
- break;
- }
- if (mCurrentInsets != null) {
- if (mCurrentInsets.right > 0) {
- // navigation bar on the right
- mRightMargin = mRightMargin > 0 ? mRightMargin : mCurrentInsets.right;
- } else {
- // navigation bar on the bottom
- mBottomMargin = mBottomMargin > 0 ? mBottomMargin : mCurrentInsets.bottom;
- }
- }
- // make sure all the children are resized
- super.onMeasure(widthMeasureSpec - mLeftMargin - mRightMargin,
- heightMeasureSpec - mTopMargin - mBottomMargin);
- setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
- }
-
- @Override
- public void onLayout(boolean changed, int l, int t, int r, int b) {
- r -= l;
- b -= t;
- l = 0;
- t = 0;
- int orientation = getResources().getConfiguration().orientation;
- // Lay out children
- for (int i = 0; i < getChildCount(); i++) {
- View v = getChildAt(i);
- if (v instanceof CameraControls) {
- // Lay out camera controls to center on the short side of the screen
- // so that they stay in place during rotation
- int width = v.getMeasuredWidth();
- int height = v.getMeasuredHeight();
- if (orientation == Configuration.ORIENTATION_PORTRAIT) {
- int left = (l + r - width) / 2;
- v.layout(left, t + mTopMargin, left + width, b - mBottomMargin);
- } else {
- int top = (t + b - height) / 2;
- v.layout(l + mLeftMargin, top, r - mRightMargin, top + height);
- }
- } else {
- v.layout(l + mLeftMargin, t + mTopMargin, r - mRightMargin, b - mBottomMargin);
- }
- }
- }
-*/
}
diff --git a/src/com/android/camera/ui/RenderOverlay.java b/src/com/android/camera/ui/RenderOverlay.java
index d82ce18b6..75e616441 100644
--- a/src/com/android/camera/ui/RenderOverlay.java
+++ b/src/com/android/camera/ui/RenderOverlay.java
@@ -18,6 +18,7 @@ package com.android.camera.ui;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
@@ -48,6 +49,7 @@ public class RenderOverlay extends FrameLayout {
// reverse list of touch clients
private List<Renderer> mTouchClients;
private int[] mPosition = new int[2];
+ private final Rect mInsets = new Rect();
public RenderOverlay(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -69,13 +71,15 @@ public class RenderOverlay extends FrameLayout {
if (renderer.handlesTouch()) {
mTouchClients.add(0, renderer);
}
- renderer.layout(getLeft(), getTop(), getRight(), getBottom());
+ renderer.layout(mRenderView.getLeft(), mRenderView.getTop(),
+ mRenderView.getRight(), mRenderView.getBottom());
}
public void addRenderer(int pos, Renderer renderer) {
mClients.add(pos, renderer);
renderer.setOverlay(this);
- renderer.layout(getLeft(), getTop(), getRight(), getBottom());
+ renderer.layout(mRenderView.getLeft(), mRenderView.getTop(),
+ mRenderView.getRight(), mRenderView.getBottom());
}
public void remove(Renderer renderer) {
@@ -88,6 +92,24 @@ public class RenderOverlay extends FrameLayout {
}
@Override
+ protected boolean fitSystemWindows(Rect insets) {
+ if (!mInsets.equals(insets)) {
+ mInsets.set(insets);
+ // Make sure onMeasure will be called to adapt to the new insets.
+ requestLayout();
+ }
+ return false;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // make sure all the children are resized - insets include status bar,
+ // navigation bar, etc, but in this case, we are only concerned with the size of nav bar
+ super.onMeasure(widthMeasureSpec - mInsets.right, heightMeasureSpec - mInsets.bottom);
+ setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ @Override
public boolean dispatchTouchEvent(MotionEvent m) {
if (mGestures != null) {
if (!mGestures.isEnabled()) return false;