You've already forked RN_Android_FitFullScreen
初步这样
This commit is contained in:
@ -1,12 +1,22 @@
|
|||||||
package top.jerryyan.RN.A.FitFullScreen;
|
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.ReactApplicationContext;
|
||||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||||
import com.facebook.react.bridge.ReactMethod;
|
import com.facebook.react.bridge.ReactMethod;
|
||||||
import com.facebook.react.bridge.Callback;
|
import com.facebook.react.bridge.Callback;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class FitModule extends ReactContextBaseJavaModule {
|
public class FitModule extends ReactContextBaseJavaModule {
|
||||||
private final ReactApplicationContext reactContext;
|
private final ReactApplicationContext reactContext;
|
||||||
|
private final String MANUFACTURER = Build.MANUFACTURER;
|
||||||
|
|
||||||
public FitModule(ReactApplicationContext reactContext) {
|
public FitModule(ReactApplicationContext reactContext) {
|
||||||
super(reactContext);
|
super(reactContext);
|
||||||
@ -15,12 +25,50 @@ public class FitModule extends ReactContextBaseJavaModule {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
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
|
@ReactMethod
|
||||||
public void sampleMethod(String stringArgument, int numberArgument, Callback callback) {
|
public void checkFullScreen(Callback callback){
|
||||||
// TODO: Implement some actually useful functionality
|
if ("xiaomi".equalsIgnoreCase(MANUFACTURER)) {
|
||||||
callback.invoke("Received numberArgument: " + numberArgument + " stringArgument: " + stringArgument);
|
callback.invoke(_isXiaoMiFullScreen());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ReactMethod
|
||||||
|
public void isNavBarExist(Callback callback){
|
||||||
|
callback.invoke(_isVirtualNavigationBarExist());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user