Skip to content

Commit

Permalink
refactor: 移除旧版UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jing332 committed Aug 27, 2023
1 parent efe9cc6 commit ea2431d
Show file tree
Hide file tree
Showing 115 changed files with 168 additions and 12,117 deletions.
30 changes: 5 additions & 25 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,10 @@
android:exported="true"
android:label="@string/plugin_manager"
android:taskAffinity="com.github.jing332.tts_server_android.plugin" />
<activity
android:name=".ui.systts.edit.plugin.PluginTtsEditActivity"
android:exported="false"
android:label="@string/edit_plugin_tts" />

<activity
android:name=".ui.MainActivity"
android:exported="true"
android:label="旧版old">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -175,18 +166,7 @@
</intent-filter>

</activity>
<activity
android:name=".ui.systts.edit.microsoft.MsTtsEditActivity"
android:label="@string/edit_builtin_tts" />
<activity
android:name=".ui.systts.edit.http.HttpTtsEditActivity"
android:label="@string/systts_http_edit_title" />
<activity
android:name=".ui.systts.edit.local.LocalTtsEditActivity"
android:label="@string/edit_local_tts" />
<activity
android:name=".ui.systts.edit.bgm.BgmTtsEditActivity"
android:label="@string/edit_bgm_tts" />

<activity
android:name=".ui.systts.replace.ReplaceManagerActivity"
android:exported="true"
Expand All @@ -198,11 +178,11 @@
android:launchMode="singleTask"
android:theme="@style/Theme.TtsServer.NoActionBar" />
<activity
android:name=".ui.forwarder.ms.ScSwitchActivity"
android:name=".ui.forwarder.MsForwarderSwitchActivity"
android:taskAffinity="sc.switch"
android:theme="@android:style/Theme.NoDisplay" />
<activity
android:name=".ui.forwarder.sys.ScSwitchActivity"
android:name=".ui.forwarder.SystemForwarderSwitchActivity"
android:taskAffinity="sc.switch"
android:theme="@android:style/Theme.NoDisplay" />
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import android.content.Intent
import androidx.core.content.pm.ShortcutInfoCompat
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
import com.github.jing332.tts_server_android.ui.forwarder.ms.ScSwitchActivity
import com.github.jing332.tts_server_android.ui.forwarder.SystemForwarderSwitchActivity
import com.github.jing332.tts_server_android.ui.forwarder.MsForwarderSwitchActivity
import com.github.jing332.tts_server_android.ui.systts.plugin.PluginManagerActivity
import com.github.jing332.tts_server_android.ui.systts.replace.ReplaceManagerActivity

Expand All @@ -18,7 +19,7 @@ object ShortCuts {

private fun buildSysSwitchShortCutInfo(context: Context): ShortcutInfoCompat {
val msSwitchIntent =
buildIntent<com.github.jing332.tts_server_android.ui.forwarder.sys.ScSwitchActivity>(
buildIntent<SystemForwarderSwitchActivity>(
context
)
return ShortcutInfoCompat.Builder(context, "forwarder_sys_switch")
Expand All @@ -31,7 +32,7 @@ object ShortCuts {


private fun buildMsSwitchShortCutInfo(context: Context): ShortcutInfoCompat {
val msSwitchIntent = buildIntent<ScSwitchActivity>(context)
val msSwitchIntent = buildIntent<MsForwarderSwitchActivity>(context)
return ShortcutInfoCompat.Builder(context, "forwarder_ms_switch")
.setShortLabel(context.getString(R.string.forwarder_ms))
.setLongLabel(context.getString(R.string.forwarder_ms))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.github.jing332.tts_server_android.compose.widgets.TextFieldDialog
import com.github.jing332.tts_server_android.conf.MsForwarderConfig
import com.github.jing332.tts_server_android.service.forwarder.ForwarderServiceManager.switchMsTtsForwarder
import com.github.jing332.tts_server_android.service.forwarder.ms.MsTtsForwarderService
import com.github.jing332.tts_server_android.ui.forwarder.ms.ScSwitchActivity
import com.github.jing332.tts_server_android.ui.forwarder.MsForwarderSwitchActivity
import com.github.jing332.tts_server_android.utils.MyTools

@OptIn(ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -62,7 +62,7 @@ fun MsTtsForwarderScreen(
name = context.getString(R.string.forwarder_ms),
id = "switch_ms_forwarder",
iconResId = R.mipmap.ic_launcher_round,
launcherIntent = Intent(context, ScSwitchActivity::class.java)
launcherIntent = Intent(context, MsForwarderSwitchActivity::class.java)
)
},
actions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import com.github.jing332.tts_server_android.compose.nav.forwarder.ForwarderTopA
import com.github.jing332.tts_server_android.conf.SysttsForwarderConfig
import com.github.jing332.tts_server_android.service.forwarder.ForwarderServiceManager.switchSysTtsForwarder
import com.github.jing332.tts_server_android.service.forwarder.system.SysTtsForwarderService
import com.github.jing332.tts_server_android.ui.forwarder.sys.ScSwitchActivity
import com.github.jing332.tts_server_android.ui.forwarder.SystemForwarderSwitchActivity
import com.github.jing332.tts_server_android.utils.MyTools

@Composable
Expand All @@ -42,7 +42,7 @@ fun SystemTtsForwarderScreen(cfgVM: ConfigViewModel = viewModel()) {
name = context.getString(R.string.forwarder_systts),
id = "switch_systts_forwarder",
iconResId = R.mipmap.ic_launcher_round,
launcherIntent = Intent(context, ScSwitchActivity::class.java)
launcherIntent = Intent(context, SystemForwarderSwitchActivity::class.java)
)
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.jing332.tts_server_android.compose.nav.systts.edit.quick
package com.github.jing332.tts_server_android.compose.nav.systts.edit

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,43 @@ import android.speech.tts.TextToSpeech
import android.speech.tts.Voice
import androidx.compose.runtime.mutableStateListOf
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.github.jing332.tts_server_android.App
import com.github.jing332.tts_server_android.ui.systts.edit.local.TtsEngineHelper
import com.github.jing332.tts_server_android.model.LocalTtsEngine
import java.util.Locale

class LocalTtsViewModel : ViewModel() {
private val engineHelper by lazy { TtsEngineHelper(App.context, viewModelScope) }
private val engine by lazy { LocalTtsEngine(App.context) }

val engines = mutableStateListOf<TextToSpeech.EngineInfo>()
val locales = mutableStateListOf<Locale>()
val voices = mutableStateListOf<Voice>()

fun init() {
engines.clear()
engines.addAll(TtsEngineHelper.getEngines())
engines.addAll(LocalTtsEngine.getEngines())
}

suspend fun setEngine(engine: String) {
engineHelper.setEngine(engine)
this.engine.setEngine(engine)

engines.clear()
engines.addAll(TtsEngineHelper.getEngines())
engines.addAll(LocalTtsEngine.getEngines())
}

fun updateLocales() {
locales.clear()
locales.addAll(engineHelper.locales)
locales.addAll(engine.locales)
}

fun updateVoices(locale: String) {
voices.clear()
voices.addAll(engineHelper.voices.filter { it.locale.toLanguageTag() == locale }
voices.addAll(engine.voices.filter { it.locale.toLanguageTag() == locale }
.sortedBy { it.name })
}


override fun onCleared() {
super.onCleared()

engineHelper.shutdown()
engine.shutdown()
}
}
Loading

0 comments on commit ea2431d

Please sign in to comment.