WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 80c2bea

Browse files
committed
继续优化代码
1 parent 81ed4f1 commit 80c2bea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1559
-112
lines changed

app/build.gradle.kts

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
2+
import java.util.Properties
3+
14
plugins {
25
alias(libs.plugins.android.application)
36
alias(libs.plugins.kotlin.android)
@@ -7,30 +10,61 @@ plugins {
710
android {
811
namespace = "com.ghhccghk.xiaomibluetoothdiy"
912
compileSdk = 35
13+
val buildTime = System.currentTimeMillis()
14+
val localProperties = Properties()
15+
if (rootProject.file("local.properties").canRead())
16+
localProperties.load(rootProject.file("local.properties").inputStream())
1017

1118
defaultConfig {
1219
applicationId = "com.ghhccghk.xiaomibluetoothdiy"
1320
minSdk = 32
1421
targetSdk = 35
1522
versionCode = 1
1623
versionName = "1.0"
24+
dependenciesInfo.includeInApk = false
25+
ndk.abiFilters += arrayOf("arm64-v8a", "armeabi-v7a", "x86", "x86_64","armeabi","mips", "mips64")
26+
buildConfigField("long", "BUILD_TIME", "$buildTime")
27+
vectorDrawables {
28+
useSupportLibrary = true
29+
}
30+
}
1731

18-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
32+
val config = localProperties.getProperty("androidStoreFile")?.let {
33+
signingConfigs.create("config") {
34+
storeFile = file(it)
35+
storePassword = localProperties.getProperty("androidStorePassword")
36+
keyAlias = localProperties.getProperty("androidKeyAlias")
37+
keyPassword = localProperties.getProperty("androidKeyPassword")
38+
enableV3Signing = true
39+
enableV4Signing = true
40+
}
1941
}
2042

2143
buildTypes {
44+
all {
45+
signingConfig = config ?: signingConfigs["debug"]
46+
}
47+
2248
release {
23-
isMinifyEnabled = false
24-
proguardFiles(
25-
getDefaultProguardFile("proguard-android-optimize.txt"),
26-
"proguard-rules.pro"
49+
isMinifyEnabled = true
50+
isShrinkResources = true
51+
vcsInfo.include = false
52+
setProguardFiles(
53+
listOf(
54+
getDefaultProguardFile("proguard-android-optimize.txt"),
55+
"proguard-rules.pro"
56+
)
2757
)
2858
}
2959
androidResources.additionalParameters("--allow-reserved-package-id", "--package-id", "0x64")
3060
aaptOptions.cruncherEnabled = false
3161
buildFeatures.buildConfig = true
3262
dependenciesInfo.includeInApk = false
3363
}
64+
buildFeatures {
65+
viewBinding = true
66+
buildConfig = true
67+
}
3468
compileOptions {
3569
sourceCompatibility = JavaVersion.VERSION_21
3670
targetCompatibility = JavaVersion.VERSION_21
@@ -41,9 +75,31 @@ android {
4175
buildFeatures {
4276
compose = true
4377
}
78+
packaging {
79+
resources {
80+
excludes += "**"
81+
}
82+
dex {
83+
useLegacyPackaging = true
84+
}
85+
}
86+
buildFeatures {
87+
viewBinding = true
88+
buildConfig = true
89+
}
90+
applicationVariants.all {
91+
outputs.all {
92+
(this as BaseVariantOutputImpl).outputFileName = "xiaomibluetoothdiy-$versionName-$versionCode-$name-$buildTime.apk"
93+
}
94+
}
4495
}
4596

4697
dependencies {
98+
implementation(libs.androidx.fragment)
99+
implementation(libs.androidx.constraintlayout)
100+
implementation(libs.material)
101+
implementation(libs.androidx.coordinatorlayout)
102+
implementation(libs.androidx.navigation.fragment)
47103
val composeBom = platform(libs.androidx.compose.bom)
48104
implementation(composeBom)
49105
androidTestImplementation(composeBom)
@@ -71,6 +127,12 @@ dependencies {
71127
implementation(libs.androidx.compose.materialWindow)
72128
implementation(libs.androidx.compose.ui.googlefonts)
73129
implementation(libs.androidx.compose.ui.tooling.preview)
130+
implementation(libs.androidx.navigation.compose)
131+
implementation(libs.androidx.navigation.ui.ktx)
132+
implementation(libs.androidx.appcompat)
133+
implementation(libs.androidx.material3)
134+
135+
74136
debugImplementation(libs.androidx.compose.ui.tooling)
75137
implementation(libs.hyperfocusapi)
76138
}

app/release/app-release.apk

-38.7 MB
Binary file not shown.
Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,46 @@
11
package com.ghhccghk.xiaomibluetoothdiy
22

33
import android.os.Bundle
4-
import androidx.activity.ComponentActivity
5-
import androidx.activity.compose.setContent
64
import androidx.activity.enableEdgeToEdge
7-
import androidx.compose.foundation.layout.fillMaxSize
8-
import androidx.compose.foundation.layout.padding
9-
import androidx.compose.material3.Scaffold
10-
import androidx.compose.material3.Text
11-
import androidx.compose.runtime.Composable
12-
import androidx.compose.ui.Modifier
13-
import androidx.compose.ui.tooling.preview.Preview
14-
import com.ghhccghk.xiaomibluetoothdiy.ui.theme.MyApplicationTheme
5+
import androidx.compose.foundation.layout.*
6+
import androidx.compose.material3.*
7+
import androidx.compose.runtime.*
8+
import androidx.navigation.compose.*
9+
import androidx.activity.viewModels
10+
import androidx.appcompat.app.AppCompatActivity
11+
import androidx.navigation.findNavController
12+
import androidx.navigation.ui.setupWithNavController
13+
import cn.xiaowine.dsp.DSP
14+
import cn.xiaowine.dsp.data.MODE
15+
import cn.xiaowine.xkt.AcTool
16+
import com.ghhccghk.xiaomibluetoothdiy.databinding.ActivityMainBinding
17+
import com.ghhccghk.xiaomibluetoothdiy.tools.Tools.xpActivation
18+
import com.ghhccghk.xiaomibluetoothdiy.ui.viewmodel.ShareViewModel
19+
import com.google.android.material.navigation.NavigationBarView
20+
21+
class MainActivity : AppCompatActivity() {
22+
23+
private val shareViewModel: ShareViewModel by viewModels()
24+
private lateinit var binding: ActivityMainBinding
1525

16-
class MainActivity : ComponentActivity() {
1726
override fun onCreate(savedInstanceState: Bundle?) {
1827
super.onCreate(savedInstanceState)
28+
AcTool.init(this)
1929
enableEdgeToEdge()
20-
setContent {
21-
MyApplicationTheme {
22-
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
23-
Greeting(
24-
name = "Android",
25-
modifier = Modifier.padding(innerPadding)
26-
)
27-
}
28-
}
29-
}
30+
xpActivation = DSP.init(this, BuildConfig.APPLICATION_ID, MODE.HOOK, false)
31+
shareViewModel.activated = xpActivation
32+
binding = ActivityMainBinding.inflate(layoutInflater)
33+
setContentView(binding.root)
3034
}
31-
}
3235

33-
@Composable
34-
fun Greeting(name: String, modifier: Modifier = Modifier) {
35-
Text(
36-
text = "Hello $name!",
37-
modifier = modifier
38-
)
39-
}
4036

41-
@Preview(showBackground = true)
42-
@Composable
43-
fun GreetingPreview() {
44-
MyApplicationTheme {
45-
Greeting("Android")
37+
override fun onStart() {
38+
super.onStart()
39+
(binding.nav as NavigationBarView).setupWithNavController(findNavController(R.id.nav_host_fragment))
4640
}
47-
}
41+
42+
override fun onSupportNavigateUp(): Boolean {
43+
val navController = findNavController(R.id.nav_host_fragment)
44+
return navController.navigateUp() || super.onSupportNavigateUp()
45+
}
46+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.ghhccghk.xiaomibluetoothdiy.config
2+
3+
import cn.xiaowine.dsp.delegate.Delegate.serialLazy
4+
5+
class Config {
6+
var hideicon: Boolean by serialLazy(true)
7+
}
8+

app/src/main/java/com/ghhccghk/xiaomibluetoothdiy/hook/Hook.kt

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import android.content.Context
1010
import android.content.Intent
1111
import android.graphics.drawable.Icon
1212
import android.os.Bundle
13+
import android.view.View
1314
import android.widget.RemoteViews
1415
import android.widget.RemoteViews.RemoteView
1516
import androidx.compose.material3.Icon
17+
import androidx.transition.Visibility
1618
import cn.xiaowine.xkt.LogTool.log
1719
import cn.xiaowine.xkt.Tool.isNull
1820
import com.ghhccghk.xiaomibluetoothdiy.BaseHook
1921
import com.ghhccghk.xiaomibluetoothdiy.R
22+
import com.ghhccghk.xiaomibluetoothdiy.tools.ConfigTools.xConfig
2023
import com.ghhccghk.xiaomibluetoothdiy.utils.ResInjectTool.injectModuleRes
2124
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClass
2225
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
@@ -128,6 +131,8 @@ object Hook : BaseHook() {
128131
)
129132

130133
val focustest_layout = res.getIdentifier("focustest_layout", "layout", "com.ghhccghk.xiaomibluetoothdiy")
134+
val kl = res.getIdentifier("kl","drawable","com.ghhccghk.xiaomibluetoothdiy")
135+
val imagelogo = res.getIdentifier("imagelogo", "id","com.ghhccghk.xiaomibluetoothdiy" )
131136
val device_name = res.getIdentifier("device_name", "id","com.ghhccghk.xiaomibluetoothdiy" )
132137
val connection_status = res.getIdentifier("focus_small_title", "id","com.ghhccghk.xiaomibluetoothdiy" )
133138
val right_battery = res.getIdentifier("right_battery", "id","com.ghhccghk.xiaomibluetoothdiy" )
@@ -138,28 +143,22 @@ object Hook : BaseHook() {
138143
val rV = RemoteViews("com.ghhccghk.xiaomibluetoothdiy",focustest_layout)
139144

140145
rV.setTextViewText(device_name,deviceName)
146+
if (deviceName.contains("Redmi AirDots 3 Pro 原神版") ){
147+
rV.setImageViewResource(imagelogo,kl)
148+
}
149+
if (xConfig.hideicon){
150+
rV.setViewVisibility(imagelogo, View.GONE)
151+
}
141152
rV.setTextViewText(connection_status,"已连接")
142-
rV.setTextViewText(right_battery,"右:$right")
143-
rV.setTextViewText(left_battery,"左:$left")
144-
rV.setTextViewText(case_battery,"充电盒:$case")
145-
rV.setTextViewText(disconnect,"断开")
153+
rV.setTextViewText(right_battery,": $right")
154+
rV.setTextViewText(left_battery,": $left")
155+
rV.setTextViewText(case_battery,": $case")
146156
rV.setOnClickPendingIntent(disconnect,ass)
147157

148158
val actionss = api.actionInfo(actionsIntent = intent, actionsTitle = "断开", actionTitleColor = "#FFFFFF")
149159
actionss.put("actionIntentType",2)
150160
actionss.toString().log()
151161

152-
val hintInfo = api.hintInfo(type = 1 ,
153-
titleLineCount = 6, actionInfo = actionss,
154-
title = "已连接")
155-
156-
val baseinfo = api.baseinfo(
157-
content = deviceName,
158-
title = "左:$left",
159-
subTitle = "右:$right",
160-
extraTitle = "充电盒:$case"
161-
)
162-
val a = android.R.drawable.stat_sys_data_bluetooth
163162
val focus = api.senddiyFocus(
164163
ticker = "",
165164
picticker = Icon.createWithResource(context,android.R.drawable.stat_sys_data_bluetooth),
@@ -172,12 +171,28 @@ object Hook : BaseHook() {
172171
val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
173172
val channelId = ("BTHeadset" + device.address)
174173

174+
175+
val intent2 = Intent("com.android.bluetooth.headset.click.detail_notification").apply {
176+
putExtra("bluetoothaddress", device.address)
177+
putExtra("COME_FROM", "MIUI_BLUETOOTH_SETTINGS")
178+
putExtra("android.bluetooth.device.extra.DEVICE", device)
179+
setIdentifier("BTHeadset" + device.address)
180+
}
181+
182+
val broadcast = PendingIntent.getBroadcast(
183+
context,
184+
0,
185+
intent2,
186+
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
187+
)
188+
189+
175190
val notification = Notification.Builder(context, channelId)
176191
.setContentTitle(deviceName)
177192
.setContentText(content)
178193
.setSmallIcon(android.R.drawable.stat_sys_data_bluetooth)
179194
.setAutoCancel(true)
180-
.setContentIntent(ass)
195+
.setContentIntent(broadcast)
181196
.build()
182197
notification.extras.putAll(focus)
183198
manager.notify(channelId,10003,notification)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* StatusBarLyric
3+
* Copyright (C) 2021-2022 [email protected]
4+
* https://github.com/577fkj/StatusBarLyric
5+
*
6+
* This software is free opensource software: you can redistribute it
7+
* and/or modify it under the terms of the GNU General Public License
8+
* as published by the Free Software Foundation; either
9+
* version 3 of the License, or any later version and our eula as published
10+
* by 577fkj.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* and eula along with this software. If not, see
19+
* <https://www.gnu.org/licenses/>
20+
* <https://github.com/577fkj/StatusBarLyric/blob/main/LICENSE>.
21+
*/
22+
23+
package com.ghhccghk.xiaomibluetoothdiy.tools
24+
25+
import android.annotation.SuppressLint
26+
import com.ghhccghk.xiaomibluetoothdiy.config.Config
27+
28+
@SuppressLint("StaticFieldLeak")
29+
object ConfigTools {
30+
val config: Config by lazy { Config() }
31+
val xConfig: Config by lazy { Config() }
32+
}

0 commit comments

Comments
 (0)