Skip to content

Commit

Permalink
76
Browse files Browse the repository at this point in the history
76
  • Loading branch information
umerov1999 committed Dec 15, 2024
1 parent b59e189 commit bbf9c05
Show file tree
Hide file tree
Showing 328 changed files with 2,105 additions and 1,365 deletions.
3 changes: 2 additions & 1 deletion app_fenrir/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ android {
//noinspection ChromeOsAbiSupport
abiFilters = targetAbi
}
resConfigs "en", "ru"
androidResources.localeFilters = ["en", "ru"]
}

lint {
Expand All @@ -67,6 +67,7 @@ android {
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.serialization.internal.CoreFriendModuleApi",
"-opt-in=kotlinx.serialization.SealedSerializationApi",
"-opt-in=kotlinx.serialization.InternalSerializationApi",
"-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.ExperimentalStdlibApi"]
}
Expand Down
2 changes: 1 addition & 1 deletion app_fenrir/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
android:theme="@style/App.DayNight.Swipes"
android:windowSoftInputMode="adjustResize|stateHidden">

<intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
Expand Down
12 changes: 11 additions & 1 deletion app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@ import android.view.View
import androidx.annotation.ColorInt
import androidx.core.database.getBlobOrNull
import androidx.core.database.getStringOrNull
import dev.ragnarok.fenrir.util.serializeble.json.Json
import kotlinx.serialization.json.Json
import okhttp3.ResponseBody
import java.io.Serializable
import kotlin.contracts.contract

val kJson: Json by lazy { Json { ignoreUnknownKeys = true; isLenient = true } }
val kJsonPretty: Json by lazy {
Json {
ignoreUnknownKeys = true; isLenient = true; prettyPrint = true
}
}
val kJsonNotPretty: Json by lazy {
Json {
ignoreUnknownKeys = true; isLenient = true; prettyPrint = false
}
}

