diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 50020f3..6942910 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -20,7 +20,10 @@
-
+
\ No newline at end of file
diff --git a/android/app/src/main/java/com/metallic/chiaki/StreamSession.kt b/android/app/src/main/java/com/metallic/chiaki/StreamSession.kt
index f5d3133..44c024b 100644
--- a/android/app/src/main/java/com/metallic/chiaki/StreamSession.kt
+++ b/android/app/src/main/java/com/metallic/chiaki/StreamSession.kt
@@ -30,7 +30,7 @@ data class StreamStateCreateError(val error: SessionCreateError): StreamState()
data class StreamStateQuit(val reason: QuitReason, val reasonString: String?): StreamState()
data class StreamStateLoginPinRequest(val pinIncorrect: Boolean): StreamState()
-class StreamSession(connectInfo: ConnectInfo)
+class StreamSession(val connectInfo: ConnectInfo)
{
var session: Session? = null
private set(value) { field = value }
@@ -88,7 +88,7 @@ class StreamSession(connectInfo: ConnectInfo)
return surfaceTexture == null
}
- override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {}
+ override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) { }
override fun onSurfaceTextureUpdated(surface: SurfaceTexture) {}
}
diff --git a/android/app/src/main/java/com/metallic/chiaki/stream/StreamActivity.kt b/android/app/src/main/java/com/metallic/chiaki/stream/StreamActivity.kt
index 080de38..13b67b3 100644
--- a/android/app/src/main/java/com/metallic/chiaki/stream/StreamActivity.kt
+++ b/android/app/src/main/java/com/metallic/chiaki/stream/StreamActivity.kt
@@ -17,20 +17,15 @@
package com.metallic.chiaki.stream
-import android.graphics.SurfaceTexture
+import android.graphics.Matrix
import android.os.Bundle
import android.util.Log
-import android.view.Surface
-import android.view.SurfaceHolder
-import android.view.TextureView
+import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.Observer
-import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import com.metallic.chiaki.R
import com.metallic.chiaki.lib.ConnectInfo
-import com.metallic.chiaki.lib.Session
-import com.metallic.chiaki.lib.SessionCreateError
import kotlinx.android.synthetic.main.activity_stream.*
class StreamActivity : AppCompatActivity()
@@ -64,5 +59,63 @@ class StreamActivity : AppCompatActivity()
viewModel.session.state.observe(this, Observer {
stateTextView.text = "$it"
})
+
+ textureView.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
+ adjustTextureViewAspect()
+ }
+ }
+
+ override fun onResume()
+ {
+ super.onResume()
+ hideSystemUI()
+ }
+
+ override fun onWindowFocusChanged(hasFocus: Boolean)
+ {
+ super.onWindowFocusChanged(hasFocus)
+ if(hasFocus)
+ hideSystemUI()
+ }
+
+ private fun hideSystemUI()
+ {
+ Log.i("StreamActivity", "HIDE!!!!!!!!!!")
+ window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ or View.SYSTEM_UI_FLAG_FULLSCREEN)
+ }
+
+
+ private fun adjustTextureViewAspect()
+ {
+ val contentWidth = viewModel.session.connectInfo.videoProfile.width.toFloat()
+ val contentHeight = viewModel.session.connectInfo.videoProfile.height.toFloat()
+ val viewWidth = textureView.width.toFloat()
+ val viewHeight = textureView.height.toFloat()
+ val contentAspect = contentHeight / contentWidth
+
+ val width: Float
+ val height: Float
+ if(viewHeight > viewWidth * contentAspect)
+ {
+ width = viewWidth
+ height = viewWidth * contentAspect
+ }
+ else
+ {
+ width = viewHeight / contentAspect
+ height = viewHeight
+ }
+
+ Matrix().also {
+ textureView.getTransform(it)
+ it.setScale(width / viewWidth, height / viewHeight)
+ it.postTranslate((viewWidth - width) * 0.5f, (viewHeight - height) * 0.5f)
+ textureView.setTransform(it)
+ }
}
}
diff --git a/android/app/src/main/res/layout/activity_stream.xml b/android/app/src/main/res/layout/activity_stream.xml
index b3b4b37..4004b06 100644
--- a/android/app/src/main/res/layout/activity_stream.xml
+++ b/android/app/src/main/res/layout/activity_stream.xml
@@ -9,15 +9,12 @@
+ android:layout_height="match_parent"/>
\ No newline at end of file
diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml
index 69b2233..35f5d47 100644
--- a/android/app/src/main/res/values/colors.xml
+++ b/android/app/src/main/res/values/colors.xml
@@ -1,6 +1,9 @@
- #008577
- #00574B
- #D81B60
+ #008577
+ #00574B
+ #D81B60
+
+ @android:color/white
+ @android:color/black
diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml
index 5885930..d0481c0 100644
--- a/android/app/src/main/res/values/styles.xml
+++ b/android/app/src/main/res/values/styles.xml
@@ -1,11 +1,15 @@
-
-
-
+