Skip to content

Commit

Permalink
更新V6.3 解决悬浮球在不同分辨率下大小过大或过小的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mingzhixian committed Apr 22, 2023
1 parent ef4efa8 commit 1248cb7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions scrcpy_android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "top.saymzx.scrcpy_android"
minSdk 23
targetSdk 33
versionCode 62
versionName "6.2"
versionCode 63
versionName "6.3"
resConfigs "zh"
ndk {
abiFilter "arm64-v8a"
Expand Down
4 changes: 2 additions & 2 deletions scrcpy_android/app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 62,
"versionName": "6.2",
"versionCode": 63,
"versionName": "6.3",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ class MainActivity : AppCompatActivity() {
configs.localWidth = metric.widthPixels
configs.localHeight = metric.heightPixels
// 防止打开时为横屏导致分辨率反了
if(configs.localWidth>configs.localHeight){
val tmp=configs.localWidth
configs.localWidth=configs.localHeight
configs.localHeight=tmp
if (configs.localWidth > configs.localHeight) {
val tmp = configs.localWidth
configs.localWidth = configs.localHeight
configs.localHeight = tmp
}
// 读取配置
readConfigs {
Expand Down Expand Up @@ -459,11 +459,13 @@ class MainActivity : AppCompatActivity() {
// 导航球,旋转不改变位置
if (configs.remoteWidth > configs.remoteHeight) {
tmp = configs.navLayoutParams.y
configs.navLayoutParams.y = configs.localHeight - configs.navLayoutParams.x - 170
configs.navLayoutParams.y =
configs.localHeight - configs.navLayoutParams.x - configs.navLayoutParams.width
configs.navLayoutParams.x = tmp
} else {
tmp = configs.navLayoutParams.x
configs.navLayoutParams.x = configs.localWidth - configs.navLayoutParams.y - 170
configs.navLayoutParams.x =
configs.localWidth - configs.navLayoutParams.y - configs.navLayoutParams.height
configs.navLayoutParams.y = tmp
}
runOnUiThread {
Expand All @@ -486,8 +488,8 @@ class MainActivity : AppCompatActivity() {
else LayoutParams.TYPE_PHONE
flags =
LayoutParams.FLAG_LAYOUT_NO_LIMITS or LayoutParams.FLAG_LAYOUT_IN_SCREEN or LayoutParams.FLAG_NOT_FOCUSABLE //位置大小设置
width = 170
height = 170
width = (60 * resources.displayMetrics.density + 0.5f).toInt()
height = (60 * resources.displayMetrics.density + 0.5f).toInt()
gravity = Gravity.START or Gravity.TOP
format = PixelFormat.RGBA_8888
x = 0
Expand Down Expand Up @@ -531,8 +533,8 @@ class MainActivity : AppCompatActivity() {
} else {
event.action = ACTION_CANCEL
gestureDetector.onTouchEvent(event)
configs.navLayoutParams.x = x - 85
configs.navLayoutParams.y = y - 85
configs.navLayoutParams.x = x - configs.navLayoutParams.width / 2
configs.navLayoutParams.y = y - configs.navLayoutParams.height / 2
windowManager.updateViewLayout(configs.navView, configs.navLayoutParams)
return@setOnTouchListener true
}
Expand Down

0 comments on commit 1248cb7

Please sign in to comment.