Talkback improvements for Settings screens.

Bug: 21164141
Change-Id: I7444261ccf967f6db70c9fe44a00bd3f19ceb975
This commit is contained in:
Julia Reynolds
2015-07-08 16:56:31 -04:00
parent 64e1e15d10
commit ce25af4838
12 changed files with 139 additions and 3 deletions

View File

@@ -27,7 +27,8 @@
android:layout_marginEnd="12dp" android:layout_marginEnd="12dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_weight="1"> android:layout_weight="1">
<LinearLayout android:layout_width="match_parent" <LinearLayout android:id="@+id/master_clear_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView

View File

@@ -20,6 +20,7 @@
> >
<TextView <TextView
android:id="@+id/master_clear_confirm"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"

View File

@@ -1921,6 +1921,14 @@
<string name="category_personal">Personal</string> <string name="category_personal">Personal</string>
<!-- Header for items under the work user [CHAR LIMIT=30] --> <!-- Header for items under the work user [CHAR LIMIT=30] -->
<string name="category_work">Work</string> <string name="category_work">Work</string>
<!-- Content description for work profile accounts group [CHAR LIMIT=NONE] -->
<string name="accessibility_category_work">Work profile accounts - <xliff:g id="managed_by" example="Managed by Corporate application">%s</xliff:g></string>
<!-- Content description for personal profile accounts group [CHAR LIMIT=NONE] -->
<string name="accessibility_category_personal">Personal profile accounts</string>
<!-- Content description for work profile details page title [CHAR LIMIT=NONE] -->
<string name="accessibility_work_account_title">Work account - <xliff:g id="managed_by" example="Email provider">%s</xliff:g></string>
<!-- Content description for personal profile details page title [CHAR LIMIT=NONE] -->
<string name="accessibility_personal_account_title">Personal account - <xliff:g id="managed_by" example="Email provider">%s</xliff:g></string>
<!-- Main Settings screen, setting option name to go into search settings --> <!-- Main Settings screen, setting option name to go into search settings -->
<string name="search_settings">Search</string> <string name="search_settings">Search</string>

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings;
import android.content.Context;
import android.preference.PreferenceCategory;
import android.view.View;
/**
* Preference category that accepts a content description for accessibility.
*/
public class AccessiblePreferenceCategory extends PreferenceCategory {
private String mContentDescription;
public AccessiblePreferenceCategory(Context context) {
super(context);
}
public void setContentDescription(String contentDescription) {
mContentDescription = contentDescription;
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
view.setContentDescription(mContentDescription);
}
}

View File

@@ -17,6 +17,7 @@
package com.android.settings; package com.android.settings;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@@ -82,6 +83,17 @@ public abstract class ConfirmDeviceCredentialBaseFragment extends InstrumentedFr
} }
} }
protected void setAccessibilityTitle(CharSequence suplementalText) {
Intent intent = getActivity().getIntent();
if (intent != null) {
CharSequence titleText = intent.getCharSequenceExtra(
ConfirmDeviceCredentialBaseFragment.TITLE_TEXT);
String accessibilityTitle =
new StringBuilder(titleText).append(",").append(suplementalText).toString();
getActivity().setTitle(Utils.createAccessibleSequence(titleText, accessibilityTitle));
}
}
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();

View File

@@ -161,6 +161,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
110, 1f /* translationScale */, 110, 1f /* translationScale */,
0.5f /* delayScale */, AnimationUtils.loadInterpolator( 0.5f /* delayScale */, AnimationUtils.loadInterpolator(
getContext(), android.R.interpolator.fast_out_linear_in)); getContext(), android.R.interpolator.fast_out_linear_in));
setAccessibilityTitle(mHeaderTextView.getText());
return view; return view;
} }

View File

@@ -178,6 +178,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
return (float)(numRows - row) / numRows; return (float)(numRows - row) / numRows;
} }
}); });
setAccessibilityTitle(mHeaderTextView.getText());
return view; return view;
} }

View File

