Merge "UI updates for work profile first run." into tm-qpr-dev

This commit is contained in:
Matt Casey
2023-01-31 15:42:18 +00:00
committed by Android (Google) Code Review
4 changed files with 21 additions and 22 deletions

View File

@@ -4,12 +4,16 @@
android:id="@+id/work_profile_first_run" android:id="@+id/work_profile_first_run"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:paddingStart="16dp"
android:paddingEnd="4dp"
android:paddingVertical="16dp"
android:visibility="gone"> android:visibility="gone">
<ImageView <ImageView
android:id="@+id/screenshot_message_icon" android:id="@+id/screenshot_message_icon"
android:layout_width="48dp" android:layout_width="32dp"
android:layout_height="48dp" android:layout_height="32dp"
android:paddingEnd="4dp" android:layout_marginEnd="12dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_work_app_badge"/> android:src="@drawable/ic_work_app_badge"/>
<TextView <TextView
@@ -17,7 +21,11 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:layout_gravity="start"/> android:layout_gravity="start|center_vertical"
android:textSize="18sp"
android:textColor="?android:attr/textColorPrimary"
android:lineHeight="24sp"
/>
<FrameLayout <FrameLayout
android:id="@+id/message_dismiss_button" android:id="@+id/message_dismiss_button"
@@ -25,9 +33,9 @@
android:layout_height="@dimen/overlay_dismiss_button_tappable_size" android:layout_height="@dimen/overlay_dismiss_button_tappable_size"
android:contentDescription="@string/screenshot_dismiss_work_profile"> android:contentDescription="@string/screenshot_dismiss_work_profile">
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="24dp"
android:layout_height="match_parent" android:layout_height="24dp"
android:layout_margin="@dimen/overlay_dismiss_button_margin" android:layout_gravity="center"
android:src="@drawable/overlay_cancel"/> android:src="@drawable/overlay_cancel"/>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View File

@@ -240,7 +240,7 @@
<!-- Content description for the right boundary of the screenshot being cropped, with the current position as a percentage. [CHAR LIMIT=NONE] --> <!-- Content description for the right boundary of the screenshot being cropped, with the current position as a percentage. [CHAR LIMIT=NONE] -->
<string name="screenshot_right_boundary_pct">Right boundary <xliff:g id="percent" example="50">%1$d</xliff:g> percent</string> <string name="screenshot_right_boundary_pct">Right boundary <xliff:g id="percent" example="50">%1$d</xliff:g> percent</string>
<!-- Notification displayed when a screenshot is saved in a work profile. [CHAR LIMIT=NONE] --> <!-- Notification displayed when a screenshot is saved in a work profile. [CHAR LIMIT=NONE] -->
<string name="screenshot_work_profile_notification">Work screenshots are saved in the <xliff:g id="app" example="Work Files">%1$s</xliff:g> app</string> <string name="screenshot_work_profile_notification">Saved in <xliff:g id="app" example="Files">%1$s</xliff:g> in the work profile</string>
<!-- Default name referring to the app on the device that lets the user browse stored files. [CHAR LIMIT=NONE] --> <!-- Default name referring to the app on the device that lets the user browse stored files. [CHAR LIMIT=NONE] -->
<string name="screenshot_default_files_app_name">Files</string> <string name="screenshot_default_files_app_name">Files</string>
<!-- A notice shown to the user to indicate that an app has detected the screenshot that the user has just taken. [CHAR LIMIT=75] --> <!-- A notice shown to the user to indicate that an app has detected the screenshot that the user has just taken. [CHAR LIMIT=75] -->

View File

@@ -67,10 +67,7 @@ constructor(
} }
// If label wasn't loaded, use a default // If label wasn't loaded, use a default
val badgedLabel = return WorkProfileFirstRunData(label ?: defaultFileAppName(), badgedIcon)
packageManager.getUserBadgedLabel(label ?: defaultFileAppName(), userHandle)
return WorkProfileFirstRunData(badgedLabel, badgedIcon)
} }
return null return null
} }

View File

