Compare commits
12 Commits
47f78754dc
...
v124123651
Author | SHA1 | Date | |
---|---|---|---|
934c112db5 | |||
ad7549a89f | |||
fb9ceecabd | |||
61b9fd30e0 | |||
806e56e20b | |||
cd8b7aaf9d | |||
c25ad7621e | |||
63da3b9fe7 | |||
1d99eeb633 | |||
162a350a8f | |||
27c1bba146 | |||
b7f3a9877a |
@@ -3,7 +3,7 @@ on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
BuildAndTest:
|
||||
BuildAndTestAndCoverage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
@@ -16,9 +16,30 @@ jobs:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
cache: gradle
|
||||
- uses: gradle/actions/setup-gradle@v3
|
||||
- uses: android-actions/setup-android@v3
|
||||
- name: Configure gradle...
|
||||
run: mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=true" >> ~/.gradle/gradle.properties
|
||||
- name: Build and test
|
||||
run: ./gradlew build -x test --stacktrace
|
||||
run: ./gradlew build -x testReleaseUnitTest -x testDebugUnitTest -x testGithubConfigReleaseUnitTest -x testGithubConfigDebugUnitTest # These tests will be done
|
||||
- uses: KengoTODA/actions-setup-docker-compose@v1
|
||||
with:
|
||||
version: "2.23.3"
|
||||
- name: run selfoss
|
||||
run: |
|
||||
docker compose -f .gitea/workflows/assets/docker-compose.yml up -d
|
||||
- name: coverage
|
||||
run: |
|
||||
./gradlew :koverHtmlReport
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage
|
||||
path: build/reports/kover/html
|
||||
retention-days: 1
|
||||
overwrite: true
|
||||
include-hidden-files: true
|
||||
- name: Clean
|
||||
if: always()
|
||||
run: |
|
||||
docker compose -f .gitea/workflows/assets/docker-compose.yml stop
|
@@ -85,6 +85,7 @@ jobs:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: gradle
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
- name: Configure gradle...
|
||||
|
@@ -12,8 +12,9 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: gradle
|
||||
- name: Install klint
|
||||
run: curl -sSLO https://github.com/pinterest/ktlint/releases/download/1.0.0/ktlint && chmod a+x ktlint && mv ktlint /usr/local/bin/
|
||||
- name: Install detekt
|
||||
|
@@ -1,44 +0,0 @@
|
||||
name: Check master code
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Fetch tags
|
||||
run: git fetch --tags -p
|
||||
- uses: KengoTODA/actions-setup-docker-compose@v1
|
||||
with:
|
||||
version: "2.23.3"
|
||||
- name: run selfoss
|
||||
run: |
|
||||
docker compose -f .gitea/workflows/assets/docker-compose.yml up -d
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: gradle
|
||||
- uses: gradle/actions/setup-gradle@v3
|
||||
- uses: android-actions/setup-android@v3
|
||||
- name: Configure gradle...
|
||||
run: mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=true" >> ~/.gradle/gradle.properties
|
||||
- name: coverage
|
||||
run: |
|
||||
./gradlew :koverHtmlReport
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage
|
||||
path: build/reports/kover/html
|
||||
retention-days: 1
|
||||
overwrite: true
|
||||
include-hidden-files: true
|
||||
- name: Clean
|
||||
if: always()
|
||||
run: |
|
||||
docker compose -f .gitea/workflows/assets/docker-compose.yml stop
|
@@ -203,7 +203,7 @@ dependencies {
|
||||
|
||||
implementation("ch.acra:acra-http:$acraVersion")
|
||||
implementation("ch.acra:acra-toast:$acraVersion")
|
||||
|
||||
implementation("com.google.auto.service:auto-service:1.1.1")
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
|
@@ -62,7 +62,7 @@ class LoginActivityTest {
|
||||
|
||||
@Test
|
||||
fun urlError() {
|
||||
performLogin("172.17.0.1:8888")
|
||||
performLogin("10.0.2.2:8888")
|
||||
onView(withId(R.id.urlView)).perform(click())
|
||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.wrong_infos)))
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package bou.amine.apps.readerforselfossv2.android
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
@@ -32,6 +31,7 @@ import bou.amine.apps.readerforselfossv2.android.settings.SettingsActivity
|
||||
import bou.amine.apps.readerforselfossv2.android.testing.CountingIdlingResourceSingleton
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.bottombar.maybeShow
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.bottombar.removeBadge
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openUrlInBrowser
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||
@@ -589,9 +589,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.issue_tracker -> {
|
||||
val browserIntent =
|
||||
Intent(Intent.ACTION_VIEW, Uri.parse(AppSettingsService.trackerUrl))
|
||||
startActivity(browserIntent)
|
||||
baseContext.openUrlInBrowser(AppSettingsService.trackerUrl)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@@ -8,11 +8,11 @@ import android.widget.ImageView.ScaleType
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.databinding.CardItemBinding
|
||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.bitmapCenterCrop
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openInBrowserAsNewTask
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openItemUrlInBrowserAsNewTask
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.shareLink
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
@@ -71,7 +71,7 @@ class ItemCardAdapter(
|
||||
}
|
||||
|
||||
binding.browserBtn.setOnClickListener {
|
||||
c.openInBrowserAsNewTask(items[position])
|
||||
c.openItemUrlInBrowserAsNewTask(items[position])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,4 +126,4 @@ class ItemCardAdapter(
|
||||
}
|
||||
|
||||
inner class ViewHolder(val binding: CardItemBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
}
|
||||
}
|
@@ -6,8 +6,8 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.databinding.ListItemBinding
|
||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.LinkOnTouchListener
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.circularDrawable
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
@@ -73,4 +73,4 @@ class ItemListAdapter(
|
||||
}
|
||||
|
||||
inner class ViewHolder(val binding: ListItemBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
}
|
||||
}
|
@@ -1,16 +1,20 @@
|
||||
package bou.amine.apps.readerforselfossv2.android.fragments
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.content.res.TypedArray
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Typeface
|
||||
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.WebResourceResponse
|
||||
import android.webkit.WebSettings
|
||||
import android.webkit.WebView
|
||||
@@ -25,10 +29,11 @@ import bou.amine.apps.readerforselfossv2.android.databinding.FragmentArticleBind
|
||||
import bou.amine.apps.readerforselfossv2.android.model.ParecelableItem
|
||||
import bou.amine.apps.readerforselfossv2.android.model.toModel
|
||||
import bou.amine.apps.readerforselfossv2.android.model.toParcelable
|
||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.getBitmapInputStream
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.isUrlValid
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openInBrowserAsNewTask
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openItemUrlInBrowserAsNewTask
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openUrlInBrowser
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.shareLink
|
||||
import bou.amine.apps.readerforselfossv2.model.MercuryModel
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
@@ -47,13 +52,14 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.acra.ktx.sendSilentlyWithAcra
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.DIAware
|
||||
import org.kodein.di.android.x.closestDI
|
||||
import org.kodein.di.instance
|
||||
import java.net.MalformedURLException
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.ExecutionException
|
||||
|
||||
private const val IMAGE_JPG = "image/jpg"
|
||||
@@ -98,7 +104,12 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
try {
|
||||
binding = FragmentArticleBinding.inflate(inflater, container, false)
|
||||
|
||||
url = item.getLinkDecoded()
|
||||
try {
|
||||
url = item.getLinkDecoded()
|
||||
} catch (e: Exception) {
|
||||
e.sendSilentlyWithAcra()
|
||||
}
|
||||
|
||||
contentText = item.content
|
||||
contentTitle = item.title.getHtmlDecoded()
|
||||
contentImage = item.getThumbnail(repository.baseUrl)
|
||||
@@ -152,7 +163,7 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
)
|
||||
} catch (e: InflateException) {
|
||||
e.sendSilentlyWithAcraWithName("webview not available")
|
||||
if (context != null) {
|
||||
try {
|
||||
AlertDialog.Builder(requireContext())
|
||||
.setMessage(requireContext().getString(R.string.webview_dialog_issue_message))
|
||||
.setTitle(requireContext().getString(R.string.webview_dialog_issue_title))
|
||||
@@ -164,6 +175,8 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
}
|
||||
.create()
|
||||
.show()
|
||||
} catch (e: IllegalStateException) {
|
||||
e.sendSilentlyWithAcraWithName("Context required is null")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,16 +224,16 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
override fun onItemClick(item: MenuItem) {
|
||||
when (item.itemId) {
|
||||
R.id.share_action -> requireActivity().shareLink(url, contentTitle)
|
||||
R.id.open_action -> requireActivity().openInBrowserAsNewTask(this@ArticleFragment.item)
|
||||
R.id.open_action -> requireActivity().openItemUrlInBrowserAsNewTask(this@ArticleFragment.item)
|
||||
R.id.unread_action ->
|
||||
if (context != null) {
|
||||
try {
|
||||
if (this@ArticleFragment.item.unread) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.markAsRead(this@ArticleFragment.item)
|
||||
}
|
||||
this@ArticleFragment.item.unread = false
|
||||
Toast.makeText(
|
||||
context,
|
||||
requireContext(),
|
||||
R.string.marked_as_read,
|
||||
Toast.LENGTH_LONG,
|
||||
).show()
|
||||
@@ -235,7 +248,10 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
Toast.LENGTH_LONG,
|
||||
).show()
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
e.sendSilentlyWithAcraWithName("Context required is null")
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -320,11 +336,7 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
url: String,
|
||||
): Boolean {
|
||||
return if (context != null && url.isUrlValid() && binding.webcontent.hitTestResult.type != WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
|
||||
try {
|
||||
requireContext().startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
e.sendSilentlyWithAcraWithName("activityNotFound > $url")
|
||||
}
|
||||
requireContext().openUrlInBrowser(url)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
@@ -343,7 +355,8 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
) {
|
||||
try {
|
||||
val image =
|
||||
Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get()
|
||||
Glide.with(view).asBitmap().apply(glideOptions).load(url).submit()
|
||||
.get()
|
||||
return WebResourceResponse(
|
||||
IMAGE_JPG,
|
||||
"UTF-8",
|
||||
@@ -355,7 +368,8 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
} else if (url.lowercase(Locale.US).contains(".png")) {
|
||||
try {
|
||||
val image =
|
||||
Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get()
|
||||
Glide.with(view).asBitmap().apply(glideOptions).load(url).submit()
|
||||
.get()
|
||||
return WebResourceResponse(
|
||||
IMAGE_JPG,
|
||||
"UTF-8",
|
||||
@@ -367,7 +381,8 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
} else if (url.lowercase(Locale.US).contains(".webp")) {
|
||||
try {
|
||||
val image =
|
||||
Glide.with(view).asBitmap().apply(glideOptions).load(url).submit().get()
|
||||
Glide.with(view).asBitmap().apply(glideOptions).load(url).submit()
|
||||
.get()
|
||||
return WebResourceResponse(
|
||||
IMAGE_JPG,
|
||||
"UTF-8",
|
||||
@@ -384,7 +399,7 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
}
|
||||
|
||||
private fun htmlToWebview() {
|
||||
if (context != null) {
|
||||
try {
|
||||
val attrs: IntArray = intArrayOf(android.R.attr.fontFamily)
|
||||
val a: TypedArray = requireContext().obtainStyledAttributes(resId, attrs)
|
||||
|
||||
@@ -529,6 +544,8 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
"utf-8",
|
||||
null,
|
||||
)
|
||||
} catch (e: IllegalStateException) {
|
||||
e.sendSilentlyWithAcraWithName("Context required is null")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,10 +561,10 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
|
||||
private fun openInBrowserAfterFailing() {
|
||||
binding.progressBar.visibility = View.GONE
|
||||
if (context != null) {
|
||||
requireContext().openInBrowserAsNewTask(this@ArticleFragment.item)
|
||||
} else {
|
||||
Exception("openInBrowserAfterFailing context is null").sendSilentlyWithAcraWithName("openInBrowserAfterFailing > $context")
|
||||
try {
|
||||
requireContext().openItemUrlInBrowserAsNewTask(this@ArticleFragment.item)
|
||||
} catch (e: IllegalStateException) {
|
||||
e.sendSilentlyWithAcraWithName("Context required is null")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -565,9 +582,9 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
|
||||
fun performClick(): Boolean {
|
||||
if (allImages != null && (
|
||||
binding.webcontent.hitTestResult.type == WebView.HitTestResult.IMAGE_TYPE ||
|
||||
binding.webcontent.hitTestResult.type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
||||
)
|
||||
binding.webcontent.hitTestResult.type == WebView.HitTestResult.IMAGE_TYPE ||
|
||||
binding.webcontent.hitTestResult.type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE
|
||||
)
|
||||
) {
|
||||
val position: Int = allImages.indexOf(binding.webcontent.hitTestResult.extra)
|
||||
|
||||
@@ -579,4 +596,4 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,7 +15,7 @@ import android.view.ViewGroup
|
||||
import bou.amine.apps.readerforselfossv2.android.HomeActivity
|
||||
import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.databinding.FilterFragmentBinding
|
||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||
import bou.amine.apps.readerforselfossv2.utils.getColorHexCode
|
||||
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
|
||||
@@ -52,19 +52,17 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
|
||||
false,
|
||||
)
|
||||
|
||||
val context: Context? = context
|
||||
|
||||
if (context == null) {
|
||||
dismiss()
|
||||
Exception("FilterSheetFragment context is null").sendSilentlyWithAcraWithName("FilterSheetFragment > onCreateView")
|
||||
} else {
|
||||
try {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
handleTagChips(context)
|
||||
handleSourceChips(context)
|
||||
handleTagChips(requireContext())
|
||||
handleSourceChips(requireContext())
|
||||
|
||||
binding.progressBar2.visibility = GONE
|
||||
binding.filterView.visibility = VISIBLE
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
dismiss()
|
||||
e.sendSilentlyWithAcraWithName("FilterSheetFragment > onCreateView")
|
||||
}
|
||||
|
||||
binding.floatingActionButton2.setOnClickListener {
|
||||
@@ -192,4 +190,4 @@ class FilterSheetFragment : BottomSheetDialogFragment(), DIAware {
|
||||
companion object {
|
||||
const val TAG = "FilterModalBottomSheet"
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@ package bou.amine.apps.readerforselfossv2.android.model
|
||||
|
||||
import android.content.Context
|
||||
import android.webkit.URLUtil
|
||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.getImages
|
||||
import com.bumptech.glide.Glide
|
||||
@@ -40,4 +40,4 @@ fun String.toTextDrawableString(): String {
|
||||
}
|
||||
}
|
||||
return textDrawable.toString()
|
||||
}
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
package bou.amine.apps.readerforselfossv2.android.settings
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.InputFilter
|
||||
@@ -16,7 +14,8 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.databinding.ActivitySettingsBinding
|
||||
import bou.amine.apps.readerforselfossv2.android.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.acra.sendSilentlyWithAcraWithName
|
||||
import bou.amine.apps.readerforselfossv2.android.utils.openUrlInBrowser
|
||||
import bou.amine.apps.readerforselfossv2.service.AppSettingsService
|
||||
import com.mikepenz.aboutlibraries.LibsBuilder
|
||||
import org.kodein.di.DIAware
|
||||
@@ -105,7 +104,9 @@ class SettingsActivity :
|
||||
|
||||
preferenceManager.findPreference<Preference>("currentMode")?.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt()) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
newValue.toString().toInt()
|
||||
) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯
|
||||
true
|
||||
}
|
||||
|
||||
@@ -129,7 +130,8 @@ class SettingsActivity :
|
||||
) {
|
||||
setPreferencesFromResource(R.xml.pref_general, rootKey)
|
||||
|
||||
val editTextPreference = preferenceManager.findPreference<EditTextPreference>("prefer_api_items_number")
|
||||
val editTextPreference =
|
||||
preferenceManager.findPreference<EditTextPreference>("prefer_api_items_number")
|
||||
editTextPreference?.setOnBindEditTextListener { editText ->
|
||||
editText.inputType = InputType.TYPE_CLASS_NUMBER
|
||||
editText.filters =
|
||||
@@ -139,8 +141,11 @@ class SettingsActivity :
|
||||
val input: Int = (dest.toString() + source.toString()).toInt()
|
||||
if (input in 1..200) return@InputFilter null
|
||||
} catch (nfe: NumberFormatException) {
|
||||
nfe.sendSilentlyWithAcraWithName("GeneralPreferenceFragment")
|
||||
Toast.makeText(activity, R.string.items_number_should_be_number, Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(
|
||||
activity,
|
||||
R.string.items_number_should_be_number,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
""
|
||||
},
|
||||
@@ -222,16 +227,17 @@ class SettingsActivity :
|
||||
|
||||
preferenceManager.findPreference<Preference>("currentMode")?.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt()) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
newValue.toString().toInt()
|
||||
) // ListPreference Only takes string-arrays ¯\_(ツ)_/¯
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LinksPreferenceFragment : PreferenceFragmentCompat() {
|
||||
private fun openUrl(uri: Uri?) {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, uri)
|
||||
startActivity(browserIntent)
|
||||
private fun openUrl(url: String) {
|
||||
context?.openUrlInBrowser(url)
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(
|
||||
@@ -242,19 +248,19 @@ class SettingsActivity :
|
||||
|
||||
preferenceManager.findPreference<Preference>("trackerLink")?.onPreferenceClickListener =
|
||||
Preference.OnPreferenceClickListener {
|
||||
openUrl(Uri.parse(AppSettingsService.trackerUrl))
|
||||
openUrl(AppSettingsService.trackerUrl)
|
||||
true
|
||||
}
|
||||
|
||||
preferenceManager.findPreference<Preference>("sourceLink")?.onPreferenceClickListener =
|
||||
Preference.OnPreferenceClickListener {
|
||||
openUrl(Uri.parse(AppSettingsService.sourceUrl))
|
||||
openUrl(AppSettingsService.sourceUrl)
|
||||
false
|
||||
}
|
||||
|
||||
preferenceManager.findPreference<Preference>("translation")?.onPreferenceClickListener =
|
||||
Preference.OnPreferenceClickListener {
|
||||
openUrl(Uri.parse(AppSettingsService.translationUrl))
|
||||
openUrl(AppSettingsService.translationUrl)
|
||||
false
|
||||
}
|
||||
}
|
||||
@@ -268,4 +274,4 @@ class SettingsActivity :
|
||||
setPreferencesFromResource(R.xml.pref_experimental, rootKey)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package bou.amine.apps.readerforselfossv2.android.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
@@ -17,6 +18,7 @@ import bou.amine.apps.readerforselfossv2.model.SelfossModel
|
||||
import bou.amine.apps.readerforselfossv2.utils.toStringUriWithHttp
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
|
||||
|
||||
fun Context.openItemUrl(
|
||||
currentItem: Int,
|
||||
linkDecoded: String,
|
||||
@@ -35,15 +37,13 @@ fun Context.openItemUrl(
|
||||
intent.putExtra("currentItem", currentItem)
|
||||
app.startActivity(intent)
|
||||
} else {
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
intent.data = Uri.parse(linkDecoded.toStringUriWithHttp())
|
||||
startActivity(intent)
|
||||
this.openUrlInBrowserAsNewTask(linkDecoded)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun String.isUrlValid(): Boolean = this.toHttpUrlOrNull() != null && Patterns.WEB_URL.matcher(this).matches()
|
||||
fun String.isUrlValid(): Boolean =
|
||||
this.toHttpUrlOrNull() != null && Patterns.WEB_URL.matcher(this).matches()
|
||||
|
||||
fun String.isBaseUrlInvalid(): Boolean {
|
||||
val baseUrl = this.toHttpUrlOrNull()
|
||||
@@ -56,11 +56,31 @@ fun String.isBaseUrlInvalid(): Boolean {
|
||||
return !(Patterns.WEB_URL.matcher(this).matches() && existsAndEndsWithSlash)
|
||||
}
|
||||
|
||||
fun Context.openInBrowserAsNewTask(i: SelfossModel.Item) {
|
||||
fun Context.openItemUrlInBrowserAsNewTask(i: SelfossModel.Item) {
|
||||
this.openUrlInBrowserAsNewTask(i.getLinkDecoded().toStringUriWithHttp())
|
||||
}
|
||||
|
||||
fun Context.openUrlInBrowserAsNewTask(url: String) {
|
||||
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
intent.data = Uri.parse(i.getLinkDecoded().toStringUriWithHttp())
|
||||
startActivity(intent)
|
||||
intent.data = Uri.parse(url)
|
||||
this.mayBeStartActivity(intent)
|
||||
}
|
||||
|
||||
fun Context.openUrlInBrowser(url: String) {
|
||||
val intent = Intent(Intent.ACTION_VIEW)
|
||||
intent.data = Uri.parse(url)
|
||||
this.mayBeStartActivity(intent)
|
||||
}
|
||||
|
||||
fun Context.mayBeStartActivity(intent: Intent) {
|
||||
try {
|
||||
this.startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Toast.makeText(this, getString(R.string.no_browser), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LinkOnTouchListener : View.OnTouchListener {
|
||||
@@ -102,4 +122,4 @@ class LinkOnTouchListener : View.OnTouchListener {
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package bou.amine.apps.readerforselfossv2.android
|
||||
package bou.amine.apps.readerforselfossv2.android.utils.acra
|
||||
|
||||
import org.acra.ACRA
|
||||
import org.acra.ktx.sendSilentlyWithAcra
|
||||
@@ -6,4 +6,4 @@ import org.acra.ktx.sendSilentlyWithAcra
|
||||
fun Throwable.sendSilentlyWithAcraWithName(name: String) {
|
||||
ACRA.errorReporter.putCustomData("error_source", name)
|
||||
this.sendSilentlyWithAcra()
|
||||
}
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package bou.amine.apps.readerforselfossv2.android.utils.acra
|
||||
|
||||
import android.content.Context
|
||||
import android.os.DeadSystemException
|
||||
import com.google.auto.service.AutoService
|
||||
import org.acra.builder.ReportBuilder
|
||||
import org.acra.config.CoreConfiguration
|
||||
import org.acra.config.ReportingAdministrator
|
||||
import org.acra.data.CrashReportData
|
||||
|
||||
|
||||
@AutoService(ReportingAdministrator::class)
|
||||
class AcraReportingAdministrator : ReportingAdministrator {
|
||||
override fun shouldStartCollecting(
|
||||
context: Context,
|
||||
config: CoreConfiguration,
|
||||
reportBuilder: ReportBuilder
|
||||
): Boolean {
|
||||
return reportBuilder.exception !is DeadSystemException
|
||||
}
|
||||
|
||||
override fun shouldSendReport(
|
||||
context: Context,
|
||||
config: CoreConfiguration,
|
||||
crashReportData: CrashReportData
|
||||
): Boolean {
|
||||
return crashReportData.get("BRAND") != "redroid"
|
||||
}
|
||||
}
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
</resources>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"No hi ha res"</string>
|
||||
<string name="tab_new">"Nou"</string>
|
||||
<string name="tab_read">"Tot"</string>
|
||||
<string name="tab_favs">"Preferits"</string>
|
||||
<string name="action_about">"Quant a"</string>
|
||||
<string name="marked_as_read">"Element llegit"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Quelle aktualisieren</string>
|
||||
<string name="confirm_disconnect_title">Verbindung trennen?</string>
|
||||
<string name="confirm_disconnect_description">Die Verbindung zur Selfoss-Instanz wird getrennt.</string>
|
||||
</resources>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Keine Einträge vorhanden"</string>
|
||||
<string name="tab_new">"Neu"</string>
|
||||
<string name="tab_read">"Alle"</string>
|
||||
<string name="tab_favs">"Favoriten"</string>
|
||||
<string name="action_about">"Über"</string>
|
||||
<string name="marked_as_read">"Artikel gelesen"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Nada aquí"</string>
|
||||
<string name="tab_new">"Nuevo"</string>
|
||||
<string name="tab_read">"Todo"</string>
|
||||
<string name="tab_favs">"Favoritos"</string>
|
||||
<string name="action_about">"Acerca de"</string>
|
||||
<string name="marked_as_read">"Artículo leído"</string>
|
||||
<string name="marked_as_unread">"Artículo no leído"</string>
|
||||
</resources>
|
@@ -115,7 +115,7 @@
|
||||
<string name="mode_system">Utiliser les paramètres système</string>
|
||||
<string name="mode_light">Thème clair</string>
|
||||
<string name="gdpr_dialog_title">L\'application ne partage aucune information personnelle.</string>
|
||||
<string name="gdpr_dialog_message"><![CDATA[Le rapport de plantage est activés par défaut. Il peut être désactivé depuis les paramètres de l'application. Notez que les rapports de plantage sont essentiels pour le développement de l'application.]]></string>
|
||||
<string name="gdpr_dialog_message"><![CDATA[Le rapport de plantage est activés par défaut. Il peut être désactivé depuis les paramètres de l\'application. Notez que les rapports de plantage sont essentiels pour le développement de l\'application.]]></string>
|
||||
<string name="crash_toast_text">Un bug s\'est produit. Le développeur en sera informé.</string>
|
||||
<string name="pref_switch_disable_acra">"Désactiver les rapports de plantage."</string>
|
||||
<string name="menu_home_filter">Filtres</string>
|
||||
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Mise à jour des sources</string>
|
||||
<string name="confirm_disconnect_title">Se déconnecter ?</string>
|
||||
<string name="confirm_disconnect_description">Vous allez être déconnecté de votre instance Selfoss.</string>
|
||||
</resources>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Il n'y a rien ici !"</string>
|
||||
<string name="tab_new">"Non lus"</string>
|
||||
<string name="tab_read">"Tous"</string>
|
||||
<string name="tab_favs">"Favoris"</string>
|
||||
<string name="action_about">"À propos"</string>
|
||||
<string name="marked_as_read">"Marqué comme lu"</string>
|
||||
<string name="marked_as_unread">"Marqué comme non lu"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Non hai nada aquí"</string>
|
||||
<string name="tab_new">"Novo"</string>
|
||||
<string name="tab_read">"Todos"</string>
|
||||
<string name="tab_favs">"Favoritos"</string>
|
||||
<string name="action_about">"Acerca de"</string>
|
||||
<string name="marked_as_read">"Elemento lido"</string>
|
||||
<string name="marked_as_unread">"Elemento non lido"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Tidak ada di sini"</string>
|
||||
<string name="tab_new">"Baru"</string>
|
||||
<string name="tab_read">"Semua"</string>
|
||||
<string name="tab_favs">"Favorit"</string>
|
||||
<string name="action_about">"Tentang"</string>
|
||||
<string name="marked_as_read">"Membaca item"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Non c'è niente qui"</string>
|
||||
<string name="tab_new">"Nuovi"</string>
|
||||
<string name="tab_read">"Tutti"</string>
|
||||
<string name="tab_favs">"Preferiti"</string>
|
||||
<string name="action_about">"Informazioni"</string>
|
||||
<string name="marked_as_read">"Articolo letto"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"비어있음"</string>
|
||||
<string name="tab_new">"새로운"</string>
|
||||
<string name="tab_read">"전체"</string>
|
||||
<string name="tab_favs">"즐겨찾기"</string>
|
||||
<string name="action_about">"정보"</string>
|
||||
<string name="marked_as_read">"항목 읽기"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -23,7 +23,6 @@
|
||||
<string name="wrong_infos">"Controleer de gegevens nogmaals."</string>
|
||||
<string name="all_posts_not_read">"Fout bij markeren als gelezen"</string>
|
||||
<string name="all_posts_read">"Alle artikelen gemarkeerd als gelezen"</string>
|
||||
<string name="undo_string">"Ongedaan maken"</string>
|
||||
<string name="addStringNoUrl">"Login om bronnen toe te voegen"</string>
|
||||
<string name="cant_get_sources">"Kan de lijst met bronnen niet ophalen"</string>
|
||||
<string name="cant_create_source">"Kan bron niet creëeren"</string>
|
||||
@@ -124,4 +123,13 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Niets gevonden"</string>
|
||||
<string name="tab_new">"Nieuw"</string>
|
||||
<string name="tab_read">"Alle"</string>
|
||||
<string name="tab_favs">"Favorieten"</string>
|
||||
<string name="action_about">"Over"</string>
|
||||
<string name="marked_as_read">"Artikel gelezen"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
<string name="undo_string">"Ongedaan maken"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Nada aqui"</string>
|
||||
<string name="tab_new">"Novo"</string>
|
||||
<string name="tab_read">"Todos"</string>
|
||||
<string name="tab_favs">"Favoritos"</string>
|
||||
<string name="action_about">"Sobre"</string>
|
||||
<string name="marked_as_read">"Item lido"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Nada aqui"</string>
|
||||
<string name="tab_new">"Novo"</string>
|
||||
<string name="tab_read">"Tudo"</string>
|
||||
<string name="tab_favs">"Favoritos"</string>
|
||||
<string name="action_about">"Sobre"</string>
|
||||
<string name="marked_as_read">"Item lido"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Nothing here"</string>
|
||||
<string name="tab_new">"New"</string>
|
||||
<string name="tab_read">"සියල්ල"</string>
|
||||
<string name="tab_favs">"Favorites"</string>
|
||||
<string name="action_about">"මේ ගැන"</string>
|
||||
<string name="marked_as_read">"Item read"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Burada hiçbir şey yok"</string>
|
||||
<string name="tab_new">"Yeni"</string>
|
||||
<string name="tab_read">"Tüm"</string>
|
||||
<string name="tab_favs">"Favoriler"</string>
|
||||
<string name="action_about">"Hakkında"</string>
|
||||
<string name="marked_as_read">"Öğeleri oku"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">更新源</string>
|
||||
<string name="confirm_disconnect_title">断开连接?</string>
|
||||
<string name="confirm_disconnect_description">您将断开与 selfoss 实例的连接。</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"暂无内容!"</string>
|
||||
<string name="tab_new">"新建"</string>
|
||||
<string name="tab_read">"所有"</string>
|
||||
<string name="tab_favs">"收藏夹"</string>
|
||||
<string name="action_about">"关于我们"</string>
|
||||
<string name="marked_as_read">"已读"</string>
|
||||
<string name="marked_as_unread">"未读条目"</string>
|
||||
</resources>
|
@@ -124,4 +124,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"暂无内容!"</string>
|
||||
<string name="tab_new">"新建"</string>
|
||||
<string name="tab_read">"所有"</string>
|
||||
<string name="tab_favs">"收藏夹"</string>
|
||||
<string name="action_about">"关于我们"</string>
|
||||
<string name="marked_as_read">"已读"</string>
|
||||
<string name="marked_as_unread">"未讀項目"</string>
|
||||
</resources>
|
@@ -126,4 +126,12 @@
|
||||
<string name="update_source">Update source</string>
|
||||
<string name="confirm_disconnect_title">Disconnect ?</string>
|
||||
<string name="confirm_disconnect_description">You will be disconnected from your selfoss instance.</string>
|
||||
<string name="no_browser">Can\'t open a link without a browser installed</string>
|
||||
<string name="nothing_here">"Nothing here"</string>
|
||||
<string name="tab_new">"New"</string>
|
||||
<string name="tab_read">"All"</string>
|
||||
<string name="tab_favs">"Favorites"</string>
|
||||
<string name="action_about">"About"</string>
|
||||
<string name="marked_as_read">"Item read"</string>
|
||||
<string name="marked_as_unread">"Item unread"</string>
|
||||
</resources>
|
@@ -3,3 +3,4 @@ files:
|
||||
translation: /androidApp/src/main/res/values-%android_code%/%original_file_name%
|
||||
translate_attributes: '0'
|
||||
content_segmentation: '0'
|
||||
preserve_hierarchy: true
|
@@ -2,6 +2,7 @@ package bou.amine.apps.readerforselfossv2.model
|
||||
|
||||
import bou.amine.apps.readerforselfossv2.utils.DateUtils
|
||||
import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded
|
||||
import bou.amine.apps.readerforselfossv2.utils.isEmptyOrNullOrNullString
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.PrimitiveKind
|
||||
@@ -10,7 +11,12 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlinx.serialization.encoding.encodeCollection
|
||||
import kotlinx.serialization.json.*
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonDecoder
|
||||
import kotlinx.serialization.json.boolean
|
||||
import kotlinx.serialization.json.booleanOrNull
|
||||
import kotlinx.serialization.json.int
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
|
||||
class SelfossModel {
|
||||
@Serializable
|
||||
@@ -134,6 +140,10 @@ class SelfossModel {
|
||||
stringUrl = "http:$stringUrl"
|
||||
}
|
||||
|
||||
if (stringUrl.isEmptyOrNullOrNullString()) {
|
||||
throw Exception("Link ${link} was translated to ${stringUrl}, but was empty. Handle this.")
|
||||
}
|
||||
|
||||
return stringUrl
|
||||
}
|
||||
|
||||
@@ -176,7 +186,10 @@ class SelfossModel {
|
||||
encoder: Encoder,
|
||||
value: List<String>,
|
||||
) {
|
||||
encoder.encodeCollection(PrimitiveSerialDescriptor("tags", PrimitiveKind.STRING), value.size) { this.toString() }
|
||||
encoder.encodeCollection(
|
||||
PrimitiveSerialDescriptor("tags", PrimitiveKind.STRING),
|
||||
value.size
|
||||
) { this.toString() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +204,10 @@ class SelfossModel {
|
||||
}
|
||||
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = PrimitiveSerialDescriptor("BooleanOrIntForSomeSelfossVersions", PrimitiveKind.BOOLEAN)
|
||||
get() = PrimitiveSerialDescriptor(
|
||||
"BooleanOrIntForSomeSelfossVersions",
|
||||
PrimitiveKind.BOOLEAN
|
||||
)
|
||||
|
||||
override fun serialize(
|
||||
encoder: Encoder,
|
||||
@@ -200,4 +216,4 @@ class SelfossModel {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,10 +30,14 @@ suspend fun maybeResponse(r: HttpResponse?): SuccessResponse {
|
||||
}
|
||||
|
||||
suspend inline fun <reified T> bodyOrFailure(r: HttpResponse?): StatusAndData<T> {
|
||||
return if (r != null && r.status.isSuccess()) {
|
||||
StatusAndData.succes(r.body())
|
||||
} else {
|
||||
StatusAndData.error()
|
||||
try {
|
||||
return if (r != null && r.status.isSuccess()) {
|
||||
StatusAndData.succes(r.body())
|
||||
} else {
|
||||
StatusAndData.error()
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
return StatusAndData.error()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,4 +98,4 @@ suspend fun HttpClient.tryToSubmitForm(
|
||||
url(url)
|
||||
block()
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,12 +2,8 @@ package bou.amine.apps.readerforselfossv2.utils
|
||||
|
||||
actual class DateUtils {
|
||||
actual companion object {
|
||||
actual fun parseDate(dateString: String): Long {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun parseRelativeDate(dateString: String): String {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -2,12 +2,8 @@ package bou.amine.apps.readerforselfossv2.utils
|
||||
|
||||
actual class DateUtils {
|
||||
actual companion object {
|
||||
actual fun parseDate(dateString: String): Long {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
actual fun parseRelativeDate(dateString: String): String {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user