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 } 50 51 @Override onSaveInstanceState(Bundle savedState)52 protected void onSaveInstanceState(Bundle savedState) { 53 savedState.putCharSequence(SAVE_KEY_TITLE, getTitle()); 54 super.onSaveInstanceState(savedState); 55 } 56 57 @Override onRestoreInstanceState(Bundle savedState)58 protected void onRestoreInstanceState(Bundle savedState) { 59 super.onRestoreInstanceState(savedState); 60 setTitle(savedState.getCharSequence(SAVE_KEY_TITLE)); 61 } 62 63 @Override onResume()64 public void onResume() { 65 super.onResume(); 66 mSendExtraWindowStateChanged = false; 67 } 68 69 @Override onCreateOptionsMenu(Menu menu)70 public boolean onCreateOptionsMenu(Menu menu) { 71 // Return true, so we get notified when items in the menu are clicked. 72 return true; 73 } 74 75 @Override onNavigateUp()76 public boolean onNavigateUp() { 77 onBackPressed(); 78 79 // Clear accessibility focus and let the screen reader announce the new title. 80 getWindow().getDecorView() 81 .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); 82 83 return true; 84 } 85 86 @Override startPreferencePanel(Fragment caller, String fragmentClass, Bundle args, int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode)87 public void startPreferencePanel(Fragment caller, String fragmentClass, Bundle args, 88 int titleRes, CharSequence titleText, Fragment resultTo, int resultRequestCode) { 89 // Set the title. 90 if (!TextUtils.isEmpty(titleText)) { 91 setTitle(titleText); 92 } else if (titleRes > 0) { 93 setTitle(getString(titleRes)); 94 } 95 96 // Start the new Fragment. 97 args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0); 98 startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true); 99 mSendExtraWindowStateChanged = true; 100 } 101 102 @Override onAttachFragment(Fragment fragment)103 public void onAttachFragment(Fragment fragment) { 104 if (mSendExtraWindowStateChanged) { 105 // Clear accessibility focus and let the screen reader announce the new title. 106 getWindow().getDecorView() 107 .sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); 108 } 109 } 110 } 111