Commit 6b493b59 authored by fallenstardust's avatar fallenstardust

没写完

parent 6105b329
......@@ -21,6 +21,9 @@
<meta-data
android:name="android.app.lib_name"
android:value="YGOMobile"/>
<meta-data
android:name="android.notch_support"
android:value="true"/>
</activity>
<receiver android:name="cn.garymb.ygomobile.GameReceiver"
android:process=":game" >
......
......@@ -15,6 +15,7 @@ import org.json.JSONArray;
import java.io.File;
import java.io.FileFilter;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
......@@ -65,17 +66,52 @@ public class AppsSettings {
update(context);
}
public static int getRealHeight(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealMetrics(dm);
} else {
display.getMetrics(dm);
//检测是否存在刘海屏
public static boolean hasNotchInScreen(Context context) {
boolean ret = false;
try {
ClassLoader cl = context.getClassLoader();
Class HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil");
Method get = HwNotchSizeUtil.getMethod("hasNotchInScreen");
ret = (boolean) get.invoke(HwNotchSizeUtil);
} catch (ClassNotFoundException e) {
Log.e("test", "hasNotchInScreen ClassNotFoundException");
} catch (NoSuchMethodException e) {
Log.e("test", "hasNotchInScreen NoSuchMethodException");
} catch (Exception e) {
Log.e("test", "hasNotchInScreen Exception");
} finally {
return ret;
}
int realHeight = dm.widthPixels;
return realHeight;
}
//获取刘海屏的参数
public static int[] getNotchSize(Context context) {
int[] notchSize = new int[]{0, 0};
try {
ClassLoader cl = context.getClassLoader();
Class HwNotchSizeUtil = cl.loadClass("com.huawei.android.util.HwNotchSizeUtil");
Method get = HwNotchSizeUtil.getMethod("getNotchSize");
notchSize = (int[]) get.invoke(HwNotchSizeUtil);
} catch (ClassNotFoundException e) {
Log.e("test", "getNotchSize ClassNotFoundException");
} catch (NoSuchMethodException e) {
Log.e("test", "getNotchSize NoSuchMethodException");
} catch (Exception e) {
Log.e("test", "getNotchSize Exception");
} finally {
return notchSize;
}
}
//获取系统状态栏高度
public static int getStatusBarHeight(Context context) {
int StatusBarHeight = 0;
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
StatusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
}
return StatusBarHeight;
}
public void update(Context context) {
......@@ -87,14 +123,16 @@ public class AppsSettings {
if (dm != null) {
int height = Math.max(dm.widthPixels, dm.heightPixels);
if (mScreenHeight == Math.max(mScreenHeight, mScreenWidth)) {
mScreenHeight = getRealHeight(context);
mScreenHeight = height;
} else {
mScreenWidth = getRealHeight(context);
mScreenWidth = height;
}
}
}
if (!hasNotchInScreen(context)) {
}
Log.i("屏幕不算虚拟键", "" + mScreenHeight);
Log.i("屏幕总宽", "" + getRealHeight(context));
}
public int getAppVersion() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment