mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
Make the engine private to the Sky package and expose the relevant public methods on PlatformViewAndroid
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package org.domokit.sky.shell;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.opengl.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
@@ -39,6 +40,7 @@ import org.chromium.mojom.pointer.PointerPacket;
|
||||
import org.chromium.mojom.pointer.PointerType;
|
||||
import org.chromium.mojom.raw_keyboard.RawKeyboardService;
|
||||
import org.chromium.mojom.semantics.SemanticsServer;
|
||||
import org.chromium.mojom.sky.AppLifecycleState;
|
||||
import org.chromium.mojom.sky.ServicesData;
|
||||
import org.chromium.mojom.sky.SkyEngine;
|
||||
import org.chromium.mojom.sky.ViewportMetrics;
|
||||
@@ -46,6 +48,7 @@ import org.chromium.mojom.sky.ViewportMetrics;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.domokit.editing.KeyboardImpl;
|
||||
@@ -112,6 +115,8 @@ public class PlatformViewAndroid extends SurfaceView
|
||||
mRawKeyboardState = new RawKeyboardServiceState();
|
||||
|
||||
mAccessibilityManager = (AccessibilityManager)getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
|
||||
|
||||
setLocale(getResources().getConfiguration().locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,10 +133,36 @@ public class PlatformViewAndroid extends SurfaceView
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
public SkyEngine getEngine() {
|
||||
SkyEngine getEngine() {
|
||||
return mSkyEngine;
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
mSkyEngine.onAppLifecycleStateChanged(AppLifecycleState.PAUSED);
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
mSkyEngine.onAppLifecycleStateChanged(AppLifecycleState.RESUMED);
|
||||
}
|
||||
|
||||
public void pushRoute(String route) {
|
||||
mSkyEngine.pushRoute(route);
|
||||
}
|
||||
|
||||
public void popRoute() {
|
||||
mSkyEngine.popRoute();
|
||||
}
|
||||
|
||||
private void setLocale(Locale locale) {
|
||||
mSkyEngine.onLocaleChanged(locale.getLanguage(), locale.getCountry());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
setLocale(newConfig.locale);
|
||||
}
|
||||
|
||||
float getDevicePixelRatio() {
|
||||
return mMetrics.devicePixelRatio;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package org.domokit.sky.shell;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -16,7 +15,6 @@ import android.view.WindowManager;
|
||||
|
||||
import org.chromium.base.PathUtils;
|
||||
import org.chromium.base.TraceEvent;
|
||||
import org.chromium.mojom.sky.AppLifecycleState;
|
||||
import org.chromium.mojom.sky.EventType;
|
||||
import org.chromium.mojom.sky.InputEvent;
|
||||
|
||||
@@ -24,7 +22,6 @@ import org.domokit.activity.ActivityImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
/**
|
||||
@@ -97,7 +94,7 @@ public class SkyActivity extends Activity {
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mView != null) {
|
||||
mView.getEngine().popRoute();
|
||||
mView.popRoute();
|
||||
return;
|
||||
}
|
||||
super.onBackPressed();
|
||||
@@ -107,7 +104,7 @@ public class SkyActivity extends Activity {
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (mView != null) {
|
||||
mView.getEngine().onAppLifecycleStateChanged(AppLifecycleState.PAUSED);
|
||||
mView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +118,7 @@ public class SkyActivity extends Activity {
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
if (mView != null) {
|
||||
mView.getEngine().onAppLifecycleStateChanged(AppLifecycleState.RESUMED);
|
||||
mView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,10 +128,6 @@ public class SkyActivity extends Activity {
|
||||
protected void onSkyReady() {
|
||||
TraceEvent.instant("SkyActivity.onSkyReady");
|
||||
|
||||
Locale locale = getResources().getConfiguration().locale;
|
||||
mView.getEngine().onLocaleChanged(locale.getLanguage(),
|
||||
locale.getCountry());
|
||||
|
||||
if (loadIntent(getIntent())) {
|
||||
return;
|
||||
}
|
||||
@@ -158,18 +151,10 @@ public class SkyActivity extends Activity {
|
||||
intent.getStringExtra("snapshot"));
|
||||
String route = intent.getStringExtra("route");
|
||||
if (route != null)
|
||||
mView.getEngine().pushRoute(route);
|
||||
mView.pushRoute(route);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
Locale locale = getResources().getConfiguration().locale;
|
||||
mView.getEngine().onLocaleChanged(locale.getLanguage(),
|
||||
locale.getCountry());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user