1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.password; 18 19 import android.app.Fragment; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.os.Bundle; 23 import android.support.annotation.Nullable; 24 import android.view.LayoutInflater; 25 import android.view.View; 26 import android.view.ViewGroup; 27 import android.widget.Button; 28 29 import com.android.settings.R; 30 import com.android.settings.SetupRedactionInterstitial; 31 32 /** 33 * Setup Wizard's version of ChooseLockPattern screen. It inherits the logic and basic structure 34 * from ChooseLockPattern class, and should remain similar to that behaviorally. This class should 35 * only overload base methods for minor theme and behavior differences specific to Setup Wizard. 36 * Other changes should be done to ChooseLockPattern class instead and let this class inherit 37 * those changes. 38 */ 39 public class SetupChooseLockPattern extends ChooseLockPattern { 40 41 public static Intent modifyIntentForSetup(Context context, Intent chooseLockPatternIntent) { 42 chooseLockPatternIntent.setClass(context, SetupChooseLockPattern.class); 43 return chooseLockPatternIntent; 44 } 45 46 @Override 47 protected boolean isValidFragment(String fragmentName) { 48 return SetupChooseLockPatternFragment.class.getName().equals(fragmentName); 49 } 50 51 @Override 52 /* package */ Class<? extends Fragment> getFragmentClass() { 53 return SetupChooseLockPatternFragment.class; 54 } 55 56 public static class SetupChooseLockPatternFragment extends ChooseLockPatternFragment 57 implements ChooseLockTypeDialogFragment.OnLockTypeSelectedListener { 58 59 @Nullable 60 private Button mOptionsButton; 61 62 @Override 63 public View onCreateView( 64 LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 65 View view = super.onCreateView(inflater, container, savedInstanceState); 66 if (!getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) { 67 mOptionsButton = view.findViewById(R.id.screen_lock_options); 68 mOptionsButton.setOnClickListener((btn) -> 69 ChooseLockTypeDialogFragment.newInstance(mUserId) 70 .show(getChildFragmentManager(), null)); 71 } 72 // enable skip button only during setup wizard and not with fingerprint flow. 73 if (!mForFingerprint) { 74 Button skipButton = view.findViewById(R.id.skip_button); 75 skipButton.setVisibility(View.VISIBLE); 76 skipButton.setOnClickListener(v -> { 77 SetupSkipDialog dialog = SetupSkipDialog.newInstance( 78 getActivity().getIntent() 79 .getBooleanExtra(SetupSkipDialog.EXTRA_FRP_SUPPORTED, false)); 80 dialog.show(getFragmentManager()); 81 }); 82 } 83 return view; 84 } 85 86 @Override 87 public void onLockTypeSelected(ScreenLockType lock) { 88 if (ScreenLockType.PATTERN == lock) { 89 return; 90 } 91 startChooseLockActivity(lock, getActivity()); 92 } 93 94 @Override 95 protected void updateStage(Stage stage) { 96 super.updateStage(stage); 97 if (!getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui) 98 && mOptionsButton != null) { 99 mOptionsButton.setVisibility( 100 stage == Stage.Introduction ? View.VISIBLE : View.INVISIBLE); 101 } 102 } 103 104 @Override 105 protected Intent getRedactionInterstitialIntent(Context context) { 106 // Setup wizard's redaction interstitial is deferred to optional step. Enable that 107 // optional step if the lock screen was set up. 108 SetupRedactionInterstitial.setEnabled(context, true); 109 return null; 110 } 111 } 112 } 113