Snap for 5254928 from d3c02d87f9 to qt-release
Change-Id: Ieb3f356379d53a5d1a622090643934ed66e1a911
This commit is contained in:
@@ -17,11 +17,11 @@
|
|||||||
<com.google.android.setupdesign.GlifLayout
|
<com.google.android.setupdesign.GlifLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/setup_wizard_layout"
|
||||||
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"
|
||||||
android:importantForAutofill="noExcludeDescendants"
|
android:importantForAutofill="noExcludeDescendants"
|
||||||
settings:sucFooter="@layout/choose_lock_password_footer"
|
|
||||||
settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
|
settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -1,53 +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/SudGlifButtonBar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<!-- left : skip -->
|
|
||||||
<Button android:id="@+id/skip_button"
|
|
||||||
style="@style/SudGlifButton.Secondary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/skip_label"
|
|
||||||
android:visibility="gone" />
|
|
||||||
|
|
||||||
|
|
||||||
<!-- left : clear -->
|
|
||||||
<Button android:id="@+id/clear_button"
|
|
||||||
style="@style/SudGlifButton.Secondary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:text="@string/lockpassword_clear_label" />
|
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<!-- right : continue -->
|
|
||||||
<Button android:id="@+id/next_button"
|
|
||||||
style="@style/SudGlifButton.Primary"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/next_label" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -26,7 +26,8 @@
|
|||||||
android:id="@+id/network_request_title_text"
|
android:id="@+id/network_request_title_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingLeft="16dip"
|
android:paddingLeft="24dp"
|
||||||
|
android:paddingTop="18dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
|||||||
@@ -10458,6 +10458,8 @@
|
|||||||
<string name="network_connection_timeout_dialog_ok">Try again</string>
|
<string name="network_connection_timeout_dialog_ok">Try again</string>
|
||||||
<!-- Message for Network connection error state Dialog [CHAR LIMIT=NONE] -->
|
<!-- Message for Network connection error state Dialog [CHAR LIMIT=NONE] -->
|
||||||
<string name="network_connection_errorstate_dialog_message">Something came up. The application has cancelled the request to choose a device.</string>
|
<string name="network_connection_errorstate_dialog_message">Something came up. The application has cancelled the request to choose a device.</string>
|
||||||
|
<!-- Toast message when connection is successful [CHAR LIMIT=30] -->
|
||||||
|
<string name="network_connection_connect_successful">Connection successful</string>
|
||||||
|
|
||||||
<!-- Summary for bluetooth devices count in Bluetooth devices slice. [CHAR LIMIT=NONE] -->
|
<!-- Summary for bluetooth devices count in Bluetooth devices slice. [CHAR LIMIT=NONE] -->
|
||||||
<plurals name="show_bluetooth_devices">
|
<plurals name="show_bluetooth_devices">
|
||||||
|
|||||||
@@ -109,12 +109,14 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
|
|||||||
mCachedDevice = getCachedDevice(mDeviceAddress);
|
mCachedDevice = getCachedDevice(mDeviceAddress);
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
|
|
||||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlags.SLICE_INJECTION)) {
|
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(
|
||||||
final BluetoothFeatureProvider featureProvider = FeatureFactory.getFactory(context)
|
context).getBluetoothFeatureProvider(context);
|
||||||
.getBluetoothFeatureProvider(context);
|
final boolean injectionEnabled = FeatureFlagUtils.isEnabled(context,
|
||||||
use(BlockingSlicePrefController.class).setSliceUri(
|
FeatureFlags.SLICE_INJECTION);
|
||||||
featureProvider.getBluetoothDeviceSettingsUri(mDeviceAddress));
|
|
||||||
}
|
use(BlockingSlicePrefController.class).setSliceUri(injectionEnabled
|
||||||
|
? featureProvider.getBluetoothDeviceSettingsUri(mDeviceAddress)
|
||||||
|
: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.TextView.OnEditorActionListener;
|
import android.widget.TextView.OnEditorActionListener;
|
||||||
@@ -69,6 +68,8 @@ import com.android.settings.core.InstrumentedFragment;
|
|||||||
import com.android.settings.notification.RedactionInterstitial;
|
import com.android.settings.notification.RedactionInterstitial;
|
||||||
import com.android.settings.widget.ImeAwareEditText;
|
import com.android.settings.widget.ImeAwareEditText;
|
||||||
|
|
||||||
|
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.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -168,8 +169,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class ChooseLockPasswordFragment extends InstrumentedFragment
|
public static class ChooseLockPasswordFragment extends InstrumentedFragment
|
||||||
implements OnClickListener, OnEditorActionListener, TextWatcher,
|
implements OnEditorActionListener, TextWatcher, SaveAndFinishWorker.Listener {
|
||||||
SaveAndFinishWorker.Listener {
|
|
||||||
private static final String KEY_FIRST_PIN = "first_pin";
|
private static final String KEY_FIRST_PIN = "first_pin";
|
||||||
private static final String KEY_UI_STAGE = "ui_stage";
|
private static final String KEY_UI_STAGE = "ui_stage";
|
||||||
private static final String KEY_CURRENT_PASSWORD = "current_password";
|
private static final String KEY_CURRENT_PASSWORD = "current_password";
|
||||||
@@ -210,9 +210,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
private String mFirstPin;
|
private String mFirstPin;
|
||||||
private RecyclerView mPasswordRestrictionView;
|
private RecyclerView mPasswordRestrictionView;
|
||||||
protected boolean mIsAlphaMode;
|
protected boolean mIsAlphaMode;
|
||||||
protected Button mSkipButton;
|
protected FooterButton mSkipOrClearButton;
|
||||||
private Button mClearButton;
|
private FooterButton mNextButton;
|
||||||
private Button mNextButton;
|
|
||||||
private TextView mMessage;
|
private TextView mMessage;
|
||||||
|
|
||||||
private TextChangedHandler mTextChangedHandler;
|
private TextChangedHandler mTextChangedHandler;
|
||||||
@@ -408,13 +407,25 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
ViewGroup container = view.findViewById(R.id.password_container);
|
ViewGroup container = view.findViewById(R.id.password_container);
|
||||||
container.setOpticalInsets(Insets.NONE);
|
container.setOpticalInsets(Insets.NONE);
|
||||||
|
|
||||||
mSkipButton = view.findViewById(R.id.skip_button);
|
final ButtonFooterMixin mixin = mLayout.getMixin(ButtonFooterMixin.class);
|
||||||
mSkipButton.setOnClickListener(this);
|
mixin.setSecondaryButton(
|
||||||
mNextButton = view.findViewById(R.id.next_button);
|
new FooterButton.Builder(getActivity())
|
||||||
mNextButton.setOnClickListener(this);
|
.setText(R.string.lockpassword_clear_label)
|
||||||
mClearButton = view.findViewById(R.id.clear_button);
|
.setListener(this::onSkipOrClearButtonClick)
|
||||||
mClearButton.setOnClickListener(this);
|
.setButtonType(FooterButton.ButtonType.SKIP)
|
||||||
|
.setTheme(R.style.SudGlifButton_Secondary)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
mixin.setPrimaryButton(
|
||||||
|
new FooterButton.Builder(getActivity())
|
||||||
|
.setText(R.string.next_label)
|
||||||
|
.setListener(this::onNextButtonClick)
|
||||||
|
.setButtonType(FooterButton.ButtonType.NEXT)
|
||||||
|
.setTheme(R.style.SudGlifButton_Primary)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
mSkipOrClearButton = mixin.getSecondaryButton();
|
||||||
|
mNextButton = mixin.getPrimaryButton();
|
||||||
|
|
||||||
mMessage = view.findViewById(R.id.message);
|
mMessage = view.findViewById(R.id.message);
|
||||||
if (mForFingerprint) {
|
if (mForFingerprint) {
|
||||||
@@ -777,19 +788,15 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void setNextText(int text) {
|
protected void setNextText(int text) {
|
||||||
mNextButton.setText(text);
|
mNextButton.setText(getActivity(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
protected void onSkipOrClearButtonClick(View view) {
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.next_button:
|
|
||||||
handleNext();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.clear_button:
|
|
||||||
mPasswordEntry.setText("");
|
mPasswordEntry.setText("");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onNextButtonClick(View view) {
|
||||||
|
handleNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
@@ -894,13 +901,12 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
mPasswordRequirementAdapter.setRequirements(messages);
|
mPasswordRequirementAdapter.setRequirements(messages);
|
||||||
// Enable/Disable the next button accordingly.
|
// Enable/Disable the next button accordingly.
|
||||||
setNextEnabled(errorCode == NO_ERROR);
|
setNextEnabled(errorCode == NO_ERROR);
|
||||||
mClearButton.setVisibility(View.GONE);
|
|
||||||
} else {
|
} else {
|
||||||
// Hide password requirement view when we are just asking user to confirm the pw.
|
// Hide password requirement view when we are just asking user to confirm the pw.
|
||||||
mPasswordRestrictionView.setVisibility(View.GONE);
|
mPasswordRestrictionView.setVisibility(View.GONE);
|
||||||
setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, getStageType())));
|
setHeaderText(getString(mUiStage.getHint(mIsAlphaMode, getStageType())));
|
||||||
setNextEnabled(canInput && length >= mPasswordMinLength);
|
setNextEnabled(canInput && length >= mPasswordMinLength);
|
||||||
mClearButton.setVisibility(toVisibility(canInput && length > 0));
|
mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0));
|
||||||
}
|
}
|
||||||
int message = mUiStage.getMessage(mIsAlphaMode, getStageType());
|
int message = mUiStage.getMessage(mIsAlphaMode, getStageType());
|
||||||
if (message != 0) {
|
if (message != 0) {
|
||||||
|
|||||||
@@ -72,8 +72,11 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
|
|||||||
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment
|
public static class SetupChooseLockPasswordFragment extends ChooseLockPasswordFragment
|
||||||
implements OnLockTypeSelectedListener {
|
implements OnLockTypeSelectedListener {
|
||||||
|
|
||||||
|
private static final String TAG_SKIP_SCREEN_LOCK_DIALOG = "skip_screen_lock_dialog";
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Button mOptionsButton;
|
private Button mOptionsButton;
|
||||||
|
private boolean mLeftButtonIsSkip;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
@@ -92,26 +95,22 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
|
|||||||
if (showOptionsButton && anyOptionsShown) {
|
if (showOptionsButton && anyOptionsShown) {
|
||||||
mOptionsButton = view.findViewById(R.id.screen_lock_options);
|
mOptionsButton = view.findViewById(R.id.screen_lock_options);
|
||||||
mOptionsButton.setVisibility(View.VISIBLE);
|
mOptionsButton.setVisibility(View.VISIBLE);
|
||||||
mOptionsButton.setOnClickListener(this);
|
mOptionsButton.setOnClickListener((btn) ->
|
||||||
|
ChooseLockTypeDialogFragment.newInstance(mUserId)
|
||||||
|
.show(getChildFragmentManager(), TAG_SKIP_SCREEN_LOCK_DIALOG));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
protected void onSkipOrClearButtonClick(View view) {
|
||||||
switch (v.getId()) {
|
if (mLeftButtonIsSkip) {
|
||||||
case R.id.screen_lock_options:
|
|
||||||
ChooseLockTypeDialogFragment.newInstance(mUserId)
|
|
||||||
.show(getChildFragmentManager(), null);
|
|
||||||
break;
|
|
||||||
case R.id.skip_button:
|
|
||||||
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
|
||||||
getActivity().getIntent()
|
getActivity().getIntent()
|
||||||
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
.getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false));
|
||||||
dialog.show(getFragmentManager());
|
dialog.show(getFragmentManager());
|
||||||
break;
|
return;
|
||||||
default:
|
|
||||||
super.onClick(v);
|
|
||||||
}
|
}
|
||||||
|
super.onSkipOrClearButtonClick(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -137,9 +136,11 @@ public class SetupChooseLockPassword extends ChooseLockPassword {
|
|||||||
super.updateUi();
|
super.updateUi();
|
||||||
// Show the skip button during SUW but not during Settings > Biometric Enrollment
|
// Show the skip button during SUW but not during Settings > Biometric Enrollment
|
||||||
if (mUiStage == Stage.Introduction) {
|
if (mUiStage == Stage.Introduction) {
|
||||||
mSkipButton.setVisibility(View.VISIBLE);
|
mSkipOrClearButton.setText(getActivity(), R.string.skip_label);
|
||||||
|
mLeftButtonIsSkip = true;
|
||||||
} else {
|
} else {
|
||||||
mSkipButton.setVisibility(View.GONE);
|
mSkipOrClearButton.setText(getActivity(), R.string.lockpassword_clear_label);
|
||||||
|
mLeftButtonIsSkip = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mOptionsButton != null) {
|
if (mOptionsButton != null) {
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
|||||||
public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment
|
public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment
|
||||||
implements ChooseLockTypeDialogFragment.OnLockTypeSelectedListener {
|
implements ChooseLockTypeDialogFragment.OnLockTypeSelectedListener {
|
||||||
|
|
||||||
|
private static final String TAG_SKIP_SCREEN_LOCK_DIALOG = "skip_screen_lock_dialog";
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Button mOptionsButton;
|
private Button mOptionsButton;
|
||||||
private boolean mLeftButtonIsSkip;
|
private boolean mLeftButtonIsSkip;
|
||||||
@@ -69,7 +71,7 @@ public class SetupChooseLockPattern extends ChooseLockPattern {
|
|||||||
mOptionsButton = view.findViewById(R.id.screen_lock_options);
|
mOptionsButton = view.findViewById(R.id.screen_lock_options);
|
||||||
mOptionsButton.setOnClickListener((btn) ->
|
mOptionsButton.setOnClickListener((btn) ->
|
||||||
ChooseLockTypeDialogFragment.newInstance(mUserId)
|
ChooseLockTypeDialogFragment.newInstance(mUserId)
|
||||||
.show(getChildFragmentManager(), null));
|
.show(getChildFragmentManager(), TAG_SKIP_SCREEN_LOCK_DIALOG));
|
||||||
}
|
}
|
||||||
// Show the skip button during SUW but not during Settings > Biometric Enrollment
|
// Show the skip button during SUW but not during Settings > Biometric Enrollment
|
||||||
mSkipOrClearButton.setOnClickListener(this::onSkipOrClearButtonClick);
|
mSkipOrClearButton.setOnClickListener(this::onSkipOrClearButtonClick);
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class SlicePreferenceController extends BasePreferenceController implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Slice slice) {
|
public void onChanged(Slice slice) {
|
||||||
|
if (slice != null) {
|
||||||
mSlicePreference.onSliceUpdated(slice);
|
mSlicePreference.onSliceUpdated(slice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -29,6 +30,7 @@ import android.net.wifi.WifiManager.NetworkRequestUserSelectionCallback;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -36,6 +38,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
@@ -65,15 +68,9 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
|
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
|
||||||
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
|
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
|
||||||
|
|
||||||
/** Message sent to us to finish activity. */
|
|
||||||
private static final int MESSAGE_FINISH_ACTIVITY = 1;
|
|
||||||
|
|
||||||
/** Spec defines there should be 5 wifi ap on the list at most. */
|
/** Spec defines there should be 5 wifi ap on the list at most. */
|
||||||
private static final int MAX_NUMBER_LIST_ITEM = 5;
|
private static final int MAX_NUMBER_LIST_ITEM = 5;
|
||||||
|
|
||||||
/** Holding time to let user be aware that selected wifi ap is connected */
|
|
||||||
private static final int DELAY_TIME_USER_AWARE_CONNECTED_MS = 1 * 1000;
|
|
||||||
|
|
||||||
/** Delayed time to stop scanning wifi. */
|
/** Delayed time to stop scanning wifi. */
|
||||||
private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
|
private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
|
||||||
|
|
||||||
@@ -184,7 +181,6 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
mHandler.removeMessages(MESSAGE_FINISH_ACTIVITY);
|
|
||||||
if (mFilterWifiTracker != null) {
|
if (mFilterWifiTracker != null) {
|
||||||
mFilterWifiTracker.onDestroy();
|
mFilterWifiTracker.onDestroy();
|
||||||
mFilterWifiTracker = null;
|
mFilterWifiTracker = null;
|
||||||
@@ -215,10 +211,7 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MESSAGE_STOP_SCAN_WIFI_LIST:
|
case MESSAGE_STOP_SCAN_WIFI_LIST:
|
||||||
removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
|
removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
|
||||||
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
|
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
|
||||||
break;
|
|
||||||
case MESSAGE_FINISH_ACTIVITY:
|
|
||||||
stopScanningAndMaybePopErrorDialog(/* ERROR_DIALOG_TYPE */ null);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
@@ -227,19 +220,13 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
|
protected void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
|
||||||
// Dismisses current dialog.
|
// Dismisses current dialog.
|
||||||
final Dialog dialog = getDialog();
|
final Dialog dialog = getDialog();
|
||||||
if (dialog != null && dialog.isShowing()) {
|
if (dialog != null && dialog.isShowing()) {
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == null) {
|
|
||||||
// If no error, finishes activity.
|
|
||||||
if (getActivity() != null) {
|
|
||||||
getActivity().finish();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Throws error dialog.
|
// Throws error dialog.
|
||||||
final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
|
final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
|
||||||
.newInstance();
|
.newInstance();
|
||||||
@@ -250,8 +237,6 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
NetworkRequestDialogFragment.class.getSimpleName());
|
NetworkRequestDialogFragment.class.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.WIFI_SCANNING_NEEDED_DIALOG;
|
return SettingsEnums.WIFI_SCANNING_NEEDED_DIALOG;
|
||||||
@@ -287,7 +272,13 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
|
|
||||||
final TextView summary = view.findViewById(android.R.id.summary);
|
final TextView summary = view.findViewById(android.R.id.summary);
|
||||||
if (summary != null) {
|
if (summary != null) {
|
||||||
summary.setText(accessPoint.getSettingsSummary());
|
final String summaryString = accessPoint.getSettingsSummary();
|
||||||
|
if (TextUtils.isEmpty(summaryString)) {
|
||||||
|
summary.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
summary.setVisibility(View.VISIBLE);
|
||||||
|
summary.setText(summaryString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final PreferenceImageView imageView = view.findViewById(android.R.id.icon);
|
final PreferenceImageView imageView = view.findViewById(android.R.id.icon);
|
||||||
@@ -306,7 +297,7 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAbort() {
|
public void onAbort() {
|
||||||
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -354,24 +345,17 @@ public class NetworkRequestDialogFragment extends InstrumentedDialogFragment imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
|
public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
|
||||||
// Removes the progress icon.
|
final Activity activity = getActivity();
|
||||||
final Dialog dialog = getDialog();
|
if (activity != null) {
|
||||||
if (dialog != null) {
|
Toast.makeText(activity, R.string.network_connection_connect_successful,
|
||||||
final View view = dialog.findViewById(R.id.network_request_title_progress);
|
Toast.LENGTH_SHORT).show();
|
||||||
if (view != null) {
|
activity.finish();
|
||||||
view.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Posts delay to finish self since connection is success.
|
|
||||||
mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
|
|
||||||
mHandler.sendEmptyMessageDelayed(MESSAGE_FINISH_ACTIVITY,
|
|
||||||
DELAY_TIME_USER_AWARE_CONNECTED_MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
|
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
|
||||||
stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class FilterWifiTracker {
|
private final class FilterWifiTracker {
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
|
|||||||
import com.android.settings.testutils.shadow.ShadowUtils;
|
import com.android.settings.testutils.shadow.ShadowUtils;
|
||||||
import com.android.settings.widget.ScrollToParentEditText;
|
import com.android.settings.widget.ScrollToParentEditText;
|
||||||
|
|
||||||
|
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;
|
||||||
@@ -137,17 +140,19 @@ public class SetupChooseLockPasswordTest {
|
|||||||
public void createActivity_skipButtonInIntroductionStage_shouldBeVisible() {
|
public void createActivity_skipButtonInIntroductionStage_shouldBeVisible() {
|
||||||
SetupChooseLockPassword activity = createSetupChooseLockPassword();
|
SetupChooseLockPassword activity = createSetupChooseLockPassword();
|
||||||
|
|
||||||
Button skipButton = activity.findViewById(R.id.skip_button);
|
final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
assertThat(skipButton).isNotNull();
|
final Button skipOrClearButton =
|
||||||
assertThat(skipButton.getVisibility()).isEqualTo(View.VISIBLE);
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||||
|
assertThat(skipOrClearButton).isNotNull();
|
||||||
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
|
||||||
skipButton.performClick();
|
skipOrClearButton.performClick();
|
||||||
AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
final AlertDialog chooserDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
|
||||||
assertThat(chooserDialog).isNotNull();
|
assertThat(chooserDialog).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createActivity_inputPasswordInConfirmStage_clearButtonShouldBeVisible() {
|
public void createActivity_inputPasswordInConfirmStage_clearButtonShouldBeShown() {
|
||||||
SetupChooseLockPassword activity = createSetupChooseLockPassword();
|
SetupChooseLockPassword activity = createSetupChooseLockPassword();
|
||||||
|
|
||||||
SetupChooseLockPasswordFragment fragment =
|
SetupChooseLockPasswordFragment fragment =
|
||||||
@@ -158,15 +163,17 @@ public class SetupChooseLockPasswordTest {
|
|||||||
passwordEntry.setText("");
|
passwordEntry.setText("");
|
||||||
fragment.updateStage(Stage.NeedToConfirm);
|
fragment.updateStage(Stage.NeedToConfirm);
|
||||||
|
|
||||||
Button skipButton = activity.findViewById(R.id.skip_button);
|
final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
Button clearButton = activity.findViewById(R.id.clear_button);
|
final Button skipOrClearButton =
|
||||||
assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||||
assertThat(clearButton.getVisibility()).isEqualTo(View.GONE);
|
assertThat(skipOrClearButton.isEnabled()).isTrue();
|
||||||
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
|
||||||
passwordEntry.setText("1234");
|
passwordEntry.setText("1234");
|
||||||
fragment.updateUi();
|
fragment.updateUi();
|
||||||
assertThat(skipButton.getVisibility()).isEqualTo(View.GONE);
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
assertThat(clearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(skipOrClearButton.getText())
|
||||||
|
.isEqualTo(application.getString(R.string.lockpassword_clear_label));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SetupChooseLockPassword createSetupChooseLockPassword() {
|
private SetupChooseLockPassword createSetupChooseLockPassword() {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class NetworkRequestDialogFragmentTest {
|
|||||||
ERROR_DIALOG_TYPE errorType = null;
|
ERROR_DIALOG_TYPE errorType = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
|
public void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
|
||||||
bCalledStopAndPop = true;
|
bCalledStopAndPop = true;
|
||||||
errorType = type;
|
errorType = type;
|
||||||
}
|
}
|
||||||
@@ -152,25 +152,19 @@ public class NetworkRequestDialogFragmentTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateAccessPointList_onUserSelectionConnectSuccess_shouldCloseTheDialog() {
|
public void updateAccessPointList_onUserSelectionConnectSuccess_shouldFinishActivity() {
|
||||||
// Assert
|
// Assert
|
||||||
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
|
final FragmentActivity spyActivity = spy(mActivity);
|
||||||
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
|
when(networkRequestDialogFragment.getActivity()).thenReturn(spyActivity);
|
||||||
|
networkRequestDialogFragment.show(spyActivity.getSupportFragmentManager(), "onUserSelectionConnectSuccess");
|
||||||
List<AccessPoint> accessPointList = createAccessPointList();
|
|
||||||
when(spyFakeFragment.getAccessPointList()).thenReturn(accessPointList);
|
|
||||||
|
|
||||||
spyFakeFragment.show(mActivity.getSupportFragmentManager(), null);
|
|
||||||
|
|
||||||
// Action
|
// Action
|
||||||
WifiConfiguration config = new WifiConfiguration();
|
final WifiConfiguration config = new WifiConfiguration();
|
||||||
config.SSID = "Test AP 3";
|
config.SSID = "Test AP 3";
|
||||||
spyFakeFragment.onUserSelectionConnectSuccess(config);
|
networkRequestDialogFragment.onUserSelectionConnectSuccess(config);
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
ShadowLooper.getShadowMainLooper().runToEndOfTasks();
|
verify(spyActivity).finish();
|
||||||
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
|
|
||||||
assertThat(fakeFragment.errorType).isNull();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -24,12 +24,16 @@ import static androidx.test.espresso.matcher.ViewMatchers.isEnabled;
|
|||||||
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
|
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Instrumentation;
|
import android.app.Instrumentation;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
import androidx.test.espresso.action.ViewActions;
|
import androidx.test.espresso.action.ViewActions;
|
||||||
@@ -38,6 +42,9 @@ import androidx.test.runner.AndroidJUnit4;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import com.google.android.setupcompat.PartnerCustomizationLayout;
|
||||||
|
import com.google.android.setupcompat.template.ButtonFooterMixin;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -54,28 +61,41 @@ public class ChooseLockPasswordTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearNotVisible_when_activityLaunchedInitially() {
|
public void clearIsNotShown_when_activityLaunchedInitially() {
|
||||||
mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class));
|
final Activity activity =
|
||||||
onView(withId(R.id.clear_button)).check(matches(
|
mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class)
|
||||||
withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
|
final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
|
assertThat(
|
||||||
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().getVisibility())
|
||||||
|
.isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearNotEnabled_when_nothingEntered() {
|
public void clearIsNotShown_when_nothingEntered() {
|
||||||
|
final Activity activity =
|
||||||
mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class));
|
mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class));
|
||||||
|
final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
||||||
.perform(pressKey(KeyEvent.KEYCODE_ENTER));
|
.perform(pressKey(KeyEvent.KEYCODE_ENTER));
|
||||||
onView(withId(R.id.clear_button)).check(matches(isDisplayed()))
|
assertThat(
|
||||||
.check(matches(not(isEnabled())));
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().getVisibility())
|
||||||
|
.isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearEnabled_when_somethingEnteredToConfirm() {
|
public void clearIsShown_when_somethingEnteredToConfirm() {
|
||||||
|
final Activity activity =
|
||||||
mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class));
|
mInstrumentation.startActivitySync(new Intent(mContext, ChooseLockPassword.class));
|
||||||
|
final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
||||||
.perform(pressKey(KeyEvent.KEYCODE_ENTER))
|
.perform(pressKey(KeyEvent.KEYCODE_ENTER))
|
||||||
.perform(ViewActions.typeText("1"));
|
.perform(ViewActions.typeText("1"));
|
||||||
// clear should be present if text field contains content
|
// clear should be present if text field contains content
|
||||||
onView(withId(R.id.clear_button)).check(matches(isDisplayed()));
|
assertThat(layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().getText())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lockpassword_clear_label));
|
||||||
|
assertThat(
|
||||||
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().getVisibility())
|
||||||
|
.isEqualTo(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,12 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import androidx.test.InstrumentationRegistry;
|
||||||
import androidx.test.espresso.action.ViewActions;
|
import androidx.test.espresso.action.ViewActions;
|
||||||
import androidx.test.espresso.matcher.ViewMatchers;
|
import androidx.test.espresso.matcher.ViewMatchers;
|
||||||
import androidx.test.filters.MediumTest;
|
import androidx.test.filters.MediumTest;
|
||||||
@@ -40,6 +44,10 @@ import androidx.test.runner.AndroidJUnit4;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import com.google.android.setupcompat.PartnerCustomizationLayout;
|
||||||
|
import com.google.android.setupcompat.template.ButtonFooterMixin;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -48,6 +56,8 @@ import org.junit.runner.RunWith;
|
|||||||
@MediumTest
|
@MediumTest
|
||||||
public class SetupChooseLockPasswordAppTest {
|
public class SetupChooseLockPasswordAppTest {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ActivityTestRule<SetupChooseLockPassword> mActivityTestRule =
|
public ActivityTestRule<SetupChooseLockPassword> mActivityTestRule =
|
||||||
new ActivityTestRule<>(
|
new ActivityTestRule<>(
|
||||||
@@ -55,42 +65,56 @@ public class SetupChooseLockPasswordAppTest {
|
|||||||
true /* enable touch at launch */,
|
true /* enable touch at launch */,
|
||||||
false /* don't launch at every test */);
|
false /* don't launch at every test */);
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = InstrumentationRegistry.getTargetContext();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSkipDialogIsShown() throws Throwable {
|
public void testSkipDialogIsShown() throws Throwable {
|
||||||
SetupChooseLockPassword activity = mActivityTestRule.launchActivity(null);
|
SetupChooseLockPassword activity = mActivityTestRule.launchActivity(null);
|
||||||
|
PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
|
final Button skipOrClearButton =
|
||||||
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView();
|
||||||
|
|
||||||
onView(withId(R.id.cancel_button))
|
assertThat(skipOrClearButton.getText()).isEqualTo(mContext.getString(R.string.skip_label));
|
||||||
.check(matches(withText(R.string.skip_label)))
|
assertThat(skipOrClearButton.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
.check(matches(isDisplayed()))
|
skipOrClearButton.performClick();
|
||||||
.perform(click());
|
|
||||||
onView(withId(android.R.id.button1)).check(matches(isDisplayed())).perform(click());
|
|
||||||
|
|
||||||
assertThat(activity.isFinishing()).named("Is finishing").isTrue();
|
assertThat(activity.isFinishing()).named("Is finishing").isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearNotVisible_when_activityLaunchedInitially() {
|
public void clearIsNotShown_when_activityLaunchedInitially() {
|
||||||
mActivityTestRule.launchActivity(null);
|
SetupChooseLockPassword activity = mActivityTestRule.launchActivity(null);
|
||||||
onView(withId(R.id.clear_button)).check(matches(
|
PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
withEffectiveVisibility(ViewMatchers.Visibility.GONE)));
|
assertThat(layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().getText())
|
||||||
|
.isEqualTo(mContext.getString(R.string.lockpassword_clear_label));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearNotEnabled_when_nothingEntered() throws Throwable {
|
public void clearIsNotShown_when_nothingEntered() throws Throwable {
|
||||||
mActivityTestRule.launchActivity(null);
|
SetupChooseLockPassword activity = mActivityTestRule.launchActivity(null);
|
||||||
|
PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
||||||
.perform(pressKey(KeyEvent.KEYCODE_ENTER));
|
.perform(pressKey(KeyEvent.KEYCODE_ENTER));
|
||||||
onView(withId(R.id.clear_button)).check(matches(isDisplayed()))
|
assertThat(
|
||||||
.check(matches(not(isEnabled())));
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().getVisibility())
|
||||||
|
.isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearEnabled_when_somethingEnteredToConfirm() {
|
public void clearIsShown_when_somethingEnteredToConfirm() {
|
||||||
|
SetupChooseLockPassword activity = mActivityTestRule.launchActivity(null);
|
||||||
|
PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
|
||||||
|
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
||||||
|
.perform(pressKey(KeyEvent.KEYCODE_ENTER));
|
||||||
mActivityTestRule.launchActivity(null);
|
mActivityTestRule.launchActivity(null);
|
||||||
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
onView(withId(R.id.password_entry)).perform(ViewActions.typeText("1234"))
|
||||||
.perform(pressKey(KeyEvent.KEYCODE_ENTER))
|
.perform(pressKey(KeyEvent.KEYCODE_ENTER))
|
||||||
.perform(ViewActions.typeText("1"));
|
.perform(ViewActions.typeText("1"));
|
||||||
// clear should be present if text field contains content
|
// clear should be present if text field contains content
|
||||||
onView(withId(R.id.clear_button)).check(matches(isDisplayed()));
|
assertThat(
|
||||||
|
layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().getVisibility())
|
||||||
|
.isEqualTo(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user