Skip to content

Commit

Permalink
一些小优化,和防呆设计
Browse files Browse the repository at this point in the history
  • Loading branch information
mingzhixian committed Apr 28, 2023
1 parent 9bca7e4 commit 3e0b27a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 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 78
versionName "7.8"
versionCode 79
versionName "7.9"
resConfigs "zh"
resConfigs "xhdpi"
ndk {
Expand Down
1 change: 1 addition & 0 deletions scrcpy_android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.REORDER_TASKS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />

<application
android:icon="@drawable/icon"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ class MainActivity : AppCompatActivity() {
addDeviceView.findViewById<Button>(R.id.add_device_ok).setOnClickListener {
deviceAdapter.newDevice(
addDeviceView.findViewById<EditText>(R.id.add_device_name).text.toString(),
addDeviceView.findViewById<EditText>(R.id.add_device_address).text.toString()
.replace("\\s|\\n|\\r|\\t".toRegex(), ""),
addDeviceView.findViewById<EditText>(R.id.add_device_address).text.toString(),
addDeviceView.findViewById<EditText>(R.id.add_device_port).text.toString().toInt(),
addDeviceView.findViewById<Spinner>(R.id.add_device_videoCodec).selectedItem.toString(),
addDeviceView.findViewById<Spinner>(R.id.add_device_resolution).selectedItem.toString()
Expand Down Expand Up @@ -639,8 +638,20 @@ class MainActivity : AppCompatActivity() {

// 按键广播处理
inner class ScreenReceiver : BroadcastReceiver() {
override fun onReceive(p0: Context?, p1: Intent?) {
@SuppressLint("WrongConstant")
override fun onReceive(context: Context?, intent: Intent?) {
if (configs.status > 0) {
// 如果为通知栏关闭则自动收起通知栏
try {
val service = getSystemService("statusbar")
if (service != null) {
val collapse = Class.forName("android.app.StatusBarManager").getMethod("collapsePanels")
collapse.isAccessible = true
collapse.invoke(service)
}
} catch (e: Exception) {
e.printStackTrace()
}
// 恢复为未投屏状态
configs.status = -1
// 取消强制旋转
Expand Down
3 changes: 3 additions & 0 deletions scrcpy_android/app/src/main/res/layout/add_device.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ."
android:textSize="@dimen/middleFont" />
</LinearLayout>

Expand All @@ -74,6 +75,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:digits="1234567890"
android:text="5555"
android:textSize="@dimen/middleFont" />
</LinearLayout>

Expand Down
2 changes: 1 addition & 1 deletion scrcpy_android/app/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<string-array name="fps">
<item>60</item>
<item>90</item>
<item>30</item>
<item>40</item>
<item>30</item>
<item>10</item>
</string-array>
<string-array name="videoBit">
Expand Down

0 comments on commit 3e0b27a

Please sign in to comment.