Compare commits
4 Commits
release/1.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 51f1b9494e | |||
| e2285ec1c5 | |||
| 6de3eeeb2f | |||
| 3cc08fc13d |
@@ -12,12 +12,12 @@ android {
|
||||
keyPassword '34864394'
|
||||
}
|
||||
}
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 32
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.yutou.nas_music_player"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 32
|
||||
versionCode 1
|
||||
versionName "1.1"
|
||||
|
||||
@@ -44,14 +44,14 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation 'com.google.android.material:material:1.6.0'
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
|
||||
implementation fileTree(dir: "libs", include: ["*.aar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
|
||||
implementation 'androidx.work:work-runtime:2.5.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.work:work-runtime:2.7.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
BIN
app/libs/POPDialog-release.aar
Normal file
BIN
app/libs/POPDialog-release.aar
Normal file
Binary file not shown.
@@ -14,9 +14,10 @@
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:screenOrientation="portrait"
|
||||
android:screenOrientation="fullSensor"
|
||||
android:name=".views.OpenActivity"
|
||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -46,7 +47,8 @@
|
||||
<action android:name="android.media.browse.MediaBrowserService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<receiver android:name="androidx.media.session.MediaButtonReceiver">
|
||||
<receiver android:name="androidx.media.session.MediaButtonReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
</intent-filter>
|
||||
|
||||
@@ -45,14 +45,15 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
public static final int LIBS_MODEL_PLAY_LIST = 4;
|
||||
public static final int LIBS_MODEL_PLAY_Collection = 5;
|
||||
|
||||
public interface OnClickAction{
|
||||
void onClick(Intent intent,View view);
|
||||
}
|
||||
protected OnClickAction clickAction;
|
||||
public void setOnClickAction(OnClickAction onClickAction) {
|
||||
this.clickAction=onClickAction;
|
||||
public interface OnClickAction {
|
||||
void onClick(Intent intent, View view);
|
||||
}
|
||||
|
||||
protected OnClickAction clickAction;
|
||||
|
||||
public void setOnClickAction(OnClickAction onClickAction) {
|
||||
this.clickAction = onClickAction;
|
||||
}
|
||||
|
||||
|
||||
List<MusicData> list = new ArrayList<>();
|
||||
@@ -141,7 +142,7 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
}
|
||||
|
||||
public void setModel(int model) {
|
||||
this.model=model;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public class ViewHolderCollection extends ViewHolder {
|
||||
@@ -298,9 +299,9 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
Intent intent = new Intent(itemView.getContext(), AlbumsActivity.class);
|
||||
intent.putExtra("model", 2);
|
||||
intent.putExtra("fid", data.getId());
|
||||
intent.putExtra("image",data.getImg(AppData.imageWidth, AppData.imageHigh));
|
||||
if(clickAction!=null){
|
||||
clickAction.onClick(intent,icon);
|
||||
intent.putExtra("image", data.getImg(AppData.imageWidth, AppData.imageHigh));
|
||||
if (clickAction != null) {
|
||||
clickAction.onClick(intent, icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,10 +311,10 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
Intent intent = new Intent(itemView.getContext(), AlbumsActivity.class);
|
||||
intent.putExtra("model", 0);
|
||||
intent.putExtra("album", data.getAlbum());
|
||||
intent.putExtra("image",data.getImg(AppData.imageWidth, AppData.imageHigh));
|
||||
intent.putExtra("color",AppTools.getImageColor(data.getImg(AppData.minImageWidth,AppData.minImageHigh)));
|
||||
if(clickAction!=null){
|
||||
clickAction.onClick(intent,icon);
|
||||
intent.putExtra("image", data.getImg(AppData.imageWidth, AppData.imageHigh));
|
||||
intent.putExtra("color", AppTools.getImageColor(data.getImg(AppData.minImageWidth, AppData.minImageHigh)));
|
||||
if (clickAction != null) {
|
||||
clickAction.onClick(intent, icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,8 +367,8 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
icon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (data.getImg(AppData.minImageWidth,AppData.minImageHigh) != null) {
|
||||
Glide.with(MyApplication.application).load(data.getImg(AppData.minImageWidth,AppData.minImageHigh))
|
||||
if (data.getImg(AppData.minImageWidth, AppData.minImageHigh) != null) {
|
||||
Glide.with(MyApplication.application).load(data.getImg(AppData.minImageWidth, AppData.minImageHigh))
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
||||
.into(icon);
|
||||
icon.setTag("img");
|
||||
@@ -411,11 +412,10 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
.setTitle("添加文件夹到队列")
|
||||
.setMessage("将文件夹中所有歌曲添加到队列?")
|
||||
.setPositiveButton("添加", new DialogInterface.OnClickListener() {
|
||||
KProgressHUD hud;
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
hud = AppTools.showLoading(itemView.getContext());
|
||||
AppTools.showHud(itemView.getContext());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("path", data.getFile());
|
||||
json.put("type", true);
|
||||
@@ -425,14 +425,15 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
List<MusicData> list = (List<MusicData>) data;
|
||||
for (MusicData musicData : list) {
|
||||
MusicContainer.getInstance().addTmpList(musicData);
|
||||
hud.dismiss();
|
||||
}
|
||||
AppTools.hideHud();
|
||||
AppTools.toast(list.size()+"首歌已添加到队列中");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
AppTools.toast("添加失败:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -448,7 +449,7 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
|
||||
|
||||
protected void showImage(MusicData musicData, ViewHolder holder) {
|
||||
musicData.getImg(AppData.minImageWidth,AppData.minImageHigh, new NetworkInterface() {
|
||||
musicData.getImg(AppData.minImageWidth, AppData.minImageHigh, new NetworkInterface() {
|
||||
@Override
|
||||
public void httpGetData(Object data, int state) {
|
||||
Glide.with(MyApplication.application).load((Bitmap) data)
|
||||
|
||||
@@ -9,9 +9,11 @@ import android.support.v4.media.MediaMetadataCompat;
|
||||
import android.support.v4.media.session.MediaControllerCompat;
|
||||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
@@ -22,10 +24,14 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.core.view.GestureDetectorCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.yutou.nas_music_player.Adapters.MusicLibsAdapter;
|
||||
import com.yutou.nas_music_player.Datas.MusicData;
|
||||
import com.yutou.nas_music_player.R;
|
||||
import com.yutou.nas_music_player.containers.MediaBrowserHelper;
|
||||
@@ -33,6 +39,7 @@ import com.yutou.nas_music_player.containers.MusicContainer;
|
||||
import com.yutou.nas_music_player.tools.AppData;
|
||||
import com.yutou.nas_music_player.tools.AppTools;
|
||||
import com.yutou.nas_music_player.tools.ConfigTools;
|
||||
import com.yutou.popdialog.POPDialog;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -51,6 +58,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
private TextView positionTime, durationTime, bitRate, playIndex;
|
||||
private SeekBar seekBar;
|
||||
private Handler handler;
|
||||
|
||||
private GestureDetectorCompat touch;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
@@ -130,51 +140,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
public void onClick(View v) {
|
||||
int model = (int) playModel.getTag();
|
||||
if (model == MusicContainer.PLAY_MODEL_LIST_RANDOM) {
|
||||
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM,true);
|
||||
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM, true);
|
||||
return;
|
||||
}
|
||||
setPlayModelButton(model + 1,true);
|
||||
setPlayModelButton(model + 1, true);
|
||||
}
|
||||
});
|
||||
getWindow().getDecorView().setOnTouchListener(new View.OnTouchListener() {
|
||||
float downPosition_x = 0, downPosition_y = 0;
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
downPosition_x = event.getRawX();
|
||||
downPosition_y = event.getRawY();
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
if (Math.abs(downPosition_x - event.getRawX()) < 500 && downPosition_y - event.getRawY() > 500) {
|
||||
Pair<View, String> pImage = Pair.create((View) album_image, "main_album_image");
|
||||
Pair<View, String> pPrevious = Pair.create((View) previous, "previous");
|
||||
Pair<View, String> pPlay = Pair.create((View) play, "play");
|
||||
Pair<View, String> pNext = Pair.create((View) next, "next");
|
||||
Pair<View, String> pTitle = Pair.create((View) title, "title");
|
||||
Pair<View, String> pArtist = Pair.create((View) artist, "artist");
|
||||
Pair<View, String> pBar = Pair.create((View) seekBar, "bar");
|
||||
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this,
|
||||
pImage,
|
||||
pPrevious,
|
||||
pPlay,
|
||||
pNext,
|
||||
pBar,
|
||||
pTitle,
|
||||
pArtist).toBundle();
|
||||
|
||||
Intent intent = new Intent(
|
||||
MainActivity.this, PlayLibsActivity.class);
|
||||
intent.putExtra("bar_pos", seekBar.getProgress());
|
||||
if (bundle != null) {
|
||||
startActivity(intent, bundle);
|
||||
} else {
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
browserHelper = new MediaBrowserHelper(this);
|
||||
browserHelper.regPlayListener(new PlayListener());
|
||||
|
||||
@@ -270,7 +242,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
AppTools.toast("列表随机");
|
||||
break;
|
||||
default:
|
||||
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM,isButton);
|
||||
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM, isButton);
|
||||
return;
|
||||
}
|
||||
ConfigTools.getPreferences().edit().putInt("playModel", model).apply();
|
||||
@@ -301,6 +273,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
seekBar = findViewById(R.id.seekBar);
|
||||
playModel = findViewById(R.id.playModel);
|
||||
playIndex = findViewById(R.id.playIndex);
|
||||
touch = new GestureDetectorCompat(this, new MyTouch());
|
||||
int model = ConfigTools.getPreferences().getInt("playModel", MusicContainer.PLAY_MODEL_RANDOM);
|
||||
setPlayModelButton(model);
|
||||
}
|
||||
@@ -341,29 +314,62 @@ public class MainActivity extends AppCompatActivity {
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
float downX = 0;
|
||||
float downY = 0;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
downX = event.getRawX();
|
||||
downY = event.getRawY();
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
pass(event.getRawX(), event.getRawY());
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
return touch.onTouchEvent(event);
|
||||
}
|
||||
|
||||
private void pass(float upX, float upY) {
|
||||
boolean isOkY = Math.abs(upY - downY) <= 200;
|
||||
if (upX - downX > 200 && isOkY) {
|
||||
previous.callOnClick();
|
||||
} else if (upX - downX < -200 && isOkY) {
|
||||
next.callOnClick();
|
||||
private void toPlayList() {
|
||||
Pair<View, String> pImage = Pair.create((View) album_image, "main_album_image");
|
||||
Pair<View, String> pPrevious = Pair.create((View) previous, "previous");
|
||||
Pair<View, String> pPlay = Pair.create((View) play, "play");
|
||||
Pair<View, String> pNext = Pair.create((View) next, "next");
|
||||
Pair<View, String> pTitle = Pair.create((View) title, "title");
|
||||
Pair<View, String> pArtist = Pair.create((View) artist, "artist");
|
||||
Pair<View, String> pBar = Pair.create((View) seekBar, "bar");
|
||||
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this,
|
||||
pImage,
|
||||
pPrevious,
|
||||
pPlay,
|
||||
pNext,
|
||||
pBar,
|
||||
pTitle,
|
||||
pArtist).toBundle();
|
||||
|
||||
Intent intent = new Intent(
|
||||
MainActivity.this, PlayLibsActivity.class);
|
||||
intent.putExtra("bar_pos", seekBar.getProgress());
|
||||
if (bundle != null) {
|
||||
startActivity(intent, bundle);
|
||||
} else {
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void showPOPDialog() {
|
||||
List<MusicData> playList = MusicContainer.getInstance().getPlayList();
|
||||
POPDialog dialog = new POPDialog(this);
|
||||
RecyclerView recyclerView = null;
|
||||
dialog.enableExitButton(true);
|
||||
if (playList.isEmpty()) {
|
||||
dialog.setTitle("播放列表");
|
||||
dialog.setMessage("播放列表为空,正在全列表随机播放");
|
||||
} else {
|
||||
dialog.setTitle("播放列表:" + playList.size());
|
||||
MusicLibsAdapter adapter = new MusicLibsAdapter(this);
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
recyclerView = new RecyclerView(this);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setLayoutParams(params);
|
||||
recyclerView.setAdapter(adapter);
|
||||
adapter.setData(playList);
|
||||
adapter.setBrowserHelper(browserHelper);
|
||||
dialog.setContentView(recyclerView);
|
||||
}
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private class PlayListener extends MediaControllerCompat.Callback {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
@@ -412,4 +418,23 @@ public class MainActivity extends AppCompatActivity {
|
||||
System.out.println("不知道是啥变换了");
|
||||
}
|
||||
}
|
||||
|
||||
private class MyTouch extends GestureDetector.SimpleOnGestureListener {
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
float x = e1.getX() - e2.getX();
|
||||
float y = e1.getY() - e2.getY();
|
||||
if (Math.abs(x) < 200 && y > 300) {
|
||||
showPOPDialog();
|
||||
} else if (Math.abs(x) < 200 && y < -500) {
|
||||
toPlayList();
|
||||
} else if (Math.abs(y) < 200 && x > 300) {
|
||||
next.callOnClick();
|
||||
} else if (Math.abs(y) < 200 && x < -300) {
|
||||
previous.callOnClick();
|
||||
}
|
||||
return super.onFling(e1, e2, velocityX, velocityY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.yutou.nas_music_player.views;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@@ -9,7 +9,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
||||
Reference in New Issue
Block a user