@@ -59,9 +59,7 @@ import kotlin.Unit;
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
public class WorkProfileMessageControllerTest extends SysuiTestCase { public class WorkProfileMessageControllerTest extends SysuiTestCase {
private static final String DEFAULT_LABEL = "default label"; private static final String DEFAULT_LABEL = "default label";
private static final String BADGED_DEFAULT_LABEL = "badged default label";
private static final String APP_LABEL = "app label"; private static final String APP_LABEL = "app label";
private static final String BADGED_APP_LABEL = "badged app label";
private static final UserHandle NON_WORK_USER = UserHandle.of(0); private static final UserHandle NON_WORK_USER = UserHandle.of(0);
private static final UserHandle WORK_USER = UserHandle.of(10); private static final UserHandle WORK_USER = UserHandle.of(10);
@@ -91,10 +89,6 @@ public class WorkProfileMessageControllerTest extends SysuiTestCase {
eq(WorkProfileMessageController.SHARED_PREFERENCES_NAME), eq(WorkProfileMessageController.SHARED_PREFERENCES_NAME),
eq(Context.MODE_PRIVATE))).thenReturn(mSharedPreferences); eq(Context.MODE_PRIVATE))).thenReturn(mSharedPreferences);
when(mMockContext.getString(ArgumentMatchers.anyInt())).thenReturn(DEFAULT_LABEL); when(mMockContext.getString(ArgumentMatchers.anyInt())).thenReturn(DEFAULT_LABEL);
when(mPackageManager.getUserBadgedLabel(eq(DEFAULT_LABEL), any()))
.thenReturn(BADGED_DEFAULT_LABEL);
when(mPackageManager.getUserBadgedLabel(eq(APP_LABEL), any()))
.thenReturn(BADGED_APP_LABEL);
when(mPackageManager.getActivityIcon(any(ComponentName.class))) when(mPackageManager.getActivityIcon(any(ComponentName.class)))
.thenReturn(mActivityIcon); .thenReturn(mActivityIcon);
when(mPackageManager.getUserBadgedIcon( when(mPackageManager.getUserBadgedIcon(
@@ -133,7 +127,7 @@ public class WorkProfileMessageControllerTest extends SysuiTestCase {
WorkProfileMessageController.WorkProfileFirstRunData data = WorkProfileMessageController.WorkProfileFirstRunData data =
mMessageController.onScreenshotTaken(WORK_USER); mMessageController.onScreenshotTaken(WORK_USER);
assertEquals(BADGED_DEFAULT_LABEL, data.getAppName()); assertEquals(DEFAULT_LABEL, data.getAppName());
assertNull(data.getIcon()); assertNull(data.getIcon());
} }
@@ -142,7 +136,7 @@ public class WorkProfileMessageControllerTest extends SysuiTestCase {
WorkProfileMessageController.WorkProfileFirstRunData data = WorkProfileMessageController.WorkProfileFirstRunData data =
mMessageController.onScreenshotTaken(WORK_USER); mMessageController.onScreenshotTaken(WORK_USER);
assertEquals(BADGED_APP_LABEL, data.getAppName()); assertEquals(APP_LABEL, data.getAppName());
assertEquals(mBadgedActivityIcon, data.getIcon()); assertEquals(mBadgedActivityIcon, data.getIcon());
} }
@@ -151,7 +145,7 @@ public class WorkProfileMessageControllerTest extends SysuiTestCase {
ViewGroup layout = (ViewGroup) LayoutInflater.from(mContext).inflate( ViewGroup layout = (ViewGroup) LayoutInflater.from(mContext).inflate(
R.layout.screenshot_work_profile_first_run, null); R.layout.screenshot_work_profile_first_run, null);
WorkProfileMessageController.WorkProfileFirstRunData data = WorkProfileMessageController.WorkProfileFirstRunData data =
new WorkProfileMessageController.WorkProfileFirstRunData(BADGED_APP_LABEL, new WorkProfileMessageController.WorkProfileFirstRunData(APP_LABEL,
mBadgedActivityIcon); mBadgedActivityIcon);
final CountDownLatch countdown = new CountDownLatch(1); final CountDownLatch countdown = new CountDownLatch(1);
mMessageController.populateView(layout, data, () -> { mMessageController.populateView(layout, data, () -> {
@@ -163,7 +157,7 @@ public class WorkProfileMessageControllerTest extends SysuiTestCase {
assertEquals(mBadgedActivityIcon, image.getDrawable()); assertEquals(mBadgedActivityIcon, image.getDrawable());
TextView text = layout.findViewById(R.id.screenshot_message_content); TextView text = layout.findViewById(R.id.screenshot_message_content);
// The app name is used in a template, but at least validate that it was inserted. // The app name is used in a template, but at least validate that it was inserted.
assertTrue(text.getText().toString().contains(BADGED_APP_LABEL)); assertTrue(text.getText().toString().contains(APP_LABEL));
// Validate that clicking the dismiss button calls back properly. // Validate that clicking the dismiss button calls back properly.
assertEquals(1, countdown.getCount()); assertEquals(1, countdown.getCount());