@@ -168,6 +168,24 @@ public class MasterClear extends InstrumentedFragment {
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
loadAccountList(um); loadAccountList(um);
StringBuffer contentDescription = new StringBuffer();
View masterClearContainer = mContentView.findViewById(R.id.master_clear_container);
getContentDescription(masterClearContainer, contentDescription);
masterClearContainer.setContentDescription(contentDescription);
}
private void getContentDescription(View v, StringBuffer description) {
if (v instanceof ViewGroup) {
ViewGroup vGroup = (ViewGroup) v;
for (int i = 0; i < vGroup.getChildCount(); i++) {
View nextChild = vGroup.getChildAt(i);
getContentDescription(nextChild, description);
}
} else if (v instanceof TextView) {
TextView vText = (TextView) v;
description.append(vText.getText());
description.append(","); // Allow Talkback to pause between sections.
}
} }
private boolean isExtStorageEncrypted() { private boolean isExtStorageEncrypted() {

View File

@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.service.persistentdata.PersistentDataBlockManager; import android.service.persistentdata.PersistentDataBlockManager;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import android.content.Intent; import android.content.Intent;
@@ -30,6 +31,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView;
/** /**
* Confirm and execute a reset of the device to a clean "just out of the box" * Confirm and execute a reset of the device to a clean "just out of the box"
@@ -134,9 +136,21 @@ public class MasterClearConfirm extends InstrumentedFragment {
} }
mContentView = inflater.inflate(R.layout.master_clear_confirm, null); mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
establishFinalConfirmationState(); establishFinalConfirmationState();
setAccessibilityTitle();
return mContentView; return mContentView;
} }
private void setAccessibilityTitle() {
CharSequence currentTitle = getActivity().getTitle();
TextView confirmationMessage =
(TextView) mContentView.findViewById(R.id.master_clear_confirm);
if (confirmationMessage != null) {
String accessibileText = new StringBuilder(currentTitle).append(",").append(
confirmationMessage.getText()).toString();
getActivity().setTitle(Utils.createAccessibleSequence(currentTitle, accessibileText));
}
}
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);

View File

@@ -70,7 +70,10 @@ import android.provider.ContactsContract.Profile;
import android.provider.ContactsContract.RawContacts; import android.provider.ContactsContract.RawContacts;
import android.service.persistentdata.PersistentDataBlockManager; import android.service.persistentdata.PersistentDataBlockManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.TtsSpan;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
@@ -1217,4 +1220,18 @@ public final class Utils {
return false; return false;
} }
} }
/**
* Returns an accessible SpannableString.
* @param displayText the text to display
* @param accessibileText the text text-to-speech engines should read
*/
public static SpannableString createAccessibleSequence(CharSequence displayText,
String accessibileText) {
SpannableString str = new SpannableString(displayText);
str.setSpan(new TtsSpan.TextBuilder(accessibileText).build(), 0,
displayText.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return str;
}
} }

View File

@@ -49,6 +49,7 @@ import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.settings.AccessiblePreferenceCategory;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils; import com.android.settings.Utils;
@@ -270,14 +271,19 @@ public class AccountSettings extends SettingsPreferenceFragment
final ProfileData profileData = new ProfileData(); final ProfileData profileData = new ProfileData();
profileData.userInfo = userInfo; profileData.userInfo = userInfo;
if (addCategory) { if (addCategory) {
profileData.preferenceGroup = new PreferenceCategory(context); profileData.preferenceGroup = new AccessiblePreferenceCategory(context);
if (userInfo.isManagedProfile()) { if (userInfo.isManagedProfile()) {
profileData.preferenceGroup.setLayoutResource(R.layout.work_profile_category); profileData.preferenceGroup.setLayoutResource(R.layout.work_profile_category);
profileData.preferenceGroup.setTitle(R.string.category_work); profileData.preferenceGroup.setTitle(R.string.category_work);
profileData.preferenceGroup.setSummary(getWorkGroupSummary(context, userInfo)); String workGroupSummary = getWorkGroupSummary(context, userInfo);
profileData.preferenceGroup.setSummary(workGroupSummary);
((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription(
getString(R.string.accessibility_category_work, workGroupSummary));
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context); profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
} else { } else {
profileData.preferenceGroup.setTitle(R.string.category_personal); profileData.preferenceGroup.setTitle(R.string.category_personal);
((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription(
getString(R.string.accessibility_category_personal));
} }
parent.addPreference(profileData.preferenceGroup); parent.addPreference(profileData.preferenceGroup);
} else { } else {

View File

@@ -35,6 +35,7 @@ import android.content.SyncAdapterType;
import android.content.SyncInfo; import android.content.SyncInfo;
import android.content.SyncStatusInfo; import android.content.SyncStatusInfo;
import android.content.pm.ProviderInfo; import android.content.pm.ProviderInfo;
import android.content.pm.UserInfo;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
@@ -151,6 +152,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
super.onCreate(icicle); super.onCreate(icicle);
setPreferenceScreen(null); setPreferenceScreen(null);
addPreferencesFromResource(R.xml.account_sync_settings); addPreferencesFromResource(R.xml.account_sync_settings);
setAccessibilityTitle();
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@@ -200,6 +202,18 @@ public class AccountSyncSettings extends AccountPreferenceBase {
mProviderId.setText(mAccount.type); mProviderId.setText(mAccount.type);
} }
private void setAccessibilityTitle() {
final UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
UserInfo user = um.getUserInfo(mUserHandle.getIdentifier());
boolean isWorkProfile = user != null ? user.isManagedProfile() : false;
CharSequence currentTitle = getActivity().getTitle();
String accessibilityTitle =
getString(isWorkProfile
? R.string.accessibility_work_account_title
: R.string.accessibility_personal_account_title, currentTitle);
getActivity().setTitle(Utils.createAccessibleSequence(currentTitle, accessibilityTitle));
}
@Override @Override
public void onResume() { public void onResume() {
removePreference("dummy"); removePreference("dummy");