Skip to content

Commit

Permalink
Set color when attachPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
YuKongA committed Aug 31, 2024
1 parent 9bb2091 commit 0031cc9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
25 changes: 20 additions & 5 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,29 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: MediaControl-Release-Snapshot
path: |
app/build/outputs/apk/release
path: app/build/outputs/apk/release
compression-level: 9

- name: Upload Debug Snapshot
uses: actions/upload-artifact@v4
with:
name: MediaControl-Debug-Snapshot
path: |
app/build/outputs/apk/debug
compression-level: 9
path: app/build/outputs/apk/debug
compression-level: 9

- name: Post to Telegram ci channel
if: ${{ success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag' }}
env:
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
export RELEASE=$(find "app/build/outputs/apk/release/" -name "*.apk")
export DEBUG=$(find "app/build/outputs/apk/debug/" -name "*.apk")
event_path=$GITHUB_EVENT_PATH
commit_count=$(jq -r '.commits | length' $event_path)
{ echo -e 'New CI from MediaControl-BlurBg\n'; git log -$commit_count --pretty=format:"%h %s"; } > ${{ github.workspace }}/git_log
ESCAPED="$(cat ${{ github.workspace }}/git_log | gawk '{gsub(/[_*[\]()~`>#+=\|{}.!-]/,"\\\\\\\\&")}1' | sed -e 's|"|\\"|g' -e 's|^[0-9a-z]\+|__&__|' | hexdump -v -e '/1 "%02X"' | sed 's/\(..\)/%\1/g')"
cd ${{ github.workspace }}
curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Frelease%22%7D%2C%7B%22type%22%3A%22document%22%2C%22media%22%3A%22attach%3A%2F%2Fdebug%22%2C%22caption%22%3A%22${ESCAPED}%22%2C%22parse_mode%22%3A%22MarkdownV2%22%7D%5D" -F release="@$RELEASE" -F debug="@$DEBUG"
fi
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = namespace
minSdk = 34
targetSdk = 35
versionCode = 2520
versionName = "2.5.2"
versionCode = 2530
versionName = "2.5.3"
}
val properties = Properties()
runCatching { properties.load(project.rootProject.file("local.properties").inputStream()) }
Expand Down
37 changes: 37 additions & 0 deletions app/src/main/kotlin/top/yukonga/mediaControlBlur/MainHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MainHook : IXposedHookLoadPackage {
var lockScreenStatus: Boolean? = null
var darkModeStatus: Boolean? = null

val mediaControlPanel = loadClassOrNull("com.android.systemui.media.controls.ui.MediaControlPanel")
val miuiMediaControlPanel = loadClassOrNull("com.android.systemui.statusbar.notification.mediacontrol.MiuiMediaControlPanel")
val notificationUtil = loadClassOrNull("com.android.systemui.statusbar.notification.NotificationUtil")
val playerTwoCircleView = loadClassOrNull("com.android.systemui.statusbar.notification.mediacontrol.PlayerTwoCircleView")
Expand Down Expand Up @@ -122,6 +123,42 @@ class MainHook : IXposedHookLoadPackage {
}
}

mediaControlPanel?.methodFinder()?.filterByName("attachPlayer")?.first()?.createAfterHook {
val context = it.thisObject.objectHelper().getObjectOrNullUntilSuperclassAs<Context>("mContext") ?: return@createAfterHook

val isBackgroundBlurOpened = XposedHelpers.callStaticMethod(notificationUtil, "isBackgroundBlurOpened", context) as Boolean

val mMediaViewHolder = it.args[0]

val titleText = mMediaViewHolder.objectHelper().getObjectOrNullAs<TextView>("titleText")
val artistText = mMediaViewHolder.objectHelper().getObjectOrNullAs<TextView>("artistText")
val seamlessIcon = mMediaViewHolder.objectHelper().getObjectOrNullAs<ImageView>("seamlessIcon")
val seekBar = mMediaViewHolder.objectHelper().getObjectOrNullAs<SeekBar>("seekBar")
val elapsedTimeView = mMediaViewHolder.objectHelper().getObjectOrNullAs<TextView>("elapsedTimeView")
val totalTimeView = mMediaViewHolder.objectHelper().getObjectOrNullAs<TextView>("totalTimeView")
val appIcon = mMediaViewHolder.objectHelper().getObjectOrNullAs<ImageView>("appIcon")

val grey = if (isDarkMode(context)) Color.LTGRAY else Color.DKGRAY
val color = if (isDarkMode(context)) Color.WHITE else Color.BLACK
seekBar?.thumb?.colorFilter = colorFilter(Color.TRANSPARENT)
elapsedTimeView?.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11f)
totalTimeView?.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11f)
(appIcon?.parent as ViewGroup?)?.removeView(appIcon)
if (!isBackgroundBlurOpened) {
titleText?.setTextColor(Color.WHITE)
seamlessIcon?.setColorFilter(Color.WHITE)
seekBar?.progressDrawable?.colorFilter = colorFilter(Color.WHITE)
} else {
artistText?.setTextColor(grey)
elapsedTimeView?.setTextColor(grey)
totalTimeView?.setTextColor(grey)
titleText?.setTextColor(grey)
titleText?.setTextColor(color)
seamlessIcon?.setColorFilter(color)
seekBar?.progressDrawable?.colorFilter = colorFilter(color)
}
}

miuiMediaControlPanel?.methodFinder()?.filterByName("bindPlayer")?.first()?.createAfterHook {
val context = it.thisObject.objectHelper().getObjectOrNullUntilSuperclassAs<Context>("mContext") ?: return@createAfterHook

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.5.2"
agp = "8.6.0"
ezXHelper = "2.2.0"
kotlin = "2.0.20"
xposed = "82"
Expand Down

0 comments on commit 0031cc9

Please sign in to comment.