2 * Copyright (C) 2014 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 package com.android.settings;
19 import com.android.setupwizardlib.SetupWizardLayout;
20 import com.android.setupwizardlib.view.NavigationBar;
22 import android.app.Activity;
23 import android.content.Context;
24 import android.content.Intent;
25 import android.content.res.Resources;
26 import android.os.Bundle;
27 import android.view.LayoutInflater;
28 import android.view.View;
29 import android.view.ViewGroup;
32 * Setup Wizard's version of EncryptionInterstitial screen. It inherits the logic and basic
33 * structure from EncryptionInterstitial class, and should remain similar to that behaviorally. This
34 * class should only overload base methods for minor theme and behavior differences specific to
35 * Setup Wizard. Other changes should be done to EncryptionInterstitial class instead and let this
36 * class inherit those changes.
38 public class SetupEncryptionInterstitial extends EncryptionInterstitial {
40 public static Intent createStartIntent(Context ctx, int quality,
41 boolean requirePasswordDefault) {
42 Intent startIntent = EncryptionInterstitial.createStartIntent(ctx, quality,
43 requirePasswordDefault);
44 startIntent.setClass(ctx, SetupEncryptionInterstitial.class);
45 startIntent.putExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)
46 .putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
51 public Intent getIntent() {
52 Intent modIntent = new Intent(super.getIntent());
53 modIntent.putExtra(EXTRA_SHOW_FRAGMENT,
54 SetupEncryptionInterstitialFragment.class.getName());
59 protected boolean isValidFragment(String fragmentName) {
60 return SetupEncryptionInterstitialFragment.class.getName().equals(fragmentName);
64 protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
65 resid = SetupWizardUtils.getTheme(getIntent());
66 super.onApplyThemeResource(theme, resid, first);
69 public static class SetupEncryptionInterstitialFragment extends EncryptionInterstitialFragment
70 implements NavigationBar.NavigationBarListener {
73 public View onCreateView(LayoutInflater inflater, ViewGroup container,
74 Bundle savedInstanceState) {
75 return inflater.inflate(R.layout.setup_encryption_interstitial, container, false);
79 public void onViewCreated(View view, Bundle savedInstanceState) {
80 super.onViewCreated(view, savedInstanceState);
82 final SetupWizardLayout layout =
83 (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout);
85 final NavigationBar navigationBar = layout.getNavigationBar();
86 navigationBar.setNavigationBarListener(this);
88 Activity activity = getActivity();
89 if (activity != null) {
90 activity.setTitle(R.string.encryption_interstitial_header);
91 SetupWizardUtils.setImmersiveMode(activity);
96 public void onNavigateBack() {
97 final Activity activity = getActivity();
98 if (activity != null) {
99 activity.onBackPressed();
104 public void onNavigateNext() {
105 final SetupEncryptionInterstitial activity =
106 (SetupEncryptionInterstitial) getActivity();
107 if (activity != null) {
108 activity.setResult(RESULT_OK, activity.getResultIntentData());