Merge "Add ambient notifications as inline setting." into oc-dr1-dev
diff --git a/res/layout/battery_header.xml b/res/layout/battery_header.xml
index d59476c..db90e2e 100644
--- a/res/layout/battery_header.xml
+++ b/res/layout/battery_header.xml
@@ -47,6 +47,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
+ android:minLines="2"
android:textAppearance="@android:style/TextAppearance.Material.Small"/>
<TextView
diff --git a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
index bc6950e..3b5dbba 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
@@ -92,6 +92,6 @@
mContext.getString(R.string.display_settings));
return new InlineSwitchPayload(SECURE_KEY, ResultPayload.SettingsSource.SECURE,
- ON /* onValue */, intent, isAvailable(), ON /* defaultValue */);
+ ON /* onValue */, intent, isAvailable(), OFF /* defaultValue */);
}
}
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index 0aea810..84e150a 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -356,6 +356,7 @@
fingerprintBackupMessage
.setText(R.string.setup_lock_settings_picker_fingerprint_message);
}
+ mLayout.setIcon(getActivity().getDrawable(R.drawable.ic_fingerprint_header));
}
mIsAlphaMode = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC == mRequestedQuality
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index d1964b4..9d00729 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -400,6 +400,7 @@
private ChooseLockSettingsHelper mChooseLockSettingsHelper;
private SaveAndFinishWorker mSaveAndFinishWorker;
private int mUserId;
+ private boolean mForFingerprint;
private static final String KEY_UI_STAGE = "uiStage";
private static final String KEY_PATTERN_CHOICE = "chosenPattern";
@@ -429,6 +430,8 @@
false, 0, LockPatternUtils.stringToPattern(current), current, mUserId);
}
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
+ mForFingerprint = intent.getBooleanExtra(
+ ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
}
@Override
@@ -437,6 +440,9 @@
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));
+ }
return layout;
}
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
index 74eeaf1..5fa731e 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
@@ -22,22 +22,53 @@
import android.app.admin.DevicePolicyManager;
import android.content.Intent;
+import android.os.UserHandle;
import com.android.internal.widget.LockPatternUtils;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.R;
import com.android.settings.TestConfig;
+import com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment;
import com.android.settings.password.ChooseLockPassword.IntentBuilder;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
+import com.android.settings.testutils.shadow.ShadowEventLogWriter;
+import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.setupwizardlib.GlifLayout;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowDrawable;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
manifest = TestConfig.MANIFEST_PATH,
- sdk = TestConfig.SDK_VERSION)
+ sdk = TestConfig.SDK_VERSION,
+ shadows = {
+ SettingsShadowResources.class,
+ SettingsShadowResources.SettingsShadowTheme.class,
+ ShadowDynamicIndexableContentMonitor.class,
+ ShadowEventLogWriter.class,
+ ShadowUtils.class
+ })
public class ChooseLockPasswordTest {
+ @Before
+ public void setUp() throws Exception {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.string.config_headlineFontFamily, "");
+ }
+
+ @After
+ public void tearDown() {
+ SettingsShadowResources.reset();
+ }
+
@Test
public void intentBuilder_setPassword_shouldAddExtras() {
Intent intent = new IntentBuilder(application)
@@ -95,4 +126,30 @@
.named("EXTRA_USER_ID")
.isEqualTo(123);
}
+
+ @Test
+ public void assertThat_chooseLockIconChanged_WhenFingerprintExtraSet() {
+ ShadowDrawable drawable = setActivityAndGetIconDrawable(true);
+ assertThat(drawable.getCreatedFromResId()).isEqualTo(R.drawable.ic_fingerprint_header);
+ }
+
+ @Test
+ public void assertThat_chooseLockIconNotChanged_WhenFingerprintExtraSet() {
+ ShadowDrawable drawable = setActivityAndGetIconDrawable(false);
+ assertThat(drawable.getCreatedFromResId()).isNotEqualTo(R.drawable.ic_fingerprint_header);
+ }
+
+ private ShadowDrawable setActivityAndGetIconDrawable(boolean addFingerprintExtra) {
+ ChooseLockPassword passwordActivity =
+ Robolectric.buildActivity(
+ ChooseLockPassword.class,
+ new IntentBuilder(application)
+ .setUserId(UserHandle.myUserId())
+ .setForFingerprint(addFingerprintExtra)
+ .build())
+ .setup().get();
+ ChooseLockPasswordFragment fragment = (ChooseLockPasswordFragment)
+ passwordActivity.getFragmentManager().findFragmentById(R.id.main_content);
+ return Shadows.shadowOf(((GlifLayout) fragment.getView()).getIcon());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index fa09884..b238049 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -21,19 +21,25 @@
import static org.robolectric.RuntimeEnvironment.application;
import android.content.Intent;
+import android.os.UserHandle;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.R;
import com.android.settings.TestConfig;
+import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
import com.android.settings.password.ChooseLockPattern.IntentBuilder;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
import com.android.settings.testutils.shadow.ShadowEventLogWriter;
import com.android.settings.testutils.shadow.ShadowUtils;
+import com.android.setupwizardlib.GlifLayout;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
+import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowDrawable;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(
@@ -95,4 +101,23 @@
.named("EXTRA_USER_ID")
.isEqualTo(123);
}
+
+ @Test
+ public void assertThat_chooseLockIconChanged_WhenFingerprintExtraSet() {
+ 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);
+ }
+
+ private ChooseLockPattern createActivity(boolean addFingerprintExtra) {
+ return Robolectric.buildActivity(
+ ChooseLockPattern.class,
+ new IntentBuilder(application)
+ .setUserId(UserHandle.myUserId())
+ .setForFingerprint(addFingerprintExtra)
+ .build())
+ .setup().get();
+ }
}