A面功能界面优化
This commit is contained in:
parent
186ac6b208
commit
7fd2da133c
@ -102,12 +102,9 @@ public class A_ImportFragmentAdapter extends RecyclerView.Adapter<A_ImportFragme
|
||||
onOptionClickListener.onOptionClick(position, audioItem.getFile(), option);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ public class CircularProgressBar extends View {
|
||||
private float maxProgress = 100;
|
||||
|
||||
private int fixedSize = 47; // 固定圆环的直径(dp)
|
||||
private int progressWidth = 5; // 固定进度条宽度(dp)
|
||||
private int progressWidth = 3; // 固定进度条宽度(dp)
|
||||
|
||||
private OnProgressChangeListener listener; // 自定义监听器
|
||||
|
||||
|
||||
@ -12,12 +12,16 @@ import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.hi.music.player.R;
|
||||
@ -35,10 +39,17 @@ public class MusicPlayerForegroundService extends Service {
|
||||
private final IBinder binder = new MusicBinder(); // 用于绑定服务的Binder
|
||||
private final MutableLiveData<Boolean> isPlaying = new MutableLiveData<>(false); // 播放状态
|
||||
private final MutableLiveData<String> fileName = new MutableLiveData<>(); // 当前播放的文件名
|
||||
private MutableLiveData<Integer> remainingTimeLiveData = new MutableLiveData<>(); // 创建LiveData
|
||||
private AudioItem audioItem; // 当前播放的音频项
|
||||
private String currentAudioPath = null; // 当前播放的音频路径
|
||||
private PowerManager.WakeLock wakeLock; // 用于防止设备休眠
|
||||
private boolean isLooping = true; // 循环播放标志
|
||||
private Handler timerHandler; // 用于管理倒计时
|
||||
private Runnable timerRunnable; // 倒计时Runnable
|
||||
private int remainingTime; // 剩余时间(毫秒)
|
||||
private boolean isTimerRunning = false; // 计时器状态
|
||||
private boolean isTimerPaused = false; // 计时器是否暂停
|
||||
|
||||
|
||||
// 自定义Binder类
|
||||
public class MusicBinder extends Binder {
|
||||
@ -216,6 +227,58 @@ public class MusicPlayerForegroundService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
// 开始或重新开始计时器
|
||||
public void startTimer(int duration) {
|
||||
if (isTimerRunning && !isTimerPaused) {
|
||||
stopTimer(); // 如果计时器已经运行并且没有暂停,则重新开始计时器前先停止
|
||||
}
|
||||
remainingTime = duration; // 重置计时器时间
|
||||
isTimerPaused = false; // 清除暂停状态
|
||||
isTimerRunning = true; // 标记计时器正在运行
|
||||
timerHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
timerRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (remainingTime > 0) {
|
||||
remainingTime -= 1000; // 每秒减少1秒
|
||||
remainingTimeLiveData.postValue(remainingTime); // 更新LiveData,通知UI
|
||||
timerHandler.postDelayed(this, 1000); // 每秒更新一次
|
||||
} else {
|
||||
pauseAudio(); // 时间到,暂停音乐
|
||||
isPlaying.postValue(false); // 更新播放状态
|
||||
Toast.makeText(getApplicationContext(), "定时器结束", Toast.LENGTH_SHORT).show();
|
||||
stopTimer(); // 时间到,结束计时器
|
||||
}
|
||||
}
|
||||
};
|
||||
timerHandler.postDelayed(timerRunnable, 1000); // 启动计时器
|
||||
}
|
||||
|
||||
// 暂停计时器
|
||||
public void pauseTimer() {
|
||||
if (isTimerRunning && !isTimerPaused) {
|
||||
isTimerPaused = true; // 标记为暂停状态
|
||||
timerHandler.removeCallbacks(timerRunnable); // 暂停计时器
|
||||
}
|
||||
}
|
||||
|
||||
// 恢复计时器
|
||||
public void resumeTimer() {
|
||||
if (isTimerRunning && isTimerPaused) {
|
||||
isTimerPaused = false; // 清除暂停状态
|
||||
timerHandler.postDelayed(timerRunnable, 1000); // 恢复计时器
|
||||
}
|
||||
}
|
||||
|
||||
// 结束计时器
|
||||
public void stopTimer() {
|
||||
isTimerRunning = false; // 更新状态
|
||||
isTimerPaused = false; // 清除暂停状态
|
||||
if (timerHandler != null && timerRunnable != null) {
|
||||
timerHandler.removeCallbacks(timerRunnable); // 移除所有回调,停止计时器
|
||||
}
|
||||
}
|
||||
|
||||
// 暂停播放
|
||||
public void pauseAudio() {
|
||||
@ -243,10 +306,21 @@ public class MusicPlayerForegroundService extends Service {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
//获取audioItem的名字
|
||||
public String getName() {
|
||||
return mediaPlayer != null ? audioItem.getName() : null;
|
||||
}
|
||||
|
||||
//获取audioItem
|
||||
public AudioItem getAudioItem() {
|
||||
return audioItem;
|
||||
}
|
||||
|
||||
//获取计时器时间
|
||||
public LiveData<Integer> getRemainingTimeLiveData() {
|
||||
return remainingTimeLiveData; // 提供LiveData访问
|
||||
}
|
||||
|
||||
// 获取当前播放位置(毫秒)
|
||||
public int getCurrentPosition() {
|
||||
return mediaPlayer != null ? mediaPlayer.getCurrentPosition() : 0;
|
||||
@ -287,5 +361,6 @@ public class MusicPlayerForegroundService extends Service {
|
||||
mediaPlayer.release(); // 释放MediaPlayer资源
|
||||
mediaPlayer = null; // 设置为null
|
||||
}
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import android.content.ServiceConnection;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@ -16,6 +17,7 @@ import com.hi.music.player.R;
|
||||
import com.hi.music.player.adapter.A_HomeViewPagerAdapter;
|
||||
import com.hi.music.player.databinding.ActivityAhomeBinding;
|
||||
import com.hi.music.player.databinding.HomeTabCustomBinding;
|
||||
import com.hi.music.player.javabean.A_data.AudioItem;
|
||||
import com.hi.music.player.service.MusicPlayerForegroundService;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -39,6 +41,7 @@ public class A_HomeActivity extends BaseActivity<ActivityAhomeBinding> {
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
musicService = ((MusicPlayerForegroundService.MusicBinder) service).getService(); // 获取服务实例
|
||||
isBound = true; // 服务已绑定
|
||||
Log.d("A_HomeActivity", "isBound");
|
||||
updatePlayButtonState(); // 更新播放按钮状态
|
||||
startUpdatingProgress(); // 启动进度更新
|
||||
observeIsPlaying(); // 观察播放状态变化
|
||||
@ -57,7 +60,17 @@ public class A_HomeActivity extends BaseActivity<ActivityAhomeBinding> {
|
||||
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); // 绑定服务
|
||||
|
||||
// 初始化界面
|
||||
vb.homeContainer.setVisibility(View.GONE);
|
||||
vb.pause.setOnClickListener(v -> togglePlayPause()); // 设置暂停/播放按钮点击事件
|
||||
vb.homeContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AudioItem audioItem = musicService.getAudioItem();
|
||||
Intent intent = new Intent(A_HomeActivity.this, A_PlayActivity.class);
|
||||
intent.putExtra("Path", audioItem);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
setupProgressBar(); // 设置进度条
|
||||
setupViewPager(); // 设置ViewPager
|
||||
setupTabLayout(); // 设置TabLayout
|
||||
@ -70,12 +83,12 @@ public class A_HomeActivity extends BaseActivity<ActivityAhomeBinding> {
|
||||
|
||||
@Override
|
||||
public boolean isFullScreen() {
|
||||
return false; // 不是全屏模式
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean statusBarLight() {
|
||||
return false; // 状态栏不为浅色
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置进度条
|
||||
@ -142,6 +155,9 @@ public class A_HomeActivity extends BaseActivity<ActivityAhomeBinding> {
|
||||
musicService.getIsPlaying().observe(this, isPlaying -> {
|
||||
if (isPlaying != null) {
|
||||
vb.pause.setImageResource(isPlaying ? R.drawable.pause : R.drawable.play); // 更新播放按钮图标
|
||||
if (isPlaying) {
|
||||
vb.homeContainer.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.hi.music.player.R;
|
||||
import com.hi.music.player.databinding.ActivityAplayBinding;
|
||||
@ -34,6 +35,7 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
private boolean isBackground; // 背景状态
|
||||
private Handler progressHandler; // 用于更新进度的Handler
|
||||
private List<TextView> textViews = new ArrayList<>(); // 存储变换颜色的文字
|
||||
private boolean isTimerOff = false; // 标志位
|
||||
|
||||
// 服务连接对象
|
||||
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||
@ -47,6 +49,9 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
// musicService.getFileName().observe(A_PlayActivity.this, vb.songTitle::setText);
|
||||
vb.songTitle.setText(musicService.getName());
|
||||
|
||||
// 更新进度条和时间
|
||||
updateSeekBarAndTime(); // 添加这一行以确保服务连接时更新UI
|
||||
|
||||
startUpdatingProgress(); // 启动进度更新
|
||||
}
|
||||
|
||||
@ -59,6 +64,11 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
private void updatePlayButton(Boolean isPlaying) {
|
||||
if (isPlaying != null) {
|
||||
vb.playButton.setBackgroundResource(isPlaying ? R.drawable.pause : R.drawable.play);
|
||||
if (isPlaying) {
|
||||
musicService.resumeTimer();
|
||||
} else {
|
||||
musicService.pauseTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -78,6 +88,7 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
|
||||
loadBackgroundPreference(); // 加载之前保存的背景状态
|
||||
|
||||
|
||||
// 从Intent获取音频项
|
||||
AudioItem audioItem = (AudioItem) getIntent().getSerializableExtra("Path");
|
||||
if (audioItem == null) {
|
||||
@ -85,8 +96,15 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
return;
|
||||
}
|
||||
|
||||
Glide.with(this)
|
||||
.load("file:///android_asset/" + audioItem.getImage())
|
||||
.placeholder(R.mipmap.default_image) // 默认图片
|
||||
.into(vb.recordImage); // 加载专辑图片
|
||||
|
||||
|
||||
startMusicService(audioItem); // 启动音乐服务
|
||||
setupPlayButtonClickListener(); // 设置播放按钮的点击事件
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,10 +174,14 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
vb.rootLayout.setBackgroundResource(R.color.dark_music); // 切换为暗色背景
|
||||
vb.backButton.setImageResource(R.drawable.arrow_left);
|
||||
setTextColor(Color.WHITE); // 设置文字颜色为白色
|
||||
vb.prevButton.setImageResource(R.drawable.sleep);
|
||||
vb.repeatButton.setImageResource(R.drawable.timing);
|
||||
} else {
|
||||
vb.rootLayout.setBackgroundResource(R.color.white); // 切换为亮色背景
|
||||
vb.backButton.setImageResource(R.drawable.arrow_left_black);
|
||||
setTextColor(Color.BLACK); // 设置文字颜色为黑色
|
||||
vb.prevButton.setImageResource(R.drawable.light);
|
||||
vb.repeatButton.setImageResource(R.drawable.timing_drak);
|
||||
}
|
||||
saveBackgroundPreference(); // 保存当前背景状态
|
||||
}
|
||||
@ -180,6 +202,8 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
// 根据保存的状态设置背景
|
||||
vb.rootLayout.setBackgroundResource(isBackground ? R.color.dark_music : R.color.white);
|
||||
vb.backButton.setImageResource(isBackground ? R.drawable.arrow_left : R.drawable.arrow_left_black);
|
||||
vb.prevButton.setImageResource(isBackground ? R.drawable.sleep : R.drawable.light);
|
||||
vb.repeatButton.setImageResource(isBackground ? R.drawable.timing : R.drawable.timing_drak);
|
||||
setTextColor(isBackground ? Color.WHITE : Color.BLACK);
|
||||
}
|
||||
|
||||
@ -197,40 +221,58 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
bottomSheetDialog.setContentView(dialogView);
|
||||
|
||||
RadioGroup timerOptions = dialogView.findViewById(R.id.timerOptions);
|
||||
TextView time = dialogView.findViewById(R.id.timerLabel);
|
||||
|
||||
// 读取上次选中的 radioButton ID
|
||||
SharedPreferences sharedPreferences = getSharedPreferences("TimerPreferences", MODE_PRIVATE);
|
||||
int selectedId = sharedPreferences.getInt("selectedTimerOption", R.id.radioOff); // 默认选项为 radioOff
|
||||
timerOptions.check(selectedId); // 设置默认选中的 RadioButton
|
||||
|
||||
timerOptions.setOnCheckedChangeListener((group, checkedId) -> {
|
||||
int duration = 0; // 用于保存定时时长
|
||||
|
||||
if (checkedId == R.id.radioOff) {
|
||||
musicService.stopTimer();
|
||||
time.setText("Timing off");
|
||||
isTimerOff = true; // 设置标志位为 true
|
||||
Toast.makeText(getApplicationContext(), "定时关闭已取消", Toast.LENGTH_SHORT).show();
|
||||
return; // 取消定时
|
||||
} else if (checkedId == R.id.radio10) {
|
||||
duration = 10 * 60 * 1000; // 10分钟
|
||||
isTimerOff = false;
|
||||
} else if (checkedId == R.id.radio20) {
|
||||
duration = 20 * 60 * 1000; // 20分钟
|
||||
isTimerOff = false;
|
||||
} else if (checkedId == R.id.radio30) {
|
||||
duration = 30 * 60 * 1000; // 30分钟
|
||||
isTimerOff = false;
|
||||
} else if (checkedId == R.id.radio60) {
|
||||
duration = 60 * 60 * 1000; // 60分钟
|
||||
isTimerOff = false;
|
||||
} else if (checkedId == R.id.radio90) {
|
||||
duration = 90 * 60 * 1000; // 90分钟
|
||||
isTimerOff = false;
|
||||
}
|
||||
if (duration > 0) {
|
||||
Toast.makeText(getApplicationContext(), "定时设置为 " + (duration / 60000) + " 分钟", Toast.LENGTH_SHORT).show();
|
||||
startTimer(duration); // 启动定时器
|
||||
musicService.startTimer(duration);
|
||||
}
|
||||
|
||||
// 保存选中的 radioButton ID 到 SharedPreferences
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt("selectedTimerOption", checkedId);
|
||||
editor.apply();
|
||||
});
|
||||
|
||||
// 观察remainingTimeLiveData,实时更新UI
|
||||
musicService.getRemainingTimeLiveData().observe(A_PlayActivity.this, remainingTime -> {
|
||||
if (!isTimerOff) {
|
||||
time.setText("Count down " + formatTime(remainingTime));
|
||||
}
|
||||
});
|
||||
|
||||
bottomSheetDialog.show(); // 显示 BottomSheetDialog
|
||||
}
|
||||
|
||||
// 启动定时器
|
||||
private void startTimer(int duration) {
|
||||
// 使用 Handler 来设置定时器
|
||||
new Handler().postDelayed(() -> {
|
||||
musicService.pauseAudio();
|
||||
Toast.makeText(getApplicationContext(), "定时器结束", Toast.LENGTH_SHORT).show();
|
||||
}, duration);
|
||||
}
|
||||
|
||||
// 格式化时间显示
|
||||
private String formatTime(int milliseconds) {
|
||||
@ -239,6 +281,7 @@ public class A_PlayActivity extends BaseActivity<ActivityAplayBinding> {
|
||||
return String.format(Locale.getDefault(), "%d:%02d", minutes, seconds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@ -4,10 +4,6 @@ import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.hi.music.player.service.MusicPlayerForegroundService;
|
||||
|
||||
public class A_VMHome extends AndroidViewModel {
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ import static android.app.Activity.RESULT_OK;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
@ -14,10 +13,10 @@ import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -77,55 +76,42 @@ public class A_ImportFragment extends BaseFragment<FragmentAImportBinding> {
|
||||
private void initEvent() {
|
||||
Vb.setting.setOnClickListener(v -> startActivity(new Intent(getContext(), A_SettingActivity.class)));
|
||||
Vb.add.setOnClickListener(v -> checkAndOpenAudioPicker());
|
||||
adapter.setOnOptionClickListener(this::showDialog);
|
||||
adapter.setOnOptionClickListener(this::showPopupWindow);
|
||||
}
|
||||
|
||||
private void showDialog(int position, String filePath, View anchorView) {
|
||||
Dialog dialog = createOptionsDialog(anchorView);
|
||||
Button buttonOne = dialog.findViewById(R.id.rename);
|
||||
Button buttonTwo = dialog.findViewById(R.id.delete);
|
||||
private void showPopupWindow(int position, String filePath, View anchorView) {
|
||||
// 膨胀 PopupWindow 的布局
|
||||
View popupView = LayoutInflater.from(requireContext()).inflate(R.layout.options_popup_window, null);
|
||||
|
||||
buttonOne.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
showRenameDialog(position);
|
||||
}
|
||||
// 创建 PopupWindow
|
||||
PopupWindow popupWindow = new PopupWindow(popupView,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
true);
|
||||
|
||||
// 设置背景为透明
|
||||
// popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
popupWindow.setOutsideTouchable(true); // 允许点击外部关闭
|
||||
|
||||
// 获取 PopupWindow 中的控件
|
||||
Button renameButton = popupView.findViewById(R.id.rename);
|
||||
Button deleteButton = popupView.findViewById(R.id.delete);
|
||||
|
||||
// 设置重命名按钮的点击事件
|
||||
renameButton.setOnClickListener(v -> {
|
||||
popupWindow.dismiss();
|
||||
showRenameDialog(position);
|
||||
});
|
||||
|
||||
buttonTwo.setOnClickListener(v -> deleteAudioFile(position, filePath, dialog));
|
||||
dialog.show();
|
||||
}
|
||||
// 设置删除按钮的点击事件
|
||||
deleteButton.setOnClickListener(v -> {
|
||||
deleteAudioFile(position, filePath, popupWindow);
|
||||
});
|
||||
|
||||
|
||||
private Dialog createOptionsDialog(View anchorView) {
|
||||
Dialog dialog = new Dialog(requireContext());
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(R.layout.options_dialog);
|
||||
dialog.setCancelable(true);
|
||||
Objects.requireNonNull(dialog.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
setDialogPosition(dialog, anchorView); // 设置对话框的位置
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
private void setDialogPosition(Dialog dialog, View anchorView) {
|
||||
Window window = dialog.getWindow();
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
window.setAttributes(layoutParams);
|
||||
|
||||
// 获取按钮在屏幕上的位置
|
||||
int[] location = new int[2];
|
||||
anchorView.getLocationOnScreen(location);
|
||||
|
||||
// 设置对话框在按钮旁边显示
|
||||
layoutParams.x = location[0] + anchorView.getWidth(); // 在按钮右侧显示
|
||||
layoutParams.y = location[1]; // 与按钮的 Y 坐标对齐
|
||||
window.setAttributes(layoutParams);
|
||||
}
|
||||
// 显示 PopupWindow,设置其位置
|
||||
int[] location = new int[2];
|
||||
anchorView.getLocationOnScreen(location);
|
||||
popupWindow.showAsDropDown(anchorView, 0, 10); // 在 anchorView 下方显示
|
||||
}
|
||||
|
||||
|
||||
@ -156,10 +142,10 @@ public class A_ImportFragment extends BaseFragment<FragmentAImportBinding> {
|
||||
subDialog.show();
|
||||
}
|
||||
|
||||
private void deleteAudioFile(int position, String filePath, Dialog dialog) {
|
||||
private void deleteAudioFile(int position, String filePath, PopupWindow popupWindow) {
|
||||
viewModel.markAudioAsDeleted(filePath);
|
||||
Toast.makeText(requireContext(), "删除按钮被点击, 项目: " + position, Toast.LENGTH_SHORT).show();
|
||||
dialog.dismiss();
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
|
||||
private void checkAndOpenAudioPicker() {
|
||||
|
||||
12
app/src/main/res/drawable/light.xml
Normal file
12
app/src/main/res/drawable/light.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200.2dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1025"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M512.6,798a289,289 0,1 1,288.1 -289A289.4,289.4 0,0 1,512.6 798zM512.6,284.1a224.9,224.9 0,1 0,224.1 224.9A225.1,225.1 0,0 0,512.6 284.1zM274.5,291.6a32,32 0,0 1,-21.4 -8.5L178.1,213.6a32,32 0,0 1,43.8 -46.8l74.5,69.8a32,32 0,0 1,-21.4 55.3zM64.1,537a32,32 0,0 1,0 -64.1L165.1,469.9a32,32 0,0 1,1.9 64.1l-101.9,3.2zM191,856.1a31.8,31.8 0,0 1,-23.5 -53.8l69.8,-74.5a32.3,32.3 0,0 1,45.3 -1.5,31.8 31.8,0 0,1 1.5,45.3L213.6,846.1a32.3,32.3 0,0 1,-22.6 10zM506.2,992.2A32,32 0,0 1,474.2 961.2l-3.2,-101.9a32,32 0,1 1,64.1 -2.1l3.4,102.1a32.3,32.3 0,0 1,-31.2 33.1zM825.4,865.3a31.4,31.4 0,0 1,-21.4 -8.8l-74.5,-69.8a32,32 0,0 1,44 -46.6l74.3,69.8a31.8,31.8 0,0 1,0.9 44.4,32.7 32.7,0 0,1 -23.3,10.9zM859.1,553.2a32,32 0,0 1,0 -64.1l102.1,-3.2a32,32 0,0 1,2.1 64.1l-102.1,3.2zM764.5,305.4a32.3,32.3 0,0 1,-21.4 -8.8,31.8 31.8,0 0,1 -1.5,-45.3L811.7,177.1a32,32 0,1 1,46.8 43.8l-69.8,74.3a32,32 0,0 1,-24.1 10.3z"/>
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="M522.3,196.9A31.8,31.8 0,0 1,491.3 166L487,64.1a32,32 0,0 1,31.2 -32.9A31.4,31.4 0,0 1,551.1 61.9l4.3,102.1a31.8,31.8 0,0 1,-32 32.9z"/>
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/timing.xml
Normal file
12
app/src/main/res/drawable/timing.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M553,186.4v-84h204.8c22.5,0 41,-18.4 41,-41 0,-22.5 -18.4,-41 -41,-41L266.2,20.4c-22.5,0 -41,18.4 -41,41 0,22.5 18.4,41 41,41L471,102.4v84C264,207 102.4,381.5 102.4,593.9c0,226.2 183.4,409.6 409.6,409.6s409.6,-183.4 409.6,-409.6c0,-212.4 -161.7,-387 -368.6,-407.5zM512,921.6c-180.7,0 -327.7,-147 -327.7,-327.7s147,-327.7 327.7,-327.7 327.7,147 327.7,327.7 -147,327.7 -327.7,327.7z"/>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M532.5,556.5V368.6c0,-22.5 -18.4,-41 -41,-41s-41,18.4 -41,41v204.8c0,0.3 0.1,0.5 0.1,0.7 0,2.4 0.3,4.9 0.7,7.3 0.2,0.9 0.5,1.7 0.8,2.6 0.5,1.7 0.9,3.5 1.6,5.2 0.2,0.5 0.5,1 0.8,1.5 2,4.2 4.5,8.2 8,11.6l173.8,173.8c15.9,15.9 42,15.9 57.9,0 15.9,-15.9 15.9,-42 0,-57.9L532.5,556.5z"/>
|
||||
</vector>
|
||||
12
app/src/main/res/drawable/timing_drak.xml
Normal file
12
app/src/main/res/drawable/timing_drak.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M553,186.4v-84h204.8c22.5,0 41,-18.4 41,-41 0,-22.5 -18.4,-41 -41,-41L266.2,20.4c-22.5,0 -41,18.4 -41,41 0,22.5 18.4,41 41,41L471,102.4v84C264,207 102.4,381.5 102.4,593.9c0,226.2 183.4,409.6 409.6,409.6s409.6,-183.4 409.6,-409.6c0,-212.4 -161.7,-387 -368.6,-407.5zM512,921.6c-180.7,0 -327.7,-147 -327.7,-327.7s147,-327.7 327.7,-327.7 327.7,147 327.7,327.7 -147,327.7 -327.7,327.7z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M532.5,556.5V368.6c0,-22.5 -18.4,-41 -41,-41s-41,18.4 -41,41v204.8c0,0.3 0.1,0.5 0.1,0.7 0,2.4 0.3,4.9 0.7,7.3 0.2,0.9 0.5,1.7 0.8,2.6 0.5,1.7 0.9,3.5 1.6,5.2 0.2,0.5 0.5,1 0.8,1.5 2,4.2 4.5,8.2 8,11.6l173.8,173.8c15.9,15.9 42,15.9 57.9,0 15.9,-15.9 15.9,-42 0,-57.9L532.5,556.5z"/>
|
||||
</vector>
|
||||
@ -91,8 +91,8 @@
|
||||
android:id="@+id/separator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="/"
|
||||
android:layout_marginStart="6dp"
|
||||
android:text="/"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/bottom_text1"
|
||||
@ -109,17 +109,6 @@
|
||||
app:layout_constraintStart_toEndOf="@+id/separator"
|
||||
app:layout_constraintTop_toBottomOf="@+id/top_text" />
|
||||
|
||||
<!-- 右侧水平排列的两个 ImageView -->
|
||||
<ImageView
|
||||
android:id="@+id/clock"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:src="@drawable/clock"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/pause"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/pause"
|
||||
android:layout_width="34dp"
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/root_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/root_layout"
|
||||
android:background="@color/dark_music"
|
||||
tools:context=".ui.activity.A_PlayActivity">
|
||||
|
||||
@ -35,7 +35,6 @@
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="300dp"
|
||||
android:layout_marginTop="66dp"
|
||||
android:contentDescription="Record"
|
||||
android:src="@mipmap/default_image"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@ -71,76 +70,70 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:max="100"
|
||||
android:progress="0"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/play_button"
|
||||
android:progress="50"
|
||||
app:layout_constraintBottom_toTopOf="@+id/current"
|
||||
app:layout_constraintEnd_toStartOf="@+id/play_button"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/artist_album_text" />
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/play_button"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/pause"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/song_seekbar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/artist_album_text" />
|
||||
app:layout_constraintTop_toTopOf="@+id/song_seekbar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/current"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="17.5dp"
|
||||
android:text="00:00"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintStart_toStartOf="@id/song_seekbar"
|
||||
app:layout_constraintTop_toBottomOf="@id/song_seekbar" />
|
||||
app:layout_constraintBottom_toTopOf="@+id/linear"
|
||||
app:layout_constraintStart_toStartOf="@id/song_seekbar" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="17.5dp"
|
||||
android:text="4:08"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="@id/song_seekbar"
|
||||
app:layout_constraintTop_toBottomOf="@id/song_seekbar" />
|
||||
app:layout_constraintBottom_toTopOf="@+id/linear"
|
||||
app:layout_constraintEnd_toEndOf="@id/song_seekbar" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="69dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/time">
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/prev_button"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:src="@mipmap/light" />
|
||||
android:src="@drawable/sleep" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/repeat_button"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="14dp"
|
||||
android:src="@mipmap/timing" />
|
||||
android:src="@drawable/timing" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/next_button"
|
||||
android:layout_width="52dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="14dp"
|
||||
android:src="@drawable/sleep" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -32,7 +32,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="11dp"
|
||||
android:text="Top Text"
|
||||
android:textColor="@android:color/black"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/card_view"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="11dp"
|
||||
android:text="Top Text"
|
||||
android:textColor="@android:color/black"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/card_view"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
android:text="Rename"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/black"/>
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
@ -29,7 +29,7 @@
|
||||
android:layout_gravity="center"
|
||||
android:text="Delete"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
android:textColor="@color/black"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
@ -25,7 +25,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:text="The value contains a maximum
|
||||
of 60 characters"
|
||||
of 30 characters"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
@ -37,8 +37,9 @@
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@drawable/rounded_edittext_background"
|
||||
android:hint="Placeholder"
|
||||
android:textColor="@color/white"
|
||||
android:maxLength="30"
|
||||
android:padding="12dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user