Skip to content

Commit

Permalink
Impl Wear OS Support
Browse files Browse the repository at this point in the history
  • Loading branch information
mbakgun committed Aug 18, 2023
1 parent 8dd5495 commit 97c35be
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 2 deletions.
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ rootProject.name = "MidJourneyImagesComposeMultiplatform"

include(":androidApp")
include(":shared")
include(":wearApp")

pluginManagement {
repositories {
Expand Down
5 changes: 3 additions & 2 deletions shared/src/commonMain/kotlin/ui/MjImagesApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,11 @@ fun ScrollToTopButton(
.padding(bottom = 24.dp, end = 25.dp), Alignment.BottomEnd
) {
Button(
onClick = { onClick() }, modifier = Modifier
onClick = { onClick() },
modifier = Modifier
.shadow(10.dp, shape = CircleShape)
.clip(shape = CircleShape)
.size(65.dp),
.size(50.dp),
colors = ButtonDefaults.buttonColors(
backgroundColor = MaterialTheme.colors.background,
contentColor = MaterialTheme.colors.onSurface,
Expand Down
1 change: 1 addition & 0 deletions wearApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
41 changes: 41 additions & 0 deletions wearApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
kotlin("multiplatform")
id("com.android.application")
id("org.jetbrains.compose")
}

kotlin {
androidTarget()
sourceSets {
val androidMain by getting {
dependencies {
implementation(project(":shared"))
api(libs.androidxActivityCompose)
api(libs.androidxAppcompat)
api(libs.androidxCoreKtx)
}
}
}
}

android {
compileSdk = (findProperty("android.compileSdk") as String).toInt()
namespace = "com.mbakgun.mj"

sourceSets["main"].manifest.srcFile("src/main/AndroidManifest.xml")

defaultConfig {
applicationId = "com.mbakgun.mj"
minSdk = (findProperty("android.minSdk") as String).toInt()
targetSdk = (findProperty("android.targetSdk") as String).toInt()
versionCode = 1
versionName = "1.0"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlin {
jvmToolchain(11)
}
}
21 changes: 21 additions & 0 deletions wearApp/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions wearApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:name="android.hardware.type.watch" />

<application
android:allowBackup="true"
android:name=".App"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
<activity
android:name="com.mbakgun.mj.ui.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
17 changes: 17 additions & 0 deletions wearApp/src/main/java/com/mbakgun/mj/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mbakgun.mj

import android.app.Application
import com.mbakgun.mj.di.viewModelModule
import di.initKoin
import org.koin.android.ext.koin.androidContext

class App : Application() {

override fun onCreate() {
super.onCreate()
initKoin {
androidContext(this@App)
modules(viewModelModule)
}
}
}
9 changes: 9 additions & 0 deletions wearApp/src/main/java/com/mbakgun/mj/di/ViewModelModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mbakgun.mj.di

import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module
import ui.MjImagesViewModel

val viewModelModule = module {
viewModel { MjImagesViewModel(get(), get()) }
}
23 changes: 23 additions & 0 deletions wearApp/src/main/java/com/mbakgun/mj/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mbakgun.mj.ui

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import org.koin.android.ext.android.get
import ui.MjImagesApp

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setComposable()
}

private fun setComposable() {
setContent {
MjImagesApp(
viewModel = get()
)
}
}
}
Binary file added wearApp/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Binary file added wearApp/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions wearApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">MidJourney Images Compose Multiplatform</string>
</resources>

0 comments on commit 97c35be

Please sign in to comment.