• 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.os.Bundle;
20 import android.support.v14.preference.PreferenceFragment;
21 import android.support.v7.preference.Preference;
22 import android.view.Menu;
23 import android.view.accessibility.AccessibilityEvent;
24 
25 import com.android.settings.SettingsActivity;
26 import com.android.settings.core.SubSettingLauncher;
27 import com.android.settings.search.actionbar.SearchMenuController;
28 import com.android.settings.support.actionbar.HelpResourceProvider;
29 import com.android.settingslib.core.instrumentation.Instrumentable;
30 
31 public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
32 
33     private static final String SAVE_KEY_TITLE = "activity_title";
34 
35     @Override
onCreate(Bundle savedState)36     protected void onCreate(Bundle savedState) {
37         super.onCreate(savedState);
38 
39         // Finish configuring the content view.
40         getActionBar().setDisplayHomeAsUpEnabled(true);
41     }
42 
43     @Override
onSaveInstanceState(Bundle savedState)44     protected void onSaveInstanceState(Bundle savedState) {
45         savedState.putCharSequence(SAVE_KEY_TITLE, getTitle());
46         super.onSaveInstanceState(savedState);
47     }
48 
49     @Override
onRestoreInstanceState(Bundle savedState)50     protected void onRestoreInstanceState(Bundle savedState) {
51         super.onRestoreInstanceState(savedState);
52         setTitle(savedState.getCharSequence(SAVE_KEY_TITLE));
53     }
54 
55     @Override
onCreateOptionsMenu(Menu menu)56     public boolean onCreateOptionsMenu(Menu menu) {
57         // Return true, so we get notified when items in the menu are clicked.
58         return true;
59     }
60 
61     @Override
onNavigateUp()62     public boolean onNavigateUp() {
63         onBackPressed();
64 
65         // Clear accessibility focus and let the screen reader announce the new title.
66         getWindow().getDecorView()
67                 .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
68 
69         return true;
70     }
71 
72     @Override
onPreferenceStartFragment(PreferenceFragment caller, Preference pref)73     public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) {
74         Bundle args = pref.getExtras();
75         if (args == null) {
76             args = new Bundle();
77         }
78         args.putInt(HelpResourceProvider.HELP_URI_RESOURCE_KEY, 0);
79         args.putBoolean(SearchMenuController.NEED_SEARCH_ICON_IN_ACTION_BAR, false);
80         new SubSettingLauncher(this)
81                 .setDestination(pref.getFragment())
82                 .setArguments(args)
83                 .setSourceMetricsCategory(caller instanceof Instrumentable
84                         ? ((Instrumentable) caller).getMetricsCategory()
85                         : Instrumentable.METRICS_CATEGORY_UNKNOWN)
86                 .launch();
87         return true;
88     }
89 }
90