All Projects → saket → Better Link Movement Method

saket / Better Link Movement Method

Licence: apache-2.0
Attempts to improve how clickable links are detected, highlighted and handled in TextView

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Better Link Movement Method

Limax
Node.js module to generate URL slugs. Another one? This one cares about i18n and transliterates non-Latin scripts to conform to the RFC3986 standard. Mostly API-compatible with similar modules.
Stars: ✭ 423 (-38.16%)
Mutual labels:  url
Textviewexpandableanimation
Expandable TextView With Smooth Transition Animation
Stars: ✭ 537 (-21.49%)
Mutual labels:  textview
Expandabletextview
Android TextView that can expand and collapse.
Stars: ✭ 632 (-7.6%)
Mutual labels:  textview
Flipview
Flipping views like Gmail & beyond
Stars: ✭ 477 (-30.26%)
Mutual labels:  textview
Kotlinextensions.com
A handy collection of most commonly used Kotlin extensions to boost your productivity.
Stars: ✭ 522 (-23.68%)
Mutual labels:  textview
Htextview
Animation effects to text, not really textview
Stars: ✭ 5,309 (+676.17%)
Mutual labels:  textview
Text Decorator
Decorate your TextView easily
Stars: ✭ 402 (-41.23%)
Mutual labels:  textview
Android Ago
An Android TextView that always displays an auto refreshing relative time span with respect to a reference time
Stars: ✭ 669 (-2.19%)
Mutual labels:  textview
Simplifyspan
A easy-to-use and powerful Spannable library
Stars: ✭ 522 (-23.68%)
Mutual labels:  textview
Query String
Parse and stringify URL query strings
Stars: ✭ 5,781 (+745.18%)
Mutual labels:  url
Htmlbuilder
Build valid HTML for Android TextView
Stars: ✭ 506 (-26.02%)
Mutual labels:  textview
Digger
Digger is a lightweight download framework that requires only one line of code to complete the file download task
Stars: ✭ 521 (-23.83%)
Mutual labels:  url
Laravel Url Signer
Create and validate signed URLs with a limited lifetime
Stars: ✭ 611 (-10.67%)
Mutual labels:  url
Stacklabel
🔥空祖家的堆叠标签(以下碎念:一开始起名字“StackLabel”没想太多结果被人吐槽Stack是整齐堆叠的意思...........好吧这是我的锅不过现在要改也来不及了,好用就行了...吧?
Stars: ✭ 471 (-31.14%)
Mutual labels:  textview
Urlembeddedview
URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.
Stars: ✭ 633 (-7.46%)
Mutual labels:  url
Inputkit
📝InputKit, an Elegant Kit to limits your input text, inspired by BlocksKit, written in both Objective-C & ⚡️Swift.
Stars: ✭ 420 (-38.6%)
Mutual labels:  textview
React Native Hyperlink
A <Hyperlink /> component for react-native that makes urls, fuzzy links, emails etc clickable
Stars: ✭ 572 (-16.37%)
Mutual labels:  url
Wmzdialog
功能最多样式最多的弹窗,支持普通/微信底部/日期/地区/日历/选择/编辑/分享/菜单/自定义弹窗等,支持多种动画,链式编程调用(Pop-up windows with the most functions and styles, support normal/WeChat bottom/date/region/calendar/select/edit/share/menu/custom pop-up windows, etc., support multiple animations, chain programming calls)
Stars: ✭ 673 (-1.61%)
Mutual labels:  textview
Gsyricktext
类似微博的emoji表情、@人、话题等的EdiText,优化了编辑框中的光标点击和删除处理。TextView支持emoji表情、话题、链接、电话和@某人特殊显示的文本。
Stars: ✭ 651 (-4.82%)
Mutual labels:  textview
Selectabletextview
A text view that supports selection and expansion
Stars: ✭ 626 (-8.48%)
Mutual labels:  textview

BetterLinkMovementMethod

Better-Link-Movement-Method

When android:autoLink="all" or Linkify.addLinks(textView, Linkify.ALL) is used to add links to web URLs, phone-numbers, map addresses or email addresses in a TextView, Android uses a class known as LinkMovementMethod for highlighting links when they're focused and dispatching an Intent when they're clicked.

BetterLinkMovementMethod improves over LinkMovementMethod, by fixing some of its flaws:

  • No support for custom click listeners. For e.g., phone numbers always show up in the dialer when clicked and there's no way to change that.
  • Incorrect calculation of touch areas for links, resulting in ghost touch areas (video).
  • Unreliable highlighting of links (video).

A detailed explanation of why (and when) you should use BetterLinkMovementMethod can be read on my blog: http://saket.me/better-url-handler-textview-android/

Usage

BetterLinkMovementMethod is designed to be a drop-in replacement for LinkMovementMethod:

dependencies {
  implementation 'me.saket:better-link-movement-method:2.2.0'
}
val textView = findViewById(...)
Linkify.addLinks(textView, Linkify.ALL)
textView.movementMethod = BetterLinkMovementMethod.getInstance()

Click listeners can be registered by creating a unique instance of BetterLinkMovementMethod for each TextView:

textView.movementMethod = BetterLinkMovementMethod.newInstance().apply {
  setOnLinkClickListener { textView, url ->
    // Handle click or return false to let the framework handle this link.
    true
  }
  setOnLinkLongClickListener { textView, url ->
    // Handle long-click or return false to let the framework handle this link.
    true
  }
}

License

Copyright 2018 Saket Narayan.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].