feat(app-glasses): AR-метка RayNeoX2 (com.rayneo.mercury.app) + тема + landscape

Из pair-view: meta-data com.rayneo.mercury.app=true — очки распознают
приложение как AR (без неё открывалось как обычное). Тема
Theme.ViewMateGlasses (чёрный фон, fullscreen), screenOrientation
landscape, hardwareAccelerated. Плюс фикс краша: prefs читались в
конструкторе Application (до attachBaseContext) — перенесено в onCreate.
Проверено на железе: открывается через лаунчер нормально.
This commit is contained in:
Hermes Agent
2026-08-20 01:22:27 +03:00
parent 896185244b
commit 9f1c6735c1
4 changed files with 33 additions and 4 deletions
+9 -2
View File
@@ -12,13 +12,20 @@
<application <application
android:name=".GlassesApp" android:name=".GlassesApp"
android:label="ViewMate Glasses" android:label="ViewMate Glasses"
android:theme="@style/Theme.AppCompat" android:theme="@style/Theme.ViewMateGlasses"
android:hardwareAccelerated="true"
android:allowBackup="true" android:allowBackup="true"
android:usesCleartextTraffic="true"> android:usesCleartextTraffic="true">
<!-- indicate this is an app that supports RayNeoX2 glasses -->
<meta-data
android:name="com.rayneo.mercury.app"
android:value="true" />
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> android:exported="true"
android:screenOrientation="landscape">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@@ -1,6 +1,7 @@
package pw.binom.viewmate.glasses package pw.binom.viewmate.glasses
import android.app.Application import android.app.Application
import android.content.Context
import com.rayneo.arsdk.android.MercurySDK import com.rayneo.arsdk.android.MercurySDK
import java.io.File import java.io.File
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
@@ -28,12 +29,24 @@ class GlassesApp : Application() {
lateinit var downloadManager: GlassesDownloadManager lateinit var downloadManager: GlassesDownloadManager
private set private set
/** Масштаб экрана очков (0.5..1.0); задаётся пультом телефона. */ private val prefs by lazy {
getSharedPreferences("viewmate_prefs", Context.MODE_PRIVATE)
}
/** Масштаб экрана очков (0.5..1.0). Загружается в onCreate (prefs — после привязки контекста). */
val scale = MutableStateFlow(1f) val scale = MutableStateFlow(1f)
/** Применить и сохранить масштаб. */
fun applyScale(value: Float) {
val v = value.coerceIn(0.5f, 1f)
scale.value = v
prefs.edit().putFloat("scale", v).apply()
}
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
instance = this instance = this
scale.value = prefs.getFloat("scale", 1f).coerceIn(0.5f, 1f)
MercurySDK.init(this) MercurySDK.init(this)
movieController = MovieController(applicationContext) movieController = MovieController(applicationContext)
movieController.eventLogger = { msg -> logToFile("mc: $msg") } movieController.eventLogger = { msg -> logToFile("mc: $msg") }
@@ -223,7 +223,7 @@ class HostConnection(
is SetMode -> addMessage("SetMode: ${msg.mode}") is SetMode -> addMessage("SetMode: ${msg.mode}")
is SetScale -> { is SetScale -> {
GlassesApp.instance.scale.value = msg.scale.coerceIn(0.5f, 1f) GlassesApp.instance.applyScale(msg.scale)
log("app", "scale → ${msg.scale}") log("app", "scale → ${msg.scale}")
} }
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Тема очков: чёрный фон окна, полноэкранно, без заголовка. -->
<style name="Theme.ViewMateGlasses" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@android:color/black</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
</style>
</resources>