List of usage examples for android.widget ImageView setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:com.owncloud.android.utils.DisplayUtils.java
/** * Show the avatar corresponding to the received account in an {@ImageView}. * * The avatar is shown if available locally in {@link ThumbnailsCacheManager}. The avatar is not * fetched from the server if not available. * * If there is no avatar stored, a colored icon is generated with the first letter of the account username. * * If this is not possible either, a predefined user icon is shown instead. * * @param account OC account which avatar will be shown. * @param displayView The image view to set the avatar on. * @param displayRadius The radius of the circle where the avatar will be clipped into. * @param fetchFromServer When 'true', if there is no avatar stored in the cache, it's fetched from * the server. When 'false', server is not accessed, the fallback avatar is * generated instead. USE WITH CARE, probably to be removed in the future. * *///from w w w.j av a2 s . com public static void showAccountAvatar(Account account, ImageView displayView, float displayRadius, boolean fetchFromServer) { if (account != null) { // not just accessibility support, used to know what account is bound to each imageView displayView.setContentDescription(account.name); final ThumbnailsCacheManager.GetAvatarTask task = new ThumbnailsCacheManager.GetAvatarTask(displayView, account, displayRadius, fetchFromServer); task.execute(); } }
From source file:com.csipsimple.ui.filters.AccountFiltersListAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { Filter filter = new Filter(); filter.createFromDb(cursor);//from ww w . jav a 2s . c o m String filterDesc = filter.getRepresentation(context); TextView tv = (TextView) view.findViewById(R.id.line1); ImageView icon = (ImageView) view.findViewById(R.id.action_icon); tv.setText(filterDesc); icon.setContentDescription(filterDesc); switch (filter.action) { case Filter.ACTION_CAN_CALL: icon.setImageResource(R.drawable.ic_menu_goto); break; case Filter.ACTION_CANT_CALL: icon.setImageResource(R.drawable.ic_menu_blocked_user); break; case Filter.ACTION_REPLACE: icon.setImageResource(android.R.drawable.ic_menu_edit); break; case Filter.ACTION_DIRECTLY_CALL: icon.setImageResource(R.drawable.ic_menu_answer_call); break; case Filter.ACTION_AUTO_ANSWER: icon.setImageResource(R.drawable.ic_menu_auto_answer); break; default: break; } }
From source file:com.sip.pwc.sipphone.ui.filters.AccountFiltersListAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { Filter filter = new Filter(); filter.createFromDb(cursor);//from w ww .ja v a2 s.c om String filterDesc = filter.getRepresentation(context); TextView tv = (TextView) view.findViewById(R.id.line1); ImageView icon = (ImageView) view.findViewById(R.id.action_icon); tv.setText(filterDesc); icon.setContentDescription(filterDesc); switch (filter.action) { case Filter.ACTION_CAN_CALL: icon.setImageResource(R.mipmap.ic_menu_goto); break; case Filter.ACTION_CANT_CALL: icon.setImageResource(R.mipmap.ic_menu_blocked_user); break; case Filter.ACTION_REPLACE: icon.setImageResource(android.R.drawable.ic_menu_edit); break; case Filter.ACTION_DIRECTLY_CALL: icon.setImageResource(R.mipmap.ic_menu_answer_call); break; case Filter.ACTION_AUTO_ANSWER: icon.setImageResource(R.mipmap.ic_menu_auto_answer); break; default: break; } }
From source file:galilei.kelimekavanozu.view.ImageAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { if (context.get() != null) { final int drawableId = theme.getImageList().get(position + 1); final ImageView view = new ImageView(context.get()); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setContentDescription(context.get().getResources().getString(R.string.content_desc_poempic)); view.setScaleType(ImageView.ScaleType.CENTER_CROP); view.setAdjustViewBounds(true);/*from w w w.j a v a 2 s.c om*/ view.setTag(drawableId); container.addView(view, 0); view.post(new Runnable() { @Override public void run() { ImageLoader.getImageLoader().load(drawableId, view); } }); return view; } return null; }
From source file:finalproject.ece558.edu.pdx.ece.brailleblackjack.LearnBrailleFragment.java
/** * Brings the fragment into view by showing the image/card associated with th page number * @param inflater/*from w w w .j av a 2s . c o m*/ * @param container * @param savedInstanceState * @return ViewGroup */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_learn_braille, container, false); ImageView img = (ImageView) rootView.findViewById(R.id.learnBrailImg); switch (mPageNumber + 1) { case 1: // Switch to number card img.setImageDrawable(getResources().getDrawable(R.drawable.numbers)); img.setContentDescription(getResources().getString(R.string.description_numbers)); break; case 2: // Switch to capitalization card img.setImageDrawable(getResources().getDrawable(R.drawable.capital_letters)); img.setContentDescription(getResources().getString(R.string.description_capitalization)); break; case 3: // Switch to Alphabet a-m card img.setImageDrawable(getResources().getDrawable(R.drawable.letters_atom)); img.setContentDescription(getResources().getString(R.string.description_letters_atom)); break; case 4: // Switch to Alphabet n-z card img.setImageDrawable(getResources().getDrawable(R.drawable.letters_ntoz)); img.setContentDescription(getResources().getString(R.string.description_letters_ntoz)); break; default: break; } return rootView; }
From source file:ca.marklauman.dominionpicker.CardAdapter.java
/** Binds the contents of the Cursor to View elements * provided by this adapter. When a value is bound * by this method, it returns {@code true}, so * that no other binding is performed. If it * returns false, the value is bound by the default * SimpleCursorAdapter methods./* ww w . ja v a 2 s . co m*/ * @param view the view to bind the data to. * @param cursor the cursor to get the data from * (it has been moved to the appropriate position * for this row). * @param columnIndex the index of the column * that is being bound right now. * @return {@code true} if that column was bound to * the view, {@code false} otherwise. */ @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (col_cost == columnIndex || col_gold == columnIndex || col_vict == columnIndex) { if ("0".equals(cursor.getString(columnIndex))) view.setVisibility(View.GONE); else view.setVisibility(View.VISIBLE); return false; } else if (col_potion == columnIndex) { if (1 > cursor.getInt(columnIndex)) view.setVisibility(View.GONE); else view.setVisibility(View.VISIBLE); return true; } else if (col_expansion == columnIndex) { String val = cursor.getString(col_expansion); ImageView v = (ImageView) view; v.setContentDescription(val); Integer icon_id = exp_icons.get(val); if (icon_id == null) icon_id = R.drawable.ic_set_unknown; v.setImageResource(icon_id); return true; } else if (col_buy == columnIndex) { String res = ""; String val = cursor.getString(col_buy); if (!"0".equals(val)) res += ", +" + val + " buy"; val = cursor.getString(col_draw); if (!"0".equals(val)) res += ", +" + val + " card"; val = cursor.getString(col_act); if (!"0".equals(val)) res += ", +" + val + " action"; if (0 != col_gold && 0 != col_vict && res.length() > 2) res = res.substring(2); if ("".equals(res)) view.setVisibility(View.GONE); else { view.setVisibility(View.VISIBLE); TextView v = (TextView) view; v.setText(res); } return true; } else if (col_desc == columnIndex) { String desc = cursor.getString(columnIndex); if ("".equals(desc)) { view.setVisibility(View.GONE); return true; } view.setVisibility(View.VISIBLE); return false; } else if (col_id == columnIndex) { TextView v = (TextView) view; if (yw_bane != cursor.getLong(col_id)) v.setVisibility(View.GONE); else v.setVisibility(View.VISIBLE); return true; } return false; }
From source file:net.simno.klingar.ui.PlayerController.java
@Override public void onPrepareOptionsMenu(@NonNull Menu menu) { MenuItem item = menu.findItem(R.id.action_queue_track); ImageView actionView = (ImageView) MenuItemCompat.getActionView(item); actionView.setImageState(isQueueVisible ? TRACK : QUEUE, true); actionView.setContentDescription(isQueueVisible ? descTrack : descQueue); actionView.setOnClickListener(view -> { actionView.setImageState(isQueueVisible ? QUEUE : TRACK, true); actionView.setContentDescription(isQueueVisible ? descQueue : descTrack); toggleQueue();/*from w w w . java 2s . co m*/ }); }
From source file:com.aprz.easy_iosched.ui.widget.CustomRatingBar.java
/** * Creates ({@link ImageView}s) used to submit a rating using unfilled drawables and adds them to * the layout./*w w w . java 2 s.c o m*/ */ private void createRatingViews() { for (int i = 0; i < mMaxRating; i++) { ImageView imageView = new ImageView(getContext()); imageView.setLayoutParams( new android.view.ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); int tagValue = i + 1; imageView.setTag(tagValue); imageView.setContentDescription(getContext().getString(R.string.feedback_rating_value, tagValue)); imageView.setImageDrawable(mUnfilledDrawable); imageView.setOnClickListener(this); addView(imageView); } }
From source file:com.orange.essentials.otb.ui.OtbContainerFragment.java
/** * Add the policy buttons ont appropriate layout *//*from w w w.ja v a2s .c o m*/ private void buildCards() { Log.d(TAG, "buildCards"); LinearLayout dataLayout = null; LinearLayout usageLayout = null; View containerData = this.getActivity().findViewById(R.id.otb_home_data_card); if (null != containerData) { containerData.setVisibility(TrustBadgeManager.INSTANCE.hasData() ? View.VISIBLE : View.GONE); dataLayout = (LinearLayout) containerData.findViewById(R.id.otb_home_data_card_ll_container); } View containerUsage = this.getActivity().findViewById(R.id.otb_home_usage_card); if (null != containerUsage) { containerUsage.setVisibility(TrustBadgeManager.INSTANCE.hasUsage() ? View.VISIBLE : View.GONE); usageLayout = (LinearLayout) containerUsage.findViewById(R.id.otb_home_data_card_ll_container); } View containerTerms = this.getActivity().findViewById(R.id.otb_home_terms_card); if (null != containerTerms) { containerTerms.setVisibility(TrustBadgeManager.INSTANCE.hasTerms() ? View.VISIBLE : View.GONE); } if (dataLayout != null && usageLayout != null) { dataLayout.removeAllViews(); usageLayout.removeAllViews(); List<TrustBadgeElement> trustBadgeElements = TrustBadgeManager.INSTANCE.getTrustBadgeElements(); if (trustBadgeElements != null) { for (TrustBadgeElement trustBadgeElement : trustBadgeElements) { Log.d(TAG, trustBadgeElement.toString()); if (trustBadgeElement.getElementType() == ElementType.MAIN || trustBadgeElement.getElementType() == ElementType.USAGE) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.otb_custom_toggle_button, null); ImageView icon = (ImageView) view.findViewById(R.id.otb_custom_toggle_button_iv_id); icon.setContentDescription(trustBadgeElement.getNameKey()); TextView buttonText = (TextView) view.findViewById(R.id.otb_custom_toggle_button_tv_id); if (trustBadgeElement.getGroupType() != GroupType.PEGI) { if ((trustBadgeElement.getAppUsesPermission() == AppUsesPermission.TRUE) || (trustBadgeElement .getAppUsesPermission() == AppUsesPermission.NOT_SIGNIFICANT)) { if (trustBadgeElement.getUserPermissionStatus() == UserPermissionStatus.GRANTED || trustBadgeElement .getUserPermissionStatus() == UserPermissionStatus.MANDATORY) { buttonText .setText(getResources().getString(R.string.otb_toggle_button_granted)); buttonText.setTextColor(getResources().getColor(R.color.colorAccent)); icon.setImageDrawable( getResources().getDrawable(trustBadgeElement.getEnabledIconId())); } else { buttonText.setText( getResources().getString(R.string.otb_toggle_button_not_granted)); buttonText.setTextColor(getResources().getColor(R.color.otb_black)); icon.setImageDrawable( getResources().getDrawable(trustBadgeElement.getDisabledIconId())); } } else { buttonText .setText(getResources().getString(R.string.otb_toggle_button_not_granted)); icon.setImageDrawable( getResources().getDrawable(trustBadgeElement.getDisabledIconId())); } } else { icon.setImageDrawable(getResources().getDrawable(trustBadgeElement.getEnabledIconId())); buttonText.setText(TrustBadgeManager.INSTANCE.getPegiAge(trustBadgeElement) .concat(getString(R.string.otb_home_usage_pegi_age))); buttonText.setTextColor(getResources().getColor(R.color.otb_black)); } if (trustBadgeElement.getElementType() == ElementType.MAIN) { dataLayout.addView(view); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onDataClick(); } }); } else { usageLayout.addView(view); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onUsageClick(); } }); } } } } else { Log.d(TAG, "TrustBadgeElements is null, please add TrustBadgeElements to list"); } } Log.d(TAG, "buildCards"); }
From source file:com.stasbar.knowyourself.stopwatch.StopwatchFragment.java
public void onUpdateFab(@NonNull ImageView fab) { if (getStopwatch().isRunning()) { fab.setImageResource(R.drawable.ic_pause_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.sw_pause_button)); } else {//from w w w .j a v a 2 s. co m fab.setImageResource(R.drawable.ic_start_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.sw_start_button)); } fab.setVisibility(VISIBLE); }