Update JVMActivity.java

This commit is contained in:
ShirosakiMio 2023-03-08 12:38:49 +08:00
parent fc191bc898
commit d93ea7a040
1 changed files with 15 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package com.tungsten.fcl.activity;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
import android.view.KeyEvent;
@ -31,6 +32,7 @@ public class JVMActivity extends FCLActivity implements TextureView.SurfaceTextu
private MenuCallback menu;
private static MenuType menuType;
private static FCLBridge fclBridge;
private boolean isTranslated=false;
public static void setFClBridge(FCLBridge fclBridge, MenuType menuType) {
JVMActivity.fclBridge = fclBridge;
@ -53,6 +55,19 @@ public class JVMActivity extends FCLActivity implements TextureView.SurfaceTextu
textureView.setSurfaceTextureListener(this);
addContentView(menu.getLayout(), new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(() -> {
int screenHeight = getWindow().getDecorView().getHeight();
Rect rect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);
if (screenHeight * 2 / 3 > rect.bottom){
textureView.setTranslationY(rect.bottom-screenHeight);
isTranslated = true;
} else if (isTranslated){
isTranslated = false;
textureView.setTranslationY(0);
}
});
}
@Override