style: fix linter issues
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
3ddc125286
commit
745b3a3847
|
|
@ -3,8 +3,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cmark.h>
|
#include <cmark.h>
|
||||||
|
|
||||||
#define TAG "Stendal"
|
|
||||||
|
|
||||||
#define STENDAL_ASTNODE_CONSTRUCTOR_SIGNATURE "(ILjava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V"
|
#define STENDAL_ASTNODE_CONSTRUCTOR_SIGNATURE "(ILjava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Integer;)V"
|
||||||
|
|
||||||
namespace Stendal {
|
namespace Stendal {
|
||||||
|
|
@ -27,10 +25,6 @@ namespace Stendal {
|
||||||
return std::equal(suffix.rbegin(), suffix.rend(), value.rbegin());
|
return std::equal(suffix.rbegin(), suffix.rend(), value.rbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool paragraph_is_math(std::string const &value) {
|
|
||||||
return string_starts_with(value, "$") && string_ends_with(value, "$");
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(JNIEnv *env) {
|
void init(JNIEnv *env) {
|
||||||
jclass localArrayListClass = env->FindClass("java/util/ArrayList");
|
jclass localArrayListClass = env->FindClass("java/util/ArrayList");
|
||||||
arrayListClass = (jclass) env->NewGlobalRef(localArrayListClass);
|
arrayListClass = (jclass) env->NewGlobalRef(localArrayListClass);
|
||||||
|
|
@ -146,12 +140,12 @@ namespace Stendal {
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_chat_revolt_ndk_Stendal_init(JNIEnv *env, jobject thiz) {
|
Java_chat_revolt_ndk_Stendal_init(JNIEnv *env, [[maybe_unused]] jobject thiz) {
|
||||||
Stendal::init(env);
|
Stendal::init(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" JNIEXPORT jobject JNICALL
|
extern "C" JNIEXPORT jobject JNICALL
|
||||||
Java_chat_revolt_ndk_Stendal_render(JNIEnv *env, jobject thiz, jstring input) {
|
Java_chat_revolt_ndk_Stendal_render(JNIEnv *env, [[maybe_unused]] jobject thiz, jstring input) {
|
||||||
const char *inputStr = env->GetStringUTFChars(input, nullptr);
|
const char *inputStr = env->GetStringUTFChars(input, nullptr);
|
||||||
cmark_node *doc = cmark_parse_document(inputStr, strlen(inputStr),
|
cmark_node *doc = cmark_parse_document(inputStr, strlen(inputStr),
|
||||||
CMARK_OPT_DEFAULT | CMARK_OPT_HARDBREAKS |
|
CMARK_OPT_DEFAULT | CMARK_OPT_HARDBREAKS |
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ import chat.revolt.api.settings.GlobalState
|
||||||
import chat.revolt.api.settings.SyncedSettings
|
import chat.revolt.api.settings.SyncedSettings
|
||||||
import chat.revolt.provider.getAttachmentContentUri
|
import chat.revolt.provider.getAttachmentContentUri
|
||||||
import chat.revolt.ui.theme.RevoltTheme
|
import chat.revolt.ui.theme.RevoltTheme
|
||||||
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
|
|
||||||
import io.ktor.client.request.get
|
import io.ktor.client.request.get
|
||||||
import io.ktor.client.statement.readBytes
|
import io.ktor.client.statement.readBytes
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -84,7 +83,7 @@ class ImageViewActivity : ComponentActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalGlideComposeApi::class, ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
fun ImageViewScreen(resource: AutumnResource, onClose: () -> Unit = {}) {
|
||||||
val resourceUrl = "$REVOLT_FILES/attachments/${resource.id}/${resource.filename}"
|
val resourceUrl = "$REVOLT_FILES/attachments/${resource.id}/${resource.filename}"
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ enum class DisconnectionState {
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class RealtimeSocketFrames {
|
sealed class RealtimeSocketFrames {
|
||||||
data class Reconnected(val unit: Unit = Unit) : RealtimeSocketFrames()
|
data object Reconnected : RealtimeSocketFrames()
|
||||||
}
|
}
|
||||||
|
|
||||||
object RealtimeSocket {
|
object RealtimeSocket {
|
||||||
|
|
@ -598,6 +598,6 @@ object RealtimeSocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun pushReconnectEvent() {
|
private suspend fun pushReconnectEvent() {
|
||||||
RevoltAPI.wsFrameChannel.send(RealtimeSocketFrames.Reconnected())
|
RevoltAPI.wsFrameChannel.send(RealtimeSocketFrames.Reconnected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package chat.revolt.api.routes.channel
|
package chat.revolt.api.routes.channel
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import chat.revolt.api.RevoltAPI
|
import chat.revolt.api.RevoltAPI
|
||||||
import chat.revolt.api.RevoltError
|
import chat.revolt.api.RevoltError
|
||||||
import chat.revolt.api.RevoltHttp
|
import chat.revolt.api.RevoltHttp
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ package chat.revolt.api.routes.misc
|
||||||
import chat.revolt.api.RevoltHttp
|
import chat.revolt.api.RevoltHttp
|
||||||
import io.ktor.client.call.*
|
import io.ktor.client.call.*
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.*
|
|
||||||
import io.ktor.http.*
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
@ -83,19 +83,19 @@ private fun DisconnectedNoticeBase(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DisconnectedNotice(state: DisconnectionState, onReconnect: () -> Unit) {
|
fun DisconnectedNotice(state: DisconnectionState, onReconnect: () -> Unit) {
|
||||||
val retries = remember { mutableStateOf(0) }
|
val retries = remember { mutableIntStateOf(0) }
|
||||||
|
|
||||||
LaunchedEffect(state) {
|
LaunchedEffect(state) {
|
||||||
when (state) {
|
when (state) {
|
||||||
DisconnectionState.Disconnected -> {
|
DisconnectionState.Disconnected -> {
|
||||||
if (retries.value < 3) {
|
if (retries.intValue < 3) {
|
||||||
onReconnect()
|
onReconnect()
|
||||||
retries.value++
|
retries.intValue++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisconnectionState.Connected -> {
|
DisconnectionState.Connected -> {
|
||||||
retries.value = 0
|
retries.intValue = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> Unit
|
else -> Unit
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,9 @@ private fun argbAsCssColour(argb: Int): String {
|
||||||
@Composable
|
@Composable
|
||||||
fun WebMarkdown(
|
fun WebMarkdown(
|
||||||
text: String,
|
text: String,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
maskLoading: Boolean = false,
|
maskLoading: Boolean = false,
|
||||||
simpleLineBreaks: Boolean = true,
|
simpleLineBreaks: Boolean = true,
|
||||||
modifier: Modifier = Modifier
|
|
||||||
) {
|
) {
|
||||||
val contentColour = LocalContentColor.current
|
val contentColour = LocalContentColor.current
|
||||||
val materialColourScheme = MaterialTheme.colorScheme
|
val materialColourScheme = MaterialTheme.colorScheme
|
||||||
|
|
@ -98,10 +98,10 @@ fun WebMarkdown(
|
||||||
// Capture clicks on invite links
|
// Capture clicks on invite links
|
||||||
if (webResourceRequest.url.host == "rvlt.gg" ||
|
if (webResourceRequest.url.host == "rvlt.gg" ||
|
||||||
(
|
(
|
||||||
webResourceRequest.url.host?.endsWith("revolt.chat") == true && webResourceRequest.url.path?.startsWith(
|
webResourceRequest.url.host?.endsWith("revolt.chat") == true && webResourceRequest.url.path?.startsWith(
|
||||||
"/invite"
|
"/invite"
|
||||||
) == true
|
) == true
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
val intent = Intent(
|
val intent = Intent(
|
||||||
context,
|
context,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
@ -60,10 +60,10 @@ fun WeblinkPreview() {
|
||||||
@Composable
|
@Composable
|
||||||
fun AnyLinkPreview() {
|
fun AnyLinkPreview() {
|
||||||
val clicked = remember {
|
val clicked = remember {
|
||||||
mutableStateOf(0)
|
mutableIntStateOf(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
AnyLink(text = "Click me! #${clicked.value}", action = {
|
AnyLink(text = "Click me! #${clicked.intValue}", action = {
|
||||||
clicked.value++
|
clicked.intValue++
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.mutableLongStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
|
|
@ -56,7 +57,7 @@ fun AudioPlayer(url: String, filename: String, contentType: String) {
|
||||||
|
|
||||||
val showMenu = remember { mutableStateOf(false) }
|
val showMenu = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val currentTime = remember { mutableStateOf(0L) }
|
val currentTime = remember { mutableLongStateOf(0L) }
|
||||||
val isPlaying = remember { mutableStateOf(false) }
|
val isPlaying = remember { mutableStateOf(false) }
|
||||||
val isLoading = remember { mutableStateOf(false) }
|
val isLoading = remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
|
@ -86,7 +87,7 @@ fun AudioPlayer(url: String, filename: String, contentType: String) {
|
||||||
|
|
||||||
fun seekTo(position: Long) {
|
fun seekTo(position: Long) {
|
||||||
player.seekTo(position)
|
player.seekTo(position)
|
||||||
currentTime.value = position
|
currentTime.longValue = position
|
||||||
}
|
}
|
||||||
|
|
||||||
fun formatTime(time: Long): String {
|
fun formatTime(time: Long): String {
|
||||||
|
|
@ -166,8 +167,8 @@ fun AudioPlayer(url: String, filename: String, contentType: String) {
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
while (true) {
|
while (true) {
|
||||||
if (currentTime.value != player.currentPosition && player.isPlaying) {
|
if (currentTime.longValue != player.currentPosition && player.isPlaying) {
|
||||||
currentTime.value = player.currentPosition
|
currentTime.longValue = player.currentPosition
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.currentPosition == player.duration) {
|
if (player.currentPosition == player.duration) {
|
||||||
|
|
@ -176,7 +177,7 @@ fun AudioPlayer(url: String, filename: String, contentType: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.duration < 0) {
|
if (player.duration < 0) {
|
||||||
currentTime.value = 0
|
currentTime.longValue = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(100)
|
delay(100)
|
||||||
|
|
@ -208,7 +209,7 @@ fun AudioPlayer(url: String, filename: String, contentType: String) {
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
Text(
|
Text(
|
||||||
text = formatTime(currentTime.value),
|
text = formatTime(currentTime.longValue),
|
||||||
fontWeight = FontWeight.Medium
|
fontWeight = FontWeight.Medium
|
||||||
)
|
)
|
||||||
if (player.duration >= 0) {
|
if (player.duration >= 0) {
|
||||||
|
|
|
||||||
|
|
@ -243,10 +243,7 @@ class ChatRouterViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
ExperimentalComposeUiApi::class,
|
|
||||||
ExperimentalMaterial3Api::class
|
|
||||||
)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChatRouterScreen(
|
fun ChatRouterScreen(
|
||||||
topNav: NavController,
|
topNav: NavController,
|
||||||
|
|
|
||||||
|
|
@ -621,8 +621,4 @@ fun ColourSelectorSheet(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun String.toSnakeCase(): String {
|
|
||||||
return this.replace(Regex("([a-z])([A-Z]+)"), "$1_$2").lowercase()
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue