android:layout_marginEnd="12dp"
android:layout_marginTop="12dp"
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:orientation="vertical">
<TextView
>
<TextView
+ android:id="@+id/master_clear_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
<string name="category_personal">Personal</string>
<!-- Header for items under the work user [CHAR LIMIT=30] -->
<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 -->
<string name="search_settings">Search</string>
--- /dev/null
+/*
+ * 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);
+ }
+}
package com.android.settings;
import android.annotation.Nullable;
+import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
}
}
+ 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
public void onPause() {
super.onPause();
110, 1f /* translationScale */,
0.5f /* delayScale */, AnimationUtils.loadInterpolator(
getContext(), android.R.interpolator.fast_out_linear_in));
+ setAccessibilityTitle(mHeaderTextView.getText());
return view;
}
return (float)(numRows - row) / numRows;
}
});
+ setAccessibilityTitle(mHeaderTextView.getText());
return view;
}
final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
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() {
import android.content.pm.ActivityInfo;
import android.os.AsyncTask;
import android.service.persistentdata.PersistentDataBlockManager;
+
import com.android.internal.logging.MetricsLogger;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
+import android.widget.TextView;
/**
* Confirm and execute a reset of the device to a clean "just out of the box"
}
mContentView = inflater.inflate(R.layout.master_clear_confirm, null);
establishFinalConfirmationState();
+ setAccessibilityTitle();
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
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
import android.provider.ContactsContract.RawContacts;
import android.service.persistentdata.PersistentDataBlockManager;
import android.telephony.TelephonyManager;
+import android.text.Spannable;
+import android.text.SpannableString;
import android.text.TextUtils;
+import android.text.style.TtsSpan;
import android.util.ArraySet;
import android.util.Log;
import android.util.SparseArray;
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;
+ }
}
\ No newline at end of file
import android.preference.PreferenceScreen;
import com.android.internal.logging.MetricsLogger;
+import com.android.settings.AccessiblePreferenceCategory;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
final ProfileData profileData = new ProfileData();
profileData.userInfo = userInfo;
if (addCategory) {
- profileData.preferenceGroup = new PreferenceCategory(context);
+ profileData.preferenceGroup = new AccessiblePreferenceCategory(context);
if (userInfo.isManagedProfile()) {
profileData.preferenceGroup.setLayoutResource(R.layout.work_profile_category);
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);
} else {
profileData.preferenceGroup.setTitle(R.string.category_personal);
+ ((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription(
+ getString(R.string.accessibility_category_personal));
}
parent.addPreference(profileData.preferenceGroup);
} else {
import android.content.SyncInfo;
import android.content.SyncStatusInfo;
import android.content.pm.ProviderInfo;
+import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
super.onCreate(icicle);
setPreferenceScreen(null);
addPreferencesFromResource(R.xml.account_sync_settings);
+ setAccessibilityTitle();
setHasOptionsMenu(true);
}
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
public void onResume() {
removePreference("dummy");