List of usage examples for android.view View setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:Main.java
public static void setAccessibilityIgnore(View view) { view.setClickable(false);//from ww w . j av a 2 s . c om view.setFocusable(false); view.setContentDescription(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Alert animation in//from w w w . ja v a 2 s . co m * @param configuration describes all device configuration information * @param alertView View Resources to animate * @param textView alert message to be viewed * @param mainView ViewGroup resources * @param text message to be displayed */ private static void animIn(final Configuration configuration, final View alertView, TextView textView, final ViewGroup mainView, String text) { // Colors textView.setTextColor(configuration.getColorTextResId()); alertView.setBackgroundColor(configuration.getColorBackgroundResId()); // Content Description alertView.setContentDescription(configuration.getMessageType()); // Setting the text textView.setText(text); // Animation In if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { animViews(alertView, mainView, configuration, 0, configuration.getHeight(), true); } else { animViews(alertView, mainView, configuration, mainView.getHeight() - configuration.getHeight(), -configuration.getHeight(), true); } // Delayed animation out if (configuration.isCloseable()) { handler.postDelayed(new Runnable() { @Override public void run() { animOut(configuration, mainView, alertView); } }, configuration.getDuration()); } }
From source file:com.android.talkbacktests.testsession.RoleDescriptionTest.java
@Override public View getView(final LayoutInflater inflater, ViewGroup container, Context context) { View view = inflater.inflate(R.layout.test_role_description, container, false); AccessibilityDelegateCompat buttonDelegate = new AccessibilityDelegateCompat() { @Override//from ww w. ja v a 2 s . com public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) { super.onInitializeAccessibilityNodeInfo(host, info); info.setRoleDescription(getString(R.string.role_entry_point)); } }; View mailButton = view.findViewById(R.id.test_role_description_mailButton); mailButton.setContentDescription(getString(R.string.role_send_email)); ViewCompat.setAccessibilityDelegate(mailButton, buttonDelegate); View playButton = view.findViewById(R.id.test_role_description_playButton); playButton.setContentDescription(getString(R.string.role_send_email)); ViewCompat.setAccessibilityDelegate(playButton, buttonDelegate); View lockButton = view.findViewById(R.id.test_role_description_lockButton); lockButton.setContentDescription(getString(R.string.role_lock_screen)); ViewCompat.setAccessibilityDelegate(lockButton, buttonDelegate); return view; }
From source file:org.onebusaway.android.util.UIUtils.java
/** * Formats a view so it is ignored for accessible access *///from w w w . jav a 2s.c om public static void setAccessibilityIgnore(View view) { view.setClickable(false); view.setFocusable(false); view.setContentDescription(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } }
From source file:com.cytmxk.test.animation.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { View tabView;//from w w w . java2 s. co m if (mTabIcons != null && position < mTabIcons.length) { View iconView = new View(getContext()); iconView.setBackgroundResource(mTabIcons[position]); iconView.setContentDescription(tabTitle); tabView = iconView; } else { final TextView textView = new TextView(getContext()); textView.setText(tabTitle); textView.setBackgroundResource(R.drawable.view_pager_tab_background); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setGravity(Gravity.CENTER); tabView = textView; } tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); tabView.setOnLongClickListener(new OnTabLongClickListener(position)); tabView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(tabView, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; tabView.setSelected(true); } }
From source file:com.silentcircle.contacts.activities.ScContactDetailActivity.java
/** * Setup the activity title and subtitle with contact name and company. *///from w ww. j a va2 s. c om private void setupTitle() { CharSequence displayName = ContactDetailDisplayUtils.getDisplayName(this, mContactData); String company = ContactDetailDisplayUtils.getCompany(this, mContactData); ActionBar actionBar = this.getSupportActionBar(); actionBar.setTitle(displayName); actionBar.setSubtitle(company); if (!TextUtils.isEmpty(displayName)) { AccessibilityManager accessibilityManager = (AccessibilityManager) this .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { View decorView = getWindow().getDecorView(); decorView.setContentDescription(displayName); decorView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } } }
From source file:com.android.talkback.tutorial.TutorialLessonFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { int layoutId; if (mExercise.needScrollableContainer()) { layoutId = R.layout.tutorial_lesson_fragment_scrollable; } else {//from w w w .ja v a 2s . c om layoutId = R.layout.tutorial_lesson_fragment; } View view = inflater.inflate(layoutId, container, false); mDescription = (TextView) view.findViewById(R.id.description); mDescription.setText(mPage.getDescription()); TextView subTitle = (TextView) view.findViewById(R.id.part_subtitle); subTitle.setText(mPage.getSubtitle()); TextView currentPage = (TextView) view.findViewById(R.id.current_page); TextView next = (TextView) view.findViewById(R.id.next); if (mCurrentPage < mLesson.getPagesCount() - 1) { next.setText(R.string.tutorial_next); currentPage.setVisibility(View.VISIBLE); currentPage.setText( getString(R.string.tutorial_page_number_of, mCurrentPage + 1, mLesson.getPagesCount() - 1)); } else if (mTutorialController.getNextLesson(mLesson) == null) { next.setText(R.string.tutorial_home); } else { next.setText(R.string.tutorial_next_lesson); } next.setOnClickListener(this); View previous = view.findViewById(R.id.previous_page); previous.setOnClickListener(this); previous.setContentDescription(getString(R.string.tutorial_previous)); ViewGroup contentContainer = (ViewGroup) view.findViewById(R.id.practice_area); View contentView = mPage.getExercise().getContentView(inflater, contentContainer); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); contentContainer.addView(contentView, params); return view; }
From source file:com.android.contacts.common.list.ViewPagerTabs.java
private void addTab(CharSequence tabTitle, final int position) { View tabView;//from w w w .j a v a2 s . c o m if (mTabIcons != null && position < mTabIcons.length) { View layout = LayoutInflater.from(getContext()).inflate(R.layout.unread_count_tab, null); View iconView = layout.findViewById(R.id.icon); iconView.setBackgroundResource(mTabIcons[position]); iconView.setContentDescription(tabTitle); TextView textView = (TextView) layout.findViewById(R.id.count); if (mUnreadCounts != null && mUnreadCounts[position] > 0) { textView.setText(Integer.toString(mUnreadCounts[position])); textView.setVisibility(View.VISIBLE); iconView.setContentDescription( getResources().getQuantityString(R.plurals.tab_title_with_unread_items, mUnreadCounts[position], tabTitle.toString(), mUnreadCounts[position])); } else { textView.setVisibility(View.INVISIBLE); iconView.setContentDescription(tabTitle); } tabView = layout; } else { final TextView textView = new TextView(getContext()); textView.setText(tabTitle); textView.setBackgroundResource(R.drawable.view_pager_tab_background); // Assign various text appearance related attributes to child views. if (mTextStyle > 0) { textView.setTypeface(textView.getTypeface(), mTextStyle); } if (mTextSize > 0) { textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize); } if (mTextColor != null) { textView.setTextColor(mTextColor); } textView.setAllCaps(mTextAllCaps); textView.setGravity(Gravity.CENTER); tabView = textView; } tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(getRtlPosition(position)); } }); tabView.setOnLongClickListener(new OnTabLongClickListener(position)); tabView.setPadding(mSidePadding, 0, mSidePadding, 0); mTabStrip.addView(tabView, position, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1)); // Default to the first child being selected if (position == 0) { mPrevSelected = 0; tabView.setSelected(true); } }
From source file:com.abcvoipsip.ui.calllog.CallLogDetailsFragment.java
/** Configures the call button area using the given entry. */ private void configureCallButton(String callText, CharSequence nbrLabel, CharSequence number) { View convertView = getView().findViewById(R.id.call_and_sms); convertView.setVisibility(TextUtils.isEmpty(number) ? View.GONE : View.VISIBLE); TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text); View mainAction = convertView.findViewById(R.id.call_and_sms_main_action); mainAction.setOnClickListener(mPrimaryActionListener); mainAction.setContentDescription(callText); mainAction.setTag(number);// w ww . ja v a 2s . c o m text.setText(callText); TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label); if (TextUtils.isEmpty(nbrLabel)) { label.setVisibility(View.GONE); } else { label.setText(nbrLabel); label.setVisibility(View.VISIBLE); } }
From source file:com.googlecode.eyesfree.utils.AccessibilityNodeInfoUtilsTest.java
public void testRefreshNodeContainerNode() throws Throwable { final String description = "Nice view"; setContentView(R.layout.non_speaking_container); final AccessibilityNodeInfoCompat containerNode = getNodeForId(R.id.container); final View containerView = getViewForId(R.id.container); assertNull("Container should have no content description", containerNode.getContentDescription()); runTestOnUiThread(new Runnable() { @Override/*from w ww .j a va2 s . c om*/ public void run() { containerView.setContentDescription(description); } }); waitForAccessibilityIdleSync(); final AccessibilityNodeInfoCompat refreshedNode = AccessibilityNodeInfoUtils.refreshNode(containerNode); assertEquals("Refreshed node should keep its identity", containerNode, refreshedNode); assertEquals("Refreshed node should have new content description", description, refreshedNode.getContentDescription()); }