Skip to content

Commit

Permalink
修复退出播放界面后状态栏颜色不变的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wilinz committed Feb 2, 2023
1 parent 0aa81b1 commit c17b868
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.wilinz.yuetingmusic"
minSdk 21
targetSdk 33
versionCode 4
versionName "1.1.2"
versionCode 5
versionName "1.1.3"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:configChanges="uiMode"
android:launchMode="singleTask"
android:theme="@style/Theme.Yuetingmusic">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.wilinz.yuetingmusic.ui.player

import android.annotation.SuppressLint
import android.content.res.ColorStateList
import android.content.res.Configuration
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
Expand Down Expand Up @@ -277,6 +278,20 @@ class PlayerFragment : Fragment() {
}
}

override fun onDestroy() {
super.onDestroy()
val currentNightMode =
requireContext().resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
val window = requireActivity().window
when (currentNightMode) {
Configuration.UI_MODE_NIGHT_NO -> {
setStatusBarTint(window, true)
} // Night mode is not active, we're using the light theme
Configuration.UI_MODE_NIGHT_YES -> {
setStatusBarTint(window, false)
} // Night mode is active, we're using dark theme
}
}

companion object {
private const val TAG = "PlayerFragment"
Expand Down

0 comments on commit c17b868

Please sign in to comment.