List of usage examples for android.widget ImageView setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:com.android.inputmethod.keyboard.emoji.EmojiPalettesView.java
private void addTab(final TabHost host, final int categoryId) { final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */); final TabHost.TabSpec tspec = host.newTabSpec(tabId); tspec.setContent(R.id.emoji_keyboard_dummy); final ImageView iconView = (ImageView) LayoutInflater.from(getContext()) .inflate(R.layout.emoji_keyboard_tab_icon, null); // TODO: Replace background color with its own setting rather than using the // category page indicator background as a workaround. iconView.setBackgroundColor(mCategoryPageIndicatorBackground); iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId)); iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId)); tspec.setIndicator(iconView);/*from ww w .j a v a2s .c o m*/ host.addTab(tspec); }
From source file:com.androidinspain.deskclock.stopwatch.StopwatchFragment.java
private void updateFab(@NonNull ImageView fab, boolean animate) { if (getStopwatch().isRunning()) { if (animate) { fab.setImageResource(R.drawable.ic_play_pause_animation); } else {/* w w w.ja va2 s. com*/ fab.setImageResource(R.drawable.ic_play_pause); } fab.setContentDescription(fab.getResources().getString(R.string.sw_pause_button)); } else { if (animate) { fab.setImageResource(R.drawable.ic_pause_play_animation); } else { fab.setImageResource(R.drawable.ic_pause_play); } fab.setContentDescription(fab.getResources().getString(R.string.sw_start_button)); } fab.setVisibility(VISIBLE); }
From source file:com.google.samples.apps.iosched.navigation.AppNavigationViewAsDrawerImpl.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that shows * which account the user is logged in as, and lets them switch accounts. It also shows the * user's Google+ cover photo as background. *///from w w w. ja v a 2 s .c om private void setupAccountBox() { final View chosenAccountView = mActivity.findViewById(R.id.chosen_account_view); if (chosenAccountView == null) { //This activity does not have an account box return; } Account chosenAccount = AccountUtils.getActiveAccount(mActivity); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); } ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); String imageUrl = AccountUtils.getPlusImageUrl(mActivity); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(mActivity); if (coverImageUrl != null) { mActivity.findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.GONE); coverImageView.setVisibility(View.VISIBLE); coverImageView.setContentDescription( mActivity.getResources().getString(R.string.navview_header_user_image_content_description)); mImageLoader.loadImage(coverImageUrl, coverImageView); coverImageView.setColorFilter(mActivity.getResources().getColor(R.color.light_content_scrim)); } else { mActivity.findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.VISIBLE); coverImageView.setVisibility(View.GONE); } List<Account> accounts = Arrays.asList(AccountUtils.getActiveAccount(getContext())); populateAccountList(accounts); }
From source file:com.nogago.android.tracks.UploadResultActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id != DIALOG_RESULT_ID) { return null; }/*from w ww . j ava 2s .c om*/ view = getLayoutInflater().inflate(R.layout.upload_result, null); LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result); LinearLayout fusionTablesResult = (LinearLayout) view.findViewById(R.id.upload_result_fusion_tables_result); LinearLayout docsResult = (LinearLayout) view.findViewById(R.id.upload_result_docs_result); ImageView mapsResultIcon = (ImageView) view.findViewById(R.id.upload_result_maps_result_icon); ImageView fusionTablesResultIcon = (ImageView) view .findViewById(R.id.upload_result_fusion_tables_result_icon); ImageView docsResultIcon = (ImageView) view.findViewById(R.id.upload_result_docs_result_icon); TextView successFooter = (TextView) view.findViewById(R.id.upload_result_success_footer); TextView errorFooter = (TextView) view.findViewById(R.id.upload_result_error_footer); boolean hasError = false; if (!sendRequest.isSendMaps()) { mapsResult.setVisibility(View.GONE); } else { if (!sendRequest.isMapsSuccess()) { mapsResultIcon.setImageResource(R.drawable.failure); mapsResultIcon.setContentDescription(getString(R.string.generic_error_title)); hasError = true; } } if (!sendRequest.isSendFusionTables()) { fusionTablesResult.setVisibility(View.GONE); } else { if (!sendRequest.isFusionTablesSuccess()) { fusionTablesResultIcon.setImageResource(R.drawable.failure); fusionTablesResultIcon.setContentDescription(getString(R.string.generic_error_title)); hasError = true; } } if (!sendRequest.isSendDocs()) { docsResult.setVisibility(View.GONE); } else { if (!sendRequest.isDocsSuccess()) { docsResultIcon.setImageResource(R.drawable.failure); docsResultIcon.setContentDescription(getString(R.string.generic_error_title)); hasError = true; } } if (hasError) { successFooter.setVisibility(View.GONE); } else { errorFooter.setVisibility(View.GONE); } AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true) .setIcon(hasError ? android.R.drawable.ic_dialog_alert : android.R.drawable.ic_dialog_info) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }).setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title).setView(view); // Add a Share URL button if shareUrl exists if (shareUrl != null) { builder.setNegativeButton(R.string.share_track_share_url, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ChooseActivityDialogFragment.newInstance(sendRequest.getTrackId(), shareUrl).show( getSupportFragmentManager(), ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG); } }); } resultDialog = builder.create(); return resultDialog; }
From source file:com.google.samples.apps.iosched.session.SessionDetailFragment.java
/** * Determines visibility of a social icon, sets up a click listener to allow the user to * navigate to the social network associated with the icon, and sets up a content description * for the icon./* ww w . ja va2 s . c o m*/ */ private void setUpSpeakerSocialIcon(final SessionDetailModel.Speaker speaker, ImageView socialIcon, final String socialUrl, String socialNetworkName, final String packageName) { if (socialUrl == null || socialUrl.isEmpty()) { socialIcon.setVisibility(View.GONE); } else { socialIcon.setContentDescription( getString(R.string.speaker_social_page, socialNetworkName, speaker.getName())); socialIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UIUtils.fireSocialIntent(getActivity(), Uri.parse(socialUrl), packageName); } }); } }
From source file:orbin.deskclock.timer.TimerFragment.java
@Override public void onUpdateFab(@NonNull ImageView fab) { if (mCurrentView == mTimersView) { final Timer timer = getTimer(); if (timer == null) { fab.setVisibility(INVISIBLE); return; }/*w w w . java2 s .c o m*/ fab.setVisibility(VISIBLE); switch (timer.getState()) { case RUNNING: fab.setImageResource(R.drawable.ic_pause_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_stop)); break; case RESET: case PAUSED: fab.setImageResource(R.drawable.ic_start_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_start)); break; case EXPIRED: fab.setImageResource(R.drawable.ic_stop_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_stop)); break; } } else if (mCurrentView == mCreateTimerView) { if (mCreateTimerView.hasValidInput()) { fab.setImageResource(R.drawable.ic_start_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_start)); fab.setVisibility(VISIBLE); } else { fab.setVisibility(INVISIBLE); } } }
From source file:net.abcdroid.devfest12.ui.SessionDetailFragment.java
private void onSpeakersQueryComplete(Cursor cursor) { mSpeakersCursor = true;//from ww w.j a v a 2 s . c o m // TODO: remove existing speakers from layout, since this cursor might be from a data change final ViewGroup speakersGroup = (ViewGroup) mRootView.findViewById(R.id.session_speakers_block); final LayoutInflater inflater = getActivity().getLayoutInflater(); boolean hasSpeakers = false; while (cursor.moveToNext()) { final String speakerName = cursor.getString(SpeakersQuery.SPEAKER_NAME); if (TextUtils.isEmpty(speakerName)) { continue; } final String speakerImageUrl = cursor.getString(SpeakersQuery.SPEAKER_IMAGE_URL); final String speakerCompany = cursor.getString(SpeakersQuery.SPEAKER_COMPANY); final String speakerUrl = cursor.getString(SpeakersQuery.SPEAKER_URL); final String speakerAbstract = cursor.getString(SpeakersQuery.SPEAKER_ABSTRACT); String speakerHeader = speakerName; if (!TextUtils.isEmpty(speakerCompany)) { speakerHeader += ", " + speakerCompany; } final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false); final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header); final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image); final TextView speakerAbstractView = (TextView) speakerView.findViewById(R.id.speaker_abstract); if (!TextUtils.isEmpty(speakerImageUrl)) { mImageFetcher.loadThumbnailImage(speakerImageUrl, speakerImageView, R.drawable.person_image_empty); } speakerHeaderView.setText(speakerHeader); speakerImageView.setContentDescription(getString(R.string.speaker_googleplus_profile, speakerHeader)); UIUtils.setTextMaybeHtml(speakerAbstractView, speakerAbstract); if (!TextUtils.isEmpty(speakerUrl)) { speakerImageView.setEnabled(true); speakerImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent speakerProfileIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(speakerUrl)); speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); UIUtils.preferPackageForIntent(getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME); UIUtils.safeOpenLink(getActivity(), speakerProfileIntent); } }); } else { speakerImageView.setEnabled(false); speakerImageView.setOnClickListener(null); } speakersGroup.addView(speakerView); hasSpeakers = true; mHasSummaryContent = true; } speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE); // Show empty message when all data is loaded, and nothing to show if (mSessionCursor && !mHasSummaryContent) { mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE); } }
From source file:com.stasbar.knowyourself.timer.TimerFragment.java
public void onUpdateFab(@NonNull ImageView fab) { if (mCurrentView == mTimersView) { final Timer timer = getTimer(); if (timer == null) { fab.setVisibility(INVISIBLE); return; }//from w w w .ja v a 2 s .c o m fab.setVisibility(VISIBLE); switch (timer.getState()) { case RUNNING: fab.setImageResource(R.drawable.ic_pause_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_stop)); break; case RESET: case PAUSED: fab.setImageResource(R.drawable.ic_start_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_start)); break; case MISSED: case EXPIRED: fab.setImageResource(R.drawable.ic_stop_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_stop)); break; } } else if (mCurrentView == mCreateTimerView) { if (mCreateTimerView.hasValidInput()) { fab.setImageResource(R.drawable.ic_start_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.timer_start)); fab.setVisibility(VISIBLE); } else { fab.setVisibility(INVISIBLE); } } }
From source file:com.wizardsofm.deskclock.timer.TimerFragment.java
@Override public void onUpdateFab(@NonNull ImageView fab) { if (mCurrentView == mTimersView) { final Timer timer = getTimer(); if (timer == null) { fab.setVisibility(INVISIBLE); return; }/*from ww w .ja v a 2 s .com*/ fab.setVisibility(VISIBLE); switch (timer.getState()) { case RUNNING: fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_pause_white_24dp); fab.setContentDescription( fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_stop)); break; case RESET: case PAUSED: fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_start_white_24dp); fab.setContentDescription( fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_start)); break; case EXPIRED: fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_stop_white_24dp); fab.setContentDescription( fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_stop)); break; } } else if (mCurrentView == mCreateTimerView) { if (mCreateTimerView.hasValidInput()) { fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_start_white_24dp); fab.setContentDescription( fab.getResources().getString(com.wizardsofm.deskclock.R.string.timer_start)); fab.setVisibility(VISIBLE); } else { fab.setVisibility(INVISIBLE); } } }
From source file:edu.berkeley.boinc.StatusFragment.java
private void loadLayout(Boolean forceUpdate) { //load layout, if if ClientStatus can be accessed. //if this is not the case, the broadcast receiver will call "loadLayout" again try {/*from ww w . j av a2 s .c o m*/ int currentSetupStatus = BOINCActivity.monitor.getSetupStatus(); int currentComputingStatus = BOINCActivity.monitor.getComputingStatus(); int currentComputingSuspendReason = BOINCActivity.monitor.getComputingSuspendReason(); int currentNetworkSuspendReason = BOINCActivity.monitor.getNetworkSuspendReason(); // layout only if client RPC connection is established // otherwise BOINCActivity does not start Tabs if (currentSetupStatus == ClientStatus.SETUP_STATUS_AVAILABLE) { // return in cases nothing has changed if (forceUpdate || computingStatus != currentComputingStatus || currentComputingSuspendReason != computingSuspendReason || currentNetworkSuspendReason != networkSuspendReason) { // set layout and retrieve elements LinearLayout statusWrapper = (LinearLayout) getView().findViewById(R.id.status_wrapper); LinearLayout centerWrapper = (LinearLayout) getView().findViewById(R.id.center_wrapper); LinearLayout restartingWrapper = (LinearLayout) getView().findViewById(R.id.restarting_wrapper); TextView statusHeader = (TextView) getView().findViewById(R.id.status_header); ImageView statusImage = (ImageView) getView().findViewById(R.id.status_image); TextView statusDescriptor = (TextView) getView().findViewById(R.id.status_long); restartingWrapper.setVisibility(View.GONE); // adapt to specific computing status switch (currentComputingStatus) { case ClientStatus.COMPUTING_STATUS_NEVER: statusWrapper.setVisibility(View.VISIBLE); statusHeader.setText(BOINCActivity.monitor.getCurrentStatusTitle()); statusHeader.setVisibility(View.VISIBLE); statusImage.setImageResource(R.drawable.playb48); statusImage.setContentDescription(BOINCActivity.monitor.getCurrentStatusTitle()); statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); centerWrapper.setVisibility(View.VISIBLE); centerWrapper.setOnClickListener(runModeOnClickListener); break; case ClientStatus.COMPUTING_STATUS_SUSPENDED: statusWrapper.setVisibility(View.VISIBLE); statusHeader.setText(BOINCActivity.monitor.getCurrentStatusTitle()); statusHeader.setVisibility(View.VISIBLE); statusImage.setImageResource(R.drawable.pauseb48); statusImage.setContentDescription(BOINCActivity.monitor.getCurrentStatusTitle()); statusImage.setClickable(false); centerWrapper.setVisibility(View.VISIBLE); switch (currentComputingSuspendReason) { case BOINCDefs.SUSPEND_REASON_BATTERIES: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); statusImage.setImageResource(R.drawable.notconnectedb48); statusHeader.setVisibility(View.GONE); break; case BOINCDefs.SUSPEND_REASON_USER_ACTIVE: Boolean suspendDueToScreenOn = false; try { suspendDueToScreenOn = BOINCActivity.monitor.getSuspendWhenScreenOn(); } catch (RemoteException e) { } if (suspendDueToScreenOn) { statusImage.setImageResource(R.drawable.screen48b); statusHeader.setVisibility(View.GONE); } statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_USER_REQ: // state after user stops and restarts computation centerWrapper.setVisibility(View.GONE); restartingWrapper.setVisibility(View.VISIBLE); break; case BOINCDefs.SUSPEND_REASON_TIME_OF_DAY: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_BENCHMARKS: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); statusImage.setImageResource(R.drawable.watchb48); statusHeader.setVisibility(View.GONE); break; case BOINCDefs.SUSPEND_REASON_DISK_SIZE: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_CPU_THROTTLE: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_NO_RECENT_INPUT: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_INITIAL_DELAY: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_EXCLUSIVE_APP_RUNNING: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_CPU_USAGE: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_NETWORK_QUOTA_EXCEEDED: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_OS: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_WIFI_STATE: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case BOINCDefs.SUSPEND_REASON_BATTERY_CHARGING: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); statusImage.setImageResource(R.drawable.batteryb48); statusHeader.setVisibility(View.GONE); break; case BOINCDefs.SUSPEND_REASON_BATTERY_OVERHEATED: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); statusImage.setImageResource(R.drawable.batteryb48); statusHeader.setVisibility(View.GONE); break; default: statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; } break; case ClientStatus.COMPUTING_STATUS_IDLE: statusWrapper.setVisibility(View.VISIBLE); centerWrapper.setVisibility(View.VISIBLE); statusHeader.setText(BOINCActivity.monitor.getCurrentStatusTitle()); statusHeader.setVisibility(View.VISIBLE); statusImage.setImageResource(R.drawable.pauseb48); statusImage.setContentDescription(BOINCActivity.monitor.getCurrentStatusTitle()); statusImage.setClickable(false); statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusDescription()); break; case ClientStatus.COMPUTING_STATUS_COMPUTING: statusWrapper.setVisibility(View.GONE); break; } //save new computing status computingStatus = currentComputingStatus; computingSuspendReason = currentComputingSuspendReason; networkSuspendReason = currentNetworkSuspendReason; setupStatus = -1; // invalidate to force update next time no project } } else if (currentSetupStatus == ClientStatus.SETUP_STATUS_NOPROJECT) { if (setupStatus != ClientStatus.SETUP_STATUS_NOPROJECT) { // set layout and retrieve elements LinearLayout statusWrapper = (LinearLayout) getView().findViewById(R.id.status_wrapper); LinearLayout centerWrapper = (LinearLayout) getView().findViewById(R.id.center_wrapper); LinearLayout restartingWrapper = (LinearLayout) getView().findViewById(R.id.restarting_wrapper); TextView statusHeader = (TextView) getView().findViewById(R.id.status_header); ImageView statusImage = (ImageView) getView().findViewById(R.id.status_image); TextView statusDescriptor = (TextView) getView().findViewById(R.id.status_long); statusWrapper.setVisibility(View.VISIBLE); restartingWrapper.setVisibility(View.GONE); centerWrapper.setVisibility(View.VISIBLE); centerWrapper.setOnClickListener(addProjectOnClickListener); statusImage.setImageResource(R.drawable.projectsb48); statusHeader.setVisibility(View.GONE); statusDescriptor.setText(BOINCActivity.monitor.getCurrentStatusTitle()); setupStatus = ClientStatus.SETUP_STATUS_NOPROJECT; computingStatus = -1; } } else { // BOINC client is not available //invalid computingStatus, forces layout on next event setupStatus = -1; computingStatus = -1; } } catch (Exception e) { } }