• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.accessibility;
18 
19 import android.app.Fragment;
20 import android.app.FragmentTransaction;
21 import android.os.Bundle;
22 import android.text.TextUtils;
23 import android.view.accessibility.AccessibilityEvent;
24 import android.view.LayoutInflater;
25 import android.view.Menu;
26 import android.view.View;
27 import android.view.WindowInsets;
28 import android.widget.FrameLayout;
29 import android.widget.LinearLayout;
30 
31 import com.android.settings.R;
32 import com.android.settings.SettingsActivity;
33 import com.android.settings.SettingsPreferenceFragment;
34 import com.android.setupwizardlib.util.SystemBarHelper;
35 import com.android.setupwizardlib.view.NavigationBar;
36 
37 public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
38 
39     private static final String SAVE_KEY_TITLE = "activity_title";
40 
41     private boolean mSendExtraWindowStateChanged;
42 
43     @Override
onCreate(Bundle savedState)44     protected void onCreate(Bundle savedState) {
45         super.onCreate(savedState);
46 
47         // Finish configuring the content view.
48         getActionBar().setDisplayHomeAsUpEnabled(true);
49         setIsDrawerPresent(false);
50     }
51 
52     @Override
onSaveInstanceState(Bundle savedState)53     protected void onSaveInstanceState(Bundle savedState) {
54         savedState.putCharSequence(SAVE_KEY_TITLE, getTitle());
55         super.onSaveInstanceState(savedState);
56     }
57 
58     @Override
onRestoreInstanceState(Bundle savedState)59     protected void onRestoreInstanceState(Bundle savedState) {
60         super.onRestoreInstanceState(savedState);
61         setTitle(savedState.getCharSequence(SAVE_KEY_TITLE));
62     }
63 
64     @Override
onResume()65     public void onResume() {
66         super.onResume();
67         mSendExtraWindowStateChanged = false;
68     }
69 
70     @Override
onCreateOptionsMenu(Menu menu)71     public boolean onCreateOptionsMenu(Menu menu) {
72         // Return true, so we get notified when items in the menu are clicked.
73         return true;
74     }
75 
76     @Override
onNavigateUp()77     public boolean onNavigateUp() {
78         onBackPressed();
79 
80         // Clear accessibility focus and let the screen reader announce the new title.
81         getWindow().getDecorView()
82                 .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
83 
84         return true;
85     }
86 
87     @Override
startPreferencePanel(String fragmentClass, Bundle args, int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode)88     public void startPreferencePanel(String fragmentClass, Bundle args, int titleRes,
89             CharSequence titleText, Fragment resultTo, int resultRequestCode) {
90         // Set the title.
91         if (!TextUtils.isEmpty(titleText)) {
92             setTitle(titleText);
93         } else if (titleRes > 0) {
94             setTitle(getString(titleRes));
95         }
96 
97         // Start the new Fragment.
98         args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0);
99         startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
100         mSendExtraWindowStateChanged = true;
101     }
102 
103     @Override
onAttachFragment(Fragment fragment)104     public void onAttachFragment(Fragment fragment) {
105         if (mSendExtraWindowStateChanged) {
106             // Clear accessibility focus and let the screen reader announce the new title.
107             getWindow().getDecorView()
108                     .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
109         }
110     }
111 }
112