初步这样
This commit is contained in:
parent
6df296e3d4
commit
3cdd22da9e
@ -1,12 +1,22 @@
|
||||
package top.jerryyan.RN.A.FitFullScreen;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FitModule extends ReactContextBaseJavaModule {
|
||||
private final ReactApplicationContext reactContext;
|
||||
private final String MANUFACTURER = Build.MANUFACTURER;
|
||||
|
||||
public FitModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
@ -15,12 +25,50 @@ public class FitModule extends ReactContextBaseJavaModule {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Fit";
|
||||
return "FitFullScreen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getConstants(){
|
||||
final Map<String, Object> constants = new HashMap<>();
|
||||
constants.put("MANUFACTURER", MANUFACTURER);
|
||||
return constants;
|
||||
}
|
||||
|
||||
private boolean _isVirtualNavigationBarExist(){
|
||||
WindowManager windowManager = reactContext.getCurrentActivity().getWindowManager();
|
||||
if(windowManager == null){
|
||||
return false;
|
||||
}
|
||||
Display display = windowManager.getDefaultDisplay();
|
||||
Point size = new Point();
|
||||
Point realSize = new Point();
|
||||
display.getSize(size); // app绘制区域
|
||||
display.getRealSize(realSize);
|
||||
return realSize.y != size.y;
|
||||
}
|
||||
|
||||
private boolean _isXiaoMiFullScreen(){
|
||||
return Settings.Global.getInt(reactContext.getContentResolver(), "force_fsg_nav_bar", 0) != 0;
|
||||
}
|
||||
|
||||
private boolean _isHuaWeiFullScreen(){
|
||||
try {
|
||||
reactContext.getClassLoader().loadClass("com.huawei.android.util.HwNotchSizeUtil");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sampleMethod(String stringArgument, int numberArgument, Callback callback) {
|
||||
// TODO: Implement some actually useful functionality
|
||||
callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument);
|
||||
public void checkFullScreen(Callback callback){
|
||||
if ("xiaomi".equalsIgnoreCase(MANUFACTURER)) {
|
||||
callback.invoke(_isXiaoMiFullScreen());
|
||||
}
|
||||
}
|
||||
@ReactMethod
|
||||
public void isNavBarExist(Callback callback){
|
||||
callback.invoke(_isVirtualNavigationBarExist());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user