diff --git a/src/codegen_types/array.cr b/src/codegen_types/array.cr index 97528bd..f86f110 100644 --- a/src/codegen_types/array.cr +++ b/src/codegen_types/array.cr @@ -65,17 +65,6 @@ module AST def kt_decode(expr, desc) String.build do |io| io << "gson.fromJson>(#{expr}.getJSONArray(\"result\")?.toString(), object : TypeToken>() { }.type) \n" - # io << "ArrayList<#{base.kt_native_type}>().apply {\n" - # io << " for (i in 0 until #{expr}.length()) {\n" - # if base.is_a? AST::ArrayType - # io << " add(#{base.kt_native_type}.fromJsonArray(#{expr}.getJSONArray(i)))\n" - # elsif base.is_a? AST::StructType - # io << " add(#{base.kt_native_type}.fromJson(#{expr}.getJSONObject(i)))\n" - # else - # io << " add(#{base.kt_decode(expr, "i")})" - # end - # io << " }\n" - # io << "" end end diff --git a/src/codegen_types/hex.cr b/src/codegen_types/hex.cr index 71919ac..f92b6a1 100644 --- a/src/codegen_types/hex.cr +++ b/src/codegen_types/hex.cr @@ -39,19 +39,19 @@ module AST # KOTLIN def kt_decode(expr, desc) - raise "Not implemented" + "#{expr}.getString(#{desc})" end def kt_encode(expr, desc) - raise "Not implemented" + "#{expr}" end def kt_native_type - raise "Not implemented" + "String" end def kt_return_type_name - raise "Not implemented" + "hex" end # KOTLIN end diff --git a/src/codegen_types/struct.cr b/src/codegen_types/struct.cr index a7f2629..5937662 100644 --- a/src/codegen_types/struct.cr +++ b/src/codegen_types/struct.cr @@ -99,7 +99,7 @@ module AST io << "#{suffix} \n" index += 1 end - io << "): Serializable {\n\n" + io << "): Serializable {\n" io << " companion object {\n" io << " fun fromJson(jsonToParse : JSONObject): #{kt_native_type} {\n" io << " return gson.fromJson(jsonToParse.toString(), #{name}::class.java)\n" @@ -112,8 +112,8 @@ module AST toJsonExpr = "this@#{name}" io << " fun toJson(): JSONObject {\n" - io << " return JSONObject(gson.toJson(this))" - io << " }" + io << " return JSONObject(gson.toJson(this))\n" + io << " }\n" io << "}" end end diff --git a/src/main b/src/main new file mode 100644 index 0000000..34a6d11 Binary files /dev/null and b/src/main differ diff --git a/src/main.cr b/src/main.cr index c5e8a7c..644e1c8 100644 --- a/src/main.cr +++ b/src/main.cr @@ -2,6 +2,7 @@ require "./syntax/parser" require "./semantic/ast_semantic" require "./target/java_android" require "./target/kt_android" +require "./target/kt_jetpack_android" require "./target/swift_ios" require "./target/typescript_nodeserver" require "./target/typescript_nodeclient" diff --git a/src/target/kt_jetpack_android.cr b/src/target/kt_jetpack_android.cr new file mode 100644 index 0000000..8432a64 --- /dev/null +++ b/src/target/kt_jetpack_android.cr @@ -0,0 +1,356 @@ +require "./target" +require "random/secure" + +class KtJetPackAndroidTarget < Target + def mangle(ident) + if %w[ + in out as as? break class continue do else false + for fun if in !in interface is !is null object + package return super this throw true try typealias + val var when while by catch constructor delegate + dynamic field file finally get import init param + property receiver set setparam in where actual abstract + annotation companion const crossinline data enum expect + external final infix inline inner internal lateinit noinline + open operator out override private protected public reified + sealed suspend tailrec vararg Double Float Long Int Short Byte + ].includes? ident + "_" + ident + else + ident + end + end + + def gen + @io << <<-END + +import android.util.Base64 +import org.json.JSONObject +import java.text.SimpleDateFormat +import java.util.* +import java.util.concurrent.TimeUnit +import android.view.WindowManager +import android.content.pm.PackageManager +import android.os.Build +import org.json.JSONException +import android.annotation.SuppressLint +import android.content.Context +import android.graphics.Point +import android.provider.Settings +import android.util.Log +import com.google.gson.Gson +import okhttp3.* +import java.io.IOException +import java.io.Serializable +import org.json.JSONArray +import com.google.gson.reflect.TypeToken +import kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers.IO +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine +import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.MediaType.Companion.toMediaTypeOrNull +import java.io.InvalidObjectException +import kotlin.concurrent.timerTask +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.Flow + +@ExperimentalCoroutinesApi +@Suppress("DeferredIsResult", "unused") +@SuppressLint("SimpleDateFormat", "StaticFieldLeak") +object API { + + interface Calls {\n +END + @ast.operations.each do |op| + args = op.args.map { |arg| "#{mangle arg.name}: #{arg.type.kt_native_type}" } + returnType = if !op.return_type.is_a? AST::VoidPrimitiveType + "#{op.return_type.kt_native_type}?" + else + "Boolean?" + end + @io << ident(String.build do |io| + io << " fun #{mangle op.pretty_name}(#{args.join(", ")}): Flow> = flow> { \n" + io << " emit(Response(Error(ErrorType.Fatal, \"Not Implemented\"), null)) \n" + io << " }.flowOn(IO)\n" + end) + end + @io << <<-END + } + + lateinit var context: Context + private val gson = Gson() + private val dateTimeFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS",Locale.US).apply { + timeZone = TimeZone.getTimeZone("GMT") + } + private val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) + private var isForcedBaseUrl = false + var DEFAULT_TIMEOUT_SECONDS = 15 + private var BASE_URL = #{@ast.options.url.inspect} + var useStaging = false + private val hexArray = "0123456789abcdef".toCharArray() + + fun init(appContext: Context, useStaging: Boolean, baseUrl: String? = null, timeoutSeconds: Int? = null) { + API.useStaging = useStaging + context = appContext + if (timeoutSeconds != null) + DEFAULT_TIMEOUT_SECONDS = timeoutSeconds + + if (baseUrl != null) { + BASE_URL = baseUrl + isForcedBaseUrl = true + } + } + + var connectionPool = ConnectionPool(100, 80, TimeUnit.SECONDS) + var client = OkHttpClient.Builder() + .connectionPool(connectionPool) + .dispatcher(Dispatcher().apply { maxRequests = 200 ; maxRequestsPerHost = 200 }) + .connectTimeout(80, TimeUnit.SECONDS) + .readTimeout(80, TimeUnit.SECONDS) + .retryOnConnectionFailure(false) + .build() + + class Error( + var type: ErrorType? = null, + var message: String? = null + ) + + private data class InternalResponse(val error: Error?, val data: JSONObject?) + + data class Response(val error: Error?, val data: T?)\n + +END + + @ast.struct_types.each do |t| + t.fields.each do |f| + f.name = mangle f.name + end + @io << ident(t.kt_definition) + @io << "\n\n" + end + + @ast.enum_types.each do |e| + @io << ident(e.kt_definition) + @io << "\n\n" + end + + @io << "var calls = object: Calls { \n" + @ast.operations.each do |op| + args = op.args.map { |arg| "#{mangle arg.name}: #{arg.type.kt_native_type}" } + returnType = if !op.return_type.is_a? AST::VoidPrimitiveType + "#{op.return_type.kt_native_type}?" + else + "Boolean?" + end + @io << ident(String.build do |io| + io << " override fun #{mangle op.pretty_name}(#{args.join(", ")}): Flow> = flow> { \n" + puts = op.args.map { |arg| "put(\"#{arg.name}\", #{arg.type.kt_encode(mangle(arg.name), nil)})" }.join("\n") + bodyParameter = "null" + if op.args.size > 0 + bodyParameter = "bodyArgs" + io << " val #{bodyParameter} = JSONObject().apply {\n" + io << ident ident ident puts + io << "\n" + io << " }\n" + else + "" + end + io << " val r = makeRequest(\"#{mangle op.pretty_name}\", #{bodyParameter})\n" + io << " val responseData = if (r.data != null) {\n" + responseExpression = "" + if op.return_type.is_a? AST::TypeReference + responseExpression = " #{op.return_type.kt_decode("r.data", nil)}\n" + elsif op.return_type.is_a? AST::ArrayType + responseExpression = " #{op.return_type.kt_decode("r.data", nil)}\n" + elsif op.return_type.is_a? AST::OptionalType + responseExpression = " #{op.return_type.kt_decode("r.data", "\"result\"")}\n" + elsif op.return_type.is_a? AST::VoidPrimitiveType + responseExpression = " r.error == null\n" + else + responseExpression = " #{op.return_type.kt_decode("r.data", "\"result\"")}\n" + end + io << ident responseExpression + io << " } else null\n" + io << " emit(Response(r.error, responseData))\n" + io << " }.flowOn(IO)\n" + io << "\n" + end) + end + + @io << <<-END + } + + fun randomBytesHex(len: Int): String { + val bytes = ByteArray(len) + Random().nextBytes(bytes) + return bytesToHex(bytes) + } + + private fun bytesToHex(bytes: ByteArray): String { + val hexChars = CharArray(bytes.size * 2) + for (j in bytes.indices) { + val v = bytes[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4 ] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) + } + + @SuppressLint("HardwareIds") + @Throws(JSONException::class) + private fun device(): JSONObject = + JSONObject().apply { + put("type", "android") + put("fingerprint", "" + Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)) + put("platform", JSONObject().apply { + put("version", Build.VERSION.RELEASE) + put("sdkVersion", Build.VERSION.SDK_INT) + put("brand", Build.BRAND) + put("model", Build.MODEL) + }) + try { + put("version", context.packageManager.getPackageInfo(context.packageName, 0).versionName) + } catch (e: PackageManager.NameNotFoundException) { + put("version", "unknown") + } + + put("language", language()) + put("screen", JSONObject().apply { + val manager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager + val display = manager.defaultDisplay + val size = Point() + display.getSize(size) + put("width", size.x) + put("height", size.y) + }) + val pref = context.getSharedPreferences("api", Context.MODE_PRIVATE) + if (pref.contains("deviceId")) put("id", pref.getString("deviceId", null)) + } + + + private fun language(): String { + val loc = Locale.getDefault() + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + return loc.toLanguageTag() + } + + val sep = '-' + var language = loc.language + var region = loc.country + var variant = loc.variant + + if (language == "no" && region == "NO" && variant == "NY") { + language = "nn" + region = "NO" + variant = "" + } + + if (language.isEmpty() || !language.matches("\\\\[a-zA-Z]{2,8}".toRegex())) { + language = "und" + } else if (language == "iw") { + language = "he" + } else if (language == "in") { + language = "id" + } else if (language == "ji") { + language = "yi" + } + + if (!region.matches("\\\\[a-zA-Z]{2}|\\\\[0-9]{3}".toRegex())) { + region = "" + } + + if (!variant.matches("\\\\[a-zA-Z0-9]{5,8}|\\\\[0-9]\\\\[a-zA-Z0-9]{3}".toRegex())) { + variant = "" + } + + val bcp47Tag = StringBuilder(language) + if (!region.isEmpty()) { + bcp47Tag.append(sep).append(region) + } + if (!variant.isEmpty()) { + bcp47Tag.append(sep).append(variant) + } + + return bcp47Tag.toString() + } + + private suspend fun makeRequest(functionName: String, bodyArgs: JSONObject?, timeoutSeconds: Int = DEFAULT_TIMEOUT_SECONDS): InternalResponse = suspendCoroutine { continuation -> + try { + val body = JSONObject().apply { + put("id", randomBytesHex(8)) + put("device", device()) + put("name", functionName) + put("args", bodyArgs ?: JSONObject()) + put("staging", API.useStaging) + } + + val request = Request.Builder() + .url( + if (isForcedBaseUrl) + "$BASE_URL/$functionName" + else + "https://$BASE_URL${if (useStaging) "-staging" else ""}/$functionName" + ) + .post(body.toString().toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())) + .build() + + val httpTimer = Timer() + val call = client.newCall(request) + call.enqueue(object: Callback { + override fun onFailure(call: Call, e: IOException) { + httpTimer.cancel() + e.printStackTrace() + continuation.resume(InternalResponse(Error(ErrorType.Fatal, e.message ?: "Chamada falhou sem mensagem de erro!"), null)) + } + + override fun onResponse(call: Call, response: okhttp3.Response) { + httpTimer.cancel() + if (response.code == 502) { + continuation.resume(InternalResponse(Error(ErrorType.Fatal, "Erro Fatal (502) - Tente novamente"), null)) + return + } + + val responseBody = try { + val stringBody = response.body?.string() ?: throw InvalidObjectException("") + JSONObject(stringBody) + } catch (e: Exception) { + continuation.resume(InternalResponse(Error(ErrorType.Fatal, "502 - Tente novamente"), null)) + return + } + + val pref = context.getSharedPreferences("api", Context.MODE_PRIVATE) + pref.edit().putString("deviceId", responseBody.getString("deviceId")).apply() + + if (!responseBody.getBoolean("ok")) { + val jsonError = responseBody.getJSONObject("error") + //TODO Fetch correct error type + val error = Error(ErrorType.valueOf(jsonError.getString("type")), jsonError.getString("message")) + Log.e("API Error", jsonError.getString("type") + " - " + error.message) + continuation.resume(InternalResponse(error, null)) + } else { + continuation.resume(InternalResponse(null, responseBody)) + } + } + }) + + httpTimer.schedule( + timerTask { + call.cancel() + val error = Error(ErrorType.Connection, "Timeout") + continuation.resume(InternalResponse(error, null)) + }, + timeoutSeconds * 1000L + ) + } catch (e: JSONException) { + e.printStackTrace() + continuation.resume(InternalResponse(Error(ErrorType.Fatal, e.message ?: "Erro ao parsear json"), null)) + } + } + } +END + end +end + +Target.register(KtJetPackAndroidTarget, target_name: "kt_jetpack_android") diff --git a/target-android-kt-jetpack/.gitignore b/target-android-kt-jetpack/.gitignore new file mode 100644 index 0000000..2f226b6 --- /dev/null +++ b/target-android-kt-jetpack/.gitignore @@ -0,0 +1,205 @@ + +# Created by https://www.gitignore.io/api/android,androidstudio +# Edit at https://www.gitignore.io/?templates=android,androidstudio + +### Android ### +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +### Android Patch ### +gen-external-apklibs +output.json + +# Replacement of .externalNativeBuild directories introduced +# with Android Studio 3.5. +.cxx/ + +### AndroidStudio ### +# Covers files to be ignored for android development using Android Studio. + +# Built application files + +# Files for the ART/Dalvik VM + +# Java class files + +# Generated files + +# Gradle files +.gradle + +# Signing files +.signing/ + +# Local configuration file (sdk path, etc) + +# Proguard folder generated by Eclipse + +# Log Files + +# Android Studio +/*/build/ +/*/local.properties +/*/out +/*/*/build +/*/*/production +*.ipr +*~ +*.swp + +# Android Patch + +# External native build folder generated in Android Studio 2.2 and later + +# NDK +obj/ + +# IntelliJ IDEA +*.iws +/out/ + +# User-specific configurations +.idea/caches/ +.idea/libraries/ +.idea/shelf/ +.idea/.name +.idea/compiler.xml +.idea/copyright/profiles_settings.xml +.idea/encodings.xml +.idea/misc.xml +.idea/scopes/scope_settings.xml +.idea/vcs.xml +.idea/jsLibraryMappings.xml +.idea/datasources.xml +.idea/dataSources.ids +.idea/sqlDataSources.xml +.idea/dynamic.xml +.idea/uiDesigner.xml + +# OS-specific files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Legacy Eclipse project files +.classpath +.project +.cproject +.settings/ + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.war +*.ear + +# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml) +hs_err_pid* + +## Plugin-specific files: + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Mongo Explorer plugin +.idea/mongoSettings.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### AndroidStudio Patch ### + +!/gradle/wrapper/gradle-wrapper.jar + +# End of https://www.gitignore.io/api/android,androidstudio \ No newline at end of file diff --git a/target-android-kt-jetpack/.idea/codeStyles/Project.xml b/target-android-kt-jetpack/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..3279b6b --- /dev/null +++ b/target-android-kt-jetpack/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/target-android-kt-jetpack/.idea/compiler.xml b/target-android-kt-jetpack/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/target-android-kt-jetpack/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/.idea/copyright/profiles_settings.xml b/target-android-kt-jetpack/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/target-android-kt-jetpack/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/.idea/misc.xml b/target-android-kt-jetpack/.idea/misc.xml new file mode 100644 index 0000000..ba7052b --- /dev/null +++ b/target-android-kt-jetpack/.idea/misc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/.idea/modules.xml b/target-android-kt-jetpack/.idea/modules.xml new file mode 100644 index 0000000..455866f --- /dev/null +++ b/target-android-kt-jetpack/.idea/modules.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/.idea/runConfigurations.xml b/target-android-kt-jetpack/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/target-android-kt-jetpack/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/.project b/target-android-kt-jetpack/.project new file mode 100644 index 0000000..0747141 --- /dev/null +++ b/target-android-kt-jetpack/.project @@ -0,0 +1,17 @@ + + + target-android + Project target-android created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/target-android-kt-jetpack/.settings/org.eclipse.buildship.core.prefs b/target-android-kt-jetpack/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..b888301 --- /dev/null +++ b/target-android-kt-jetpack/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +#Wed Dec 13 10:40:10 BRT 2017 +connection.project.dir= diff --git a/target-android-kt-jetpack/Dockerfile b/target-android-kt-jetpack/Dockerfile new file mode 100644 index 0000000..d76d321 --- /dev/null +++ b/target-android-kt-jetpack/Dockerfile @@ -0,0 +1,6 @@ +FROM registry.cubos.io/cubos/android-builder +WORKDIR /root +ADD . /root/ +RUN ./gradlew assembleDebug +ADD build_and_publish.sh / +RUN chmod +x /build_and_publish.sh \ No newline at end of file diff --git a/target-android-kt-jetpack/api/.classpath b/target-android-kt-jetpack/api/.classpath new file mode 100644 index 0000000..8d8d85f --- /dev/null +++ b/target-android-kt-jetpack/api/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/target-android-kt-jetpack/api/.project b/target-android-kt-jetpack/api/.project new file mode 100644 index 0000000..f90ee76 --- /dev/null +++ b/target-android-kt-jetpack/api/.project @@ -0,0 +1,23 @@ + + + api + Project api created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/target-android-kt-jetpack/api/.settings/org.eclipse.buildship.core.prefs b/target-android-kt-jetpack/api/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..963d2e5 --- /dev/null +++ b/target-android-kt-jetpack/api/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +#Wed Dec 13 10:40:10 BRT 2017 +connection.project.dir=.. diff --git a/target-android-kt-jetpack/api/build.gradle b/target-android-kt-jetpack/api/build.gradle new file mode 100644 index 0000000..b92a44d --- /dev/null +++ b/target-android-kt-jetpack/api/build.gradle @@ -0,0 +1,78 @@ +apply plugin: 'com.android.library' +apply plugin: 'maven-publish' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +android { + compileSdkVersion 29 + buildToolsVersion "29.0.2" + defaultConfig { + minSdkVersion 16 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + api 'com.squareup.okhttp3:okhttp:4.2.1' + api 'com.google.code.gson:gson:2.8.5' + api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2' + api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2' + api "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-rc03" + api 'androidx.appcompat:appcompat:1.1.0' + api 'androidx.core:core-ktx:1.1.0' +} +publishing { + repositories { + maven { +// url 'https://mymavenrepo.com/repo/4XBKk8BMCyMc24joS8Od/' + url 'https://maven.cubos.io/upload/' + credentials { + username "cubos" + password "4XBKk8BMCyMc24joS8Od" + } + } + } + publications { + maven(MavenPublication) { + artifacts { + groupId 'io.cubos.api' + artifactId 'sdkgen2' + version '1.0.10' + artifact 'build/outputs/aar/api-release.aar' + pom.withXml { + // Creating additional node for dependencies + def dependenciesNode = asNode().appendNode('dependencies') + // Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile) + def configurationNames = ["releaseCompile", 'compile'] + configurationNames.each { configurationName -> + configurations[configurationName].allDependencies.each { + if (it.group != null && it.name != null) { + def dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', it.group) + dependencyNode.appendNode('artifactId', it.name) + dependencyNode.appendNode('version', it.version) + // If there are any exclusions in dependency + if (it.excludeRules.size() > 0) { + def exclusionsNode = dependencyNode.appendNode('exclusions') + it.excludeRules.each { rule -> + def exclusionNode = exclusionsNode.appendNode('exclusion') + exclusionNode.appendNode('groupId', rule.group) + exclusionNode.appendNode('artifactId', rule.module) + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/target-android-kt-jetpack/api/proguard-rules.pro b/target-android-kt-jetpack/api/proguard-rules.pro new file mode 100644 index 0000000..f0b73f5 --- /dev/null +++ b/target-android-kt-jetpack/api/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /opt/android-sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# 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/target-android-kt-jetpack/api/src/main/AndroidManifest.xml b/target-android-kt-jetpack/api/src/main/AndroidManifest.xml new file mode 100644 index 0000000..e1a9dd7 --- /dev/null +++ b/target-android-kt-jetpack/api/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + + diff --git a/target-android-kt-jetpack/api/src/main/res/values/strings.xml b/target-android-kt-jetpack/api/src/main/res/values/strings.xml new file mode 100644 index 0000000..94cfee7 --- /dev/null +++ b/target-android-kt-jetpack/api/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + sdkgen2 + diff --git a/target-android-kt-jetpack/build.gradle b/target-android-kt-jetpack/build.gradle new file mode 100644 index 0000000..95dc464 --- /dev/null +++ b/target-android-kt-jetpack/build.gradle @@ -0,0 +1,26 @@ +buildscript { + ext.kotlin_version = '1.3.60' + repositories { + google() + jcenter() + + } + dependencies { + classpath 'com.android.tools.build:gradle:3.5.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/target-android-kt-jetpack/build_and_publish.sh b/target-android-kt-jetpack/build_and_publish.sh new file mode 100644 index 0000000..b2e1fd5 --- /dev/null +++ b/target-android-kt-jetpack/build_and_publish.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +NAME=$2 +VERSION=1.0.$3 +LOCATION=/root + +rm -rf $LOCATION/api/src/main/java/io/cubos/api +mkdir -p $LOCATION/api/src/main/java/io/cubos/api/$NAME +cp $1 $LOCATION/tmp.kt +cd $LOCATION + +(echo "package io.cubos.api."$NAME";"; cat tmp.kt) > api/src/main/java/io/cubos/api/$NAME/API.kt + +CURRENT_NAME=$(cat api/src/main/res/values/strings.xml | grep app_name | sed -e 's/<[^>]*>//g' | xargs echo -n) +CURRENT_VERSION=$(cat api/build.gradle | grep "version " | sed 's/version//g' | xargs echo -n) +sed -i -e 's/'$CURRENT_NAME'/'$NAME'/g' api/src/main/java/io/cubos/api/$NAME/API.kt +sed -i -e 's/'$CURRENT_NAME'/'$NAME'/g' api/src/main/AndroidManifest.xml +sed -i -e 's/'$CURRENT_NAME'/'$NAME'/g' api/src/main/res/values/strings.xml +sed -i -e 's/'$CURRENT_NAME'/'$NAME'/g' api/build.gradle +sed -i -e 's/version '"'"$CURRENT_VERSION"'"'/version '"'"$VERSION"'"'/g' api/build.gradle + +./gradlew assembleRelease publish diff --git a/target-android-kt-jetpack/gradle.properties b/target-android-kt-jetpack/gradle.properties new file mode 100644 index 0000000..9e6fce1 --- /dev/null +++ b/target-android-kt-jetpack/gradle.properties @@ -0,0 +1,19 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/target-android-kt-jetpack/gradle/wrapper/gradle-wrapper.jar b/target-android-kt-jetpack/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/target-android-kt-jetpack/gradle/wrapper/gradle-wrapper.jar differ diff --git a/target-android-kt-jetpack/gradle/wrapper/gradle-wrapper.properties b/target-android-kt-jetpack/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..9a90767 --- /dev/null +++ b/target-android-kt-jetpack/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Apr 27 11:23:05 BRT 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/target-android-kt-jetpack/gradlew b/target-android-kt-jetpack/gradlew new file mode 100755 index 0000000..9d82f78 --- /dev/null +++ b/target-android-kt-jetpack/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/target-android-kt-jetpack/gradlew.bat b/target-android-kt-jetpack/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/target-android-kt-jetpack/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/target-android-kt-jetpack/sample/.gitignore b/target-android-kt-jetpack/sample/.gitignore new file mode 100644 index 0000000..3543521 --- /dev/null +++ b/target-android-kt-jetpack/sample/.gitignore @@ -0,0 +1 @@ +/build diff --git a/target-android-kt-jetpack/sample/build.gradle b/target-android-kt-jetpack/sample/build.gradle new file mode 100644 index 0000000..e71f7e6 --- /dev/null +++ b/target-android-kt-jetpack/sample/build.gradle @@ -0,0 +1,46 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +android { + compileSdkVersion 29 + buildToolsVersion "29.0.2" + + defaultConfig { + applicationId "io.cubos.targetAndroidKtJetpack.sample" + minSdkVersion 16 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +sourceSets { + all { + languageSettings { + useExperimentalAnnotation('kotlin.Experimental') + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation project(':api') + testImplementation 'junit:junit:4.12' + androidTestImplementation 'androidx.test.ext:junit:1.1.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' +} + + diff --git a/target-android-kt-jetpack/sample/proguard-rules.pro b/target-android-kt-jetpack/sample/proguard-rules.pro new file mode 100644 index 0000000..6e7ffa9 --- /dev/null +++ b/target-android-kt-jetpack/sample/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/target-android-kt-jetpack/sample/settings.gradle b/target-android-kt-jetpack/sample/settings.gradle new file mode 100644 index 0000000..b6c56b6 --- /dev/null +++ b/target-android-kt-jetpack/sample/settings.gradle @@ -0,0 +1 @@ +include ':api' \ No newline at end of file diff --git a/target-android-kt-jetpack/sample/src/androidTest/java/io/cubos/targetAndroidKtJetpack/sample/ExampleInstrumentedTest.kt b/target-android-kt-jetpack/sample/src/androidTest/java/io/cubos/targetAndroidKtJetpack/sample/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..3f42a36 --- /dev/null +++ b/target-android-kt-jetpack/sample/src/androidTest/java/io/cubos/targetAndroidKtJetpack/sample/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package io.cubos.targetAndroidKtJetpack.sample + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("io.cubos.targetAndroidKtJetpack.sample", appContext.packageName) + } +} diff --git a/target-android-kt-jetpack/sample/src/main/AndroidManifest.xml b/target-android-kt-jetpack/sample/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c6b26fc --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/sample/src/main/java/io/cubos/targetAndroidKtJetpack/sample/App.kt b/target-android-kt-jetpack/sample/src/main/java/io/cubos/targetAndroidKtJetpack/sample/App.kt new file mode 100644 index 0000000..a90e1ee --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/java/io/cubos/targetAndroidKtJetpack/sample/App.kt @@ -0,0 +1,9 @@ +package io.cubos.targetAndroidKtJetpack.sample + +import android.app.Application + +class App: Application() { + override fun onCreate() { + super.onCreate() + } +} \ No newline at end of file diff --git a/target-android-kt-jetpack/sample/src/main/java/io/cubos/targetAndroidKtJetpack/sample/MainActivity.kt b/target-android-kt-jetpack/sample/src/main/java/io/cubos/targetAndroidKtJetpack/sample/MainActivity.kt new file mode 100644 index 0000000..6ce3778 --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/java/io/cubos/targetAndroidKtJetpack/sample/MainActivity.kt @@ -0,0 +1,14 @@ +package io.cubos.targetAndroidKtJetpack.sample + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.MainScope + +class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + } +} diff --git a/target-android-kt-jetpack/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml b/target-android-kt-jetpack/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..971add5 --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/target-android-kt-jetpack/sample/src/main/res/drawable/ic_launcher_background.xml b/target-android-kt-jetpack/sample/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..eed7a42 --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/target-android-kt-jetpack/sample/src/main/res/layout/activity_main.xml b/target-android-kt-jetpack/sample/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..ca0c0de --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/layout/activity_main.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/target-android-kt-jetpack/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..a26f6fb --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/target-android-kt-jetpack/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..a26f6fb --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-hdpi/ic_launcher.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..898f3ed Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..dffca36 Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-mdpi/ic_launcher.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..64ba76f Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..dae5e08 Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-xhdpi/ic_launcher.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..e5ed465 Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..14ed0af Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b0907ca Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..d8ae031 Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..2c18de9 Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..beed3cd Binary files /dev/null and b/target-android-kt-jetpack/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/target-android-kt-jetpack/sample/src/main/res/values/colors.xml b/target-android-kt-jetpack/sample/src/main/res/values/colors.xml new file mode 100644 index 0000000..6b3f6ab --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #008577 + #00574B + #D81B60 + diff --git a/target-android-kt-jetpack/sample/src/main/res/values/strings.xml b/target-android-kt-jetpack/sample/src/main/res/values/strings.xml new file mode 100644 index 0000000..1ef4c45 --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Sample + diff --git a/target-android-kt-jetpack/sample/src/main/res/values/styles.xml b/target-android-kt-jetpack/sample/src/main/res/values/styles.xml new file mode 100644 index 0000000..6f19b47 --- /dev/null +++ b/target-android-kt-jetpack/sample/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/target-android-kt-jetpack/sample/src/test/java/io/cubos/targetAndroidKtJetpack/sample/ExampleUnitTest.kt b/target-android-kt-jetpack/sample/src/test/java/io/cubos/targetAndroidKtJetpack/sample/ExampleUnitTest.kt new file mode 100644 index 0000000..ddcf499 --- /dev/null +++ b/target-android-kt-jetpack/sample/src/test/java/io/cubos/targetAndroidKtJetpack/sample/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package io.cubos.targetAndroidKtJetpack.sample + +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/target-android-kt-jetpack/settings.gradle b/target-android-kt-jetpack/settings.gradle new file mode 100644 index 0000000..a72d940 --- /dev/null +++ b/target-android-kt-jetpack/settings.gradle @@ -0,0 +1 @@ +include ':api', ':sample'