├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── xposed_init │ ├── ic_launcher-playstore.png │ ├── java │ └── io │ │ └── lamprose │ │ └── midock │ │ ├── MainHook.kt │ │ ├── Utils.kt │ │ └── ui │ │ ├── SettingSeekBar.kt │ │ └── SettingText.kt │ └── res │ ├── drawable │ ├── ic_launcher_background.xml │ └── ic_launcher_foreground.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── arrays.xml │ └── strings.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── preview-1.jpg └── preview-2.jpg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.aar 4 | *.ap_ 5 | *.aab 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | # Uncomment the following line in case you need and you don't have the release build type files in your app 18 | # release/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # IntelliJ 40 | *.iml 41 | .idea/workspace.xml 42 | .idea/tasks.xml 43 | .idea/gradle.xml 44 | .idea/assetWizardSettings.xml 45 | .idea/dictionaries 46 | .idea/libraries 47 | # Android Studio 3 in .gitignore file. 48 | .idea/caches 49 | .idea/modules.xml 50 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 51 | .idea/navEditor.xml 52 | 53 | # Keystore files 54 | # Uncomment the following lines if you do not want to check your keystore files in. 55 | #*.jks 56 | #*.keystore 57 | 58 | # External native build folder generated in Android Studio 2.2 and later 59 | .externalNativeBuild 60 | .cxx/ 61 | 62 | # Google Services (e.g. APIs or Firebase) 63 | # google-services.json 64 | 65 | # Freeline 66 | freeline.py 67 | freeline/ 68 | freeline_project_description.json 69 | 70 | # fastlane 71 | fastlane/report.xml 72 | fastlane/Preview.html 73 | fastlane/screenshots 74 | fastlane/test_output 75 | fastlane/readme.md 76 | 77 | # Version control 78 | vcs.xml 79 | 80 | # lint 81 | lint/intermediates/ 82 | lint/generated/ 83 | lint/outputs/ 84 | lint/tmp/ 85 | # lint/reports/ 86 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 lamprose 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## MIDock 2 | 项目基于[MIUIDock](https://github.com/ouhoukyo/MIUIDock)项目二次开发 3 | 一个xposed模块,将MIUI高斯模糊的搜索栏修改成Dock背景 4 | 5 | ### 模糊条件 6 | + Android 11 以上 7 | + `build.prop` 中 `ro.miui.backdrop_sampling_enabled = true` 8 | 9 | ### 使用前须知 10 | 1. 无论你使用的是哪个类xposed框架,请在设置内开启资源钩子 11 | 2. 本项目只适配最新的RELEASE版本,如果有Bug,请提交[issues](https://github.com/lamprose/MIDock/issues),如果你使用的是ALPHA(内测)版本的桌面,请自行修改代码编译 12 | 13 | ### 使用方法 14 | 激活模块后重启系统桌面,打开桌面设置点击打开搜索栏再点击即可弹出模块设置弹窗 15 | ![preview-1](https://raw.githubusercontent.com/lamprose/MIDock/master/screenshots/preview-1.jpg) 16 | ![preview-2](https://raw.githubusercontent.com/lamprose/MIDock/master/screenshots/preview-2.jpg) 17 | 18 | ### 致谢 19 | - [XposedBridge](https://github.com/rovo89/XposedBridge): the OG xposed framework APIs 20 | - [LSPosed](https://github.com/LSPosed/LSPosed):LSPosed Xposed Framework. 21 | - [MIUIDock](https://github.com/ouhoukyo/MIUIDock):一个xposed模块,将MIUI高斯模糊的搜索栏修改成Dock背景 22 | - [EzXHelper](https://github.com/KyuubiRan/EzXHelper):一个使Xposed模块开发变的更轻松的kotlin库 23 | 24 | ### License 25 | 本项目基于[MIT](https://github.com/lamprose/MIDock/blob/master/LICENSE)协议开源 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion "30.0.3" 9 | 10 | defaultConfig { 11 | applicationId "io.lamprose.midock" 12 | minSdkVersion 28 13 | targetSdkVersion 30 14 | versionCode 1004 15 | versionName "1.4-beta1" 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | 19 | ndk { 20 | abiFilters 'arm64-v8a'//'armeabi-v7a', 'x86','armeabi'','x86_64','arm64-v8a' 21 | } 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | zipAlignEnabled true 28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 29 | } 30 | } 31 | compileOptions { 32 | sourceCompatibility JavaVersion.VERSION_1_8 33 | targetCompatibility JavaVersion.VERSION_1_8 34 | } 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | } 39 | 40 | dependencies { 41 | compileOnly 'de.robv.android.xposed:api:82' 42 | implementation 'com.github.kyuubiran:EzXHelper:0.3.7' 43 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 14 | 17 | 20 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/assets/xposed_init: -------------------------------------------------------------------------------- 1 | io.lamprose.midock.MainHook -------------------------------------------------------------------------------- /app/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /app/src/main/java/io/lamprose/midock/MainHook.kt: -------------------------------------------------------------------------------- 1 | package io.lamprose.midock 2 | 3 | import android.content.Context 4 | import android.content.DialogInterface 5 | import android.content.res.XResources 6 | import android.graphics.drawable.Drawable 7 | import android.graphics.drawable.GradientDrawable 8 | import android.graphics.drawable.RippleDrawable 9 | import android.os.Bundle 10 | import android.view.View 11 | import android.widget.* 12 | import com.github.kyuubiran.ezxhelper.init.EzXHelperInit 13 | import com.github.kyuubiran.ezxhelper.utils.* 14 | import de.robv.android.xposed.* 15 | import de.robv.android.xposed.callbacks.XC_InitPackageResources 16 | import de.robv.android.xposed.callbacks.XC_LayoutInflated 17 | import de.robv.android.xposed.callbacks.XC_LoadPackage 18 | import io.lamprose.midock.ui.SettingSeekBar 19 | import io.lamprose.midock.ui.SettingText 20 | import kotlin.system.exitProcess 21 | 22 | class MainHook : IXposedHookLoadPackage, IXposedHookInitPackageResources { 23 | companion object { 24 | const val MIUI_HOME_LAUNCHER_PACKAGENAME = "com.miui.home" 25 | const val DEVICE_CONFIG_CLASSNAME = "$MIUI_HOME_LAUNCHER_PACKAGENAME.launcher.DeviceConfig" 26 | const val LAUNCHER_CLASSNAME = "$MIUI_HOME_LAUNCHER_PACKAGENAME.launcher.Launcher" 27 | private var isAlpha = false 28 | private var versionCode: Long = -1L 29 | 30 | // 单位dip 31 | const val DOCK_RADIUS = 20 32 | const val DOCK_HEIGHT = 84 33 | const val DOCK_SIDE = 30 34 | const val DOCK_BOTTOM = 23 35 | const val DOCK_ICON_BOTTOM = 35 36 | 37 | // 需要修改圆角的资源 38 | val drawableNameList = arrayOf( 39 | "bg_search_bar_white85_black5", 40 | "bg_search_bar_black20_white10", 41 | "bg_search_bar_black8_white11", 42 | "bg_search_bar_d9_15_non", 43 | "bg_search_bar_e3_25_non", 44 | "bg_search_bar_button_dark", 45 | "bg_search_bar_button_light", 46 | "bg_search_bar_dark", 47 | "bg_search_bar_light" 48 | ) 49 | val drawableNameNewList = arrayOf( 50 | "bg_search_bar_black8_white11", 51 | "bg_search_bar_button_dark", 52 | "bg_search_bar_button_light", 53 | "bg_search_bar_dark", 54 | "bg_search_bar_light", 55 | "bg_search_bar_input_dark", 56 | "bg_search_bar_input_light" 57 | ) 58 | } 59 | 60 | override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { 61 | if (lpparam.packageName != MIUI_HOME_LAUNCHER_PACKAGENAME) { 62 | return 63 | } 64 | EzXHelperInit.initHandleLoadPackage(lpparam) 65 | EzXHelperInit.setLogTag("MIDock") 66 | findMethodByCondition("$MIUI_HOME_LAUNCHER_PACKAGENAME.launcher.Application") { m -> 67 | m.name == "attachBaseContext" && m.parameterTypes[0] == Context::class.java 68 | }.hookAfter { 69 | EzXHelperInit.initAppContext(it.args[0] as Context) 70 | isAlpha = Utils.getVersionName()!!.startsWith("ALPHA") 71 | versionCode = Utils.getVersionCode() 72 | showSettingDialog() 73 | launcherHook(lpparam) 74 | deviceConfigHook(lpparam) 75 | } 76 | } 77 | 78 | private fun showSettingDialog() { 79 | findMethodByCondition("$MIUI_HOME_LAUNCHER_PACKAGENAME.settings.MiuiHomeSettings") { m -> 80 | m.name == "onCreatePreferences" && m.parameterTypes[0] == Bundle::class.java && m.parameterTypes[1] == String::class.java 81 | }.hookAfter { 82 | it.thisObject.getObjectOrNull("mSearchBarSetting")!!.invokeMethod( 83 | "setTitle", 84 | arrayOf("Dock设置"), 85 | arrayOf(CharSequence::class.java) 86 | ) 87 | } 88 | findMethodByCondition("$MIUI_HOME_LAUNCHER_PACKAGENAME.settings.MiuiHomeSettings") { m -> 89 | m.name == "showHomeSearchBarDialog" && m.parameters.isEmpty() 90 | }.hookBefore { 91 | Log.d("hook start") 92 | val context = it.thisObject.invokeMethod("getContext") as Context 93 | Utils.getVersionName()?.let { ver -> Log.d(ver) } 94 | Log.d(isAlpha.toString()) 95 | val dialogBuilderClzStr = 96 | if (isAlpha || versionCode >= 421153106L) "miuix.appcompat.app.AlertDialog${'$'}Builder" else "miui.app.AlertDialog${'$'}Builder" 97 | val dialogBuilder = loadClass(dialogBuilderClzStr) 98 | .getConstructor(Context::class.java) 99 | .newInstance(context) 100 | dialogBuilder.apply { 101 | val radiusSeek = 102 | SettingSeekBar.Builder(context, "Dock圆角", Utils.getData("DOCK_RADIUS", 20)) 103 | .build() 104 | val heightSeek = 105 | SettingSeekBar.Builder( 106 | context, 107 | "Dock高度", 108 | Utils.getData("DOCK_HEIGHT", 84), 109 | 50, 200 110 | ).build() 111 | val sideSeek = 112 | SettingSeekBar.Builder( 113 | context, 114 | "Dock距离屏幕两侧", 115 | Utils.getData("DOCK_SIDE", 30), 116 | maxVal = 200 117 | ).build() 118 | val bottomSeek = 119 | SettingSeekBar.Builder( 120 | context, 121 | "Dock距离屏幕底部", 122 | Utils.getData("DOCK_BOTTOM", 23), 123 | maxVal = 200 124 | ).build() 125 | val iconBottomSeek = 126 | SettingSeekBar.Builder( 127 | context, 128 | "图标区域距离屏幕底部", 129 | Utils.getData("DOCK_ICON_BOTTOM", 35), 130 | maxVal = 200 131 | ).build() 132 | var confirmDelete = false 133 | invokeMethod("setTitle", arrayOf("Dock设置"), arrayOf(CharSequence::class.java)) 134 | invokeMethod( 135 | "setNegativeButton", 136 | arrayOf("删除", DialogInterface.OnClickListener { _, _ -> 137 | it.thisObject.invokeMethod( 138 | "setHomeScreenSearchBar", 139 | arrayOf(context, false), 140 | arrayOf(Context::class.java, Boolean::class.java) 141 | ) 142 | confirmDelete = true 143 | }), 144 | arrayOf(CharSequence::class.java, DialogInterface.OnClickListener::class.java) 145 | ) 146 | invokeMethod( 147 | "setPositiveButton", 148 | arrayOf("保存并重启", DialogInterface.OnClickListener { _, _ -> 149 | Utils.getEditor()?.let { editor -> 150 | editor.putInt("DOCK_RADIUS", radiusSeek.value) 151 | editor.putInt("DOCK_HEIGHT", heightSeek.value) 152 | editor.putInt("DOCK_SIDE", sideSeek.value) 153 | editor.putInt("DOCK_BOTTOM", bottomSeek.value) 154 | editor.putInt("DOCK_ICON_BOTTOM", iconBottomSeek.value) 155 | if (editor.commit()) { 156 | exitProcess(0) 157 | } 158 | } 159 | }), 160 | arrayOf(CharSequence::class.java, DialogInterface.OnClickListener::class.java) 161 | ) 162 | invokeMethod( 163 | "setOnDismissListener", 164 | arrayOf(DialogInterface.OnDismissListener { _ -> 165 | if (!confirmDelete) it.thisObject.getObjectOrNull("mSearchBarSetting")!! 166 | .invokeMethod("setChecked", arrayOf(true), arrayOf(Boolean::class.java)) 167 | }), 168 | arrayOf(DialogInterface.OnDismissListener::class.java) 169 | ) 170 | val linearLayout = LinearLayout(context).apply { 171 | orientation = LinearLayout.VERTICAL 172 | if (isAlpha || versionCode >= 421153106L) 173 | setPadding( 174 | Utils.dip2px(20), 175 | Utils.dip2px(20), 176 | Utils.dip2px(20), 177 | Utils.dip2px(20) 178 | ) 179 | addView(radiusSeek) 180 | addView(heightSeek) 181 | addView(sideSeek) 182 | addView(bottomSeek) 183 | addView(iconBottomSeek) 184 | addView(SettingText.Builder(context, "重置", SettingText.titleSize) { 185 | radiusSeek.value = DOCK_RADIUS 186 | heightSeek.value = DOCK_HEIGHT 187 | sideSeek.value = DOCK_SIDE 188 | bottomSeek.value = DOCK_BOTTOM 189 | iconBottomSeek.value = DOCK_ICON_BOTTOM 190 | context.showToast("参数重置完成", Toast.LENGTH_SHORT) 191 | }.build()) 192 | } 193 | invokeMethod("setView", arrayOf(linearLayout), arrayOf(View::class.java)) 194 | } 195 | it.thisObject.putObject("mHomeSearchBarDialog", dialogBuilder.invokeMethod("create")) 196 | return@hookBefore 197 | } 198 | } 199 | 200 | override fun handleInitPackageResources(resparam: XC_InitPackageResources.InitPackageResourcesParam) { 201 | if (resparam.packageName != MIUI_HOME_LAUNCHER_PACKAGENAME) { 202 | return 203 | } 204 | 205 | resparam.res.hookLayout( 206 | MIUI_HOME_LAUNCHER_PACKAGENAME, 207 | "layout", 208 | "layout_search_bar", 209 | object : XC_LayoutInflated() { 210 | override fun handleLayoutInflated(liparam: LayoutInflatedParam) { 211 | // 替换资源圆角 212 | val targetView = liparam.view 213 | (if (isAlpha || versionCode >= 421153106L) drawableNameNewList else drawableNameList).forEach { drawableName -> 214 | resetDockRadius( 215 | resparam.res, 216 | targetView.context, 217 | drawableName 218 | ) 219 | } 220 | } 221 | }) 222 | } 223 | 224 | private fun launcherHook(lpparam: XC_LoadPackage.LoadPackageParam) { 225 | val _LAUNCHER_CLASS = XposedHelpers.findClassIfExists( 226 | LAUNCHER_CLASSNAME, 227 | lpparam.classLoader 228 | ) ?: return 229 | try { 230 | XposedHelpers.findAndHookMethod( 231 | _LAUNCHER_CLASS, 232 | "onCreate", 233 | Bundle::class.java, 234 | object : XC_MethodHook() { 235 | override fun afterHookedMethod(param: MethodHookParam) { 236 | super.afterHookedMethod(param) 237 | val SearchBarObject = XposedHelpers.callMethod( 238 | param.thisObject, 239 | "getSearchBar" 240 | ) as FrameLayout 241 | val SearchBarDesktop = SearchBarObject.getChildAt(0) as RelativeLayout 242 | val SearchBarDrawer = SearchBarObject.getChildAt(1) as RelativeLayout 243 | val SearchBarContainer = SearchBarObject.parent as FrameLayout 244 | val SearchEdgeLayout = SearchBarContainer.parent as FrameLayout 245 | // 重新给Searbar容器排序 246 | SearchEdgeLayout.removeView(SearchBarContainer) 247 | SearchEdgeLayout.addView(SearchBarContainer, 0) 248 | // 清空搜索图标和小爱同学 249 | SearchBarDesktop.removeAllViews() 250 | // 修改高度 251 | SearchBarObject.layoutParams.height = Utils.dip2px( 252 | Utils.getData("DOCK_HEIGHT", DOCK_HEIGHT) 253 | ) 254 | 255 | // 修改应用列表搜索框 256 | val mAllAppViewField = _LAUNCHER_CLASS.getDeclaredField("mAppsView") 257 | mAllAppViewField.isAccessible = true 258 | val mAllAppView = mAllAppViewField.get(param.thisObject) as RelativeLayout 259 | val mAllAppSearchView = 260 | mAllAppView.getChildAt(mAllAppView.childCount - 1) as FrameLayout 261 | SearchBarObject.removeView(SearchBarDrawer) 262 | mAllAppSearchView.addView(SearchBarDrawer) 263 | SearchBarDrawer.bringToFront() 264 | val layoutParams = SearchBarDrawer.layoutParams as FrameLayout.LayoutParams 265 | SearchBarDrawer.layoutParams.height = Utils.dip2px( 266 | 45 267 | ) 268 | layoutParams.leftMargin = Utils.dip2px(15) 269 | layoutParams.rightMargin = Utils.dip2px(15) 270 | SearchBarDrawer.layoutParams = layoutParams 271 | } 272 | }) 273 | } catch (e: Exception) { 274 | XposedBridge.log("[MIDock] LauncherHook Error:" + e.message) 275 | } 276 | } 277 | 278 | private fun deviceConfigHook(lpparam: XC_LoadPackage.LoadPackageParam) { 279 | val _DEVICE_CONFIG_CLASS = XposedHelpers.findClassIfExists( 280 | DEVICE_CONFIG_CLASSNAME, 281 | lpparam.classLoader 282 | ) ?: return 283 | try { 284 | // 图标区域顶部边距 285 | XposedHelpers.findAndHookMethod( 286 | _DEVICE_CONFIG_CLASS, 287 | "calcHotSeatsMarginTop", 288 | Context::class.java, 289 | Boolean::class.java, 290 | object : XC_MethodHook() { 291 | override fun beforeHookedMethod(param: MethodHookParam) { 292 | param.args[1] = false 293 | super.beforeHookedMethod(param) 294 | } 295 | }) 296 | // 图标区域底部边距 297 | XposedHelpers.findAndHookMethod( 298 | _DEVICE_CONFIG_CLASS, 299 | "calcHotSeatsMarginBottom", 300 | Context::class.java, 301 | Boolean::class.java, 302 | Boolean::class.java, 303 | object : XC_MethodHook() { 304 | override fun beforeHookedMethod(param: MethodHookParam) { 305 | param.result = 306 | Utils.dip2px( 307 | Utils.getData("DOCK_ICON_BOTTOM", DOCK_ICON_BOTTOM) 308 | ) 309 | } 310 | }) 311 | // 搜索框宽度 312 | XposedHelpers.findAndHookMethod( 313 | _DEVICE_CONFIG_CLASS, 314 | "calcSearchBarWidth", 315 | Context::class.java, 316 | object : XC_MethodHook() { 317 | override fun beforeHookedMethod(param: MethodHookParam) { 318 | val context = param.args[0] as Context 319 | val deviceWidth = Utils.px2dip( 320 | context.resources.displayMetrics.widthPixels 321 | ) 322 | param.result = 323 | Utils.dip2px( 324 | deviceWidth - Utils.getData("DOCK_SIDE", DOCK_SIDE) 325 | ) 326 | } 327 | }) 328 | // Dock底部边距 329 | XposedHelpers.findAndHookMethod( 330 | _DEVICE_CONFIG_CLASS, 331 | "calcSearchBarMarginBottom", 332 | Context::class.java, 333 | Boolean::class.java, 334 | object : XC_MethodHook() { 335 | override fun beforeHookedMethod(param: MethodHookParam) { 336 | param.result = Utils.dip2px(Utils.getData("DOCK_BOTTOM", DOCK_BOTTOM)) 337 | } 338 | }) 339 | // 宽度变化量 340 | XposedHelpers.findAndHookMethod( 341 | _DEVICE_CONFIG_CLASS, 342 | "getSearchBarWidthDelta", 343 | XC_MethodReplacement.returnConstant(0) 344 | ) 345 | } catch (e: Exception) { 346 | XposedBridge.log("[MIDock] DeviceConfigHook Error:" + e.message) 347 | } 348 | } 349 | 350 | private fun resetDockRadius(res: XResources, context: Context, drawableName: String) { 351 | try { 352 | res.setReplacement( 353 | MIUI_HOME_LAUNCHER_PACKAGENAME, 354 | "drawable", 355 | drawableName, 356 | object : XResources.DrawableLoader() { 357 | override fun newDrawable(xres: XResources, id: Int): Drawable { 358 | val background = context.getDrawable( 359 | xres.getIdentifier( 360 | drawableName, 361 | "drawable", 362 | MIUI_HOME_LAUNCHER_PACKAGENAME 363 | ) 364 | ) as RippleDrawable 365 | val backgroundShape = background.getDrawable(0) as GradientDrawable 366 | backgroundShape.cornerRadius = 367 | Utils.dip2px(Utils.getData("DOCK_RADIUS", DOCK_RADIUS)) 368 | .toFloat() 369 | backgroundShape.setStroke(0, 0) 370 | background.setDrawable(0, backgroundShape) 371 | return background 372 | } 373 | }) 374 | } catch (e: Exception) { 375 | XposedBridge.log("[MIDock] ResourcesReplacement Error:" + e.message) 376 | } 377 | } 378 | 379 | } -------------------------------------------------------------------------------- /app/src/main/java/io/lamprose/midock/Utils.kt: -------------------------------------------------------------------------------- 1 | package io.lamprose.midock 2 | 3 | import android.content.Context 4 | import android.content.SharedPreferences 5 | import android.content.pm.PackageManager 6 | import com.github.kyuubiran.ezxhelper.init.InitFields.appContext 7 | import com.github.kyuubiran.ezxhelper.utils.Log 8 | 9 | object Utils { 10 | private const val DATA_FILE_NAME = "MIDockConfig" 11 | 12 | fun dip2px(dpValue: Int): Int { 13 | return (dpValue * appContext.resources.displayMetrics.density + 0.5f).toInt() 14 | } 15 | 16 | fun px2dip(pxValue: Int): Int { 17 | return (pxValue / appContext.resources.displayMetrics.density + 0.5f).toInt() 18 | } 19 | 20 | fun sp2px(spValue: Float): Float { 21 | return spValue * appContext.resources.displayMetrics.scaledDensity + 0.5f 22 | } 23 | 24 | fun getEditor(): SharedPreferences.Editor? { 25 | return try { 26 | appContext.getSharedPreferences(DATA_FILE_NAME, Context.MODE_PRIVATE).edit() 27 | } catch (e: Exception) { 28 | null 29 | } 30 | } 31 | 32 | fun saveData(key: String, value: Any) { 33 | try { 34 | val sharedPreferences = 35 | appContext.getSharedPreferences(DATA_FILE_NAME, Context.MODE_PRIVATE) 36 | val editor = sharedPreferences.edit() 37 | when (value) { 38 | is Int -> editor.putInt(key, value) 39 | is Float -> editor.putFloat(key, value) 40 | is String -> editor.putString(key, value) 41 | is Boolean -> editor.putBoolean(key, value) 42 | is Long -> editor.putLong(key, value) 43 | } 44 | editor.apply() 45 | } catch (e: Exception) { 46 | // 也许是模块尚未加载 47 | Log.e(e, "saveData") 48 | } 49 | } 50 | 51 | fun getData(key: String, defValue: Int): Int { 52 | return try { 53 | val sharedPreferences = 54 | appContext.getSharedPreferences(DATA_FILE_NAME, Context.MODE_PRIVATE) 55 | sharedPreferences.getInt(key, defValue) 56 | } catch (e: Throwable) { 57 | // 也许是模块尚未加载 58 | defValue 59 | } 60 | } 61 | 62 | fun getVersionName(): String? { 63 | return try { 64 | val packageManager: PackageManager = appContext.packageManager 65 | packageManager.getPackageInfo(appContext.packageName, 0).versionName 66 | } catch (e: Exception) { 67 | Log.e(e, "getVersionName") 68 | null 69 | } 70 | } 71 | 72 | fun getVersionCode(): Long { 73 | return try { 74 | val packageManager: PackageManager = appContext.packageManager 75 | packageManager.getPackageInfo(appContext.packageName, 0).longVersionCode 76 | } catch (e: Exception) { 77 | Log.e(e, "getVersionName") 78 | -1L 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /app/src/main/java/io/lamprose/midock/ui/SettingSeekBar.kt: -------------------------------------------------------------------------------- 1 | package io.lamprose.midock.ui 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.view.ViewGroup 6 | import android.widget.LinearLayout 7 | import android.widget.SeekBar 8 | import android.widget.TextView 9 | import com.github.kyuubiran.ezxhelper.init.InitFields 10 | import io.lamprose.midock.Utils 11 | 12 | @SuppressLint("ViewConstructor") 13 | class SettingSeekBar(context: Context, minValue: Int = 0, maxValue: Int = 100) : 14 | LinearLayout(context) { 15 | var text: String = "" 16 | set(value) { 17 | field = value 18 | textView.text = value 19 | } 20 | var value: Int = 0 21 | set(value) { 22 | field = value 23 | seekBar.progress = value 24 | valueView.text = value.toString() 25 | } 26 | private val textView: TextView 27 | private val valueView: TextView 28 | private val seekBar: SeekBar 29 | 30 | 31 | init { 32 | orientation = VERTICAL 33 | setPadding(Utils.dip2px(5), Utils.dip2px(5), Utils.dip2px(5), Utils.dip2px(5)) 34 | textView = TextView(context) 35 | valueView = TextView(context).apply { 36 | text = (maxValue / 2).toString() 37 | textAlignment = TextView.TEXT_ALIGNMENT_CENTER 38 | } 39 | textView.textSize = Utils.sp2px(5f) 40 | seekBar = SeekBar(context).apply { 41 | min = minValue 42 | max = maxValue 43 | progress = valueView.text.toString().toInt() 44 | setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { 45 | override fun onProgressChanged( 46 | seekBar: SeekBar?, 47 | progress: Int, 48 | fromUser: Boolean 49 | ) { 50 | value = progress 51 | } 52 | 53 | override fun onStartTrackingTouch(seekBar: SeekBar?) {} 54 | override fun onStopTrackingTouch(seekBar: SeekBar?) {} 55 | }) 56 | } 57 | addView(textView.apply { 58 | setPadding(0, 0, 0, Utils.dip2px(5)) 59 | }) 60 | addView(seekBar) 61 | addView(LinearLayout(context).apply { 62 | orientation = HORIZONTAL 63 | addView(TextView(context).apply { 64 | text = minValue.toString() 65 | }, LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1f)) 66 | addView(valueView, LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1f)) 67 | addView(TextView(context).apply { 68 | text = maxValue.toString() 69 | textAlignment = TextView.TEXT_ALIGNMENT_VIEW_END 70 | }, LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1f)) 71 | }) 72 | } 73 | 74 | 75 | class Builder( 76 | private val mContext: Context = InitFields.appContext, 77 | private val mText: String, 78 | private val defaultValue: Int = 0, 79 | private val minVal: Int = 0, 80 | private val maxVal: Int = 100 81 | ) { 82 | fun build() = SettingSeekBar(mContext, minVal, maxVal).apply { 83 | text = mText 84 | value = defaultValue 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /app/src/main/java/io/lamprose/midock/ui/SettingText.kt: -------------------------------------------------------------------------------- 1 | package io.lamprose.midock.ui 2 | 3 | import android.content.Context 4 | import android.view.View 5 | import android.widget.TextView 6 | import com.github.kyuubiran.ezxhelper.init.InitFields 7 | import io.lamprose.midock.Utils 8 | 9 | class SettingText(context: Context) : TextView(context) { 10 | var size: Float 11 | get() = textSize 12 | set(value) { 13 | textSize = value 14 | } 15 | 16 | init { 17 | setPadding(Utils.dip2px(5), Utils.dip2px(5), Utils.dip2px(5), Utils.dip2px(5)) 18 | } 19 | 20 | 21 | class Builder(private val mContext: Context = InitFields.appContext, private val mText: String, private val mSize: Float? = null, private val mOnClickListener: ((View) -> Unit)? = null) { 22 | fun build() = SettingText(mContext).apply { 23 | text = mText 24 | mSize?.let { size = it } 25 | mOnClickListener?.let { setOnClickListener(it) } 26 | } 27 | } 28 | 29 | companion object { 30 | val titleSize = Utils.sp2px(5f) 31 | } 32 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 7 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 50 | 54 | 55 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 13 | 16 | 19 | 22 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.miui.home 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MIDock 3 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.32" 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath "com.android.tools.build:gradle:4.1.3" 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | 12 | // NOTE: Do not place your application dependencies here; they belong 13 | // in the individual module build.gradle files 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 07 11:05:20 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /screenshots/preview-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/screenshots/preview-1.jpg -------------------------------------------------------------------------------- /screenshots/preview-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lamprose/MIDock/4ee4bfe8dd323826befab42286b121b074ca7b31/screenshots/preview-2.jpg -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name = "MIDock" --------------------------------------------------------------------------------