├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── mohammadkz
│ │ └── musicbox
│ │ ├── Adapter
│ │ ├── AddMusicAdapter.java
│ │ ├── AllMusicListAdapter.java
│ │ ├── ArtistTabAdapter.java
│ │ └── PlayListAdapter.java
│ │ ├── ApplicationClass.java
│ │ ├── Fragment
│ │ ├── ArtistPlayerListFragment.java
│ │ ├── ArtistTabFragment.java
│ │ ├── BottomSheetAddMusic_playList.java
│ │ ├── HomeFragment.java
│ │ ├── LikeFragment.java
│ │ ├── PlayListFragment.java
│ │ ├── PlayListMusicFragment.java
│ │ ├── SearchFragment.java
│ │ ├── SearchTabFragment.java
│ │ ├── SheetBottomFragment.java
│ │ └── SheetBottomMusicInfo.java
│ │ ├── MainActivity.java
│ │ ├── Model
│ │ ├── ActionPlaying.java
│ │ ├── Artist.java
│ │ ├── DB.java
│ │ ├── LikeDA.java
│ │ ├── Music.java
│ │ ├── PlayList.java
│ │ └── PlayListDA.java
│ │ ├── MusicService.java
│ │ ├── NotificationReceiver.java
│ │ └── StartUpActivity.java
│ └── res
│ ├── drawable-v24
│ └── ic_jump_to.png
│ ├── drawable
│ ├── .idea
│ │ ├── .gitignore
│ │ ├── drawable.iml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ ├── audio_img_perpel.xml
│ ├── audio_img_white.xml
│ ├── bg_bottom_nav.xml
│ ├── bg_bottom_sheet.xml
│ ├── bg_button.xml
│ ├── bg_music_select.xml
│ ├── bg_sealected_sort.xml
│ ├── bg_search_box.xml
│ ├── heart.png
│ ├── home.xml
│ ├── ic_add.xml
│ ├── ic_arrow_down.xml
│ ├── ic_back.xml
│ ├── ic_cleaning.xml
│ ├── ic_close.xml
│ ├── ic_music.xml
│ ├── ic_play_circle.xml
│ ├── ic_repeat.xml
│ ├── ic_repeat_one.xml
│ ├── ic_shuffle.xml
│ ├── ic_sort.xml
│ ├── icon.png
│ ├── like.png
│ ├── more.xml
│ ├── music_artist.png
│ ├── next.xml
│ ├── pause.xml
│ ├── play.xml
│ ├── playlist.png
│ ├── previous.xml
│ ├── search.png
│ ├── selection.xml
│ ├── tab_selection.xml
│ └── user.png
│ ├── layout
│ ├── activity_main.xml
│ ├── activity_start_up.xml
│ ├── all_music_layout.xml
│ ├── artist_layout.xml
│ ├── bottom_sheet_add_to_playlist.xml
│ ├── fragment_artist_player_list.xml
│ ├── fragment_artist_tab.xml
│ ├── fragment_home.xml
│ ├── fragment_like.xml
│ ├── fragment_play_list.xml
│ ├── fragment_play_list_music.xml
│ ├── fragment_search.xml
│ ├── fragment_search_tab.xml
│ ├── fragment_sheet_bottom.xml
│ ├── layout_add_to_playlist.xml
│ ├── layout_play_list.xml
│ ├── layout_sort_bottom_sheet.xml
│ └── sheet_bottom_music_info.xml
│ ├── menu
│ ├── menu.xml
│ └── popup_menu.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── raw
│ └── music_ani.json
│ ├── values-night
│ └── themes.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── themes.xml
├── build.gradle
├── build
└── intermediates
│ └── lint-cache
│ ├── maven.google
│ ├── androidx
│ │ ├── appcompat
│ │ │ └── group-index.xml
│ │ ├── constraintlayout
│ │ │ └── group-index.xml
│ │ ├── legacy
│ │ │ └── group-index.xml
│ │ └── test
│ │ │ ├── espresso
│ │ │ └── group-index.xml
│ │ │ └── ext
│ │ │ └── group-index.xml
│ ├── com
│ │ └── google
│ │ │ └── android
│ │ │ └── material
│ │ │ └── group-index.xml
│ └── master-index.xml
│ └── sdk-registry.xml
│ └── sdk-registry.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
/README.md:
--------------------------------------------------------------------------------
1 | # MusicBox
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | }
4 |
5 | android {
6 | compileSdkVersion 30
7 | buildToolsVersion "30.0.2"
8 |
9 | defaultConfig {
10 | applicationId "com.mohammadkz.musicbox"
11 | minSdkVersion 26
12 | targetSdkVersion 30
13 | versionCode 2
14 | versionName "2.5"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 |
18 | renderscriptTargetApi 19
19 | renderscriptSupportModeEnabled true
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | compileOptions {
29 | sourceCompatibility JavaVersion.VERSION_1_8
30 | targetCompatibility JavaVersion.VERSION_1_8
31 | }
32 | }
33 |
34 | dependencies {
35 |
36 | implementation 'androidx.appcompat:appcompat:1.2.0'
37 | implementation 'com.google.android.material:material:1.3.0'
38 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
39 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
40 | testImplementation 'junit:junit:4.+'
41 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
42 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
43 | implementation 'com.google.android.material:material:1.4.0-alpha01'
44 | implementation 'de.hdodenhof:circleimageview:3.1.0'
45 | implementation 'com.jackandphantom.android:blurimage:1.2.0'
46 |
47 | // runtime permission
48 | implementation 'gun0912.ted:tedpermission:2.2.3'
49 |
50 | //lottie
51 | implementation 'com.airbnb.android:lottie:3.7.0'
52 |
53 | //pic loader
54 | implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
55 |
56 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
57 |
58 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Adapter/AddMusicAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.media.MediaMetadataRetriever;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.CheckBox;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import androidx.annotation.NonNull;
15 | import androidx.recyclerview.widget.RecyclerView;
16 |
17 | import com.bumptech.glide.Glide;
18 | import com.mohammadkz.musicbox.Model.Music;
19 | import com.mohammadkz.musicbox.R;
20 |
21 | import java.util.List;
22 |
23 | import de.hdodenhof.circleimageview.CircleImageView;
24 |
25 | public class AddMusicAdapter extends RecyclerView.Adapter {
26 |
27 | Context context;
28 | List musicList;
29 | public OnItemClickListener onItemClickListener;
30 |
31 | public AddMusicAdapter(Context context, List musicList) {
32 | this.context = context;
33 | this.musicList = musicList;
34 | }
35 |
36 | @NonNull
37 | @Override
38 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
39 | View view = LayoutInflater.from(context).inflate(R.layout.layout_add_to_playlist, parent, false);
40 | return new ViewHolder(view);
41 | }
42 |
43 | @Override
44 | public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
45 | Music music = musicList.get(position);
46 | holder.musicName.setText(music.getName());
47 | holder.artistName.setText(music.getArtist());
48 | holder.checkBox.setChecked(false);
49 |
50 | // set img of the pic
51 | try {
52 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
53 | mmr.setDataSource(music.getPath());
54 | Bitmap bitmap;
55 | byte[] data = mmr.getEmbeddedPicture();
56 | bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
57 |
58 | loadImage(holder.artistImage, bitmap);
59 |
60 | } catch (Exception e) {
61 | holder.artistImage.setImageResource(R.drawable.audio_img_white);
62 | }
63 |
64 | }
65 |
66 | private void loadImage(ImageView iv, Bitmap url) {
67 | Glide.with(iv.getContext()).load(url).thumbnail(0.3f).into(iv);
68 | }
69 |
70 | @Override
71 | public int getItemCount() {
72 | return musicList.size();
73 | }
74 |
75 | public class ViewHolder extends RecyclerView.ViewHolder {
76 | CircleImageView artistImage;
77 | TextView musicName, artistName;
78 | CheckBox checkBox;
79 |
80 | public ViewHolder(@NonNull View itemView) {
81 | super(itemView);
82 | artistImage = itemView.findViewById(R.id.artistImage);
83 | musicName = itemView.findViewById(R.id.musicName);
84 | artistName = itemView.findViewById(R.id.artistName);
85 | checkBox = itemView.findViewById(R.id.checkbox);
86 | checkBox.setChecked(false);
87 | checkBox.setOnClickListener(new View.OnClickListener() {
88 | @Override
89 | public void onClick(View v) {
90 | onItemClickListener.onItemClick(getAdapterPosition(), v, checkBox.isChecked());
91 | }
92 | });
93 |
94 | }
95 | }
96 |
97 | public interface OnItemClickListener {
98 | void onItemClick(int pos, View v, Boolean c);
99 | }
100 |
101 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
102 | this.onItemClickListener = onItemClickListener;
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Adapter/AllMusicListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Adapter;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.media.MediaMetadataRetriever;
8 | import android.net.Uri;
9 | import android.provider.MediaStore;
10 | import android.util.Log;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.Button;
15 | import android.widget.ImageView;
16 | import android.widget.TextView;
17 |
18 | import androidx.annotation.NonNull;
19 | import androidx.recyclerview.widget.RecyclerView;
20 |
21 | import com.bumptech.glide.Glide;
22 | import com.mohammadkz.musicbox.MainActivity;
23 | import com.mohammadkz.musicbox.Model.LikeDA;
24 | import com.mohammadkz.musicbox.Model.Music;
25 | import com.mohammadkz.musicbox.R;
26 | import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
27 |
28 | import java.io.ByteArrayOutputStream;
29 | import java.util.List;
30 |
31 | import de.hdodenhof.circleimageview.CircleImageView;
32 |
33 | public class AllMusicListAdapter extends RecyclerView.Adapter {
34 |
35 | private Context context;
36 | List musicList;
37 | public OnItemClickListener onItemClickListener;
38 | public OnClickListener onPopupMenuClickListener;
39 | Activity activity;
40 | ImageLoaderConfiguration config;
41 | boolean showOther;
42 |
43 | public AllMusicListAdapter(Context context, List musicList, Activity activity, boolean showOther) {
44 | this.context = context;
45 | this.musicList = musicList;
46 | this.activity = activity;
47 | this.showOther = showOther;
48 | config = new ImageLoaderConfiguration.Builder(context).build();
49 | }
50 |
51 | @NonNull
52 | @Override
53 | public AllMusicListAdapter.viewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
54 | View view = LayoutInflater.from(context).inflate(R.layout.all_music_layout, parent, false);
55 | return new viewHolder(view);
56 | }
57 |
58 | @Override
59 | public void onBindViewHolder(@NonNull AllMusicListAdapter.viewHolder holder, int position) {
60 |
61 | Music music = musicList.get(position);
62 |
63 | holder.musicName.setText(music.getName());
64 | holder.artistName.setText(music.getArtist());
65 |
66 | try {
67 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
68 | mmr.setDataSource(musicList.get(position).getPath());
69 | byte[] data = mmr.getEmbeddedPicture();
70 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
71 |
72 | loadImage(holder.artistImage, bitmap);
73 |
74 | } catch (Exception e) {
75 | e.getMessage();
76 | holder.artistImage.setImageResource(R.drawable.audio_img_white);
77 | }
78 |
79 | if (musicList.get(position).isLiked()) {
80 | holder.like.setImageResource(R.drawable.heart);
81 | } else {
82 | holder.like.setImageResource(R.drawable.like);
83 | }
84 |
85 |
86 | }
87 |
88 | public Uri getImageUri(Bitmap inImage) {
89 | ByteArrayOutputStream bytes = new ByteArrayOutputStream();
90 | inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
91 | String path = MediaStore.Images.Media.insertImage(context.getContentResolver(), inImage, "Title", null);
92 | return Uri.parse(path);
93 | }
94 |
95 | private void loadImage(ImageView iv, Bitmap url) {
96 | Glide.with(iv.getContext()).load(url).thumbnail(0.3f).into(iv);
97 | }
98 |
99 | public Bitmap getResizedBitmap(Bitmap image, int maxSize) {
100 | int width = image.getWidth();
101 | int height = image.getHeight();
102 |
103 | float bitmapRatio = (float) width / (float) height;
104 | if (bitmapRatio > 1) {
105 | width = maxSize;
106 | height = (int) (width / bitmapRatio);
107 | } else {
108 | height = maxSize;
109 | width = (int) (height * bitmapRatio);
110 | }
111 | return Bitmap.createScaledBitmap(image, width, height, true);
112 | }
113 |
114 |
115 | @Override
116 | public int getItemCount() {
117 | return musicList.size();
118 | }
119 |
120 | public class viewHolder extends RecyclerView.ViewHolder {
121 | CircleImageView artistImage; //
122 | TextView musicName, artistName;
123 | Button popupMenu;
124 | ImageView like;
125 |
126 | public viewHolder(@NonNull View itemView) {
127 | super(itemView);
128 | artistImage = itemView.findViewById(R.id.artistImage);
129 | musicName = itemView.findViewById(R.id.musicName);
130 | artistName = itemView.findViewById(R.id.artistName);
131 | popupMenu = itemView.findViewById(R.id.popupMenu);
132 | like = itemView.findViewById(R.id.like);
133 |
134 | if (!showOther) {
135 | like.setVisibility(View.GONE);
136 | popupMenu.setVisibility(View.GONE);
137 | } else {
138 | like.setVisibility(View.VISIBLE);
139 | popupMenu.setVisibility(View.VISIBLE);
140 | }
141 |
142 | itemView.setOnClickListener(new View.OnClickListener() {
143 | @Override
144 | public void onClick(View v) {
145 | onItemClickListener.onItemClick(getAdapterPosition(), v);/////
146 | }
147 | });
148 |
149 | popupMenu.setOnClickListener(new View.OnClickListener() {
150 | @Override
151 | public void onClick(View v) {
152 | onPopupMenuClickListener.onClick(getAdapterPosition(), v);
153 | }
154 | });
155 |
156 | like.setOnClickListener(new View.OnClickListener() {
157 | @Override
158 | public void onClick(View v) {
159 | Music music = musicList.get(getAdapterPosition());
160 | music.setLiked(!music.isLiked());
161 | LikeDA likeDA = new LikeDA(activity);
162 | likeDA.openDB();
163 | if (music.isLiked()) {
164 | boolean result = likeDA.newMusicLiked(music);
165 | Log.e("add liekd", "" + result);
166 | ((MainActivity) activity).LikeChanged(getAdapterPosition(), true);
167 | } else {
168 | boolean result = likeDA.removeMusicLiked(music.getPath().toString());
169 | Log.e("remove liekd", "" + result);
170 | ((MainActivity) activity).LikeChanged(getAdapterPosition(), false);
171 | }
172 |
173 | notifyItemChanged(getAdapterPosition());
174 | }
175 | });
176 | }
177 |
178 | }
179 |
180 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
181 | this.onItemClickListener = onItemClickListener;
182 | }
183 |
184 | public interface OnItemClickListener {
185 | void onItemClick(int pos, View v);
186 | }
187 |
188 | public void setOnPopupMenuClickListener(OnClickListener onPopupMenuClickListener) {
189 | this.onPopupMenuClickListener = onPopupMenuClickListener;
190 | }
191 |
192 | public interface OnClickListener {
193 | void onClick(int pos, View v);
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Adapter/ArtistTabAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Adapter;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.media.MediaMetadataRetriever;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 | import androidx.annotation.NonNull;
13 | import androidx.recyclerview.widget.RecyclerView;
14 |
15 | import com.bumptech.glide.Glide;
16 | import com.mohammadkz.musicbox.Model.Artist;
17 | import com.mohammadkz.musicbox.R;
18 |
19 | import java.util.List;
20 |
21 | import de.hdodenhof.circleimageview.CircleImageView;
22 |
23 | public class ArtistTabAdapter extends RecyclerView.Adapter {
24 |
25 | private Context context;
26 | private List artistsListLeft, artistsListRight;
27 | public OnItemClickListener onItemClickListener;
28 |
29 | public ArtistTabAdapter(Context context, List artistsListLeft, List artistsListRight) {
30 | this.context = context;
31 | this.artistsListLeft = artistsListLeft;
32 | this.artistsListRight = artistsListRight;
33 | }
34 |
35 | @NonNull
36 | @Override
37 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
38 | View view = LayoutInflater.from(context).inflate(R.layout.artist_layout, parent, false);
39 | return new ViewHolder(view);
40 | }
41 |
42 | @Override
43 | public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
44 | if (artistsListLeft.get(position) != null) {
45 | Artist artist = artistsListLeft.get(position);
46 | holder.artistName1.setText(artist.getArtistName());
47 | try {
48 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
49 | mmr.setDataSource(artist.getArtistMusic().get(0).getPath());
50 | byte[] data = mmr.getEmbeddedPicture();
51 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
52 | Glide.with(context).load(bitmap).thumbnail(0.3f).into(holder.artistImage1);
53 | } catch (Exception e) {
54 | Glide.with(context).load(R.drawable.audio_img_white).thumbnail(0.3f).into(holder.artistImage1);
55 | }
56 | } else {
57 | holder.artistName1.setVisibility(View.INVISIBLE);
58 | holder.artistImage1.setVisibility(View.INVISIBLE);
59 | }
60 |
61 | if (artistsListRight.get(position) != null) {
62 | Artist artist = artistsListRight.get(position);
63 | holder.artistName2.setText(artist.getArtistName());
64 | try {
65 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
66 | mmr.setDataSource(artist.getArtistMusic().get(0).getPath());
67 | byte[] data = mmr.getEmbeddedPicture();
68 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
69 | Glide.with(context).load(bitmap).thumbnail(0.3f).into(holder.artistImage2);
70 | } catch (Exception e) {
71 | Glide.with(context).load(R.drawable.audio_img_white).thumbnail(0.3f).into(holder.artistImage2);
72 | }
73 | } else {
74 | holder.artistName2.setVisibility(View.INVISIBLE);
75 | holder.artistImage2.setVisibility(View.INVISIBLE);
76 | }
77 |
78 | }
79 |
80 | @Override
81 | public int getItemCount() {
82 | return artistsListLeft.size();
83 | }
84 |
85 | public class ViewHolder extends RecyclerView.ViewHolder {
86 | CircleImageView artistImage1, artistImage2;
87 | TextView artistName1, artistName2;
88 |
89 | public ViewHolder(@NonNull View itemView) {
90 | super(itemView);
91 | artistImage1 = itemView.findViewById(R.id.artistImage1);
92 | artistName1 = itemView.findViewById(R.id.artistName1);
93 |
94 | artistImage2 = itemView.findViewById(R.id.artistImage2);
95 | artistName2 = itemView.findViewById(R.id.artistName2);
96 |
97 | artistImage1.setOnClickListener(new View.OnClickListener() {
98 | @Override
99 | public void onClick(View v) {
100 | onItemClickListener.onItemClick(getAdapterPosition(), v);
101 | }
102 | });
103 |
104 | artistImage2.setOnClickListener(new View.OnClickListener() {
105 | @Override
106 | public void onClick(View v) {
107 | onItemClickListener.onItemClick(getAdapterPosition(), v);
108 | }
109 | });
110 |
111 |
112 | }
113 | }
114 |
115 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
116 | this.onItemClickListener = onItemClickListener;
117 | }
118 |
119 | public interface OnItemClickListener {
120 | void onItemClick(int pos, View v);
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Adapter/PlayListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Adapter;
2 |
3 |
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapFactory;
7 | import android.media.MediaMetadataRetriever;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import androidx.annotation.NonNull;
15 | import androidx.recyclerview.widget.RecyclerView;
16 |
17 | import com.mohammadkz.musicbox.Model.PlayList;
18 | import com.mohammadkz.musicbox.R;
19 |
20 | import java.util.List;
21 |
22 | public class PlayListAdapter extends RecyclerView.Adapter {
23 |
24 | Context context;
25 | List playList;
26 | public OnItemClickListener onItemClickListener;
27 |
28 | public PlayListAdapter(Context context, List playList) {
29 | this.context = context;
30 | this.playList = playList;
31 | }
32 |
33 | @NonNull
34 | @Override
35 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
36 | View view = LayoutInflater.from(context).inflate(R.layout.layout_play_list, parent, false);
37 | return new ViewHolder(view);
38 | }
39 |
40 | @Override
41 | public void onBindViewHolder(@NonNull PlayListAdapter.ViewHolder holder, int position) {
42 | holder.name.setText(playList.get(position).getName());
43 | if (playList.get(position).getMusicList().size() > 0)
44 | holder.numbers.setText(playList.get(position).getMusicList().size() + " songs");
45 | else
46 | holder.numbers.setText("0 songs");
47 |
48 | try {
49 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
50 | mmr.setDataSource(playList.get(position).getMusicList().get(0).getPath());
51 | byte[] data = mmr.getEmbeddedPicture();
52 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
53 | holder.img.setImageBitmap(bitmap);
54 | } catch (Exception e) {
55 | holder.img.setImageResource(R.drawable.audio_img_white);
56 | }
57 | }
58 |
59 | @Override
60 | public int getItemCount() {
61 | return playList.size();
62 | }
63 |
64 | public class ViewHolder extends RecyclerView.ViewHolder {
65 | ImageView img;
66 | TextView name, numbers;
67 |
68 | public ViewHolder(@NonNull View itemView) {
69 | super(itemView);
70 | img = itemView.findViewById(R.id.img);
71 | name = itemView.findViewById(R.id.name);
72 | numbers = itemView.findViewById(R.id.numbers);
73 |
74 | itemView.setOnClickListener(new View.OnClickListener() {
75 | @Override
76 | public void onClick(View v) {
77 | onItemClickListener.onItemClick(getAdapterPosition(), v);
78 | }
79 | });
80 |
81 | }
82 | }
83 |
84 | public interface OnItemClickListener {
85 | void onItemClick(int pos, View v);
86 | }
87 |
88 | public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
89 | this.onItemClickListener = onItemClickListener;
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/ApplicationClass.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox;
2 |
3 | import android.app.Application;
4 | import android.app.Notification;
5 | import android.app.NotificationChannel;
6 | import android.app.NotificationManager;
7 | import android.os.Build;
8 |
9 | import androidx.core.app.NotificationCompat;
10 |
11 | public class ApplicationClass extends Application {
12 |
13 | public static final String CHANNEL_ID_1 = "CHANNEL_1";
14 | public static final String CHANNEL_ID_2 = "CHANNEL_2";
15 | public static final String ACTION_PLAY = "PLAY";
16 | public static final String ACTION_NEXT = "NEXT";
17 | public static final String ACTION_PREV = "PREVIOUS";
18 | public static final String ACTION_CLOSE = "CLOSE";
19 |
20 | @Override
21 | public void onCreate() {
22 | super.onCreate();
23 | createNotificationChannel();
24 | }
25 |
26 | private void createNotificationChannel() {
27 |
28 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
29 | // channel 1
30 | NotificationChannel notificationChannel_1 = new NotificationChannel(CHANNEL_ID_1, "channel1(1)", NotificationManager.IMPORTANCE_HIGH);
31 | notificationChannel_1.setDescription("channel 1 ");
32 |
33 | // channel 2
34 | NotificationChannel notificationChannel_2 = new NotificationChannel(CHANNEL_ID_2, "channel2(2)", NotificationManager.IMPORTANCE_HIGH);
35 | notificationChannel_2.setDescription("channel 2 ");
36 | notificationChannel_2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
37 |
38 | // create notif manager
39 | NotificationManager notificationManager = getSystemService(NotificationManager.class);
40 | notificationManager.createNotificationChannel(notificationChannel_1);
41 | notificationManager.createNotificationChannel(notificationChannel_2);
42 |
43 | }
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/ArtistPlayerListFragment.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.media.MediaMetadataRetriever;
6 | import android.os.Bundle;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Button;
11 | import android.widget.TextView;
12 |
13 | import androidx.fragment.app.Fragment;
14 | import androidx.fragment.app.FragmentTransaction;
15 | import androidx.recyclerview.widget.LinearLayoutManager;
16 | import androidx.recyclerview.widget.RecyclerView;
17 |
18 | import com.mohammadkz.musicbox.Adapter.AllMusicListAdapter;
19 | import com.mohammadkz.musicbox.MainActivity;
20 | import com.mohammadkz.musicbox.Model.Artist;
21 | import com.mohammadkz.musicbox.R;
22 |
23 | import java.util.List;
24 |
25 | import de.hdodenhof.circleimageview.CircleImageView;
26 |
27 |
28 | public class ArtistPlayerListFragment extends Fragment {
29 |
30 | View view;
31 | CircleImageView artistImage;
32 | TextView numbers, artistName;
33 | RecyclerView list;
34 | Artist artist;
35 | Button back;
36 | List artistList;
37 | boolean firstTime = true;
38 |
39 | public ArtistPlayerListFragment(Artist artist, List artistList) {
40 | // Required empty public constructor
41 | this.artist = artist;
42 | this.artistList = artistList;
43 | }
44 |
45 |
46 | @Override
47 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
48 | Bundle savedInstanceState) {
49 | // Inflate the layout for this fragment
50 | view = inflater.inflate(R.layout.fragment_artist_player_list, container, false);
51 |
52 | initViews();
53 | controllerViews();
54 | setValue();
55 |
56 | return view;
57 | }
58 |
59 | private void initViews() {
60 | artistImage = view.findViewById(R.id.artistImage);
61 | artistName = view.findViewById(R.id.artistName);
62 | numbers = view.findViewById(R.id.numbers);
63 | list = view.findViewById(R.id.list);
64 | back = view.findViewById(R.id.backBtn);
65 | }
66 |
67 | private void setValue() {
68 | artistName.setText(artist.getArtistName());
69 |
70 | numbers.setText(artist.getArtistMusic().size() + " songs");
71 |
72 | try {
73 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
74 | mmr.setDataSource(artist.getArtistMusic().get(0).getPath());
75 | byte[] data = mmr.getEmbeddedPicture();
76 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
77 | artistImage.setImageBitmap(bitmap);
78 | } catch (Exception e) {
79 | e.getMessage();
80 | artistImage.setImageResource(R.drawable.audio_img_white);
81 | }
82 |
83 | setAdapter();
84 | }
85 |
86 | private void controllerViews() {
87 | back.setOnClickListener(new View.OnClickListener() {
88 | @Override
89 | public void onClick(View v) {
90 | ArtistTabFragment artistTabFragment = new ArtistTabFragment(artistList);
91 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
92 | fragmentTransaction.replace(R.id.frameLayout, artistTabFragment).commit();
93 | }
94 | });
95 | }
96 |
97 | private void setAdapter() {
98 |
99 | AllMusicListAdapter allMusicListAdapter = new AllMusicListAdapter(getContext(), artist.getArtistMusic(), getActivity(), false);
100 | list.setHasFixedSize(true);
101 | list.setLayoutManager(new LinearLayoutManager(view.getContext()));
102 | list.setAdapter(allMusicListAdapter);
103 |
104 | allMusicListAdapter.setOnItemClickListener(new AllMusicListAdapter.OnItemClickListener() {
105 | @Override
106 | public void onItemClick(int pos, View v) {
107 | if (firstTime) {
108 | ((MainActivity) getActivity()).setPlayList_toPlay(artist.getArtistMusic());
109 | firstTime = false;
110 | }
111 | ((MainActivity) getActivity()).playAudio(pos, getContext());
112 |
113 | }
114 | });
115 |
116 | }
117 |
118 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/ArtistTabFragment.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.fragment.app.Fragment;
6 | import androidx.fragment.app.FragmentManager;
7 | import androidx.fragment.app.FragmentTransaction;
8 | import androidx.recyclerview.widget.LinearLayoutManager;
9 | import androidx.recyclerview.widget.RecyclerView;
10 |
11 | import android.text.Editable;
12 | import android.text.TextWatcher;
13 | import android.util.Log;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.EditText;
18 |
19 | import com.mohammadkz.musicbox.Adapter.ArtistTabAdapter;
20 | import com.mohammadkz.musicbox.Model.Artist;
21 | import com.mohammadkz.musicbox.Model.Music;
22 | import com.mohammadkz.musicbox.R;
23 |
24 | import java.util.ArrayList;
25 | import java.util.List;
26 |
27 | public class ArtistTabFragment extends Fragment {
28 |
29 | View view;
30 | RecyclerView listLeft;
31 |
32 | List artistList;
33 | ArrayList artistsLeft, artistsRight;
34 |
35 | public ArtistTabFragment(List artistList) {
36 | // Required empty public constructor
37 | this.artistList = artistList;
38 | }
39 |
40 |
41 | @Override
42 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
43 | Bundle savedInstanceState) {
44 | // Inflate the layout for this fragment
45 | view = inflater.inflate(R.layout.fragment_artist_tab, container, false);
46 |
47 | initViews();
48 | controllerViews();
49 | setArtistList();
50 | setAdapter();
51 |
52 | return view;
53 | }
54 |
55 | private void initViews() {
56 | listLeft = view.findViewById(R.id.list_left);
57 |
58 | artistsLeft = new ArrayList<>();
59 | artistsRight = new ArrayList<>();
60 | }
61 |
62 | private void controllerViews() {
63 |
64 | }
65 |
66 | private void setArtistList() {
67 |
68 | for (int i = 1; i <= artistList.size(); i++) {
69 |
70 | if (i % 2 == 0) {
71 | artistsLeft.add(artistList.get(i - 1));
72 | } else {
73 | artistsRight.add(artistList.get(i - 1));
74 | }
75 |
76 | }
77 |
78 | }
79 |
80 | private void setAdapter() {
81 | ArtistTabAdapter artistTabAdapter = new ArtistTabAdapter(getContext(), artistsLeft, artistsRight);
82 | listLeft.setHasFixedSize(true);
83 | listLeft.setLayoutManager(new LinearLayoutManager(view.getContext()));
84 |
85 | listLeft.setAdapter(artistTabAdapter);
86 |
87 | artistTabAdapter.setOnItemClickListener(new ArtistTabAdapter.OnItemClickListener() {
88 | @Override
89 | public void onItemClick(int pos, View v) {
90 |
91 | switch (v.getId()) {
92 | case R.id.artistImage1:
93 | Log.e("a", "1-" + pos);
94 | startForLeft(pos);
95 | break;
96 |
97 | case R.id.artistImage2:
98 | Log.e("a", "2-" + pos);
99 | startForRight(pos);
100 | break;
101 | }
102 | Log.e("a", "" + pos);
103 | }
104 | });
105 |
106 | }
107 |
108 | private void startForRight(int pos) {
109 | ArtistPlayerListFragment artistPlayerListFragment = new ArtistPlayerListFragment(artistsRight.get(pos), artistList);
110 | FragmentManager fragmentManager = getFragmentManager();
111 | fragmentManager.beginTransaction()
112 | .replace(R.id.frameLayout, artistPlayerListFragment)
113 | .addToBackStack(null) // name can be null
114 | .commit();
115 |
116 | }
117 |
118 | private void startForLeft(int pos) {
119 | ArtistPlayerListFragment artistPlayerListFragment = new ArtistPlayerListFragment(artistsLeft.get(pos), artistList);
120 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
121 | fragmentTransaction.replace(R.id.frameLayout, artistPlayerListFragment, null)
122 | .setReorderingAllowed(true)
123 | .addToBackStack("artistTab")
124 | .commit();
125 | ;
126 | }
127 |
128 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/BottomSheetAddMusic_playList.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ArrayAdapter;
11 | import android.widget.Button;
12 | import android.widget.Toast;
13 |
14 | import androidx.annotation.NonNull;
15 | import androidx.appcompat.app.AppCompatActivity;
16 | import androidx.fragment.app.Fragment;
17 | import androidx.fragment.app.FragmentTransaction;
18 | import androidx.recyclerview.widget.LinearLayoutManager;
19 | import androidx.recyclerview.widget.RecyclerView;
20 |
21 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
22 | import com.mohammadkz.musicbox.Adapter.AddMusicAdapter;
23 | import com.mohammadkz.musicbox.Adapter.AllMusicListAdapter;
24 | import com.mohammadkz.musicbox.MainActivity;
25 | import com.mohammadkz.musicbox.Model.Music;
26 | import com.mohammadkz.musicbox.Model.PlayList;
27 | import com.mohammadkz.musicbox.Model.PlayListDA;
28 | import com.mohammadkz.musicbox.R;
29 |
30 | import java.util.ArrayList;
31 | import java.util.List;
32 |
33 | import javax.security.auth.callback.Callback;
34 |
35 | public class BottomSheetAddMusic_playList extends BottomSheetDialogFragment {
36 |
37 | View view;
38 | RecyclerView list;
39 | List musicList;
40 | PlayList playLists;
41 | List wantList = new ArrayList<>();
42 | Button done;
43 |
44 | public BottomSheetAddMusic_playList(List musicList, PlayList playLists) {
45 | this.musicList = musicList;
46 | this.playLists = playLists;
47 | }
48 |
49 | @Override
50 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
51 | Bundle savedInstanceState) {
52 | // Inflate the layout for this fragment
53 | view = inflater.inflate(R.layout.bottom_sheet_add_to_playlist, container, false);
54 |
55 | initViews();
56 | controllerView();
57 | setAdapter();
58 |
59 | return view;
60 | }
61 |
62 | private void initViews() {
63 | list = view.findViewById(R.id.list);
64 | done = view.findViewById(R.id.done);
65 | }
66 |
67 | private void controllerView() {
68 | done.setOnClickListener(new View.OnClickListener() {
69 | @Override
70 | public void onClick(View v) {
71 | addNewMusic();
72 | }
73 | });
74 | }
75 |
76 | private void setAdapter() {
77 | AddMusicAdapter addMusicAdapter = new AddMusicAdapter(getContext(), musicList);
78 | list.setHasFixedSize(true);
79 | list.setLayoutManager(new LinearLayoutManager(view.getContext()));
80 | list.setAdapter(addMusicAdapter);
81 |
82 | addMusicAdapter.setOnItemClickListener(new AddMusicAdapter.OnItemClickListener() {
83 | @Override
84 | public void onItemClick(int pos, View v, Boolean c) {
85 | if (c) {
86 | wantList.add(musicList.get(pos));
87 | } else {
88 |
89 | }
90 | }
91 | });
92 |
93 | }
94 |
95 | private void addNewMusic() {
96 | PlayListDA playListDA = new PlayListDA(getActivity());
97 | playListDA.openDB();
98 |
99 | boolean check = playListDA.newMusic_playList(wantList, playLists.getName());
100 |
101 |
102 | if (check) {
103 | playLists.getMusicList().addAll(wantList);
104 | super.dismiss();
105 | } else {
106 | Toast.makeText(getContext(), "please try again. can't add music to play list ", Toast.LENGTH_SHORT).show();
107 | }
108 |
109 | }
110 |
111 | @Override
112 | public void onDismiss(@NonNull DialogInterface dialog) {
113 | super.onDismiss(dialog);
114 |
115 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
116 | PlayListMusicFragment playListMusicFragment = new PlayListMusicFragment(playLists , musicList);
117 | fragmentTransaction.replace(R.id.frameLayout , playListMusicFragment).commit();
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/LikeFragment.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.content.Intent;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.PopupMenu;
12 | import android.widget.Toast;
13 |
14 | import androidx.fragment.app.Fragment;
15 | import androidx.recyclerview.widget.LinearLayoutManager;
16 | import androidx.recyclerview.widget.RecyclerView;
17 |
18 | import com.mohammadkz.musicbox.Adapter.AllMusicListAdapter;
19 | import com.mohammadkz.musicbox.MainActivity;
20 | import com.mohammadkz.musicbox.Model.Music;
21 | import com.mohammadkz.musicbox.R;
22 |
23 | import java.io.File;
24 | import java.util.List;
25 |
26 | public class LikeFragment extends Fragment {
27 | View view;
28 | List musicList, likedList;
29 | RecyclerView list;
30 | boolean firstTime = true;
31 |
32 | public LikeFragment(List musicList, List likedList) {
33 | this.musicList = musicList;
34 | this.likedList = likedList;
35 | }
36 |
37 | @Override
38 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
39 | Bundle savedInstanceState) {
40 | // Inflate the layout for this fragment
41 | view = inflater.inflate(R.layout.fragment_like, container, false);
42 |
43 | initViews();
44 | controllerViews();
45 | setAdapter();
46 |
47 | return view;
48 | }
49 |
50 | private void initViews() {
51 | list = view.findViewById(R.id.favouritsList);
52 | }
53 |
54 | private void controllerViews() {
55 |
56 | }
57 |
58 | private void setAdapter() {
59 |
60 | AllMusicListAdapter allMusicListAdapter = new AllMusicListAdapter(getContext(), likedList, getActivity(), true);
61 | list.setHasFixedSize(true);
62 | list.setLayoutManager(new LinearLayoutManager(view.getContext()));
63 | list.setAdapter(allMusicListAdapter);
64 |
65 | allMusicListAdapter.setOnItemClickListener(new AllMusicListAdapter.OnItemClickListener() {
66 | @Override
67 | public void onItemClick(int pos, View v) {
68 | if (firstTime) {
69 | ((MainActivity) getActivity()).setPlayList_toPlay(likedList);
70 | firstTime = false;
71 | }
72 | ((MainActivity) getActivity()).playAudio(pos, getContext());
73 | }
74 | });
75 |
76 | allMusicListAdapter.setOnPopupMenuClickListener(new AllMusicListAdapter.OnClickListener() {
77 | @Override
78 | public void onClick(int pos, View v) {
79 | if (v.getId() == R.id.popupMenu) {
80 | //Creating the instance of PopupMenu
81 | PopupMenu popup = new PopupMenu(getContext(), v.findViewById(R.id.popupMenu));
82 | //Inflating the Popup using xml file
83 | popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
84 | //registering popup with OnMenuItemClickListener
85 | popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
86 | public boolean onMenuItemClick(MenuItem item) {
87 | Toast.makeText(getContext(), "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show();
88 | // ((MainActivity) v.getContext()).setPlayMusic(1, context);
89 | switch (item.getItemId()) {
90 | case R.id.delete_media:
91 | boolean check = deleteMedia(pos);
92 | Log.i("delete log", " " + check);
93 | break;
94 |
95 | case R.id.play_next:
96 | ((MainActivity) v.getContext()).playNext(pos);
97 | break;
98 |
99 | case R.id.song_info:
100 | SheetBottomMusicInfo sheetBottomMusicInfo = new SheetBottomMusicInfo(musicList.get(pos));
101 | sheetBottomMusicInfo.show(getFragmentManager(), "music");
102 | break;
103 |
104 | case R.id.shareMusic:
105 | shareAudio(musicList.get(pos).getPath());
106 | break;
107 |
108 | default:
109 | Toast.makeText(getContext(), "Sorry try again later", Toast.LENGTH_SHORT).show();
110 | break;
111 | }
112 |
113 | return true;
114 | }
115 | });
116 |
117 | popup.show(); //showing popup menu
118 |
119 | }
120 | }
121 | });
122 |
123 | }
124 |
125 | private boolean deleteMedia(int pos) {
126 |
127 | try {
128 | File file = new File(musicList.get(pos).getPath().toString());
129 | boolean deleted = file.delete();
130 | deleteItem(pos);
131 | return deleted;
132 | } catch (Exception e) {
133 | System.out.println(e.getMessage());
134 | return false;
135 | }
136 |
137 | }
138 |
139 | public void deleteItem(int pos) {
140 | ((MainActivity) getActivity()).deleteItem(pos);
141 | musicList.remove(pos);
142 | refreshTable();
143 | }
144 |
145 | private void refreshTable() {
146 | setAdapter();
147 | }
148 |
149 | public void shareAudio(String path) {
150 | try {
151 | Intent shareMedia = new Intent(Intent.ACTION_SEND);
152 |
153 | shareMedia.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
154 | //set application package
155 | shareMedia.setType("audio/*");
156 | //set path of media file in ExternalStorage.
157 | shareMedia.putExtra(Intent.EXTRA_STREAM, Uri.parse(path));
158 | startActivity(Intent.createChooser(shareMedia, "Share audio File"));
159 |
160 | Toast.makeText(getContext(), "Song Shared Successfully", Toast.LENGTH_SHORT).show();
161 | } catch (Exception e) {
162 | Toast.makeText(getContext(), "Song Shared Unsuccessfully", Toast.LENGTH_SHORT).show();
163 |
164 | }
165 | }
166 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/PlayListFragment.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.DialogInterface;
5 | import android.os.Bundle;
6 |
7 | import androidx.fragment.app.Fragment;
8 | import androidx.fragment.app.FragmentTransaction;
9 | import androidx.recyclerview.widget.LinearLayoutManager;
10 | import androidx.recyclerview.widget.RecyclerView;
11 |
12 | import android.text.InputType;
13 | import android.util.Log;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.EditText;
18 | import android.widget.Toast;
19 |
20 | import com.google.android.material.bottomsheet.BottomSheetDialog;
21 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
22 | import com.mohammadkz.musicbox.Adapter.AllMusicListAdapter;
23 | import com.mohammadkz.musicbox.Adapter.PlayListAdapter;
24 | import com.mohammadkz.musicbox.MainActivity;
25 | import com.mohammadkz.musicbox.Model.Music;
26 | import com.mohammadkz.musicbox.Model.PlayList;
27 | import com.mohammadkz.musicbox.Model.PlayListDA;
28 | import com.mohammadkz.musicbox.R;
29 |
30 | import java.util.List;
31 |
32 | public class PlayListFragment extends Fragment {
33 |
34 | View view;
35 | RecyclerView list;
36 | FloatingActionButton newPlayList;
37 | List playLists;
38 |
39 | PlayListDA playListDA;
40 | List musicList;
41 |
42 | public PlayListFragment(List musicList) {
43 | this.musicList = musicList;
44 | }
45 |
46 | @Override
47 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
48 | Bundle savedInstanceState) {
49 | // Inflate the layout for this fragment
50 | view = inflater.inflate(R.layout.fragment_play_list, container, false);
51 |
52 | playListDA = new PlayListDA(getActivity());
53 | playListDA.openDB();
54 |
55 | initViews();
56 | controllerViews();
57 |
58 | getPlayList();
59 |
60 | return view;
61 | }
62 |
63 | private void initViews() {
64 | list = view.findViewById(R.id.list);
65 | newPlayList = view.findViewById(R.id.newPlayList);
66 | }
67 |
68 | private void controllerViews() {
69 | newPlayList.setOnClickListener(new View.OnClickListener() {
70 | @Override
71 | public void onClick(View v) {
72 | alertDialog();
73 | }
74 | });
75 | }
76 |
77 | private void addPlayList(String name) {
78 | boolean result = playListDA.newPlayList(name);
79 |
80 | if (result) {
81 | getPlayList();
82 | } else {
83 |
84 | }
85 |
86 | }
87 |
88 | // get play list name from user
89 | private void alertDialog() {
90 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
91 | builder.setTitle("play list name");
92 |
93 | // Set up the input
94 | final EditText input = new EditText(getContext());
95 | // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
96 | input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
97 | builder.setView(input);
98 |
99 | // Set up the buttons
100 | builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
101 | @Override
102 | public void onClick(DialogInterface dialog, int which) {
103 | Toast.makeText(getContext(), input.getText().toString(), Toast.LENGTH_LONG).show();
104 | if (!input.getText().toString().equals("playList")) {
105 | addPlayList(input.getText().toString());
106 | }
107 | }
108 | });
109 | builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
110 | @Override
111 | public void onClick(DialogInterface dialog, int which) {
112 | dialog.cancel();
113 | }
114 | });
115 |
116 | builder.show();
117 | }
118 |
119 | private void getPlayList() {
120 | playLists = null;
121 | playLists = playListDA.getPlayList();
122 | if (playLists != null) {
123 | setAdapter();
124 | }
125 | }
126 |
127 | private void setAdapter() {
128 | PlayListAdapter playListAdapter = new PlayListAdapter(getContext(), playLists);
129 | list.setHasFixedSize(true);
130 | list.setLayoutManager(new LinearLayoutManager(view.getContext()));
131 | list.setAdapter(playListAdapter);
132 |
133 | playListAdapter.setOnItemClickListener(new PlayListAdapter.OnItemClickListener() {
134 | @Override
135 | public void onItemClick(int pos, View v) {
136 | itemClick(playLists.get(pos));
137 | }
138 | });
139 | }
140 |
141 | private void itemClick(PlayList playList) {
142 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
143 | PlayListMusicFragment playListMusicFragment = new PlayListMusicFragment(playList, musicList);
144 | fragmentTransaction.replace(R.id.frameLayout, playListMusicFragment).commit();
145 | }
146 |
147 | public void refresh(){
148 | Log.e("test" , "refreshed");
149 | }
150 |
151 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/PlayListMusicFragment.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.content.DialogInterface;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.media.MediaMetadataRetriever;
7 | import android.os.Bundle;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.Button;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import androidx.fragment.app.Fragment;
17 | import androidx.fragment.app.FragmentTransaction;
18 | import androidx.recyclerview.widget.LinearLayoutManager;
19 | import androidx.recyclerview.widget.RecyclerView;
20 |
21 | import com.google.android.material.dialog.MaterialAlertDialogBuilder;
22 | import com.google.android.material.floatingactionbutton.FloatingActionButton;
23 | import com.mohammadkz.musicbox.Adapter.AllMusicListAdapter;
24 | import com.mohammadkz.musicbox.MainActivity;
25 | import com.mohammadkz.musicbox.Model.Music;
26 | import com.mohammadkz.musicbox.Model.PlayList;
27 | import com.mohammadkz.musicbox.Model.PlayListDA;
28 | import com.mohammadkz.musicbox.R;
29 |
30 | import java.util.List;
31 |
32 | public class PlayListMusicFragment extends Fragment {
33 | View view;
34 | PlayList playList;
35 | FloatingActionButton addMusic;
36 | List musicList;
37 | RecyclerView list;
38 | ImageView img, delete;
39 | TextView playListName, numbers;
40 | BottomSheetAddMusic_playList bottomSheetAddMusic_playList;
41 | Button backBtn;
42 | boolean firstTime = true;
43 |
44 | public PlayListMusicFragment(PlayList playList, List musicList) {
45 | // Required empty public constructor
46 | this.playList = playList;
47 | this.musicList = musicList;
48 | }
49 |
50 | @Override
51 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
52 | Bundle savedInstanceState) {
53 | // Inflate the layout for this fragment
54 | view = inflater.inflate(R.layout.fragment_play_list_music, container, false);
55 |
56 | initViews();
57 | controllerViews();
58 | setValue();
59 |
60 | return view;
61 | }
62 |
63 | private void initViews() {
64 | addMusic = view.findViewById(R.id.newMusic);
65 | list = view.findViewById(R.id.list);
66 | img = view.findViewById(R.id.img);
67 | playListName = view.findViewById(R.id.playListName);
68 | numbers = view.findViewById(R.id.numbers);
69 | delete = view.findViewById(R.id.delete);
70 | backBtn = view.findViewById(R.id.backBtn);
71 | }
72 |
73 | private void controllerViews() {
74 | addMusic.setOnClickListener(new View.OnClickListener() {
75 | @Override
76 | public void onClick(View v) {
77 | addMusic();
78 | }
79 | });
80 |
81 | delete.setOnClickListener(new View.OnClickListener() {
82 | @Override
83 | public void onClick(View v) {
84 |
85 | try {
86 | MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
87 | builder.setTitle("remove play list");
88 | builder.setMessage("are you sure you want to remove the play list?");
89 |
90 | // have one btn ==> close
91 | builder.setPositiveButton("no", new DialogInterface.OnClickListener() {
92 | @Override
93 | public void onClick(DialogInterface dialog, int which) {
94 | dialog.dismiss();
95 | }
96 | });
97 |
98 | builder.setNegativeButton("yes", new DialogInterface.OnClickListener() {
99 | @Override
100 | public void onClick(DialogInterface dialog, int which) {
101 | deletePlayList();
102 | }
103 | });
104 |
105 | builder.show();
106 | } catch (Exception e) {
107 | e.getMessage();
108 | }
109 |
110 | }
111 | });
112 |
113 | backBtn.setOnClickListener(new View.OnClickListener() {
114 | @Override
115 | public void onClick(View v) {
116 | PlayListFragment playListFragment = new PlayListFragment(musicList);
117 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
118 | fragmentTransaction.replace(R.id.frameLayout, playListFragment).commit();
119 | }
120 | });
121 | }
122 |
123 | private void addMusic() {
124 | bottomSheetAddMusic_playList = new BottomSheetAddMusic_playList(musicList, playList);
125 | bottomSheetAddMusic_playList.show(getFragmentManager(), "tag");
126 | }
127 |
128 | private void setValue() {
129 |
130 | if (playList.getMusicList().size() > 0) {
131 | try {
132 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
133 | mmr.setDataSource(playList.getMusicList().get(0).getPath());
134 | byte[] data = mmr.getEmbeddedPicture();
135 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
136 | img.setImageBitmap(bitmap);
137 | } catch (Exception e) {
138 | e.getMessage();
139 | img.setImageResource(R.drawable.audio_img_white);
140 | }
141 |
142 | }
143 |
144 | playListName.setText(playList.getName());
145 | numbers.setText(playList.getMusicList().size() + " songs");
146 |
147 | setAdapter();
148 | }
149 |
150 | private void setAdapter() {
151 |
152 | AllMusicListAdapter allMusicListAdapter = new AllMusicListAdapter(getContext(), playList.getMusicList(), getActivity(), false);
153 | list.setHasFixedSize(true);
154 | list.setLayoutManager(new LinearLayoutManager(view.getContext()));
155 | list.setAdapter(allMusicListAdapter);
156 |
157 | allMusicListAdapter.setOnItemClickListener(new AllMusicListAdapter.OnItemClickListener() {
158 | @Override
159 | public void onItemClick(int pos, View v) {
160 | if (firstTime) {
161 | ((MainActivity) getActivity()).setPlayList_toPlay(playList.getMusicList());
162 | firstTime = false;
163 | }
164 | ((MainActivity) getActivity()).playAudio(pos, getContext());
165 |
166 | }
167 | });
168 | }
169 |
170 | private void deletePlayList() {
171 | PlayListDA playListDA = new PlayListDA(getActivity());
172 | playListDA.openDB();
173 | boolean result = playListDA.deletePlayList(playList);
174 | if (result) {
175 | Toast.makeText(getActivity(), "removed", Toast.LENGTH_SHORT).show();
176 |
177 | PlayListFragment playListFragment = new PlayListFragment(musicList);
178 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
179 | fragmentTransaction.replace(R.id.frameLayout, playListFragment).commit();
180 |
181 | } else
182 | Toast.makeText(getActivity(), "cant remoed", Toast.LENGTH_SHORT).show();
183 |
184 | }
185 |
186 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/SearchFragment.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.fragment.app.Fragment;
6 |
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.mohammadkz.musicbox.R;
12 |
13 |
14 | public class SearchFragment extends Fragment {
15 |
16 | View view;
17 |
18 | public SearchFragment() {
19 | // Required empty public constructor
20 | }
21 |
22 |
23 | @Override
24 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
25 | Bundle savedInstanceState) {
26 | // Inflate the layout for this fragment
27 | view = inflater.inflate(R.layout.fragment_search, container, false);
28 |
29 | return view;
30 | }
31 |
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/SearchTabFragment.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.fragment.app.Fragment;
6 | import androidx.recyclerview.widget.LinearLayoutManager;
7 | import androidx.recyclerview.widget.RecyclerView;
8 |
9 | import android.text.Editable;
10 | import android.text.TextWatcher;
11 | import android.util.Log;
12 | import android.view.LayoutInflater;
13 | import android.view.MenuItem;
14 | import android.view.View;
15 | import android.view.ViewGroup;
16 | import android.widget.EditText;
17 | import android.widget.PopupMenu;
18 | import android.widget.Toast;
19 |
20 | import com.mohammadkz.musicbox.Adapter.AllMusicListAdapter;
21 | import com.mohammadkz.musicbox.MainActivity;
22 | import com.mohammadkz.musicbox.Model.Music;
23 | import com.mohammadkz.musicbox.R;
24 |
25 | import java.io.File;
26 | import java.util.ArrayList;
27 | import java.util.List;
28 |
29 |
30 | public class SearchTabFragment extends Fragment {
31 | View view;
32 |
33 | EditText search;
34 | RecyclerView list;
35 | List musicList;
36 | ArrayList searched;
37 |
38 |
39 | public SearchTabFragment(List musicList) {
40 | // Required empty public constructor
41 | this.musicList = musicList;
42 | }
43 |
44 |
45 | @Override
46 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
47 | Bundle savedInstanceState) {
48 | // Inflate the layout for this fragment
49 | view = inflater.inflate(R.layout.fragment_search_tab, container, false);
50 |
51 | initViews();
52 | controllerViews();
53 |
54 | return view;
55 | }
56 |
57 | private void initViews() {
58 | search = view.findViewById(R.id.search);
59 | list = view.findViewById(R.id.list);
60 | }
61 |
62 | private void controllerViews() {
63 | search.addTextChangedListener(new TextWatcher() {
64 | @Override
65 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
66 |
67 | }
68 |
69 | @Override
70 | public void onTextChanged(CharSequence s, int start, int before, int count) {
71 | searched = new ArrayList<>();
72 | for (int i = 0; i < musicList.size(); i++) {
73 | if (musicList.get(i).getName().toLowerCase().contains(search.getText().toString().toLowerCase())) {
74 | searched.add(musicList.get(i));
75 | }
76 | }
77 | setAdapter();
78 | }
79 |
80 | @Override
81 | public void afterTextChanged(Editable s) {
82 |
83 | }
84 | });
85 | }
86 |
87 | private void setAdapter() {
88 | AllMusicListAdapter allMusicListAdapter = new AllMusicListAdapter(getContext(), searched, getActivity() , false);
89 | list.setHasFixedSize(true);
90 | list.setLayoutManager(new LinearLayoutManager(view.getContext()));
91 | list.setAdapter(allMusicListAdapter);
92 |
93 |
94 | allMusicListAdapter.setOnItemClickListener(new AllMusicListAdapter.OnItemClickListener() {
95 | @Override
96 | public void onItemClick(int pos, View v) {
97 |
98 | pos = musicList.indexOf(searched.get(pos));
99 |
100 | ((MainActivity) getActivity()).playAudio(pos, getContext());
101 | }
102 | });
103 |
104 | allMusicListAdapter.setOnPopupMenuClickListener(new AllMusicListAdapter.OnClickListener() {
105 | @Override
106 | public void onClick(int pos, View v) {
107 | if (v.getId() == R.id.popupMenu) {
108 | //Creating the instance of PopupMenu
109 | PopupMenu popup = new PopupMenu(getContext(), v.findViewById(R.id.popupMenu));
110 | //Inflating the Popup using xml file
111 | popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());
112 | //registering popup with OnMenuItemClickListener
113 | popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
114 | public boolean onMenuItemClick(MenuItem item) {
115 | Toast.makeText(getContext(), "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show();
116 | // ((MainActivity) v.getContext()).setPlayMusic(1, context);
117 | switch (item.getItemId()) {
118 | case R.id.delete_media:
119 | boolean check = deleteMedia(pos);
120 | Log.i("delete log", " " + check);
121 | break;
122 |
123 | case R.id.play_next:
124 | ((MainActivity) v.getContext()).playNext(pos);
125 | break;
126 |
127 | default:
128 | Toast.makeText(getContext(), "Sorry try again later", Toast.LENGTH_SHORT).show();
129 | break;
130 | }
131 |
132 | return true;
133 | }
134 | });
135 |
136 | popup.show(); //showing popup menu
137 |
138 | }
139 | }
140 | });
141 | }
142 |
143 | private boolean deleteMedia(int pos) {
144 |
145 | try {
146 | File file = new File(musicList.get(pos).getPath().toString());
147 | boolean deleted = file.delete();
148 | deleteItem(pos);
149 | return deleted;
150 | } catch (Exception e) {
151 | System.out.println(e.getMessage());
152 | return false;
153 | }
154 |
155 | }
156 |
157 | public void deleteItem(int pos) {
158 | ((MainActivity) getActivity()).deleteItem(pos);
159 | musicList.remove(pos);
160 | refreshTable();
161 | }
162 |
163 | private void refreshTable() {
164 | setAdapter();
165 | }
166 |
167 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Fragment/SheetBottomMusicInfo.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Fragment;
2 |
3 |
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapFactory;
6 | import android.graphics.ImageDecoder;
7 | import android.media.MediaMetadataRetriever;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.Button;
14 |
15 | import androidx.annotation.NonNull;
16 | import androidx.annotation.Nullable;
17 |
18 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
19 | import com.google.android.material.textfield.TextInputEditText;
20 | import com.google.android.material.textfield.TextInputLayout;
21 | import com.mohammadkz.musicbox.Model.Music;
22 | import com.mohammadkz.musicbox.R;
23 | import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
24 |
25 | import de.hdodenhof.circleimageview.CircleImageView;
26 |
27 | public class SheetBottomMusicInfo extends BottomSheetDialogFragment {
28 |
29 | View view;
30 | Music music;
31 | CircleImageView musicImg;
32 | TextInputEditText musicName , musicArtist , musicDuration , musicAlbum;
33 | TextInputLayout musicName_layout;
34 | Button close;
35 |
36 |
37 | public SheetBottomMusicInfo(Music music) {
38 | this.music = music;
39 | }
40 |
41 | @Override
42 | public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
43 | view = inflater.inflate(R.layout.sheet_bottom_music_info, container, false);
44 |
45 | initViews();
46 | controllerViews();
47 | setValue();
48 |
49 | return view;
50 | }
51 |
52 | private void initViews(){
53 | musicImg =view.findViewById(R.id.musicImg);
54 | musicName=view.findViewById(R.id.musicName);
55 | musicArtist=view.findViewById(R.id.musicArtist);
56 | musicDuration=view.findViewById(R.id.musicDuration);
57 | musicAlbum=view.findViewById(R.id.musicAlbum);
58 | musicName_layout=view.findViewById(R.id.musicName_layout);
59 | close=view.findViewById(R.id.close);
60 |
61 | }
62 |
63 | private void controllerViews(){
64 | close.setOnClickListener(new View.OnClickListener() {
65 | @Override
66 | public void onClick(View v) {
67 | SheetBottomMusicInfo.super.dismiss();
68 | }
69 | });
70 | }
71 |
72 | private void setValue(){
73 | try {
74 | MediaMetadataRetriever mmr = new MediaMetadataRetriever();
75 | mmr.setDataSource(music.getPath());
76 | byte[] data = mmr.getEmbeddedPicture();
77 | Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, mmr.getEmbeddedPicture().length);
78 | musicImg.setImageBitmap(bitmap);
79 | }catch (Exception e){
80 | e.getMessage();
81 | musicImg.setImageResource(R.drawable.audio_img_white);
82 | }
83 |
84 |
85 | musicName.setText(music.getName());
86 | musicArtist.setText(music.getArtist());
87 | if (music.getAlbum() != null){
88 | musicAlbum.setText(music.getAlbum());
89 | }else
90 | musicAlbum.setVisibility(View.GONE);
91 | musicDuration.setText(timerConversion(Integer.parseInt(music.getDuration())));
92 | }
93 |
94 | //set the time to the txt
95 | private String timerConversion(int duration) {
96 |
97 | Long time = Long.valueOf(duration);
98 | int mns = (int) ((time / 60000) % 60000);
99 | int scs = (int) (time % 60000 / 1000);
100 | Log.e("TIME", " " + mns + ":" + scs);
101 |
102 | if (scs <10){
103 | return mns+":0" + scs;
104 | }else
105 | return mns+":" + scs;
106 |
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Model/ActionPlaying.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Model;
2 |
3 | public interface ActionPlaying {
4 | void next();
5 |
6 | void prev();
7 |
8 | void play();
9 |
10 | void close();
11 |
12 | Music music();
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Model/Artist.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Model;
2 |
3 | import java.util.ArrayList;
4 |
5 | public class Artist {
6 | String artistName;
7 | ArrayList artistMusic;
8 |
9 | public Artist(String artistName, ArrayList artistMusic) {
10 | this.artistName = artistName;
11 | this.artistMusic = artistMusic;
12 | }
13 |
14 | public Artist() {
15 |
16 | }
17 |
18 | public String getArtistName() {
19 | return artistName;
20 | }
21 |
22 | public void setArtistName(String artistName) {
23 | this.artistName = artistName;
24 | }
25 |
26 | public ArrayList getArtistMusic() {
27 | return artistMusic;
28 | }
29 |
30 | public void setArtistMusic(ArrayList artistMusic) {
31 | this.artistMusic = artistMusic;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Model/DB.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Model;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 | import android.database.sqlite.SQLiteOpenHelper;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | class DB extends SQLiteOpenHelper {
10 |
11 | public static final int DB_VERSION = 5;
12 |
13 | public DB(Context context) {
14 | super(context, "like", null, DB_VERSION);
15 | }
16 |
17 | @Override
18 | public void onCreate(SQLiteDatabase db) {
19 |
20 | String sql_like = "create table like ( Path Text , musicName Text )";
21 | db.execSQL(sql_like);
22 |
23 | String sql_playList = "create table playList (name Text)";
24 | db.execSQL(sql_playList);
25 | }
26 |
27 | @Override
28 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
29 | db.execSQL("DROP TABLE IF EXISTS like");
30 | db.execSQL("DROP TABLE IF EXISTS playList");
31 |
32 | onCreate(db);
33 | }
34 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Model/LikeDA.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Model;
2 |
3 | import android.app.Activity;
4 | import android.database.Cursor;
5 | import android.database.sqlite.SQLiteDatabase;
6 | import android.net.Uri;
7 | import android.util.Log;
8 |
9 | import java.util.ArrayList;
10 | import java.util.Collections;
11 | import java.util.Comparator;
12 | import java.util.List;
13 |
14 | public class LikeDA {
15 | private DB sqliteDB;
16 | private SQLiteDatabase database;
17 |
18 | public static final String path = "Path";
19 |
20 | public LikeDA(Activity context) {
21 | sqliteDB = new DB(context);
22 | }
23 |
24 | public void openDB() {
25 | database = sqliteDB.getWritableDatabase();
26 | }
27 |
28 | public void closeDB() {
29 | database.close();
30 | }
31 |
32 | public boolean newMusicLiked(Music music) {
33 | try {
34 |
35 | database.execSQL("INSERT INTO 'like' VALUES ('" + music.getPath() + "' , '" + music.getName() + "' )");
36 | return true;
37 | } catch (Exception e) {
38 | e.getMessage();
39 | return false;
40 | }
41 | }
42 |
43 | public List getAllLiked(ArrayList musicList) {
44 | try {
45 | Cursor cursor = database.rawQuery("SELECT Path FROM like", null);
46 |
47 | ArrayList musicArrayList = new ArrayList<>();
48 |
49 |
50 | if (cursor.moveToFirst()) {
51 | do {
52 |
53 | String Path = cursor.getString(cursor.getColumnIndex(path));
54 | Music music = new Music();
55 | music.setPath(Path);
56 |
57 | for (int i = 0; i < musicList.size(); i++) {
58 | if (musicList.get(i).getPath().toString().equals(Path)) {
59 | musicArrayList.add(musicList.get(i));
60 | }
61 | }
62 |
63 | } while (cursor.moveToNext());
64 | }
65 |
66 | // sort the music list (A-Z)
67 | Collections.sort(musicArrayList, new Comparator() {
68 | @Override
69 | public int compare(Music music, Music music1) {
70 |
71 | return music.getName().compareTo(music1.getName());
72 | }
73 | });
74 |
75 | Log.i("size", " " + musicArrayList.size());
76 | return musicArrayList;
77 |
78 | } catch (Exception e) {
79 | e.getMessage();
80 | return null;
81 | }
82 | }
83 |
84 | public boolean removeMusicLiked(String path) {
85 | try {
86 |
87 | database.execSQL("DELETE FROM like WHERE path ='" + path + "'");
88 | return true;
89 | } catch (Exception e) {
90 | e.getMessage();
91 | return false;
92 | }
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Model/Music.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Model;
2 |
3 | public class Music {
4 | private String Path;
5 | private String Name;
6 | private String Album;
7 | private String Artist;
8 | private String Duration;
9 | private long dateAdded;
10 | private boolean Liked;
11 | private boolean selected;
12 |
13 | public Music() {
14 | Liked = false;
15 | selected = false;
16 | }
17 |
18 | public Music(String path, String name, String album, String artist, String duration, long dateAdded) {
19 | Path = path;
20 | Name = name;
21 | Album = album;
22 | Artist = artist;
23 | Duration = duration;
24 | Liked = false;
25 | selected = false;
26 | this.dateAdded = dateAdded;
27 | }
28 |
29 | public boolean isLiked() {
30 | return Liked;
31 | }
32 |
33 | public void setLiked(boolean liked) {
34 | Liked = liked;
35 | }
36 |
37 | public String getPath() {
38 | return Path;
39 | }
40 |
41 | public void setPath(String path) {
42 | Path = path;
43 | }
44 |
45 | public String getName() {
46 | return Name;
47 | }
48 |
49 | public void setName(String name) {
50 | Name = name;
51 | }
52 |
53 | public String getAlbum() {
54 | return Album;
55 | }
56 |
57 | public void setAlbum(String album) {
58 | Album = album;
59 | }
60 |
61 | public String getArtist() {
62 | return Artist;
63 | }
64 |
65 | public void setArtist(String artist) {
66 | Artist = artist;
67 | }
68 |
69 | public String getDuration() {
70 | return Duration;
71 | }
72 |
73 | public void setDuration(String duration) {
74 | Duration = duration;
75 | }
76 |
77 | public boolean isSelected() {
78 | return selected;
79 | }
80 |
81 | public void setSelected(boolean selected) {
82 | this.selected = selected;
83 | }
84 |
85 | public long getDateAdded() {
86 | return dateAdded;
87 | }
88 |
89 | public void setDateAdded(long dateAdded) {
90 | this.dateAdded = dateAdded;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Model/PlayList.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Model;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class PlayList {
7 | private String name;
8 | private List musicList;
9 |
10 | public PlayList() {
11 | this.musicList = new ArrayList<>();
12 | }
13 |
14 | public String getName() {
15 | return name;
16 | }
17 |
18 | public void setName(String name) {
19 | this.name = name;
20 | }
21 |
22 | public List getMusicList() {
23 | return musicList;
24 | }
25 |
26 | public void setMusicList(List musicList) {
27 | this.musicList = musicList;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/Model/PlayListDA.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox.Model;
2 |
3 | import android.app.Activity;
4 | import android.database.Cursor;
5 | import android.database.sqlite.SQLiteDatabase;
6 | import android.net.Uri;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | public class PlayListDA {
12 | private DB sqliteDB;
13 | private SQLiteDatabase database;
14 |
15 | public PlayListDA(Activity context) {
16 | sqliteDB = new DB(context);
17 | }
18 |
19 | public void openDB() {
20 | database = sqliteDB.getWritableDatabase();
21 | }
22 |
23 | public void closeDB() {
24 | database.close();
25 | }
26 |
27 | public boolean newPlayList(String name) {
28 | try {
29 | database.execSQL("insert into 'playList' values('" + name + "') ");
30 | database.execSQL("create table `" + name + "` ( path Text , musicName Text ) ");
31 | return true;
32 |
33 | } catch (Exception e) {
34 | return false;
35 | }
36 | }
37 |
38 | public boolean newMusic_playList(List musics, String name) {
39 |
40 | try {
41 | for (int i = 0; i < musics.size(); i++) {
42 | database.execSQL("insert into `" + name + "` values( '" + musics.get(i).getPath() + "' , '" + musics.get(i).getName() + "' )");
43 | }
44 | return true;
45 | } catch (Exception e) {
46 | e.getMessage();
47 | return false;
48 | }
49 |
50 | }
51 |
52 | public List getMusic(String name) {
53 |
54 | try {
55 |
56 | String sql = "SELECT * FROM `" + name + "`";
57 | Cursor cursor = database.rawQuery(sql, null);
58 |
59 | ArrayList musics = new ArrayList<>();
60 |
61 | if (cursor.moveToFirst()) {
62 | do {
63 |
64 | String Path = cursor.getString(cursor.getColumnIndex("path"));
65 | String musicName = cursor.getString(cursor.getColumnIndex("musicName"));
66 |
67 | Music music = new Music();
68 | music.setPath(Path);
69 | music.setName(musicName);
70 |
71 | musics.add(music);
72 |
73 | } while (cursor.moveToNext());
74 | }
75 |
76 | return musics;
77 | } catch (Exception e) {
78 | e.getMessage();
79 | return null;
80 | }
81 | }
82 |
83 | public List getPlayList() {
84 | try {
85 |
86 | Cursor cursor = database.rawQuery("SELECT `name` FROM playList", null);
87 |
88 | ArrayList playLists = new ArrayList<>();
89 |
90 | if (cursor.moveToFirst()) {
91 | do {
92 |
93 | String name = cursor.getString(cursor.getColumnIndex("name"));
94 | PlayList playList = new PlayList();
95 |
96 | playList.setMusicList(getMusic(name));
97 |
98 | playList.setName(name);
99 | playLists.add(playList);
100 | } while (cursor.moveToNext());
101 | }
102 |
103 | return playLists;
104 | } catch (Exception e) {
105 | e.getMessage();
106 | return null;
107 | }
108 |
109 | }
110 |
111 | public boolean deletePlayList(PlayList playList) {
112 | try {
113 | database.execSQL("drop table `" + playList.getName() + "`");
114 | database.execSQL("delete from playList where name = '" + playList.getName() + "' ");
115 | return true;
116 | } catch (Exception e) {
117 | e.getMessage();
118 | return false;
119 | }
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/MusicService.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox;
2 |
3 |
4 | import android.app.NotificationManager;
5 | import android.app.Service;
6 | import android.content.Intent;
7 | import android.media.MediaMetadata;
8 | import android.os.Binder;
9 | import android.os.IBinder;
10 | import android.support.v4.media.MediaMetadataCompat;
11 | import android.support.v4.media.session.MediaSessionCompat;
12 | import android.support.v4.media.session.PlaybackStateCompat;
13 | import android.util.Log;
14 | import android.view.KeyEvent;
15 | import android.widget.Toast;
16 |
17 | import androidx.annotation.Nullable;
18 | import androidx.media.session.MediaButtonReceiver;
19 |
20 | import com.mohammadkz.musicbox.Model.ActionPlaying;
21 | import com.mohammadkz.musicbox.Model.Music;
22 |
23 | public class MusicService extends Service {
24 |
25 | public static final String ACTION_PLAY = "PLAY";
26 | public static final String ACTION_NEXT = "NEXT";
27 | public static final String ACTION_PREV = "PREVIOUS";
28 | public static final String ACTION_CLOSE = "CLOSE";
29 |
30 | private IBinder mBinder = new MyBinder();
31 |
32 | ActionPlaying actionPlaying;
33 |
34 | @Nullable
35 | @Override
36 | public IBinder onBind(Intent intent) {
37 | return mBinder;
38 | }
39 |
40 | public class MyBinder extends Binder {
41 | MusicService getService() {
42 | return MusicService.this;
43 | }
44 | }
45 |
46 | @Override
47 | public int onStartCommand(Intent intent, int flags, int startId) {
48 |
49 | // if the service crashed
50 | if (intent == null) {
51 | NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
52 | notificationManager.cancel(0);
53 | stopSelf();
54 | return START_STICKY;
55 | }
56 |
57 | Log.e("SERVICE_STARTUP", "onStart");
58 |
59 | MediaButtonReceiver.handleIntent(mediaSessionCompat, intent);
60 |
61 | String action = intent.getStringExtra("action");
62 | Log.e("action", action + "");
63 | if (action != null) {
64 | setInfo();
65 | switch (action) {
66 | case ACTION_PLAY:
67 | actionPlaying.play();
68 | break;
69 | case ACTION_NEXT:
70 | actionPlaying.next();
71 | break;
72 | case ACTION_PREV:
73 | actionPlaying.prev();
74 | break;
75 | case ACTION_CLOSE:
76 | actionPlaying.close();
77 | break;
78 | }
79 | }
80 |
81 |
82 | return START_NOT_STICKY;
83 | // return super.onStartCommand(intent, flags, startId);
84 | }
85 |
86 | public void setCallBack(ActionPlaying actionPlaying) {
87 | this.actionPlaying = actionPlaying;
88 | }
89 |
90 | private MediaSessionCompat.Callback mediaSessionCompatCallBack = new MediaSessionCompat.Callback() {
91 | @Override
92 | public void onPlay() {
93 | super.onPlay();
94 | actionPlaying.play();
95 | }
96 |
97 | @Override
98 | public void onPause() {
99 | super.onPause();
100 | actionPlaying.play();
101 | }
102 |
103 | @Override
104 | public void onSkipToNext() {
105 | super.onSkipToNext();
106 | actionPlaying.next();
107 | }
108 |
109 | @Override
110 | public void onSkipToPrevious() {
111 | super.onSkipToPrevious();
112 | actionPlaying.prev();
113 | }
114 |
115 | @Override
116 | public void onStop() {
117 | super.onStop();
118 | }
119 |
120 | @Override
121 | public boolean onMediaButtonEvent(Intent mediaButtonEvent) {
122 | String intentAction = mediaButtonEvent.getAction();
123 |
124 | if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction)) {
125 | KeyEvent event = mediaButtonEvent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
126 |
127 | if (event != null) {
128 | int action = event.getAction();
129 | if (action == KeyEvent.ACTION_DOWN) {
130 | switch (event.getKeyCode()) {
131 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
132 | // code for fast forward
133 | return true;
134 | case KeyEvent.KEYCODE_MEDIA_NEXT:
135 | // code for next
136 | actionPlaying.next();
137 | return true;
138 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
139 | // code for play/pause
140 | actionPlaying.play();
141 | return true;
142 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
143 | // code for previous
144 | actionPlaying.prev();
145 | return true;
146 | case KeyEvent.KEYCODE_MEDIA_STOP:
147 | // code for stop
148 | actionPlaying.close();
149 | return true;
150 |
151 | }
152 | setInfo();
153 | return false;
154 | }
155 | if (action == KeyEvent.ACTION_UP) {
156 | }
157 |
158 |
159 | }
160 | }
161 | return super.onMediaButtonEvent(mediaButtonEvent);
162 | }
163 | };
164 |
165 | private MediaSessionCompat mediaSessionCompat;
166 |
167 | @Override
168 | public void onCreate() {
169 | Log.e("SERVICE", "onCreate");
170 |
171 | mediaSessionCompat = new MediaSessionCompat(this, "MEDIA");
172 | mediaSessionCompat.setCallback(mediaSessionCompatCallBack);
173 | mediaSessionCompat.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
174 | PlaybackStateCompat.Builder mStateBuilder = new PlaybackStateCompat.Builder()
175 | .setActions(
176 | PlaybackStateCompat.ACTION_PLAY |
177 | PlaybackStateCompat.ACTION_PAUSE |
178 | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS |
179 | PlaybackStateCompat.ACTION_SKIP_TO_NEXT |
180 | PlaybackStateCompat.ACTION_PLAY_PAUSE);
181 |
182 | mediaSessionCompat.setPlaybackState(mStateBuilder.build());
183 | mediaSessionCompat.setActive(true);
184 | }
185 |
186 | @Override
187 | public void onDestroy() {
188 | Log.e("SERVICE", "onDestroy");
189 | try {
190 | actionPlaying.close();
191 | mediaSessionCompatCallBack.onPause();
192 | } catch (NullPointerException e) {
193 | e.getMessage();
194 | }
195 |
196 | mediaSessionCompat.release();
197 | }
198 |
199 | public void setInfo() {
200 | try {
201 | mediaSessionCompat.setMetadata(new MediaMetadataCompat.Builder()
202 | // Title.
203 | .putString(MediaMetadata.METADATA_KEY_TITLE, actionPlaying.music().getName())
204 | .putString(MediaMetadata.METADATA_KEY_ARTIST, actionPlaying.music().getArtist())
205 | .putString(MediaMetadata.METADATA_KEY_ALBUM, actionPlaying.music().getAlbum())
206 | .build());
207 | } catch (NullPointerException e) {
208 | e.getMessage();
209 | Toast.makeText(getApplicationContext(), "null", Toast.LENGTH_SHORT).show();
210 | }
211 | }
212 |
213 | @Override
214 | public void onTaskRemoved(Intent rootIntent) {
215 | super.onTaskRemoved(rootIntent);
216 | NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
217 | notificationManager.cancel(0);
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/NotificationReceiver.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.widget.Toast;
7 |
8 | public class NotificationReceiver extends BroadcastReceiver {
9 |
10 | public static final String ACTION_PLAY = "PLAY";
11 | public static final String ACTION_NEXT = "NEXT";
12 | public static final String ACTION_PREV = "PREVIOUS";
13 | public static final String ACTION_CLOSE = "CLOSE";
14 |
15 | @Override
16 | public void onReceive(Context context, Intent intent) {
17 | Intent intent1 = new Intent(context, MusicService.class);
18 |
19 | if (intent.getAction() != null)
20 | switch (intent.getAction()) {
21 | case ACTION_PLAY:
22 | intent1.putExtra("action", intent.getAction());
23 | context.startService(intent1);
24 | break;
25 | case ACTION_NEXT:
26 | intent1.putExtra("action", intent.getAction());
27 | context.startService(intent1);
28 | break;
29 |
30 | case ACTION_PREV:
31 | intent1.putExtra("action", intent.getAction());
32 | context.startService(intent1);
33 | break;
34 | case ACTION_CLOSE:
35 | intent1.putExtra("action", intent.getAction());
36 | context.startService(intent1);
37 | break;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mohammadkz/musicbox/StartUpActivity.java:
--------------------------------------------------------------------------------
1 | package com.mohammadkz.musicbox;
2 |
3 | import androidx.appcompat.app.ActionBar;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import androidx.core.app.ActivityCompat;
6 | import androidx.core.content.ContextCompat;
7 |
8 | import android.Manifest;
9 | import android.content.Intent;
10 | import android.content.pm.PackageManager;
11 | import android.os.Bundle;
12 | import android.os.Handler;
13 | import android.widget.Toast;
14 |
15 | import com.gun0912.tedpermission.PermissionListener;
16 | import com.gun0912.tedpermission.TedPermission;
17 |
18 | import java.util.List;
19 |
20 | import static android.bluetooth.BluetoothGattCharacteristic.PERMISSION_READ;
21 | import static android.bluetooth.BluetoothGattCharacteristic.PERMISSION_WRITE;
22 |
23 | public class StartUpActivity extends AppCompatActivity {
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_start_up);
29 |
30 | ActionBar actionBar = getSupportActionBar();
31 | actionBar.hide();
32 |
33 |
34 | Handler handler = new Handler();
35 | handler.postDelayed(new Runnable() {
36 | @Override
37 | public void run() {
38 |
39 | startActivity(new Intent(StartUpActivity.this, MainActivity.class));
40 | finish();
41 |
42 | }
43 | }, 4000);
44 | }
45 |
46 | private void permission() {
47 |
48 | PermissionListener permissionListener = new PermissionListener() {
49 | @Override
50 | public void onPermissionGranted() {
51 |
52 | }
53 |
54 | @Override
55 | public void onPermissionDenied(List deniedPermissions) {
56 |
57 | }
58 | };
59 |
60 | TedPermission.with(this)
61 | .setPermissionListener(permissionListener)
62 | .setPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE , Manifest.permission.ACCESS_FINE_LOCATION)
63 | .check();
64 | }
65 |
66 | // public boolean checkPermission() {
67 | // boolean per1 = true, per2 = true;
68 | // int READ_EXTERNAL_PERMISSION = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE);
69 | // if ((READ_EXTERNAL_PERMISSION != PackageManager.PERMISSION_GRANTED)) {
70 | // ActivityCompat.requestPermissions(StartUpActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_READ);
71 | // per1 = false;
72 | // }
73 | //
74 | // int WRITE_EXTERNAL_STORAGE = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE);
75 | // if ((WRITE_EXTERNAL_STORAGE != PackageManager.PERMISSION_GRANTED)) {
76 | // ActivityCompat.requestPermissions(StartUpActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_READ);
77 | // per2 = false;
78 | // }
79 | //
80 | // if (!per1 || !per2)
81 | // return false;
82 | // else
83 | // return true;
84 | // }
85 | //
86 | // @Override
87 | // public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
88 | // super.onRequestPermissionsResult(requestCode, permissions, grantResults);
89 | // switch (requestCode) {
90 | // case PERMISSION_READ: {
91 | // if (grantResults.length > 0 && permissions[0].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
92 | // if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
93 | // Toast.makeText(getApplicationContext(), "Please allow storage permission", Toast.LENGTH_LONG).show();
94 | // } else {
95 | //
96 | // }
97 | // }
98 | //
99 | // }
100 | // case PERMISSION_WRITE: {
101 | // if (grantResults.length > 0 && permissions[0].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
102 | // if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
103 | // Toast.makeText(getApplicationContext(), "Please allow storage permission", Toast.LENGTH_LONG).show();
104 | // } else {
105 | //
106 | // }
107 | // }
108 | //
109 | // }
110 | // break;
111 | //
112 | // }
113 | // }
114 |
115 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_jump_to.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable-v24/ic_jump_to.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/.idea/drawable.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/audio_img_perpel.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/audio_img_white.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_bottom_nav.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_bottom_sheet.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_music_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_sealected_sort.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_search_box.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable/heart.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/home.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_down.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_back.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_cleaning.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_music.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play_circle.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_repeat.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_repeat_one.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_shuffle.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sort.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/like.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable/like.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/more.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/music_artist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable/music_artist.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/next.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/pause.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/play.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/playlist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable/playlist.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/previous.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable/search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selection.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/tab_selection.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/drawable/user.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
26 |
27 |
28 |
36 |
37 |
44 |
45 |
51 |
52 |
53 |
58 |
59 |
76 |
77 |
91 |
92 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_start_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/all_music_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
22 |
23 |
28 |
29 |
34 |
35 |
41 |
42 |
53 |
54 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
79 |
80 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/artist_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
21 |
22 |
27 |
28 |
37 |
38 |
39 |
46 |
47 |
52 |
53 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/bottom_sheet_add_to_playlist.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_artist_player_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
23 |
24 |
36 |
37 |
45 |
46 |
53 |
54 |
61 |
62 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
85 |
86 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_artist_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
29 |
30 |
41 |
42 |
48 |
49 |
55 |
56 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
25 |
26 |
40 |
41 |
55 |
56 |
67 |
68 |
69 |
70 |
77 |
78 |
87 |
88 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_like.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
23 |
24 |
35 |
36 |
45 |
46 |
52 |
53 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_play_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
24 |
25 |
34 |
35 |
47 |
48 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_play_list_music.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
31 |
32 |
40 |
41 |
47 |
48 |
49 |
50 |
57 |
58 |
65 |
66 |
73 |
74 |
75 |
76 |
83 |
84 |
85 |
86 |
96 |
97 |
108 |
109 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_search_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
25 |
26 |
44 |
45 |
54 |
55 |
61 |
62 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_sheet_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
32 |
33 |
44 |
45 |
57 |
58 |
70 |
71 |
84 |
85 |
95 |
96 |
104 |
105 |
114 |
115 |
124 |
125 |
134 |
135 |
144 |
145 |
154 |
155 |
167 |
168 |
174 |
175 |
181 |
182 |
188 |
189 |
195 |
196 |
202 |
203 |
209 |
210 |
216 |
217 |
218 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_add_to_playlist.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
23 |
24 |
29 |
30 |
35 |
36 |
41 |
42 |
54 |
55 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_play_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
26 |
27 |
34 |
35 |
42 |
43 |
51 |
52 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_sort_bottom_sheet.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
30 |
31 |
37 |
38 |
49 |
50 |
56 |
57 |
68 |
69 |
75 |
76 |
87 |
88 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/sheet_bottom_music_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
31 |
32 |
49 |
50 |
62 |
63 |
64 |
65 |
82 |
83 |
95 |
96 |
97 |
98 |
115 |
116 |
128 |
129 |
130 |
131 |
148 |
149 |
161 |
162 |
163 |
164 |
173 |
174 |
175 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/popup_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #DFD3C9
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MusicBox
3 |
4 | Hello blank fragment
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
25 |
26 |
29 |
30 |
33 |
34 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:4.1.1'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/appcompat/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/constraintlayout/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/legacy/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/test/espresso/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/androidx/test/ext/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/com/google/android/material/group-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/build/intermediates/lint-cache/maven.google/master-index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mohkhz2001/MusicBox/191f4bcc2a9fbdc30583a11447585723c65baa8c/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Mar 25 19:20:53 IRDT 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/home/mohammadkz/Android/Sdk
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "MusicBox"
--------------------------------------------------------------------------------