List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:com.android.mail.browse.SubjectAndFolderView.java
public void setFolders(ConversationViewHeaderCallbacks callbacks, Account account, Conversation conv) { mVisibleFolders = true;/*from w ww . j av a2s . c om*/ final BidiFormatter bidiFormatter = getBidiFormatter(); final String wrappedSubject = mSubject == null ? "" : bidiFormatter.unicodeWrap(mSubject); final SpannableStringBuilder sb = new SpannableStringBuilder(wrappedSubject); sb.append('\u0020'); final Settings settings = account.settings; final int start = sb.length(); if (settings.importanceMarkersEnabled && conv.isImportant()) { sb.append(".\u0020"); sb.setSpan(new ReplacementSpan() { @Override public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) { return mImportanceMarkerDrawable.getIntrinsicWidth(); } @Override public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int baseline, int bottom, Paint paint) { canvas.save(); final int transY = baseline + mChipVerticalOffset - mImportanceMarkerDrawable.getIntrinsicHeight(); canvas.translate(x, transY); mImportanceMarkerDrawable.draw(canvas); canvas.restore(); } }, start, start + 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } mFolderDisplayer.loadConversationFolders(conv, null /* ignoreFolder */, -1 /* ignoreFolderType */); mFolderDisplayer.constructFolderChips(sb); final int end = sb.length(); sb.setSpan(new ChangeLabelsSpan(callbacks), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); setText(sb); setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever.java
final void append(String itemID, String source, String[] newTexts, String linkURL) throws InterruptedException { final TextView textView = textViewRef.get(); if (textView == null) { throw new InterruptedException(); }//from w w w . j a v a 2s .c o m StringBuilder newTextCombined = new StringBuilder(); if (source != null) { newTextCombined.append(source).append(" : "); } int linkStart = newTextCombined.length(); boolean first = true; for (String newText : newTexts) { if (first) { newTextCombined.append(newText); first = false; } else { newTextCombined.append(" ["); newTextCombined.append(newText); newTextCombined.append(']'); } } int linkEnd = newTextCombined.length(); String newText = newTextCombined.toString(); final Spannable content = new SpannableString(newText + "\n\n"); if (linkURL != null) { content.setSpan(new URLSpan(linkURL), linkStart, linkEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { public void run() { textView.append(content); textView.setMovementMethod(LinkMovementMethod.getInstance()); } }); // Add the text to the history. historyManager.addHistoryItemDetails(itemID, newText); }
From source file:com.joyepay.qrcode.result.supplement.SupplementalInfoRetriever.java
final void append(String itemID, String source, String[] newTexts, String linkURL) throws InterruptedException { final TextView textView = textViewRef.get(); if (textView == null) { throw new InterruptedException(); }//from w ww .j a va 2 s . c om StringBuilder newTextCombined = new StringBuilder(); if (source != null) { newTextCombined.append(source).append(" : "); } int linkStart = newTextCombined.length(); boolean first = true; for (String newText : newTexts) { if (first) { newTextCombined.append(newText); first = false; } else { newTextCombined.append(" ["); newTextCombined.append(newText); newTextCombined.append(']'); } } int linkEnd = newTextCombined.length(); String newText = newTextCombined.toString(); final Spannable content = new SpannableString(newText + "\n\n"); if (linkURL != null) { content.setSpan(new URLSpan(linkURL), linkStart, linkEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } handler.post(new Runnable() { public void run() { textView.append(content); textView.setMovementMethod(LinkMovementMethod.getInstance()); } }); // Add the text to the history. // historyManager.addHistoryItemDetails(itemID, newText); }
From source file:com.orange.essentials.otb.ui.OtbTermsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.otb_terms, container, false); LinearLayout llayout = (LinearLayout) mView.findViewById(R.id.otb_terms_layout); TextView headerTv = (TextView) llayout.findViewById(R.id.otb_header_tv_text); headerTv.setText(R.string.otb_home_terms_content); List<Term> terms = TrustBadgeManager.INSTANCE.getTerms(); for (Term term : terms) { View layoutToAdd = null;//from ww w . ja v a2 s.c o m if (term.getTermType() == TermType.VIDEO && Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_video, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_video_title); final AutoResizingFrameLayout anchorView = (AutoResizingFrameLayout) layoutToAdd .findViewById(R.id.videoSurfaceContainer); if (mVideoViews == null) { mVideoViews = new ArrayList<>(); } mVideoViews.add(anchorView); SurfaceView videoSurface = (SurfaceView) layoutToAdd.findViewById(R.id.videoSurface); titleTv.setText(term.getTitleId()); SurfaceHolder videoHolder = videoSurface.getHolder(); MediaPlayer player = new MediaPlayer(); if (mPlayers == null) { mPlayers = new ArrayList<>(); } mPlayers.add(player); final VideoControllerView controller = new VideoControllerView(getContext()); VideoCallback videoCallback = new VideoCallback(player, controller, anchorView); videoHolder.addCallback(videoCallback); anchorView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { controller.show(); return false; } }); try { player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource(getContext(), Uri.parse(getString(term.getContentId()))); player.setOnPreparedListener(videoCallback); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (term.getTermType() == TermType.TEXT) {//TermType.TEXT layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_text, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_title); TextView contentTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_content); titleTv.setText(term.getTitleId()); contentTv.setText(Html.fromHtml(getString(term.getContentId()))); contentTv.setMovementMethod(LinkMovementMethod.getInstance()); contentTv.setLinkTextColor(getResources().getColor(R.color.colorAccent)); } if (null != layoutToAdd) { llayout.addView(layoutToAdd); } if (terms.indexOf(term) != terms.size() - 1) { View.inflate(getActivity(), R.layout.otb_separator, llayout); } } return mView; }
From source file:com.github.guwenk.smuradio.SignInDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { builder = new AlertDialog.Builder(getActivity()); View signInDialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_sign_in, null); builder.setView(signInDialogView);// w w w .j a v a 2 s . c om builder.setMessage(R.string.upload_your_song); checkBox = (CheckBox) signInDialogView.findViewById(R.id.checkBox2); int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } check1 = false; check2 = false; check3 = false; // Log.d(AuthTag, "onCreateDialog " + check1 + " " + check2 + " " + check3); this.mGoogleApiClient = OrderActivity.getmGoogleApiClient(); mAuth = FirebaseAuth.getInstance(); selectFileButton = (Button) signInDialogView.findViewById(R.id.selectFileButton); selectFileButton.setOnClickListener(new customButtonClickListener()); signInButton = (SignInButton) signInDialogView.findViewById(R.id.sign_in_button); signInButton.setStyle(SignInButton.SIZE_WIDE, SignInButton.COLOR_AUTO); signInButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { signIn(); } }); builder.setPositiveButton(getString(R.string.next), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO upload song } }); builder.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); SpannableString ss = new SpannableString(getString(R.string.you_accepting_license_agreement)); ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View textView) { Log.d(AuthTag, "click"); LicenseDialog licenseDialog = new LicenseDialog(); licenseDialog.show(getFragmentManager(), "Sing in dialog"); } @Override public void updateDrawState(TextPaint ds) { super.updateDrawState(ds); ds.setUnderlineText(true); } }; ss.setSpan(clickableSpan, 14, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); TextView textView = (TextView) signInDialogView.findViewById(R.id.textView); textView.setText(ss); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setHighlightColor(Color.TRANSPARENT); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { check2 = isChecked; Log.d(AuthTag, "Checked: " + isChecked); buttonStatus(); } }); mStorageRef = FirebaseStorage.getInstance().getReference(); alert = builder.create(); return alert; }
From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.product_detail); // Allow links in promotions label TextView promotionsTextView = (TextView) findViewById(R.id.textViewPromotion); promotionsTextView.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:net.opendasharchive.openarchive.ReviewMediaActivity.java
private void bindMedia() { // set values tvTitle.setText(mMedia.getTitle());/* w ww. j a v a 2 s . c o m*/ tvDescription.setText(mMedia.getDescription()); tvAuthor.setText(mMedia.getAuthor()); tvLocation.setText(mMedia.getLocation()); tvTags.setText(mMedia.getTags()); tvLicenseUrl.setText(mMedia.getLicenseUrl()); if (mMedia.status != Media.STATUS_LOCAL && mMedia.status != Media.STATUS_NEW) { if (mMedia.status == Media.STATUS_PUBLISHED) { tvUrl.setText(Html.fromHtml(getString(R.string.your_media_is_available) + " <a href=\"" + mMedia.getServerUrl() + "\">" + mMedia.getServerUrl() + "</a>")); tvUrl.setMovementMethod(LinkMovementMethod.getInstance()); tvUrl.setVisibility(View.VISIBLE); } else if (mMedia.status == Media.STATUS_QUEUED) { tvUrl.setText("Waiting for upload..."); tvUrl.setVisibility(View.VISIBLE); } else if (mMedia.status == Media.STATUS_UPLOADING) { tvUrl.setText("Uploading now..."); tvUrl.setVisibility(View.VISIBLE); } tvLicenseUrl.setMovementMethod(LinkMovementMethod.getInstance()); tvTitle.setEnabled(false); tvDescription.setEnabled(false); if (TextUtils.isEmpty(mMedia.getDescription())) tvDescription.setVisibility(View.GONE); tvAuthor.setEnabled(false); if (TextUtils.isEmpty(mMedia.getAuthor())) tvAuthor.setVisibility(View.GONE); tvLocation.setEnabled(false); if (TextUtils.isEmpty(mMedia.getLocation())) tvLocation.setVisibility(View.GONE); tvTags.setEnabled(false); if (TextUtils.isEmpty(mMedia.getTags())) tvTags.setVisibility(View.GONE); tvLicenseUrl.setEnabled(false); if (TextUtils.isEmpty(mMedia.getLicenseUrl())) tvTags.setVisibility(View.GONE); findViewById(R.id.groupLicenseChooser).setVisibility(View.GONE); } if (menuPublish != null) { if (mMedia.status == Media.STATUS_LOCAL) { menuPublish.setVisible(true); menuShare.setVisible(false); } else { menuShare.setVisible(true); menuPublish.setVisible(false); } } }
From source file:com.anton.gavel.GavelMain.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gavel_main); // set up edit text input style for complaints (multiline, capitalize sentences) EditText edit = (EditText) findViewById(R.id.complaint_body); edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE); // set up cities spinner Spinner citiesSpinner = (Spinner) findViewById(R.id.cities_spinner); ArrayAdapter<CharSequence> citiesAdapter = ArrayAdapter.createFromResource(this, R.array.cities, android.R.layout.simple_spinner_item); citiesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); citiesSpinner.setAdapter(citiesAdapter); // set up complaints map List<String> standardComplaints = this.getStandardComplaints(); List<String> complaintSubmitValues = this.getComplaintSubmitValues(); Iterator<String> standard = standardComplaints.iterator(); Iterator<String> submit = complaintSubmitValues.iterator(); complaintsMap = new HashMap<String, String>(); //standard.next(); submit.next(); //skip the first item 'select a complaint' while (standard.hasNext() && submit.hasNext()) complaintsMap.put(standard.next().toString(), submit.next().toString()); // set up complaint spinner List<String> complaints_list = this.getStandardComplaints(); complaintSpinner = (Spinner) findViewById(R.id.complaint_spinner); complaintsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, complaints_list);// w w w. j ava 2s . c o m complaintsAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); complaintSpinner.setAdapter(complaintsAdapter); complaintSpinner.setOnItemSelectedListener(this); complaintSpinner.setOnItemLongClickListener(this);// this doesn't actually work yet bc not supported by API - events don't get fired //attach location listener to button findViewById(R.id.location_button).setOnClickListener(this); // make link in disclaimer clickable TextView disclaimer = (TextView) findViewById(R.id.disclaimer_textview); disclaimer.setMovementMethod(LinkMovementMethod.getInstance()); // check &or load shared preferences to populate saved personal information mPersonalInfo = new PersonalInfo(); SharedPreferences preferences = getPreferences(MODE_PRIVATE); mPersonalInfo.loadFromPreferences(preferences); // suppress keyboard this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // set complaint location to multiline for large layouts if (findViewById(R.id.layout_large_land) != null || findViewById(R.id.layout_large) != null) { ((EditText) findViewById(R.id.complaint_address)).setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_WORDS); } }
From source file:com.pemikir.youtubeplus.VideoItemDetailFragment.java
public void updateInfo(VideoInfo info) { Activity a = getActivity();/* ww w. ja va 2s . c om*/ try { ProgressBar progressBar = (ProgressBar) a.findViewById(R.id.detailProgressBar); TextView videoTitleView = (TextView) a.findViewById(R.id.detailVideoTitleView); TextView uploaderView = (TextView) a.findViewById(R.id.detailUploaderView); TextView viewCountView = (TextView) a.findViewById(R.id.detailViewCountView); TextView thumbsUpView = (TextView) a.findViewById(R.id.detailThumbsUpCountView); TextView thumbsDownView = (TextView) a.findViewById(R.id.detailThumbsDownCountView); TextView uploadDateView = (TextView) a.findViewById(R.id.detailUploadDateView); TextView descriptionView = (TextView) a.findViewById(R.id.detailDescriptionView); ImageView thumbnailView = (ImageView) a.findViewById(R.id.detailThumbnailView); ImageView uploaderThumbnailView = (ImageView) a.findViewById(R.id.detailUploaderThumbnailView); ImageView thumbsUpPic = (ImageView) a.findViewById(R.id.detailThumbsUpImgView); ImageView thumbsDownPic = (ImageView) a.findViewById(R.id.detailThumbsDownImgView); View textSeperationLine = a.findViewById(R.id.textSeperationLine); if (textSeperationLine != null) { textSeperationLine.setVisibility(View.VISIBLE); } progressBar.setVisibility(View.GONE); videoTitleView.setVisibility(View.VISIBLE); uploaderView.setVisibility(View.VISIBLE); uploadDateView.setVisibility(View.VISIBLE); viewCountView.setVisibility(View.VISIBLE); thumbsUpView.setVisibility(View.VISIBLE); thumbsDownView.setVisibility(View.VISIBLE); uploadDateView.setVisibility(View.VISIBLE); descriptionView.setVisibility(View.VISIBLE); thumbnailView.setVisibility(View.VISIBLE); uploaderThumbnailView.setVisibility(View.VISIBLE); thumbsUpPic.setVisibility(View.VISIBLE); thumbsDownPic.setVisibility(View.VISIBLE); switch (info.videoAvailableStatus) { case VideoInfo.VIDEO_AVAILABLE: { videoTitleView.setText(info.title); uploaderView.setText(info.uploader); viewCountView.setText(info.view_count + " " + a.getString(R.string.viewSufix)); thumbsUpView.setText(info.like_count); thumbsDownView.setText(info.dislike_count); uploadDateView.setText(a.getString(R.string.uploadDatePrefix) + " " + info.upload_date); descriptionView.setText(Html.fromHtml(info.description)); descriptionView.setMovementMethod(LinkMovementMethod.getInstance()); ActionBarHandler.getHandler().setVideoInfo(info.webpage_url, info.title); // parse streams Vector<VideoInfo.VideoStream> streamsToUse = new Vector<>(); for (VideoInfo.VideoStream i : info.videoStreams) { if (useStream(i, streamsToUse)) { streamsToUse.add(i); } } VideoInfo.VideoStream[] streamList = new VideoInfo.VideoStream[streamsToUse.size()]; for (int i = 0; i < streamList.length; i++) { streamList[i] = streamsToUse.get(i); } ActionBarHandler.getHandler().setStreams(streamList, info.audioStreams); } break; case VideoInfo.VIDEO_UNAVAILABLE_GEMA: thumbnailView.setImageBitmap( BitmapFactory.decodeResource(getResources(), R.drawable.gruese_die_gema_unangebracht)); break; case VideoInfo.VIDEO_UNAVAILABLE: thumbnailView.setImageBitmap( BitmapFactory.decodeResource(getResources(), R.drawable.not_available_monkey)); break; default: Log.e(TAG, "Video Availeble Status not known."); } if (autoPlayEnabled) { ActionBarHandler.getHandler().playVideo(); } } catch (java.lang.NullPointerException e) { Log.w(TAG, "updateInfo(): Fragment closed before thread ended work... or else"); e.printStackTrace(); } }
From source file:org.bwgz.quotation.fragment.AuthorFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log.d(TAG, String.format("onCreateView - savedInstanceState: %s", savedInstanceState)); View view = inflater.inflate(R.layout.author_fragment, container, false); viewHolder = new ViewHolder(); viewHolder.author_name = (TextView) view.findViewById(R.id.author_name); viewHolder.author_image = (NetworkImageView) view.findViewById(R.id.author_image); viewHolder.author_description_citation_full = (TextView) view .findViewById(R.id.author_description_citation_full); viewHolder.author_description_short = (TextView) view.findViewById(R.id.author_description_short); viewHolder.author_description_full = (TextView) view.findViewById(R.id.author_description_full); viewHolder.author_notable_for = (TextView) view.findViewById(R.id.author_notable_for); viewHolder.author_description_layout = (LinearLayout) view.findViewById(R.id.author_description_layout); viewHolder.author_description_layout_short = (RelativeLayout) view .findViewById(R.id.author_description_layout_short); viewHolder.author_description_layout_full = (RelativeLayout) view .findViewById(R.id.author_description_layout_full); viewHolder.quotation_grid = (GridView) view.findViewById(R.id.quotations); viewHolder.author_description_citation_full.setMovementMethod(LinkMovementMethod.getInstance()); viewHolder.author_description_layout.setOnClickListener(new ViewToggleOnClickListener( viewHolder.author_description_layout_short, viewHolder.author_description_layout_full)); GridView gridView = viewHolder.quotation_grid; gridView.setOnItemClickListener(new GridViewOnItemClickListener(gridView)); gridView.setAdapter(new LoadingAdapter()); Bundle bundle = new Bundle(); bundle.putParcelable(LOADER_BUNDLE_URI, Person.withAppendedId(getPick().getId())); bundle.putStringArray(LOADER_BUNDLE_PROJECTION, new String[] { Person.NAME, Person.DESCRIPTION, Person.NOTABLE_FOR, Person.IMAGE_ID, Person.CITATION_PROVIDER, Person.CITATION_STATEMENT, Person.CITATION_URI, BookmarkPerson.BOOKMARK_ID }); authorLoaderId = initLoader(this, bundle); quotationLoaderId = initLoader(this, PersonQuotation.withAppendedId(getPick().getId()), QuotationQuery.PROJECTION, null, null, null); return view;/* w w w . j ava 2s .c o m*/ }