List of usage examples for android.widget TextView setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:com.orange.essentials.otb.ui.OtbDataFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.otb_data, container, false); TextView headerTv = (TextView) view.findViewById(R.id.otb_header_tv_text); headerTv.setText(R.string.otb_home_data_content); TextView keyDataTitleText = (TextView) view.findViewById(R.id.otb_data_tv_main_data_title); keyDataTitleText .setContentDescription(getContext().getString(R.string.otb_accessibility_category_description) + " " + getContext().getString(R.string.otb_main_data_title)); mMainll = (LinearLayout) view.findViewById(R.id.otb_data_ll_main_data); mOtherll = (LinearLayout) view.findViewById(R.id.otb_data_ll_other_data); mNoOtherLayout = view.findViewById(R.id.otb_data_tv_no_other_data); /** Adding listener on bottom button */ Button bottomButton = (Button) view.findViewById(R.id.otb_data_bt_parameter); bottomButton.setOnClickListener(new View.OnClickListener() { @Override// w w w . j a v a2 s . co m public void onClick(View v) { gotoPermissions(); } }); return view; }
From source file:com.fbartnitzek.tasteemall.addentry.CompletionProducerAdapter.java
@Override public void setViewText(TextView v, String text) { Log.v(LOG_TAG,/*from w w w .ja va 2 s .c o m*/ "setViewText, hashCode=" + this.hashCode() + ", " + "v = [" + v + "], text = [" + text + "]"); if (v.getId() == R.id.list_item_location_name) { v.setText(mActivity.getString(R.string.completion_subentry_formatting, text)); v.setContentDescription(mActivity.getString(R.string.a11y_producer_location, text)); } else if (v.getId() == R.id.list_item_producer_name) { v.setText(text); v.setContentDescription(mActivity.getString(R.string.a11y_producer_name, text)); } }
From source file:com.orange.essentials.otb.ui.OtbDataFragment.java
public void refreshPermission() { TrustBadgeManager.INSTANCE.refreshTrustBadgePermission(getContext()); ArrayList<TrustBadgeElement> datas = TrustBadgeManager.INSTANCE.getElementsForDataCollected(); mMainll.removeAllViews();//w w w . j a v a 2s . c om mOtherll.removeAllViews(); boolean isOtherTitleAdded = false; for (final TrustBadgeElement data : datas) { View usageView = View.inflate(getContext(), R.layout.otb_data_usage_item, null); ViewHelper.INSTANCE.buildView(usageView, data, getContext()); if (data.getElementType() == ElementType.MAIN) { mMainll.addView(usageView); } else { mOtherll.addView(usageView); isOtherTitleAdded = true; } if (data.isToggable()) { final SwitchCompat switchCompat = (SwitchCompat) usageView .findViewById(R.id.otb_data_usage_item_sc_switch); switchCompat.setVisibility(View.VISIBLE); switchCompat.setContentDescription( getToggleContentDescription(data.getNameKey(), switchCompat.isChecked())); if (data.getAppUsesPermission() == AppUsesPermission.TRUE) { switchCompat.setEnabled(true); switchCompat.setChecked(data.getUserPermissionStatus() == UserPermissionStatus.GRANTED); } switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switchCompat .setContentDescription(getToggleContentDescription(data.getNameKey(), isChecked)); if (ignoreCheckedChange) { return; } TrustBadgeManager.INSTANCE.getEventTagger().tagElement(EventType.TRUSTBADGE_ELEMENT_TOGGLED, data); TrustBadgeManager.INSTANCE.badgeChanged(data, isChecked, (AppCompatActivity) getActivity()); TrustBadgeManager.INSTANCE.badgeChanged(data.getGroupType(), isChecked, (AppCompatActivity) getActivity()); } }); } } if (!isOtherTitleAdded) { mOtherll.setVisibility(View.GONE); mNoOtherLayout.setVisibility(View.VISIBLE); /** Accessibility : Adding "other data" section */ TextView otherDataTitleText = (TextView) mNoOtherLayout.findViewById(R.id.otb_data_tv_other_data_title); if (otherDataTitleText != null) { otherDataTitleText.setContentDescription( getContext().getString(R.string.otb_accessibility_category_description) + " " + getContext().getString(R.string.otb_other_data_title)); } } else { mOtherll.setVisibility(View.VISIBLE); mNoOtherLayout.setVisibility(View.GONE); } }
From source file:com.fbartnitzek.tasteemall.addentry.CompletionDrinkAdapter.java
@Override public void setViewText(TextView v, String text) { // Log.v(LOG_TAG, "setViewText, hashCode=" + this.hashCode() + ", " + "v = [" + v + "], text = [" + text + "]"); switch (v.getId()) { case R.id.list_item_producer_name: v.setText(mActivity.getString(R.string.completion_subentry_formatting, text)); v.setContentDescription(mActivity.getString(R.string.a11y_producer_name, text)); break;//from ww w . j a v a2 s . c om case R.id.list_item_drink_name: v.setText(text); v.setContentDescription(mActivity.getString(R.string.a11y_drink_name, text)); break; case R.id.list_item_drink_type: v.setText(mActivity.getString(R.string.completion_prefix_formatting, text)); v.setContentDescription(mActivity.getString(R.string.a11y_drink_type, mActivity.getString(Utils.getReadableDrinkNameId(mContext, text)))); break; default: super.setViewText(v, text); } }
From source file:com.google.android.apps.forscience.whistlepunk.EditNoteDialog.java
@Override public AlertDialog onCreateDialog(Bundle savedInstanceState) { mLabel = getArguments().getParcelable(KEY_SAVED_LABEL); String timeText = getArguments().getString(KEY_SAVED_TIME_TEXT, ""); String timeTextContentDescription = getArguments().getString(KEY_SAVED_TIME_TEXT_DESCRIPTION); mTimestamp = getArguments().getLong(KEY_SAVED_TIMESTAMP); try {//from w w w. jav a 2s . c om mSelectedValue = GoosciLabelValue.LabelValue.parseFrom(getArguments().getByteArray(KEY_SELECTED_VALUE)); } catch (InvalidProtocolBufferNanoException ex) { Log.wtf(TAG, "Couldn't parse label value"); } AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); LinearLayout rootView = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.run_review_label_edit, null); alertDialog.setView(rootView); ImageView imageView = (ImageView) rootView.findViewById(R.id.picture_note_preview_image); final EditText editText = (EditText) rootView.findViewById(R.id.edit_note_text); TextView autoTextView = (TextView) rootView.findViewById(R.id.auto_note_text); // Use mSelectedValue to load content, because the user may have changed the value since // it was stored in the label. Note that picture labels can't be edited at this time, // but in the future this will apply to picture labels as well. if (mLabel instanceof PictureLabel) { imageView.setVisibility(View.VISIBLE); autoTextView.setVisibility(View.GONE); editText.setText(PictureLabel.getCaption(mSelectedValue)); editText.setHint(R.string.picture_note_caption_hint); Glide.with(getActivity()).load(PictureLabel.getFilePath(mSelectedValue)).into(imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PictureUtils.launchExternalViewer(getActivity(), (PictureLabel.getFilePath(mSelectedValue))); } }); } else if (mLabel instanceof TextLabel) { imageView.setVisibility(View.GONE); autoTextView.setVisibility(View.GONE); editText.setText(TextLabel.getText(mSelectedValue)); } else if (mLabel instanceof SensorTriggerLabel) { imageView.setVisibility(View.GONE); autoTextView.setVisibility(View.VISIBLE); editText.setText(SensorTriggerLabel.getCustomText(mSelectedValue)); String autoText = SensorTriggerLabel.getAutogenText(mSelectedValue); TriggerHelper.populateAutoTextViews(autoTextView, autoText, R.drawable.ic_label_black_24dp, getResources()); } alertDialog.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mLabel.setTimestamp(mTimestamp); if (mLabel instanceof TextLabel) { ((TextLabel) mLabel).setText(editText.getText().toString()); } else if (mLabel instanceof PictureLabel) { ((PictureLabel) mLabel).setCaption(editText.getText().toString()); } else if (mLabel instanceof SensorTriggerLabel) { ((SensorTriggerLabel) mLabel).setCustomText(editText.getText().toString()); } getDataController().editLabel(mLabel, ((EditNoteDialogListener) getParentFragment()).onLabelEdit(mLabel)); } }); alertDialog.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.setCancelable(true); TextView timeTextView = (TextView) rootView.findViewById(R.id.edit_note_time); timeTextView.setText(timeText); timeTextView.setContentDescription(timeTextContentDescription); if (labelBelongsToRun() && mLabel.canEditTimestamp()) { timeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GoosciLabelValue.LabelValue value = new GoosciLabelValue.LabelValue(); if (mLabel instanceof PictureLabel) { // Captions can be edited, but the picture path cannot be edited at this // time. PictureLabel.populateStorageValue(value, ((PictureLabel) mLabel).getFilePath(), editText.getText().toString()); ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value, mTimestamp); } else if (mLabel instanceof TextLabel) { TextLabel.populateStorageValue(value, editText.getText().toString()); ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value, mTimestamp); } } }); } else if (labelBelongsToRun()) { Drawable lockDrawable = getResources().getDrawable(R.drawable.ic_lock_black_18dp); DrawableCompat.setTint(lockDrawable, getResources().getColor(R.color.text_color_light_grey)); // There is already a start drawable. Use it again. Drawable[] drawables = timeTextView.getCompoundDrawablesRelative(); timeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawables[0], null, lockDrawable, null); } AlertDialog dialog = alertDialog.create(); if (mLabel instanceof TextLabel || mLabel instanceof SensorTriggerLabel) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); } return dialog; }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java
public SuggestionStripView(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); final LayoutInflater inflater = LayoutInflater.from(context); inflater.inflate(R.layout.suggestions_strip, this); mSuggestionsStrip = (ViewGroup) findViewById(R.id.suggestions_strip); mVoiceKey = (ImageButton) findViewById(R.id.suggestions_strip_voice_key); mImportantNoticeStrip = findViewById(R.id.important_notice_strip); mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip, mImportantNoticeStrip); for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) { final TextView word = new TextView(context, null, R.attr.suggestionWordStyle); word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion)); word.setOnClickListener(this); word.setOnLongClickListener(this); mWordViews.add(word);//ww w . ja v a 2s.c o m final View divider = inflater.inflate(R.layout.suggestion_divider, null); mDividerViews.add(divider); final TextView info = new TextView(context, null, R.attr.suggestionWordStyle); info.setTextColor(Color.WHITE); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP); mDebugInfoViews.add(info); } mLayoutHelper = new SuggestionStripLayoutHelper(context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews); mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null); mMoreSuggestionsView = (MoreSuggestionsView) mMoreSuggestionsContainer .findViewById(R.id.more_suggestions_view); mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView); final Resources res = context.getResources(); mMoreSuggestionsModalTolerance = res .getDimensionPixelOffset(R.dimen.config_more_suggestions_modal_tolerance); mMoreSuggestionsSlidingDetector = new GestureDetector(context, mMoreSuggestionsSlidingListener); final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs, R.styleable.Keyboard, defStyle, R.style.SuggestionStripView); final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey); keyboardAttr.recycle(); mVoiceKey.setImageDrawable(iconVoice); mVoiceKey.setOnClickListener(this); }
From source file:pl.edu.agh.schedule.myschedule.MyScheduleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_schedule); if (mDataHelper == null) { mDataHelper = new ScheduleHelper(this); }//from w w w .j a va 2s .c o m mViewPager = (ViewPager) findViewById(R.id.view_pager); for (int i = 0; i < DAYS_RANGE; i++) { mScheduleAdapters[i] = new MyScheduleAdapter(this, getLUtils()); } mViewPagerAdapter = new OurViewPagerAdapter(getFragmentManager()); mViewPager.setAdapter(mViewPagerAdapter); mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs); if (mTabLayout != null) { mTabLayout.setTabsFromPagerAdapter(mViewPagerAdapter); } mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { mViewPager.setCurrentItem(tab.getPosition(), true); TextView view = (TextView) findViewById(baseTabViewId + tab.getPosition()); if (view != null) { view.setContentDescription( getString(R.string.talkback_selected, getString(R.string.a11y_button, tab.getText()))); } } @Override public void onTabUnselected(TabLayout.Tab tab) { TextView view = (TextView) findViewById(baseTabViewId + tab.getPosition()); if (view != null) { view.setContentDescription(getString(R.string.a11y_button, tab.getText())); } } @Override public void onTabReselected(TabLayout.Tab tab) { // Do nothing } }); mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages, select the corresponding tab. securelySelectTab(position); } }); mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.my_schedule_page_margin)); mViewPager.setPageMarginDrawable(R.drawable.page_margin); setTabLayoutContentDescriptions(); overridePendingTransition(0, 0); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); sp.registerOnSharedPreferenceChangeListener(this); if (cachedSettingsState == null) { cachedSettingsState = getIsScanEnabled(sp); } // FIXME adjust settings beaconManager = new BeaconManager(this); beaconManager.setForegroundScanPeriod(1000, 5000); beaconManager.setRangingListener(new BeaconManager.RangingListener() { @Override public void onBeaconsDiscovered(Region region, List<Beacon> list) { if (!list.isEmpty()) { Beacon nearestBeacon = list.get(0); String id = String.format("%s:%d:%d", nearestBeacon.getProximityUUID().toString(), nearestBeacon.getMajor(), nearestBeacon.getMinor()); if (!id.equals(BeaconUtils.nearestBeacon())) { setTitle(mDataHelper.getLocationForBeacon(id)); BeaconUtils.nearestBeacon(id); updateData(); } } } }); region = new Region("ranged region", null, null, null); SystemRequirementsChecker.checkWithDefaultDialogs(this); if (mViewPager != null) { selectDay(TODAY); } if (savedInstanceState == null) { new Handler().postDelayed(new Runnable() { @Override public void run() { securelySelectTab(TODAY); } }, 100); } if (getIsScanEnabled(sp)) { beaconManager.connect(new BeaconManager.ServiceReadyCallback() { @Override public void onServiceReady() { beaconManager.startRanging(region); } }); } }
From source file:pl.edu.agh.schedule.myschedule.MyScheduleActivity.java
private void setTabLayoutContentDescriptions() { LayoutInflater inflater = getLayoutInflater(); int gap = 0;/*from ww w. j a va 2 s . c o m*/ for (int i = 0, count = mTabLayout.getTabCount(); i < count; i++) { TabLayout.Tab tab = mTabLayout.getTabAt(i); if (tab != null) { TextView view = (TextView) inflater.inflate(R.layout.tab_my_schedule, mTabLayout, false); view.setId(baseTabViewId + i); view.setText(tab.getText()); if (i == 0) { view.setContentDescription( getString(R.string.talkback_selected, getString(R.string.a11y_button, tab.getText()))); } else { view.setContentDescription(getString(R.string.a11y_button, tab.getText())); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.announceForAccessibility( getString(R.string.my_schedule_tab_desc_a11y, getDayName(i - gap))); } tab.setCustomView(view); } else { Log.e(TAG, "Tab is null."); } } }
From source file:com.yaozu.object.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setContentDescription(title); tab.setText(title);/*from w ww . j a va 2s. c o m*/ tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTextColor(tabTextColorNormal); // add by hangl addTab(position, tab); }
From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java
@Override public void onBindViewHolder(ViewHolder holder, int position) { switch (holder.getItemViewType()) { case ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break;//from ww w. j ava 2s . c o m } case PREDICTION_ICON_VIEW_TYPE: { AppInfo info = mApps.getAdapterItems().get(position).appInfo; BubbleTextView icon = (BubbleTextView) holder.mContent; icon.applyFromApplicationInfo(info); break; } case EMPTY_SEARCH_VIEW_TYPE: TextView emptyViewText = (TextView) holder.mContent; emptyViewText.setText(mEmptySearchMessage); emptyViewText.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); break; case SEARCH_MARKET_VIEW_TYPE: TextView searchView = (TextView) holder.mContent; if (mMarketSearchIntent != null) { searchView.setVisibility(View.VISIBLE); searchView.setContentDescription(mMarketSearchMessage); searchView.setGravity( mApps.hasNoFilteredResults() ? Gravity.CENTER : Gravity.START | Gravity.CENTER_VERTICAL); searchView.setText(mMarketSearchMessage); } else { searchView.setVisibility(View.GONE); } break; } }