mirror of
https://github.com/tribufu/tribufu-java
synced 2026-05-06 06:47:27 +00:00
Migrate Library to Kotlin
This commit is contained in:
parent
8a3eb4809e
commit
85ca2b7701
12 changed files with 81 additions and 79 deletions
|
|
@ -41,7 +41,9 @@ dependencies {
|
|||
implementation "androidx.core:core-ktx:1.3.2"
|
||||
implementation "androidx.appcompat:appcompat:1.2.0"
|
||||
implementation "com.google.android.material:material:1.3.0"
|
||||
|
||||
testImplementation "junit:junit:4.+"
|
||||
|
||||
androidTestImplementation "androidx.test.ext:junit:1.1.2"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
buildscript {
|
||||
ext.kotlin_version = "1.3.72"
|
||||
ext.kotlin_version = "1.4.31"
|
||||
|
||||
repositories {
|
||||
google()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
plugins {
|
||||
// Apply the scala Plugin to add support for Scala.
|
||||
id "scala"
|
||||
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
|
||||
// Apply the java-library plugin for API and implementation separation.
|
||||
id "java-library"
|
||||
|
|
@ -15,26 +15,21 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
// Use Scala 2.13 in our library project
|
||||
implementation "org.scala-lang:scala-library:2.13.3"
|
||||
// Align versions of all Kotlin components
|
||||
implementation platform("org.jetbrains.kotlin:kotlin-bom")
|
||||
|
||||
// Use the Kotlin JDK 8 standard library.
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||
|
||||
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
|
||||
implementation "com.google.guava:guava:30.0-jre"
|
||||
|
||||
// Use Scalatest for testing our library
|
||||
testImplementation "junit:junit:4.13.1"
|
||||
testImplementation "org.scalatest:scalatest_2.13:3.2.3"
|
||||
testImplementation "org.scalatestplus:junit-4-13_2.13:3.2.2.0"
|
||||
// Use the Kotlin test library.
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
||||
|
||||
// Need scala-xml at test runtime
|
||||
testRuntimeOnly "org.scala-lang.modules:scala-xml_2.13:1.2.0"
|
||||
// Use the Kotlin JUnit integration.
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
|
||||
|
||||
// This dependency is exported to consumers, that is to say found on their compile classpath.
|
||||
api "org.apache.commons:commons-math3:3.6.1"
|
||||
}
|
||||
|
||||
tasks.named("jar") {
|
||||
manifest {
|
||||
attributes("Implementation-Title": "TribuFu", "Implementation-Version": project.version)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
package com.tribufu.sdk
|
||||
|
||||
class System {}
|
||||
interface IHandler {}
|
||||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
package com.tribufu.sdk
|
||||
|
||||
class Handler {}
|
||||
interface ISystem {}
|
||||
13
library/src/main/kotlin/com/tribufu/sdk/TribuFu.kt
Normal file
13
library/src/main/kotlin/com/tribufu/sdk/TribuFu.kt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
package com.tribufu.sdk
|
||||
|
||||
class TribuFu {
|
||||
// Used to load the 'TribuFu' library on application startup.
|
||||
init {
|
||||
System.loadLibrary("TribuFu_Jvm")
|
||||
}
|
||||
|
||||
/** A native method that is implemented by the 'TribuFu' native library. */
|
||||
external fun Hello(input: String ): String
|
||||
}
|
||||
10
library/src/main/kotlin/com/tribufu/sdk/models/Email.kt
Normal file
10
library/src/main/kotlin/com/tribufu/sdk/models/Email.kt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
package com.tribufu.sdk.models
|
||||
|
||||
class Email {
|
||||
var address = ""
|
||||
var user_id = "1"
|
||||
var confirmed = false
|
||||
var primary = true
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved.
|
||||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
package com.tribufu.sdk.models
|
||||
|
||||
class User {
|
||||
val id = ""
|
||||
val name = ""
|
||||
var id = ""
|
||||
var name = ""
|
||||
var display_name = ""
|
||||
var password_hash = ""
|
||||
var role = Role.User
|
||||
var confirmed = false
|
||||
var two_factor_enabled = false
|
||||
|
|
@ -15,15 +16,15 @@ class User {
|
|||
var parental_control = false
|
||||
var profile_url = ""
|
||||
var public_birthday = false
|
||||
var birthday = ""
|
||||
var Birthday = ""
|
||||
var location = ""
|
||||
var timezone = ""
|
||||
var language = ""
|
||||
var currency = ""
|
||||
var theme = Theme.Light
|
||||
var ip_address = ""
|
||||
val registration_ip_address = ""
|
||||
val Joined = ""
|
||||
var registration_ip_address = ""
|
||||
var Joined = ""
|
||||
var Updated = ""
|
||||
var failed_logins = 0
|
||||
var about = ""
|
||||
|
|
@ -32,21 +33,33 @@ class User {
|
|||
var avatar_url = ""
|
||||
var background_url = ""
|
||||
var status = Status.Offline
|
||||
var last_online = ""
|
||||
var last_activity = ""
|
||||
var last_post = ""
|
||||
var LastOnline = ""
|
||||
var LastActivity = ""
|
||||
var LastPost = ""
|
||||
var warnings = 0
|
||||
var last_warn = ""
|
||||
var LastWarn = ""
|
||||
}
|
||||
|
||||
object Role extends Enumeration {
|
||||
val User, Bot, Helper, Tester, Developer, Moderator, Admin, Root = Value
|
||||
enum class Role {
|
||||
User,
|
||||
Bot,
|
||||
Helper,
|
||||
Tester,
|
||||
Developer,
|
||||
Moderator,
|
||||
Admin,
|
||||
Root
|
||||
}
|
||||
|
||||
object Theme extends Enumeration {
|
||||
val Light, Dark = Value
|
||||
enum class Theme {
|
||||
Light,
|
||||
Dark
|
||||
}
|
||||
|
||||
object Status extends Enumeration {
|
||||
val Offline, Away, Disturb, Online, Playing = Value
|
||||
enum class Status {
|
||||
Offline,
|
||||
Away,
|
||||
Disturb,
|
||||
Online,
|
||||
Playing
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved.
|
||||
|
||||
package com.tribufu.sdk
|
||||
|
||||
class TribuFu {
|
||||
Init()
|
||||
|
||||
// Used to load the 'TribuFu' library on application startup.
|
||||
private def Init() {
|
||||
System.loadLibrary("TribuFu_Jvm")
|
||||
}
|
||||
|
||||
/**
|
||||
* A native method that is implemented by the 'TribuFu' native library.
|
||||
*/
|
||||
@native def Hello(input: String): String
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved.
|
||||
|
||||
package com.tribufu.sdk.models
|
||||
|
||||
class Email() {
|
||||
val address = ""
|
||||
val added = ""
|
||||
var updated = ""
|
||||
var confirmed = false
|
||||
var primary = true
|
||||
}
|
||||
13
library/src/test/kotlin/library/kotlin/TribuFuTest.kt
Normal file
13
library/src/test/kotlin/library/kotlin/TribuFuTest.kt
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
package com.tribufu.sdk
|
||||
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class LibraryTest {
|
||||
@Test fun testSomeLibraryMethod() {
|
||||
//val library = TribuFu()
|
||||
assertTrue(true, "someLibraryMethod should return 'true'")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved.
|
||||
|
||||
package com.tribufu.sdk
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.funsuite.AnyFunSuite
|
||||
import org.scalatestplus.junit.JUnitRunner
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class TribuFuSuite extends AnyFunSuite {
|
||||
test("Hello is always true") {
|
||||
//def library = new TribuFu()
|
||||
//assert(library.Hello("Scala") == "Scala")
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue