diff --git a/examples/android/android-simple/app/build.gradle b/examples/android/android-simple/app/build.gradle index 8529509b2..877e1046e 100644 --- a/examples/android/android-simple/app/build.gradle +++ b/examples/android/android-simple/app/build.gradle @@ -2,11 +2,6 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' -//Properties properties = new Properties() -//properties.load(project.rootProject.file('local.properties').newDataInputStream()) -//def ndkDir = properties.getProperty('ndk.dir') -//def valLayerBinDir = "${ndkDir}/sources/third_party/vulkan/src/build-android/jniLibs" - android { compileSdkVersion 29 ndkVersion '21.2.6472646' @@ -46,15 +41,6 @@ android { } } -// sourceSets { -// main { -// jniLibs { -// // Must have ndk-r12 or better which including layer binaries -// srcDirs = ["${valLayerBinDir}"] -// } -// } -// } - flavorDimensions 'cpuArch' productFlavors { arm8 { @@ -81,5 +67,4 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -// implementation fileTree(dir: 'libs', include: ['*.jar']) } diff --git a/examples/android/android-simple/app/src/main/AndroidManifest.xml b/examples/android/android-simple/app/src/main/AndroidManifest.xml index ea3001a09..4965abb44 100755 --- a/examples/android/android-simple/app/src/main/AndroidManifest.xml +++ b/examples/android/android-simple/app/src/main/AndroidManifest.xml @@ -1,24 +1,8 @@ + package="com.ethicalml.kompute"> - - - - - - - - - - - - - - - - NewStringUTF("Result is: "); } } diff --git a/examples/android/android-simple/app/src/main/java/com/ethicalml/kompute/KomputeJni.kt b/examples/android/android-simple/app/src/main/java/com/ethicalml/kompute/KomputeJni.kt new file mode 100755 index 000000000..e306cf5b2 --- /dev/null +++ b/examples/android/android-simple/app/src/main/java/com/ethicalml/kompute/KomputeJni.kt @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ethicalml.kompute + +import android.os.Bundle +import android.util.Log +import androidx.appcompat.app.AppCompatActivity +import com.ethicalml.kompute.databinding.ActivityKomputeJniBinding + +class KomputeJni : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + val binding = ActivityKomputeJniBinding.inflate(layoutInflater) + setContentView(binding.root) + + binding.komputeGifView.loadUrl("file:///android_asset/komputer-2.gif") + + binding.komputeGifView.getSettings().setUseWideViewPort(true) + binding.komputeGifView.getSettings().setLoadWithOverviewMode(true) + + val successVulkanInit = initVulkan() + Log.i("KomputeJni", "Vulkan Result: " + successVulkanInit) + + binding.komputeJniTextview.text = stringFromJNI() + } + + external fun initVulkan(): Boolean + + external fun stringFromJNI(): String + + companion object { + init { + System.loadLibrary("kompute-jni") + } + } +} + diff --git a/examples/android/android-simple/app/src/main/java/com/ethicalml/komputejni/KomputeJni.kt b/examples/android/android-simple/app/src/main/java/com/ethicalml/komputejni/KomputeJni.kt deleted file mode 100755 index 8c7c9996e..000000000 --- a/examples/android/android-simple/app/src/main/java/com/ethicalml/komputejni/KomputeJni.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.ethicalml.komputejni - -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity -import com.ethicalml.komputejni.databinding.ActivityKomputeJniBinding - -class KomputeJni : AppCompatActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - /* - * Retrieve our TextView and set its content. - * the text is retrieved by calling a native - * function. - */ - val binding = ActivityKomputeJniBinding.inflate(layoutInflater) - setContentView(binding.root) - binding.komputeJniTextview.text = stringFromJNI() - } - - /* - * A native method that is implemented by the - * 'hello-jni' native library, which is packaged - * with this application. - */ - external fun stringFromJNI(): String? - - /* - * This is another native method declaration that is *not* - * implemented by 'hello-jni'. This is simply to show that - * you can declare as many native methods in your Java code - * as you want, their implementation is searched in the - * currently loaded native libraries only the first time - * you call them. - * - * Trying to call this function will result in a - * java.lang.UnsatisfiedLinkError exception ! - */ - external fun unimplementedStringFromJNI(): String? - - companion object { - /* - * this is used to load the 'hello-jni' library on application - * startup. The library has already been unpacked into - * /data/data/com.example.hellojni/lib/libhello-jni.so - * at the installation time by the package manager. - */ - init { - System.loadLibrary("kompute-jni") - } - } -} - diff --git a/examples/android/android-simple/app/src/main/res/layout/activity_kompute_jni.xml b/examples/android/android-simple/app/src/main/res/layout/activity_kompute_jni.xml index 8196c4b61..26294546e 100644 --- a/examples/android/android-simple/app/src/main/res/layout/activity_kompute_jni.xml +++ b/examples/android/android-simple/app/src/main/res/layout/activity_kompute_jni.xml @@ -1,20 +1,107 @@ - + tools:context="com.ethicalml.kompute.KomputeJni"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/android/android-simple/app/src/main/res/mipmap-anydpi-v26/kompute_icon.xml b/examples/android/android-simple/app/src/main/res/mipmap-anydpi-v26/kompute_icon.xml new file mode 100755 index 000000000..54207096d --- /dev/null +++ b/examples/android/android-simple/app/src/main/res/mipmap-anydpi-v26/kompute_icon.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/examples/android/android-simple/app/src/main/res/mipmap-xhdpi/kompute_icon.png b/examples/android/android-simple/app/src/main/res/mipmap-xhdpi/kompute_icon.png new file mode 100755 index 000000000..49e2477e9 Binary files /dev/null and b/examples/android/android-simple/app/src/main/res/mipmap-xhdpi/kompute_icon.png differ diff --git a/examples/android/android-simple/app/src/main/res/mipmap-xhdpi/kompute_icon_foreground.png b/examples/android/android-simple/app/src/main/res/mipmap-xhdpi/kompute_icon_foreground.png new file mode 100755 index 000000000..02cb5eecf Binary files /dev/null and b/examples/android/android-simple/app/src/main/res/mipmap-xhdpi/kompute_icon_foreground.png differ diff --git a/examples/android/android-simple/app/src/main/res/values/kompute_icon_background.xml b/examples/android/android-simple/app/src/main/res/values/kompute_icon_background.xml new file mode 100755 index 000000000..01f925c3f --- /dev/null +++ b/examples/android/android-simple/app/src/main/res/values/kompute_icon_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + \ No newline at end of file