List of usage examples for android.view View setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:org.jorge.cmp.ui.fragment.ArticleReaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { setHasOptionsMenu(Boolean.TRUE); final View ret = inflater.inflate(R.layout.fragment_article_reader, container, Boolean.FALSE); View mHeaderView = ret.findViewById(R.id.image); PicassoUtils.loadInto(mContext, mArticle.getImageUrl(), mDefaultImageId, (android.widget.ImageView) mHeaderView, TAG); final String title = mArticle.getTitle(); mHeaderView.setContentDescription(title); ((TextView) ret.findViewById(R.id.title)).setText(title); WebView contentView = (WebView) ret.findViewById(android.R.id.text1); WebSettings webViewSettings = contentView.getSettings(); contentView.setOverScrollMode(View.OVER_SCROLL_NEVER); webViewSettings.setJavaScriptCanOpenWindowsAutomatically(Boolean.TRUE); webViewSettings.setBuiltInZoomControls(Boolean.FALSE); contentView.setBackgroundColor(0x00000000); //I wonder why the default background is white contentView.loadData(mArticle.getPreviewText(), "text/html; charset=UTF-8", "UTF-8"); mActionBar = mActivity.getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE); mActionBarBackgroundDrawable = new ColorDrawable( mContext.getResources().getColor(R.color.toolbar_background)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { mActionBarBackgroundDrawable.setCallback(mDrawableCallback); }/* ww w.j a v a 2 s .co m*/ mActionBar.setBackgroundDrawable(mActionBarBackgroundDrawable); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mOriginalElevation = mActionBar.getElevation(); mActionBar.setElevation(0); //So that the shadow of the ActionBar doesn't show over // the article title } mActionBar.setTitle(mActivity.getString(R.string.section_title_article_reader)); StickyParallaxNotifyingScrollView scrollView = (StickyParallaxNotifyingScrollView) ret .findViewById(R.id.scroll_view); scrollView.setOnScrollChangedListener(mOnScrollChangedListener); scrollView.smoothScrollTo(0, 0); if (!mArticle.isRead()) { mMarkAsReadFab = (FloatingActionButton) ret.findViewById(R.id.fab_button_mark_as_read); mMarkAsReadFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { markArticleAsRead(mArticle); if (mMarkAsReadFab.isShown()) mMarkAsReadFab.hide(); } private void markArticleAsRead(FeedArticle article) { final Realm r = Realm.getInstanceByRealmId(ArticleReaderFragment.this.mAccount.getRealmEnum()); String l = PreferenceAssistant.readSharedString(mContext, PreferenceAssistant.PREF_LANG, null); if (l == null || !Arrays.asList(r.getLocales()).contains(l)) { l = r.getLocales()[0]; PreferenceAssistant.writeSharedString(mContext, PreferenceAssistant.PREF_LANG, l); } final Class newsClass = NewsListFragment.class; final Class communityClass = CommunityListFragment.class; final Class schoolClass = SchoolListFragment.class; String tableName; if (mClass == newsClass) { if (l == null || !Arrays.asList(r.getLocales()).contains(l)) { l = r.getLocales()[0]; PreferenceAssistant.writeSharedString(mContext, PreferenceAssistant.PREF_LANG, l); } tableName = SQLiteDAO.getNewsTableName(r, l); } else if (mClass == communityClass) { tableName = SQLiteDAO.getCommunityTableName(); } else if (mClass == schoolClass) { tableName = SQLiteDAO.getSchoolTableName(); } else { throw new IllegalArgumentException( "Feed list fragment class " + mClass.getCanonicalName() + " not recognized."); } new AsyncTask<Object, Void, Void>() { @Override protected Void doInBackground(Object... params) { SQLiteDAO.getInstance().markArticleAsRead((FeedArticle) params[0], (String) params[1]); return null; } }.executeOnExecutor(Executors.newSingleThreadExecutor(), article, tableName); article.markAsRead(); } }); mMarkAsReadFab.hide(); mMarkAsReadFab.setVisibility(View.VISIBLE); showMarkAsReadFabIfItProceeds(); } return ret; }
From source file:com.massivekinetics.ow.ui.views.timepicker.TimePicker.java
private void trySetContentDescription(View root, int viewId, int contDescResId) { View target = root.findViewById(viewId); if (target != null) { target.setContentDescription(getContext().getString(contDescResId)); }/* w w w .j a v a 2 s .co m*/ }
From source file:net.maa123.tatuky.MainActivity.java
private void setupSearchView() { searchView.attachNavigationDrawerToMenuButton(drawer.getDrawerLayout()); // Setup content descriptions for the different elements in the search view. final View leftAction = searchView.findViewById(R.id.left_action); leftAction.setContentDescription(getString(R.string.action_open_drawer)); searchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() { @Override//w w w .j ava 2 s .c o m public void onFocus() { leftAction.setContentDescription(getString(R.string.action_close)); } @Override public void onFocusCleared() { leftAction.setContentDescription(getString(R.string.action_open_drawer)); } }); View clearButton = searchView.findViewById(R.id.clear_btn); clearButton.setContentDescription(getString(R.string.action_clear)); searchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override public void onSearchTextChanged(String oldQuery, String newQuery) { if (!oldQuery.equals("") && newQuery.equals("")) { searchView.clearSuggestions(); return; } if (newQuery.length() < 3) { return; } searchView.showProgress(); mastodonAPI.searchAccounts(newQuery, false, 5).enqueue(new Callback<List<Account>>() { @Override public void onResponse(Call<List<Account>> call, Response<List<Account>> response) { if (response.isSuccessful()) { searchView.swapSuggestions(response.body()); searchView.hideProgress(); } else { searchView.hideProgress(); } } @Override public void onFailure(Call<List<Account>> call, Throwable t) { searchView.hideProgress(); } }); } }); searchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { @Override public void onSuggestionClicked(SearchSuggestion searchSuggestion) { Account accountSuggestion = (Account) searchSuggestion; Intent intent = new Intent(MainActivity.this, AccountActivity.class); intent.putExtra("id", accountSuggestion.id); startActivity(intent); } @Override public void onSearchAction(String currentQuery) { } }); searchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() { @Override public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) { Account accountSuggestion = ((Account) item); Picasso.with(MainActivity.this).load(accountSuggestion.avatar) .placeholder(R.drawable.avatar_default).into(leftIcon); String searchStr = accountSuggestion.getDisplayName() + " " + accountSuggestion.username; final SpannableStringBuilder str = new SpannableStringBuilder(searchStr); str.setSpan(new StyleSpan(Typeface.BOLD), 0, accountSuggestion.getDisplayName().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(str); textView.setMaxLines(1); textView.setEllipsize(TextUtils.TruncateAt.END); } }); }
From source file:com.thelastcrusade.soundstream.components.ConnectFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_connect, container, false); ((CoreActivity) getActivity()).hidePlaybar(); int rotation = getActivity().getWindowManager().getDefaultDisplay().getRotation(); if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) { ((LinearLayout) v).setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams clickableParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1); clickableParams.setMargins(5, 10, 10, 10); v.findViewById(R.id.join).setLayoutParams(clickableParams); clickableParams.setMargins(10, 10, 5, 10); v.findViewById(R.id.create).setLayoutParams(clickableParams); } else {//from w w w. j av a2s . com ((LinearLayout) v).setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams clickableParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, 0, 1); clickableParams.setMargins(10, 5, 10, 10); v.findViewById(R.id.join).setLayoutParams(clickableParams); clickableParams.setMargins(10, 10, 10, 5); v.findViewById(R.id.create).setLayoutParams(clickableParams); } View create = v.findViewById(R.id.create); create.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Transitions.transitionToHome((CoreActivity) getActivity()); ((CoreActivity) getActivity()).enableSlidingMenu(); //add the playbar fragment onto the active content view ((CoreActivity) getActivity()).showPlaybar(); } }); create.setContentDescription(ContentDescriptionUtils.CREATE); this.joinView = v.findViewById(R.id.join); this.joinView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new WithBluetoothEnabled(getActivity(), getConnectionService()).run(new Runnable() { @Override public void run() { getConnectionService().broadcastSelfAsGuest(getActivity()); } }); } }); joinView.setContentDescription(ContentDescriptionUtils.CONNECT); TextView joinText = (TextView) v.findViewById(R.id.join_network_id); joinText.setText(String.format(getString(R.string.join_network), BluetoothUtils.getLocalBluetoothName())); if (savedInstanceState != null) { isSearching = savedInstanceState.getBoolean(SEARCHING_TAG); if (isSearching) setJoinToSearchingState(); } return v; }
From source file:com.android.contacts.activities.ContactDetailActivity.java
/** * Setup the activity title and subtitle with contact name and company. *///from w ww. jav a 2 s .c o m private void setupTitle() { CharSequence displayName = ContactDetailDisplayUtils.getDisplayName(this, mContactData); String company = ContactDetailDisplayUtils.getCompany(this, mContactData); ActionBar actionBar = getActionBar(); actionBar.setTitle(displayName); actionBar.setSubtitle(company); final StringBuilder talkback = new StringBuilder(); if (!TextUtils.isEmpty(displayName)) { talkback.append(displayName); } if (!TextUtils.isEmpty(company)) { if (talkback.length() != 0) { talkback.append(", "); } talkback.append(company); } if (talkback.length() != 0) { AccessibilityManager accessibilityManager = (AccessibilityManager) this .getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager.isEnabled()) { View decorView = getWindow().getDecorView(); decorView.setContentDescription(talkback); decorView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); } } }
From source file:com.fa.mastodon.activity.MainActivity.java
private void setupSearchView() { searchView.attachNavigationDrawerToMenuButton(drawer.getDrawerLayout()); // Setup content descriptions for the different elements in the search view. final View leftAction = searchView.findViewById(R.id.left_action); leftAction.setContentDescription(getString(R.string.action_open_drawer)); searchView.setOnFocusChangeListener(new FloatingSearchView.OnFocusChangeListener() { @Override/*ww w. j a va2s . c om*/ public void onFocus() { leftAction.setContentDescription(getString(R.string.action_close)); } @Override public void onFocusCleared() { leftAction.setContentDescription(getString(R.string.action_open_drawer)); } }); View clearButton = searchView.findViewById(R.id.clear_btn); clearButton.setContentDescription(getString(R.string.action_clear)); searchView.setOnQueryChangeListener(new FloatingSearchView.OnQueryChangeListener() { @Override public void onSearchTextChanged(String oldQuery, String newQuery) { if (!oldQuery.equals("") && newQuery.equals("")) { searchView.clearSuggestions(); return; } if (newQuery.length() < 3) { return; } searchView.showProgress(); mastodonAPI.searchAccounts(newQuery, false, 5).enqueue(new Callback<List<Account>>() { @Override public void onResponse(Call<List<Account>> call, Response<List<Account>> response) { if (response.isSuccessful()) { searchView.swapSuggestions(response.body()); searchView.hideProgress(); } else { searchView.hideProgress(); } } @Override public void onFailure(Call<List<Account>> call, Throwable t) { searchView.hideProgress(); } }); } }); searchView.setOnSearchListener(new FloatingSearchView.OnSearchListener() { @Override public void onSuggestionClicked(SearchSuggestion searchSuggestion) { Account accountSuggestion = (Account) searchSuggestion; Intent intent = new Intent(MainActivity.this, AccountActivity.class); intent.putExtra("id", accountSuggestion.id); startActivity(intent); } @Override public void onSearchAction(String currentQuery) { } }); searchView.setOnBindSuggestionCallback(new SearchSuggestionsAdapter.OnBindSuggestionCallback() { @Override public void onBindSuggestion(View suggestionView, ImageView leftIcon, TextView textView, SearchSuggestion item, int itemPosition) { Account accountSuggestion = ((Account) item); Picasso.with(MainActivity.this).load(accountSuggestion.avatar) .placeholder(R.drawable.avatar_default).into(leftIcon); String searchStr = accountSuggestion.getDisplayName() + " " + accountSuggestion.username; final SpannableStringBuilder str = new SpannableStringBuilder(searchStr); str.setSpan(new StyleSpan(Typeface.BOLD), 0, accountSuggestion.getDisplayName().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(str); textView.setMaxLines(1); textView.setEllipsize(TextUtils.TruncateAt.END); } }); if (PreferenceManager.getDefaultSharedPreferences(this).getString("theme_selection", "light") .equals("black")) { searchView.setBackgroundColor(Color.parseColor("#444444")); } }
From source file:com.yaozu.object.widget.PagerSlidingTabStrip.java
/** * Runs through all tabs and sets if they are currently selected. * * @param position The position of the currently selected tab. *//*from w w w . j av a2s. c om*/ private void selectTab(int position) { for (int i = 0; i < tabsContainer.getChildCount(); i++) { View childView = tabsContainer.getChildAt(i); if (childView instanceof TextView) { CharSequence text = ((TextView) childView).getText(); if (i != position) { ((TextView) childView).setTextColor(tabTextColorNormal); childView.setContentDescription(text); } else { ((TextView) childView).setTextColor(tabTextColorSelected); childView.setContentDescription("(" + text + ")"); } } } }
From source file:com.android.purenexussettings.utils.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = createDefaultTabView(getContext()); TextView tabTitleView = (TextView) tabView; // not completely sure what changes result from this... if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0;//from w w w .j a va 2 s . c o m lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(Color.WHITE); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:org.nativescript.widgets.TabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TabItemSpec tabItem;//from w w w. j a v a2 s.c o m if (this.mTabItems != null && this.mTabItems.length > i) { tabItem = this.mTabItems[i]; } else { tabItem = new TabItemSpec(); tabItem.title = adapter.getPageTitle(i).toString(); } tabView = createDefaultTabView(getContext(), tabItem); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:gov.cdc.epiinfo.RecordList.java
/** Called when the activity is first created. */ @SuppressLint("NewApi") @Override/*from ww w. j ava2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (DeviceManager.IsPhone()) { DeviceManager.SetOrientation(this, false); } else { DeviceManager.SetOrientation(this, true); } this.setTheme(R.style.AppTheme); //getSupportActionBar().setDisplayHomeAsUpEnabled(true); self = this; setContentView(R.layout.record_list); lineListFragment = (LineListFragment) getFragmentManager().findFragmentById(R.id.listFragment); logo = BitmapFactory.decodeResource(getResources(), R.drawable.launcher); View addButton = findViewById(R.id.add_button); addButton.setContentDescription("Add a new record"); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { createRecord(); } }); AppManager.Started(this); Bundle extras = getIntent().getExtras(); if (extras != null) { try { viewName = extras.getString("ViewName"); if (extras.containsKey("FKEY")) { fkeyGuid = extras.getString("FKEY"); } formMetadata = new FormMetadata("EpiInfo/Questionnaires/" + viewName + ".xml", this); AppManager.AddFormMetadata(viewName, formMetadata); mDbHelper = new EpiDbHelper(this, formMetadata, viewName); mDbHelper.open(); AppManager.SetCurrentDatabase(mDbHelper); fillData(); } catch (Exception ex) { Alert(getString(R.string.database_error)); this.finish(); } } }