Improve pattern layout for tiiiny screens
On small screens < sw400dp, - Don't show icon - Don't show "Screen lock options" button Test: cd tests/robotests && mma Bug: 72764729 Change-Id: I8d9863d43c877fcc18f504d91d3183760b3fafc2
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/suw_layout_icon"
|
||||
style="@style/LockPatternIconStyle"
|
||||
style="@style/SuwGlifIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_lock" />
|
||||
@@ -73,6 +73,7 @@
|
||||
style="@style/SuwDescription.Glif"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="?attr/suwMarginSides"
|
||||
android:minLines="2" />
|
||||
|
||||
<TextView android:id="@+id/headerText"
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/suw_layout_icon"
|
||||
style="@style/LockPatternIconStyle"
|
||||
style="@style/SuwGlifIcon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="?attr/suwGlifHeaderGravity"
|
||||
|
8
res/values-sw400dp/styles.xml → res/values-sw400dp/config.xml
Executable file → Normal file
8
res/values-sw400dp/styles.xml → res/values-sw400dp/config.xml
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
Copyright (C) 2018 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,9 @@
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Unhide the icon on bigger screens -->
|
||||
<style name="LockPatternIconStyle" parent="SuwGlifIcon" />
|
||||
<!-- Whether to use a UI variant that minimizes the number of UI elements on screen. This is
|
||||
typically used when there is not enough space to display everything, because pattern view
|
||||
doesn't interact well with scroll view -->
|
||||
<bool name="config_lock_pattern_minimal_ui">false</bool>
|
||||
|
||||
</resources>
|
@@ -122,4 +122,10 @@
|
||||
|
||||
<!-- Whether or not new device intro suggestion is supported for this device -->
|
||||
<bool name="config_new_device_intro_suggestion_supported">false</bool>
|
||||
|
||||
<!-- Whether to use a UI variant that minimizes the number of UI elements on screen. This is
|
||||
typically used when there is not enough space to display everything, because pattern view
|
||||
doesn't interact well with scroll view -->
|
||||
<bool name="config_lock_pattern_minimal_ui">true</bool>
|
||||
|
||||
</resources>
|
||||
|
@@ -457,11 +457,6 @@
|
||||
<item name="*android:successColor">@color/setup_lock_pattern_view_success_color_light</item>
|
||||
</style>
|
||||
|
||||
<!-- Overridden in sw400dp -->
|
||||
<style name="LockPatternIconStyle" parent="SuwGlifIcon">
|
||||
<item name="android:visibility">gone</item>
|
||||
</style>
|
||||
|
||||
<style name="SuggestionConditionStyle">
|
||||
<item name="android:background">@color/suggestion_condition_background</item>
|
||||
</style>
|
||||
|
@@ -452,8 +452,15 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
final GlifLayout layout = (GlifLayout) inflater.inflate(
|
||||
R.layout.choose_lock_pattern, container, false);
|
||||
layout.setHeaderText(getActivity().getTitle());
|
||||
if (mForFingerprint) {
|
||||
layout.setIcon(getActivity().getDrawable(R.drawable.ic_fingerprint_header));
|
||||
if (getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
|
||||
View iconView = layout.findViewById(R.id.suw_layout_icon);
|
||||
if (iconView != null) {
|
||||
iconView.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
if (mForFingerprint) {
|
||||
layout.setIcon(getActivity().getDrawable(R.drawable.ic_fingerprint_header));
|
||||
}
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
@@ -57,11 +57,13 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
Button optionsButton = (Button) view.findViewById(R.id.screen_lock_options);
|
||||
optionsButton.setVisibility(View.VISIBLE);
|
||||
optionsButton.setOnClickListener((btn) ->
|
||||
ChooseLockTypeDialogFragment.newInstance(mUserId)
|
||||
.show(getChildFragmentManager(), null));
|
||||
if (!getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
|
||||
Button optionsButton = view.findViewById(R.id.screen_lock_options);
|
||||
optionsButton.setVisibility(View.VISIBLE);
|
||||
optionsButton.setOnClickListener((btn) ->
|
||||
ChooseLockTypeDialogFragment.newInstance(mUserId)
|
||||
.show(getChildFragmentManager(), null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -22,6 +22,7 @@ import static org.robolectric.RuntimeEnvironment.application;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
@@ -102,15 +103,27 @@ public class ChooseLockPatternTest {
|
||||
.isEqualTo(123);
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw400dp")
|
||||
@Test
|
||||
public void assertThat_chooseLockIconChanged_WhenFingerprintExtraSet() {
|
||||
public void fingerprintExtraSet_shouldDisplayFingerprintIcon() {
|
||||
ChooseLockPattern activity = createActivity(true);
|
||||
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
|
||||
activity.getFragmentManager().findFragmentById(R.id.main_content);
|
||||
|
||||
ShadowDrawable drawable = Shadows.shadowOf(((GlifLayout) fragment.getView()).getIcon());
|
||||
assertThat(drawable.getCreatedFromResId()).isEqualTo(R.drawable.ic_fingerprint_header);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smallScreens_shouldHideIcon() {
|
||||
ChooseLockPattern activity = createActivity(true);
|
||||
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
|
||||
activity.getFragmentManager().findFragmentById(R.id.main_content);
|
||||
|
||||
View iconView = fragment.getView().findViewById(R.id.suw_layout_icon);
|
||||
assertThat(iconView.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
private ChooseLockPattern createActivity(boolean addFingerprintExtra) {
|
||||
return Robolectric.buildActivity(
|
||||
ChooseLockPattern.class,
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings;
|
||||
package com.android.settings.password;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -28,9 +28,11 @@ import android.os.UserHandle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SetupRedactionInterstitial;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
|
||||
import com.android.settings.password.ChooseLockPattern.IntentBuilder;
|
||||
import com.android.settings.password.SetupChooseLockPattern;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResourcesImpl;
|
||||
@@ -89,8 +91,9 @@ public class SetupChooseLockPatternTest {
|
||||
.isEqualTo(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw400dp")
|
||||
@Test
|
||||
public void screenLockOptions_shouldBeVisible() {
|
||||
public void sw400dp_shouldShowScreenLockOptions() {
|
||||
Button button = mActivity.findViewById(R.id.screen_lock_options);
|
||||
assertThat(button).isNotNull();
|
||||
assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
@@ -102,6 +105,13 @@ public class SetupChooseLockPatternTest {
|
||||
assertThat(count).named("List items shown").isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smallScreens_shouldHideScreenLockOptions() {
|
||||
Button button = mActivity.findViewById(R.id.screen_lock_options);
|
||||
assertThat(button).isNotNull();
|
||||
assertThat(button.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipButton_shouldBeVisible_duringNonFingerprintFlow() {
|
||||
Button button = mActivity.findViewById(R.id.footerLeftButton);
|
Reference in New Issue
Block a user