Add background image for work challenge

If the challenge shown is for a work profile, add the default image and
color to the background of the fragment.

Change-Id: I148c6cd3a835a84c7bac78b020839dfdae4a6c36
This commit is contained in:
Benjamin Franz
2016-01-13 12:16:25 +00:00
parent 45bc64afcb
commit 194300dff3
18 changed files with 448 additions and 326 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

View File

@@ -13,81 +13,89 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<LinearLayout <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="match_parent" >
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView <include layout="@layout/confirm_lock_background_base" />
style="@android:style/TextAppearance.Material.Title"
android:id="@+id/headerText"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/colorAccent"/>
<TextView <LinearLayout
style="@android:style/TextAppearance.Material.Body1" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/detailsText" android:id="@+id/topLayout"
android:layout_marginStart="24dp" android:orientation="vertical"
android:layout_marginEnd="24dp"
android:layout_marginTop="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent">
android:layout_weight="1"/>
<FrameLayout <TextView
android:layout_height="wrap_content" style="@android:style/TextAppearance.Material.Title"
android:layout_width="match_parent" android:id="@+id/headerText"
android:orientation="horizontal"> android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
<Button android:layout_marginTop="12dp"
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/cancelButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|bottom" android:textColor="?android:attr/colorAccent"/>
android:text="@string/cancel"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="14dp"/>
<EditText android:id="@+id/password_entry" <TextView
android:layout_width="208dp" style="@android:style/TextAppearance.Material.Body1"
android:layout_height="wrap_content" android:id="@+id/detailsText"
android:layout_gravity="center_horizontal|bottom" android:layout_marginStart="24dp"
android:layout_marginBottom="26dp" android:layout_marginEnd="24dp"
android:inputType="textPassword" android:layout_marginTop="8dp"
android:imeOptions="actionNext|flagNoFullscreen"
android:gravity="center"
android:textSize="16sp"
style="@style/TextAppearance.PasswordEntry"/>
<TextView style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom" />
android:layout_marginBottom="10dp"/>
<ImageView <View
android:id="@+id/fingerprintIcon" android:layout_width="match_parent"
android:layout_gravity="end|bottom" android:layout_height="0dp"
android:layout_width="wrap_content" android:layout_weight="1"/>
<FrameLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="28dp" android:layout_width="match_parent"
android:layout_marginEnd="20dp" android:orientation="horizontal">
android:visibility="gone"/>
</FrameLayout>
</LinearLayout> <Button
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:text="@string/cancel"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="14dp"/>
<EditText android:id="@+id/password_entry"
android:layout_width="208dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="26dp"
android:inputType="textPassword"
android:imeOptions="actionNext|flagNoFullscreen"
android:gravity="center"
android:textSize="16sp"
style="@style/TextAppearance.PasswordEntry"/>
<TextView style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="10dp"/>
<ImageView
android:id="@+id/fingerprintIcon"
android:layout_gravity="end|bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:layout_marginEnd="20dp"
android:visibility="gone"/>
</FrameLayout>
</LinearLayout>
</FrameLayout>

View File

