Compare commits
	
		
			3 Commits
		
	
	
		
			v171810292
			...
			v171810304
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | ab2d0c4036 | ||
|  | 99fc417109 | ||
|  | dc304ef8c1 | 
| @@ -16,6 +16,7 @@ import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi | ||||
| import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse | ||||
| import apps.amine.bou.readerforselfoss.persistence.database.AppDatabase | ||||
| import apps.amine.bou.readerforselfoss.themes.AppColors | ||||
| import apps.amine.bou.readerforselfoss.utils.LinkOnTouchListener | ||||
| import apps.amine.bou.readerforselfoss.utils.buildCustomTabsIntent | ||||
| import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper | ||||
| import apps.amine.bou.readerforselfoss.utils.glide.bitmapCenterCrop | ||||
| @@ -65,6 +66,7 @@ class ItemCardAdapter( | ||||
|  | ||||
|         holder.mView.favButton.isLiked = itm.starred | ||||
|         holder.mView.title.text = Html.fromHtml(itm.title) | ||||
|         holder.mView.title.setOnTouchListener(LinkOnTouchListener()) | ||||
|  | ||||
|         holder.mView.title.setLinkTextColor(appColors.colorAccent) | ||||
|  | ||||
|   | ||||
| @@ -5,10 +5,14 @@ import android.content.Context | ||||
| import androidx.constraintlayout.widget.ConstraintLayout | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import android.text.Html | ||||
| import android.text.Spannable | ||||
| import android.text.style.ClickableSpan | ||||
| import android.util.TypedValue | ||||
| import android.view.LayoutInflater | ||||
| import android.view.MotionEvent | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import android.widget.TextView | ||||
| import android.widget.Toast | ||||
| import apps.amine.bou.readerforselfoss.R | ||||
| import apps.amine.bou.readerforselfoss.api.selfoss.Item | ||||
| @@ -16,6 +20,7 @@ import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi | ||||
| import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse | ||||
| import apps.amine.bou.readerforselfoss.persistence.database.AppDatabase | ||||
| import apps.amine.bou.readerforselfoss.themes.AppColors | ||||
| import apps.amine.bou.readerforselfoss.utils.LinkOnTouchListener | ||||
| import apps.amine.bou.readerforselfoss.utils.buildCustomTabsIntent | ||||
| import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper | ||||
| import apps.amine.bou.readerforselfoss.utils.glide.bitmapCenterCrop | ||||
| @@ -67,6 +72,8 @@ class ItemListAdapter( | ||||
|  | ||||
|         holder.mView.title.text = Html.fromHtml(itm.title) | ||||
|  | ||||
|         holder.mView.title.setOnTouchListener(LinkOnTouchListener()) | ||||
|  | ||||
|         holder.mView.title.setLinkTextColor(appColors.colorAccent) | ||||
|  | ||||
|         holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText() | ||||
|   | ||||
| @@ -6,8 +6,13 @@ import android.content.Context | ||||
| import android.content.Intent | ||||
| import android.graphics.BitmapFactory | ||||
| import android.net.Uri | ||||
| import android.text.Spannable | ||||
| import android.text.style.ClickableSpan | ||||
| import androidx.browser.customtabs.CustomTabsIntent | ||||
| import android.util.Patterns | ||||
| import android.view.MotionEvent | ||||
| import android.view.View | ||||
| import android.widget.TextView | ||||
| import android.widget.Toast | ||||
| import apps.amine.bou.readerforselfoss.R | ||||
| import apps.amine.bou.readerforselfoss.ReaderActivity | ||||
| @@ -146,3 +151,40 @@ fun Context.openInBrowserAsNewTask(i: Item) { | ||||
|     intent.data = Uri.parse(i.getLinkDecoded().toStringUriWithHttp()) | ||||
|     startActivity(intent) | ||||
| } | ||||
|  | ||||
| class LinkOnTouchListener: View.OnTouchListener { | ||||
|     override fun onTouch(v: View?, event: MotionEvent?): Boolean { | ||||
|         var ret = false | ||||
|         val widget: TextView = v as TextView | ||||
|         val text: CharSequence = widget.text | ||||
|         val stext = Spannable.Factory.getInstance().newSpannable(text) | ||||
|  | ||||
|         val action = event!!.action | ||||
|  | ||||
|         if (action == MotionEvent.ACTION_UP || | ||||
|             action == MotionEvent.ACTION_DOWN) { | ||||
|             var x: Float = event.x | ||||
|             var y: Float = event.y | ||||
|  | ||||
|             x -= widget.totalPaddingLeft | ||||
|             y -= widget.totalPaddingTop | ||||
|  | ||||
|             x += widget.scrollX | ||||
|             y += widget.scrollY | ||||
|  | ||||
|             val layout = widget.layout | ||||
|             val line = layout.getLineForVertical(y.toInt()) | ||||
|             val off = layout.getOffsetForHorizontal(line, x) | ||||
|  | ||||
|             val link = stext.getSpans(off, off, ClickableSpan::class.java) | ||||
|  | ||||
|             if (link.isNotEmpty()) { | ||||
|                 if (action == MotionEvent.ACTION_UP) { | ||||
|                     link[0].onClick(widget) | ||||
|                 } | ||||
|                 ret = true | ||||
|             } | ||||
|         } | ||||
|         return ret | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -15,7 +15,7 @@ buildscript { | ||||
|         } | ||||
|     } | ||||
|     dependencies { | ||||
|         classpath 'com.android.tools.build:gradle:3.2.0' | ||||
|         classpath 'com.android.tools.build:gradle:3.2.1' | ||||
|         classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1 +1,14 @@ | ||||
| include ':app' | ||||
| include ':app' | ||||
|  | ||||
| ext.isCiServer = !!System.getProperty("CI") | ||||
|  | ||||
| buildCache { | ||||
|     local { | ||||
|         enabled = !isCiServer | ||||
|     } | ||||
|     remote(HttpBuildCache) { | ||||
|         // DO NOT COMMIT !!!!! | ||||
|         url = 'http://amine-bou.fr:8885/cache/' | ||||
|         push = isCiServer | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user