Migrating to new footer button for lockscreen pages.
Bug: 120805516
Test: RunSettingsRoboTests
Change-Id: I12d68cd2eaa750eecd2c40e172efd6b6b16a0849
diff --git a/res/layout/encryption_interstitial.xml b/res/layout/encryption_interstitial.xml
index ff56a7c..5acc7b1 100644
--- a/res/layout/encryption_interstitial.xml
+++ b/res/layout/encryption_interstitial.xml
@@ -20,8 +20,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:icon="@drawable/ic_lock"
- app:sucFooter="@layout/encryption_interstitial_footer">
+ android:icon="@drawable/ic_lock">
<LinearLayout
style="@style/SuwContentFrame"
diff --git a/res/layout/encryption_interstitial_footer.xml b/res/layout/encryption_interstitial_footer.xml
deleted file mode 100644
index 2f876f3..0000000
--- a/res/layout/encryption_interstitial_footer.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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.
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/encrypt_dont_require_password"
- style="@style/SuwGlifButton.Secondary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/encryption_interstitial_no" />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" />
-
- <Button
- android:id="@+id/encrypt_require_password"
- style="@style/SuwGlifButton.Primary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/encryption_interstitial_yes" />
-
-</LinearLayout>
diff --git a/res/layout/redaction_interstitial.xml b/res/layout/redaction_interstitial.xml
index 929ac07..ab7e0b3 100644
--- a/res/layout/redaction_interstitial.xml
+++ b/res/layout/redaction_interstitial.xml
@@ -22,7 +22,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/ic_suggested_notifications"
- settings:sucFooter="@layout/redaction_interstitial_footer"
settings:suwHeaderText="@string/lock_screen_notifications_interstitial_title">
<LinearLayout
diff --git a/res/layout/redaction_interstitial_footer.xml b/res/layout/redaction_interstitial_footer.xml
deleted file mode 100644
index 1d8758b..0000000
--- a/res/layout/redaction_interstitial_footer.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/redaction_done_button"
- style="@style/SuwGlifButton.Primary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:text="@string/app_notifications_dialog_done" />
-
-</FrameLayout>
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index 8cae26b..a524a66 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -40,6 +40,8 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
import com.google.android.setupdesign.GlifLayout;
import java.util.List;
@@ -86,11 +88,8 @@
layout.setFitsSystemWindows(false);
}
- public static class EncryptionInterstitialFragment extends InstrumentedFragment
- implements View.OnClickListener {
+ public static class EncryptionInterstitialFragment extends InstrumentedFragment {
- private View mRequirePasswordToDecrypt;
- private View mDontRequirePasswordToDecrypt;
private boolean mPasswordRequired;
private Intent mUnlockMethodIntent;
private int mRequestedPasswordQuality;
@@ -110,8 +109,6 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mRequirePasswordToDecrypt = view.findViewById(R.id.encrypt_require_password);
- mDontRequirePasswordToDecrypt = view.findViewById(R.id.encrypt_dont_require_password);
final boolean forFingerprint = getActivity().getIntent().getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
final boolean forFace = getActivity().getIntent()
@@ -147,14 +144,30 @@
TextView message = (TextView) getActivity().findViewById(R.id.encryption_message);
message.setText(msgId);
- mRequirePasswordToDecrypt.setOnClickListener(this);
- mDontRequirePasswordToDecrypt.setOnClickListener(this);
-
setRequirePasswordState(getActivity().getIntent().getBooleanExtra(
EXTRA_REQUIRE_PASSWORD, true));
GlifLayout layout = (GlifLayout) view;
layout.setHeaderText(getActivity().getTitle());
+
+ final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
+ buttonFooterMixin.setSecondaryButton(
+ new FooterButton(
+ getContext(),
+ R.string.encryption_interstitial_no,
+ this::onNoButtonClicked,
+ FooterButton.ButtonType.SKIP,
+ R.style.SuwGlifButton_Secondary)
+ );
+
+ buttonFooterMixin.setPrimaryButton(
+ new FooterButton(
+ getContext(),
+ R.string.encryption_interstitial_yes,
+ this::onYesButtonClicked,
+ FooterButton.ButtonType.NEXT,
+ R.style.SuwGlifButton_Primary)
+ );
}
protected void startLockIntent() {
@@ -176,26 +189,25 @@
}
}
- @Override
- public void onClick(View view) {
- if (view == mRequirePasswordToDecrypt) {
- final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
- if (accEn && !mPasswordRequired) {
- setRequirePasswordState(false); // clear the UI state
- AccessibilityWarningDialogFragment.newInstance(mRequestedPasswordQuality)
- .show(
- getChildFragmentManager(),
- AccessibilityWarningDialogFragment.TAG);
- } else {
- setRequirePasswordState(true);
- startLockIntent();
- }
+ private void onYesButtonClicked(View view) {
+ final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
+ if (accEn && !mPasswordRequired) {
+ setRequirePasswordState(false); // clear the UI state
+ AccessibilityWarningDialogFragment.newInstance(mRequestedPasswordQuality)
+ .show(
+ getChildFragmentManager(),
+ AccessibilityWarningDialogFragment.TAG);
} else {
- setRequirePasswordState(false);
+ setRequirePasswordState(true);
startLockIntent();
}
}
+ private void onNoButtonClicked(View view) {
+ setRequirePasswordState(false);
+ startLockIntent();
+ }
+
private void setRequirePasswordState(boolean required) {
mPasswordRequired = required;
}
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index 32dc52d..a45dba1 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -32,7 +32,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
@@ -46,9 +45,12 @@
import com.android.settings.SetupRedactionInterstitial;
import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
-import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+import com.google.android.setupdesign.GlifLayout;
+
public class RedactionInterstitial extends SettingsActivity {
@Override
@@ -91,7 +93,7 @@
}
public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
- implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {
+ implements RadioGroup.OnCheckedChangeListener {
private RadioGroup mRadioGroup;
private RestrictedRadioButton mShowAllButton;
@@ -130,19 +132,24 @@
((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
}
- final Button button = (Button) view.findViewById(R.id.redaction_done_button);
- button.setOnClickListener(this);
+ final GlifLayout layout = view.findViewById(R.id.setup_wizard_layout);
+ final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
+ buttonFooterMixin.setPrimaryButton(
+ new FooterButton(
+ getContext(),
+ R.string.app_notifications_dialog_done,
+ this::onDoneButtonClicked,
+ FooterButton.ButtonType.NEXT,
+ R.style.SuwGlifButton_Primary)
+ );
}
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.redaction_done_button) {
- SetupRedactionInterstitial.setEnabled(getContext(), false);
- final RedactionInterstitial activity = (RedactionInterstitial) getActivity();
- if (activity != null) {
- activity.setResult(RESULT_OK, null);
- finish();
- }
+ private void onDoneButtonClicked(View view) {
+ SetupRedactionInterstitial.setEnabled(getContext(), false);
+ final RedactionInterstitial activity = (RedactionInterstitial) getActivity();
+ if (activity != null) {
+ activity.setResult(RESULT_OK, null);
+ finish();
}
}
diff --git a/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java b/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java
index 9a6b754..3b4abfe 100644
--- a/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java
+++ b/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java
@@ -35,6 +35,9 @@
import androidx.test.filters.MediumTest;
import androidx.test.runner.AndroidJUnit4;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -63,10 +66,11 @@
@Test
public void clickYes_shouldRequirePassword() {
- mInstrumentation.startActivitySync(
+ final Activity activity = mInstrumentation.startActivitySync(
new Intent(mContext, EncryptionInterstitial.class)
.putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent")));
- onView(withId(R.id.encrypt_require_password)).perform(click());
+ final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getPrimaryButtonView().performClick();
mActivityMonitor.waitForActivityWithTimeout(1000);
assertEquals(1, mActivityMonitor.getHits());
@@ -77,10 +81,11 @@
@Test
public void clickNo_shouldNotRequirePassword() {
- mInstrumentation.startActivitySync(
+ final Activity activity = mInstrumentation.startActivitySync(
new Intent(mContext, EncryptionInterstitial.class)
.putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent")));
- onView(withId(R.id.encrypt_dont_require_password)).perform(click());
+ final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().performClick();
mActivityMonitor.waitForActivityWithTimeout(1000);
assertEquals(1, mActivityMonitor.getHits());