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 17package com.android.settings.accessibility; 18 19import android.app.Fragment; 20import android.app.FragmentTransaction; 21import android.os.Bundle; 22import android.text.TextUtils; 23import android.view.accessibility.AccessibilityEvent; 24import android.view.LayoutInflater; 25import android.view.Menu; 26import android.view.View; 27import android.view.WindowInsets; 28import android.widget.FrameLayout; 29import android.widget.LinearLayout; 30 31import com.android.settings.R; 32import com.android.settings.SettingsActivity; 33import com.android.settings.SettingsPreferenceFragment; 34import com.android.setupwizardlib.util.SystemBarHelper; 35import com.android.setupwizardlib.view.NavigationBar; 36 37public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity { 38 39 private static final String SAVE_KEY_TITLE = "activity_title"; 40 41 private boolean mSendExtraWindowStateChanged; 42 43 @Override 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 52 protected void onSaveInstanceState(Bundle savedState) { 53 savedState.putCharSequence(SAVE_KEY_TITLE, getTitle()); 54 super.onSaveInstanceState(savedState); 55 } 56 57 @Override 58 protected void onRestoreInstanceState(Bundle savedState) { 59 super.onRestoreInstanceState(savedState); 60 setTitle(savedState.getCharSequence(SAVE_KEY_TITLE)); 61 } 62 63 @Override 64 public void onResume() { 65 super.onResume(); 66 mSendExtraWindowStateChanged = false; 67 } 68 69 @Override 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 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 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 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