import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment
implements ChooseLockTypeDialogFragment.OnLockTypeSelectedListener {
+ @Nullable
+ private Button mOptionsButton;
+
@Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
+ public View onCreateView(
+ LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View view = super.onCreateView(inflater, container, savedInstanceState);
if (!getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
- Button optionsButton = view.findViewById(R.id.screen_lock_options);
- optionsButton.setVisibility(View.VISIBLE);
- optionsButton.setOnClickListener((btn) ->
+ mOptionsButton = view.findViewById(R.id.screen_lock_options);
+ mOptionsButton.setOnClickListener((btn) ->
ChooseLockTypeDialogFragment.newInstance(mUserId)
.show(getChildFragmentManager(), null));
}
+ return view;
}
@Override
}
@Override
+ protected void updateStage(Stage stage) {
+ super.updateStage(stage);
+ if (!getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)
+ && mOptionsButton != null) {
+ mOptionsButton.setVisibility(
+ stage == Stage.Introduction ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
+
+ @Override
public void handleLeftButton() {
SetupSkipDialog dialog = SetupSkipDialog.newInstance(
getActivity().getIntent()
import android.view.View;
import android.widget.Button;
+import com.android.internal.widget.LockPatternView;
import com.android.settings.R;
import com.android.settings.SetupRedactionInterstitial;
import com.android.settings.password.ChooseLockPattern.ChooseLockPatternFragment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowAlertDialog;
import org.robolectric.shadows.ShadowPackageManager;
+import org.robolectric.util.ReflectionHelpers;
+import org.robolectric.util.ReflectionHelpers.ClassParameter;
+
+import java.util.Collections;
+import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(shadows = {
@Config(qualifiers = "sw400dp")
@Test
+ public void selectPattern_shouldHideOptionsButton() {
+ Button button = mActivity.findViewById(R.id.screen_lock_options);
+ assertThat(button).isNotNull();
+ assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
+
+ LockPatternView lockPatternView = mActivity.findViewById(R.id.lockPattern);
+ ReflectionHelpers.callInstanceMethod(lockPatternView, "notifyPatternDetected");
+ }
+
+ @Config(qualifiers = "sw400dp")
+ @Test
public void sw400dp_shouldShowScreenLockOptions() {
Button button = mActivity.findViewById(R.id.screen_lock_options);
assertThat(button).isNotNull();