@@ -13,103 +13,110 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout"
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" >
android:clipChildren="false"
android:clipToPadding="false">
<LinearLayout <include layout="@layout/confirm_lock_background_base" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView <com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
style="@android:style/TextAppearance.Material.Headline" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/headerText" android:id="@+id/topLayout"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/colorAccent"/>
<TextView
style="@android:style/TextAppearance.Material.Body1"
android:id="@+id/detailsText"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false"> android:clipToPadding="false">
<View <LinearLayout
android:id="@+id/leftSpacer" android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
style="@android:style/TextAppearance.Material.Headline"
android:id="@+id/headerText"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/colorAccent"/>
<TextView
style="@android:style/TextAppearance.Material.Body1"
android:id="@+id/detailsText"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.4"/> android:layout_weight="1"
android:orientation="horizontal"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clipChildren="false" android:clipChildren="false"
android:clipToPadding="false"> android:clipToPadding="false">
<com.android.internal.widget.LockPatternView <View
android:id="@+id/lockPattern" android:id="@+id/leftSpacer"
android:layout_width="288dp" android:layout_width="0dp"
android:layout_height="288dp" android:layout_height="match_parent"
android:layout_marginStart="-42dp" android:layout_weight="0.4"/>
android:layout_marginEnd="-42dp"
android:layout_gravity="center_vertical"/>
<TextView <FrameLayout
style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false">
<com.android.internal.widget.LockPatternView
android:id="@+id/lockPattern"
android:layout_width="288dp"
android:layout_height="288dp"
android:layout_marginStart="-42dp"
android:layout_marginEnd="-42dp"
android:layout_gravity="center_vertical"/>
<TextView
style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="24dp"/>
</FrameLayout>
<View
android:id="@+id/rightSpacer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:id="@+id/fingerprintIcon"
android:layout_gravity="center_vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal" android:visibility="gone"/>
android:layout_marginBottom="24dp"/> </LinearLayout>
</FrameLayout>
<View
android:id="@+id/rightSpacer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<ImageView
android:id="@+id/fingerprintIcon"
android:layout_gravity="center_vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:visibility="gone"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
</FrameLayout>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />

View File

@@ -13,79 +13,87 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="match_parent" >
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView <include layout="@layout/confirm_lock_background_base" />
style="@android:style/TextAppearance.Material.Headline"
android:id="@+id/headerText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginTop="?attr/confirmDeviceCredentialsTopMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/colorAccent"/>
<TextView <com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
style="@android:style/TextAppearance.Material.Body1" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/detailsText" android:id="@+id/topLayout"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin" android:orientation="vertical"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin" android:layout_width="match_parent"
android:layout_marginTop="12dp" android:layout_height="match_parent">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button <TextView
style="@android:style/Widget.Material.Button.Borderless" style="@android:style/TextAppearance.Material.Headline"
android:id="@+id/cancelButton" android:id="@+id/headerText"
android:layout_width="wrap_content" android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_height="wrap_content" android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:text="@string/cancel" android:layout_marginTop="?attr/confirmDeviceCredentialsTopMargin"
android:layout_marginStart="16dp" android:layout_width="wrap_content"
android:layout_marginEnd="16dp" android:layout_height="wrap_content"
android:layout_marginTop="16dp"/> android:textColor="?android:attr/colorAccent"/>
<View android:layout_width="match_parent" <TextView
android:layout_height="0dp" style="@android:style/TextAppearance.Material.Body1"
android:layout_weight="1"/> android:id="@+id/detailsText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<EditText <Button
android:id="@+id/password_entry" style="@android:style/Widget.Material.Button.Borderless"
android:layout_width="208dp" android:id="@+id/cancelButton"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_gravity="center_horizontal" android:layout_height="wrap_content"
android:layout_marginTop="-40dp" android:text="@string/cancel"
android:inputType="textPassword" android:layout_marginStart="16dp"
android:imeOptions="actionNext|flagNoFullscreen" android:layout_marginEnd="16dp"
android:gravity="center" android:layout_marginTop="16dp"/>
android:textSize="16sp"
style="@style/TextAppearance.PasswordEntry"/>
<TextView <View android:layout_width="match_parent"
style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText" android:layout_height="0dp"
android:accessibilityLiveRegion="polite" android:layout_weight="1"/>
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:gravity="center_vertical"/>
<ImageView <EditText
android:id="@+id/fingerprintIcon" android:id="@+id/password_entry"
android:layout_gravity="center_horizontal" android:layout_width="208dp"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true" android:layout_marginTop="-40dp"
android:layout_marginBottom="24dp" android:inputType="textPassword"
android:contentDescription="@string/confirm_fingerprint_icon_content_description" android:imeOptions="actionNext|flagNoFullscreen"
android:visibility="gone"/> android:gravity="center"
android:textSize="16sp"
style="@style/TextAppearance.PasswordEntry"/>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient> <TextView
style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:gravity="center_vertical"/>
<ImageView
android:id="@+id/fingerprintIcon"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="24dp"
android:contentDescription="@string/confirm_fingerprint_icon_content_description"
android:visibility="gone"/>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
</FrameLayout>

