Migrating to new footer button for lockscreen pages.
Bug: 120805516 Test: RunSettingsRoboTests Change-Id: I12d68cd2eaa750eecd2c40e172efd6b6b16a0849
This commit is contained in:
@@ -20,8 +20,7 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:icon="@drawable/ic_lock"
|
android:icon="@drawable/ic_lock">
|
||||||
app:sucFooter="@layout/encryption_interstitial_footer">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="@style/SuwContentFrame"
|
style="@style/SuwContentFrame"
|
||||||
|
@@ -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>
|
|
@@ -22,7 +22,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:icon="@drawable/ic_suggested_notifications"
|
android:icon="@drawable/ic_suggested_notifications"
|
||||||
settings:sucFooter="@layout/redaction_interstitial_footer"
|
|
||||||
settings:suwHeaderText="@string/lock_screen_notifications_interstitial_title">
|
settings:suwHeaderText="@string/lock_screen_notifications_interstitial_title">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@@ -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>
|
|
@@ -40,6 +40,8 @@ import com.android.settings.core.InstrumentedFragment;
|
|||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
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 com.google.android.setupdesign.GlifLayout;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -86,11 +88,8 @@ public class EncryptionInterstitial extends SettingsActivity {
|
|||||||
layout.setFitsSystemWindows(false);
|
layout.setFitsSystemWindows(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EncryptionInterstitialFragment extends InstrumentedFragment
|
public static class EncryptionInterstitialFragment extends InstrumentedFragment {
|
||||||
implements View.OnClickListener {
|
|
||||||
|
|
||||||
private View mRequirePasswordToDecrypt;
|
|
||||||
private View mDontRequirePasswordToDecrypt;
|
|
||||||
private boolean mPasswordRequired;
|
private boolean mPasswordRequired;
|
||||||
private Intent mUnlockMethodIntent;
|
private Intent mUnlockMethodIntent;
|
||||||
private int mRequestedPasswordQuality;
|
private int mRequestedPasswordQuality;
|
||||||
@@ -110,8 +109,6 @@ public class EncryptionInterstitial extends SettingsActivity {
|
|||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, 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(
|
final boolean forFingerprint = getActivity().getIntent().getBooleanExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
|
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
|
||||||
final boolean forFace = getActivity().getIntent()
|
final boolean forFace = getActivity().getIntent()
|
||||||
@@ -147,14 +144,30 @@ public class EncryptionInterstitial extends SettingsActivity {
|
|||||||
TextView message = (TextView) getActivity().findViewById(R.id.encryption_message);
|
TextView message = (TextView) getActivity().findViewById(R.id.encryption_message);
|
||||||
message.setText(msgId);
|
message.setText(msgId);
|
||||||
|
|
||||||
mRequirePasswordToDecrypt.setOnClickListener(this);
|
|
||||||
mDontRequirePasswordToDecrypt.setOnClickListener(this);
|
|
||||||
|
|
||||||
setRequirePasswordState(getActivity().getIntent().getBooleanExtra(
|
setRequirePasswordState(getActivity().getIntent().getBooleanExtra(
|
||||||
EXTRA_REQUIRE_PASSWORD, true));
|
EXTRA_REQUIRE_PASSWORD, true));
|
||||||
|
|
||||||
GlifLayout layout = (GlifLayout) view;
|
GlifLayout layout = (GlifLayout) view;
|
||||||
layout.setHeaderText(getActivity().getTitle());
|
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() {
|
protected void startLockIntent() {
|
||||||
@@ -176,9 +189,7 @@ public class EncryptionInterstitial extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void onYesButtonClicked(View view) {
|
||||||
public void onClick(View view) {
|
|
||||||
if (view == mRequirePasswordToDecrypt) {
|
|
||||||
final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
|
final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
|
||||||
if (accEn && !mPasswordRequired) {
|
if (accEn && !mPasswordRequired) {
|
||||||
setRequirePasswordState(false); // clear the UI state
|
setRequirePasswordState(false); // clear the UI state
|
||||||
@@ -190,11 +201,12 @@ public class EncryptionInterstitial extends SettingsActivity {
|
|||||||
setRequirePasswordState(true);
|
setRequirePasswordState(true);
|
||||||
startLockIntent();
|
startLockIntent();
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
private void onNoButtonClicked(View view) {
|
||||||
setRequirePasswordState(false);
|
setRequirePasswordState(false);
|
||||||
startLockIntent();
|
startLockIntent();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void setRequirePasswordState(boolean required) {
|
private void setRequirePasswordState(boolean required) {
|
||||||
mPasswordRequired = required;
|
mPasswordRequired = required;
|
||||||
|
@@ -32,7 +32,6 @@ import android.provider.Settings;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
@@ -46,9 +45,12 @@ import com.android.settings.SettingsPreferenceFragment;
|
|||||||
import com.android.settings.SetupRedactionInterstitial;
|
import com.android.settings.SetupRedactionInterstitial;
|
||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settings.SetupWizardUtils;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
|
||||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
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 {
|
public class RedactionInterstitial extends SettingsActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,7 +93,7 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
|
public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
|
||||||
implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {
|
implements RadioGroup.OnCheckedChangeListener {
|
||||||
|
|
||||||
private RadioGroup mRadioGroup;
|
private RadioGroup mRadioGroup;
|
||||||
private RestrictedRadioButton mShowAllButton;
|
private RestrictedRadioButton mShowAllButton;
|
||||||
@@ -130,13 +132,19 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
|
((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Button button = (Button) view.findViewById(R.id.redaction_done_button);
|
final GlifLayout layout = view.findViewById(R.id.setup_wizard_layout);
|
||||||
button.setOnClickListener(this);
|
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
|
private void onDoneButtonClicked(View view) {
|
||||||
public void onClick(View v) {
|
|
||||||
if (v.getId() == R.id.redaction_done_button) {
|
|
||||||
SetupRedactionInterstitial.setEnabled(getContext(), false);
|
SetupRedactionInterstitial.setEnabled(getContext(), false);
|
||||||
final RedactionInterstitial activity = (RedactionInterstitial) getActivity();
|
final RedactionInterstitial activity = (RedactionInterstitial) getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
@@ -144,7 +152,6 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
@@ -35,6 +35,9 @@ import androidx.test.InstrumentationRegistry;
|
|||||||
import androidx.test.filters.MediumTest;
|
import androidx.test.filters.MediumTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
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.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -63,10 +66,11 @@ public class EncryptionInterstitialTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clickYes_shouldRequirePassword() {
|
public void clickYes_shouldRequirePassword() {
|
||||||
mInstrumentation.startActivitySync(
|
final Activity activity = mInstrumentation.startActivitySync(
|
||||||
new Intent(mContext, EncryptionInterstitial.class)
|
new Intent(mContext, EncryptionInterstitial.class)
|
||||||
.putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent")));
|
.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);
|
mActivityMonitor.waitForActivityWithTimeout(1000);
|
||||||
assertEquals(1, mActivityMonitor.getHits());
|
assertEquals(1, mActivityMonitor.getHits());
|
||||||
@@ -77,10 +81,11 @@ public class EncryptionInterstitialTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clickNo_shouldNotRequirePassword() {
|
public void clickNo_shouldNotRequirePassword() {
|
||||||
mInstrumentation.startActivitySync(
|
final Activity activity = mInstrumentation.startActivitySync(
|
||||||
new Intent(mContext, EncryptionInterstitial.class)
|
new Intent(mContext, EncryptionInterstitial.class)
|
||||||
.putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent")));
|
.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);
|
mActivityMonitor.waitForActivityWithTimeout(1000);
|
||||||
assertEquals(1, mActivityMonitor.getHits());
|
assertEquals(1, mActivityMonitor.getHits());
|
||||||
|
Reference in New Issue
Block a user