Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [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 | |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 19 | import android.content.Context; |
| 20 | import android.content.Intent; |
| 21 | import android.content.res.Resources; |
| 22 | import android.os.Bundle; |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 23 | import android.support.v7.widget.RecyclerView; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 24 | import android.view.LayoutInflater; |
| 25 | import android.view.View; |
| 26 | import android.view.ViewGroup; |
Udam Saini | 71fde52 | 2016-03-30 13:38:05 -0700 | [diff] [blame] | 27 | import android.widget.LinearLayout; |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 28 | import android.widget.TextView; |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 29 | |
Maurice Lam | 190ec1c | 2016-04-22 16:41:18 -0700 | [diff] [blame^] | 30 | import com.android.setupwizardlib.GlifPreferenceLayout; |
Jason Monk | 39b4674 | 2015-09-10 15:52:51 -0400 | [diff] [blame] | 31 | |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 32 | /** |
| 33 | * Setup Wizard's version of EncryptionInterstitial screen. It inherits the logic and basic |
| 34 | * structure from EncryptionInterstitial class, and should remain similar to that behaviorally. This |
| 35 | * class should only overload base methods for minor theme and behavior differences specific to |
| 36 | * Setup Wizard. Other changes should be done to EncryptionInterstitial class instead and let this |
| 37 | * class inherit those changes. |
| 38 | */ |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 39 | public class SetupEncryptionInterstitial extends EncryptionInterstitial { |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 40 | |
| 41 | public static Intent createStartIntent(Context ctx, int quality, |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 42 | boolean requirePasswordDefault, Intent unlockMethodIntent) { |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 43 | Intent startIntent = EncryptionInterstitial.createStartIntent(ctx, quality, |
Udam Saini | edac136 | 2015-12-08 17:28:19 -0800 | [diff] [blame] | 44 | requirePasswordDefault, unlockMethodIntent); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 45 | startIntent.setClass(ctx, SetupEncryptionInterstitial.class); |
| 46 | startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false) |
| 47 | .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1); |
| 48 | return startIntent; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Intent getIntent() { |
| 53 | Intent modIntent = new Intent(super.getIntent()); |
| 54 | modIntent.putExtra(EXTRA_SHOW_FRAGMENT, |
| 55 | SetupEncryptionInterstitialFragment.class.getName()); |
| 56 | return modIntent; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | protected boolean isValidFragment(String fragmentName) { |
| 61 | return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) { |
Maurice Lam | 598be1e | 2015-04-08 21:13:42 -0700 | [diff] [blame] | 66 | resid = SetupWizardUtils.getTheme(getIntent()); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 67 | super.onApplyThemeResource(theme, resid, first); |
| 68 | } |
| 69 | |
Udam Saini | 71fde52 | 2016-03-30 13:38:05 -0700 | [diff] [blame] | 70 | @Override |
| 71 | protected void onCreate(Bundle savedInstance) { |
| 72 | super.onCreate(savedInstance); |
| 73 | LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent); |
| 74 | layout.setFitsSystemWindows(false); |
| 75 | } |
| 76 | |
Maurice Lam | 190ec1c | 2016-04-22 16:41:18 -0700 | [diff] [blame^] | 77 | public static class SetupEncryptionInterstitialFragment extends EncryptionInterstitialFragment { |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 78 | |
| 79 | @Override |
Maurice Lam | 7e83103 | 2015-07-20 16:08:38 -0700 | [diff] [blame] | 80 | public void onViewCreated(View view, Bundle savedInstanceState) { |
| 81 | super.onViewCreated(view, savedInstanceState); |
| 82 | |
Maurice Lam | 190ec1c | 2016-04-22 16:41:18 -0700 | [diff] [blame^] | 83 | final GlifPreferenceLayout layout = (GlifPreferenceLayout) view; |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 84 | layout.setDividerInset(getContext().getResources().getDimensionPixelSize( |
Maurice Lam | 190ec1c | 2016-04-22 16:41:18 -0700 | [diff] [blame^] | 85 | R.dimen.suw_items_glif_icon_divider_inset)); |
| 86 | layout.setIcon(getContext().getDrawable(R.drawable.ic_lock)); |
Maurice Lam | 83301b5 | 2015-04-18 20:11:59 -0700 | [diff] [blame] | 87 | |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 88 | layout.setHeaderText(R.string.encryption_interstitial_header); |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 89 | |
| 90 | // Use the dividers in SetupWizardRecyclerLayout. Suppress the dividers in |
| 91 | // PreferenceFragment. |
| 92 | setDivider(null); |
| 93 | } |
| 94 | |
| 95 | @Override |
| 96 | protected TextView createHeaderView() { |
| 97 | TextView message = (TextView) LayoutInflater.from(getActivity()).inflate( |
| 98 | R.layout.setup_encryption_interstitial_header, null, false); |
| 99 | return message; |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent, |
| 104 | Bundle savedInstanceState) { |
Maurice Lam | 190ec1c | 2016-04-22 16:41:18 -0700 | [diff] [blame^] | 105 | GlifPreferenceLayout layout = (GlifPreferenceLayout) parent; |
Udam Saini | d553abc | 2016-02-16 17:54:13 -0800 | [diff] [blame] | 106 | return layout.onCreateRecyclerView(inflater, parent, savedInstanceState); |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 107 | } |
Maurice Lam | ecd2b7b | 2014-12-01 10:41:49 -0800 | [diff] [blame] | 108 | } |
| 109 | } |