View File

@@ -13,83 +13,91 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/topLayout" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="match_parent" >
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView <include layout="@layout/confirm_lock_background_base" />
style="@android:style/TextAppearance.Material.Headline"
android:id="@+id/headerText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginTop="?attr/confirmDeviceCredentialsTopMargin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/colorAccent"/>
<TextView <com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
style="@android:style/TextAppearance.Material.Body1" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/detailsText" android:id="@+id/topLayout"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin" android:orientation="vertical"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"/>
<View android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"/>
<com.android.internal.widget.LockPatternView
android:id="@+id/lockPattern"
android:layout_width="312dp"
android:layout_height="312dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-46dp"
android:layout_marginBottom="-46dp"/>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="match_parent">
android:layout_weight="1"
android:orientation="vertical">
<TextView <TextView
style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText" style="@android:style/TextAppearance.Material.Headline"
android:accessibilityLiveRegion="polite" android:id="@+id/headerText"
android:id="@+id/errorText" android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_width="wrap_content" android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_height="0dp" android:layout_marginTop="?attr/confirmDeviceCredentialsTopMargin"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:gravity="center_vertical"/>
<ImageView
android:id="@+id/fingerprintIcon"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:textColor="?android:attr/colorAccent"/>
android:layout_marginBottom="24dp"
android:contentDescription="@string/confirm_fingerprint_icon_content_description"
android:visibility="gone"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient> <TextView
style="@android:style/TextAppearance.Material.Body1"
android:id="@+id/detailsText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginTop="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
style="@android:style/Widget.Material.Button.Borderless"
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"/>
<View android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"/>
<com.android.internal.widget.LockPatternView
android:id="@+id/lockPattern"
android:layout_width="312dp"
android:layout_height="312dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-46dp"
android:layout_marginBottom="-46dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:gravity="center_vertical"/>
<ImageView
android:id="@+id/fingerprintIcon"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="24dp"
android:contentDescription="@string/confirm_fingerprint_icon_content_description"
android:visibility="gone"/>
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
</FrameLayout>

View File

@@ -82,6 +82,7 @@
<color name="warning">#ff5621</color> <color name="warning">#ff5621</color>
<color name="confirm_device_credential_dark_background">#263238</color> <color name="confirm_device_credential_dark_background">#263238</color>
<color name="confirm_device_credential_transparent_black">#60000000</color>
<color name="fab_ripple">#1fffffff</color><!-- 12% white --> <color name="fab_ripple">#1fffffff</color><!-- 12% white -->
<color name="fab_shape">?android:attr/colorAccent</color> <color name="fab_shape">?android:attr/colorAccent</color>
<color name="voice_interaction_highlight">#33b5e5</color> <color name="voice_interaction_highlight">#33b5e5</color>

View File

@@ -255,6 +255,9 @@
<item name="android:windowAnimationStyle">@style/ConfirmDeviceCredentialsAnimationStyle</item> <item name="android:windowAnimationStyle">@style/ConfirmDeviceCredentialsAnimationStyle</item>
</style> </style>
<style name="Theme.ConfirmDeviceCredentialsWork" parent="Theme.ConfirmDeviceCredentialsDark">
<item name="@*android:regularColor">@*android:color/white</item>
</style>
<style name="Theme.FingerprintEnroll" parent="@*android:style/Theme.Material.Settings.NoActionBar"> <style name="Theme.FingerprintEnroll" parent="@*android:style/Theme.Material.Settings.NoActionBar">
<item name="android:windowAnimationStyle">@style/Animation.SuwWindowAnimation</item> <item name="android:windowAnimationStyle">@style/Animation.SuwWindowAnimation</item>

View File

