diff --git a/app/build.gradle b/app/build.gradle
index cba597e..1967b13 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -36,7 +36,6 @@ dependencies {
implementation 'com.alibaba:fastjson:1.1.72.android'
//noinspection GradleCompatible
implementation 'com.android.support:support-media-compat:28.0.0'
-
-
+ implementation 'androidx.palette:palette:1.0.0'
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3760c8e..f90c0a6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -19,8 +19,12 @@
-
-
+
+
diff --git a/app/src/main/java/com/yutou/nas_music_player/containers/MusicData.java b/app/src/main/java/com/yutou/nas_music_player/containers/MusicData.java
index e7c3c58..7dc8beb 100644
--- a/app/src/main/java/com/yutou/nas_music_player/containers/MusicData.java
+++ b/app/src/main/java/com/yutou/nas_music_player/containers/MusicData.java
@@ -3,6 +3,7 @@ package com.yutou.nas_music_player.containers;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.graphics.Color;
import android.util.Base64;
import com.alibaba.fastjson.JSONObject;
@@ -10,6 +11,8 @@ import com.yutou.nas_music_player.Interfaces.NetworkInterface;
import com.yutou.nas_music_player.tools.NetworkTool;
import com.yutou.nas_music_player.tools.StringUtil;
+import androidx.palette.graphics.Palette;
+
public class MusicData {
private String artist;//艺术家
private String album;//专辑
@@ -172,4 +175,10 @@ public class MusicData {
});
return img;
}
+ public int getImageColor(){
+ if(img==null){
+ return -1;
+ }
+ return Palette.from(img).generate().getLightVibrantColor(Color.parseColor("#6DE1A1"));
+ }
}
diff --git a/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java b/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java
index 2b53ebc..899323d 100644
--- a/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java
+++ b/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java
@@ -2,12 +2,14 @@ package com.yutou.nas_music_player.views;
import androidx.appcompat.app.AppCompatActivity;
+import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaControllerCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.view.View;
+import android.view.Window;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.MediaController;
@@ -15,6 +17,7 @@ import android.widget.MediaController;
import com.yutou.nas_music_player.R;
import com.yutou.nas_music_player.containers.MediaBrowserHelper;
import com.yutou.nas_music_player.containers.MusicContainer;
+import com.yutou.nas_music_player.containers.MusicData;
import java.util.List;
@@ -26,6 +29,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ setBarColor(android.R.color.transparent);
setContentView(R.layout.activity_main);
MusicContainer.getInstance();
play = findViewById(R.id.play);
@@ -47,13 +51,20 @@ public class MainActivity extends AppCompatActivity {
previous.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
-
+ MusicData data=MusicContainer.getInstance().getNowPlayData();
+ if(data!=null){
+ setBarColor(data.getImageColor());
+ }
}
});
browserHelper = new MediaBrowserHelper(this);
browserHelper.regPlayListener(new PlayListener());
}
+ public void setBarColor(int color){
+ getWindow().setStatusBarColor(color);
+ getWindow().setNavigationBarColor(color);
+ }
private class PlayListener extends MediaControllerCompat.Callback {
@Override
@@ -78,5 +89,8 @@ public class MainActivity extends AppCompatActivity {
public void onQueueChanged(List queue) {
super.onQueueChanged(queue);
}
+ public void setImage(){
+
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index d623804..ab0bcb5 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -9,7 +9,8 @@
@@ -21,68 +22,141 @@
android:scaleType="fitXY"
android:src="@drawable/ic_launcher_background" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 4faecfa..f6f7ea4 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -3,4 +3,9 @@
#6200EE
#3700B3
#03DAC5
+ #000000
+
+ #000000
+ #000000
+ #DEDEDE
\ No newline at end of file