diff --git a/app/build.gradle b/app/build.gradle index e27daca3a..bc14e674a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -215,23 +215,17 @@ dependencies { implementation libs.bundles.accompanist - implementation("io.github.dokar3:sheets-m3:0.5.4") + implementation(libs.bundles.lifecycle) - implementation(libs.bundles.compose) - def composeBom = platform(libs.composeBom) + def composeBom = platform(libs.compose.bom) // def composeBom = platform("dev.chrisbanes.compose:compose-bom:2024.01.00-alpha01") implementation composeBom androidTestImplementation composeBom - implementation("androidx.compose.material3:material3") - implementation("androidx.compose.foundation:foundation") - implementation("androidx.compose.ui:ui") - - implementation("androidx.compose.material:material-icons-core") - implementation("androidx.compose.material:material-icons-extended") - implementation("androidx.compose.material3:material3-window-size-class") + implementation(libs.bundles.compose) + implementation(libs.bundles.compose.material3) androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-test-manifest' diff --git a/app/src/androidTest/java/com/github/jing332/tts_server_android/HttpTtsUrlTest.kt b/app/src/androidTest/java/com/github/jing332/tts_server_android/HttpTtsUrlTest.kt deleted file mode 100644 index fa6cf05d5..000000000 --- a/app/src/androidTest/java/com/github/jing332/tts_server_android/HttpTtsUrlTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.github.jing332.tts_server_android - -import android.util.Log -import androidx.test.ext.junit.runners.AndroidJUnit4 -import com.github.jing332.tts_server_android.constant.AppConst -import com.github.jing332.tts_server_android.model.AnalyzeUrl -import org.junit.Assert.* -import org.junit.Test -import org.junit.runner.RunWith - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class HttpTtsUrlTest { - @Test - fun test() { - // Context of the app under test. -// val appContext = InstrumentationRegistry.getInstrumentation().targetContext - - // "http://tsn.baidu.com/text2audio,{\"method\": \"POST\", \"body\": \"tex={{java.encodeURI(java.encodeURI(speakText))}}&spd={{(speakSpeed + 5) / 10 + 4}}&per=4114&cuid=baidu_speech_demo&idx=1&cod=2&lan=zh&ctp=1&pdt=220&vol=5&aue=6&pit=5&res_tag=audio\"}" - val url = - """ http://192.168.0.109:1233/api/ra ,{"method":"POST","body":"{{String(speakText).replace(/&/g, '&').replace(/\"/g, '"').replace(/'/g, ''').replace(//g, '>')}}"} """ - Log.e("TAG", url) - val a = AnalyzeUrl(url, speakText = "t\\\\est\\测\\\\试") - Log.e("TAG", "baseUrl: " + a.eval().toString()) - - println(AppConst.SCRIPT_ENGINE.eval(""" String("Test\\\\测试") """)) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/github/jing332/tts_server_android/CrashHandler.kt b/app/src/main/java/com/github/jing332/tts_server_android/CrashHandler.kt index 3624e14e2..73e8a3661 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/CrashHandler.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/CrashHandler.kt @@ -3,7 +3,7 @@ package com.github.jing332.tts_server_android import android.content.Context import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.lib_gojni.NativeUtils -import com.github.jing332.tts_server_android.utils.ClipboardUtils +import com.github.jing332.common.utils.ClipboardUtils import com.github.jing332.common.utils.longToast import com.github.jing332.common.utils.runOnUI import java.time.LocalDateTime diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/AboutDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/AboutDialog.kt index 207739b41..1eb01a0d6 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/AboutDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/AboutDialog.kt @@ -23,10 +23,10 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign.Companion import androidx.compose.ui.unit.dp import androidx.core.net.toUri +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.AppLauncherIcon import com.github.jing332.tts_server_android.BuildConfig import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.AppLauncherIcon @Composable fun AboutDialog(onDismissRequest: () -> Unit) { @@ -36,7 +36,7 @@ fun AboutDialog(onDismissRequest: () -> Unit) { onDismissRequest = onDismissRequest, title = { Row(verticalAlignment = Alignment.CenterVertically) { - AppLauncherIcon(modifier = Modifier.size(64.dp)) + AppLauncherIcon(modifier = Modifier.size(64.dp), R.mipmap.ic_app_launcher_round) Text( stringResource(id = R.string.app_name), modifier = Modifier diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/AppUpdateDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/AppUpdateDialog.kt index b0f009176..7ff02e8a4 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/AppUpdateDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/AppUpdateDialog.kt @@ -25,12 +25,11 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.github.jing332.common.DateFormatConst +import com.github.jing332.common.utils.ClipboardUtils +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.Markdown import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.Markdown -import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.tts_server_android.model.updater.AppUpdateChecker -import com.github.jing332.tts_server_android.utils.ClipboardUtils @Preview @Composable @@ -101,8 +100,7 @@ fun AppUpdateDialog( ClipboardUtils.copyText("TTS Server", url) context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) } - - AppDialog(onDismissRequest = onDismissRequest, + AppDialog(onDismissRequest = onDismissRequest, title = { Text( stringResource(id = R.string.check_update), diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/MainActivity.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/MainActivity.kt index 771f3258c..b5d198c00 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/MainActivity.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/MainActivity.kt @@ -80,6 +80,11 @@ import androidx.navigation.compose.composable import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import com.github.jing332.common.DateFormatConst +import com.github.jing332.common.utils.clone +import com.github.jing332.common.utils.longToast +import com.github.jing332.common.utils.performLongPress +import com.github.jing332.common.utils.toast +import com.github.jing332.compose.widgets.AppLauncherIcon import com.github.jing332.tts_server_android.BuildConfig import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.ShortCuts @@ -90,7 +95,6 @@ import com.github.jing332.tts_server_android.compose.settings.SettingsScreen import com.github.jing332.tts_server_android.compose.systts.SystemTtsScreen import com.github.jing332.tts_server_android.compose.systts.list.edit.TtsEditContainerScreen import com.github.jing332.tts_server_android.compose.theme.AppTheme -import com.github.jing332.tts_server_android.compose.widgets.AppLauncherIcon import com.github.jing332.tts_server_android.conf.AppConfig import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.tts_server_android.data.appDb @@ -99,10 +103,6 @@ import com.github.jing332.tts_server_android.model.speech.tts.ITextToSpeechEngin import com.github.jing332.tts_server_android.service.systts.SystemTtsService import com.github.jing332.tts_server_android.ui.AppHelpDocumentActivity import com.github.jing332.tts_server_android.utils.MyTools.killBattery -import com.github.jing332.tts_server_android.utils.clone -import com.github.jing332.common.utils.longToast -import com.github.jing332.tts_server_android.utils.performLongPress -import com.github.jing332.common.utils.toast import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.isGranted import com.google.accompanist.permissions.rememberPermissionState @@ -362,7 +362,7 @@ fun NavDrawerContent( } )) { Row(verticalAlignment = Alignment.CenterVertically) { - AppLauncherIcon(Modifier.size(64.dp)) + AppLauncherIcon(Modifier.size(64.dp), R.mipmap.ic_app_launcher_round) Column( modifier = Modifier .padding(start = 8.dp) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/BackupDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/BackupDialog.kt index 0083caaac..2cd009848 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/BackupDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/BackupDialog.kt @@ -20,9 +20,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.lifecycle.viewmodel.compose.viewModel +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.TextCheckBox import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.TextCheckBox import com.github.jing332.tts_server_android.ui.AppActivityResultContracts import com.github.jing332.tts_server_android.ui.FilePickerActivity import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/RestoreDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/RestoreDialog.kt index 9893c7825..d468af9ee 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/RestoreDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/backup/RestoreDialog.kt @@ -19,12 +19,12 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.app -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.LoadingContent import com.github.jing332.tts_server_android.ui.AppActivityResultContracts import com.github.jing332.tts_server_android.ui.FilePickerActivity import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog import com.github.jing332.common.utils.FileUtils.readBytes +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.LoadingContent import kotlinx.coroutines.launch @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/CodeEditorScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/CodeEditorScreen.kt index 6c7070811..72de0164d 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/CodeEditorScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/CodeEditorScreen.kt @@ -12,10 +12,10 @@ import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.automirrored.filled.InsertDriveFile import androidx.compose.material.icons.automirrored.filled.WrapText import androidx.compose.material.icons.filled.BugReport import androidx.compose.material.icons.filled.ColorLens -import androidx.compose.material.icons.filled.InsertDriveFile import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material.icons.filled.Save import androidx.compose.material.icons.filled.SettingsRemote @@ -43,14 +43,14 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel +import com.github.jing332.compose.ComposeExtensions.clickableRipple +import com.github.jing332.compose.widgets.CheckedMenuItem +import com.github.jing332.compose.widgets.LongClickIconButton import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.CheckedMenuItem -import com.github.jing332.tts_server_android.compose.widgets.LongClickIconButton import com.github.jing332.tts_server_android.conf.CodeEditorConfig import com.github.jing332.tts_server_android.ui.AppActivityResultContracts import com.github.jing332.tts_server_android.ui.FilePickerActivity import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog -import com.github.jing332.tts_server_android.utils.clickableRipple import io.github.rosemoe.sora.widget.CodeEditor import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -157,7 +157,7 @@ fun CodeEditorScreen( ) } }, - leadingIcon = { Icon(Icons.Default.InsertDriveFile, null) } + leadingIcon = { Icon(Icons.AutoMirrored.Filled.InsertDriveFile, null) } ) var syncEnabled by remember { CodeEditorConfig.isRemoteSyncEnabled } diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/LoggerBottomSheet.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/LoggerBottomSheet.kt index 49b73e063..ec15e303d 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/LoggerBottomSheet.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/LoggerBottomSheet.kt @@ -21,7 +21,7 @@ import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.compose.widgets.AppBottomSheet +import com.github.jing332.compose.widgets.AppBottomSheet import com.github.jing332.common.LogLevel @OptIn(ExperimentalMaterial3Api::class) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/RemoteSyncSettings.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/RemoteSyncSettings.kt index c7c669150..83cf1e5e2 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/RemoteSyncSettings.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/RemoteSyncSettings.kt @@ -17,8 +17,8 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.DenseOutlinedField +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.DenseOutlinedField import com.github.jing332.tts_server_android.conf.CodeEditorConfig @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/ThemeSettingsDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/ThemeSettingsDialog.kt index 90c1984d5..fc629076a 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/ThemeSettingsDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/codeeditor/ThemeSettingsDialog.kt @@ -9,7 +9,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppSelectionDialog +import com.github.jing332.compose.widgets.AppSelectionDialog import com.github.jing332.tts_server_android.conf.CodeEditorConfig import com.github.jing332.tts_server_android.constant.CodeEditorTheme diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicConfigScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicConfigScreen.kt index 81e0ceefa..ec0ef8c30 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicConfigScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicConfigScreen.kt @@ -11,14 +11,14 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import com.github.jing332.common.LogLevel +import com.github.jing332.compose.widgets.DenseOutlinedField +import com.github.jing332.compose.widgets.LocalBroadcastReceiver +import com.github.jing332.compose.widgets.SwitchFloatingButton import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.systts.LogScreen -import com.github.jing332.tts_server_android.compose.widgets.DenseOutlinedField -import com.github.jing332.tts_server_android.compose.widgets.LocalBroadcastReceiver -import com.github.jing332.tts_server_android.compose.widgets.SwitchFloatingButton -import com.github.jing332.tts_server_android.constant.KeyConst -import com.github.jing332.common.LogLevel import com.github.jing332.tts_server_android.constant.AppLog +import com.github.jing332.tts_server_android.constant.KeyConst @Suppress("DEPRECATION") @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicForwarderScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicForwarderScreen.kt index c9c222413..977ab349e 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicForwarderScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/BasicForwarderScreen.kt @@ -21,7 +21,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.LocalBroadcastReceiver +import com.github.jing332.compose.widgets.LocalBroadcastReceiver import com.github.jing332.tts_server_android.service.forwarder.system.SysTtsForwarderService import com.google.accompanist.web.rememberWebViewNavigator import com.google.accompanist.web.rememberWebViewState diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ForwarderTopAppBar.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ForwarderTopAppBar.kt index cd88b6bd0..b45f3615f 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ForwarderTopAppBar.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ForwarderTopAppBar.kt @@ -27,7 +27,7 @@ import androidx.compose.ui.res.stringResource import androidx.core.net.toUri import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.nav.NavTopAppBar -import com.github.jing332.tts_server_android.compose.widgets.CheckedMenuItem +import com.github.jing332.compose.widgets.CheckedMenuItem import com.github.jing332.common.utils.toast @OptIn(ExperimentalMaterial3Api::class) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ms/MsTtsForwarderScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ms/MsTtsForwarderScreen.kt index eaf72e419..d71ce759b 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ms/MsTtsForwarderScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/forwarder/ms/MsTtsForwarderScreen.kt @@ -22,7 +22,7 @@ import com.github.jing332.tts_server_android.compose.forwarder.BasicConfigScreen import com.github.jing332.tts_server_android.compose.forwarder.BasicForwarderScreen import com.github.jing332.tts_server_android.compose.forwarder.ConfigViewModel import com.github.jing332.tts_server_android.compose.forwarder.ForwarderTopAppBar -import com.github.jing332.tts_server_android.compose.widgets.TextFieldDialog +import com.github.jing332.compose.widgets.TextFieldDialog import com.github.jing332.tts_server_android.conf.MsTtsForwarderConfig import com.github.jing332.tts_server_android.service.forwarder.ForwarderServiceManager.switchMsTtsForwarder import com.github.jing332.tts_server_android.service.forwarder.ms.MsTtsForwarderService diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/nav/NavTopAppBar.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/nav/NavTopAppBar.kt index a21bee24f..89c1d5190 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/nav/NavTopAppBar.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/nav/NavTopAppBar.kt @@ -21,7 +21,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.LocalDrawerState -import com.github.jing332.tts_server_android.compose.widgets.AppTooltip +import com.github.jing332.compose.widgets.AppTooltip import kotlinx.coroutines.launch @OptIn(ExperimentalMaterial3Api::class) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/settings/SettingsWidgets.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/settings/SettingsWidgets.kt index ab143eb39..83b956770 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/settings/SettingsWidgets.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/settings/SettingsWidgets.kt @@ -36,8 +36,8 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.LabelSlider +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.LabelSlider @Composable internal fun DropdownPreference( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/AuditionDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/AuditionDialog.kt index d26345579..166119d69 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/AuditionDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/AuditionDialog.kt @@ -22,15 +22,15 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.drake.net.utils.withMain +import com.github.jing332.common.utils.ClipboardUtils +import com.github.jing332.common.utils.toast +import com.github.jing332.compose.ComposeExtensions.clickableRipple +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.LoadingContent import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.LoadingContent import com.github.jing332.tts_server_android.conf.AppConfig import com.github.jing332.tts_server_android.data.entities.systts.SystemTts -import com.github.jing332.tts_server_android.utils.ClipboardUtils import com.github.jing332.tts_server_android.utils.StringUtils.sizeToReadable -import com.github.jing332.tts_server_android.utils.clickableRipple -import com.github.jing332.common.utils.toast import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigExportBottomSheet.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigExportBottomSheet.kt index e1dcbf8e8..dd0d50029 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigExportBottomSheet.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigExportBottomSheet.kt @@ -26,11 +26,11 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.systts.directlink.LinkUploadSelectionDialog -import com.github.jing332.tts_server_android.compose.widgets.AppBottomSheet +import com.github.jing332.compose.widgets.AppBottomSheet import com.github.jing332.tts_server_android.ui.AppActivityResultContracts import com.github.jing332.tts_server_android.ui.FilePickerActivity import com.github.jing332.tts_server_android.ui.view.BigTextView -import com.github.jing332.tts_server_android.utils.ClipboardUtils +import com.github.jing332.common.utils.ClipboardUtils import com.github.jing332.common.utils.toast diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigImportBottomSheet.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigImportBottomSheet.kt index 99427c805..42c2e74bf 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigImportBottomSheet.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ConfigImportBottomSheet.kt @@ -46,13 +46,13 @@ import com.drake.net.Net import com.drake.net.okhttp.trustSSLCertificate import com.drake.net.utils.withMain import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppBottomSheet -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.RowToggleButtonGroup +import com.github.jing332.compose.widgets.AppBottomSheet +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.RowToggleButtonGroup import com.github.jing332.tts_server_android.ui.AppActivityResultContracts import com.github.jing332.tts_server_android.ui.FilePickerActivity import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog -import com.github.jing332.tts_server_android.utils.ClipboardUtils +import com.github.jing332.common.utils.ClipboardUtils import com.github.jing332.common.utils.FileUtils.readAllText import com.github.jing332.common.utils.longToast import com.github.jing332.tts_server_android.utils.toJsonListString diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ListSortSettingsDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ListSortSettingsDialog.kt index 06e0d5b7e..4bc335f90 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ListSortSettingsDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/ListSortSettingsDialog.kt @@ -24,11 +24,11 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.LoadingContent -import com.github.jing332.tts_server_android.compose.widgets.TextCheckBox import com.github.jing332.common.utils.toast +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.LoadingContent +import com.github.jing332.compose.widgets.TextCheckBox +import com.github.jing332.tts_server_android.R import kotlinx.coroutines.launch import kotlin.system.measureTimeMillis @@ -83,7 +83,10 @@ fun ListSortSettingsDialog( Row(Modifier.fillMaxWidth()) { TextCheckBox( text = { - Text(stringResource(id = R.string.descending), modifier = Modifier.padding(end = 8.dp)) + Text( + stringResource(id = R.string.descending), + modifier = Modifier.padding(end = 8.dp) + ) }, checked = descending, onCheckedChange = { descending = it } ) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/LogScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/LogScreen.kt index 7dff770ef..acbd22e5e 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/LogScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/LogScreen.kt @@ -31,11 +31,11 @@ import androidx.compose.ui.platform.LocalView import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.core.text.HtmlCompat +import com.github.jing332.common.utils.ClipboardUtils +import com.github.jing332.common.utils.toast +import com.github.jing332.compose.ComposeExtensions.toAnnotatedString import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.constant.AppLog -import com.github.jing332.tts_server_android.utils.ClipboardUtils -import com.github.jing332.tts_server_android.utils.toAnnotatedString -import com.github.jing332.common.utils.toast import kotlinx.coroutines.launch @OptIn(ExperimentalFoundationApi::class) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/TtsLogScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/TtsLogScreen.kt index b614e6416..4cf915ed2 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/TtsLogScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/TtsLogScreen.kt @@ -16,7 +16,7 @@ import androidx.compose.ui.res.stringResource import androidx.lifecycle.viewmodel.compose.viewModel import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.nav.NavTopAppBar -import com.github.jing332.tts_server_android.compose.widgets.LocalBroadcastReceiver +import com.github.jing332.compose.widgets.LocalBroadcastReceiver import com.github.jing332.tts_server_android.constant.KeyConst import com.github.jing332.tts_server_android.service.systts.SystemTtsService import com.github.jing332.tts_server_android.constant.AppLog diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/directlink/LinkUploadSelectionDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/directlink/LinkUploadSelectionDialog.kt index 49984aefe..fac32d543 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/directlink/LinkUploadSelectionDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/directlink/LinkUploadSelectionDialog.kt @@ -13,11 +13,11 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import com.drake.net.utils.withIO import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppSelectionDialog +import com.github.jing332.compose.widgets.AppSelectionDialog import com.github.jing332.tts_server_android.model.rhino.direct_link_upload.DirectUploadEngine import com.github.jing332.tts_server_android.model.rhino.direct_link_upload.DirectUploadFunction import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog -import com.github.jing332.tts_server_android.utils.ClipboardUtils +import com.github.jing332.common.utils.ClipboardUtils import com.github.jing332.common.utils.longToast import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BasicAudioParamsDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BasicAudioParamsDialog.kt index 132d36f9f..1ef3fdc5f 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BasicAudioParamsDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BasicAudioParamsDialog.kt @@ -8,9 +8,9 @@ import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.LabelSlider -import com.github.jing332.tts_server_android.utils.toScale +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.LabelSlider +import com.github.jing332.common.utils.toScale @Composable fun BasicAudioParamsDialog( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BgmSettingsDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BgmSettingsDialog.kt index 512a40ff7..1430bc58b 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BgmSettingsDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/BgmSettingsDialog.kt @@ -16,9 +16,9 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.AppDialog import com.github.jing332.tts_server_android.conf.SystemTtsConfig -import com.github.jing332.tts_server_android.utils.clickableRipple +import com.github.jing332.compose.ComposeExtensions.clickableRipple @Composable fun BgmSettingsDialog(onDismissRequest: () -> Unit) { diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Group.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Group.kt index bf0f859e6..5926a80d3 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Group.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Group.kt @@ -21,7 +21,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.state.ToggleableState import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.systts.GroupItem -import com.github.jing332.tts_server_android.compose.widgets.TextFieldDialog +import com.github.jing332.compose.widgets.TextFieldDialog @Composable fun Group( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/IntSlider.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/IntSlider.kt index 78ccea521..ace5841f0 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/IntSlider.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/IntSlider.kt @@ -2,7 +2,7 @@ package com.github.jing332.tts_server_android.compose.systts.list import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.github.jing332.tts_server_android.compose.widgets.LabelSlider +import com.github.jing332.compose.widgets.LabelSlider @Composable fun IntSlider( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/InternalPlayerDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/InternalPlayerDialog.kt index 91592498c..605223864 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/InternalPlayerDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/InternalPlayerDialog.kt @@ -9,10 +9,10 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.res.stringResource import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.LabelSlider +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.LabelSlider import com.github.jing332.tts_server_android.conf.SystemTtsConfig -import com.github.jing332.tts_server_android.utils.toScale +import com.github.jing332.common.utils.toScale @Composable fun InternalPlayerDialog(onDismissRequest: () -> Unit) { diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Item.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Item.kt index 789893ae0..274507579 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Item.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/Item.kt @@ -2,7 +2,6 @@ package com.github.jing332.tts_server_android.compose.systts.list import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.combinedClickable -import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxHeight @@ -16,7 +15,6 @@ import androidx.compose.material.icons.filled.Edit import androidx.compose.material.icons.filled.Headphones import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material.icons.filled.Output -import androidx.compose.material.ripple.rememberRipple import androidx.compose.material3.Checkbox import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem @@ -48,13 +46,12 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.constraintlayout.compose.ConstraintLayout import androidx.constraintlayout.compose.Dimension +import com.github.jing332.common.utils.performLongPress +import com.github.jing332.compose.widgets.LongClickIconButton +import com.github.jing332.compose.widgets.htmlcompose.HtmlText import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.HtmlText -import com.github.jing332.tts_server_android.compose.widgets.LongClickIconButton import com.github.jing332.tts_server_android.conf.AppConfig import com.github.jing332.tts_server_android.utils.StringUtils.limitLength -import com.github.jing332.tts_server_android.utils.clickableRipple -import com.github.jing332.tts_server_android.utils.performLongPress import org.burnoutcrew.reorderable.ReorderableLazyListState import org.burnoutcrew.reorderable.detectReorder diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/ListManagerScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/ListManagerScreen.kt index f584730f9..3c05aca3f 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/ListManagerScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/ListManagerScreen.kt @@ -54,8 +54,8 @@ import com.github.jing332.tts_server_android.compose.systts.ConfigExportBottomSh import com.github.jing332.tts_server_android.compose.systts.list.edit.QuickEditBottomSheet import com.github.jing332.tts_server_android.compose.systts.list.edit.TagDataClearConfirmDialog import com.github.jing332.tts_server_android.compose.systts.sizeToToggleableState -import com.github.jing332.tts_server_android.compose.widgets.LazyListIndexStateSaver -import com.github.jing332.tts_server_android.compose.widgets.TextFieldDialog +import com.github.jing332.compose.widgets.LazyListIndexStateSaver +import com.github.jing332.compose.widgets.TextFieldDialog import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.tts_server_android.constant.SpeechTarget import com.github.jing332.tts_server_android.data.appDb diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/MenuMoreOptions.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/MenuMoreOptions.kt index 3a1758ea6..b0d039b9b 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/MenuMoreOptions.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/MenuMoreOptions.kt @@ -28,9 +28,9 @@ import com.github.jing332.tts_server_android.compose.asAppCompatActivity import com.github.jing332.tts_server_android.compose.systts.plugin.PluginManagerActivity import com.github.jing332.tts_server_android.compose.systts.replace.ReplaceManagerActivity import com.github.jing332.tts_server_android.compose.systts.speechrule.SpeechRuleManagerActivity -import com.github.jing332.tts_server_android.compose.widgets.CheckedMenuItem +import com.github.jing332.compose.widgets.CheckedMenuItem import com.github.jing332.tts_server_android.conf.SystemTtsConfig -import com.github.jing332.tts_server_android.utils.startActivity +import com.github.jing332.common.utils.startActivity @Composable internal fun MenuMoreOptions( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/BasicInfoEditScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/BasicInfoEditScreen.kt index 7bcd47228..9415ef4bf 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/BasicInfoEditScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/BasicInfoEditScreen.kt @@ -43,9 +43,9 @@ import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.systts.list.BasicAudioParamsDialog import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.SaveActionHandler import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.InternalPlayerDialog -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.AppSpinner -import com.github.jing332.tts_server_android.compose.widgets.RowToggleButtonGroup +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.AppSpinner +import com.github.jing332.compose.widgets.RowToggleButtonGroup import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.tts_server_android.constant.SpeechTarget import com.github.jing332.tts_server_android.data.appDb @@ -58,8 +58,8 @@ import com.github.jing332.tts_server_android.data.entities.systts.SystemTtsGroup import com.github.jing332.tts_server_android.model.rhino.speech_rule.SpeechRuleEngine import com.github.jing332.tts_server_android.model.speech.tts.ITextToSpeechEngine import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog -import com.github.jing332.tts_server_android.utils.ClipboardUtils -import com.github.jing332.tts_server_android.utils.clone +import com.github.jing332.common.utils.ClipboardUtils +import com.github.jing332.common.utils.clone import com.github.jing332.common.utils.longToast import com.github.jing332.common.utils.toast import kotlinx.serialization.encodeToString diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/QuickEditBottomSheet.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/QuickEditBottomSheet.kt index f499fa6ba..753a81c28 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/QuickEditBottomSheet.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/QuickEditBottomSheet.kt @@ -17,7 +17,7 @@ import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.LocalSaveCallBack import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.TtsUiFactory import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.rememberSaveCallBacks -import com.github.jing332.tts_server_android.compose.widgets.AppBottomSheet +import com.github.jing332.compose.widgets.AppBottomSheet import com.github.jing332.tts_server_android.data.entities.systts.SystemTts import com.github.jing332.tts_server_android.model.speech.tts.BgmTTS import kotlinx.coroutines.Dispatchers diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/TagDataClearConfirmDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/TagDataClearConfirmDialog.kt index 280b05b5f..b024c8bd2 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/TagDataClearConfirmDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/TagDataClearConfirmDialog.kt @@ -7,7 +7,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.AppDialog @Composable fun TagDataClearConfirmDialog( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/BgmTtsUI.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/BgmTtsUI.kt index ab2d9a5f1..55564ff81 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/BgmTtsUI.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/BgmTtsUI.kt @@ -51,7 +51,7 @@ import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.systts.list.IntSlider import com.github.jing332.tts_server_android.compose.systts.list.edit.BasicInfoEditScreen import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.TtsTopAppBar -import com.github.jing332.tts_server_android.compose.widgets.AppSelectionDialog +import com.github.jing332.compose.widgets.AppSelectionDialog import com.github.jing332.tts_server_android.constant.SpeechTarget import com.github.jing332.tts_server_android.data.entities.systts.SpeechRuleInfo import com.github.jing332.tts_server_android.data.entities.systts.SystemTts @@ -62,7 +62,7 @@ import com.github.jing332.tts_server_android.ui.FilePickerActivity import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog import com.github.jing332.common.utils.ASFUriUtils.getPath import com.github.jing332.common.utils.FileUtils.audioList -import com.github.jing332.tts_server_android.utils.clickableRipple +import com.github.jing332.compose.ComposeExtensions.clickableRipple import com.github.jing332.common.utils.toast import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.isGranted diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/LocalTtsUI.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/LocalTtsUI.kt index b19f2214d..0da3d9ce6 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/LocalTtsUI.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/LocalTtsUI.kt @@ -41,10 +41,10 @@ import com.github.jing332.tts_server_android.compose.systts.list.IntSlider import com.github.jing332.tts_server_android.compose.systts.list.edit.BasicInfoEditScreen import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.AuditionTextField import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.TtsTopAppBar -import com.github.jing332.tts_server_android.compose.widgets.AppSpinner -import com.github.jing332.tts_server_android.compose.widgets.DenseOutlinedField -import com.github.jing332.tts_server_android.compose.widgets.LabelSlider -import com.github.jing332.tts_server_android.compose.widgets.LoadingContent +import com.github.jing332.compose.widgets.AppSpinner +import com.github.jing332.compose.widgets.DenseOutlinedField +import com.github.jing332.compose.widgets.LabelSlider +import com.github.jing332.compose.widgets.LoadingContent import com.github.jing332.tts_server_android.data.entities.systts.SystemTts import com.github.jing332.tts_server_android.model.speech.tts.LocalTTS import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/MsTtsUI.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/MsTtsUI.kt index 0e9aa0edd..f86dbe267 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/MsTtsUI.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/MsTtsUI.kt @@ -25,8 +25,8 @@ import com.github.jing332.tts_server_android.compose.systts.list.IntSlider import com.github.jing332.tts_server_android.compose.systts.list.edit.BasicInfoEditScreen import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.AuditionTextField import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.TtsTopAppBar -import com.github.jing332.tts_server_android.compose.widgets.AppSpinner -import com.github.jing332.tts_server_android.compose.widgets.LoadingContent +import com.github.jing332.compose.widgets.AppSpinner +import com.github.jing332.compose.widgets.LoadingContent import com.github.jing332.tts_server_android.constant.MsTtsApiType import com.github.jing332.tts_server_android.data.entities.systts.SystemTts import com.github.jing332.tts_server_android.model.GeneralVoiceData diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/PluginTtsUI.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/PluginTtsUI.kt index eec02d068..94fb23549 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/PluginTtsUI.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/list/edit/ui/PluginTtsUI.kt @@ -31,9 +31,9 @@ import com.github.jing332.tts_server_android.compose.systts.list.IntSlider import com.github.jing332.tts_server_android.compose.systts.list.edit.BasicInfoEditScreen import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.AuditionTextField import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.widgets.TtsTopAppBar -import com.github.jing332.tts_server_android.compose.widgets.AppSpinner -import com.github.jing332.tts_server_android.compose.widgets.LoadingContent -import com.github.jing332.tts_server_android.compose.widgets.LoadingDialog +import com.github.jing332.compose.widgets.AppSpinner +import com.github.jing332.compose.widgets.LoadingContent +import com.github.jing332.compose.widgets.LoadingDialog import com.github.jing332.tts_server_android.data.entities.systts.SystemTts import com.github.jing332.tts_server_android.model.speech.tts.BaseAudioFormat import com.github.jing332.tts_server_android.model.speech.tts.PluginTTS diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginEditScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginEditScreen.kt index 0da74d57c..ecac20287 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginEditScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginEditScreen.kt @@ -27,7 +27,7 @@ import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.LocalNavController import com.github.jing332.tts_server_android.compose.codeeditor.CodeEditorScreen import com.github.jing332.tts_server_android.compose.codeeditor.LoggerBottomSheet -import com.github.jing332.tts_server_android.compose.widgets.TextFieldDialog +import com.github.jing332.compose.widgets.TextFieldDialog import com.github.jing332.tts_server_android.conf.PluginConfig import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.tts_server_android.data.entities.plugin.Plugin diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginExportBottomSheet.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginExportBottomSheet.kt index e9128a5e5..b144f1bcf 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginExportBottomSheet.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginExportBottomSheet.kt @@ -19,7 +19,7 @@ import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.systts.ConfigExportBottomSheet -import com.github.jing332.tts_server_android.compose.widgets.TextCheckBox +import com.github.jing332.compose.widgets.TextCheckBox @Composable internal fun PluginExportBottomSheet( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginPreviewActivity.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginPreviewActivity.kt index 862d5d2a1..03e5ec731 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginPreviewActivity.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginPreviewActivity.kt @@ -34,12 +34,12 @@ import com.github.jing332.tts_server_android.AppLocale import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.systts.list.edit.ui.PluginTtsUI import com.github.jing332.tts_server_android.compose.theme.AppTheme -import com.github.jing332.tts_server_android.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.AppDialog import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.tts_server_android.data.entities.systts.SystemTts import com.github.jing332.tts_server_android.model.speech.tts.PluginTTS import com.github.jing332.tts_server_android.ui.view.ErrorDialogActivity -import com.github.jing332.tts_server_android.utils.clickableRipple +import com.github.jing332.compose.ComposeExtensions.clickableRipple @Suppress("DEPRECATION") class PluginPreviewActivity : AppCompatActivity() { diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginVarsBottomSheet.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginVarsBottomSheet.kt index b7ec9f76e..fbaa16ad7 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginVarsBottomSheet.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/plugin/PluginVarsBottomSheet.kt @@ -9,7 +9,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.compose.widgets.AppBottomSheet +import com.github.jing332.compose.widgets.AppBottomSheet import com.github.jing332.tts_server_android.data.entities.plugin.Plugin @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/GroupEditDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/GroupEditDialog.kt index 961e44560..b616155ad 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/GroupEditDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/GroupEditDialog.kt @@ -18,11 +18,11 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog -import com.github.jing332.tts_server_android.compose.widgets.TextCheckBox +import com.github.jing332.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.TextCheckBox import com.github.jing332.tts_server_android.constant.ReplaceExecution import com.github.jing332.tts_server_android.data.entities.replace.ReplaceRuleGroup -import com.github.jing332.tts_server_android.utils.clickableRipple +import com.github.jing332.compose.ComposeExtensions.clickableRipple @Composable internal fun GroupEditDialog( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/ReplaceRuleManagerScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/ReplaceRuleManagerScreen.kt index 6e8383195..dfeccd8a0 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/ReplaceRuleManagerScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/ReplaceRuleManagerScreen.kt @@ -49,8 +49,8 @@ import com.github.jing332.tts_server_android.compose.LocalNavController import com.github.jing332.tts_server_android.compose.ShadowReorderableItem import com.github.jing332.tts_server_android.compose.navigate import com.github.jing332.tts_server_android.compose.systts.sizeToToggleableState -import com.github.jing332.tts_server_android.compose.widgets.LazyListIndexStateSaver -import com.github.jing332.tts_server_android.compose.widgets.TextFieldDialog +import com.github.jing332.compose.widgets.LazyListIndexStateSaver +import com.github.jing332.compose.widgets.TextFieldDialog import com.github.jing332.tts_server_android.data.appDb import com.github.jing332.tts_server_android.data.entities.replace.GroupWithReplaceRule import com.github.jing332.tts_server_android.data.entities.replace.ReplaceRule diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/SearchTextField.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/SearchTextField.kt index 544802d95..8c067abd6 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/SearchTextField.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/SearchTextField.kt @@ -39,7 +39,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.theme.AppTheme -import com.github.jing332.tts_server_android.compose.widgets.DenseTextField +import com.github.jing332.compose.widgets.DenseTextField import kotlinx.parcelize.Parcelize @Parcelize diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ReplaceRuleEditScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ReplaceRuleEditScreen.kt index 5902fee5e..55e4cd8ca 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ReplaceRuleEditScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ReplaceRuleEditScreen.kt @@ -56,8 +56,8 @@ import androidx.lifecycle.viewmodel.compose.viewModel import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.LocalNavController import com.github.jing332.tts_server_android.compose.systts.AuditionDialog -import com.github.jing332.tts_server_android.compose.widgets.AppSpinner -import com.github.jing332.tts_server_android.compose.widgets.TextCheckBox +import com.github.jing332.compose.widgets.AppSpinner +import com.github.jing332.compose.widgets.TextCheckBox import com.github.jing332.tts_server_android.conf.ReplaceRuleConfig import com.github.jing332.tts_server_android.data.appDb import com.github.jing332.tts_server_android.data.entities.replace.ReplaceRule diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ToolBarSettingsDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ToolBarSettingsDialog.kt index 33bdc6792..fa890c53a 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ToolBarSettingsDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/ToolBarSettingsDialog.kt @@ -16,7 +16,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppDialog +import com.github.jing332.compose.widgets.AppDialog @Composable fun ToolBarSettingsDialog( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/TtsConfigSelectDialog.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/TtsConfigSelectDialog.kt index 82ffccbb0..7f7dbdb64 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/TtsConfigSelectDialog.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/replace/edit/TtsConfigSelectDialog.kt @@ -22,11 +22,11 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.theme.AppTheme -import com.github.jing332.tts_server_android.compose.widgets.AppBottomSheet -import com.github.jing332.tts_server_android.compose.widgets.HtmlText +import com.github.jing332.compose.widgets.AppBottomSheet +import com.github.jing332.compose.widgets.HtmlText import com.github.jing332.tts_server_android.data.appDb import com.github.jing332.tts_server_android.data.entities.systts.SystemTts -import com.github.jing332.tts_server_android.utils.clickableRipple +import com.github.jing332.compose.ComposeExtensions.clickableRipple @Preview @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleEditScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleEditScreen.kt index cad0e3648..71251a412 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleEditScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleEditScreen.kt @@ -20,7 +20,7 @@ import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.compose.LocalNavController import com.github.jing332.tts_server_android.compose.codeeditor.CodeEditorScreen import com.github.jing332.tts_server_android.compose.codeeditor.LoggerBottomSheet -import com.github.jing332.tts_server_android.compose.widgets.TextFieldDialog +import com.github.jing332.compose.widgets.TextFieldDialog import com.github.jing332.tts_server_android.conf.SpeechRuleConfig import com.github.jing332.tts_server_android.data.entities.SpeechRule import com.github.jing332.tts_server_android.ui.view.AppDialogs.displayErrorDialog diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleManagerScreen.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleManagerScreen.kt index 06ef15832..9a9fbb5e7 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleManagerScreen.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/systts/speechrule/SpeechRuleManagerScreen.kt @@ -55,7 +55,7 @@ import com.github.jing332.tts_server_android.compose.ShadowReorderableItem import com.github.jing332.tts_server_android.compose.navigate import com.github.jing332.tts_server_android.compose.systts.ConfigDeleteDialog import com.github.jing332.tts_server_android.compose.systts.plugin.PluginManagerActivity -import com.github.jing332.tts_server_android.compose.widgets.LazyListIndexStateSaver +import com.github.jing332.compose.widgets.LazyListIndexStateSaver import com.github.jing332.tts_server_android.data.appDb import com.github.jing332.tts_server_android.data.entities.SpeechRule import com.github.jing332.tts_server_android.utils.MyTools diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/theme/Theme.kt b/app/src/main/java/com/github/jing332/tts_server_android/compose/theme/Theme.kt index 809bfbca2..68829a862 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/theme/Theme.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/compose/theme/Theme.kt @@ -13,7 +13,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView -import com.github.jing332.tts_server_android.compose.widgets.SetupSystemBars +import com.github.jing332.compose.widgets.SetupSystemBars import com.github.jing332.tts_server_android.conf.AppConfig import com.gyf.immersionbar.ImmersionBar diff --git a/app/src/main/java/com/github/jing332/tts_server_android/model/AnalyzeUrl.kt b/app/src/main/java/com/github/jing332/tts_server_android/model/AnalyzeUrl.kt index b16814dbc..40c59e66a 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/model/AnalyzeUrl.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/model/AnalyzeUrl.kt @@ -1,7 +1,6 @@ package com.github.jing332.tts_server_android.model import com.github.jing332.tts_server_android.constant.AppConst -import com.github.jing332.tts_server_android.constant.AppConst.SCRIPT_ENGINE import com.script.SimpleBindings import kotlinx.serialization.decodeFromString import java.util.regex.Pattern @@ -26,8 +25,8 @@ class AnalyzeUrl( matcher.group().replace("{{", "").replace("}}", "").replace("java.", "") kotlin.runCatching { - val result = evalJs(jsCodeStr) - matcher.appendReplacement(sb, result.toString()) +// val result = evalJs(jsCodeStr) + matcher.appendReplacement(sb," result.toString()") }.onFailure { throw Exception("执行 $jsCodeStr 时出错", it) } @@ -51,13 +50,13 @@ class AnalyzeUrl( // 执行js 替换变量 - private fun evalJs(jsStr: String): Any? { - val bindings = SimpleBindings() - bindings["speakText"] = speakText - bindings["speakSpeed"] = speakSpeed - bindings["speakVolume"] = speakVolume - return SCRIPT_ENGINE.eval(jsStr, bindings) - } +// private fun evalJs(jsStr: String): Any? { +// val bindings = SimpleBindings() +// bindings["speakText"] = speakText +// bindings["speakSpeed"] = speakSpeed +// bindings["speakVolume"] = speakVolume +// return SCRIPT_ENGINE.eval(jsStr, bindings) +// } // url中的参数 @kotlinx.serialization.Serializable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginEngine.kt b/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginEngine.kt index c0d2f20e1..d2aad4a1e 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginEngine.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginEngine.kt @@ -4,8 +4,6 @@ import android.content.Context import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.constant.AppConst import com.github.jing332.tts_server_android.data.entities.plugin.Plugin -import com.github.jing332.script_engine.core.BaseScriptEngine -import com.github.jing332.script_engine.core.Logger import com.github.jing332.tts_server_android.model.speech.tts.PluginTTS import com.script.javascript.RhinoScriptEngine import org.mozilla.javascript.NativeObject @@ -41,11 +39,6 @@ open class TtsPluginEngine( const val FUNC_ON_STOP = "onStop" } - @Synchronized - override fun eval(prefixCode: String): Any? { - return super.eval("$prefixCode ;importPackage(${AppConst.PACKET_NAME}.model.rhino.core.type.ws)") - } - // 已弃用, 占位 @Suppress("unused") var extraData: String = "" @@ -71,7 +64,7 @@ open class TtsPluginEngine( } catch (t: Throwable) { mPlugin.defVars = emptyMap() - throw ClassCastException("\"vars\" bad format" ).initCause(t) + throw ClassCastException("\"vars\" bad format").initCause(t) } runCatching { @@ -98,7 +91,7 @@ open class TtsPluginEngine( @Synchronized fun onStop(): Any? { logger.d("onStop()...") - ttsrvObject.cancel() + ttsrvObject.cancelNetwork() try { return rhino.invokeMethod(pluginJsObject, FUNC_ON_STOP) } catch (_: NoSuchMethodException) { diff --git a/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginUiEngine.kt b/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginUiEngine.kt index c0f9badae..7a1bc0b05 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginUiEngine.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/model/rhino/tts/TtsPluginUiEngine.kt @@ -2,9 +2,8 @@ package com.github.jing332.tts_server_android.model.rhino.tts import android.content.Context import android.widget.LinearLayout -import com.github.jing332.tts_server_android.constant.AppConst +import com.github.jing332.common.utils.dp import com.github.jing332.tts_server_android.model.speech.tts.PluginTTS -import com.github.jing332.tts_server_android.utils.dp import org.mozilla.javascript.NativeObject import java.util.Locale @@ -31,11 +30,7 @@ class TtsPluginUiEngine( } private val editUiJsObject: NativeObject by lazy { - val importCode = "importPackage(${AppConst.PACKET_NAME}.model.rhino.core.type.ui);" + - "importPackage(android.view);" + - "importPackage(android.widget);" - - eval(importCode) + eval() findObject(OBJ_UI_JS) } diff --git a/app/src/main/java/com/github/jing332/tts_server_android/service/forwarder/AbsForwarderService.kt b/app/src/main/java/com/github/jing332/tts_server_android/service/forwarder/AbsForwarderService.kt index d9fe46f84..488b878bd 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/service/forwarder/AbsForwarderService.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/service/forwarder/AbsForwarderService.kt @@ -20,9 +20,9 @@ import com.github.jing332.tts_server_android.constant.AppLog import com.github.jing332.common.LogLevel import com.github.jing332.lib_gojni.NativeUtils import com.github.jing332.tts_server_android.ui.ImportConfigActivity -import com.github.jing332.tts_server_android.utils.ClipboardUtils -import com.github.jing332.tts_server_android.utils.registerGlobalReceiver -import com.github.jing332.tts_server_android.utils.startForegroundCompat +import com.github.jing332.common.utils.ClipboardUtils +import com.github.jing332.common.utils.registerGlobalReceiver +import com.github.jing332.common.utils.startForegroundCompat import com.github.jing332.common.utils.toast import splitties.systemservices.powerManager diff --git a/app/src/main/java/com/github/jing332/tts_server_android/service/systts/SystemTtsService.kt b/app/src/main/java/com/github/jing332/tts_server_android/service/systts/SystemTtsService.kt index e63dea438..6644d0df4 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/service/systts/SystemTtsService.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/service/systts/SystemTtsService.kt @@ -36,13 +36,12 @@ import com.github.jing332.tts_server_android.service.systts.help.exception.Speec import com.github.jing332.tts_server_android.service.systts.help.exception.TextReplacerException import com.github.jing332.tts_server_android.service.systts.help.exception.TtsManagerException import com.github.jing332.tts_server_android.constant.AppLog -import com.github.jing332.tts_server_android.utils.GcManager import com.github.jing332.tts_server_android.utils.StringUtils.limitLength import com.github.jing332.common.utils.longToast -import com.github.jing332.tts_server_android.utils.registerGlobalReceiver +import com.github.jing332.common.utils.registerGlobalReceiver import com.github.jing332.common.utils.rootCause import com.github.jing332.common.utils.runOnUI -import com.github.jing332.tts_server_android.utils.startForegroundCompat +import com.github.jing332.common.utils.startForegroundCompat import com.github.jing332.tts_server_android.utils.toHtmlBold import com.github.jing332.tts_server_android.utils.toHtmlItalic import com.github.jing332.tts_server_android.utils.toHtmlSmall @@ -284,7 +283,7 @@ class SystemTtsService : TextToSpeechService(), TextToSpeechManager.Listener { if (mWakeLock != null && mWakeLock?.isHeld == false) { mWakeLock?.acquire(60 * 20 * 1000) } - GcManager.doGC() +// GcManager.doGC() } private var mNotificationBuilder: Notification.Builder? = null diff --git a/app/src/main/java/com/github/jing332/tts_server_android/service/systts/help/TextToSpeechManager.kt b/app/src/main/java/com/github/jing332/tts_server_android/service/systts/help/TextToSpeechManager.kt index 458529403..ac23a6c4a 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/service/systts/help/TextToSpeechManager.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/service/systts/help/TextToSpeechManager.kt @@ -4,14 +4,15 @@ import android.content.Context import android.media.AudioFormat import android.media.AudioTrack import android.util.Log -import androidx.media3.exoplayer.audio.SilenceSkippingAudioProcessor +import com.github.jing332.common.audio.AudioDecoder.Companion.readPcmChunk +import com.github.jing332.common.utils.longToast +import com.github.jing332.common.utils.toast import com.github.jing332.tts_server_android.R import com.github.jing332.tts_server_android.conf.SysTtsConfig import com.github.jing332.tts_server_android.constant.AppPattern import com.github.jing332.tts_server_android.constant.ReplaceExecution import com.github.jing332.tts_server_android.constant.SpeechTarget import com.github.jing332.tts_server_android.data.appDb -import com.github.jing332.common.audio.AudioDecoder.Companion.readPcmChunk import com.github.jing332.tts_server_android.model.speech.ITextToSpeechSynthesizer import com.github.jing332.tts_server_android.model.speech.TtsTextSegment import com.github.jing332.tts_server_android.model.speech.tts.BaseAudioFormat @@ -25,8 +26,6 @@ import com.github.jing332.tts_server_android.service.systts.help.exception.Reque import com.github.jing332.tts_server_android.service.systts.help.exception.SpeechRuleException import com.github.jing332.tts_server_android.service.systts.help.exception.TtsManagerException import com.github.jing332.tts_server_android.utils.StringUtils -import com.github.jing332.common.utils.longToast -import com.github.jing332.common.utils.toast import kotlinx.coroutines.cancelAndJoin import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay @@ -425,7 +424,6 @@ class TextToSpeechManager(val context: Context) : ITextToSpeechSynthesizer= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { // A14 - startForeground( - notificationId, - notification, - ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK - ) - } else { - startForeground(notificationId, notification) - } -} - -@Composable -fun Modifier.simpleVerticalScrollbar( - state: LazyListState, - width: Dp = 8.dp, - color: Color = MaterialTheme.colorScheme.secondary -): Modifier { - val targetAlpha = if (state.isScrollInProgress) 1f else 0f - val duration = if (state.isScrollInProgress) 150 else 500 - - val alpha by animateFloatAsState( - targetValue = targetAlpha, - animationSpec = tween(durationMillis = duration), label = "" - ) - - return drawWithContent { - drawContent() - - val firstVisibleElementIndex = state.layoutInfo.visibleItemsInfo.firstOrNull()?.index - val needDrawScrollbar = state.isScrollInProgress || alpha > 0.0f - - // Draw scrollbar if scrolling or if the animation is still running and lazy column has content - if (needDrawScrollbar && firstVisibleElementIndex != null) { - val elementHeight = this.size.height / state.layoutInfo.totalItemsCount - - val scrollbarOffsetY = - firstVisibleElementIndex * elementHeight + state.firstVisibleItemScrollOffset / 4 - -// val scrollbarOffsetY = firstVisibleElementIndex * elementHeight - val scrollbarHeight = state.layoutInfo.visibleItemsInfo.size * elementHeight - - drawRect( - color = color, - topLeft = Offset(this.size.width - width.toPx(), scrollbarOffsetY), - size = Size(width.toPx(), scrollbarHeight), - alpha = alpha - ) - } - } -} - -@OptIn(ExperimentalFoundationApi::class) -@Composable -fun Modifier.clickableRipple( - enabled: Boolean = true, - role: Role? = null, - onLongClick: (() -> Unit)? = null, - onLongClickLabel: String? = null, - onClickLabel: String? = null, - onClick: () -> Unit, -) = - this.combinedClickable( - enabled = enabled, - role = role, - indication = rememberRipple(), - interactionSource = remember { MutableInteractionSource() }, - onClickLabel = onClickLabel, - onClick = onClick, - onLongClick = onLongClick, - onLongClickLabel = onLongClickLabel, - ) - -fun Spanned.toAnnotatedString(): AnnotatedString = buildAnnotatedString { - val spanned = this@toAnnotatedString - append(spanned.toString()) - getSpans(0, spanned.length, Any::class.java).forEach { span -> - val start = getSpanStart(span) - val end = getSpanEnd(span) - when (span) { - is StyleSpan -> when (span.style) { - Typeface.BOLD -> addStyle(SpanStyle(fontWeight = FontWeight.Bold), start, end) - Typeface.ITALIC -> addStyle(SpanStyle(fontStyle = FontStyle.Italic), start, end) - Typeface.BOLD_ITALIC -> addStyle( - SpanStyle( - fontWeight = FontWeight.Bold, - fontStyle = FontStyle.Italic - ), start, end - ) - } - - is UnderlineSpan -> addStyle( - SpanStyle(textDecoration = TextDecoration.Underline), - start, - end - ) - - is ForegroundColorSpan -> addStyle( - SpanStyle(color = Color(span.foregroundColor)), - start, - end - ) - } - } -} - -fun Context.registerGlobalReceiver( - actions: List, - receiver: BroadcastReceiver -) { - ContextCompat.registerReceiver(this, receiver, IntentFilter().apply { - actions.forEach { addAction(it) } - }, ContextCompat.RECEIVER_EXPORTED) -} - -fun View.performLongPress() { - this.isHapticFeedbackEnabled = true - this.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) -} - -fun Context.startActivity(clz: Class<*>) { - startActivity(Intent(this, clz).apply { action = Intent.ACTION_VIEW }) -} - -fun Uri.grantReadWritePermission(contentResolver: ContentResolver) { - contentResolver.takePersistableUriPermission( - this, - Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION - ) -} - -fun Intent.getBinder(): IBinder? { - val bundle = getBundleExtra(KeyConst.KEY_BUNDLE) - return bundle?.getBinder(KeyConst.KEY_LARGE_DATA_BINDER) -} - -fun Intent.setBinder(binder: IBinder) { - putExtra( - KeyConst.KEY_BUNDLE, - Bundle().apply { - putBinder(KeyConst.KEY_LARGE_DATA_BINDER, binder) - }) -} - -val Int.dp: Int get() = SizeUtils.dp2px(this.toFloat()) - -val Int.px: Int get() = SizeUtils.px2dp(this.toFloat()) - -val Context.layoutInflater: LayoutInflater - get() = LayoutInflater.from(this) - -fun ViewGroup.setMarginMatchParent() { - this.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT -} - -/** - * 重启当前 Activity - */ -fun Activity.restart() { - finish() - ContextCompat.startActivity(this, intent, null) -} - -@Suppress("UNCHECKED_CAST") -fun Any.inflateBinding( - inflater: LayoutInflater, - root: ViewGroup? = null, - attachToParent: Boolean = false -): T { - return (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments - .filterIsInstance>() - .first() - .getDeclaredMethod( - "inflate", LayoutInflater::class.java, ViewGroup::class.java, Boolean::class.java - ) - .also { it.isAccessible = true } - .invoke(null, inflater, root, attachToParent) as T -} - -val WindowManager.windowSize: DisplayMetrics - get() { - val displayMetrics = DisplayMetrics() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - val windowMetrics: WindowMetrics = currentWindowMetrics - val insets = windowMetrics.windowInsets - .getInsetsIgnoringVisibility(WindowInsets.Type.systemBars()) - displayMetrics.widthPixels = windowMetrics.bounds.width() - insets.left - insets.right - displayMetrics.heightPixels = windowMetrics.bounds.height() - insets.top - insets.bottom - } else { - @Suppress("DEPRECATION") - defaultDisplay.getMetrics(displayMetrics) - } - return displayMetrics - } - -@Suppress("DEPRECATION") -val Activity.displayHeight: Int - get() { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - val windowMetrics = windowManager.currentWindowMetrics - val insets = windowMetrics.windowInsets.getInsetsIgnoringVisibility( - WindowInsets.Type.systemBars() or WindowInsets.Type.displayCutout() - ) - windowMetrics.bounds.height() - insets.bottom - insets.top - } else - windowManager.defaultDisplay.height - } - -/** - * 点击防抖动 - */ -fun View.clickWithThrottle(throttleTime: Long = 600L, action: (v: View) -> Unit) { - this.setOnClickListener(object : View.OnClickListener { - private var lastClickTime: Long = 0 - - override fun onClick(v: View) { - if (SystemClock.elapsedRealtime() - lastClickTime < throttleTime) return - else action(v) - - lastClickTime = SystemClock.elapsedRealtime() - } - }) -} - -/** - * View 是否在屏幕上可见 - */ -fun View.isVisibleOnScreen(): Boolean { - if (!isShown) { - return false - } - val actualPosition = Rect() - val isGlobalVisible = getGlobalVisibleRect(actualPosition) - val screenWidth = Resources.getSystem().displayMetrics.widthPixels - val screenHeight = Resources.getSystem().displayMetrics.heightPixels - val screen = Rect(0, 0, screenWidth, screenHeight) - return isGlobalVisible && Rect.intersects(actualPosition, screen) -} - -fun ViewPager2.reduceDragSensitivity(f: Int = 4) { - val recyclerViewField = ViewPager2::class.java.getDeclaredField("mRecyclerView") - recyclerViewField.isAccessible = true - val recyclerView = recyclerViewField.get(this) as RecyclerView - - val touchSlopField = RecyclerView::class.java.getDeclaredField("mTouchSlop") - touchSlopField.isAccessible = true - val touchSlop = touchSlopField.get(recyclerView) as Int - touchSlopField.set(recyclerView, touchSlop * f) // "8" was obtained experimentally -} - -/** - * 绑定返回键回调(建议使用该方法) - * @param owner Receive callbacks to a new OnBackPressedCallback when the given LifecycleOwner is at least started. - * This will automatically call addCallback(OnBackPressedCallback) and remove the callback as the lifecycle state changes. As a corollary, if your lifecycle is already at least started, calling this method will result in an immediate call to addCallback(OnBackPressedCallback). - * When the LifecycleOwner is destroyed, it will automatically be removed from the list of callbacks. The only time you would need to manually call OnBackPressedCallback.remove() is if you'd like to remove the callback prior to destruction of the associated lifecycle. - * @param onBackPressed 回调方法;返回true则表示消耗了按键事件,事件不会继续往下传递,相反返回false则表示没有消耗,事件继续往下传递 - * @return 注册的回调对象,如果想要移除注册的回调,直接通过调用[OnBackPressedCallback.remove]方法即可。 - */ -fun androidx.activity.ComponentActivity.addOnBackPressed( - owner: LifecycleOwner, - onBackPressed: () -> Boolean -): OnBackPressedCallback { - return backPressedCallback(onBackPressed).also { - onBackPressedDispatcher.addCallback(owner, it) - } -} - -/** - * 绑定返回键回调,未关联生命周期,建议使用关联生命周期的办法(尤其在fragment中使用,应该关联fragment的生命周期) - */ -fun androidx.activity.ComponentActivity.addOnBackPressed(onBackPressed: () -> Boolean): OnBackPressedCallback { - return backPressedCallback(onBackPressed).also { - onBackPressedDispatcher.addCallback(it) - } -} - -private fun androidx.activity.ComponentActivity.backPressedCallback(onBackPressed: () -> Boolean): OnBackPressedCallback { - return object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - if (!onBackPressed()) { - isEnabled = false - onBackPressedDispatcher.onBackPressed() - isEnabled = true - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/github/jing332/tts_server_android/utils/GcManager.kt b/app/src/main/java/com/github/jing332/tts_server_android/utils/GcManager.kt deleted file mode 100644 index b18c74fcc..000000000 --- a/app/src/main/java/com/github/jing332/tts_server_android/utils/GcManager.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.github.jing332.tts_server_android.utils - -import android.os.SystemClock - - -object GcManager { - var last: Long = 0 - - /** - * 避免频繁GC - */ - @Synchronized - fun doGC() { - if (SystemClock.elapsedRealtime() - last > 10000) { - Runtime.getRuntime().gc() - last = SystemClock.elapsedRealtime() - } - - } - -} diff --git a/app/src/main/java/com/github/jing332/tts_server_android/utils/LiveDataNoStickyExt.kt b/app/src/main/java/com/github/jing332/tts_server_android/utils/LiveDataNoStickyExt.kt deleted file mode 100644 index cb93d06e6..000000000 --- a/app/src/main/java/com/github/jing332/tts_server_android/utils/LiveDataNoStickyExt.kt +++ /dev/null @@ -1,148 +0,0 @@ -package com.github.jing332.tts_server_android.utils - - -import androidx.lifecycle.* - -/** - * 零入侵零反射解决 [LiveData] 在 event 场景下的粘性数据问题 - * - * 原理:既然不能入侵(魔改) [LiveData],那就对 observer 做文章,以静态代理的方式包装 [Observer],当 [Observer.onChanged] 被回调时判定其参数是否是粘性数据,如果是就忽略不处理 - * - * 判定依据:liveData 订阅(即执行 [LiveData.observe])前一刻 liveData 有了数据(即被执行过 setValue,[LiveData.mVersion] 不再是 [LiveData.START_VERSION]),且 observer 处于 active 状态(详见 [LiveData.ObserverWrapper.shouldBeActive]), - * 那么订阅时会立即触发 [Observer.onChanged] 执行,此时认为第一次在 onChanged 收到的参数就是粘滞数据 - * - * ‼️ 该方法中 [owner] 通过 [LifecycleOwner.activeWhenCreated] 扩宽了 [LiveData.LifecycleBoundObserver.shouldBeActive] 判定为 true 的范围; - * 目的在于实时接收并处理 event. 即当 [androidx.lifecycle.Lifecycle.getCurrentState] 处于 [androidx.lifecycle.Lifecycle.State.CREATED] 就开始接收 LiveData 数据, - * 不用等到 [androidx.lifecycle.Lifecycle.State.STARTED] 才开始处理; - * - * 实时接收并处理 Event 的原因: - * - * 1、此处防止数据粘滞的方案原理是识别粘滞数据并跳过对它的处理,如果在 inactive 时间区间内(即 observer observe ~ observer 状态达到 active 这个时间区间)[LiveData.setValue] 被触发,那么该行为不能够被 [NoStickyObserverWrapper] 有效感知 - * (因为处于 inactive 状态,[LiveData.dispatchingValue] -> [LiveData.considerNotify] -> [LiveData.ObserverWrapper.shouldBeActive] 为 false,所以不会回调 [Observer.onChanged]) - * 进而会导致跳过了非粘性数据的 bug 发生。 - * - * 2、event 的场景有别于 state 的场景,前者更加倾向于即时消费数据,不用延迟到 owner 处于 STARTED 状态再接收数据。虽然可以通过更加复杂的判定方案实现更加完美的粘滞数据判定, - * 但 activeWhenCreated 方案原理简单直接,契合 event 场景,且避免了过度复杂的设计 - * - * (复杂方案之一:NoStickyObserverWrapper 构造时持有 liveData 引用,observe 时读取一次 [LiveData.mVersion] 的值并记录(反射读取),[NoStickyObserverWrapper.onChanged] 第一次执行时读取 [LiveData.mVersion] 的值, - * 两者进行比较,根据变化就能知道 inactive 期间是否有被 setValue) - * (复杂方案之二:如果不使用反射,那么在 NoStickyObserverWrapper inactive 期间通过额外执行一次 observeForever 来辅助监视 liveData 的数据变化,当 NoStickyObserverWrapper 状态变更为 active 状态后移除 observeForever 相关配置。。。不推荐,复杂度急剧升高) - * - * ⚠️ 在试图通过 [LiveData.removeObservers] 方法移除 observer 时不能将 [NoStickyObserverWrapper] 真正移除。通常情况下 observer 会随着 owner 持有的 lifecycle 的 destroy 自动移除; - * 非要手动移除 observer 合理的做法是通过 [observeNoSticky](或 [observeForeverNoSticky]) 的返回值得到最终的 observer,再通过 [LiveData.removeObserver] 进行手动移除 - * - * @return 返回实际传入 LiveData 的 Observer,用于进行后续的 [LiveData.removeObserver] 操作 - */ -fun LiveData.observeNoSticky( - owner: LifecycleOwner, observer: Observer -): Observer { - // generate observer - val noStickyObserverWrapper = NoStickyObserverWrapper(this.hasValue(), observer) - // do observe - this.observe(owner.activeWhenCreated(), noStickyObserverWrapper) - return noStickyObserverWrapper -} - -/** - * 零入侵零反射解决 [LiveData] 在 event 场景下的粘性数据问题 - * - * 通过 [LiveData.observeForever] 订阅数据的 observer 是一直处于 active 状态的,详见 [LiveData.AlwaysActiveObserver] - * - * @return 返回实际传入 LiveData 的 observer,用于进行后续的 [LiveData.removeObserver] 操作 - */ -fun LiveData.observeForeverNoSticky( - observer: Observer -): Observer { - // generate observer - val noStickyObserverWrapper = NoStickyObserverWrapper(this.hasValue(), observer) - // do observe - this.observeForever(noStickyObserverWrapper) - return noStickyObserverWrapper -} - -/** - * 检测 LiveData 是否设置过数据(粘滞数据判定的关键方法) - * - * 如果 LiveData 已经有了有效数据([LiveData.mData] 已经不是 [LiveData.NOT_SET], 或 [LiveData.mVersion] 已经不是 [LiveData.START_VERSION]), - * 那么执行 [LiveData.observeForever] 方法时其内部会立即触发 [Observer.onChanged] 执行, - * 利用这个特性得以实现在不魔改 LiveData 的前提下感知 liveData 内部数据状态 - * - * (如果能接受使用反射,那么也可以直接反射读取 [LiveData.mVersion] 看它是不是 [LiveData.START_VERSION]) - */ -fun LiveData<*>.hasValue(): Boolean { - var hasValue = false - val observer = Observer { - hasValue = true - }/* 如果 liveData 设置过数据,会在 observeForever 执行时同步执行 onChanged 回调。*/ - observeForever(observer)/* 用完 observer 后立即移除. */ - removeObserver(observer) - return hasValue -} - -/////////////////////////////////////////////////////////////////////////// -// NoStickyObserverWrapper -/////////////////////////////////////////////////////////////////////////// - -/** - * 对 [Observer] 进行静态代理包装,包装类 [NoStickyObserverWrapper] 拿到数据后识别是否是粘滞数据,如果是那么不将其传递给 [originObserver] - * - * @param hasValueBeforeObserve [LiveData] 在被本 Observer 观察前(即执行 observe)是否已经被设置了数据(没有被设置过数据那么 [LiveData.mData] 是 [LiveData.NOT_SET]) - * @param originObserver 原始的 observer - */ -private class NoStickyObserverWrapper( - private val hasValueBeforeObserve: Boolean, - val originObserver: Observer, -) : Observer { - private var firstTime = true - - override fun onChanged(value: T) { - if (firstTime) { - firstTime = false/* 第一次执行. */ - when {/* 如果 observe 前有了数据,那么跳过该(粘滞数据)*/ - hasValueBeforeObserve -> Unit/* 如果 observe 前还没有数据,那么传递该数据. */ - else -> originObserver.onChanged(value) - } - } else {/* 不是第一次执行则直接传递数据. */ - originObserver.onChanged(value) - } - } - -} - -/** - * 将 owner 的 active 状态从 STARTED 状态扩宽到 CREATED 状态 - * - * Fragment 或 Activity 处于 CREATED 状态时依然要接收 LiveData 的实时数据时,可以使用此方案解决 - */ -fun LifecycleOwner.activeWhenCreated(): LifecycleOwner = ActiveWhenCreateLifecycleOwner(this) - -/** - * 根据当前 owner,构造一个新的 owner,源 owner 处于 CREATED 状态时,新 owner 处于 STARTED 状态(对应 LiveData 的 active 状态) - */ -private class ActiveWhenCreateLifecycleOwner( - origin: LifecycleOwner, -) : LifecycleOwner { - override val lifecycle = LifecycleRegistry(this) - - init { - origin.lifecycle.addObserver(object : DefaultLifecycleObserver { - override fun onCreate(owner: LifecycleOwner) { - lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_CREATE) - lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_START) - } - - override fun onResume(owner: LifecycleOwner) { - lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME) - } - - override fun onPause(owner: LifecycleOwner) { - lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE) - } - - override fun onDestroy(owner: LifecycleOwner) { - lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_STOP) - lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY) - } - }) - } -} diff --git a/app/src/main/java/com/github/jing332/tts_server_android/utils/MyTools.kt b/app/src/main/java/com/github/jing332/tts_server_android/utils/MyTools.kt index 4f66cfa74..dc66d3b51 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/utils/MyTools.kt +++ b/app/src/main/java/com/github/jing332/tts_server_android/utils/MyTools.kt @@ -11,6 +11,7 @@ import android.net.Uri import android.os.Build import android.provider.Settings import android.util.Log +import com.github.jing332.common.utils.ClipboardUtils import com.github.jing332.common.utils.longToast import com.github.jing332.common.utils.runOnUI import com.github.jing332.common.utils.toast diff --git a/build.gradle b/build.gradle index 2268ef28e..cdc6cada3 100644 --- a/build.gradle +++ b/build.gradle @@ -12,4 +12,5 @@ plugins { task clean(type: Delete) { delete rootProject.buildDir -} \ No newline at end of file +} + diff --git a/lib-common/build.gradle.kts b/lib-common/build.gradle.kts index a2a45ad07..ef3388c28 100644 --- a/lib-common/build.gradle.kts +++ b/lib-common/build.gradle.kts @@ -30,13 +30,21 @@ android { kotlinOptions { jvmTarget = "1.8" } + + android { + packaging { + resources { + excludes += setOf("META-INF/INDEX.LIST", "META-INF/*.md") + } + } + } } dependencies { - implementation(libs.splitties.appctx) - implementation(libs.hutool.crypto) - implementation(libs.bundles.network) - implementation(libs.bundles.media3) + api(libs.splitties.appctx) + api(libs.hutool.crypto) + api(libs.bundles.network) + api(libs.bundles.media3) implementation(libs.coreKtx) implementation(libs.appcompat) diff --git a/lib-common/src/main/java/com/github/jing332/common/utils/AndroidExtension.kt b/lib-common/src/main/java/com/github/jing332/common/utils/AndroidExtension.kt new file mode 100644 index 000000000..ba7761290 --- /dev/null +++ b/lib-common/src/main/java/com/github/jing332/common/utils/AndroidExtension.kt @@ -0,0 +1,179 @@ +package com.github.jing332.common.utils + +import android.app.Activity +import android.app.Notification +import android.app.Service +import android.content.BroadcastReceiver +import android.content.ContentResolver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.content.pm.ServiceInfo +import android.content.res.Resources +import android.graphics.Rect +import android.net.Uri +import android.os.Build +import android.os.Bundle +import android.os.IBinder +import android.os.SystemClock +import android.view.HapticFeedbackConstants +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.view.WindowInsets +import androidx.activity.OnBackPressedCallback +import androidx.core.content.ContextCompat +import androidx.lifecycle.LifecycleOwner + +fun Service.startForegroundCompat( + notificationId: Int, + notification: Notification +) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { // A14 + startForeground( + notificationId, + notification, + ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK + ) + } else { + startForeground(notificationId, notification) + } +} + + +fun Context.registerGlobalReceiver( + actions: List, + receiver: BroadcastReceiver +) { + ContextCompat.registerReceiver(this, receiver, IntentFilter().apply { + actions.forEach { addAction(it) } + }, ContextCompat.RECEIVER_EXPORTED) +} + +fun View.performLongPress() { + this.isHapticFeedbackEnabled = true + this.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) +} + +fun Context.startActivity(clz: Class<*>) { + startActivity(Intent(this, clz).apply { action = Intent.ACTION_VIEW }) +} + +fun Uri.grantReadWritePermission(contentResolver: ContentResolver) { + contentResolver.takePersistableUriPermission( + this, + Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION + ) +} + + +fun Intent.getBinder(): IBinder? { + val bundle = getBundleExtra("bundle") + return bundle?.getBinder("bigData") +} + +fun Intent.setBinder(binder: IBinder) { + putExtra( + "bundle", + Bundle().apply { + putBinder("bigData", binder) + }) +} + +val Context.layoutInflater: LayoutInflater + get() = LayoutInflater.from(this) + +fun ViewGroup.setMarginMatchParent() { + this.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT +} + +/** + * 重启当前 Activity + */ +fun Activity.restart() { + finish() + ContextCompat.startActivity(this, intent, null) +} + +@Suppress("DEPRECATION") +val Activity.displayHeight: Int + get() { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + val windowMetrics = windowManager.currentWindowMetrics + val insets = windowMetrics.windowInsets.getInsetsIgnoringVisibility( + WindowInsets.Type.systemBars() or WindowInsets.Type.displayCutout() + ) + windowMetrics.bounds.height() - insets.bottom - insets.top + } else + windowManager.defaultDisplay.height + } + +/** + * 点击防抖动 + */ +fun View.clickWithThrottle(throttleTime: Long = 600L, action: (v: View) -> Unit) { + this.setOnClickListener(object : View.OnClickListener { + private var lastClickTime: Long = 0 + + override fun onClick(v: View) { + if (SystemClock.elapsedRealtime() - lastClickTime < throttleTime) return + else action(v) + + lastClickTime = SystemClock.elapsedRealtime() + } + }) +} + +/** + * View 是否在屏幕上可见 + */ +fun View.isVisibleOnScreen(): Boolean { + if (!isShown) { + return false + } + val actualPosition = Rect() + val isGlobalVisible = getGlobalVisibleRect(actualPosition) + val screenWidth = Resources.getSystem().displayMetrics.widthPixels + val screenHeight = Resources.getSystem().displayMetrics.heightPixels + val screen = Rect(0, 0, screenWidth, screenHeight) + return isGlobalVisible && Rect.intersects(actualPosition, screen) +} + + +/** + * 绑定返回键回调(建议使用该方法) + * @param owner Receive callbacks to a new OnBackPressedCallback when the given LifecycleOwner is at least started. + * This will automatically call addCallback(OnBackPressedCallback) and remove the callback as the lifecycle state changes. As a corollary, if your lifecycle is already at least started, calling this method will result in an immediate call to addCallback(OnBackPressedCallback). + * When the LifecycleOwner is destroyed, it will automatically be removed from the list of callbacks. The only time you would need to manually call OnBackPressedCallback.remove() is if you'd like to remove the callback prior to destruction of the associated lifecycle. + * @param onBackPressed 回调方法;返回true则表示消耗了按键事件,事件不会继续往下传递,相反返回false则表示没有消耗,事件继续往下传递 + * @return 注册的回调对象,如果想要移除注册的回调,直接通过调用[OnBackPressedCallback.remove]方法即可。 + */ +fun androidx.activity.ComponentActivity.addOnBackPressed( + owner: LifecycleOwner, + onBackPressed: () -> Boolean +): OnBackPressedCallback { + return backPressedCallback(onBackPressed).also { + onBackPressedDispatcher.addCallback(owner, it) + } +} + +/** + * 绑定返回键回调,未关联生命周期,建议使用关联生命周期的办法(尤其在fragment中使用,应该关联fragment的生命周期) + */ +fun androidx.activity.ComponentActivity.addOnBackPressed(onBackPressed: () -> Boolean): OnBackPressedCallback { + return backPressedCallback(onBackPressed).also { + onBackPressedDispatcher.addCallback(it) + } +} + +private fun androidx.activity.ComponentActivity.backPressedCallback(onBackPressed: () -> Boolean): OnBackPressedCallback { + return object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + if (!onBackPressed()) { + isEnabled = false + onBackPressedDispatcher.onBackPressed() + isEnabled = true + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/jing332/tts_server_android/utils/ClipBoardUtils.kt b/lib-common/src/main/java/com/github/jing332/common/utils/ClipBoardUtils.kt similarity index 69% rename from app/src/main/java/com/github/jing332/tts_server_android/utils/ClipBoardUtils.kt rename to lib-common/src/main/java/com/github/jing332/common/utils/ClipBoardUtils.kt index 166abe067..8edd8ce0c 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/utils/ClipBoardUtils.kt +++ b/lib-common/src/main/java/com/github/jing332/common/utils/ClipBoardUtils.kt @@ -1,10 +1,10 @@ -package com.github.jing332.tts_server_android.utils +package com.github.jing332.common.utils import android.content.ClipData import android.content.ClipboardManager import android.content.ClipboardManager.OnPrimaryClipChangedListener import android.content.Context -import com.github.jing332.tts_server_android.App +import splitties.init.appCtx /** @@ -15,6 +15,7 @@ import com.github.jing332.tts_server_android.App * desc : utils about clipboard * */ +@Suppress("unused") object ClipboardUtils { /** * Copy the text to clipboard. @@ -24,8 +25,8 @@ object ClipboardUtils { * @param text The text. */ fun copyText(text: CharSequence?) { - val cm = App.instance.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - cm.setPrimaryClip(ClipData.newPlainText(App.instance.getPackageName(), text)) + val cm = appCtx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + cm.setPrimaryClip(ClipData.newPlainText(appCtx.packageName, text)) } /** @@ -35,7 +36,7 @@ object ClipboardUtils { * @param text The text. */ fun copyText(label: CharSequence?, text: CharSequence?) { - val cm = App.instance.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val cm = appCtx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager cm.setPrimaryClip(ClipData.newPlainText(label, text)) } @@ -43,7 +44,7 @@ object ClipboardUtils { * Clear the clipboard. */ fun clear() { - val cm = App.instance.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val cm = appCtx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager cm.setPrimaryClip(ClipData.newPlainText(null, "")) } @@ -53,7 +54,7 @@ object ClipboardUtils { * @return the label for clipboard */ fun getLabel(): CharSequence { - val cm = App.instance + val cm = appCtx .getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val des = cm.primaryClipDescription ?: return "" return des.label ?: return "" @@ -67,10 +68,10 @@ object ClipboardUtils { val text: CharSequence get() { val cm = - App.instance.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + appCtx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clip = cm.primaryClip if (clip != null && clip.itemCount > 0) { - val text = clip.getItemAt(0).coerceToText(App.instance) + val text = clip.getItemAt(0).coerceToText(appCtx) if (text != null) { return text } @@ -82,7 +83,7 @@ object ClipboardUtils { * Add the clipboard changed listener. */ fun addChangedListener(listener: OnPrimaryClipChangedListener?) { - val cm = App.instance.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val cm = appCtx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager cm.addPrimaryClipChangedListener(listener) } @@ -90,7 +91,7 @@ object ClipboardUtils { * Remove the clipboard changed listener. */ fun removeChangedListener(listener: OnPrimaryClipChangedListener?) { - val cm = App.instance.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val cm = appCtx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager cm.removePrimaryClipChangedListener(listener) } } \ No newline at end of file diff --git a/app/src/main/java/com/github/jing332/tts_server_android/utils/DecimalUtils.kt b/lib-common/src/main/java/com/github/jing332/common/utils/DecimalUtils.kt similarity index 79% rename from app/src/main/java/com/github/jing332/tts_server_android/utils/DecimalUtils.kt rename to lib-common/src/main/java/com/github/jing332/common/utils/DecimalUtils.kt index ef3c05d25..13ffe5463 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/utils/DecimalUtils.kt +++ b/lib-common/src/main/java/com/github/jing332/common/utils/DecimalUtils.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.utils +package com.github.jing332.common.utils import java.math.BigDecimal import java.math.RoundingMode diff --git a/app/src/main/java/com/github/jing332/tts_server_android/utils/ParcelUtils.kt b/lib-common/src/main/java/com/github/jing332/common/utils/ParcelUtils.kt similarity index 87% rename from app/src/main/java/com/github/jing332/tts_server_android/utils/ParcelUtils.kt rename to lib-common/src/main/java/com/github/jing332/common/utils/ParcelUtils.kt index 4e1660f53..84eb82583 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/utils/ParcelUtils.kt +++ b/lib-common/src/main/java/com/github/jing332/common/utils/ParcelUtils.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.utils +package com.github.jing332.common.utils import android.os.Parcel import android.os.Parcelable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/utils/SizeUtils.kt b/lib-common/src/main/java/com/github/jing332/common/utils/SizeUtils.kt similarity index 89% rename from app/src/main/java/com/github/jing332/tts_server_android/utils/SizeUtils.kt rename to lib-common/src/main/java/com/github/jing332/common/utils/SizeUtils.kt index 6085a98cc..745d3a50f 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/utils/SizeUtils.kt +++ b/lib-common/src/main/java/com/github/jing332/common/utils/SizeUtils.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.utils +package com.github.jing332.common.utils import android.content.res.Resources @@ -48,4 +48,7 @@ object SizeUtils { val fontScale: Float = Resources.getSystem().getDisplayMetrics().scaledDensity return (pxValue / fontScale + 0.5f).toInt() } -} \ No newline at end of file +} + +val Int.dp: Int get() = SizeUtils.dp2px(this.toFloat()) +val Int.px: Int get() = SizeUtils.px2dp(this.toFloat()) \ No newline at end of file diff --git a/lib-compose/.gitignore b/lib-compose/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/lib-compose/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/lib-compose/build.gradle.kts b/lib-compose/build.gradle.kts new file mode 100644 index 000000000..98ccd6231 --- /dev/null +++ b/lib-compose/build.gradle.kts @@ -0,0 +1,75 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) +} + +android { + namespace = "com.github.jing332.compose" + compileSdk = 34 + + defaultConfig { + minSdk = 21 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + + buildFeatures { + compose = true + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.composeComplile.get() + } + + android { + packaging { + resources { + excludes += setOf("META-INF/INDEX.LIST", "META-INF/*.md") + } + } + } +} + +dependencies { + api(project(":lib-common")) + + implementation(libs.bundles.markwon) + implementation(libs.bundles.accompanist) + + val composeBom = platform(libs.compose.bom) +// def composeBom = platform("dev.chrisbanes.compose:compose-bom:2024.01.00-alpha01") + implementation(composeBom) + androidTestImplementation(composeBom) + api(libs.bundles.compose) + api(libs.bundles.compose.material3) + + androidTestApi("androidx.compose.ui:ui-test-junit4") + debugApi("androidx.compose.ui:ui-test-manifest") + api("androidx.compose.ui:ui-tooling-preview") + debugApi("androidx.compose.ui:ui-tooling") + + implementation(libs.coreKtx) + implementation(libs.appcompat) + implementation(libs.material) + testImplementation(libs.junit) + androidTestImplementation(libs.ext.junit) + androidTestImplementation(libs.espresso.core) +} \ No newline at end of file diff --git a/lib-compose/consumer-rules.pro b/lib-compose/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/lib-compose/proguard-rules.pro b/lib-compose/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/lib-compose/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/lib-compose/src/androidTest/java/com/github/jing332/compose/ExampleInstrumentedTest.kt b/lib-compose/src/androidTest/java/com/github/jing332/compose/ExampleInstrumentedTest.kt new file mode 100644 index 000000000..8702b6467 --- /dev/null +++ b/lib-compose/src/androidTest/java/com/github/jing332/compose/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.github.jing332.compose + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.github.jing332.compose_common.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/lib-compose/src/main/AndroidManifest.xml b/lib-compose/src/main/AndroidManifest.xml new file mode 100644 index 000000000..a5918e68a --- /dev/null +++ b/lib-compose/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/lib-compose/src/main/java/com/github/jing332/compose/ComposeExtensions.kt b/lib-compose/src/main/java/com/github/jing332/compose/ComposeExtensions.kt new file mode 100644 index 000000000..47f5fa11b --- /dev/null +++ b/lib-compose/src/main/java/com/github/jing332/compose/ComposeExtensions.kt @@ -0,0 +1,85 @@ +package com.github.jing332.compose + +import android.graphics.Typeface +import android.text.Spanned +import android.text.style.ForegroundColorSpan +import android.text.style.StyleSpan +import android.text.style.UnderlineSpan +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.combinedClickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.material.ripple.rememberRipple +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.AnnotatedString +import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.buildAnnotatedString +import androidx.compose.ui.text.font.FontStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextDecoration + +object ComposeExtensions { + @OptIn(ExperimentalFoundationApi::class) + @Composable + fun Modifier.clickableRipple( + enabled: Boolean = true, + role: Role? = null, + onLongClick: (() -> Unit)? = null, + onLongClickLabel: String? = null, + onClickLabel: String? = null, + onClick: () -> Unit, + ) = + this.combinedClickable( + enabled = enabled, + role = role, + indication = rememberRipple(), + interactionSource = remember { MutableInteractionSource() }, + onClickLabel = onClickLabel, + onClick = onClick, + onLongClick = onLongClick, + onLongClickLabel = onLongClickLabel, + ) + + + fun Spanned.toAnnotatedString(): AnnotatedString = buildAnnotatedString { + val spanned = this@toAnnotatedString + append(spanned.toString()) + getSpans(0, spanned.length, Any::class.java).forEach { span -> + val start = getSpanStart(span) + val end = getSpanEnd(span) + when (span) { + is StyleSpan -> when (span.style) { + Typeface.BOLD -> addStyle( + SpanStyle(fontWeight = FontWeight.Bold), + start, + end + ) + + Typeface.ITALIC -> addStyle(SpanStyle(fontStyle = FontStyle.Italic), start, end) + Typeface.BOLD_ITALIC -> addStyle( + SpanStyle( + fontWeight = FontWeight.Bold, + fontStyle = FontStyle.Italic + ), start, end + ) + } + + is UnderlineSpan -> addStyle( + SpanStyle(textDecoration = TextDecoration.Underline), + start, + end + ) + + is ForegroundColorSpan -> addStyle( + SpanStyle(color = Color(span.foregroundColor)), + start, + end + ) + } + } + } +} + diff --git a/lib-compose/src/main/java/com/github/jing332/compose/ComposeWidgetSettings.kt b/lib-compose/src/main/java/com/github/jing332/compose/ComposeWidgetSettings.kt new file mode 100644 index 000000000..7fbc97ee4 --- /dev/null +++ b/lib-compose/src/main/java/com/github/jing332/compose/ComposeWidgetSettings.kt @@ -0,0 +1,5 @@ +package com.github.jing332.compose + +object ComposeWidgetSettings { + var maxDropDownCount: Int = 3 +} \ No newline at end of file diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppBottomSheet.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppBottomSheet.kt similarity index 95% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppBottomSheet.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/AppBottomSheet.kt index a1d345159..67f15556b 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppBottomSheet.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppBottomSheet.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppDialog.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppDialog.kt similarity index 90% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppDialog.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/AppDialog.kt index f08b49e92..c8ebfa626 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppDialog.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppDialog.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -9,7 +9,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.AlertDialog import androidx.compose.material3.BasicAlertDialog import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.LocalTextStyle @@ -19,28 +18,20 @@ import androidx.compose.material3.Text import androidx.compose.material3.TextButton import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.Layout import androidx.compose.ui.layout.Placeable -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.platform.LocalSoftwareKeyboardController import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.window.DialogProperties -import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.asActivity -import com.github.jing332.tts_server_android.compose.asAppCompatActivity -import com.github.jing332.tts_server_android.compose.systts.replace.edit.SoftKeyboardInputToolbar +import com.github.jing332.compose.R import kotlin.math.max @Preview @@ -86,7 +77,11 @@ fun AppDialog( buttons: @Composable BoxScope.() -> Unit = { TextButton(onClick = onDismissRequest) { Text(stringResource(id = R.string.close)) } }, -) = BasicAlertDialog(modifier = modifier, onDismissRequest = onDismissRequest, properties = properties) { +) = BasicAlertDialog( + modifier = modifier, + onDismissRequest = onDismissRequest, + properties = properties +) { Surface( tonalElevation = 8.dp, shadowElevation = 8.dp, shape = MaterialTheme.shapes.extraLarge ) { diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppLauncherIcon.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppLauncherIcon.kt similarity index 90% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppLauncherIcon.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/AppLauncherIcon.kt index f767bdf80..b0631d74f 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppLauncherIcon.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppLauncherIcon.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import android.graphics.drawable.AdaptiveIconDrawable import android.os.Build @@ -15,7 +15,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.core.content.res.ResourcesCompat import androidx.core.graphics.drawable.toBitmap -import com.github.jing332.tts_server_android.R // https://gist.github.com/tkuenneth/ddf598663f041dc79960cda503d14448?permalink_comment_id=4660486#gistcomment-4660486 @Composable @@ -35,10 +34,10 @@ fun adaptiveIconPainterResource(@DrawableRes id: Int): Painter { } @Composable -fun AppLauncherIcon(modifier: Modifier) { +fun AppLauncherIcon(modifier: Modifier, @DrawableRes resourceId: Int) { Image( modifier = modifier.clip(CircleShape), - painter = adaptiveIconPainterResource(R.mipmap.ic_app_launcher_round), + painter = adaptiveIconPainterResource(resourceId), contentDescription = "LOGO" ) // ResourcesCompat.getDrawable( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppSelectionDialog.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppSelectionDialog.kt similarity index 95% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppSelectionDialog.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/AppSelectionDialog.kt index ca7e1d985..4fd5d6690 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppSelectionDialog.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppSelectionDialog.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.background import androidx.compose.foundation.layout.BoxScope @@ -37,11 +37,11 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.utils.ClipboardUtils -import com.github.jing332.tts_server_android.utils.clickableRipple -import com.github.jing332.tts_server_android.utils.performLongPress +import com.github.jing332.common.utils.ClipboardUtils +import com.github.jing332.common.utils.performLongPress import com.github.jing332.common.utils.toast +import com.github.jing332.compose.ComposeExtensions.clickableRipple +import com.github.jing332.compose.R import kotlinx.coroutines.delay import kotlinx.coroutines.isActive @@ -131,7 +131,8 @@ fun AppSelectionDialog( LazyColumn(state = state) { itemsIndexed(entries) { i, entry -> if (searchEnabled && searchText.isNotBlank() && - !entry.contains(searchText, ignoreCase = true)) return@itemsIndexed + !entry.contains(searchText, ignoreCase = true) + ) return@itemsIndexed val current = values[i] val isSelected = onValueSame(value, current) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppSpinner.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppSpinner.kt similarity index 96% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppSpinner.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/AppSpinner.kt index cf4cc34a8..410720607 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppSpinner.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppSpinner.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -25,7 +25,7 @@ import androidx.compose.ui.platform.LocalTextInputService import androidx.compose.ui.platform.LocalTextToolbar import androidx.compose.ui.semantics.Role import androidx.compose.ui.tooling.preview.Preview -import com.github.jing332.tts_server_android.conf.AppConfig +import com.github.jing332.compose.ComposeWidgetSettings import kotlin.math.max @OptIn(ExperimentalMaterial3Api::class) @@ -122,7 +122,7 @@ fun AppSpinner( value: Any, values: List, entries: List, - maxDropDownCount: Int = AppConfig.spinnerMaxDropDownCount.value, + maxDropDownCount: Int = ComposeWidgetSettings.maxDropDownCount, enabled: Boolean = true, onValueSame: (current: Any, new: Any) -> Boolean = { current, new -> current == new }, diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppTooltip.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppTooltip.kt similarity index 93% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppTooltip.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/AppTooltip.kt index 458f5f147..9a5ff1f6f 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/AppTooltip.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/AppTooltip.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.PlainTooltip diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ButtonToggleGroup.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/ButtonToggleGroup.kt similarity index 99% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ButtonToggleGroup.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/ButtonToggleGroup.kt index ce4262af9..84182d3f4 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ButtonToggleGroup.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/ButtonToggleGroup.kt @@ -1,7 +1,6 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.Image import androidx.compose.foundation.focusGroup import androidx.compose.foundation.layout.Column diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/CheckMenuItem.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/CheckMenuItem.kt similarity index 95% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/CheckMenuItem.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/CheckMenuItem.kt index af1bf8294..73f111def 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/CheckMenuItem.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/CheckMenuItem.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.PaddingValues diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/DenseTextField.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/DenseTextField.kt similarity index 99% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/DenseTextField.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/DenseTextField.kt index e4bc3f7a5..86f298236 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/DenseTextField.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/DenseTextField.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.interaction.InteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/DropdownTextField.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/DropdownTextField.kt similarity index 92% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/DropdownTextField.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/DropdownTextField.kt index 626c3d2a2..ceb2a1f7b 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/DropdownTextField.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/DropdownTextField.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxWidth @@ -102,13 +102,13 @@ fun DropdownTextField( @Preview @Composable private fun PreviewDropdownTextField() { - var key by remember { mutableIntStateOf(1) } - AppSpinner( - label = { Text("所属分组") }, - value = key, - values = listOf(1, 2, 3), - entries = listOf("1", "2", "3"), - ) { k, _ -> - key = k as Int - } +// var key by remember { mutableIntStateOf(1) } +// AppSpinner( +// label = { Text("所属分组") }, +// value = key, +// values = listOf(1, 2, 3), +// entries = listOf("1", "2", "3"), +// ) { k, _ -> +// key = k as Int +// } } \ No newline at end of file diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/EmptyTextToolbar.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/EmptyTextToolbar.kt similarity index 89% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/EmptyTextToolbar.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/EmptyTextToolbar.kt index 90fb82207..5b40c66b6 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/EmptyTextToolbar.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/EmptyTextToolbar.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.ui.geometry.Rect import androidx.compose.ui.platform.TextToolbar diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ErrorDialog.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/ErrorDialog.kt similarity index 96% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ErrorDialog.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/ErrorDialog.kt index f09753433..896f749bd 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ErrorDialog.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/ErrorDialog.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Column @@ -23,8 +23,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.R - +import com.github.jing332.compose.R @OptIn(ExperimentalMaterial3Api::class) @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ExpandableText.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/ExpandableText.kt similarity index 100% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/ExpandableText.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/ExpandableText.kt diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/HtmlText.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/HtmlText.kt similarity index 94% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/HtmlText.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/HtmlText.kt index 0c5166d9f..5b29b20ff 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/HtmlText.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/HtmlText.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.text.InlineTextContent import androidx.compose.material3.LocalTextStyle @@ -17,7 +17,7 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.TextUnit import androidx.core.text.HtmlCompat -import com.github.jing332.tts_server_android.utils.toAnnotatedString +import com.github.jing332.compose.ComposeExtensions.toAnnotatedString @Composable fun HtmlText( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LabelSlider.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LabelSlider.kt similarity index 97% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LabelSlider.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/LabelSlider.kt index c05a64212..30de37d73 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LabelSlider.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LabelSlider.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxScope @@ -26,8 +26,8 @@ import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.constraintlayout.compose.ConstraintLayout -import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.utils.performLongPress +import com.github.jing332.common.utils.performLongPress +import com.github.jing332.compose.R @OptIn(ExperimentalComposeUiApi::class) @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LazyListIndexStateSaver.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LazyListIndexStateSaver.kt similarity index 94% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LazyListIndexStateSaver.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/LazyListIndexStateSaver.kt index 0c6919ac2..b3b805ce4 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LazyListIndexStateSaver.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LazyListIndexStateSaver.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.lazy.LazyListState import androidx.compose.runtime.Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingAnimation.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingAnimation.kt similarity index 84% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingAnimation.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingAnimation.kt index 50613ee3b..b9430d47b 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingAnimation.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingAnimation.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.RepeatMode @@ -6,36 +6,21 @@ import androidx.compose.animation.core.infiniteRepeatable import androidx.compose.animation.core.keyframes import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material3.AlertDialog -import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.DialogProperties -import com.github.jing332.tts_server_android.R import kotlinx.coroutines.delay //@OptIn(ExperimentalMaterial3Api::class) diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingContent.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingContent.kt similarity index 95% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingContent.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingContent.kt index 46ba2c620..fa3492f88 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingContent.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingContent.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.layout.Box @@ -22,7 +22,7 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.R +import com.github.jing332.compose.R import kotlinx.coroutines.delay @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingDialog.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingDialog.kt similarity index 98% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingDialog.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingDialog.kt index 66ea10ee7..5a57dfd1b 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LoadingDialog.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LoadingDialog.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.infiniteRepeatable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LongClickIconButton.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LongClickIconButton.kt similarity index 95% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LongClickIconButton.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/LongClickIconButton.kt index ac3285a2c..518bcf3a0 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/LongClickIconButton.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/LongClickIconButton.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background @@ -25,7 +25,7 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalView import androidx.compose.ui.semantics.Role import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.utils.performLongPress +import com.github.jing332.common.utils.performLongPress @OptIn(ExperimentalFoundationApi::class) @Composable diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/Markdown.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/Markdown.kt similarity index 98% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/Markdown.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/Markdown.kt index 10a7b58a5..7ec3879e6 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/Markdown.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/Markdown.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import android.text.Spanned import android.text.method.LinkMovementMethod diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/SelectableText.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/SelectableText.kt similarity index 100% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/SelectableText.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/SelectableText.kt diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/SwitchFloatingAction.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/SwitchFloatingAction.kt similarity index 93% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/SwitchFloatingAction.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/SwitchFloatingAction.kt index d3d355e92..740ccf607 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/SwitchFloatingAction.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/SwitchFloatingAction.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.animation.Crossfade import androidx.compose.animation.animateColorAsState @@ -22,13 +22,11 @@ import androidx.compose.ui.draw.rotate import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.R +import com.github.jing332.compose.R @Composable fun SwitchFloatingButton(modifier: Modifier, switch: Boolean, onSwitchChange: (Boolean) -> Unit) { - val scope = rememberCoroutineScope() - val targetIcon = if (switch) Icons.Filled.Stop else Icons.Filled.Send val rotationAngle by animateFloatAsState(targetValue = if (switch) 360f else 0f, label = "") diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/TextCheckBox.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/TextCheckBox.kt similarity index 88% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/TextCheckBox.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/TextCheckBox.kt index 0f54528c9..652e10611 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/TextCheckBox.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/TextCheckBox.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row @@ -12,9 +12,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp -import com.github.jing332.tts_server_android.utils.clickableRipple +import com.github.jing332.compose.ComposeExtensions.clickableRipple + @Composable fun TextCheckBox( diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/TextFieldDialog.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/TextFieldDialog.kt similarity index 92% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/TextFieldDialog.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/TextFieldDialog.kt index 50c849569..c0528f741 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/TextFieldDialog.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/TextFieldDialog.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import androidx.compose.material3.AlertDialog import androidx.compose.material3.OutlinedTextField diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/Widgets.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/Widgets.kt similarity index 95% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/Widgets.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/Widgets.kt index ec3acf340..deaeb90be 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/Widgets.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/Widgets.kt @@ -1,11 +1,10 @@ -package com.github.jing332.tts_server_android.compose.widgets +package com.github.jing332.compose.widgets import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.SideEffect diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/CharacterStyle.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/CharacterStyle.kt similarity index 88% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/CharacterStyle.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/CharacterStyle.kt index 746205f62..d0905bea1 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/CharacterStyle.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/CharacterStyle.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets.htmlcompose +package com.github.jing332.compose.widgets.htmlcompose import android.text.style.ForegroundColorSpan import android.text.style.StrikethroughSpan diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/HtmlText.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/HtmlText.kt similarity index 98% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/HtmlText.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/HtmlText.kt index eb473f3fa..50aaadbf1 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/HtmlText.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/HtmlText.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets.htmlcompose +package com.github.jing332.compose.widgets.htmlcompose import android.text.style.BulletSpan import android.text.style.ForegroundColorSpan diff --git a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/MetricAffectingSpan.kt b/lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/MetricAffectingSpan.kt similarity index 96% rename from app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/MetricAffectingSpan.kt rename to lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/MetricAffectingSpan.kt index 23260fded..86c2dcce7 100644 --- a/app/src/main/java/com/github/jing332/tts_server_android/compose/widgets/htmlcompose/MetricAffectingSpan.kt +++ b/lib-compose/src/main/java/com/github/jing332/compose/widgets/htmlcompose/MetricAffectingSpan.kt @@ -1,4 +1,4 @@ -package com.github.jing332.tts_server_android.compose.widgets.htmlcompose +package com.github.jing332.compose.widgets.htmlcompose import android.graphics.Typeface import android.text.style.* diff --git a/lib-compose/src/main/res/values-en/strings.xml b/lib-compose/src/main/res/values-en/strings.xml new file mode 100644 index 000000000..01e6346ea --- /dev/null +++ b/lib-compose/src/main/res/values-en/strings.xml @@ -0,0 +1,12 @@ + + + Error + Close + Search + Empty List + Copied + Decrease Seekbar + Increase Seekbar + Loading + Start + diff --git a/lib-compose/src/main/res/values-fa/strings.xml b/lib-compose/src/main/res/values-fa/strings.xml new file mode 100644 index 000000000..4cace9260 --- /dev/null +++ b/lib-compose/src/main/res/values-fa/strings.xml @@ -0,0 +1,12 @@ + + + خطا + بستن + جستجو + لیست خالی است + کپی شد + کاهش دکمه اسکرول + افزایش دکمه اسکرول + در حال بارگذاری + شروع + diff --git a/lib-compose/src/main/res/values/strings.xml b/lib-compose/src/main/res/values/strings.xml new file mode 100644 index 000000000..f0a18ccfc --- /dev/null +++ b/lib-compose/src/main/res/values/strings.xml @@ -0,0 +1,13 @@ + + + 错误 + 关闭 + 搜索 + 列表为空 + 已复制 + 滑动条减少 + 滑动条增加 + 加载中 + 启动 + + diff --git a/lib-compose/src/test/java/com/github/jing332/compose/ExampleUnitTest.kt b/lib-compose/src/test/java/com/github/jing332/compose/ExampleUnitTest.kt new file mode 100644 index 000000000..943866a6a --- /dev/null +++ b/lib-compose/src/test/java/com/github/jing332/compose/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.github.jing332.compose + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/lib-script-engine/build.gradle.kts b/lib-script-engine/build.gradle.kts index 6237a88a8..7b1ba9012 100644 --- a/lib-script-engine/build.gradle.kts +++ b/lib-script-engine/build.gradle.kts @@ -30,14 +30,30 @@ android { kotlinOptions { jvmTarget = "1.8" } + buildFeatures { + compose = true + } + composeOptions{ + kotlinCompilerExtensionVersion = libs.versions.composeComplile.get() + } + + packaging { + resources { + excludes += setOf("META-INF/INDEX.LIST", "META-INF/*.md") + } + } } dependencies { - implementation(fileTree("include" to listOf("*.jar"), "dir" to "libs")) + api(fileTree("include" to listOf("*.jar"), "dir" to "libs")) api(project(":lib-common")) + api(project(":lib-compose")) + implementation(libs.hutool.crypto) + implementation(libs.bundles.network) + implementation(libs.bundles.compose) implementation(libs.coreKtx) implementation(libs.appcompat) diff --git a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/BaseScriptEngine.kt b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/BaseScriptEngine.kt index 9e1f4cefc..d658461cd 100644 --- a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/BaseScriptEngine.kt +++ b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/BaseScriptEngine.kt @@ -28,7 +28,7 @@ open class BaseScriptEngine( @Synchronized open fun eval( - prefixCode: String = "" + prefixCode: String = PackageImporter.default ): Any? { putDefaultObjects() diff --git a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/PackageImporter.kt b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/PackageImporter.kt new file mode 100644 index 000000000..bfb90b01b --- /dev/null +++ b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/PackageImporter.kt @@ -0,0 +1,23 @@ +package com.github.jing332.script_engine.core + +object PackageImporter { + val default by lazy { + appendImportPackage( + "", + listOf( + "com.github.jing332.script_engine.core.type.ws", + "com.github.jing332.script_engine.core.type.ui", + "android.view", + "android.widget", + ) + ) + } + + private fun appendImportPackage(s: String, packages: List): String { + val strBuilder = StringBuilder(s) + if (!strBuilder.endsWith(";")) + strBuilder.append(";") + + return strBuilder.toString() + packages.joinToString(separator = ";") { "importPackage($it)" } + } +} \ No newline at end of file diff --git a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsNet.kt b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsNet.kt index 60641e004..654d96514 100644 --- a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsNet.kt +++ b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsNet.kt @@ -2,7 +2,6 @@ package com.github.jing332.script_engine.core.ext import androidx.annotation.Keep import com.drake.net.Net -import com.drake.net.NetConfig import com.drake.net.exception.ConvertException import okhttp3.MediaType.Companion.toMediaType import okhttp3.MultipartBody @@ -15,7 +14,7 @@ import java.io.File open class JsNet(private val engineId: String) { private val groupId by lazy { engineId + hashCode() } - internal fun cancel() { + fun cancelNetwork() { Net.cancelGroup(groupId) } diff --git a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsUserInterface.kt b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsUserInterface.kt index a672ff7dc..31a0aa147 100644 --- a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsUserInterface.kt +++ b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/ext/JsUserInterface.kt @@ -2,14 +2,15 @@ package com.github.jing332.script_engine.core.ext import android.view.View import android.view.ViewGroup -import com.github.jing332.tts_server_android.app -import com.github.jing332.tts_server_android.utils.dp -import com.github.jing332.tts_server_android.utils.longToast -import com.github.jing332.tts_server_android.utils.toast +import com.github.jing332.common.utils.dp +import com.github.jing332.common.utils.longToast +import com.github.jing332.common.utils.toast +import splitties.init.appCtx + interface JsUserInterface { - fun toast(msg: String) = app.toast(msg) - fun longToast(msg: String) = app.longToast(msg) + fun toast(msg: String) = appCtx.toast(msg) + fun longToast(msg: String) = appCtx.longToast(msg) fun setMargins(v: View, left: Int, top: Int, right: Int, bottom: Int) { (v.layoutParams as ViewGroup.MarginLayoutParams).setMargins( diff --git a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSeekBar.kt b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSeekBar.kt index 197c02f6e..2f3ecf006 100644 --- a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSeekBar.kt +++ b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSeekBar.kt @@ -8,9 +8,9 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.platform.ComposeView -import com.github.jing332.tts_server_android.compose.widgets.LabelSlider -import com.github.jing332.tts_server_android.utils.ThrottleUtil -import com.github.jing332.tts_server_android.utils.toScale +import com.github.jing332.common.utils.ThrottleUtil +import com.github.jing332.common.utils.toScale +import com.github.jing332.compose.widgets.LabelSlider @Suppress("unused") @SuppressLint("ViewConstructor") diff --git a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSpinner.kt b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSpinner.kt index 8c0ab7ad1..c6fd7db62 100644 --- a/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSpinner.kt +++ b/lib-script-engine/src/main/java/com/github/jing332/script_engine/core/type/ui/JSpinner.kt @@ -5,19 +5,15 @@ package com.github.jing332.script_engine.core.type.ui import android.annotation.SuppressLint import android.content.Context import android.widget.FrameLayout -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.res.stringResource -import com.github.jing332.tts_server_android.R -import com.github.jing332.tts_server_android.compose.widgets.AppSpinner +import com.github.jing332.compose.widgets.AppSpinner import kotlin.math.max @Suppress("MemberVisibilityCanBePrivate") @@ -70,17 +66,16 @@ class JSpinner(context: Context, val hint: CharSequence) : FrameLayout(context) @Composable fun Content() { val item = mItems.getOrElse(mSelectedPosition) { mItems.getOrNull(0) } ?: Item("null", Unit) - if (mItems.isEmpty()){ + if (mItems.isEmpty()) { AppSpinner( label = { Text(hint.toString()) }, value = item.value, values = listOf(Unit), - entries = listOf(stringResource(id = R.string.empty_list)), + entries = listOf(stringResource(id = com.github.jing332.compose.R.string.empty_list)), enabled = false, onSelectedChange = { _, _ -> } ) - } - else + } else AppSpinner( label = { Text(hint.toString()) }, value = item.value, diff --git a/libs.versions.toml b/libs.versions.toml index 4276c279e..625f1d3ad 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -24,6 +24,7 @@ reorderable = "0.9.6" constraintlayoutCompose = "1.0.1" navigationCompose = "2.7.7" dataSaver = "v1.1.5" +sheet = "0.5.4" okio = "3.3.0" okhttp = "4.11.0" @@ -69,7 +70,15 @@ markwon-linkify = { module = "io.noties.markwon:linkify", version.ref = "markwon android-svg = { module = "com.caverock:androidsvg", version.ref = "androidsgv" } -composeBom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" } +compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" } +compose-foundation = { module = "androidx.compose.foundation:foundation" } +compose-ui = { module = "androidx.compose.ui:ui" } + +compose-material3-core = { module = "androidx.compose.material3:material3" } +compose-material3-winsize = { module = "androidx.compose.material3:material3-window-size-class" } +compose-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" } +compose-material-icons-core = { module = "androidx.compose.material:material-icons-core" } + lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecyle" } lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecyle" } lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecyle" } @@ -80,6 +89,7 @@ navigation-compose = { module = "androidx.navigation:navigation-compose", versio compose-reorderable = { module = "org.burnoutcrew.composereorderable:reorderable", version.ref = "reorderable" } compose-datasaver = { module = "com.github.FunnySaltyFish.ComposeDataSaver:data-saver", version.ref = "dataSaver" } +compose-sheet = { module = "io.github.dokar3:sheets-m3", version.ref = "sheet" } about = { module = "com.mikepenz:aboutlibraries-core", version.ref = "about" } about-compose = { module = "com.mikepenz:aboutlibraries-compose", version.ref = "about" } @@ -109,9 +119,11 @@ room = ["roomRuntime", "roomKtx"] accompanist = ["accompanist-systemuicontroller", "accompanist-nativation-animation", "accompanist-webview", "accompanist-permissions"] lifecycle = ["lifecycle-runtime-compose", "lifecycle-viewmodel-ktx", "lifecycle-livedata-ktx"] compose = [ + "compose-foundation", "compose-ui", "activity-compose", "constraintlayout-compose", "navigation-compose", - "compose-reorderable", "compose-datasaver" + "compose-reorderable", "compose-datasaver", "compose-sheet" ] +compose-material3 = ["compose-material-icons-core", "compose-material-icons-extended", "compose-material3-winsize", "compose-material3-core"] about = ["about", "about-compose"] network = ["okio", "okhttp", "net"] ui = ["material", "recyclerview"] diff --git a/settings.gradle b/settings.gradle index 42ce96787..5b271df72 100644 --- a/settings.gradle +++ b/settings.gradle @@ -30,3 +30,4 @@ include ':lib-gojni-aar' //include ':core' include ':lib-script-engine' include ':lib-common' +include ':lib-compose'