diff --git a/.idea/misc.xml b/.idea/misc.xml index 736cd08..2370002 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,10 +1,11 @@ + diff --git a/app/build.gradle b/app/build.gradle index c43637a..de009e4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,7 +18,7 @@ android { //noinspection OldTargetApi targetSdk 31 versionCode 1 - versionName "1.7.1" + versionName "1.7.5" } compileOptions { diff --git a/app/debug/output-metadata.json b/app/debug/output-metadata.json index 1318b62..38f64a4 100644 --- a/app/debug/output-metadata.json +++ b/app/debug/output-metadata.json @@ -12,8 +12,8 @@ "filters": [], "attributes": [], "versionCode": 1, - "versionName": "1.7.1", - "outputFile": "Cloud_music-debug-v1.7.1.apk" + "versionName": "1.7.5", + "outputFile": "Cloud_music-debug-v1.7.5.apk" } ], "elementType": "File" diff --git a/app/src/main/java/com/muqingbfq/MediaPlayer.java b/app/src/main/java/com/muqingbfq/MediaPlayer.java index ec4d92d..f0b1247 100644 --- a/app/src/main/java/com/muqingbfq/MediaPlayer.java +++ b/app/src/main/java/com/muqingbfq/MediaPlayer.java @@ -29,7 +29,7 @@ public class MediaPlayer { public Runnable updateSeekBar = new Runnable() { @Override public void run() { - if (build != null && build.isPlaying() && Media.getlrcView() != null) { + if (build != null && build.isPlaying() && Media.lrcview != null) { long position = build.getCurrentPosition(); Media.setProgress((int) position); } @@ -169,9 +169,7 @@ public class MediaPlayer { Media.setzz(zz); bfq_an.islike(); } - bfq_db.setname(name); - bfq_db.setzz(zz); - + bfq_db.setname(name+"/"+zz); if (com.muqingbfq.fragment.mp3.lbspq != null) { com.muqingbfq.fragment.mp3.lbspq.notifyDataSetChanged(); } diff --git a/app/src/main/java/com/muqingbfq/activity_search.java b/app/src/main/java/com/muqingbfq/activity_search.java index dfab609..997944d 100644 --- a/app/src/main/java/com/muqingbfq/activity_search.java +++ b/app/src/main/java/com/muqingbfq/activity_search.java @@ -26,7 +26,7 @@ import com.google.android.flexbox.FlexboxLayoutManager; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.muqingbfq.databinding.ActivitySearchBinding; import com.muqingbfq.fragment.search; -import com.muqingbfq.mq.ActivityToolbar; +import com.muqingbfq.mq.FragmentActivity; import com.muqingbfq.mq.gj; import com.muqingbfq.mq.wj; import com.muqingbfq.mq.wl; @@ -38,7 +38,7 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.List; -public class activity_search extends ActivityToolbar { +public class activity_search extends FragmentActivity { private EditText editText; private ArrayAdapter adapter; private SearchRecordAdapter recordAdapter; diff --git a/app/src/main/java/com/muqingbfq/api/FileDownloader.java b/app/src/main/java/com/muqingbfq/api/FileDownloader.java new file mode 100644 index 0000000..83154e6 --- /dev/null +++ b/app/src/main/java/com/muqingbfq/api/FileDownloader.java @@ -0,0 +1,151 @@ +package com.muqingbfq.api; + +import android.Manifest; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.content.Context; +import android.content.pm.PackageManager; +import android.graphics.Color; +import android.os.Build; +import android.os.Environment; + +import androidx.core.app.ActivityCompat; +import androidx.core.app.NotificationCompat; +import androidx.core.app.NotificationManagerCompat; + +import com.mpatric.mp3agic.ID3v2; +import com.mpatric.mp3agic.InvalidDataException; +import com.mpatric.mp3agic.Mp3File; +import com.mpatric.mp3agic.UnsupportedTagException; +import com.muqingbfq.R; +import com.muqingbfq.mq.gj; +import com.muqingbfq.mq.wj; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +public class FileDownloader { + private static final String CHANNEL_ID = "download_channel"; + private static final int NOTIFICATION_ID = 3; + + public static void downloadFile(Context context, String url,com.muqingbfq.xm x) { + OkHttpClient client = new OkHttpClient(); + Request request = new Request.Builder() + .url(url) + .build(); + // 创建通知渠道(仅适用于Android 8.0及以上版本) + createNotificationChannel(context); + // 发起请求 + client.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + e.printStackTrace(); + // 下载失败处理 + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + if (!response.isSuccessful()) { + // 下载失败处理 + return; + } + + File outputFile = new File(wj.mp3, "nihao"); + File parentFile = outputFile.getParentFile(); + if (!parentFile.isDirectory()) { + parentFile.mkdirs(); + } + InputStream inputStream = null; + FileOutputStream outputStream = null; + try { + byte[] buffer = new byte[4096]; + long fileSize = response.body().contentLength(); + long fileSizeDownloaded = 0; + + inputStream = response.body().byteStream(); + outputStream = new FileOutputStream(outputFile); + + int read; + while ((read = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, read); + fileSizeDownloaded += read; + // 更新通知栏进度 + updateNotificationProgress(context, fileSize, fileSizeDownloaded); + } + try { + Mp3File mp3file = new Mp3File(outputFile); + if (mp3file.hasId3v2Tag()) { + ID3v2 id3v2Tag = mp3file.getId3v2Tag(); + // 设置新的ID值 + id3v2Tag.setTitle(x.name); + id3v2Tag.setArtist(x.zz); + id3v2Tag.setAlbum(x.zz); + id3v2Tag.setUrl(x.picurl.toString()); + mp3file.save(wj.mp3 + x.id); + outputFile.delete(); + } + // 保存修改后的音乐文件,删除原来的文件 + } catch (Exception e) { + gj.sc(e); + } + // 下载完成处理 + } catch (IOException e) { + e.printStackTrace(); + // 下载失败处理 + } finally { + if (inputStream != null) { + inputStream.close(); + } + if (outputStream != null) { + outputStream.close(); + } + NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); + notificationManager.cancel(NOTIFICATION_ID); + } + } + }); + } + + private static void createNotificationChannel(Context context) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + CharSequence name = "Download Channel"; + String description = "Channel for file download"; + int importance = NotificationManager.IMPORTANCE_LOW; + + NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance); + channel.setDescription(description); + channel.setShowBadge(false); + channel.enableLights(true); + channel.setLightColor(Color.BLUE); + + NotificationManager notificationManager = context.getSystemService(NotificationManager.class); + notificationManager.createNotificationChannel(channel); + } + } + + private static void updateNotificationProgress(Context context, long fileSize, + long fileSizeDownloaded) { + int progress = (int) ((fileSizeDownloaded * 100) / fileSize); + + NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID) + .setSmallIcon(R.drawable.icon) + .setContentTitle("Downloading File") + .setContentText(progress + "% downloaded") + .setProgress(100, progress, false) + .setOngoing(true) + .setOnlyAlertOnce(true); + NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); + if (ActivityCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + return; + } + notificationManager.notify(NOTIFICATION_ID, builder.build()); + } +} diff --git a/app/src/main/java/com/muqingbfq/api/playlist.java b/app/src/main/java/com/muqingbfq/api/playlist.java index 7ff9cfd..72dd180 100644 --- a/app/src/main/java/com/muqingbfq/api/playlist.java +++ b/app/src/main/java/com/muqingbfq/api/playlist.java @@ -27,6 +27,8 @@ public class playlist extends Thread { return playlist.hq_xz(list); } else if (uid.equals("mp3_like.json")) { return playlist.hq_like(list); + } else if (uid.equals("mp3_hc.json")) { + return hq_hc(list); } list.clear(); try { @@ -105,4 +107,24 @@ public class playlist extends Thread { } return false; } + public static boolean hq_hc(List list) { + list.clear(); + try { + File file = new File(wj.filesdri + "hc"); + File[] files = file.listFiles(); + for (int i = 0; i < files.length; i++) { + ID3v2 mp3File = new Mp3File(files[i]).getId3v2Tag(); + String id = files[i].getName(); + String name = mp3File.getTitle(); + String zz = mp3File.getArtist(); + String picUrl = mp3File.getUrl(); + list.add(new xm(id, name, zz, picUrl)); + } + return true; + } catch (Exception e) { + gj.sc("失败的错误 " + e); + wj.sc(wj.mp3_xz); + } + return false; + } } diff --git a/app/src/main/java/com/muqingbfq/api/resource.java b/app/src/main/java/com/muqingbfq/api/resource.java index 47d2ef3..b0c03ee 100644 --- a/app/src/main/java/com/muqingbfq/api/resource.java +++ b/app/src/main/java/com/muqingbfq/api/resource.java @@ -3,8 +3,6 @@ package com.muqingbfq.api; import android.text.TextUtils; import com.muqingbfq.R; -import com.muqingbfq.main; -import com.muqingbfq.start; import com.muqingbfq.mq.gj; import com.muqingbfq.mq.wj; import com.muqingbfq.mq.wl; @@ -77,9 +75,9 @@ public class resource { } public static void 下载(List list) { -// list.add(new xm("hc.json", "缓存", R.drawable.icon, true)); list.add(new xm("mp3_like.json", "喜欢", R.mipmap.like, true)); list.add(new xm("mp3_xz.json", "下载", R.drawable.icon, true)); + list.add(new xm("mp3_hc.json", "缓存", R.drawable.icon, true)); try { JSONObject date = new JSONObject(wj.dqwb(wj.gd_xz)); for (Iterator it = date.keys(); it.hasNext(); ) { diff --git a/app/src/main/java/com/muqingbfq/api/url.java b/app/src/main/java/com/muqingbfq/api/url.java index 8885e9c..30ad91c 100644 --- a/app/src/main/java/com/muqingbfq/api/url.java +++ b/app/src/main/java/com/muqingbfq/api/url.java @@ -1,5 +1,7 @@ package com.muqingbfq.api; +import com.mpatric.mp3agic.ID3v2; +import com.mpatric.mp3agic.Mp3File; import com.muqingbfq.fragment.Media; import com.muqingbfq.mq.gj; import com.muqingbfq.mq.wj; @@ -11,6 +13,16 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; + +import okhttp3.Call; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + public class url extends Thread { public static String api = "/song/url/v1"; xm x; @@ -21,12 +33,12 @@ public class url extends Thread { } public static String hq(xm x) { - if (Media.getlrcView() != null) { + if (Media.lrcview != null) { gc(x.id); } try { - if (wj.cz(wj.mp3 + x.id)) { - return wj.mp3 ; + if (wj.cz(wj.filesdri + "hc/" + x.id)) { + return wj.filesdri + "hc/" + x.id; } String level = "standard"; boolean wiFiConnected = gj.isWiFiConnected(); @@ -43,7 +55,65 @@ public class url extends Thread { JSONObject jsonObject = data.getJSONObject(0); String url = jsonObject.getString("url"); if (wiFiConnected) { - new wl.xz(url, x); + new Thread() { + @Override + public void run() { + super.run(); + try { + if (new File(wj.filesdri + "hc").isDirectory()) { + File[] aa = new File(wj.filesdri + "hc").listFiles(); + if (aa.length >= 30) { + aa[0].delete(); + } + } + OkHttpClient client = new OkHttpClient(); + Request request = new Request.Builder() + //访问路径 + .url(url) + .build(); + Call call = client.newCall(request); + Response response = call.execute(); + if (response.isSuccessful()) { + ResponseBody body = response.body(); + if (body != null) { + File file = new File(wj.filesdri + "hc", x.id + ".mp3"); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + File parentFile = file.getParentFile(); + if (!parentFile.isDirectory()) { + parentFile.mkdirs(); + } + InputStream inputStream = body.byteStream(); + FileOutputStream fileOutputStream = + new FileOutputStream(file); + // 替换为实际要保存的文件路径 + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + fileOutputStream.write(buffer, 0, bytesRead); + } + fileOutputStream.close(); + inputStream.close(); + Mp3File mp3file = new Mp3File(file); + if (mp3file.hasId3v2Tag()) { + ID3v2 id3v2Tag = mp3file.getId3v2Tag(); + // 设置新的ID值 + id3v2Tag.setTitle(x.name); + id3v2Tag.setArtist(x.zz); + id3v2Tag.setAlbum(x.zz); + id3v2Tag.setUrl(x.picurl.toString()); + mp3file.save(wj.filesdri + "hc/" + x.id); + file.delete(); + // 保存修改后的音乐文件,删除原来的文件 + } + } + } + } catch (Exception e) { + gj.sc("wl xz " + e); + } + } + }.start(); } return url; } catch (JSONException e) { @@ -61,12 +131,11 @@ public class url extends Thread { public static void gc(String id) { String lrc = null, tlyric = null; - JSONObject jsonObject; try { - jsonObject = new JSONObject(wl.hq("/lyric?id=" + id)); + JSONObject jsonObject = new JSONObject(wl.hq("/lyric?id=" + id)); lrc = jsonObject.getJSONObject("lrc").getString("lyric"); tlyric = jsonObject.getJSONObject("tlyric").getString("lyric"); - } catch (JSONException e) { + } catch (Exception e) { gj.sc("url gc(int id) lrc: " + e); } Media.loadLyric(lrc, tlyric); diff --git a/app/src/main/java/com/muqingbfq/bfq.java b/app/src/main/java/com/muqingbfq/bfq.java index 6474d48..c79f49e 100644 --- a/app/src/main/java/com/muqingbfq/bfq.java +++ b/app/src/main/java/com/muqingbfq/bfq.java @@ -12,7 +12,6 @@ import android.os.Bundle; import android.util.TypedValue; import android.view.MotionEvent; import android.view.WindowManager; -import android.widget.ImageView; import android.widget.LinearLayout; import androidx.annotation.NonNull; @@ -21,9 +20,16 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; +import com.muqingbfq.api.FileDownloader; +import com.muqingbfq.api.url; import com.muqingbfq.databinding.ActivityBfqBinding; import com.muqingbfq.fragment.Media; +import com.muqingbfq.mq.gj; +import com.muqingbfq.mq.wj; +import com.muqingbfq.mq.wl; +import org.json.JSONArray; +import org.json.JSONException; import org.json.JSONObject; public class bfq extends AppCompatActivity { @@ -95,8 +101,37 @@ public class bfq extends AppCompatActivity { Media.setzz(bfqkz.xm.zz); bfq_an.islike(); } + inflate.download.setOnClickListener(view -> { + if (wj.cz(wj.mp3 + bfqkz.xm.id)) { + gj.ts(this, "你已经下载过这首歌曲了"); + return; + } + if (bfqkz.xm != null) { + new Thread(){ + @Override + public void run() { + super.run(); + xm x = bfqkz.xm; + String hq = wl.hq(url.api + "?id=" + x.id + "&level=exhigh" + "&cookie=" + wl.Cookie); + if (hq == null) { + return; + } + try { + JSONObject json = new JSONObject(hq); + JSONArray data = json.getJSONArray("data"); + JSONObject jsonObject = data.getJSONObject(0); + String url = jsonObject.getString("url"); + FileDownloader.downloadFile(bfq.this, url, bfqkz.xm); + } catch (JSONException e) { + throw new RuntimeException(e); + } + } + }.start(); + } + }); } + public static Bitmap bitmap; public static void start(Context context) { diff --git a/app/src/main/java/com/muqingbfq/clean/fragment_clean.java b/app/src/main/java/com/muqingbfq/clean/fragment_clean.java index 5a66d21..6fd0564 100644 --- a/app/src/main/java/com/muqingbfq/clean/fragment_clean.java +++ b/app/src/main/java/com/muqingbfq/clean/fragment_clean.java @@ -1,12 +1,14 @@ package com.muqingbfq.clean; +import android.annotation.SuppressLint; import android.os.Bundle; import android.text.format.Formatter; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; -import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -14,7 +16,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.muqingbfq.R; import com.muqingbfq.databinding.CleanBinding; -import com.muqingbfq.mq.ActivityToolbar; +import com.muqingbfq.mq.FragmentActivity; import com.muqingbfq.mq.gj; import com.muqingbfq.mq.wj; @@ -22,16 +24,24 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -public class fragment_clean extends ActivityToolbar { +public class fragment_clean extends FragmentActivity { List list = new ArrayList<>(); + List list_box = new ArrayList<>(); + CleanBinding binding; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - list.add(new String[]{"音乐", wj.mp3}); - list.add(new String[]{"歌单",wj.gd}); - CleanBinding binding = CleanBinding.inflate(getLayoutInflater()); - binding.toolbar.setTitle("储存清理"); + binding = CleanBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); + UI(); + } + + private void UI() { + list.clear(); + list.add(new String[]{"下载的音乐", wj.mp3}); + list.add(new String[]{"下载的歌单",wj.gd}); + list.add(new String[]{"缓存的音乐",wj.filesdri+"hc"}); + binding.toolbar.setTitle("储存清理"); binding.recyclerview.setAdapter(adapter); } @@ -44,19 +54,79 @@ public class fragment_clean extends ActivityToolbar { return new VH(inflate); } + @SuppressLint("ClickableViewAccessibility") @Override public void onBindViewHolder(@NonNull VH holder, int position) { String[] s = list.get(position); File file = new File(s[1]); long leng = 0; + int size = 0; if (file.isDirectory()) { gj.sc(file.toString()); for (File a : file.listFiles()) { leng += a.length(); + size++; } + } else { + holder.checkBox.setEnabled(false); } + +/* GestureDetector gestureDetector=new GestureDetector(fragment_clean.this, + new GestureDetector.OnGestureListener() { + @Override + public boolean onDown(@NonNull MotionEvent motionEvent) { + return true; + } + + @Override + public void onShowPress(@NonNull MotionEvent motionEvent) { + + } + + @Override + public boolean onSingleTapUp(@NonNull MotionEvent motionEvent) { + return false; + } + + @Override + public boolean onScroll(@Nullable MotionEvent motionEvent, @NonNull MotionEvent motionEvent1, float v, float v1) { + return false; + } + + @Override + public void onLongPress(@NonNull MotionEvent motionEvent) { + + } + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { + // 计算水平方向滑动的距离 + float deltaX = e2.getX() - e1.getX(); + holder.checkBox.setX(deltaX); + // 判断是否是从左向右滑动,并且滑动距离超过一定阈值 + if (deltaX > 0 && Math.abs(deltaX) > 100) { + // 执行删除操作 + gj.sc("sc"); + return true; + } + return true; + } + });*/ String s1 = Formatter.formatFileSize(fragment_clean.this, leng); - holder.checkBox.setText(s[0] + ":" + s1); + holder.checkBox.setText(s[0] + ":" + s1 + " 共计:" + size+" 个文件"); +/* holder.checkBox.setOnTouchListener((view, motionEvent) -> + gestureDetector.onTouchEvent(motionEvent));*/ + holder.checkBox.setOnCheckedChangeListener((compoundButton, b) -> { + if (b) { + list_box.add(file.toString()); + }else { + list_box.remove(file.toString()); + } + if (list_box.size() > 0) { + menu_deleat.setVisible(true); + } else { + menu_deleat.setVisible(false); + } + }); } @Override @@ -72,4 +142,31 @@ public class fragment_clean extends ActivityToolbar { checkBox = itemView.findViewById(R.id.box); } } + + MenuItem menu_deleat; + @Override + public boolean onCreateOptionsMenu(Menu menu) { + menu_deleat = menu.add("删除"); + menu_deleat.setIcon(R.drawable.deleat); + menu_deleat.setTitle("删除"); + menu_deleat.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + menu_deleat.setVisible(false); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + finish(); + } else if (item == menu_deleat) { + for (int i = 0; i < list_box.size(); i++) { + File s= new File(list_box.get(i)); + wj.sc(s); + } + list_box.clear(); + menu_deleat.setVisible(false); + UI(); + } + return super.onOptionsItemSelected(item); + } } diff --git a/app/src/main/java/com/muqingbfq/fragment/Media.java b/app/src/main/java/com/muqingbfq/fragment/Media.java index c1d8ccc..34e71bf 100644 --- a/app/src/main/java/com/muqingbfq/fragment/Media.java +++ b/app/src/main/java/com/muqingbfq/fragment/Media.java @@ -44,7 +44,7 @@ public class Media extends Fragment { private static TextView time_a, time_b; @SuppressLint("StaticFieldLeak") private static SeekBar tdt; - private static LrcView lrcview; + public static LrcView lrcview; public static void setTime_a(String str) { if (time_a == null) { @@ -94,6 +94,10 @@ public class Media extends Fragment { view = inflate.getRoot(); inflate.cardview.addView(home.imageView); + LinearLayout.LayoutParams layoutParams = + new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT,2); + inflate.linearlayout.addView(lrcview,layoutParams); tdt = inflate.tdt; tdt.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override @@ -118,7 +122,6 @@ public class Media extends Fragment { time_a = inflate.timeA; time_b = inflate.timeB; //初始化歌词组件 - lrcview = getlrcView(); lrcview.setDraggable(true, (view, time) -> { bfqkz.mt.build.seekTo(Math.toIntExact(time)); return false; @@ -160,14 +163,10 @@ public class Media extends Fragment { Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; } - public static LrcView getlrcView() { - if (view == null) { - return null; - } - return view.findViewById(R.id.gc); - } - public static void loadLyric(String a, String b) { + if (lrcview == null || a == null) { + return; + } lrcview.loadLrc(a, b); } diff --git a/app/src/main/java/com/muqingbfq/fragment/bflb_db.java b/app/src/main/java/com/muqingbfq/fragment/bflb_db.java index e397417..e26e99f 100644 --- a/app/src/main/java/com/muqingbfq/fragment/bflb_db.java +++ b/app/src/main/java/com/muqingbfq/fragment/bflb_db.java @@ -20,7 +20,6 @@ import com.muqingbfq.xm; import com.muqingbfq.yc; public class bflb_db extends BottomSheetDialog { - public static String gdid; public static RecyclerView.Adapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/com/muqingbfq/fragment/bfq_db.java b/app/src/main/java/com/muqingbfq/fragment/bfq_db.java index aa564d3..cdc6f12 100644 --- a/app/src/main/java/com/muqingbfq/fragment/bfq_db.java +++ b/app/src/main/java/com/muqingbfq/fragment/bfq_db.java @@ -18,6 +18,7 @@ import com.muqingbfq.bfq; import com.muqingbfq.bfq_an; import com.muqingbfq.bfqkz; import com.muqingbfq.home; +import com.muqingbfq.mq.wj; import com.muqingbfq.xm; import java.lang.reflect.Type; @@ -25,7 +26,8 @@ import java.util.List; public class bfq_db extends Fragment { @SuppressLint("StaticFieldLeak") - private static View view; + public static View view; + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -35,25 +37,26 @@ public class bfq_db extends Fragment { if (jsonList != null) { Type type = new TypeToken>() { }.getType(); - bfqkz.list = new com.google.gson.Gson().fromJson(jsonList, type); // 将 JSON 字符串转换回列表数据 + bfqkz.list = new com.google.gson.Gson().fromJson(jsonList, type); + // 将 JSON 字符串转换回列表数据 } } view = inflater.inflate(R.layout.fragment_bfq_db, container, false); + TextView name = view.findViewById(R.id.name); - TextView zz = view.findViewById(R.id.zz); view.findViewById(R.id.kg).setOnClickListener(new bfq_an.kz()); view.findViewById(R.id.txb).setOnClickListener(view -> bflb_db.start(getContext())); view.setOnClickListener(vw -> bfq.start(home.appCompatActivity)); // 恢复列表数据 if (bfqkz.xm != null) { - name.setText(bfqkz.xm.name); - zz.setText(bfqkz.xm.zz); + name.setText(bfqkz.xm.name + "/" + bfqkz.xm.zz); } if (bfqkz.mt != null) { Media.setbf(bfqkz.mt.isPlaying()); } return view; } + private static T findViewById(int id) { return view.findViewById(id); } @@ -75,11 +78,4 @@ public class bfq_db extends Fragment { textView.setText(str); } } - - public static void setzz(String str) { - if (view != null) { - TextView textView = findViewById(R.id.zz); - textView.setText(str); - } - } } \ No newline at end of file diff --git a/app/src/main/java/com/muqingbfq/fragment/gd.java b/app/src/main/java/com/muqingbfq/fragment/gd.java index 675db3d..68c4643 100644 --- a/app/src/main/java/com/muqingbfq/fragment/gd.java +++ b/app/src/main/java/com/muqingbfq/fragment/gd.java @@ -2,8 +2,10 @@ package com.muqingbfq.fragment; import android.annotation.SuppressLint; import android.content.Context; +import android.graphics.Color; import android.graphics.drawable.Drawable; import android.os.Bundle; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,65 +15,94 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import androidx.viewpager2.adapter.FragmentStateAdapter; +import androidx.viewpager2.widget.ViewPager2; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; import com.google.android.material.card.MaterialCardView; -import com.google.android.material.tabs.TabLayout; import com.muqingbfq.R; import com.muqingbfq.api.playlist; import com.muqingbfq.api.resource; import com.muqingbfq.bfq_an; import com.muqingbfq.bfqkz; +import com.muqingbfq.databinding.FragmentGdBinding; import com.muqingbfq.list.list_gd; import com.muqingbfq.main; +import com.muqingbfq.mq.gj; import com.muqingbfq.mq.wj; import com.muqingbfq.xm; import org.json.JSONException; import org.json.JSONObject; -import java.util.ArrayList; import java.util.List; +import java.util.Objects; public class gd extends Fragment { public static String gdid; - public static RecyclerView.Adapter lbspq; - public List list = new ArrayList<>(); public static JSONObject like = new JSONObject(); - RecyclerView gridView; + FragmentGdBinding binding; + @Override + public void onResume() { + super.onResume(); + getActivity().getSupportFragmentManager().beginTransaction() + .replace(R.id.bfq_db, new bfq_db()) + .commit(); + } + @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_gd, container, false); - lbspq = new baseadapter(view.getContext(),list); - gridView = view.findViewById(R.id.wgbj); - int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f); - GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), k / 120); - gridView.setLayoutManager(gridLayoutManager); - gridView.setAdapter(lbspq); - TabLayout tabLayout = view.findViewById(R.id.tablayout); - for (String name : new String[]{"推荐", "排行榜", "下载"}) { - TabLayout.Tab tab = tabLayout.newTab(); - tab.setText(name); - tabLayout.addTab(tab); - } - new thread("推荐"); - tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { + binding = FragmentGdBinding.inflate(inflater, container, false); + binding.viewPager.setAdapter(new FragmentStateAdapter(getActivity()) { + @NonNull @Override - public void onTabSelected(TabLayout.Tab tab) { - new thread(tab.getText().toString()); + public Fragment createFragment(int position) { + switch (position) { + case 0: + return new gd_adapter(); + case 1: + return new gd_adapter.paihangbang(); + case 2: + return new gd_adapter.wuode(); + default: + return new Fragment(); + } } @Override - public void onTabUnselected(TabLayout.Tab tab) { + public int getItemCount() { + return 3; } - + }); +// 将 ViewPager2 绑定到 TabLayout + binding.tablayout.setOnItemSelectedListener(item -> { + int itemId = item.getItemId(); + if (itemId == R.id.a) { + binding.viewPager.setCurrentItem(0); + } else if (itemId == R.id.b) { + binding.viewPager.setCurrentItem(1); + } else if (itemId == R.id.c) { + binding.viewPager.setCurrentItem(2); + } + return true; + });binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { @Override - public void onTabReselected(TabLayout.Tab tab) { + public void onPageSelected(int position) { + switch (position) { + case 0: + binding.tablayout.setSelectedItemId(R.id.a); + break; + case 1: + binding.tablayout.setSelectedItemId(R.id.b); + break; + case 2: + binding.tablayout.setSelectedItemId(R.id.c); + break; + } } }); try { @@ -79,18 +110,19 @@ public class gd extends Fragment { like = new JSONObject(wj.dqwb(wj.mp3_like)); } } catch (JSONException e) { - throw new RuntimeException(e); + gj.sc(e); } - return view; + return binding.getRoot(); } - public static class baseadapter extends RecyclerView.Adapter { Context context; List list; + public baseadapter(Context context, List list) { this.context = context; this.list = list; } + @NonNull @Override public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { @@ -106,7 +138,7 @@ public class gd extends Fragment { @Override public void onBindViewHolder(@NonNull VH holder, int position) { xm xm = list.get(position); - list_gd gd = new list_gd(xm); + list_gd gd = new list_gd(xm,this); holder.cardView.setOnClickListener(gd); holder.cardView.setOnLongClickListener(gd); holder.textView.setText(xm.name); @@ -126,7 +158,7 @@ public class gd extends Fragment { main.edit.commit(); gdid = xm.id; } - com.muqingbfq.fragment.gd.lbspq.notifyDataSetChanged(); + notifyDataSetChanged(); }); } }.start(); @@ -160,33 +192,4 @@ public class gd extends Fragment { kg = itemView.findViewById(R.id.kg); } } - - class thread extends Thread { - String name; - - public thread(String name) { - this.name = name; - list.clear(); - start(); - } - - @SuppressLint("NotifyDataSetChanged") - @Override - public void run() { - super.run(); - switch (name) { - case "推荐": - resource.recommend(list); - break; - case "下载": - resource.下载(list); - break; - case "排行榜": - resource.排行榜(list); - break; - } - main.handler.post(() -> lbspq.notifyDataSetChanged()); - } - } - } \ No newline at end of file diff --git a/app/src/main/java/com/muqingbfq/fragment/gd_adapter.java b/app/src/main/java/com/muqingbfq/fragment/gd_adapter.java new file mode 100644 index 0000000..fc08c85 --- /dev/null +++ b/app/src/main/java/com/muqingbfq/fragment/gd_adapter.java @@ -0,0 +1,123 @@ +package com.muqingbfq.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.LinearLayout; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.muqingbfq.R; +import com.muqingbfq.api.resource; +import com.muqingbfq.main; +import com.muqingbfq.xm; + +import java.util.ArrayList; +import java.util.List; + +public class gd_adapter extends Fragment { + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + FrameLayout layout = new FrameLayout(getContext()); + List list = new ArrayList<>(); + RecyclerView recyclerView = new RecyclerView(layout.getContext()); + int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f); + GridLayoutManager gridLayoutManager = new GridLayoutManager(layout.getContext(), k / 120); + recyclerView.setLayoutManager(gridLayoutManager); + layout.addView(recyclerView); + gd.baseadapter baseadapter = new gd.baseadapter(getContext(), list); + recyclerView.setAdapter(baseadapter); + new Thread() { + @SuppressLint("NotifyDataSetChanged") + @Override + public void run() { + super.run(); + resource.recommend(list); + main.handler.postDelayed(new sx(baseadapter),500); + } + }.start(); + return layout; + } + + public static class paihangbang extends Fragment { + + List list = new ArrayList<>(); + gd.baseadapter baseadapter; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + FrameLayout layout = new FrameLayout(getContext()); + RecyclerView recyclerView = new RecyclerView(layout.getContext()); + int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f); + GridLayoutManager gridLayoutManager = new GridLayoutManager(layout.getContext(), k / 120); + recyclerView.setLayoutManager(gridLayoutManager); + layout.addView(recyclerView); + baseadapter = new gd.baseadapter(getContext(), list); + recyclerView.setAdapter(baseadapter); + new Thread() { + @SuppressLint("NotifyDataSetChanged") + @Override + public void run() { + super.run(); + resource.排行榜(list); + main.handler.postDelayed(new sx(baseadapter),500); + } + }.start(); + return layout; + } + } + + public static class wuode extends Fragment { + List list = new ArrayList<>(); + gd.baseadapter baseadapter; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + FrameLayout layout = new FrameLayout(getContext()); + RecyclerView recyclerView = new RecyclerView(layout.getContext()); + int k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f); + GridLayoutManager gridLayoutManager = new GridLayoutManager(layout.getContext(), k / 120); + recyclerView.setLayoutManager(gridLayoutManager); + layout.addView(recyclerView); + baseadapter = new gd.baseadapter(getContext(), list); + recyclerView.setAdapter(baseadapter); + new Thread() { + @SuppressLint("NotifyDataSetChanged") + @Override + public void run() { + super.run(); + resource.下载(list); + main.handler.postDelayed(new sx(baseadapter),500); + } + }.start(); + return layout; + } + } + + private static class sx implements Runnable { + gd.baseadapter baseadapter; + + public sx(gd.baseadapter baseadapter) { + this.baseadapter = baseadapter; + } + @SuppressLint("NotifyDataSetChanged") + @Override + public void run() { + baseadapter.notifyDataSetChanged(); + } + } + +} diff --git a/app/src/main/java/com/muqingbfq/fragment/mp3.java b/app/src/main/java/com/muqingbfq/fragment/mp3.java index 699b313..bd46578 100644 --- a/app/src/main/java/com/muqingbfq/fragment/mp3.java +++ b/app/src/main/java/com/muqingbfq/fragment/mp3.java @@ -5,14 +5,11 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -23,15 +20,15 @@ import com.muqingbfq.api.url; import com.muqingbfq.bfq; import com.muqingbfq.bfqkz; import com.muqingbfq.databinding.FragmentMp3Binding; -import com.muqingbfq.home; import com.muqingbfq.list.MyViewHoder; import com.muqingbfq.main; +import com.muqingbfq.mq.FragmentActivity; import com.muqingbfq.xm; import java.util.ArrayList; import java.util.List; -public class mp3 extends com.muqingbfq.mq.ActivityToolbar { +public class mp3 extends FragmentActivity { private final List list = new ArrayList<>(); public static RecyclerView.Adapter lbspq; @@ -40,7 +37,8 @@ public class mp3 extends com.muqingbfq.mq.ActivityToolbar { super.onCreate(savedInstanceState); FragmentMp3Binding inflate = FragmentMp3Binding.inflate(getLayoutInflater()); Intent intent = getIntent(); - inflate.toolbar.setTitle(intent.getStringExtra("name")); + inflate.title.setText(intent.getStringExtra("name")); +// inflate.toolbar.setTitle(intent.getStringExtra("name")); setContentView(inflate.getRoot()); lbspq = new spq(); RecyclerView lb = findViewById(R.id.lb); @@ -48,6 +46,8 @@ public class mp3 extends com.muqingbfq.mq.ActivityToolbar { lb.setLayoutManager(layoutManager); lb.setAdapter(lbspq); String id = intent.getStringExtra("id"); + +// inflate.bfqDb.setBackground(gd.color); new start(id); } diff --git a/app/src/main/java/com/muqingbfq/fragment/search.java b/app/src/main/java/com/muqingbfq/fragment/search.java index 2f46c39..9932812 100644 --- a/app/src/main/java/com/muqingbfq/fragment/search.java +++ b/app/src/main/java/com/muqingbfq/fragment/search.java @@ -161,7 +161,7 @@ public class search extends Fragment { } private void gd() { - String hq = wl.hq("/search?keywords=" + name + "&limit=" + (k * k) + "&type=1000"); + String hq = wl.hq("/search?keywords=" + name + "&limit=" + (k * 3) + "&type=1000"); try { JSONArray jsonArray = new JSONObject(hq).getJSONObject("result") .getJSONArray("playlists"); diff --git a/app/src/main/java/com/muqingbfq/home.java b/app/src/main/java/com/muqingbfq/home.java index d291446..0c88aee 100644 --- a/app/src/main/java/com/muqingbfq/home.java +++ b/app/src/main/java/com/muqingbfq/home.java @@ -5,6 +5,8 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.widget.ImageView; @@ -14,12 +16,14 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.drawerlayout.widget.DrawerLayout; -import com.google.android.material.card.MaterialCardView; import com.google.android.material.navigation.NavigationView; import com.muqingbfq.fragment.Media; import com.muqingbfq.fragment.bfq_db; +import com.muqingbfq.fragment.gd; import com.muqingbfq.mq.gj; +import me.wcy.lrcview.LrcView; + public class home extends AppCompatActivity { @SuppressLint("StaticFieldLeak") public static AppCompatActivity appCompatActivity; @@ -28,11 +32,13 @@ public class home extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { + appCompatActivity = this; setTheme(R.style.Theme_muqing); super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); - appCompatActivity = this; - new start(); + DisplayMetrics dm = getResources().getDisplayMetrics(); + main.k = dm.widthPixels; + main.g = dm.heightPixels; if (imageView == null) { imageView = new ImageView(this); imageView.setScaleType(ImageView.ScaleType.FIT_XY); @@ -42,6 +48,20 @@ public class home extends AppCompatActivity { Media.setImageBitmap(); } } + if (Media.lrcview == null) { + // 在合适的位置初始化LrcView + Media.lrcview = new LrcView(this); + // 请将Context替换为实际的上下文对象 + // 设置LrcView的属性 + Media.lrcview.setCurrentColor(getResources().getColor(R.color.text)); + Media.lrcview.setLabel(getString(R.string.app_name)); + Media.lrcview.setCurrentTextSize(TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics())); +// lrcView.setLrcPadding(16); + Media.lrcview.setCurrentTextSize(TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics())); + Media.lrcview.setTimelineTextColor(getResources().getColor(R.color.text_tm)); + } try { //初始化工具栏 Toolbar toolbar = findViewById(R.id.toolbar); @@ -66,6 +86,7 @@ public class home extends AppCompatActivity { } //检测更新 new gj.jianchagengxin(this); + } catch (Exception e) { yc.tc(this, e); } @@ -85,12 +106,6 @@ public class home extends AppCompatActivity { editor.apply(); } - @Override - protected void onResume() { - super.onResume(); - getSupportFragmentManager().beginTransaction() - .add(R.id.bfq_db, new bfq_db()).commit(); - } private long time; diff --git a/app/src/main/java/com/muqingbfq/list/list_gd.java b/app/src/main/java/com/muqingbfq/list/list_gd.java index 4130e4a..8b598dd 100644 --- a/app/src/main/java/com/muqingbfq/list/list_gd.java +++ b/app/src/main/java/com/muqingbfq/list/list_gd.java @@ -23,22 +23,20 @@ import java.util.Objects; public class list_gd implements View.OnClickListener, View.OnLongClickListener { xm xm; - - public list_gd(com.muqingbfq.xm xm) { + gd.baseadapter adaper; + public list_gd(com.muqingbfq.xm xm,gd.baseadapter baseadapter) { this.xm = xm; + this.adaper = baseadapter; } @SuppressLint("NotifyDataSetChanged") @Override public void onClick(View view) { -// if (!gd.gdid.equals(xm.id)) { -// gd.gdid = xm.id; Context context = view.getContext(); Intent intent = new Intent(context, com.muqingbfq.fragment.mp3.class); intent.putExtra("id", xm.id); intent.putExtra("name", xm.name); context.startActivity(intent); -// mp3.startactivity(view.getContext(),xm.id); } @@ -84,7 +82,7 @@ public class list_gd implements View.OnClickListener, View.OnLongClickListener { gj.sc(e); } } - main.handler.post(() -> gd.lbspq.notifyDataSetChanged()); + main.handler.post(() -> adaper.notifyDataSetChanged()); } }.start(); // 在这里处理菜单项的点击事件 diff --git a/app/src/main/java/com/muqingbfq/login/cookie.java b/app/src/main/java/com/muqingbfq/login/cookie.java index ef4ddf0..52b817b 100644 --- a/app/src/main/java/com/muqingbfq/login/cookie.java +++ b/app/src/main/java/com/muqingbfq/login/cookie.java @@ -9,7 +9,7 @@ import androidx.annotation.Nullable; import com.muqingbfq.R; import com.muqingbfq.main; -import com.muqingbfq.mq.ActivityToolbar; +import com.muqingbfq.mq.FragmentActivity; import com.muqingbfq.mq.gj; import com.muqingbfq.mq.wl; @@ -17,7 +17,7 @@ import org.json.JSONObject; import java.util.Objects; -public class cookie extends ActivityToolbar { +public class cookie extends FragmentActivity { View view_a, view_b; TextView textView; diff --git a/app/src/main/java/com/muqingbfq/login/enroll.java b/app/src/main/java/com/muqingbfq/login/enroll.java index 71c0adf..a79f2b6 100644 --- a/app/src/main/java/com/muqingbfq/login/enroll.java +++ b/app/src/main/java/com/muqingbfq/login/enroll.java @@ -9,14 +9,14 @@ import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import com.muqingbfq.R; -import com.muqingbfq.mq.ActivityToolbar; +import com.muqingbfq.mq.FragmentActivity; import com.muqingbfq.mq.gj; import com.muqingbfq.mq.wl; import org.json.JSONException; import org.json.JSONObject; -public class enroll extends ActivityToolbar { +public class enroll extends FragmentActivity { EditText edit_account, edit_username, edit_password, edit_email; diff --git a/app/src/main/java/com/muqingbfq/login/user_editing.java b/app/src/main/java/com/muqingbfq/login/user_editing.java index a8d9823..26321a2 100644 --- a/app/src/main/java/com/muqingbfq/login/user_editing.java +++ b/app/src/main/java/com/muqingbfq/login/user_editing.java @@ -10,7 +10,6 @@ import android.os.Bundle; import android.provider.MediaStore; import android.text.TextUtils; import android.view.View; -import android.widget.AutoCompleteTextView; import android.widget.EditText; import android.widget.ImageView; @@ -26,7 +25,7 @@ import com.muqingbfq.R; import com.muqingbfq.databinding.ActivityUserEditingBinding; import com.muqingbfq.fragment.sz; import com.muqingbfq.main; -import com.muqingbfq.mq.ActivityToolbar; +import com.muqingbfq.mq.FragmentActivity; import com.muqingbfq.mq.gj; import org.json.JSONException; @@ -44,7 +43,7 @@ import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; -public class user_editing extends ActivityToolbar { +public class user_editing extends FragmentActivity { //头像,用户名,签名,性别,背景 ImageView imageViewa; EditText edit_name, edit_qianming; diff --git a/app/src/main/java/com/muqingbfq/main.java b/app/src/main/java/com/muqingbfq/main.java index 96d5edb..3b58d8e 100644 --- a/app/src/main/java/com/muqingbfq/main.java +++ b/app/src/main/java/com/muqingbfq/main.java @@ -30,9 +30,11 @@ public class main extends Application { @Override public void onCreate() { super.onCreate(); + if (wj.filesdri == null) { + new wj(this); + } application = this; // UUID.randomUUID().toString(); - new wj(this); sp = getSharedPreferences("Set_up", MODE_PRIVATE); edit = sp.edit(); boolean bj = false; diff --git a/app/src/main/java/com/muqingbfq/mq/ActivityToolbar.java b/app/src/main/java/com/muqingbfq/mq/FragmentActivity.java similarity index 87% rename from app/src/main/java/com/muqingbfq/mq/ActivityToolbar.java rename to app/src/main/java/com/muqingbfq/mq/FragmentActivity.java index 18c7fb6..2a073e1 100644 --- a/app/src/main/java/com/muqingbfq/mq/ActivityToolbar.java +++ b/app/src/main/java/com/muqingbfq/mq/FragmentActivity.java @@ -1,16 +1,14 @@ package com.muqingbfq.mq; -import android.os.Bundle; import android.view.MenuItem; import android.view.View; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import com.muqingbfq.R; -public class ActivityToolbar extends AppCompatActivity { +public class FragmentActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { diff --git a/app/src/main/java/com/muqingbfq/mq/wj.java b/app/src/main/java/com/muqingbfq/mq/wj.java index e8aa77c..db8a70e 100644 --- a/app/src/main/java/com/muqingbfq/mq/wj.java +++ b/app/src/main/java/com/muqingbfq/mq/wj.java @@ -8,7 +8,11 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; +import java.nio.file.Files; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -133,4 +137,23 @@ public class wj { } return null; } + + public static void fz(String sourceFilePath, String targetFilePath) { + File sourceFile = new File(sourceFilePath); + File targetFile = new File(targetFilePath); + + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + try (InputStream in = Files.newInputStream(sourceFile.toPath()); + OutputStream out = Files.newOutputStream(targetFile.toPath())) { + byte[] buf = new byte[1024]; + int bytesRead; + while ((bytesRead = in.read(buf)) > 0) { + out.write(buf, 0, bytesRead); + } + // 文件复制完成 + } catch (IOException e) { + e.printStackTrace(); + } + } + } } diff --git a/app/src/main/java/com/muqingbfq/mq/wl.java b/app/src/main/java/com/muqingbfq/mq/wl.java index e5a2456..d20b605 100644 --- a/app/src/main/java/com/muqingbfq/mq/wl.java +++ b/app/src/main/java/com/muqingbfq/mq/wl.java @@ -1,37 +1,18 @@ package com.muqingbfq.mq; -import android.content.ContentResolver; -import android.content.ContentUris; -import android.content.ContentValues; -import android.media.MediaMetadataRetriever; -import android.media.MediaScannerConnection; -import android.net.Uri; -import android.nfc.Tag; -import android.provider.MediaStore; - -import com.mpatric.mp3agic.ID3v2; -import com.mpatric.mp3agic.InvalidDataException; -import com.mpatric.mp3agic.Mp3File; -import com.mpatric.mp3agic.UnsupportedTagException; -import com.muqingbfq.home; import com.muqingbfq.main; import com.muqingbfq.xm; import org.json.JSONException; import org.json.JSONObject; -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import okhttp3.Call; import okhttp3.FormBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import okhttp3.ResponseBody; public class wl { public static String Cookie; @@ -114,63 +95,6 @@ public class wl { start(); } - @Override - public void run() { - super.run(); - try { - if (new File(wj.mp3).isDirectory()) { - File[] aa = new File(wj.mp3).listFiles(); - if (aa.length >= 30) { - aa[0].delete(); - } - } - OkHttpClient client = new OkHttpClient(); - Request request = new Request.Builder() - //访问路径 - .url(url) - .build(); - Call call = client.newCall(request); - Response response = call.execute(); - if (response.isSuccessful()) { - ResponseBody body = response.body(); - if (body != null) { - File file = new File(wj.mp3, x.id+".mp3"); - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - File parentFile = file.getParentFile(); - if (!parentFile.isDirectory()) { - parentFile.mkdirs(); - } - InputStream inputStream = body.byteStream(); - FileOutputStream fileOutputStream = - new FileOutputStream(file); - // 替换为实际要保存的文件路径 - byte[] buffer = new byte[4096]; - int bytesRead; - while ((bytesRead = inputStream.read(buffer)) != -1) { - fileOutputStream.write(buffer, 0, bytesRead); - } - fileOutputStream.close(); - inputStream.close(); - Mp3File mp3file = new Mp3File(file); - if (mp3file.hasId3v2Tag()) { - ID3v2 id3v2Tag = mp3file.getId3v2Tag(); - // 设置新的ID值 - id3v2Tag.setTitle(x.name); - id3v2Tag.setArtist(x.zz); - id3v2Tag.setAlbum(x.zz); - id3v2Tag.setUrl(x.picurl.toString()); - mp3file.save(wj.mp3 + x.id); - file.delete(); - // 保存修改后的音乐文件,删除原来的文件 - } - } - } - } catch (Exception e) { - gj.sc("wl xz " + e); - } - } } } diff --git a/app/src/main/java/com/muqingbfq/start.java b/app/src/main/java/com/muqingbfq/start.java deleted file mode 100644 index d761036..0000000 --- a/app/src/main/java/com/muqingbfq/start.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.muqingbfq; - -import android.util.DisplayMetrics; - -import com.muqingbfq.mq.wj; - -public class start { - public start() { - DisplayMetrics dm = home.appCompatActivity.getResources().getDisplayMetrics(); - main.k = dm.widthPixels; - main.g = dm.heightPixels; - if (wj.filesdri == null) { - new wj(home.appCompatActivity); - } - } -} \ No newline at end of file diff --git a/app/src/main/res/anim/slide_in.xml b/app/src/main/res/anim/slide_in.xml deleted file mode 100644 index ce27a16..0000000 --- a/app/src/main/res/anim/slide_in.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/app/src/main/res/anim/slide_out.xml b/app/src/main/res/anim/slide_out.xml deleted file mode 100644 index b98eddd..0000000 --- a/app/src/main/res/anim/slide_out.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/background.xml b/app/src/main/res/drawable/background.xml index 0ea92cf..eb16e59 100644 --- a/app/src/main/res/drawable/background.xml +++ b/app/src/main/res/drawable/background.xml @@ -1,10 +1,12 @@ - - - - + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/download.xml b/app/src/main/res/drawable/download.xml new file mode 100644 index 0000000..7d81e1a --- /dev/null +++ b/app/src/main/res/drawable/download.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/logo.xml b/app/src/main/res/drawable/logo.xml deleted file mode 100644 index b003cdd..0000000 --- a/app/src/main/res/drawable/logo.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/app/src/main/res/drawable/paihangbang.xml b/app/src/main/res/drawable/paihangbang.xml new file mode 100644 index 0000000..005e55b --- /dev/null +++ b/app/src/main/res/drawable/paihangbang.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/user.xml b/app/src/main/res/drawable/user.xml new file mode 100644 index 0000000..c30ffde --- /dev/null +++ b/app/src/main/res/drawable/user.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/zhuye.xml b/app/src/main/res/drawable/zhuye.xml new file mode 100644 index 0000000..96805ed --- /dev/null +++ b/app/src/main/res/drawable/zhuye.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout-land/activity_bfq.xml b/app/src/main/res/layout-land/activity_bfq.xml index cef7ddf..d885993 100644 --- a/app/src/main/res/layout-land/activity_bfq.xml +++ b/app/src/main/res/layout-land/activity_bfq.xml @@ -6,7 +6,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - - + @@ -69,6 +70,15 @@ android:background="?android:attr/selectableItemBackgroundBorderless" android:src="@drawable/mt_sx" tools:ignore="ContentDescription" /> + - - - - + - @@ -59,9 +59,22 @@ android:layout_height="36dp" android:background="?android:attr/selectableItemBackgroundBorderless" android:src="@mipmap/like" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" app:tint="@color/text" tools:ignore="ContentDescription" /> - + + + diff --git a/app/src/main/res/layout/activity_cookie.xml b/app/src/main/res/layout/activity_cookie.xml index 1b3da04..698b225 100644 --- a/app/src/main/res/layout/activity_cookie.xml +++ b/app/src/main/res/layout/activity_cookie.xml @@ -5,7 +5,7 @@ android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical"> - - - + android:layout_height="match_parent" + android:orientation="vertical"> - + android:layout_height="wrap_content"> + + + - - - + - diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index 891f7c3..64bf8e9 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -6,7 +6,7 @@ android:fitsSystemWindows="true" android:orientation="vertical" tools:context=".activity_search"> - @@ -24,7 +24,7 @@ android:paddingStart="3dp" android:paddingEnd="3dp" tools:ignore="TextContrastCheck,VisualLintTextFieldSize" /> - + diff --git a/app/src/main/res/layout/activity_sz.xml b/app/src/main/res/layout/activity_sz.xml index 1945fca..fbdd8bb 100644 --- a/app/src/main/res/layout/activity_sz.xml +++ b/app/src/main/res/layout/activity_sz.xml @@ -7,7 +7,7 @@ android:orientation="vertical" tools:context=".sz"> - - - - - @@ -46,6 +34,7 @@ android:layout_height="wrap_content" android:gravity="center_vertical" android:orientation="horizontal" + android:background="@color/bj" android:paddingStart="3dp" android:paddingEnd="3dp"> diff --git a/app/src/main/res/layout/fragment_bfq_db.xml b/app/src/main/res/layout/fragment_bfq_db.xml index 3d4aeb7..0e363b1 100644 --- a/app/src/main/res/layout/fragment_bfq_db.xml +++ b/app/src/main/res/layout/fragment_bfq_db.xml @@ -1,38 +1,30 @@ - + android:background="@drawable/background"> - - - + android:textSize="26sp" /> @@ -60,4 +52,4 @@ android:src="@drawable/cd" /> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_gd.xml b/app/src/main/res/layout/fragment_gd.xml index 073d901..5805263 100644 --- a/app/src/main/res/layout/fragment_gd.xml +++ b/app/src/main/res/layout/fragment_gd.xml @@ -2,15 +2,24 @@ - + + + - + android:contentDescription="@string/Playlist" + app:menu="@menu/bottom_gd"/> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_mp3.xml b/app/src/main/res/layout/fragment_mp3.xml index c37c31c..88f0993 100644 --- a/app/src/main/res/layout/fragment_mp3.xml +++ b/app/src/main/res/layout/fragment_mp3.xml @@ -4,10 +4,18 @@ android:layout_height="match_parent" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical"> - + android:layout_height="wrap_content"> + + + + android:layout_height="100dp" + android:text="@string/app_name" + android:textSize="26sp"/> \ No newline at end of file diff --git a/app/src/main/res/menu/bottom_gd.xml b/app/src/main/res/menu/bottom_gd.xml new file mode 100644 index 0000000..d8571f4 --- /dev/null +++ b/app/src/main/res/menu/bottom_gd.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 41f35ef..2c2db12 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -2,5 +2,5 @@ @color/white #99FFFFFF - #323232 + #2A2831 \ 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 229bde8..19249b8 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -13,7 +13,7 @@ #000000 #80000000 #00FFFFFF - @color/white + #F2ECF6 #B3E5FC \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 4cf2284..c57f132 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -10,7 +10,7 @@ + + + +