1ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam/*
2ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * Copyright (C) 2014 The Android Open Source Project
3ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam *
4ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * Licensed under the Apache License, Version 2.0 (the "License");
5ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * you may not use this file except in compliance with the License.
6ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * You may obtain a copy of the License at
7ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam *
8ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam *      http://www.apache.org/licenses/LICENSE-2.0
9ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam *
10ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * Unless required by applicable law or agreed to in writing, software
11ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * distributed under the License is distributed on an "AS IS" BASIS,
12ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * See the License for the specific language governing permissions and
14ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * limitations under the License
15ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam */
16ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
17ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lampackage com.android.settings;
18ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
19ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lamimport android.content.Context;
20ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lamimport android.content.Intent;
21ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lamimport android.content.res.Resources;
22ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lamimport android.os.Bundle;
23d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Sainiimport android.support.v7.widget.RecyclerView;
24ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lamimport android.view.LayoutInflater;
25ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lamimport android.view.View;
26ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lamimport android.view.ViewGroup;
2771fde52ae36f134e93835bee53bc4bfe5481bba0Udam Sainiimport android.widget.LinearLayout;
28ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
29cf19ef7596b2e425a4f94c947eb8806753d427bcMaurice Lamimport com.android.settings.utils.SettingsDividerItemDecoration;
30190ec1c14acbe305ac38d7d584a66ea57b7392faMaurice Lamimport com.android.setupwizardlib.GlifPreferenceLayout;
3139b467482d1bf256a111c757e9b7621c6f523271Jason Monk
32ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam/**
33ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * Setup Wizard's version of EncryptionInterstitial screen. It inherits the logic and basic
34ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * structure from EncryptionInterstitial class, and should remain similar to that behaviorally. This
35ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * class should only overload base methods for minor theme and behavior differences specific to
36ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * Setup Wizard. Other changes should be done to EncryptionInterstitial class instead and let this
37ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam * class inherit those changes.
38ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam */
3983301b5256e3fd930d620e8e9ad5f43cd388ba09Maurice Lampublic class SetupEncryptionInterstitial extends EncryptionInterstitial {
40ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
41ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    public static Intent createStartIntent(Context ctx, int quality,
42edac136e162d3935ea1ccedf6c630eff4c591d7eUdam Saini            boolean requirePasswordDefault, Intent unlockMethodIntent) {
43ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        Intent startIntent = EncryptionInterstitial.createStartIntent(ctx, quality,
44edac136e162d3935ea1ccedf6c630eff4c591d7eUdam Saini                requirePasswordDefault, unlockMethodIntent);
45ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        startIntent.setClass(ctx, SetupEncryptionInterstitial.class);
46ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)
47ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam                .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
48ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        return startIntent;
49ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    }
50ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
51ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    @Override
52ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    public Intent getIntent() {
53ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        Intent modIntent = new Intent(super.getIntent());
54ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
55ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam                SetupEncryptionInterstitialFragment.class.getName());
56ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        return modIntent;
57ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    }
58ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
59ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    @Override
60ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    protected boolean isValidFragment(String fragmentName) {
61ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
62ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    }
63ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
64ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    @Override
65ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
66598be1eab6b6aa76033acb8534330731962e986aMaurice Lam        resid = SetupWizardUtils.getTheme(getIntent());
67ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        super.onApplyThemeResource(theme, resid, first);
68ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    }
69ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
7071fde52ae36f134e93835bee53bc4bfe5481bba0Udam Saini    @Override
7171fde52ae36f134e93835bee53bc4bfe5481bba0Udam Saini    protected void onCreate(Bundle savedInstance) {
7271fde52ae36f134e93835bee53bc4bfe5481bba0Udam Saini        super.onCreate(savedInstance);
7371fde52ae36f134e93835bee53bc4bfe5481bba0Udam Saini        LinearLayout layout = (LinearLayout) findViewById(R.id.content_parent);
7471fde52ae36f134e93835bee53bc4bfe5481bba0Udam Saini        layout.setFitsSystemWindows(false);
7571fde52ae36f134e93835bee53bc4bfe5481bba0Udam Saini    }
7671fde52ae36f134e93835bee53bc4bfe5481bba0Udam Saini
77190ec1c14acbe305ac38d7d584a66ea57b7392faMaurice Lam    public static class SetupEncryptionInterstitialFragment extends EncryptionInterstitialFragment {
78ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam
79ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        @Override
807e831030201fcac9ca0acc9684497dc44cea7023Maurice Lam        public void onViewCreated(View view, Bundle savedInstanceState) {
817e831030201fcac9ca0acc9684497dc44cea7023Maurice Lam            super.onViewCreated(view, savedInstanceState);
827e831030201fcac9ca0acc9684497dc44cea7023Maurice Lam
83190ec1c14acbe305ac38d7d584a66ea57b7392faMaurice Lam            final GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
84cf19ef7596b2e425a4f94c947eb8806753d427bcMaurice Lam            layout.setDividerItemDecoration(new SettingsDividerItemDecoration(getContext()));
85d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini            layout.setDividerInset(getContext().getResources().getDimensionPixelSize(
86190ec1c14acbe305ac38d7d584a66ea57b7392faMaurice Lam                    R.dimen.suw_items_glif_icon_divider_inset));
87190ec1c14acbe305ac38d7d584a66ea57b7392faMaurice Lam            layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
8883301b5256e3fd930d620e8e9ad5f43cd388ba09Maurice Lam
89d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini            layout.setHeaderText(R.string.encryption_interstitial_header);
90d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini
91d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini            // Use the dividers in SetupWizardRecyclerLayout. Suppress the dividers in
92d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini            // PreferenceFragment.
93d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini            setDivider(null);
94d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini        }
95d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini
96d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini        @Override
97d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini        public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
98d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini                                                 Bundle savedInstanceState) {
99190ec1c14acbe305ac38d7d584a66ea57b7392faMaurice Lam            GlifPreferenceLayout layout = (GlifPreferenceLayout) parent;
100d553abcb4cd4ee3682ae4e864c06514d65fcb253Udam Saini            return layout.onCreateRecyclerView(inflater, parent, savedInstanceState);
101ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam        }
102ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam    }
103ecd2b7b81fd2faa2f2f3dbe5a169c749321f3d89Maurice Lam}
104