Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 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; |
| 18 | |
Jim Miller | aa03767 | 2014-10-17 18:28:52 -0700 | [diff] [blame] | 19 | import android.accessibilityservice.AccessibilityServiceInfo; |
Maurice Lam | 18d7965 | 2017-03-21 17:57:55 -0700 | [diff] [blame] | 20 | import android.app.Activity; |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 21 | import android.app.Dialog; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 22 | import android.app.admin.DevicePolicyManager; |
Fan Zhang | 31b2100 | 2019-01-16 13:49:47 -0800 | [diff] [blame] | 23 | import android.app.settings.SettingsEnums; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 24 | import android.content.Context; |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 25 | import android.content.DialogInterface; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 26 | import android.content.Intent; |
Maurice Lam | 9990f39 | 2017-06-28 15:06:09 -0700 | [diff] [blame] | 27 | import android.content.res.Resources; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 29 | import android.util.Log; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 30 | import android.view.LayoutInflater; |
Maurice Lam | d189ac5 | 2016-06-15 13:39:34 -0700 | [diff] [blame] | 31 | import android.view.View; |
| 32 | import android.view.ViewGroup; |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 33 | import android.view.accessibility.AccessibilityManager; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 34 | import android.widget.TextView; |
| 35 | |
Fan Zhang | 23f8d59 | 2018-08-28 15:11:40 -0700 | [diff] [blame] | 36 | import androidx.appcompat.app.AlertDialog; |
| 37 | |
Maurice Lam | 18d7965 | 2017-03-21 17:57:55 -0700 | [diff] [blame] | 38 | import com.android.settings.core.InstrumentedFragment; |
| 39 | import com.android.settings.core.instrumentation.InstrumentedDialogFragment; |
Maurice Lam | 2eb170c | 2017-04-28 16:18:47 -0700 | [diff] [blame] | 40 | import com.android.settings.password.ChooseLockSettingsHelper; |
Pasty Chang | c1f8600 | 2018-12-11 02:22:55 +0000 | [diff] [blame] | 41 | |
pastychang | 9bdb59a | 2019-01-21 09:49:15 +0800 | [diff] [blame] | 42 | import com.google.android.setupcompat.template.FooterBarMixin; |
| 43 | import com.google.android.setupcompat.template.FooterButton; |
Pasty Chang | c1f8600 | 2018-12-11 02:22:55 +0000 | [diff] [blame] | 44 | import com.google.android.setupdesign.GlifLayout; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 45 | |
| 46 | import java.util.List; |
| 47 | |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 48 | public class EncryptionInterstitial extends SettingsActivity { |
Maurice Lam | d189ac5 | 2016-06-15 13:39:34 -0700 | [diff] [blame] | 49 | private static final String TAG = EncryptionInterstitial.class.getSimpleName(); |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 50 | |
Maurice Lam | 0973c31 | 2014-12-05 12:19:05 -0800 | [diff] [blame] | 51 | protected static final String EXTRA_PASSWORD_QUALITY = "extra_password_quality"; |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 52 | protected static final String EXTRA_UNLOCK_METHOD_INTENT = "extra_unlock_method_intent"; |
Jim Miller | 0698a21 | 2014-10-16 19:49:07 -0700 | [diff] [blame] | 53 | public static final String EXTRA_REQUIRE_PASSWORD = "extra_require_password"; |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 54 | private static final int CHOOSE_LOCK_REQUEST = 100; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 55 | |
| 56 | @Override |
| 57 | public Intent getIntent() { |
| 58 | Intent modIntent = new Intent(super.getIntent()); |
| 59 | modIntent.putExtra(EXTRA_SHOW_FRAGMENT, EncryptionInterstitialFragment.class.getName()); |
| 60 | return modIntent; |
| 61 | } |
| 62 | |
| 63 | @Override |
Maurice Lam | 9990f39 | 2017-06-28 15:06:09 -0700 | [diff] [blame] | 64 | protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) { |
| 65 | resid = SetupWizardUtils.getTheme(getIntent()); |
| 66 | super.onApplyThemeResource(theme, resid, first); |
| 67 | } |
| 68 | |
| 69 | @Override |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 70 | protected boolean isValidFragment(String fragmentName) { |
| 71 | return EncryptionInterstitialFragment.class.getName().equals(fragmentName); |
| 72 | } |
| 73 | |
Jim Miller | 0698a21 | 2014-10-16 19:49:07 -0700 | [diff] [blame] | 74 | public static Intent createStartIntent(Context ctx, int quality, |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 75 | boolean requirePasswordDefault, Intent unlockMethodIntent) { |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 76 | return new Intent(ctx, EncryptionInterstitial.class) |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 77 | .putExtra(EXTRA_PASSWORD_QUALITY, quality) |
Jim Miller | 0698a21 | 2014-10-16 19:49:07 -0700 | [diff] [blame] | 78 | .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.encryption_interstitial_header) |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 79 | .putExtra(EXTRA_REQUIRE_PASSWORD, requirePasswordDefault) |
| 80 | .putExtra(EXTRA_UNLOCK_METHOD_INTENT, unlockMethodIntent); |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 81 | } |
| 82 | |
Maurice Lam | d189ac5 | 2016-06-15 13:39:34 -0700 | [diff] [blame] | 83 | @Override |
| 84 | protected void onCreate(Bundle savedInstance) { |
| 85 | super.onCreate(savedInstance); |
Fan Zhang | 9db66a5 | 2019-05-10 14:18:33 -0700 | [diff] [blame] | 86 | findViewById(R.id.content_parent).setFitsSystemWindows(false); |
Maurice Lam | d189ac5 | 2016-06-15 13:39:34 -0700 | [diff] [blame] | 87 | } |
| 88 | |
pastychang | 5dfdb4f | 2018-12-17 14:50:27 +0800 | [diff] [blame] | 89 | public static class EncryptionInterstitialFragment extends InstrumentedFragment { |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 90 | |
Jim Miller | 0698a21 | 2014-10-16 19:49:07 -0700 | [diff] [blame] | 91 | private boolean mPasswordRequired; |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 92 | private Intent mUnlockMethodIntent; |
Maurice Lam | 8890f7a | 2016-05-12 16:24:41 -0700 | [diff] [blame] | 93 | private int mRequestedPasswordQuality; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 94 | |
| 95 | @Override |
Fan Zhang | 6507613 | 2016-08-08 10:25:13 -0700 | [diff] [blame] | 96 | public int getMetricsCategory() { |
Fan Zhang | 31b2100 | 2019-01-16 13:49:47 -0800 | [diff] [blame] | 97 | return SettingsEnums.ENCRYPTION; |
Chris Wren | 8a963ba | 2015-03-20 10:29:14 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | @Override |
Maurice Lam | 9be96e0 | 2017-02-23 14:43:48 -0800 | [diff] [blame] | 101 | public View onCreateView( |
| 102 | LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
| 103 | return inflater.inflate(R.layout.encryption_interstitial, container, false); |
| 104 | } |
Maurice Lam | 7e83103 | 2015-07-20 16:08:38 -0700 | [diff] [blame] | 105 | |
Maurice Lam | 9be96e0 | 2017-02-23 14:43:48 -0800 | [diff] [blame] | 106 | @Override |
| 107 | public void onViewCreated(View view, Bundle savedInstanceState) { |
| 108 | super.onViewCreated(view, savedInstanceState); |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 109 | |
Kevin Chyn | 81dc029 | 2018-06-28 14:59:38 -0700 | [diff] [blame] | 110 | final boolean forFingerprint = getActivity().getIntent().getBooleanExtra( |
Maurice Lam | c0e7879 | 2015-07-20 14:49:29 -0700 | [diff] [blame] | 111 | ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false); |
Kevin Chyn | 81dc029 | 2018-06-28 14:59:38 -0700 | [diff] [blame] | 112 | final boolean forFace = getActivity().getIntent() |
| 113 | .getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false); |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 114 | Intent intent = getActivity().getIntent(); |
Maurice Lam | 8890f7a | 2016-05-12 16:24:41 -0700 | [diff] [blame] | 115 | mRequestedPasswordQuality = intent.getIntExtra(EXTRA_PASSWORD_QUALITY, 0); |
| 116 | mUnlockMethodIntent = intent.getParcelableExtra(EXTRA_UNLOCK_METHOD_INTENT); |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 117 | final int msgId; |
Maurice Lam | 8890f7a | 2016-05-12 16:24:41 -0700 | [diff] [blame] | 118 | switch (mRequestedPasswordQuality) { |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 119 | case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: |
Maurice Lam | c0e7879 | 2015-07-20 14:49:29 -0700 | [diff] [blame] | 120 | msgId = forFingerprint ? |
| 121 | R.string.encryption_interstitial_message_pattern_for_fingerprint : |
Kevin Chyn | 81dc029 | 2018-06-28 14:59:38 -0700 | [diff] [blame] | 122 | forFace ? |
| 123 | R.string.encryption_interstitial_message_pattern_for_face : |
Maurice Lam | c0e7879 | 2015-07-20 14:49:29 -0700 | [diff] [blame] | 124 | R.string.encryption_interstitial_message_pattern; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 125 | break; |
| 126 | case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: |
| 127 | case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: |
Maurice Lam | c0e7879 | 2015-07-20 14:49:29 -0700 | [diff] [blame] | 128 | msgId = forFingerprint ? |
| 129 | R.string.encryption_interstitial_message_pin_for_fingerprint : |
Kevin Chyn | 81dc029 | 2018-06-28 14:59:38 -0700 | [diff] [blame] | 130 | forFace ? |
| 131 | R.string.encryption_interstitial_message_pin_for_face : |
Maurice Lam | c0e7879 | 2015-07-20 14:49:29 -0700 | [diff] [blame] | 132 | R.string.encryption_interstitial_message_pin; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 133 | break; |
| 134 | default: |
Maurice Lam | c0e7879 | 2015-07-20 14:49:29 -0700 | [diff] [blame] | 135 | msgId = forFingerprint ? |
| 136 | R.string.encryption_interstitial_message_password_for_fingerprint : |
Kevin Chyn | 81dc029 | 2018-06-28 14:59:38 -0700 | [diff] [blame] | 137 | forFace ? |
| 138 | R.string.encryption_interstitial_message_password_for_face : |
Maurice Lam | c0e7879 | 2015-07-20 14:49:29 -0700 | [diff] [blame] | 139 | R.string.encryption_interstitial_message_password; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 140 | break; |
| 141 | } |
pastychang | fa68ec4 | 2019-04-12 16:22:17 +0800 | [diff] [blame] | 142 | TextView message = (TextView) getActivity().findViewById(R.id.sud_layout_description); |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 143 | message.setText(msgId); |
Jim Miller | 0698a21 | 2014-10-16 19:49:07 -0700 | [diff] [blame] | 144 | |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 145 | setRequirePasswordState(getActivity().getIntent().getBooleanExtra( |
| 146 | EXTRA_REQUIRE_PASSWORD, true)); |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 147 | |
Maurice Lam | 9be96e0 | 2017-02-23 14:43:48 -0800 | [diff] [blame] | 148 | GlifLayout layout = (GlifLayout) view; |
Maurice Lam | d189ac5 | 2016-06-15 13:39:34 -0700 | [diff] [blame] | 149 | layout.setHeaderText(getActivity().getTitle()); |
pastychang | 5dfdb4f | 2018-12-17 14:50:27 +0800 | [diff] [blame] | 150 | |
pastychang | 9bdb59a | 2019-01-21 09:49:15 +0800 | [diff] [blame] | 151 | final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class); |
| 152 | mixin.setSecondaryButton( |
pastychang | 908501e | 2018-12-26 10:46:40 +0800 | [diff] [blame] | 153 | new FooterButton.Builder(getContext()) |
| 154 | .setText(R.string.encryption_interstitial_no) |
| 155 | .setListener(this::onNoButtonClicked) |
| 156 | .setButtonType(FooterButton.ButtonType.SKIP) |
pastychang | 7961482 | 2019-01-03 10:12:54 +0800 | [diff] [blame] | 157 | .setTheme(R.style.SudGlifButton_Secondary) |
pastychang | 908501e | 2018-12-26 10:46:40 +0800 | [diff] [blame] | 158 | .build() |
pastychang | 5dfdb4f | 2018-12-17 14:50:27 +0800 | [diff] [blame] | 159 | ); |
| 160 | |
pastychang | 9bdb59a | 2019-01-21 09:49:15 +0800 | [diff] [blame] | 161 | mixin.setPrimaryButton( |
pastychang | 908501e | 2018-12-26 10:46:40 +0800 | [diff] [blame] | 162 | new FooterButton.Builder(getContext()) |
| 163 | .setText(R.string.encryption_interstitial_yes) |
| 164 | .setListener(this::onYesButtonClicked) |
| 165 | .setButtonType(FooterButton.ButtonType.NEXT) |
pastychang | 7961482 | 2019-01-03 10:12:54 +0800 | [diff] [blame] | 166 | .setTheme(R.style.SudGlifButton_Primary) |
pastychang | 908501e | 2018-12-26 10:46:40 +0800 | [diff] [blame] | 167 | .build() |
pastychang | 5dfdb4f | 2018-12-17 14:50:27 +0800 | [diff] [blame] | 168 | ); |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | protected void startLockIntent() { |
| 172 | if (mUnlockMethodIntent != null) { |
| 173 | mUnlockMethodIntent.putExtra(EXTRA_REQUIRE_PASSWORD, mPasswordRequired); |
| 174 | startActivityForResult(mUnlockMethodIntent, CHOOSE_LOCK_REQUEST); |
| 175 | } else { |
| 176 | Log.wtf(TAG, "no unlock intent to start"); |
| 177 | finish(); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | @Override |
| 182 | public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 183 | super.onActivityResult(requestCode, resultCode, data); |
Maurice Lam | e9d2abc | 2015-12-14 18:03:54 -0800 | [diff] [blame] | 184 | if (requestCode == CHOOSE_LOCK_REQUEST && resultCode != RESULT_CANCELED) { |
| 185 | getActivity().setResult(resultCode, data); |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 186 | finish(); |
| 187 | } |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 188 | } |
| 189 | |
pastychang | 5dfdb4f | 2018-12-17 14:50:27 +0800 | [diff] [blame] | 190 | private void onYesButtonClicked(View view) { |
| 191 | final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled(); |
| 192 | if (accEn && !mPasswordRequired) { |
| 193 | setRequirePasswordState(false); // clear the UI state |
| 194 | AccessibilityWarningDialogFragment.newInstance(mRequestedPasswordQuality) |
| 195 | .show( |
| 196 | getChildFragmentManager(), |
| 197 | AccessibilityWarningDialogFragment.TAG); |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 198 | } else { |
pastychang | 5dfdb4f | 2018-12-17 14:50:27 +0800 | [diff] [blame] | 199 | setRequirePasswordState(true); |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 200 | startLockIntent(); |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 201 | } |
Jim Miller | 0698a21 | 2014-10-16 19:49:07 -0700 | [diff] [blame] | 202 | } |
| 203 | |
pastychang | 5dfdb4f | 2018-12-17 14:50:27 +0800 | [diff] [blame] | 204 | private void onNoButtonClicked(View view) { |
| 205 | setRequirePasswordState(false); |
| 206 | startLockIntent(); |
| 207 | } |
| 208 | |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 209 | private void setRequirePasswordState(boolean required) { |
| 210 | mPasswordRequired = required; |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 211 | } |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 212 | |
Maurice Lam | 18d7965 | 2017-03-21 17:57:55 -0700 | [diff] [blame] | 213 | public void finish() { |
| 214 | Activity activity = getActivity(); |
| 215 | if (activity == null) return; |
| 216 | if (getFragmentManager().getBackStackEntryCount() > 0) { |
| 217 | getFragmentManager().popBackStack(); |
| 218 | } else { |
| 219 | activity.finish(); |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | public static class AccessibilityWarningDialogFragment extends InstrumentedDialogFragment |
| 225 | implements DialogInterface.OnClickListener { |
| 226 | |
| 227 | public static final String TAG = "AccessibilityWarningDialog"; |
| 228 | |
| 229 | public static AccessibilityWarningDialogFragment newInstance(int passwordQuality) { |
| 230 | AccessibilityWarningDialogFragment fragment = new AccessibilityWarningDialogFragment(); |
| 231 | Bundle args = new Bundle(1); |
| 232 | args.putInt(EXTRA_PASSWORD_QUALITY, passwordQuality); |
| 233 | fragment.setArguments(args); |
| 234 | return fragment; |
| 235 | } |
| 236 | |
| 237 | @Override |
| 238 | public Dialog onCreateDialog(Bundle savedInstanceState) { |
| 239 | final int titleId; |
| 240 | final int messageId; |
| 241 | switch (getArguments().getInt(EXTRA_PASSWORD_QUALITY)) { |
| 242 | case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: |
| 243 | titleId = R.string.encrypt_talkback_dialog_require_pattern; |
| 244 | messageId = R.string.encrypt_talkback_dialog_message_pattern; |
| 245 | break; |
| 246 | case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: |
| 247 | case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: |
| 248 | titleId = R.string.encrypt_talkback_dialog_require_pin; |
| 249 | messageId = R.string.encrypt_talkback_dialog_message_pin; |
| 250 | break; |
| 251 | default: |
| 252 | titleId = R.string.encrypt_talkback_dialog_require_password; |
| 253 | messageId = R.string.encrypt_talkback_dialog_message_password; |
| 254 | break; |
| 255 | } |
| 256 | |
| 257 | |
| 258 | final Activity activity = getActivity(); |
| 259 | List<AccessibilityServiceInfo> list = |
| 260 | AccessibilityManager.getInstance(activity) |
| 261 | .getEnabledAccessibilityServiceList( |
| 262 | AccessibilityServiceInfo.FEEDBACK_ALL_MASK); |
| 263 | final CharSequence exampleAccessibility; |
| 264 | if (list.isEmpty()) { |
| 265 | // This should never happen. But we shouldn't crash |
| 266 | exampleAccessibility = ""; |
| 267 | } else { |
| 268 | exampleAccessibility = list.get(0).getResolveInfo() |
| 269 | .loadLabel(activity.getPackageManager()); |
| 270 | } |
| 271 | return new AlertDialog.Builder(activity) |
| 272 | .setTitle(titleId) |
| 273 | .setMessage(getString(messageId, exampleAccessibility)) |
| 274 | .setCancelable(true) |
| 275 | .setPositiveButton(android.R.string.ok, this) |
| 276 | .setNegativeButton(android.R.string.cancel, this) |
| 277 | .create(); |
| 278 | } |
| 279 | |
| 280 | @Override |
| 281 | public int getMetricsCategory() { |
Fan Zhang | 31b2100 | 2019-01-16 13:49:47 -0800 | [diff] [blame] | 282 | return SettingsEnums.DIALOG_ENCRYPTION_INTERSTITIAL_ACCESSIBILITY; |
Maurice Lam | 18d7965 | 2017-03-21 17:57:55 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 285 | @Override |
| 286 | public void onClick(DialogInterface dialog, int which) { |
Maurice Lam | 18d7965 | 2017-03-21 17:57:55 -0700 | [diff] [blame] | 287 | EncryptionInterstitialFragment fragment = |
| 288 | (EncryptionInterstitialFragment) getParentFragment(); |
| 289 | if (fragment != null) { |
| 290 | if (which == DialogInterface.BUTTON_POSITIVE) { |
| 291 | fragment.setRequirePasswordState(true); |
| 292 | fragment.startLockIntent(); |
| 293 | } else if (which == DialogInterface.BUTTON_NEGATIVE) { |
| 294 | fragment.setRequirePasswordState(false); |
| 295 | } |
Jim Miller | 47adff0 | 2014-10-17 17:43:18 -0700 | [diff] [blame] | 296 | } |
| 297 | } |
Jim Miller | 46c7f6d | 2014-10-13 18:15:17 -0700 | [diff] [blame] | 298 | } |
| 299 | } |