Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
6b493b59
Commit
6b493b59
authored
Dec 06, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
没写完
parent
6105b329
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
13 deletions
+54
-13
libcore/src/main/AndroidManifest.xml
libcore/src/main/AndroidManifest.xml
+3
-0
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+51
-13
No files found.
libcore/src/main/AndroidManifest.xml
View file @
6b493b59
...
...
@@ -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"
>
...
...
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
6b493b59
...
...
@@ -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
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment