private void onClickURL(){ MovementMethod contributors_descMovementMethod = contributors_desc.getMovementMethod(); if ((contributors_descMovementMethod == null) || !(contributors_descMovementMethod instanceof LinkMovementMethod)) { if (contributors_desc.getLinksClickable()) { contributors_desc.setMovementMethod(LinkMovementMethod.getInstance()); } } MovementMethod app_report_issues_descMovementMethod = app_report_issues_desc.getMovementMethod(); if ((app_report_issues_descMovementMethod == null) || !(app_report_issues_descMovementMethod instanceof LinkMovementMethod)) { if (app_report_issues_desc.getLinksClickable()) { app_report_issues_desc.setMovementMethod(LinkMovementMethod.getInstance()); } } MovementMethod app_license_info_descMovementMethod = app_license_info_desc.getMovementMethod(); if ((app_license_info_descMovementMethod == null) || !(app_license_info_descMovementMethod instanceof LinkMovementMethod)) { if (app_license_info_desc.getLinksClickable()) { app_license_info_desc.setMovementMethod(LinkMovementMethod.getInstance()); } } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); ButterKnife.bind(this); setupToolbar(); MovementMethod movementMethod = LinkMovementMethod.getInstance(); versionTextView.setText(getVersionName()); appInfoTextView.setText(StringUtils.fromHtml(getString(R.string.about_app_info))); appInfoTextView.setMovementMethod(movementMethod); librariesTextView.setText(StringUtils.fromHtml(getString(R.string.about_libraries_text))); librariesTextView.setMovementMethod(movementMethod); licenseTextView.setText(StringUtils.fromHtml(getString(R.string.about_license_text))); licenseTextView.setMovementMethod(movementMethod); }
/** * Sets the movement method (arrow key handler) to be used for * this TextView. This can be null to disallow using the arrow keys * to move the cursor or scroll the view. * <p> * Be warned that if you want a TextView with a key listener or movement * method not to be focusable, or if you want a TextView without a * key listener or movement method to be focusable, you must call * {@link #setFocusable} again after calling this to get the focusability * back the way you want it. */ public final void setMovementMethod(MovementMethod movement) { if (mMovement != movement) { mMovement = movement; if (movement != null && !(mText instanceof Spannable)) { setText(mText); } fixFocusableAndClickableSettings(); // SelectionModifierCursorController depends on textCanBeSelected, which depends on // mMovement if (mEditor != null) mEditor.prepareCursorControllers(); } }
private void showResponseText(final DConnectResponseMessage response) { View view = findViewById(R.id.response_layout); view.setVisibility(View.VISIBLE); final MessageParser parser = new MessageParser(); parser.setClickLinkListener(new MessageParser.OnClickLinkListener() { @Override public void onClick(String uri) { openImageActivity(uri); } }); MovementMethod method = LinkMovementMethod.getInstance(); TextView textView = (TextView) findViewById(R.id.response); textView.setText(parser.parse(response, 4)); textView.setMovementMethod(method); }
private void showEventText(final DConnectEventMessage event) { View view = findViewById(R.id.event_layout); view.setVisibility(View.VISIBLE); final MessageParser parser = new MessageParser(); parser.setClickLinkListener(new MessageParser.OnClickLinkListener() { @Override public void onClick(String uri) { openImageActivity(uri); } }); MovementMethod method = LinkMovementMethod.getInstance(); TextView textView = (TextView) findViewById(R.id.event); textView.setText(parser.parse(event, 4)); textView.setMovementMethod(method); }
@Override public boolean onTouchEvent(MotionEvent event) { super.onTouchEvent(event); MovementMethod movementMethod = getMovementMethod(); if (movementMethod instanceof TouchableMovementMethod) { TouchableBaseSpan span = ((TouchableMovementMethod) movementMethod).getPressedSpan(); if (span != null) { return true; } } return false; }
protected void onCreate(Bundle savedInstance) { super.onCreate(savedInstance); setContentView(R.layout.activity_main); mContext = this; prefs = PreferenceManager.getDefaultSharedPreferences(this); String text = "This is a #test of regular expressions with http://example.com/ links as used in @twitter for performing various operations based on the links this handles multiple links like http://this_is_fun.com/ and #Awesomess and @Cool"; // textview = new LinkEnabledTextView(this, null); textview = (LinkEnabledTextView) findViewById(R.id.textview); textview.setOnTextLinkClickListener(this); textview.gatherLinksForText(text); edittext = (LinkEnabledEditText) findViewById(R.id.edittext); edittext.setText(prefs.getString("edittextstring", "")); edittext.gatherLinksForText(); edittext.setOnTextLinkClickListener(this); MovementMethod m = textview.getMovementMethod(); if ((m == null) || !(m instanceof LinkMovementMethod)) { if (textview.getLinksClickable()) { textview.setMovementMethod(LinkMovementMethod.getInstance()); } } }
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); // apply the link movement method to all appropriate text views to allow the user to click // any anchors final MovementMethod movementMethod = LinkMovementMethod.getInstance(); appCredits.setMovementMethod(movementMethod); contentCredits.setMovementMethod(movementMethod); styleCredits.setMovementMethod(movementMethod); backendCredits.setMovementMethod(movementMethod); interfaceCredits.setMovementMethod(movementMethod); // setup the action bar, setting the logo and title and enabling the home button final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setIcon(R.drawable.spaced_logo); actionBar.setTitle(R.string.about_activity_title); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); int padding = (int) (getResources().getDisplayMetrics().density * 8); // 8dip ListView listView = getListView(); listView.setPadding(padding, 0, padding, 0); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setDivider(null); LayoutInflater inflater = LayoutInflater.from(getActivity()); View header = inflater.inflate(R.layout.list_header_footer, listView, false); View footer = inflater.inflate(R.layout.list_footer, listView, false); TextView tv = (TextView) footer.findViewById(R.id.footer); String str = getResources().getString(R.string.footer); MovementMethod method = LinkMovementMethod.getInstance(); tv.setMovementMethod(method); CharSequence html = Html.fromHtml(str); tv.setText(html); listView.addHeaderView(header, null, false); listView.addFooterView(footer, null, false); setTrack(7); }
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState ) { View view = inflater.inflate( R.layout.fragment_about, container, false ); ButterKnife.inject( this, view ); Dialog dialog = getDialog(); if( dialog != null ) { dialog.setTitle( R.string.about_title ); } Button marketButton = (Button) view.findViewById( R.id.ABOUT_market_button ); marketButton.setOnClickListener( this ); MovementMethod linkMovementMethod = LinkMovementMethod.getInstance(); m_githubAndroidView.setMovementMethod( linkMovementMethod ); m_githubAndroidView.setText( getText( R.string.about_body_github_android ) ); m_githubFeedbackView.setMovementMethod( linkMovementMethod ); m_githubFeedbackView.setText( getText( R.string.about_body_feedback ) ); m_versionView.setText( "v" + getAppVersion() ); return view; }
public s(View paramView, boolean paramBoolean) { this.a = ((TextView)paramView.findViewById(2131230732)); this.b = ((TextView)paramView.findViewById(2131230733)); if (ao.m()); for (Object localObject = u.a(); ; localObject = LinkMovementMethod.getInstance()) { this.b.setMovementMethod((MovementMethod)localObject); if (paramBoolean) { this.b.setSingleLine(true); this.b.setEllipsize(TextUtils.TruncateAt.END); this.a.setTextColor(paramView.getContext().getResources().getColor(2131165198)); } return; } }
private static final void addLinkMovementMethod(TextView t) { MovementMethod m = t.getMovementMethod(); if ((m == null) || !(m instanceof LinkMovementMethod)) { if (t.getLinksClickable()) { t.setMovementMethod(LinkMovementMethod.getInstance()); } } }
@SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { MovementMethod mm = getMovementMethod(); CharSequence text = getText(); if (mm != null && (text instanceof Spannable) && handleTouchEvent(event)) { mm.onTouchEvent(this, (Spannable) text, event); if (dispatchToParent) { return false; } } return super.onTouchEvent(event); }
@Override public boolean performLongClick() { MovementMethod mm = getMovementMethod(); if (mm != null && (mm instanceof MyLinkMovementMethod)) ((MyLinkMovementMethod) mm).a(this); return super.performLongClick(); }
private static void addLinkMovementMethod(TextView t) { MovementMethod m = t.getMovementMethod(); if ((m == null) || !(m instanceof LinkMovementMethod)) { if (t.getLinksClickable()) { t.setMovementMethod(LinkMovementMethod.getInstance()); } } }
@Override protected MovementMethod getDefaultMovementMethod() { if (isNeedPattern()) { return ImageClickMethod.getInstance(); } return super.getDefaultMovementMethod(); }
public static MovementMethod getInstance() { if (sInstance == null) { sInstance = new LongClickLinkMovementMethod(); } return sInstance; }
public static MovementMethod getInstance() { if (instance == null) { instance = new LongClickLinkMovementMethod(); instance.longClickHandler = new Handler(); } return instance; }
public static MovementMethod getInstance(int longClickDuration) { if (sInstance == null) { sInstance = new LongClickMovementMethod(); sInstance.longClickDuration = longClickDuration; } return sInstance; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); TextView appVersionTextView = (TextView) findViewById(R.id.appVersionTextView); try { PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); appVersionTextView.setText(getString(R.string.app_version_format, packageInfo.versionName)); } catch (NameNotFoundException e) { appVersionTextView.setText("1.0"); } MovementMethod movementMethod = LinkMovementMethod.getInstance(); ((TextView) findViewById(R.id.library1)).setMovementMethod(movementMethod); ((TextView) findViewById(R.id.library2)).setMovementMethod(movementMethod); ((TextView) findViewById(R.id.library3)).setMovementMethod(movementMethod); ((TextView) findViewById(R.id.library4)).setMovementMethod(movementMethod); ((TextView) findViewById(R.id.fontNameTextView)).setMovementMethod(movementMethod); setupWindowAnimation(); }
public static MovementMethod getInstance() { if (sInstance == null) { sInstance = new PostMovementMethod(); sInstance.addURLSpanClick(new SarabaSpan()); sInstance.addURLSpanClick(new BilibiliSpan()); } return sInstance; }
public static MovementMethod getInstance() { if (sInstance == null) { sInstance = new SearchMovementMethod(); sInstance.addURLSpanClick(new SarabaInsideThreadSpan()); sInstance.addURLSpanClick(new SarabaSpan()); sInstance.addURLSpanClick(new BilibiliSpan()); } return sInstance; }
public static MovementMethod getInstance() { if (sInstance == null) { sInstance = new LongPressLinkMovementMethod(); } return sInstance; }
private void testLinkifyAll(TextView initState, MovementMethod expectedMovementMethod) { TextViewConfigurator config = createConfigurator(createTextooContext(), initState); TextView result = config .linkifyAll() .apply(); assertEquals(expectedMovementMethod, result.getMovementMethod()); }
private void testLinkifyPattern(TextView initState, Pattern pattern, MovementMethod expectedMovementMethod) { TextViewConfigurator config = createConfigurator(createTextooContext(), initState); TextView result = config .linkify(pattern, "http://www.google.ie/search?q=") .apply(); assertEquals(expectedMovementMethod, result.getMovementMethod()); }
/** * Sets text with clickable links in the specified TextView. */ private void displayTextWithLinks(TextView textView, final SpannableString spannableString) { MovementMethod m1 = textView.getMovementMethod(); if ((m1 == null) || !(m1 instanceof LinkMovementMethod)) textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setLinkTextColor(linkTextColour); textView.setText(spannableString); }
public void linkify(SocialActionCallback actionCallback) { Linkify.TransformFilter filter = new Linkify.TransformFilter() { public final String transformUrl(final Matcher match, String url) { return match.group(); } }; // emails Linkify.addLinks(this, Patterns.EMAIL_ADDRESS, null, null, filter); // @mentions Linkify.addLinks(this, MENTION_PATTERN, SocialMovementMethod.SOCIAL_UI_MENTION_SCHEME, null, filter); // #hashtags Linkify.addLinks(this, HASHTAG_PATTERN, SocialMovementMethod.SOCIAL_UI_HASHTAG_SCHEME, null, filter); // Links Linkify.addLinks(this, Patterns.WEB_URL, null, null, filter); // Hooking up the actionHandler MovementMethod movementMethod = null; if(actionCallback != null) { movementMethod = new SocialMovementMethod(actionCallback); } setMovementMethod(movementMethod); }
@Override public boolean onTouchEvent(MotionEvent event) { boolean ret = super.onTouchEvent(event); MovementMethod method = getMovementMethod(); if (method instanceof HackyMovementMethod) { return ((HackyMovementMethod) method).isLinkHit(); } return ret; }
/** * Add the movement method to handle the clicks. */ private void addLinkMovementMethod() { MovementMethod m = textView.getMovementMethod(); if ((m == null) || !(m instanceof TouchableMovementMethod)) { if (textView.getLinksClickable()) { textView.setMovementMethod(TouchableMovementMethod.getInstance()); } } }
/** * Don't need to create a new instance for every text view. We can re-use them * @return Instance of the movement method */ public static MovementMethod getInstance() { if (sInstance == null) sInstance = new TouchableMovementMethod(); return sInstance; }
@Override protected MovementMethod getDefaultMovementMethod() { return ScrollingMovementMethod.getInstance(); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // データなし時TextViewのリンクタップでブラウザ表示されるように設定します。 TextView emptyView = (TextView) getListView().getEmptyView(); MovementMethod mMethod = LinkMovementMethod.getInstance(); emptyView.setMovementMethod(mMethod); }
/** * Makes links in a textview clickable * includes support for long clicks * @param view */ public static void makeLinksClickable(TextView view) { MovementMethod m = view.getMovementMethod(); if(m == null || !(m instanceof LongClickLinkMovementMethod)) { if(view.getLinksClickable()) { view.setMovementMethod(LongClickLinkMovementMethod.getInstance()); } } }
public void setLinkText(String text) { links.clear(); if (containsLinkType(LINK_TYPE_WEB)) { gatherLinks(text, hyperlinkPattern, LINK_TYPE_WEB); } if (containsLinkType(LINK_TYPE_HASHTAG)) { gatherLinks(text, hashtagPattern, LINK_TYPE_HASHTAG); } if (containsLinkType(LINK_TYPE_SCREENNAME)) { gatherLinks(text, screenNamePattern, LINK_TYPE_SCREENNAME); } if (containsLinkType(LINK_TYPE_EMAIL)) { gatherLinks(text, emailPattern, LINK_TYPE_EMAIL); } SpannableString linkableText = new SpannableString(text); if (!links.isEmpty()) { for (Hyperlink linkSpec : links) { linkableText.setSpan(linkSpec.span, linkSpec.start, linkSpec.end, 0); } MovementMethod m = getMovementMethod(); if ((m == null) || !(m instanceof LinkMovementMethod)) { if (getLinksClickable()) { setMovementMethod(LocalLinkMovementMethod.getInstance()); } } } setText(linkableText); }