Skip to content

Commit

Permalink
AlbumArtLockscreen: use only playback state to show album art
Browse files Browse the repository at this point in the history
Signed-off-by: DHD2280 <[email protected]>
  • Loading branch information
DHD2280 committed Nov 22, 2024
1 parent b8d5f7e commit db173c4
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {

albumArtContainer = new FrameLayout(mContext);
albumArtContainer.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
albumArtContainer.setVisibility(View.GONE);
albumArtView = new ImageView(mContext);
albumArtView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
albumArtView.setScaleType(ImageView.ScaleType.CENTER_CROP);
albumArtView.setVisibility(View.GONE);
albumArtView.setVisibility(View.VISIBLE);
albumArtContainer.addView(albumArtView);

rootView.addView(albumArtContainer, 3);
Expand Down Expand Up @@ -126,22 +127,17 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
private void updateAlbumArt() {
if (showAlbumArt && shouldShowArt && canShowArt) {
// Keyguard so we can show album art
albumArtView.post(() -> albumArtView.setVisibility(View.VISIBLE));
albumArtContainer.post(() -> albumArtContainer.setVisibility(View.VISIBLE));
} else {
// Not Keyguard so we must hide album art
albumArtView.post(() -> albumArtView.setVisibility(View.GONE));
albumArtContainer.post(() -> albumArtContainer.setVisibility(View.GONE));
}
}

private void onPrimaryMetadataOrStateChanged(int state) {
boolean isMusicActive = false;
if (SystemUtils.AudioManager() != null) {
isMusicActive = SystemUtils.AudioManager().isMusicActive();
}
canShowArt = (getMediaMetadata() != null &&
(isMusicActive ||
state == PlaybackState.STATE_PLAYING ||
state == PlaybackState.STATE_PAUSED) && getArt() != null);
(state == PlaybackState.STATE_PLAYING ||
state == PlaybackState.STATE_BUFFERING) && getArt() != null);
if (showAlbumArt && canShowArt) {
Bitmap oldArt = mArt;
mArt = getArtFilter(getArt());
Expand All @@ -153,7 +149,6 @@ private void onPrimaryMetadataOrStateChanged(int state) {
transitionDrawable.startTransition(250);
} else {
albumArtView.setImageBitmap(null);
albumArtView.post(() -> albumArtView.setVisibility(View.GONE));
}
updateAlbumArt();
}
Expand Down

0 comments on commit db173c4

Please sign in to comment.