-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: shift business logic to module
- Loading branch information
1 parent
0ae3922
commit d514163
Showing
38 changed files
with
537 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,60 @@ | ||
language: android | ||
dist: trusty | ||
sudo: true | ||
jdk: | ||
- oraclejdk8 | ||
android: | ||
components: | ||
- tools | ||
- android-29 | ||
- build-tools-29.0.2 | ||
- platform-tools | ||
before_cache: | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
cache: | ||
bundler : true | ||
directories: | ||
- "${TRAVIS_BUILD_DIR}/gradle/caches/" | ||
- "${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/" | ||
- "$HOME/.gradle/caches/" | ||
- "$HOME/.gradle/wrapper/" | ||
jobs: | ||
include: | ||
- stage: build android and ios-framework | ||
language: android | ||
dist: trusty | ||
sudo: true | ||
jdk: | ||
- oraclejdk8 | ||
android: | ||
components: | ||
- tools | ||
- android-29 | ||
- build-tools-29.0.2 | ||
- platform-tools | ||
before_cache: | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
cache: | ||
bundler : true | ||
directories: | ||
- "${TRAVIS_BUILD_DIR}/gradle/caches/" | ||
- "${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/" | ||
- "$HOME/.gradle/caches/" | ||
- "$HOME/.gradle/wrapper/" | ||
|
||
install: | ||
- bundle install | ||
install: | ||
- bundle install | ||
|
||
before_script: | ||
- bash scripts/prep-key.sh | ||
- bash scripts/check-screenshots.sh | ||
before_script: | ||
- bash scripts/prep-key.sh | ||
- bash scripts/check-screenshots.sh | ||
|
||
script: | ||
- ./gradlew spotlessCheck | ||
- ./gradlew build --stacktrace | ||
script: | ||
- ./gradlew spotlessCheck | ||
- ./gradlew build --stacktrace | ||
|
||
deploy: | ||
- provider: script | ||
skip_cleanup: true | ||
script: bash scripts/upload-apk.sh | ||
on: | ||
all_branches: true | ||
condition: $TRAVIS_BRANCH =~ ^(master|development)$ | ||
repo: fossasia/badge-magic-android | ||
- provider: script | ||
skip_cleanup: true | ||
script: bash scripts/upload-gh-pages.sh | ||
on: | ||
all_branches: true | ||
repo: fossasia/badge-magic-android | ||
deploy: | ||
- provider: script | ||
skip_cleanup: true | ||
script: bash scripts/upload-apk.sh | ||
on: | ||
all_branches: true | ||
condition: $TRAVIS_BRANCH =~ ^(master|development)$ | ||
repo: fossasia/badge-magic-android | ||
- provider: script | ||
skip_cleanup: true | ||
script: bash scripts/upload-gh-pages.sh | ||
on: | ||
all_branches: true | ||
repo: fossasia/badge-magic-android | ||
- provider: script | ||
skip_cleanup: true | ||
script: bash scripts/upload-ios-framework.sh | ||
on: | ||
all_branches: true | ||
repo: fossasia/badge-magic-android | ||
- stage: build ios | ||
os: osx | ||
osx_image: xcode11.3 | ||
language: objective-c | ||
script: echo "Hello IOS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
id("kotlinx-serialization") | ||
} | ||
|
||
val kt_serial = "0.14.0" | ||
val klockVersion = "1.8.6" | ||
|
||
kotlin { | ||
//select iOS target platform depending on the Xcode environment variables | ||
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget = | ||
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true) | ||
::iosArm64 | ||
else | ||
::iosX64 | ||
|
||
iOSTarget("ios") { | ||
binaries { | ||
framework { | ||
baseName = "BadgeMagicModule" | ||
} | ||
} | ||
} | ||
|
||
jvm("android") | ||
|
||
sourceSets["commonMain"].dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-common") | ||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kt_serial") | ||
implementation("com.soywiz.korlibs.klock:klock:$klockVersion") | ||
} | ||
|
||
sourceSets["androidMain"].dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib") | ||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kt_serial") | ||
} | ||
|
||
sourceSets["iosMain"].dependencies { | ||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$kt_serial") | ||
} | ||
} | ||
|
||
val packForXcode by tasks.creating(Sync::class) { | ||
val targetDir = File(buildDir, "xcode-frameworks") | ||
|
||
/// selecting the right configuration for the iOS | ||
/// framework depending on the environment | ||
/// variables set by Xcode build | ||
val mode = System.getenv("CONFIGURATION") ?: "DEBUG" | ||
val framework = kotlin.targets | ||
.getByName<KotlinNativeTarget>("ios") | ||
.binaries.getFramework(mode) | ||
inputs.property("mode", mode) | ||
dependsOn(framework.linkTask) | ||
|
||
from({ framework.outputDirectory }) | ||
into(targetDir) | ||
|
||
/// generate a helpful ./gradlew wrapper with embedded Java path | ||
doLast { | ||
val gradlew = File(targetDir, "gradlew") | ||
gradlew.writeText("#!/bin/bash\n" | ||
+ "export 'JAVA_HOME=${System.getProperty("java.home")}'\n" | ||
+ "cd '${rootProject.rootDir}'\n" | ||
+ "./gradlew \$@\n") | ||
gradlew.setExecutable(true) | ||
} | ||
} | ||
|
||
tasks.getByName("build").dependsOn(packForXcode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a/badgemagic/data/fragments/ConfigInfo.kt → ...rg/fossasia/badgemagic/data/ConfigInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package org.fossasia.badgemagic.data.fragments | ||
package org.fossasia.badgemagic.data | ||
|
||
data class ConfigInfo(val badgeJSON: String, val fileName: String) |
6 changes: 6 additions & 0 deletions
6
BadgeMagicModule/src/commonMain/kotlin/org/fossasia/badgemagic/data/DataToSend.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.fossasia.badgemagic.data | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class DataToSend(val messages: List<Message>) |
5 changes: 4 additions & 1 deletion
5
...a/badgemagic/data/device/model/Message.kt → ...n/org/fossasia/badgemagic/data/Message.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package org.fossasia.badgemagic.data.device.model | ||
package org.fossasia.badgemagic.data | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Message(val hexStrings: List<String>, val flash: Boolean = false, val marquee: Boolean = false, val speed: Speed = Speed.ONE, val mode: Mode = Mode.LEFT) |
13 changes: 13 additions & 0 deletions
13
BadgeMagicModule/src/commonMain/kotlin/org/fossasia/badgemagic/data/Mode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.fossasia.badgemagic.data | ||
|
||
enum class Mode(val hexValue: Byte) { | ||
LEFT(0x00), | ||
RIGHT(0x01), | ||
UP(0x02), | ||
DOWN(0x03), | ||
FIXED(0x04), | ||
SNOWFLAKE(0x05), | ||
PICTURE(0x06), | ||
ANIMATION(0x07), | ||
LASER(0x08); | ||
} |
12 changes: 12 additions & 0 deletions
12
BadgeMagicModule/src/commonMain/kotlin/org/fossasia/badgemagic/data/Speed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.fossasia.badgemagic.data | ||
|
||
enum class Speed(val hexValue: Byte) { | ||
ONE(0x00), | ||
TWO(0x10), | ||
THREE(0x20), | ||
FOUR(0x30), | ||
FIVE(0x40), | ||
SIX(0x50), | ||
SEVEN(0x60), | ||
EIGHT(0x70); | ||
} |
Oops, something went wrong.