Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/flow #1

Merged
merged 11 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# ktlint config
[*.{kt,kts}]
ktlint_function_naming_ignore_when_annotated_with=Composable
ktlint_standard_final-newline=disabled
# Can't detect factory function name correctly, so disable it for now.
ktlint_standard_function-naming=disabled
# 下面是一些不太符合个人习惯的

# 强制换行,比如 Modifier 后面跟着很长的一串,那这个 Modifier 的位置,lint 必须另起一行
ktlint_standard_multiline-expression-wrapping=disabled
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ plugins {
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.kotlinx.serialization) apply false
}
36 changes: 28 additions & 8 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

Expand All @@ -7,6 +6,7 @@ plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlinx.serialization)
}

kotlin {
Expand All @@ -16,12 +16,27 @@ kotlin {
jvmTarget.set(JvmTarget.JVM_11)
}
}

sourceSets {

androidMain.dependencies {
implementation(compose.preview)
implementation(libs.androidx.activity.compose)
implementation(libs.navigation)
implementation(sharedLibs.logcat)
implementation(sharedLibs.sugar)
implementation(sharedLibs.koin)
implementation(sharedLibs.bundles.jetpack)
implementation(libs.documentfile)
implementation(libs.bundles.media3)
implementation(dependencies.create(libs.lame.get()).toString()) {
exclude(group = "com.android.support")
}
implementation(dependencies.create(libs.elevenlabs.get()).toString()) {
exclude(group = "org.apache.httpcomponents.core5")
exclude(group = "org.apache.httpcomponents.client5")
exclude(group = "com.fasterxml.jackson.core")
exclude(group = "org.slf4j")
}
}
commonMain.dependencies {
implementation(compose.runtime)
Expand All @@ -30,33 +45,37 @@ kotlin {
implementation(compose.ui)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
implementation(libs.kotlinx.json)
}
}
}

android {
namespace = "com.github.kkoshin.speaker"
namespace = "com.github.kkoshin.muse"
compileSdk = libs.versions.android.compileSdk.get().toInt()

sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")

defaultConfig {
applicationId = "com.github.kkoshin.speaker"
applicationId = "com.github.kkoshin.muse"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
versionName = "0.1.0"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
debug {
versionNameSuffix = ".alpha"
}
release {
isMinifyEnabled = true
}
}
compileOptions {
Expand All @@ -68,6 +87,7 @@ android {
}
dependencies {
debugImplementation(compose.uiTooling)
implementation(platform(sharedLibs.koin.bom))
}
}

18 changes: 11 additions & 7 deletions composeApp/src/androidMain/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:name=".App"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
android:supportsRtl="false"
android:theme="@android:style/Theme.Material.Light.NoActionBar"
tools:replace="android:supportsRtl,android:allowBackup">
<activity
android:exported="true"
android:name=".MainActivity"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|layoutDirection|locale|mcc|navigation|smallestScreenSize|touchscreen|uiMode"
android:name=".MainActivity">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Binary file added composeApp/src/androidMain/assets/ic_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added composeApp/src/androidMain/assets/sample.wav
Binary file not shown.
Binary file not shown.
Binary file added composeApp/src/androidMain/assets/test.mp3
Binary file not shown.
35 changes: 0 additions & 35 deletions composeApp/src/androidMain/kotlin/App.kt

This file was deleted.

7 changes: 0 additions & 7 deletions composeApp/src/androidMain/kotlin/Greeting.kt

This file was deleted.

7 changes: 0 additions & 7 deletions composeApp/src/androidMain/kotlin/Platform.kt

This file was deleted.

34 changes: 34 additions & 0 deletions composeApp/src/androidMain/kotlin/com/github/kkoshin/muse/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.github.kkoshin.muse

import android.app.Application
import com.github.kkoshin.muse.editor.EditorViewModel
import com.github.kkoshin.muse.tts.TTSManager
import com.github.kkoshin.muse.tts.TTSProvider
import com.github.kkoshin.muse.tts.vendor.ElevenLabTTSProvider
import com.github.kkoshin.muse.tts.vendor.MockTTSProvider
import logcat.AndroidLogcatLogger
import logcat.LogPriority
import org.koin.android.ext.koin.androidContext
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.context.GlobalContext.startKoin
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module

class App : Application() {
private val appModule = module {
single<TTSProvider> {
MockTTSProvider()
}
viewModel { EditorViewModel(get()) }
singleOf(::TTSManager)
}

override fun onCreate() {
super.onCreate()
AndroidLogcatLogger.installOnDebuggableApp(this, minPriority = LogPriority.VERBOSE)
startKoin {
androidContext(this@App)
modules(appModule)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.kkoshin.muse

import logcat.logcat

fun debugLog(action: () -> String) = logcat("debugLog") {
action()
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
package com.github.kkoshin.speaker
package com.github.kkoshin.muse

import App
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.activity.enableEdgeToEdge

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

enableEdgeToEdge()
setContent {
App()
MainScreen()
}
}
}

@Preview
@Composable
fun AppAndroidPreview() {
App()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.kkoshin.muse

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.lightColors
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.toRoute
import com.github.kkoshin.muse.editor.EditorArgs
import com.github.kkoshin.muse.editor.EditorScreen
import com.github.kkoshin.muse.export.ExportArgs
import com.github.kkoshin.muse.export.ExportScreen
import com.github.kkoshin.muse.script.ScriptArgs
import com.github.kkoshin.muse.script.ScriptScreen

@Composable
fun MainScreen() {
MaterialTheme(colors = lightColors(primary = Color(0xFF5D9CED))) {
val navController = rememberNavController()
NavHost(
modifier = Modifier.fillMaxSize(),
navController = navController,
startDestination = ScriptArgs,
) {
composable<ScriptArgs> {
ScriptScreen { phrases ->
navController.navigate(EditorArgs(phrases))
}
}

composable<EditorArgs> {
EditorScreen(args = it.toRoute()) { uri ->
navController.navigate(ExportArgs(uri.toString()))
}
}

composable<ExportArgs> {
ExportScreen(args = it.toRoute())
}
}
}
}
Loading