summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredia Huya-Kouadio <fhuya@meta.com>2023-10-06 10:58:19 -0700
committerFredia Huya-Kouadio <fhuya@meta.com>2023-10-06 10:58:19 -0700
commit0e3440f357f8be5b4c63a4fe75766793199a99d0 (patch)
tree50dadfc422b4051fbf08851578ff79fe25c7eb5d
parent567fd1ad05768cd2ecd2f51f2bd8347dfc530e7d (diff)
downloadgodot-android-samples-0e3440f357f8be5b4c63a4fe75766793199a99d0.tar.gz
godot-android-samples-0e3440f357f8be5b4c63a4fe75766793199a99d0.tar.bz2
godot-android-samples-0e3440f357f8be5b4c63a4fe75766793199a99d0.zip
Update the sample app manifest parameters including its supported orientation
-rw-r--r--apps/gltf_viewer/src/main/AndroidManifest.xml5
-rw-r--r--apps/gltf_viewer/src/main/assets/project.godot2
-rw-r--r--apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/ItemsSelectionFragment.kt2
-rw-r--r--apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/MainActivity.kt19
4 files changed, 19 insertions, 9 deletions
diff --git a/apps/gltf_viewer/src/main/AndroidManifest.xml b/apps/gltf_viewer/src/main/AndroidManifest.xml
index 21b68aa..bed036b 100644
--- a/apps/gltf_viewer/src/main/AndroidManifest.xml
+++ b/apps/gltf_viewer/src/main/AndroidManifest.xml
@@ -10,9 +10,8 @@
android:theme="@style/Theme.GodotAndroidSamples" >
<activity android:name=".MainActivity"
- android:screenOrientation="portrait"
- android:launchMode="singleInstance"
- android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
+ android:screenOrientation="fullUser"
+ android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
android:exported="true">
<intent-filter>
diff --git a/apps/gltf_viewer/src/main/assets/project.godot b/apps/gltf_viewer/src/main/assets/project.godot
index ba3e422..8599945 100644
--- a/apps/gltf_viewer/src/main/assets/project.godot
+++ b/apps/gltf_viewer/src/main/assets/project.godot
@@ -21,7 +21,7 @@ settings/stdout/verbose_stdout=true
[display]
-window/handheld/orientation=1
+window/handheld/orientation=6
[input_devices]
diff --git a/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/ItemsSelectionFragment.kt b/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/ItemsSelectionFragment.kt
index 1db4244..027e242 100644
--- a/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/ItemsSelectionFragment.kt
+++ b/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/ItemsSelectionFragment.kt
@@ -59,7 +59,7 @@ class ItemsSelectionFragment : Fragment(), GLTFItemRecyclerViewAdapter.Listener
override fun onItemSelected(item: GLTFContent.GLTFItem) {
val parentActivity = activity
if (parentActivity is MainActivity) {
- parentActivity.appPlugin.showGLTF(item.glbFilepath)
+ parentActivity.appPlugin?.showGLTF(item.glbFilepath)
}
}
}
diff --git a/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/MainActivity.kt b/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/MainActivity.kt
index c084e24..7c5f358 100644
--- a/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/MainActivity.kt
+++ b/apps/gltf_viewer/src/main/java/fhuyakou/godot/app/android/gltfviewer/MainActivity.kt
@@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity
import org.godotengine.godot.Godot
import org.godotengine.godot.GodotFragment
import org.godotengine.godot.GodotHost
+import org.godotengine.godot.plugin.GodotPlugin
/**
* Implements the [GodotHost] interface so it can access functionality from the [Godot] instance.
@@ -13,9 +14,7 @@ class MainActivity: AppCompatActivity(), GodotHost {
private var godotFragment: GodotFragment? = null
- internal val appPlugin: AppPlugin by lazy {
- AppPlugin(godot!!)
- }
+ internal var appPlugin: AppPlugin? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -32,6 +31,8 @@ class MainActivity: AppCompatActivity(), GodotHost {
.commitNowAllowingStateLoss()
}
+ initAppPluginIfNeeded(godot!!)
+
var itemsSelectionFragment = supportFragmentManager.findFragmentById(R.id.item_selection_fragment_container)
if (itemsSelectionFragment !is ItemsSelectionFragment) {
itemsSelectionFragment = ItemsSelectionFragment.newInstance(1)
@@ -41,9 +42,19 @@ class MainActivity: AppCompatActivity(), GodotHost {
}
}
+ private fun initAppPluginIfNeeded(godot: Godot) {
+ if (appPlugin == null) {
+ appPlugin = AppPlugin(godot)
+ }
+ }
+
override fun getActivity() = this
override fun getGodot() = godotFragment?.godot
- override fun getHostPlugins() = setOf(appPlugin)
+ override fun getHostPlugins(godot: Godot): Set<GodotPlugin> {
+ initAppPluginIfNeeded(godot)
+
+ return setOf(appPlugin!!)
+ }
}