diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/android/.gitignore @@ -0,0 +1 @@ +/build diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..fffa703 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,38 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-platform-android' + +android { + compileSdkVersion 26 + + + + defaultConfig { + applicationId "software.jonasfranz.android" + minSdkVersion 15 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + +} + +repositories { + google() +} + +dependencies { + expectedBy project(":common") + implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" + implementation 'com.android.support:appcompat-v7:26.1.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' +} diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/android/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 diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..82403e4 --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/src/main/java/software/jonasfranz/android/MainActivity.kt b/android/src/main/java/software/jonasfranz/android/MainActivity.kt new file mode 100644 index 0000000..5126265 --- /dev/null +++ b/android/src/main/java/software/jonasfranz/android/MainActivity.kt @@ -0,0 +1,14 @@ +package software.jonasfranz.android + +import android.support.v7.app.AppCompatActivity +import android.os.Bundle +import software.jonasfranz.common.Common + +class MainActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + println(Common().platform()) + } +} diff --git a/android/src/main/java/software/jonasfranz/common/ExceptPlatform.kt b/android/src/main/java/software/jonasfranz/common/ExceptPlatform.kt new file mode 100644 index 0000000..fb26962 --- /dev/null +++ b/android/src/main/java/software/jonasfranz/common/ExceptPlatform.kt @@ -0,0 +1,5 @@ +package software.jonasfranz.common + +actual class Platform actual constructor() { + actual fun platform(): String = "platform-android" +} \ No newline at end of file diff --git a/android/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..c7bd21d --- /dev/null +++ b/android/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/android/src/main/res/drawable/ic_launcher_background.xml b/android/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/android/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/src/main/res/layout/activity_main.xml b/android/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..84f1951 --- /dev/null +++ b/android/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/src/main/res/mipmap-hdpi/ic_launcher.png b/android/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..a2f5908 Binary files /dev/null and b/android/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..1b52399 Binary files /dev/null and b/android/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/android/src/main/res/mipmap-mdpi/ic_launcher.png b/android/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..ff10afd Binary files /dev/null and b/android/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..115a4c7 Binary files /dev/null and b/android/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/android/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..dcd3cd8 Binary files /dev/null and b/android/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..459ca60 Binary files /dev/null and b/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/android/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..8ca12fe Binary files /dev/null and b/android/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..8e19b41 Binary files /dev/null and b/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..b824ebd Binary files /dev/null and b/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..4c19a13 Binary files /dev/null and b/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/android/src/main/res/values/colors.xml b/android/src/main/res/values/colors.xml new file mode 100644 index 0000000..3ab3e9c --- /dev/null +++ b/android/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/android/src/main/res/values/strings.xml b/android/src/main/res/values/strings.xml new file mode 100644 index 0000000..64fad88 --- /dev/null +++ b/android/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + android + diff --git a/android/src/main/res/values/styles.xml b/android/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/android/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/android/src/test/java/software/jonasfranz/android/ExampleUnitTest.kt b/android/src/test/java/software/jonasfranz/android/ExampleUnitTest.kt new file mode 100644 index 0000000..ff2ca95 --- /dev/null +++ b/android/src/test/java/software/jonasfranz/android/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package software.jonasfranz.android + +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) + } +} diff --git a/build.gradle b/build.gradle index 335ad48..9cc82b7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,8 @@ buildscript { + repositories { jcenter() + google() maven { url "http://kotlin.bintray.com/kotlinx" } maven { url "https://plugins.gradle.org/m2/" } maven { url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" } @@ -9,6 +11,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version" classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version" + classpath 'com.android.tools.build:gradle:3.1.0' } } diff --git a/common/src/main/kotlin/Common.kt b/common/src/main/kotlin/Common.kt deleted file mode 100644 index 97e8daf..0000000 --- a/common/src/main/kotlin/Common.kt +++ /dev/null @@ -1,6 +0,0 @@ - -// This code is common across all backends -class Common { - fun common(): String = "common" - fun platform(): String = Platform().platform() // delegates to platform-specific -} \ No newline at end of file diff --git a/common/src/main/kotlin/ExpectPlatform.kt b/common/src/main/kotlin/software/jonasfranz/common/ExpectPlatform.kt similarity index 75% rename from common/src/main/kotlin/ExpectPlatform.kt rename to common/src/main/kotlin/software/jonasfranz/common/ExpectPlatform.kt index 4e446ae..d6ac17f 100644 --- a/common/src/main/kotlin/ExpectPlatform.kt +++ b/common/src/main/kotlin/software/jonasfranz/common/ExpectPlatform.kt @@ -1,4 +1,4 @@ - +package software.jonasfranz.common // This class is expected to have platform-specific impl expect class Platform() { fun platform(): String diff --git a/common/src/test/kotlin/CommonTest.kt b/common/src/test/kotlin/CommonTest.kt index 3089c01..7c8ed5a 100644 --- a/common/src/test/kotlin/CommonTest.kt +++ b/common/src/test/kotlin/CommonTest.kt @@ -1,4 +1,4 @@ -import kotlin.test.* +import software.jonasfranz.common.Common class CommonTest { @Test diff --git a/gradle.properties b/gradle.properties index bfdc630..8b48d62 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -kotlin_version = 1.2.20 +kotlin_version = 1.2.31 gradle_node_version = 1.2.0 node_version = 8.9.3 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9cd4350..b666f9a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jan 24 17:11:50 MSK 2018 +#Mon Apr 02 22:09:09 CEST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/js/src/main/kotlin/ActualPlatform.kt b/js/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt similarity index 73% rename from js/src/main/kotlin/ActualPlatform.kt rename to js/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt index 5086ed4..a70a70d 100644 --- a/js/src/main/kotlin/ActualPlatform.kt +++ b/js/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt @@ -1,4 +1,4 @@ - +package software.jonasfranz.common actual class Platform actual constructor() { actual fun platform(): String = "platform-js" } diff --git a/js/src/test/kotlin/ActualPlatformTest.kt b/js/src/test/kotlin/ActualPlatformTest.kt index 35f0cd9..c704a01 100644 --- a/js/src/test/kotlin/ActualPlatformTest.kt +++ b/js/src/test/kotlin/ActualPlatformTest.kt @@ -1,4 +1,4 @@ -import kotlin.test.* +import software.jonasfranz.common.Platform class ActualPlatformTest { @Test diff --git a/jvm/src/main/kotlin/ActualPlatform.kt b/jvm/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt similarity index 72% rename from jvm/src/main/kotlin/ActualPlatform.kt rename to jvm/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt index 5633817..170db0b 100644 --- a/jvm/src/main/kotlin/ActualPlatform.kt +++ b/jvm/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt @@ -1,4 +1,4 @@ - +package software.jonasfranz.common actual class Platform actual constructor() { actual fun platform(): String = "platform-jvm" -} +} \ No newline at end of file diff --git a/jvm/src/test/kotlin/ActualPlatformTest.kt b/jvm/src/test/kotlin/ActualPlatformTest.kt index 5c50ecb..50231f7 100644 --- a/jvm/src/test/kotlin/ActualPlatformTest.kt +++ b/jvm/src/test/kotlin/ActualPlatformTest.kt @@ -1,3 +1,4 @@ +import software.jonasfranz.common.Platform import kotlin.test.* class ActualPlatformTest { diff --git a/native/src/main/kotlin/ActualPlatform.kt b/native/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt similarity index 74% rename from native/src/main/kotlin/ActualPlatform.kt rename to native/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt index 8479c82..5c80fef 100644 --- a/native/src/main/kotlin/ActualPlatform.kt +++ b/native/src/main/kotlin/software/jonasfranz/common/ActualPlatform.kt @@ -1,3 +1,4 @@ +package software.jonasfranz.common actual class Platform actual constructor() { actual fun platform(): String = "platform-native" diff --git a/settings.gradle b/settings.gradle index 7c0d897..c7b4692 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,8 @@ +include ':android' rootProject.name = 'KotlinMultiplatformPlayground' include 'common' include 'jvm' include 'js' include 'native' +