更新了歌词组件支持更多操作

This commit is contained in:
muqing 2024-02-03 16:28:35 +08:00
parent 64e7336a71
commit 8a2bf60e93
7 changed files with 43 additions and 31 deletions

View File

@ -1,8 +1,6 @@
package com.muqingbfq.api; package com.muqingbfq.api;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment; import android.os.Environment;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -112,8 +110,7 @@ public class playlist extends Thread {
String id = value.getName(); String id = value.getName();
String name = mp3File.getTitle(); String name = mp3File.getTitle();
String zz = mp3File.getArtist(); String zz = mp3File.getArtist();
String picUrl = mp3File.getUrl(); list.add(new MP3(id, name, zz, value.toString()));
list.add(new MP3(id, name, zz, picUrl));
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
@ -175,11 +172,11 @@ public class playlist extends Thread {
e.printStackTrace(); e.printStackTrace();
} }
} else if (a.isDirectory()) { } else if (a.isDirectory()) {
/* String string = a.getName(); String string = a.getName();
if (string.startsWith(".") || string.equals("Android") || string.equals("data")) { if (string.startsWith(".") || string.equals("Android") || string.equals("data")) {
continue; continue;
} }
CD(a, list);*/ CD(a, list);
} }
} }
} }

View File

@ -11,6 +11,8 @@ import android.graphics.BitmapFactory;
import android.os.Bundle; import android.os.Bundle;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -37,7 +39,6 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
public class bfq extends AppCompatActivity<ActivityBfqBinding> { public class bfq extends AppCompatActivity<ActivityBfqBinding> {
public String lrc; public String lrc;
public MP3 mp3; public MP3 mp3;
public boolean isplay = true; public boolean isplay = true;
@ -52,7 +53,7 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
layoutParams.width = main.k - 100; layoutParams.width = main.k - 100;
binding.cardview.setLayoutParams(layoutParams); binding.cardview.setLayoutParams(layoutParams);
binding.cardview.setOnClickListener((view) -> { binding.fragmentBfq.setOnClickListener((view) -> {
if (binding.cardview.getVisibility() == View.VISIBLE) { if (binding.cardview.getVisibility() == View.VISIBLE) {
binding.cardview.setVisibility(View.GONE); binding.cardview.setVisibility(View.GONE);
binding.lrcView.setVisibility(View.VISIBLE); binding.lrcView.setVisibility(View.VISIBLE);
@ -61,7 +62,6 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
binding.lrcView.setVisibility(View.GONE); binding.lrcView.setVisibility(View.GONE);
} }
}); });
binding.lrcView.setOnTapListener((view, x, y) -> { binding.lrcView.setOnTapListener((view, x, y) -> {
if (binding.cardview.getVisibility() == View.VISIBLE) { if (binding.cardview.getVisibility() == View.VISIBLE) {
binding.cardview.setVisibility(View.GONE); binding.cardview.setVisibility(View.GONE);
@ -108,16 +108,8 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
protected void UI(@Nullable Bundle savedInstanceState) { protected void UI(@Nullable Bundle savedInstanceState) {
// getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); // getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
setLrc(); setLrc();
binding.toolbar.setNavigationOnClickListener(view1 -> finish()); setSupportActionBar(binding.toolbar);
binding.toolbar.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.fx && bfqkz.xm != null) {
com.muqingbfq.mq.gj.fx(this,
"音乐名称:" + bfqkz.xm.name +
"\n 作者:" + bfqkz.xm.zz +
"\n 链接https://music.163.com/#/song?id=" + bfqkz.xm.id);
}
return false;
});
binding.kg.setOnClickListener(v -> { binding.kg.setOnClickListener(v -> {
if (bfqkz.mt.isPlaying()) { if (bfqkz.mt.isPlaying()) {
bfqkz.mt.pause(); bfqkz.mt.pause();
@ -173,6 +165,24 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
new thread().start(); new thread().start();
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.bfq,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId()== R.id.fx && bfqkz.xm != null) {
com.muqingbfq.mq.gj.fx(this,
"音乐名称:" + bfqkz.xm.name +
"\n 作者:" + bfqkz.xm.zz +
"\n 链接https://music.163.com/#/song?id=" + bfqkz.xm.id);
} else if (item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
class thread extends Thread { class thread extends Thread {
@Override @Override
public void run() { public void run() {
@ -235,8 +245,6 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
protected ActivityBfqBinding getViewBindingObject(LayoutInflater layoutInflater) { protected ActivityBfqBinding getViewBindingObject(LayoutInflater layoutInflater) {
return ActivityBfqBinding.inflate(layoutInflater); return ActivityBfqBinding.inflate(layoutInflater);
} }
public class Touch implements View.OnTouchListener { public class Touch implements View.OnTouchListener {
private float downY; private float downY;

View File

@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
@ -21,7 +20,6 @@ import androidx.media.MediaBrowserServiceCompat;
import com.muqingbfq.api.url; import com.muqingbfq.api.url;
import com.muqingbfq.mq.BluetoothMusicController; import com.muqingbfq.mq.BluetoothMusicController;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -60,13 +58,13 @@ public class bfqkz extends MediaBrowserServiceCompat {
return; return;
} }
if (xm.picurl instanceof String) { if (xm.picurl instanceof String) {
if (TextUtils.isEmpty(xm.picurl.toString())) { if (TextUtils.isEmpty(xm.picurl)) {
xm.picurl = url.picurl(xm.id); xm.picurl = url.picurl(xm.id);
} }
} }
mt.setDataSource(mp3); mt.setDataSource(mp3);
} catch (Exception e) { } catch (Exception e) {
yc.start(home.appCompatActivity, "bfqkz mp3(" + mp3.toString() + ") :" + e); yc.start(home.appCompatActivity, "bfqkz mp3(" + mp3 + ") :" + e);
} }
} }

View File

@ -224,9 +224,10 @@ public class home extends com.muqingbfq.mq.AppCompatActivity<ActivityHomeBinding
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.home,menu); getMenuInflater().inflate(R.menu.home, menu);
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_search) { if (item.getItemId() == R.id.menu_search) {

View File

@ -12,7 +12,6 @@
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:menu="@menu/bfq"
app:navigationIcon="@drawable/end"> app:navigationIcon="@drawable/end">
<LinearLayout <LinearLayout
@ -64,6 +63,11 @@
android:id="@+id/lrcView" android:id="@+id/lrcView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
app:lrcTextSize="20sp"
app:lrcNormalTextSize="16sp"
app:lrcCurrentTextColor="@color/text"
app:lrcNormalTextColor="@color/text_tm"
app:lrcTimelineTextColor="@color/text"
app:layout_constraintStart_toEndOf="@id/cardview" app:layout_constraintStart_toEndOf="@id/cardview"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"

View File

@ -12,7 +12,6 @@
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:menu="@menu/bfq"
app:navigationIcon="@drawable/end"> app:navigationIcon="@drawable/end">
<LinearLayout <LinearLayout
@ -62,10 +61,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:visibility="gone" android:visibility="gone"
app:lrcTextSize="20sp"
app:lrcNormalTextSize="16sp"
app:lrcCurrentTextColor="@color/text"
app:lrcNormalTextColor="@color/text_tm"
app:lrcTimelineTextColor="@color/text"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout

View File

@ -33,8 +33,8 @@
<ImageView <ImageView
android:id="@+id/img_logo" android:id="@+id/img_logo"
android:layout_width="150dp" android:layout_width="wrap_content"
android:layout_height="150dp" android:layout_height="wrap_content"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:src="@drawable/icon" /> android:src="@drawable/icon" />