Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: improved api
  • Loading branch information
juicycleff committed Dec 21, 2022
commit d5c02e77137e48bb25570096326176a983c133a7
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.os.Build
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.FrameLayout
Expand Down Expand Up @@ -41,6 +42,17 @@ class UnityPlayerUtils {
}
}

private fun performWindowUpdate() {
if (!options.fullscreenEnabled) {
activity!!.window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN)
activity!!.window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
} else {
activity!!.window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
activity!!.window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
}
}

/**
* Create a new unity player with callback
*/
Expand All @@ -57,6 +69,7 @@ class UnityPlayerUtils {
unityPlayer!!.invalidate()
focus()
callback?.onReady()
performWindowUpdate()
return
}

Expand All @@ -78,6 +91,8 @@ class UnityPlayerUtils {
activity!!.window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
} else {
activity!!.window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
activity!!.window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
}

focus()
Expand Down Expand Up @@ -140,13 +155,6 @@ class UnityPlayerUtils {
*/
@JvmStatic
fun onUnitySceneLoaded(name: String, buildIndex: Int, isLoaded: Boolean, isValid: Boolean) {
// for (listener in mUnityEventListeners) {
// try {
// listener.onSceneLoaded(name, buildIndex, isLoaded, isValid)
// } catch (e: Exception) {
// e.message?.let { Log.e(LOG_TAG, it) }
// }
// }
try {
handleSceneLoaded(name, buildIndex, isLoaded, isValid)
} catch (e: Exception) {
Expand Down Expand Up @@ -176,13 +184,6 @@ class UnityPlayerUtils {
@JvmStatic
fun onUnityMessage(message: String) {
Log.d("UnityListener", "total listeners are ${mUnityEventListeners.size}")
// for (listener in mUnityEventListeners) {
// try {
// listener.onMessage(message)
// } catch (e: Exception) {
// e.message?.let { Log.e(LOG_TAG, it) }
// }
// }
Handler(Looper.getMainLooper()).post {
DataStreamEventNotifier.notifier.onNext(
DataStreamEvent(
Expand Down
2 changes: 2 additions & 0 deletions example/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Expand All @@ -14,5 +15,6 @@
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
2 changes: 1 addition & 1 deletion example/lib/screens/api_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class _ApiScreenState extends State<ApiScreen> {
onUnityCreated: onUnityCreated,
onUnityMessage: onUnityMessage,
onUnitySceneLoaded: onUnitySceneLoaded,
fullscreen: false,
fullscreen: true,
useAndroidViewSurface: false,
),
),
Expand Down
2 changes: 0 additions & 2 deletions lib/src/io/mobile_unity_widget_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import 'dart:async';

import 'package:flutter_unity_widget/flutter_unity_widget.dart';

import '../facade_controller.dart';
import '../helpers/events.dart';
import 'unity_widget.dart';
import 'unity_widget_platform.dart';

Expand Down