diff options
author | Alan Newberger <alann@google.com> | 2015-01-14 14:10:05 -0800 |
---|---|---|
committer | Alan Newberger <alann@google.com> | 2015-01-16 09:44:37 -0800 |
commit | 31f89504302fcecf25cad7b5f71de1978bdf877a (patch) | |
tree | 6b866a001fde55a23fefc2f1922866b0349c4d58 | |
parent | 4660e6c1011c47ad7f604ad1b7f5f2227171a694 (diff) | |
download | android_packages_apps_Camera2-31f89504302fcecf25cad7b5f71de1978bdf877a.tar.gz android_packages_apps_Camera2-31f89504302fcecf25cad7b5f71de1978bdf877a.tar.bz2 android_packages_apps_Camera2-31f89504302fcecf25cad7b5f71de1978bdf877a.zip |
Add Camera cover equivalent to windowBackground to smooth lockscreen startup
This CL adds a windowBackground drawable equivalent to the covers shown by lockscreen
and app, to remove the black screen in between. With this CL I mostly see no artifacts
when opening camera from lockscreen. Some issues:
* to improve memory usage in system UI holding the lockscreen preview, a vector
camera blanket was added in ag/587418 to ic_camera_blanket. That works transparently
everywhere so far but not in resource drawables that can only handle bitmaps in
layer-list items. Split the vector and bitmaps here, which means only the lockscreen
uses the vector -- this also surfaced a color mismatch between the vector and our PNG
bitmaps, corrected in the new ic_camera_blanket_vector resource. This is a bit fragile
as we rely on pixel match of the two resources, would like a cleaner solution but the
layer-list limitation is tough -- without this change the app crashes at runtime within
BitmapDrawable when the windowBackground is loaded.
* likewise both the lockscreen and app covers explicitly size the bitmap, there are no
provisions to do so within layer-list. Will follow up with a refactor of in-app cover
(ModeTransitionView) to remove explicit sizing and then all will rely on bitmap size
(per above will still need vector file size coordinated with bitmap).
* current implementation relies upon a black window background, we restore that in onCreate.
* Both secure camera and v21 main camera currently use the windowBackground, will submit
just for secure then introduce for main camera when we always start into Camera mode.
* For L explicitly set android:windowDrawsSystemBarBackgrounds to false to ensure the
system preview into the DecorView doesn't take the navigation bar into account when
vertically centering the cover bitmap, to make the preview identical to the other covers.
Bug: 18369862
Change-Id: Ia481e2d1d94bdc5a5d39b4d35b32c29a75bf99ec
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | res/drawable-anydpi-v21/ic_camera_blanket_vector.xml (renamed from res/drawable-anydpi-v21/ic_camera_blanket.xml) | 4 | ||||
-rw-r--r-- | res/drawable/cover.xml | 9 | ||||
-rw-r--r-- | res/layout-v21/keyguard_widget.xml | 29 | ||||
-rw-r--r-- | res/values-v21/styles.xml | 13 | ||||
-rw-r--r-- | res/values/styles.xml | 10 | ||||
-rw-r--r-- | src/com/android/camera/CameraActivity.java | 9 |
7 files changed, 66 insertions, 10 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8d0c759bb..076863de2 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -117,7 +117,7 @@ android:excludeFromRecents="true" android:label="@string/app_name" android:taskAffinity="com.android.camera.SecureCameraActivity" - android:theme="@style/Theme.Camera" + android:theme="@style/Theme.SecureCamera" android:windowSoftInputMode="stateAlwaysHidden|adjustPan" > <intent-filter> <action android:name="android.media.action.STILL_IMAGE_CAMERA_SECURE" /> diff --git a/res/drawable-anydpi-v21/ic_camera_blanket.xml b/res/drawable-anydpi-v21/ic_camera_blanket_vector.xml index 45fc29eef..dd1b049bd 100644 --- a/res/drawable-anydpi-v21/ic_camera_blanket.xml +++ b/res/drawable-anydpi-v21/ic_camera_blanket_vector.xml @@ -19,9 +19,9 @@ Copyright (C) 2014 The Android Open Source Project android:viewportWidth="48.0" android:viewportHeight="48.0"> <path - android:fillColor="#FF5a5b5e" + android:fillColor="#FF6d6e71" android:pathData="M24.0,24.0m-6.4,0.0a6.4,6.4 0.0,1.0 1.0,12.8 0.0a6.4,6.4 0.0,1.0 1.0,-12.8 0.0"/> <path - android:fillColor="#FF5a5b5e" + android:fillColor="#FF6d6e71" android:pathData="M18.0,4.0l-3.66,4.0l-6.34,0.0c-2.21,0.0 -4.0,1.79 -4.0,4.0l0.0,24.0c0.0,2.21 1.79,4.0 4.0,4.0l32.0,0.0c2.21,0.0 4.0,-1.79 4.0,-4.0l0.0,-24.0c0.0,-2.21 -1.79,-4.0 -4.0,-4.0l-6.34,0.0l-3.66,-4.0l-12.0,0.0zm6.0,30.0c-5.52,0.0 -10.0,-4.48 -10.0,-10.0s4.48,-10.0 10.0,-10.0 10.0,4.48 10.0,10.0 -4.48,10.0 -10.0,10.0z"/> </vector> diff --git a/res/drawable/cover.xml b/res/drawable/cover.xml new file mode 100644 index 000000000..f340b2866 --- /dev/null +++ b/res/drawable/cover.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > + <item> + <color android:color="@color/mode_cover_default_color"/> + </item> + <item> + <bitmap android:src="@drawable/ic_camera_blanket" android:gravity="center" /> + </item> +</layer-list> diff --git a/res/layout-v21/keyguard_widget.xml b/res/layout-v21/keyguard_widget.xml new file mode 100644 index 000000000..74f482d35 --- /dev/null +++ b/res/layout-v21/keyguard_widget.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2015 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<FrameLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@color/mode_cover_default_color" > + + <ImageView + android:layout_gravity="center" + android:layout_width="@dimen/mode_transition_view_icon_size" + android:layout_height="@dimen/mode_transition_view_icon_size" + android:scaleType="fitCenter" + android:src="@drawable/ic_camera_blanket_vector" /> + +</FrameLayout> diff --git a/res/values-v21/styles.xml b/res/values-v21/styles.xml index dd385aebc..fe1e6a464 100644 --- a/res/values-v21/styles.xml +++ b/res/values-v21/styles.xml @@ -14,7 +14,7 @@ limitations under the License. --> -<resources> +<resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Camera resources below --> <style name="Theme.Camera" parent="android:style/Theme.Material.Light.DarkActionBar"> @@ -22,9 +22,14 @@ <item name="android:windowActionBar">false</item> <item name="android:windowTitleSize">0dp</item> <item name="android:windowActionBarOverlay">true</item> - <item name="android:windowBackground">@android:color/black</item> - <item name="android:colorBackground">@android:color/black</item> - <item name="android:colorBackgroundCacheHint">@android:color/black</item> + <!-- for background layout, don't draw background under system bar, + reactivate within CameraActivity.onCreate(). --> + <item name="android:windowDrawsSystemBarBackgrounds">false</item> + <!-- TODO: add background as @drawable/cover after Camera mode cold + start default per b/17702056 --> + <item name="android:windowBackground">@color/mode_cover_default_color</item> + <item name="android:colorBackground">@color/mode_cover_default_color</item> + <item name="android:colorBackgroundCacheHint">@color/mode_cover_default_color</item> <item name="android:actionBarStyle">@style/Camera.ActionBar</item> </style> diff --git a/res/values/styles.xml b/res/values/styles.xml index 7c0f7ca80..bc849ec7c 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -24,12 +24,16 @@ <item name="android:windowActionBar">false</item> <item name="android:windowTitleSize">0dp</item> <item name="android:windowActionBarOverlay">true</item> - <item name="android:windowBackground">@android:color/black</item> - <item name="android:colorBackground">@android:color/black</item> - <item name="android:colorBackgroundCacheHint">@android:color/black</item> + <item name="android:windowBackground">@color/mode_cover_default_color</item> + <item name="android:colorBackground">@color/mode_cover_default_color</item> + <item name="android:colorBackgroundCacheHint">@color/mode_cover_default_color</item> <item name="android:actionBarStyle">@style/Camera.ActionBar</item> </style> + <style name="Theme.SecureCamera" parent="@style/Theme.Camera"> + <item name="android:windowBackground">@drawable/cover</item> + </style> + <style name="Camera.ActionBar" parent="android:Widget.Holo.Light.ActionBar"> <item name="android:displayOptions">useLogo|showHome|homeAsUp</item> <item name="android:background">@drawable/actionbar_translucent</item> diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index c12503d14..70fd52d8d 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -1433,6 +1433,15 @@ public class CameraActivity extends QuickActivity Keys.setDefaults(mSettingsManager, mAppContext); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); + // We suppress this flag via theme when drawing the system preview + // background, but once we create activity here, reactivate to the + // default value. The default is important for L, we don't want to + // change app behavior, just starting background drawable layout. + if (ApiHelper.isLOrHigher()) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + } + // We set a background drawable for startup background, reset to black + getWindow().setBackgroundDrawableResource(android.R.color.black); setContentView(R.layout.activity_main); mActionBar = getActionBar(); |