Skip to content

Commit

Permalink
updated ui for queue and sleep timer, minor clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-atul committed Dec 19, 2022
1 parent a560716 commit ab5fa04
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 77 deletions.
1 change: 0 additions & 1 deletion src/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package="com.atul.musicplayer">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
Expand Down
11 changes: 4 additions & 7 deletions src/app/src/main/java/com/atul/musicplayer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.atul.musicplayer.player.PlayerListener;
import com.atul.musicplayer.player.PlayerManager;
import com.atul.musicplayer.viewmodel.MainViewModel;
import com.atul.musicplayer.viewmodel.MainViewModelFactory;
import com.bumptech.glide.Glide;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
Expand Down Expand Up @@ -74,7 +73,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
MPConstants.musicSelectListener = this;

viewModel = new ViewModelProvider(this, new MainViewModelFactory()).get(MainViewModel.class);
viewModel = new ViewModelProvider(this).get(MainViewModel.class);

if (hasReadStoragePermission(MainActivity.this)) {
fetchMusicList();
Expand Down Expand Up @@ -137,8 +136,7 @@ public void setUpUiElements() {
public void manageStoragePermission(Activity context) {
if (!hasReadStoragePermission(context)) {
// required a dialog?
if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.READ_EXTERNAL_STORAGE) ||
ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
if (ActivityCompat.shouldShowRequestPermissionRationale(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
new MaterialAlertDialogBuilder(context)
.setTitle("Requesting permission")
.setMessage("Enable storage permission for accessing the media files.")
Expand All @@ -150,15 +148,14 @@ public void manageStoragePermission(Activity context) {

public boolean hasReadStoragePermission(Activity context) {
return (
ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
);
}

public void askReadStoragePermission(Activity context) {
ActivityCompat.requestPermissions(
context,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MPConstants.PERMISSION_READ_STORAGE
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.atul.musicplayer.listener.AlbumSelectListener;
import com.atul.musicplayer.model.Album;
import com.atul.musicplayer.viewmodel.MainViewModel;
import com.atul.musicplayer.viewmodel.MainViewModelFactory;
import com.google.android.material.appbar.MaterialToolbar;

import java.util.ArrayList;
Expand All @@ -45,8 +44,7 @@ public static AlbumsFragment newInstance() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewModel = new ViewModelProvider(requireActivity(),
new MainViewModelFactory()).get(MainViewModel.class);
viewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.atul.musicplayer.listener.ArtistSelectListener;
import com.atul.musicplayer.model.Artist;
import com.atul.musicplayer.viewmodel.MainViewModel;
import com.atul.musicplayer.viewmodel.MainViewModelFactory;
import com.google.android.material.appbar.MaterialToolbar;

import java.util.ArrayList;
Expand All @@ -45,7 +44,7 @@ public static ArtistsFragment newInstance() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewModel = new ViewModelProvider(requireActivity(), new MainViewModelFactory()).get(MainViewModel.class);
viewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.atul.musicplayer.helper.ThemeHelper;
import com.atul.musicplayer.model.Folder;
import com.atul.musicplayer.viewmodel.MainViewModel;
import com.atul.musicplayer.viewmodel.MainViewModelFactory;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.switchmaterial.SwitchMaterial;

Expand Down Expand Up @@ -53,7 +52,7 @@ public static SettingsFragment newInstance() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewModel = new ViewModelProvider(requireActivity(), new MainViewModelFactory()).get(MainViewModel.class);
viewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.atul.musicplayer.listener.MusicSelectListener;
import com.atul.musicplayer.model.Music;
import com.atul.musicplayer.viewmodel.MainViewModel;
import com.atul.musicplayer.viewmodel.MainViewModelFactory;
import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;

Expand Down Expand Up @@ -47,8 +46,7 @@ public static SongsFragment newInstance(MusicSelectListener selectListener) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
viewModel = new ViewModelProvider(requireActivity(),
new MainViewModelFactory()).get(MainViewModel.class);
viewModel = new ViewModelProvider(requireActivity()).get(MainViewModel.class);
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public void prev() {
currentPosition = played.get(lastPosition);
played.remove(lastPosition);
}
// currentPosition = isCurrentPositionOutOfBound(currentPosition - 1) ? currentQueue.size() - 1 : --currentPosition;
}

public void removeMusicFromQueue(int position) {
Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions src/app/src/main/res/layout/dialog_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,6 @@
app:tint="?colorOnBackground"
tools:ignore="DuplicateSpeakableTextCheck" />

<!-- <ImageButton-->
<!-- android:id="@+id/music_equalizer"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginBottom="5dp"-->
<!-- android:background="?android:attr/actionBarItemBackground"-->
<!-- android:contentDescription="@string/image"-->
<!-- android:padding="5dp"-->
<!-- app:srcCompat="@drawable/ic_equalizer"-->
<!-- app:tint="?colorOnBackground" />-->

<!-- <ImageButton-->
<!-- android:id="@+id/music_meta_edit"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="5dp"-->
<!-- android:layout_marginBottom="5dp"-->
<!-- android:background="?android:attr/actionBarItemBackground"-->
<!-- android:contentDescription="@string/image"-->
<!-- android:padding="5dp"-->
<!-- app:srcCompat="@drawable/ic_edit_metadata"-->
<!-- app:tint="?colorOnBackground" />-->

</LinearLayout>

<LinearLayout
Expand Down
1 change: 1 addition & 0 deletions src/app/src/main/res/layout/dialog_sleep_timer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
android:id="@+id/sleep_timer_minutes_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:hint="@string/sleep_timer_textbox_placeholder">

<com.google.android.material.textfield.TextInputEditText
Expand Down
5 changes: 2 additions & 3 deletions src/app/src/main/res/layout/item_queue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="5dp"
android:layout_marginHorizontal="5dp"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
Expand All @@ -30,6 +28,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_gravity="center_vertical"
android:layout_weight="1">

<TextView
Expand Down

0 comments on commit ab5fa04

Please sign in to comment.