Skip to content

Commit

Permalink
Set up kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
natsuk4ze committed Jul 8, 2023
1 parent 69d7fe2 commit 8158187
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 276 deletions.
18 changes: 9 additions & 9 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b
channel: beta
revision: "8fcb74dbc16b9edb3d3f14c11c627d9e8f24fb1f"
channel: "beta"

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b
base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b
create_revision: 8fcb74dbc16b9edb3d3f14c11c627d9e8f24fb1f
base_revision: 8fcb74dbc16b9edb3d3f14c11c627d9e8f24fb1f
- platform: android
create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b
base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b
create_revision: 8fcb74dbc16b9edb3d3f14c11c627d9e8f24fb1f
base_revision: 8fcb74dbc16b9edb3d3f14c11c627d9e8f24fb1f
- platform: ios
create_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b
base_revision: 74e4b092e5212ebf8292dde2a48d3da960c0920b
create_revision: 8fcb74dbc16b9edb3d3f14c11c627d9e8f24fb1f
base_revision: 8fcb74dbc16b9edb3d3f14c11c627d9e8f24fb1f

# User provided section

Expand Down
26 changes: 22 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,45 +1,63 @@
group 'studio.midoridesign.gal'
version '1.0'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

rootProject.allprojects {
allprojects {
repositories {
google()
mavenCentral()
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 33
if (project.android.hasProperty("namespace")) {
namespace 'studio.midoridesign.gal'
}

compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}

defaultConfig {
minSdkVersion 19
}

dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
}

testOptions {
unitTests.all {
useJUnitPlatform()

testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
Expand Down
221 changes: 0 additions & 221 deletions android/src/main/java/studio/midoridesign/gal/GalPlugin.java

This file was deleted.

35 changes: 35 additions & 0 deletions android/src/main/kotlin/studio/midoridesign/gal/GalPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package studio.midoridesign.gal

import androidx.annotation.NonNull

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result

/** GalPlugin */
class GalPlugin: FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
/// when the Flutter Engine is detached from the Activity
private lateinit var channel : MethodChannel

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "gal")
channel.setMethodCallHandler(this)
}

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
if (call.method == "getPlatformVersion") {
result.success("Android ${android.os.Build.VERSION.RELEASE}")
} else {
result.notImplemented()
}
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}
}
29 changes: 0 additions & 29 deletions android/src/test/java/studio/midoridesign/gal/GalPluginTest.java

This file was deleted.

Loading

0 comments on commit 8158187

Please sign in to comment.