Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoXiCheng committed Sep 25, 2024
2 parents a426c04 + 7e30193 commit d7a0c6d
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 15 deletions.
6 changes: 5 additions & 1 deletion app/src/main/java/com/android/skip/MyApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.android.skip
import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.os.Build
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import com.android.skip.util.DataStoreUtils
Expand All @@ -19,12 +20,13 @@ class MyApp : Application(), Configuration.Provider {
override fun onCreate() {
super.onCreate()
context = this
deviceName = "${Build.MANUFACTURER} ${Build.MODEL}"

DataStoreUtils.init(this)

Utils.init(this)
LogUtils.getConfig()
.setLogSwitch(true) // 是否输出日志开关
.setLogSwitch(false) // 是否输出日志开关
.setConsoleSwitch(true) // 是否在控制台输出日志开关
.setGlobalTag("SKIP_APP") // 全局标签
.setLog2FileSwitch(true) // 是否写入日志文件开关
Expand All @@ -40,6 +42,8 @@ class MyApp : Application(), Configuration.Provider {
companion object {
@SuppressLint("StaticFieldLeak")
lateinit var context: Context

lateinit var deviceName: String
}

override fun getWorkManagerConfiguration() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.android.skip.R
import com.android.skip.data.network.MyApiNetwork
import com.android.skip.dataclass.SemanticVersion
import com.android.skip.dataclass.VersionPostSchema
import com.android.skip.dataclass.VersionState
import com.blankj.utilcode.util.AppUtils
Expand All @@ -23,21 +24,22 @@ class ApkVersionRepository @Inject constructor(
private suspend fun changeVersionState(versionPostState: VersionPostSchema) =
withContext(Dispatchers.IO) {
_versionPostState.postValue(versionPostState)
val version = myApiNetwork.fetchLatestVersion()
if (version == AppUtils.getAppVersionName()) {
val version1 = myApiNetwork.fetchLatestVersion()
val version2 = AppUtils.getAppVersionName()
if (isVersionGreater(version1, version2)) {
_versionPostState.postValue(
VersionPostSchema(
VersionState.CURRENT_LATEST,
version,
version
VersionState.DISCOVER_LATEST,
getString(R.string.about_discover_latest),
version1
)
)
} else {
_versionPostState.postValue(
VersionPostSchema(
VersionState.DISCOVER_LATEST,
getString(R.string.about_discover_latest),
version
VersionState.CURRENT_LATEST,
version2,
version2
)
)
}
Expand All @@ -48,4 +50,25 @@ class ApkVersionRepository @Inject constructor(
VersionPostSchema(VersionState.PENDING, getString(R.string.checking), String())
)
}

private fun parseVersion(version: String): SemanticVersion {
val parts = version.split(".")
val major = parts.getOrNull(0)?.toIntOrNull() ?: 0
val minor = parts.getOrNull(1)?.toIntOrNull() ?: 0
val patch = parts.getOrNull(2)?.toIntOrNull() ?: 0
return SemanticVersion(major, minor, patch)
}

private fun isVersionGreater(version1: String, version2: String): Boolean {
val v1 = parseVersion(version1)
val v2 = parseVersion(version2)
return when {
v1.major > v2.major -> true
v1.major < v2.major -> false
v1.minor > v2.minor -> true
v1.minor < v2.minor -> false
v1.patch > v2.patch -> true
else -> false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ data class NodeRootSchema(
val screenHeight: Int,
val screenWidth: Int,
val createTime: Long,
val deviceName: String,
val nodes: MutableList<NodeChildSchema>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.android.skip.dataclass

data class SemanticVersion(val major: Int, val minor: Int, val patch: Int)
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class InspectService : Service() {
val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)
val notification = NotificationCompat.Builder(this, "INSPECT_SERVICE")
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.notification_accessibility_service_running))
.setContentText(getString(R.string.notification_inspect_service_running))
.setSmallIcon(R.drawable.favicon32)
// .setLargeIcon(BitmapFactory.decodeResource(resources, R.drawable.favicon32))
.setContentIntent(pendingIntent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.view.KeyEvent
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import androidx.lifecycle.Observer
import com.android.skip.MyApp
import com.android.skip.R
import com.android.skip.data.config.ConfigLoadRepository
import com.android.skip.dataclass.AccessibilityNodeInfoCarrier
Expand Down Expand Up @@ -239,6 +240,7 @@ class MyAccessibilityService : AccessibilityService() {
ScreenUtils.getScreenHeight(),
ScreenUtils.getScreenWidth(),
System.currentTimeMillis(),
MyApp.deviceName,
nodeChildSchemaList
)

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<string name="store_not_update">NOT_UPDATE</string>

<string name="notification_accessibility_service_running">无障碍服务运行中</string>
<string name="notification_inspect_service_running">布局检查服务运行中</string>

<string name="loading">加载中…</string>
</resources>
2 changes: 1 addition & 1 deletion docs/inspect/InspectTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<el-table-column prop="createTime" label="创建时间" sortable="custom" width="200" :formatter="formatter" />
<el-table-column prop="appName" label="应用名称" :filters="appFilters" width="150" />
<el-table-column prop="packageName" label="应用包名" />
<el-table-column prop="activityName" label="Activity 名称" />
<el-table-column prop="deviceName" label="设备名称" />
</el-table>
</template>

Expand Down
4 changes: 4 additions & 0 deletions docs/inspect/NodeTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const props = defineProps<{
function buildWindowTableData(data: AccessibilityWindow | null) {
if (!data) return [];
return [
{
key: "设备名称",
value: data.deviceName,
},
{
key: "应用名称",
value: data.appName,
Expand Down
4 changes: 2 additions & 2 deletions docs/inspect/hook/useZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function useZip(arrayBuffer: ArrayBuffer) {
raw.value = jsonObj;
pic.value = blobFile;

const { fileId, appName, packageName, activityName, createTime } = jsonObj;
const { fileId, appName, packageName, deviceName, createTime } = jsonObj;
const targetFileTable = await FileTable.findFileTableByFileId(fileId);
if (targetFileTable == null) {
MyIndexDB.addFileData({
Expand All @@ -34,7 +34,7 @@ export function useZip(arrayBuffer: ArrayBuffer) {
createTime,
appName,
packageName,
activityName,
deviceName,
});
added.value = true;
}
Expand Down
3 changes: 2 additions & 1 deletion docs/inspect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface AccessibilityWindow {
screenHeight: number;
screenWidth: number;
createTime: number;
deviceName: string;
nodes: AccessibilityNode[];
}

Expand Down Expand Up @@ -44,7 +45,7 @@ export interface FileTableData {
createTime: number;
appName: string;
packageName: string;
activityName: string;
deviceName: string;
}

export interface FileItemData {
Expand Down
2 changes: 1 addition & 1 deletion docs/my-index-db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MyIndexDB {
createTime: fileData.createTime,
appName: fileData.appName,
packageName: fileData.packageName,
activityName: fileData.activityName,
deviceName: fileData.deviceName,
});
fileItemStore.add({ fileId: fileData.fileId, pic: fileData.pic, raw: fileData.raw });
tx.commit();
Expand Down

0 comments on commit d7a0c6d

Please sign in to comment.