@@ -172,7 +172,7 @@ public class ChooseLockGeneric extends SettingsActivity {
!mLockPatternUtils.isSeparateProfileChallengeAllowed(targetUser)) { !mLockPatternUtils.isSeparateProfileChallengeAllowed(targetUser)) {
// Always use parent if explicitely requested or if profile challenge is not // Always use parent if explicitely requested or if profile challenge is not
// supported // supported
mUserId = Utils.getSameOwnerUserId(getContext(), getArguments()); mUserId = Utils.getUserIdFromBundle(getContext(), getArguments());
} else { } else {
mUserId = targetUser; mUserId = targetUser;
} }

View File

@@ -238,7 +238,7 @@ public class ChooseLockPassword extends SettingsActivity {
throw new SecurityException("Fragment contained in wrong activity"); throw new SecurityException("Fragment contained in wrong activity");
} }
// Only take this argument into account if it belongs to the current profile. // Only take this argument into account if it belongs to the current profile.
mUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
mRequestedQuality = Math.max(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mRequestedQuality = Math.max(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY,
mRequestedQuality), mLockPatternUtils.getRequestedPasswordQuality( mRequestedQuality), mLockPatternUtils.getRequestedPasswordQuality(
mUserId)); mUserId));

View File

@@ -370,7 +370,7 @@ public class ChooseLockPattern extends SettingsActivity {
} }
Intent intent = getActivity().getIntent(); Intent intent = getActivity().getIntent();
// Only take this argument into account if it belongs to the current profile. // Only take this argument into account if it belongs to the current profile.
mUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); mUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
} }
@Override @Override

View File

