Send Accessibility Events when Fragments change.
Bug: 27326723 Change-Id: Ia7684f7e27cdb69ad8302c9d5c37ccae6333fc92
This commit is contained in:
@@ -20,6 +20,7 @@ import android.app.Fragment;
|
|||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -31,6 +32,8 @@ import com.android.setupwizardlib.view.NavigationBar;
|
|||||||
|
|
||||||
public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
|
public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivity {
|
||||||
|
|
||||||
|
private boolean mSendExtraWindowStateChanged;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
@@ -58,6 +61,12 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
mSendExtraWindowStateChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Return true, so we get notified when items in the menu are clicked.
|
// Return true, so we get notified when items in the menu are clicked.
|
||||||
@@ -67,6 +76,11 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
|||||||
@Override
|
@Override
|
||||||
public boolean onNavigateUp() {
|
public boolean onNavigateUp() {
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
|
|
||||||
|
// Clear accessibility focus and let the screen reader announce the new title.
|
||||||
|
getWindow().getDecorView()
|
||||||
|
.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +97,16 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
|||||||
// Start the new Fragment.
|
// Start the new Fragment.
|
||||||
args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0);
|
args.putInt(SettingsPreferenceFragment.HELP_URI_RESOURCE_KEY, 0);
|
||||||
startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
|
startPreferenceFragment(Fragment.instantiate(this, fragmentClass, args), true);
|
||||||
|
mSendExtraWindowStateChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachFragment(Fragment fragment) {
|
||||||
|
if (mSendExtraWindowStateChanged) {
|
||||||
|
// Clear accessibility focus and let the screen reader announce the new title.
|
||||||
|
getWindow().getDecorView()
|
||||||
|
.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user