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"
|
||||
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"
|
||||
|
@@ -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_height="match_parent"
|
||||
android:icon="@drawable/ic_suggested_notifications"
|
||||
settings:sucFooter="@layout/redaction_interstitial_footer"
|
||||
settings:suwHeaderText="@string/lock_screen_notifications_interstitial_title">
|
||||
|
||||
<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.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 @@ public class EncryptionInterstitial extends SettingsActivity {
|
||||
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 class EncryptionInterstitial extends SettingsActivity {
|
||||
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 @@ public class EncryptionInterstitial extends SettingsActivity {
|
||||
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 @@ public class EncryptionInterstitial extends SettingsActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
@@ -32,7 +32,6 @@ import android.provider.Settings;
|
||||
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.SettingsPreferenceFragment;
|
||||
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 class RedactionInterstitial extends SettingsActivity {
|
||||
}
|
||||
|
||||
public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
|
||||
implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {
|
||||
implements RadioGroup.OnCheckedChangeListener {
|
||||
|
||||
private RadioGroup mRadioGroup;
|
||||
private RestrictedRadioButton mShowAllButton;
|
||||
@@ -130,19 +132,24 @@ public class RedactionInterstitial extends SettingsActivity {
|
||||
((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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,9 @@ import androidx.test.InstrumentationRegistry;
|
||||
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 @@ public class EncryptionInterstitialTest {
|
||||
|
||||
@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 @@ public class EncryptionInterstitialTest {
|
||||
|
||||
@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());
|
||||
|
Reference in New Issue
Block a user