Skip to content

Commit

Permalink
Merge pull request #114 from GuoXiCheng/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
GuoXiCheng authored Jan 7, 2024
2 parents b5bfff0 + 0374fbc commit bad6139
Show file tree
Hide file tree
Showing 18 changed files with 754 additions and 790 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- release
env:
LATEST_VERSION: "1.5"
LATEST_VERSION: "2.0.0"

jobs:
build-and-deploy:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SKIP 是一款免费开源的安卓应用,旨在利用 Android 无障碍服务

## 主界面预览

<img src="https://guoxicheng.top/assets/image/skip-docs/main-interface.jpg" alt="https://guoxicheng.top/assets/image/skip-docs/main-interface.jpg" style="width: 30%;" />
<img src="https://guoxicheng.top/assets/image/skip-docs/main-interface-light.png" alt="https://guoxicheng.top/assets/image/skip-docs/main-interface-light.png" style="width: 30%;" />

## 使用说明

Expand All @@ -18,7 +18,7 @@ SKIP 是一款免费开源的安卓应用,旨在利用 Android 无障碍服务
## 如何贡献

- 应用市场APP种类繁多,情况各异,无法保证完全适配
- 如有问题可以提交issue,或者参考 👉 [贡献指南](https://guoxicheng.top/projects/SKIP-Docs/003-contribute.html)
- 如有问题可以提交issue,或者参考 👉 [贡献指南](https://guoxicheng.top/projects/SKIP-Docs/contribute.html)

## 许可证

Expand Down
Binary file added apk/SKIP-v2.0.0.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
minSdk 24
targetSdk 32
versionCode 1
versionName "1.5"
versionName "2.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
29 changes: 4 additions & 25 deletions app/src/main/java/com/android/skip/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.android.skip

import android.content.Intent
import android.net.Uri
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.android.skip.compose.ConfirmDialog
import com.android.skip.compose.FlatButton
import com.android.skip.compose.OpenBrowserDialog
import com.android.skip.compose.RowContent
import com.android.skip.compose.ScaffoldPage
import com.android.skip.manager.RectManager
Expand Down Expand Up @@ -54,31 +50,14 @@ fun AboutActivityInterface(onBackClick: () -> Unit) {
}

FlatButton(content = {
RowContent("当前版本:${BuildConfig.VERSION_NAME}")
RowContent(stringResource(id = R.string.about_current_version) + BuildConfig.VERSION_NAME)
})

FlatButton(content = {
RowContent("当前分辨率:${RectManager.getMaxRect()}")
RowContent(stringResource(id = R.string.about_current_resolution) + RectManager.getMaxRect())
})

})

OpenApplicationDialog(openName = openName.value, openUrl = openUrl.value, showDialog)
}

@Composable
fun OpenApplicationDialog(openName: String, openUrl: String, showDialog: MutableState<Boolean>) {
val context = LocalContext.current

if (showDialog.value) {
ConfirmDialog(
title = "启动应用",
content = "是否通过浏览器访问 $openName",
onDismiss = { showDialog.value = false },
onAllow = {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(openUrl))
context.startActivity(intent)
showDialog.value = false
})
}
OpenBrowserDialog(openName = openName.value, openUrl = openUrl.value, showDialog)
}
33 changes: 25 additions & 8 deletions app/src/main/java/com/android/skip/KeepAliveActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ package com.android.skip
import android.content.ComponentName
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import com.android.skip.compose.FlatButton
import com.android.skip.compose.OpenBrowserDialog
import com.android.skip.compose.PictureDialog
import com.android.skip.compose.ResourceIcon
import com.android.skip.compose.RowContent
import com.android.skip.compose.ScaffoldPage
import java.net.URLEncoder

class KeepAliveActivity : BaseActivity() {

Expand All @@ -28,14 +31,15 @@ class KeepAliveActivity : BaseActivity() {
@Composable
fun KeepAliveInterface(onBackClick: () -> Unit) {
val context = LocalContext.current
val showDialog = remember { mutableStateOf(false) }
val showPicDialog = remember { mutableStateOf(false) }
val showBrowserDialog = remember { mutableStateOf(false) }
ScaffoldPage(stringResource(id = R.string.alive), onBackClick = onBackClick, content = {
PictureDialog(showDialog)
PictureDialog(showPicDialog)
FlatButton(content = {
RowContent(
stringResource(id = R.string.alive_power_saving_title),
stringResource(id = R.string.alive_power_saving_subtitle),
{ ResourceIcon(iconResource = R.drawable.counter_1)}
{ ResourceIcon(iconResource = R.drawable.counter_1) }
)
}) {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
Expand All @@ -46,7 +50,7 @@ fun KeepAliveInterface(onBackClick: () -> Unit) {
RowContent(
stringResource(id = R.string.alive_self_start_title),
stringResource(id = R.string.alive_self_start_subtitle),
{ ResourceIcon(iconResource = R.drawable.counter_2)}
{ ResourceIcon(iconResource = R.drawable.counter_2) }
)
}) {
val intent = Intent()
Expand All @@ -60,17 +64,30 @@ fun KeepAliveInterface(onBackClick: () -> Unit) {
RowContent(
stringResource(id = R.string.alive_backstage_title),
stringResource(id = R.string.alive_backstage_subtitle),
{ ResourceIcon(iconResource = R.drawable.counter_3)}
{ ResourceIcon(iconResource = R.drawable.counter_3) }
)
}) {
showDialog.value = true
showPicDialog.value = true
}
FlatButton(content = {
RowContent(
stringResource(id = R.string.alive_warn_title),
stringResource(id = R.string.alive_warn_subtitle),
{ ResourceIcon(iconResource = R.drawable.warning)}
{ ResourceIcon(iconResource = R.drawable.warning) }
)
})
}) {
showBrowserDialog.value = true
}
})

val searchContent = Build.MANUFACTURER + stringResource(id = R.string.alive_warn_search_content)
OpenBrowserDialog(
openName = searchContent,
openUrl = createBaiduSearchUrl(searchContent),
showDialog = showBrowserDialog
)
}

fun createBaiduSearchUrl(query: String): String {
return "https://www.baidu.com/s?wd=${URLEncoder.encode(query, "UTF-8")}"
}
Loading

0 comments on commit bad6139

Please sign in to comment.