diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-07-14 13:46:24 -0700 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-07-14 13:46:24 -0700 |
commit | b4844e98619766232645d70f80a29c2a53bc2709 (patch) | |
tree | 500a6deee2dfbd36f4356d69a2d5cb762314b03f /hello_signals/src | |
parent | 1d19d5912d1ac5bfa3cf6cc30f086aee8f0464f2 (diff) | |
download | godot-android-samples-b4844e98619766232645d70f80a29c2a53bc2709.tar.gz godot-android-samples-b4844e98619766232645d70f80a29c2a53bc2709.tar.bz2 godot-android-samples-b4844e98619766232645d70f80a29c2a53bc2709.zip |
Update the directory structure to make room for additional Godot Android samples besides plugins
Diffstat (limited to 'hello_signals/src')
-rw-r--r-- | hello_signals/src/main/AndroidManifest.xml | 20 | ||||
-rw-r--r-- | hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt | 59 |
2 files changed, 0 insertions, 79 deletions
diff --git a/hello_signals/src/main/AndroidManifest.xml b/hello_signals/src/main/AndroidManifest.xml deleted file mode 100644 index 8f791bd..0000000 --- a/hello_signals/src/main/AndroidManifest.xml +++ /dev/null @@ -1,20 +0,0 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="fhuyakou.godot.plugin.android.hellosignals"> - - <application> - <!-- - Plugin metadata: - - - In the `android:name` attribute, the `org.godotengine.plugin.v1` prefix - is required so Godot can recognize the project as a valid Godot - Android plugin. The plugin name following the prefix should match the value - of the plugin name returned by the plugin initializer. - - - The `android:value` attribute should be the classpath to the plugin - initializer. - --> - <meta-data - android:name="org.godotengine.plugin.v1.HelloSignals" - android:value="fhuyakou.godot.plugin.android.hellosignals.HelloSignalsPlugin" /> - </application> -</manifest> diff --git a/hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt b/hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt deleted file mode 100644 index d6df7ef..0000000 --- a/hello_signals/src/main/java/fhuyakou/godot/plugin/android/hellosignals/HelloSignalsPlugin.kt +++ /dev/null @@ -1,59 +0,0 @@ -package fhuyakou.godot.plugin.android.hellosignals - -import android.util.Log -import org.godotengine.godot.Godot -import org.godotengine.godot.plugin.GodotPlugin -import org.godotengine.godot.plugin.SignalInfo -import org.godotengine.godot.plugin.UsedByGodot -import java.util.concurrent.Executors -import java.util.concurrent.ScheduledFuture -import java.util.concurrent.TimeUnit - -/** - * Exposes a [onButtonPressed] method to the game logic. Invoking the method starts a timer which - * fires a `TikTok` signal every second. Invoking the method a second time stops the timer. - */ -class HelloSignalsPlugin(godot: Godot) : GodotPlugin(godot) { - - companion object { - val TAG = HelloSignalsPlugin::class.java.simpleName - } - - private val tikTokSignalInfo = SignalInfo("TikTok") - private var tikTokTask : ScheduledFuture<*>? = null - - override fun getPluginName() = "HelloSignals" - - override fun getPluginSignals(): Set<SignalInfo> { - Log.i(TAG, "Registering $tikTokSignalInfo") - return setOf(tikTokSignalInfo) - } - - private fun startTikTok(): Boolean { - if (tikTokTask == null || tikTokTask!!.isDone) { - Log.i(TAG, "Starting tiktok...") - tikTokTask = Executors.newSingleThreadScheduledExecutor() - .scheduleAtFixedRate({ emitSignal(tikTokSignalInfo.name) }, 0, 1, TimeUnit.SECONDS) - return true - } - return false - } - - private fun stopTikTok() { - if (tikTokTask != null) { - if (!tikTokTask!!.isDone) { - Log.i(TAG, "Stopping tiktok...") - tikTokTask!!.cancel(true) - } - tikTokTask = null - } - } - - @UsedByGodot - private fun onButtonPressed() { - Log.i(TAG, "OnButtonPressed from Kotlin") - if (!startTikTok()) { - stopTikTok() - } - } -} |