Compare commits
	
		
			5 Commits
		
	
	
		
			da71de6806
			...
			v122092691
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | a76b3dd2a9 | ||
|  | 91aed5a777 | ||
|  | 8823cc6c6c | ||
|  | 74ef4da15b | ||
|  | bd96c67788 | 
| @@ -30,7 +30,7 @@ fun gitVersion(): String { | ||||
|         println("Tag found on current commit") | ||||
|         execWithOutput("git -C ../ describe --contains HEAD") | ||||
|     } | ||||
|     return process.replace("'", "").substring(1).replace("\\.", "").trim() | ||||
|     return process.replace("^0", "").replace("'", "").substring(1).replace("\\.", "").trim() | ||||
| } | ||||
|  | ||||
| fun versionCodeFromGit(): Int { | ||||
|   | ||||
| @@ -84,7 +84,7 @@ class AddSourceActivity : AppCompatActivity(), DIAware { | ||||
|         super.onResume() | ||||
|  | ||||
|         val baseUrl = appSettingsService.getBaseUrl() | ||||
|         if (baseUrl.isEmpty() || baseUrl.isBaseUrlInvalid(this@AddSourceActivity)) { | ||||
|         if (baseUrl.isEmpty() || baseUrl.isBaseUrlInvalid()) { | ||||
|             mustLoginToAddSource() | ||||
|         } else { | ||||
|             handleSpoutsSpinner(binding.spoutsSpinner, binding.progress, binding.formContainer) | ||||
|   | ||||
| @@ -95,6 +95,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar | ||||
|  | ||||
|     private val settingsLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { | ||||
|         appSettingsService.refreshUserSettings() | ||||
|         recreate() | ||||
|     } | ||||
|  | ||||
|     override val di by closestDI() | ||||
|   | ||||
| @@ -122,7 +122,7 @@ class LoginActivity : AppCompatActivity(), DIAware { | ||||
|         var cancel = false | ||||
|         var focusView: View? = null | ||||
|  | ||||
|         if (url.isBaseUrlInvalid(this@LoginActivity)) { | ||||
|         if (url.isBaseUrlInvalid()) { | ||||
|             binding.urlView.error = getString(R.string.login_url_problem) | ||||
|             focusView = binding.urlView | ||||
|             cancel = true | ||||
|   | ||||
| @@ -30,7 +30,7 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte | ||||
|         updateItems(this.items) | ||||
|     } | ||||
|  | ||||
|     private fun unmarkSnackbar(i: SelfossModel.Item, position: Int) { | ||||
|     private fun unmarkSnackbar(position: Int) { | ||||
|         val s = Snackbar | ||||
|             .make( | ||||
|                 app.findViewById(R.id.coordLayout), | ||||
| @@ -87,7 +87,7 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte | ||||
|             notifyItemChanged(position) | ||||
|         } | ||||
|         if (showSnackbar) { | ||||
|             unmarkSnackbar(i, position) | ||||
|             unmarkSnackbar(position) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -163,7 +163,7 @@ private fun openInBrowser(linkDecoded: String, app: Activity) { | ||||
| fun String.isUrlValid(): Boolean = | ||||
|     this.toHttpUrlOrNull() != null && Patterns.WEB_URL.matcher(this).matches() | ||||
|  | ||||
| fun String.isBaseUrlInvalid(ctx: Context): Boolean { | ||||
| fun String.isBaseUrlInvalid(): Boolean { | ||||
|     val baseUrl = this.toHttpUrlOrNull() | ||||
|     var existsAndEndsWithSlash = false | ||||
|     if (baseUrl != null) { | ||||
|   | ||||
| @@ -2,7 +2,14 @@ package bou.amine.apps.readerforselfossv2.model | ||||
|  | ||||
| import bou.amine.apps.readerforselfossv2.utils.DateUtils | ||||
| import bou.amine.apps.readerforselfossv2.utils.getHtmlDecoded | ||||
| import kotlinx.serialization.KSerializer | ||||
| import kotlinx.serialization.Serializable | ||||
| import kotlinx.serialization.descriptors.PrimitiveKind | ||||
| import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||||
| import kotlinx.serialization.descriptors.SerialDescriptor | ||||
| import kotlinx.serialization.encoding.Decoder | ||||
| import kotlinx.serialization.encoding.Encoder | ||||
| import kotlinx.serialization.json.* | ||||
|  | ||||
| class SelfossModel { | ||||
|  | ||||
| @@ -50,6 +57,7 @@ class SelfossModel { | ||||
|     data class Source( | ||||
|         val id: Int, | ||||
|         val title: String, | ||||
|         @Serializable(with = TagsListSerializer::class) | ||||
|         val tags: List<String>, | ||||
|         val spout: String, | ||||
|         val error: String, | ||||
| @@ -62,12 +70,15 @@ class SelfossModel { | ||||
|         val datetime: String, | ||||
|         val title: String, | ||||
|         val content: String, | ||||
|         @Serializable(with = BooleanSerializer::class) | ||||
|         var unread: Boolean, | ||||
|         @Serializable(with = BooleanSerializer::class) | ||||
|         var starred: Boolean, | ||||
|         val thumbnail: String?, | ||||
|         val icon: String?, | ||||
|         val link: String, | ||||
|         val sourcetitle: String, | ||||
|         @Serializable(with = TagsListSerializer::class) | ||||
|         val tags: List<String> | ||||
|     ) { | ||||
|         // TODO: maybe find a better way to handle these kind of urls | ||||
| @@ -106,6 +117,38 @@ class SelfossModel { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // TODO: this seems to be super slow. | ||||
|     object TagsListSerializer : KSerializer<List<String>> { | ||||
|         override fun deserialize(decoder: Decoder): List<String> { | ||||
|             return when(val json = ((decoder as JsonDecoder).decodeJsonElement())) { | ||||
|                 is JsonArray -> json.toList().map { it.toString() } | ||||
|                 else -> json.toString().split(",") | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         override val descriptor: SerialDescriptor | ||||
|             get() = PrimitiveSerialDescriptor("tags", PrimitiveKind.STRING) | ||||
|  | ||||
|         override fun serialize(encoder: Encoder, value: List<String>) { | ||||
|             TODO("Not yet implemented") | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     object BooleanSerializer : KSerializer<Boolean> { | ||||
|         override fun deserialize(decoder: Decoder): Boolean { | ||||
|             val json = ((decoder as JsonDecoder).decodeJsonElement()).jsonPrimitive | ||||
|             return json.booleanOrNull ?: json.int == 1 | ||||
|         } | ||||
|  | ||||
|         override val descriptor: SerialDescriptor | ||||
|             get() = PrimitiveSerialDescriptor("b", PrimitiveKind.BOOLEAN) | ||||
|  | ||||
|         override fun serialize(encoder: Encoder, value: Boolean) { | ||||
|             TODO("Not yet implemented") | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     class StatusAndData<T>(val success: Boolean, val data: T? = null) { | ||||
|         companion object { | ||||
|             fun <T> succes(d: T): StatusAndData<T> { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user