chore: cleaning ci steps. #150

Merged
AmineB merged 13 commits from build-changes into master 2023-10-10 20:52:30 +00:00
8 changed files with 55 additions and 16 deletions
Showing only changes of commit 776d5d36f6 - Show all commits

View File

@ -5,6 +5,7 @@ import android.content.res.ColorStateList
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.LinearLayoutManager
import bou.amine.apps.readerforselfossv2.android.adapters.SourcesListAdapter
import bou.amine.apps.readerforselfossv2.android.databinding.ActivitySourcesBinding
@ -36,8 +37,10 @@ class SourcesActivity : AppCompatActivity(), DIAware {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
binding.fab.rippleColor = resources.getColor(R.color.colorAccentDark)
binding.fab.backgroundTintList = ColorStateList.valueOf(resources.getColor(R.color.colorAccent))
binding.fab.rippleColor = ContextCompat.getColor(this, R.color.colorAccentDark)
binding.fab.backgroundTintList =
ColorStateList.valueOf(ContextCompat.getColor(this, R.color.colorAccent))
}
override fun onStop() {

View File

@ -6,6 +6,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView.ScaleType
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.databinding.CardItemBinding
@ -60,7 +61,7 @@ class ItemCardAdapter(
binding.title.setOnTouchListener(LinkOnTouchListener())
binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent))
binding.title.setLinkTextColor(ContextCompat.getColor(c, R.color.colorAccent))
binding.sourceTitleAndDate.text = itm.sourceAuthorAndDate()

View File

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.databinding.ListItemBinding
@ -44,7 +45,8 @@ class ItemListAdapter(
binding.title.setOnTouchListener(LinkOnTouchListener())
binding.title.setLinkTextColor(c.resources.getColor(R.color.colorAccent))
binding.title.setLinkTextColor(ContextCompat.getColor(c, R.color.colorAccent))
binding.sourceTitleAndDate.text = itm.sourceAuthorAndDate()

View File

@ -10,13 +10,21 @@ import android.graphics.drawable.ColorDrawable
import android.net.Uri
import android.os.Bundle
import android.util.TypedValue
import android.view.*
import android.view.GestureDetector
import android.view.InflateException
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import bou.amine.apps.readerforselfossv2.android.ImageActivity
@ -35,6 +43,7 @@ import bou.amine.apps.readerforselfossv2.model.SelfossModel
import bou.amine.apps.readerforselfossv2.repository.Repository
import bou.amine.apps.readerforselfossv2.rest.MercuryApi
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
import bou.amine.apps.readerforselfossv2.utils.ImageMimeType
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
import bou.amine.apps.readerforselfossv2.utils.getImages
import bou.amine.apps.readerforselfossv2.utils.getThumbnail
@ -54,7 +63,7 @@ import org.kodein.di.instance
import java.net.MalformedURLException
import java.net.SocketTimeoutException
import java.net.URL
import java.util.*
import java.util.Locale
import java.util.concurrent.ExecutionException
@ -116,9 +125,15 @@ class ArticleFragment : Fragment(), DIAware {
fab = binding.fab
fab.backgroundTintList = ColorStateList.valueOf(resources.getColor(R.color.colorAccent))
fab.backgroundTintList =
ColorStateList.valueOf(
ContextCompat.getColor(
requireContext(),
R.color.colorAccent
)
)
fab.rippleColor = resources.getColor(R.color.colorAccentDark)
fab.rippleColor = ContextCompat.getColor(requireContext(), R.color.colorAccentDark)
val floatingToolbar: FloatingToolbar = handleFloatingToolbar()
@ -203,7 +218,8 @@ class ArticleFragment : Fragment(), DIAware {
}
floatingToolbar.attachFab(fab)
floatingToolbar.background = ColorDrawable(resources.getColor(R.color.colorAccent))
floatingToolbar.background =
ColorDrawable(ContextCompat.getColor(requireContext(), R.color.colorAccent))
floatingToolbar.setClickListener(
object : FloatingToolbar.ItemClickListener {
@ -288,7 +304,7 @@ class ArticleFragment : Fragment(), DIAware {
contentText = data.content.orEmpty()
htmlToWebview()
handleLeadImage(data?.lead_image_url)
handleLeadImage(data.lead_image_url)
binding.nestedScrollView.scrollTo(0, 0)
binding.progressBar.visibility = View.GONE
@ -382,6 +398,8 @@ class ArticleFragment : Fragment(), DIAware {
binding.webcontent.settings.standardFontFamily = a.getString(0)
a.recycle()
binding.webcontent.visibility = View.VISIBLE
val colorOnSurface = TypedValue()
@ -457,7 +475,7 @@ class ArticleFragment : Fragment(), DIAware {
| color: ${
String.format(
"#%06X",
0xFFFFFF and resources.getColor(R.color.colorAccent)
0xFFFFFF and ContextCompat.getColor(requireContext(), R.color.colorAccent)
)
} !important;
| }

View File

@ -12,6 +12,7 @@ import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import bou.amine.apps.readerforselfossv2.android.HomeActivity
import bou.amine.apps.readerforselfossv2.android.R
import bou.amine.apps.readerforselfossv2.android.databinding.FilterFragmentBinding
@ -20,7 +21,7 @@ import bou.amine.apps.readerforselfossv2.repository.Repository
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
import bou.amine.apps.readerforselfossv2.utils.getIcon
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.ViewTarget
import com.bumptech.glide.request.target.CustomViewTarget
import com.bumptech.glide.request.transition.Transition
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.chip.Chip
@ -88,7 +89,7 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
Glide.with(context)
.load(source.getIcon(repository.baseUrl))
.into(object : ViewTarget<Chip?, Drawable?>(c) {
.into(object : CustomViewTarget<Chip, Drawable>(c) {
override fun onResourceReady(
resource: Drawable,
transition: Transition<in Drawable?>?
@ -100,6 +101,13 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
}
}
override fun onLoadFailed(errorDrawable: Drawable?) {
c.chipIcon = errorDrawable
}
override fun onResourceCleared(placeholder: Drawable?) {
c.chipIcon = placeholder
}
})
c.text = source.title.getHtmlDecoded()
@ -156,7 +164,7 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
Color.parseColor(tag.color)
} catch (e: IllegalArgumentException) {
e.sendSilentlyWithAcraWithName("color issue " + tag.color)
resources.getColor(R.color.colorPrimary)
ContextCompat.getColor(context, R.color.colorPrimary)
}
gd.setColor(gdColor)
gd.shape = GradientDrawable.RECTANGLE

View File

@ -95,6 +95,7 @@ class LinkOnTouchListener : View.OnTouchListener {
if (link.isNotEmpty()) {
if (action == MotionEvent.ACTION_UP) {
link[0].onClick(widget)
widget.performClick()
}
ret = true
}

View File

@ -1,13 +1,19 @@
package bou.amine.apps.readerforselfossv2.utils
import android.net.Uri
import android.os.Build
import android.text.Html
import bou.amine.apps.readerforselfossv2.model.SelfossModel
import org.jsoup.Jsoup
import java.util.*
actual fun String.getHtmlDecoded(): String {
return Html.fromHtml(this).toString()
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(this, Html.FROM_HTML_MODE_COMPACT).toString()
} else {
@Suppress("DEPRECATION")
Html.fromHtml(this).toString()
}
}
actual fun SelfossModel.Item.getIcon(baseUrl: String): String {

View File

@ -17,7 +17,7 @@ fun SOURCE.toView(): SelfossModel.SourceDetail =
this.id.toInt(),
this.title,
null,
this.tags?.split(","),
this.tags.split(","),
this.spout,
this.error,
this.icon,