@@ -90,7 +90,7 @@ public final class ChooseLockSettingsHelper {
boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials, boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials,
int userId) { int userId) {
return launchConfirmationActivity(request, title, null, null, return launchConfirmationActivity(request, title, null, null,
returnCredentials, false, false, 0, Utils.getSameOwnerUserId(mActivity, userId)); returnCredentials, false, false, 0, Utils.enforceSameOwner(mActivity, userId));
} }
/** /**
@@ -110,7 +110,7 @@ public final class ChooseLockSettingsHelper {
@Nullable CharSequence header, @Nullable CharSequence description, @Nullable CharSequence header, @Nullable CharSequence description,
boolean returnCredentials, boolean external) { boolean returnCredentials, boolean external) {
return launchConfirmationActivity(request, title, header, description, return launchConfirmationActivity(request, title, header, description,
returnCredentials, external, false, 0, Utils.getEffectiveUserId(mActivity)); returnCredentials, external, false, 0, Utils.getCredentialOwnerUserId(mActivity));
} }
/** /**
@@ -131,7 +131,7 @@ public final class ChooseLockSettingsHelper {
@Nullable CharSequence header, @Nullable CharSequence description, @Nullable CharSequence header, @Nullable CharSequence description,
boolean returnCredentials, boolean external, int userId) { boolean returnCredentials, boolean external, int userId) {
return launchConfirmationActivity(request, title, header, description, return launchConfirmationActivity(request, title, header, description,
returnCredentials, external, false, 0, Utils.getSameOwnerUserId(mActivity, userId)); returnCredentials, external, false, 0, Utils.enforceSameOwner(mActivity, userId));
} }
/** /**
@@ -147,7 +147,7 @@ public final class ChooseLockSettingsHelper {
@Nullable CharSequence header, @Nullable CharSequence description, @Nullable CharSequence header, @Nullable CharSequence description,
long challenge) { long challenge) {
return launchConfirmationActivity(request, title, header, description, return launchConfirmationActivity(request, title, header, description,
false, false, true, challenge, Utils.getEffectiveUserId(mActivity)); false, false, true, challenge, Utils.getCredentialOwnerUserId(mActivity));
} }
private boolean launchConfirmationActivity(int request, @Nullable CharSequence title, private boolean launchConfirmationActivity(int request, @Nullable CharSequence title,

View File

@@ -64,12 +64,12 @@ public class ConfirmDeviceCredentialActivity extends Activity {
Intent intent = getIntent(); Intent intent = getIntent();
String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE); String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION); String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
int userId = Utils.getEffectiveUserId(this); int userId = Utils.getCredentialOwnerUserId(this);
if (isInternalActivity()) { if (isInternalActivity()) {
int givenUserId = intent.getIntExtra(Intent.EXTRA_USER_ID, userId); try {
UserManager userManager = UserManager.get(this); userId = Utils.getUserIdFromBundle(this, intent.getExtras());
if (userManager.isSameProfileGroup(givenUserId, userId)) { } catch (SecurityException se) {
userId = givenUserId; Log.e(TAG, "Invalid intent extra", se);
} }
} }
ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this); ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);

View File

@@ -18,8 +18,10 @@ package com.android.settings;
import android.app.Fragment; import android.app.Fragment;
import android.app.KeyguardManager; import android.app.KeyguardManager;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.UserManager;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.WindowManager; import android.view.WindowManager;
@@ -33,7 +35,12 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
@Override @Override
protected void onCreate(Bundle savedState) { protected void onCreate(Bundle savedState) {
if (getIntent().getBooleanExtra(ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) { int credentialOwnerUserId = Utils.getCredentialOwnerUserId(this,
Utils.getUserIdFromBundle(this, getIntent().getExtras()));
if (Utils.isManagedProfile(UserManager.get(this), credentialOwnerUserId)) {
setTheme(R.style.Theme_ConfirmDeviceCredentialsWork);
} else if (getIntent().getBooleanExtra(
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {
setTheme(R.style.Theme_ConfirmDeviceCredentialsDark); setTheme(R.style.Theme_ConfirmDeviceCredentialsDark);
mDark = true; mDark = true;
} }

View File

@@ -24,10 +24,16 @@ import android.app.IActivityManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender; import android.content.IntentSender;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.UserManager;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@@ -80,6 +86,14 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
getActivity().finish(); getActivity().finish();
} }
}); });
int credentialOwnerUserId = Utils.getCredentialOwnerUserId(
getActivity(),
Utils.getUserIdFromBundle(
getActivity(),
getActivity().getIntent().getExtras()));
if (Utils.isManagedProfile(UserManager.get(getActivity()), credentialOwnerUserId)) {
setWorkChallengeBackground(view);
}
} }
@Override @Override
@@ -155,4 +169,20 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
} }
} }
} }
private void setWorkChallengeBackground(View baseView) {
ImageView imageView = (ImageView) baseView.findViewById(R.id.background_image);
if (imageView != null) {
Drawable image = getResources().getDrawable(R.drawable.work_challenge_background);
image.setColorFilter(
getResources().getColor(R.color.confirm_device_credential_transparent_black),
PorterDuff.Mode.DARKEN);
imageView.setImageDrawable(image);
Point screenSize = new Point();
getActivity().getWindowManager().getDefaultDisplay().getSize(screenSize);
imageView.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
screenSize.y));
}
}
} }

View File

@@ -111,7 +111,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
mLockPatternUtils = new LockPatternUtils(getActivity()); mLockPatternUtils = new LockPatternUtils(getActivity());
Intent intent = getActivity().getIntent(); Intent intent = getActivity().getIntent();
// Only take this argument into account if it belongs to the current profile. // Only take this argument into account if it belongs to the current profile.
mEffectiveUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); mEffectiveUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
} }
@Override @Override

View File

@@ -116,7 +116,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
mLockPatternUtils = new LockPatternUtils(getActivity()); mLockPatternUtils = new LockPatternUtils(getActivity());
Intent intent = getActivity().getIntent(); Intent intent = getActivity().getIntent();
// Only take this argument into account if it belongs to the current profile. // Only take this argument into account if it belongs to the current profile.
mEffectiveUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); mEffectiveUserId = Utils.getUserIdFromBundle(getActivity(), intent.getExtras());
} }
@Override @Override

View File

@@ -16,6 +16,7 @@
package com.android.settings; package com.android.settings;
import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityManagerNative; import android.app.ActivityManagerNative;
@@ -180,6 +181,19 @@ public final class Utils extends com.android.settingslib.Utils {
return false; return false;
} }
/**
* Returns the UserManager for a given context
*
* @throws IllegalStateException if no UserManager could be retrieved.
*/
public static UserManager getUserManager(Context context) {
UserManager um = UserManager.get(context);
if (um == null) {
throw new IllegalStateException("Unable to load UserManager");
}
return um;
}
/** /**
* Returns true if Monkey is running. * Returns true if Monkey is running.
*/ */
@@ -569,10 +583,24 @@ public final class Utils extends com.android.settingslib.Utils {
/** /**
* Returns true if the current profile is a managed one. * Returns true if the current profile is a managed one.
*
* @throws IllegalArgumentException if userManager is null.
*/ */
public static boolean isManagedProfile(UserManager userManager) { public static boolean isManagedProfile(@NonNull UserManager userManager) {
UserInfo currentUser = userManager.getUserInfo(userManager.getUserHandle()); return isManagedProfile(userManager, UserHandle.myUserId());
return currentUser.isManagedProfile(); }
/**
* Returns true if the userId passed in is a managed profile.
*
* @throws IllegalArgumentException if userManager is null.
*/
public static boolean isManagedProfile(@NonNull UserManager userManager, int userId) {
if (userManager == null) {
throw new IllegalArgumentException("userManager must not be null");
}
UserInfo userInfo = userManager.getUserInfo(userId);
return (userInfo != null) ? userInfo.isManagedProfile() : false;
} }
/** /**
@@ -932,17 +960,17 @@ public final class Utils extends com.android.settingslib.Utils {
} }
/** /**
* Returns the user id present in the bundle with {@link ChooseLockGeneric#KEY_USER_ID} if it * Returns the user id present in the bundle with {@link Intent#EXTRA_USER_ID} if it
* belongs to the current user. * belongs to the current user.
* *
* @throws SecurityException if the given userId does not belong to the current user group. * @throws SecurityException if the given userId does not belong to the current user group.
*/ */
public static int getSameOwnerUserId(Context context, Bundle bundle) { public static int getUserIdFromBundle(Context context, Bundle bundle) {
if (bundle == null) { if (bundle == null) {
return getEffectiveUserId(context); return getCredentialOwnerUserId(context);
} }
int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId()); int userId = bundle.getInt(Intent.EXTRA_USER_ID, UserHandle.myUserId());
return getSameOwnerUserId(context, userId); return enforceSameOwner(context, userId);
} }
/** /**
@@ -950,27 +978,28 @@ public final class Utils extends com.android.settingslib.Utils {
* *
* @throws SecurityException if the given userId does not belong to the current user group. * @throws SecurityException if the given userId does not belong to the current user group.
*/ */
public static int getSameOwnerUserId(Context context, int userId) { public static int enforceSameOwner(Context context, int userId) {
UserManager um = UserManager.get(context); UserManager um = getUserManager(context);
if (um != null) { if (!um.getUserProfiles().contains(new UserHandle(userId))) {
if (um.getUserProfiles().contains(new UserHandle(userId))) { throw new SecurityException("Given user id " + userId + " does not belong to user "
return userId; + UserHandle.myUserId());
} else {
throw new SecurityException("Given user id " + userId + " does not belong to user "
+ UserHandle.myUserId());
}
} }
return getEffectiveUserId(context); return userId;
} }
public static int getEffectiveUserId(Context context) { /**
UserManager um = UserManager.get(context); * Returns the effective credential owner of the calling user.
if (um != null) { */
return um.getCredentialOwnerProfile(UserHandle.myUserId()); public static int getCredentialOwnerUserId(Context context) {
} else { return getCredentialOwnerUserId(context, UserHandle.myUserId());
Log.e(TAG, "Unable to acquire UserManager"); }
return UserHandle.myUserId();
} /**
* Returns the user id of the credential owner of the given user id.
*/
public static int getCredentialOwnerUserId(Context context, int userId) {
UserManager um = getUserManager(context);
return um.getCredentialOwnerProfile(userId);
} }
public static int resolveResource(Context context, int attr) { public static int resolveResource(Context context, int attr) {