fun SQLiteDatabase.query(
tableName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import dev.ragnarok.fenrir.settings.Settings
import dev.ragnarok.fenrir.util.Logger
import dev.ragnarok.fenrir.util.PersistentLogger
import dev.ragnarok.fenrir.util.coroutines.CoroutinesUtils.hiddenIO
import dev.ragnarok.fenrir.util.serializeble.json.Json
import kotlinx.serialization.builtins.MapSerializer
import kotlinx.serialization.builtins.serializer

Expand Down Expand Up @@ -60,9 +59,7 @@ class FcmListenerService : FirebaseMessagingService() {
if (Constants.IS_DEBUG) {
Logger.d(
TAG,
"onMessage, from: " + message.from + ", pushType: " + pushType + ", data: " + Json {
prettyPrint = true
}.encodeToString(
"onMessage, from: " + message.from + ", pushType: " + pushType + ", data: " + kJsonPretty.encodeToString(
MapSerializer(String.serializer(), String.serializer()),
message.data
)
Expand All @@ -71,9 +68,7 @@ class FcmListenerService : FirebaseMessagingService() {
PersistentLogger.logThrowable(
"Push received",
Exception(
"Key: $pushType, Dump: " + Json {
prettyPrint = true
}.encodeToString(
"Key: $pushType, Dump: " + kJsonPretty.encodeToString(
MapSerializer(String.serializer(), String.serializer()),
message.data
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import dev.ragnarok.fenrir.activity.slidr.model.SlidrPosition
import dev.ragnarok.fenrir.fragment.absownerslist.OwnersAdapter
import dev.ragnarok.fenrir.getParcelableCompat
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.kJsonPretty
import dev.ragnarok.fenrir.listener.AppStyleable
import dev.ragnarok.fenrir.model.DeltaOwner
import dev.ragnarok.fenrir.model.Owner
Expand All @@ -51,9 +52,8 @@ import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.Utils.hasVanillaIceCreamTarget
import dev.ragnarok.fenrir.util.coroutines.CancelableJob
import dev.ragnarok.fenrir.util.coroutines.CoroutinesUtils.fromIOToMain
import dev.ragnarok.fenrir.util.serializeble.json.Json
import dev.ragnarok.fenrir.util.serializeble.json.decodeFromBufferedSource
import dev.ragnarok.fenrir.util.toast.CustomToast
import kotlinx.serialization.json.decodeFromBufferedSource
import okio.buffer
import okio.source
import java.io.File
Expand Down Expand Up @@ -135,7 +135,7 @@ class DeltaOwnerActivity : AppCompatActivity(), PlaceProvider, AppStyleable {
)
var out: FileOutputStream? = null
try {
val bytes = Json { prettyPrint = true }.encodeToString(
val bytes = kJsonPretty.encodeToString(
DeltaOwner.serializer(),
delta
).toByteArray(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ package dev.ragnarok.fenrir.api.adapters

import dev.ragnarok.fenrir.Constants
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonArray
import dev.ragnarok.fenrir.util.serializeble.json.JsonDecoder
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.JsonNull
import dev.ragnarok.fenrir.util.serializeble.json.JsonObject
import dev.ragnarok.fenrir.util.serializeble.json.JsonPrimitive
import dev.ragnarok.fenrir.util.serializeble.json.booleanOrNull
import dev.ragnarok.fenrir.util.serializeble.json.doubleOrNull
import dev.ragnarok.fenrir.util.serializeble.json.floatOrNull
import dev.ragnarok.fenrir.util.serializeble.json.intOrNull
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonPrimitive
import dev.ragnarok.fenrir.util.serializeble.json.longOrNull
import dev.ragnarok.fenrir.util.serializeble.msgpack.internal.BasicMsgPackDecoder
import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonDecoder
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.booleanOrNull
import kotlinx.serialization.json.doubleOrNull
import kotlinx.serialization.json.floatOrNull
import kotlinx.serialization.json.intOrNull
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.longOrNull
import kotlinx.serialization.msgpack.internal.BasicMsgPackDecoder
import kotlin.contracts.contract

abstract class AbsDtoAdapter<T>(name: String) : KSerializer<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.VKApiArticle
import dev.ragnarok.fenrir.api.model.VKApiPhoto
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import kotlinx.serialization.json.JsonElement

import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.jsonObject

class ArticleDtoAdapter : AbsDtoAdapter<VKApiArticle>("VKApiArticle") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import dev.ragnarok.fenrir.api.model.interfaces.VKApiAttachment
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.JsonObject
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject

class AttachmentsDtoAdapter : AbsDtoAdapter<VKApiAttachments>("VKApiAttachments") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import dev.ragnarok.fenrir.api.adapters.AttachmentsDtoAdapter.Companion.parse
import dev.ragnarok.fenrir.api.model.VKApiAttachments
import dev.ragnarok.fenrir.api.model.VKApiNotSupported
import dev.ragnarok.fenrir.api.model.interfaces.VKApiAttachment
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonObject

class AttachmentsEntryDtoAdapter : AbsDtoAdapter<VKApiAttachments.Entry>("VKApiAttachments.Entry") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.VKApiAudio
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.orZero
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject

class AudioDtoAdapter : AbsDtoAdapter<VKApiAudio>("VKApiAudio") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.ragnarok.fenrir.api.adapters

import dev.ragnarok.fenrir.api.model.VKApiAudioPlaylist
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject

class AudioPlaylistDtoAdapter : AbsDtoAdapter<VKApiAudioPlaylist>("VKApiAudioPlaylist") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import dev.ragnarok.fenrir.api.model.VKApiCommunity
import dev.ragnarok.fenrir.api.model.VKApiUser
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.orZero
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import dev.ragnarok.fenrir.util.serializeble.json.long
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.long

class ChatDtoAdapter : AbsDtoAdapter<VKApiChat>("VKApiChat") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.VKApiMessage
import dev.ragnarok.fenrir.api.model.local_json.ChatJsonResponse
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject

class ChatJsonResponseDtoAdapter : AbsDtoAdapter<ChatJsonResponse>("ChatJsonResponse") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.ChatUserDto
import dev.ragnarok.fenrir.api.model.VKApiUser
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonObject

class ChatUserDtoAdapter : AbsDtoAdapter<ChatUserDto>("ChatUserDto") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.VKApiChat
import dev.ragnarok.fenrir.api.model.response.ChatsInfoResponse
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonArray

class ChatsInfoDtoAdapter : AbsDtoAdapter<ChatsInfoResponse>("ChatsInfoResponse") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.VKApiAttachments
import dev.ragnarok.fenrir.api.model.VKApiComment
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonObject

class CommentDtoAdapter : AbsDtoAdapter<VKApiComment>("VKApiComment") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import dev.ragnarok.fenrir.api.Fields
import dev.ragnarok.fenrir.api.model.*
import dev.ragnarok.fenrir.api.util.VKStringUtils
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import java.util.Locale
import kotlin.math.abs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package dev.ragnarok.fenrir.api.adapters

import dev.ragnarok.fenrir.api.model.response.CustomCommentsResponse
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.intOrNull
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import dev.ragnarok.fenrir.util.serializeble.json.jsonPrimitive
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.intOrNull
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive

class CustomCommentsResponseDtoAdapter :
AbsDtoAdapter<CustomCommentsResponse>("CustomCommentsResponse") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package dev.ragnarok.fenrir.api.adapters

import dev.ragnarok.fenrir.api.model.VKApiDoc
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonObject

class DocsEntryDtoAdapter : AbsDtoAdapter<VKApiDoc.Entry>("VKApiDoc.Entry") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.FaveLinkDto
import dev.ragnarok.fenrir.api.model.VKApiPhoto
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.JsonObject
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject

class FaveLinkDtoAdapter : AbsDtoAdapter<FaveLinkDto>("FaveLinkDto") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package dev.ragnarok.fenrir.api.adapters
import dev.ragnarok.fenrir.api.model.*
import dev.ragnarok.fenrir.api.model.feedback.*
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.JsonObject
import dev.ragnarok.fenrir.util.serializeble.json.decodeFromJsonElementOrNull
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.decodeFromJsonElementOrNull
import kotlinx.serialization.json.jsonObject

class FeedbackDtoAdapter : AbsDtoAdapter<VKApiBaseFeedback>("VKApiBaseFeedback") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package dev.ragnarok.fenrir.api.adapters

import dev.ragnarok.fenrir.api.model.feedback.UserArray
import dev.ragnarok.fenrir.orZero
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject

class FeedbackUserArrayDtoAdapter : AbsDtoAdapter<UserArray>("UserArray") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import dev.ragnarok.fenrir.model.FeedbackVKOfficialList
import dev.ragnarok.fenrir.nonNullNoEmpty
import dev.ragnarok.fenrir.orZero
import dev.ragnarok.fenrir.util.Utils
import dev.ragnarok.fenrir.util.serializeble.json.*
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.json.*

class FeedbackVKOfficialDtoAdapter :
AbsDtoAdapter<FeedbackVKOfficialList>("FeedbackVKOfficialList") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.ragnarok.fenrir.api.adapters

import dev.ragnarok.fenrir.api.model.VKApiGeo
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.jsonObject

class GeoDtoAdapter : AbsDtoAdapter<VKApiGeo>("VKApiGeo") {
@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package dev.ragnarok.fenrir.api.adapters

import dev.ragnarok.fenrir.api.model.GroupSettingsDto
import dev.ragnarok.fenrir.kJson
import dev.ragnarok.fenrir.util.serializeble.json.JsonElement
import dev.ragnarok.fenrir.util.serializeble.json.int
import dev.ragnarok.fenrir.util.serializeble.json.jsonArray
import dev.ragnarok.fenrir.util.serializeble.json.jsonObject
import dev.ragnarok.fenrir.util.serializeble.json.jsonPrimitive
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.int
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive

class GroupSettingsDtoAdapter : AbsDtoAdapter<GroupSettingsDto>("GroupSettingsDto") {
@Throws(Exception::class)
Expand Down
Loading

0 comments on commit bbf9c05

Please sign in to comment.