diff --git a/app/src/main/java/com/futo/platformplayer/Settings.kt b/app/src/main/java/com/futo/platformplayer/Settings.kt index 10ec5ae3..eb83e298 100644 --- a/app/src/main/java/com/futo/platformplayer/Settings.kt +++ b/app/src/main/java/com/futo/platformplayer/Settings.kt @@ -478,7 +478,6 @@ class Settings : FragmentedStorageFileJson() { var preferWebmAudio: Boolean = false; @FormField(R.string.allow_under_cutout, FieldForm.TOGGLE, R.string.allow_under_cutout_description, 16) - @FormFieldWarning(R.string.changing_this_field_requires_restart) var allowVideoToGoUnderCutout: Boolean = true; } diff --git a/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/models/JSArticle.kt b/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/models/JSArticle.kt new file mode 100644 index 00000000..2d0e8a65 --- /dev/null +++ b/app/src/main/java/com/futo/platformplayer/api/media/platforms/js/models/JSArticle.kt @@ -0,0 +1,78 @@ +package com.futo.platformplayer.api.media.platforms.js.models + +import com.caoccao.javet.values.reference.V8ValueObject +import com.futo.platformplayer.api.media.IPluginSourced +import com.futo.platformplayer.api.media.models.Thumbnails +import com.futo.platformplayer.api.media.models.contents.ContentType +import com.futo.platformplayer.api.media.models.post.TextType +import com.futo.platformplayer.api.media.platforms.js.SourcePluginConfig +import com.futo.platformplayer.getOrDefault +import com.futo.platformplayer.getOrThrow +import com.futo.platformplayer.getOrThrowNullableList +import kotlin.streams.toList + +open class JSArticle : JSContent, IPluginSourced { + final override val contentType: ContentType get() = ContentType.POST; + + val summary: String; + val thumbnails: Thumbnails?; + val segments: List; + + constructor(config: SourcePluginConfig, obj: V8ValueObject): super(config, obj) { + val contextName = "PlatformPost"; + + summary = _content.getOrThrow(config, "summary", contextName); + if(_content.has("thumbnails")) + thumbnails = Thumbnails.fromV8(config, _content.getOrThrow(config, "thumbnails", contextName)); + else + thumbnails = null; + + + segments = (obj.getOrThrowNullableList(config, "segments", contextName) + ?.map { fromV8Segment(config, it) } + ?.filterNotNull() ?: listOf()); + } + + + companion object { + fun fromV8Segment(config: SourcePluginConfig, obj: V8ValueObject): IJSArticleSegment? { + if(!obj.has("type")) + throw IllegalArgumentException("Object missing type field"); + return when(obj.getOrThrow(config, "type", "JSArticle.Segment")) { + SegmentType.TEXT -> JSTextSegment(config, obj); + SegmentType.IMAGES -> JSImagesSegment(config, obj); + else -> null; + } + } + } +} + +enum class SegmentType(i: Int) { + UNKNOWN(0), + TEXT(1), + IMAGES(2) +} + +interface IJSArticleSegment { + val type: SegmentType; +} +class JSTextSegment: IJSArticleSegment { + override val type = SegmentType.TEXT; + val textType: TextType; + val content: String; + + constructor(config: SourcePluginConfig, obj: V8ValueObject) { + val contextName = "JSTextSegment"; + textType = TextType.fromInt((obj.getOrDefault(config, "textType", contextName, null) ?: 0)); + content = obj.getOrDefault(config, "content", contextName, "") ?: ""; + } +} +class JSImagesSegment: IJSArticleSegment { + override val type = SegmentType.IMAGES; + val images: List; + + constructor(config: SourcePluginConfig, obj: V8ValueObject) { + val contextName = "JSTextSegment"; + images = obj.getOrThrowNullableList(config, "images", contextName) ?: listOf(); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/futo/platformplayer/views/fields/Field.kt b/app/src/main/java/com/futo/platformplayer/views/fields/Field.kt index 1b5a9282..9439d46a 100644 --- a/app/src/main/java/com/futo/platformplayer/views/fields/Field.kt +++ b/app/src/main/java/com/futo/platformplayer/views/fields/Field.kt @@ -13,6 +13,10 @@ annotation class FormField(val title: Int, val type: String, val subtitle: Int = @Retention(AnnotationRetention.RUNTIME) annotation class FormFieldWarning(val messageRes: Int) +@Target(AnnotationTarget.FIELD, AnnotationTarget.PROPERTY) +@Retention(AnnotationRetention.RUNTIME) +annotation class FormFieldHint(val messageRes: Int) + interface IField { var descriptor: FormField?; val obj : Any?; diff --git a/app/src/main/java/com/futo/platformplayer/views/fields/FieldForm.kt b/app/src/main/java/com/futo/platformplayer/views/fields/FieldForm.kt index 8412c98e..1262e345 100644 --- a/app/src/main/java/com/futo/platformplayer/views/fields/FieldForm.kt +++ b/app/src/main/java/com/futo/platformplayer/views/fields/FieldForm.kt @@ -293,6 +293,12 @@ class FieldForm : LinearLayout { }, UIDialogs.ActionStyle.PRIMARY)); } } + val hint = propertyMap[field.field]?.findAnnotation(); + if(hint != null){ + field.onChanged.subscribe { f, value, oldValue -> + UIDialogs.appToast(context.getString(hint.messageRes), false); + } + } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 888d7b8d..fda1c193 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -378,7 +378,7 @@ Prefer Webm Audio Codecs If player should prefer Webm codecs (opus) over mp4 codecs (AAC), may result in worse compatibility. Allow video under cutout - Allow video to go underneath the screen cutout in full-screen. + Allow video to go underneath the screen cutout in full-screen.\nMay require restart Allow fullscreen portrait Switch to Audio in Background Optimize bandwidth usage by switching to audio-only stream in background if available, may cause stutter