Skip to content

Commit

Permalink
New Functionality Added
Browse files Browse the repository at this point in the history
Repeat Song and  Shuffling Playlist more icon set added Android Design
Support added for more UI functionality
  • Loading branch information
dibakarece committed Jul 9, 2016
1 parent fa16856 commit a4558b3
Show file tree
Hide file tree
Showing 62 changed files with 317 additions and 84 deletions.
20 changes: 11 additions & 9 deletions app/app.iml
Expand Up @@ -69,10 +69,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/21.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/21.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/22.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/22.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
Expand All @@ -90,13 +91,14 @@
</content>
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="design-22.2.1" level="project" />
<orderEntry type="library" exported="" name="nineoldandroids-2.4.0" level="project" />
<orderEntry type="library" exported="" name="gson-2.2.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-22.1.1" level="project" />
<orderEntry type="library" exported="" name="universal-image-loader-1.9.3" level="project" />
</component>
</module>
10 changes: 5 additions & 5 deletions app/build.gradle
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "com.dmplayer"
Expand All @@ -23,9 +23,9 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/universal-image-loader-1.9.3.jar')
compile 'com.android.support:appcompat-v7:21+'
compile 'com.android.support:cardview-v7:21.+'
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:recyclerview-v7:21+'
compile files('libs/gson-2.2.3.jar')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:cardview-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
}
@@ -1,17 +1,7 @@
/*
* Copyright 2014 Soichiro Kashima
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/

package com.dmplayer.activities;
Expand All @@ -22,6 +12,7 @@
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.Toolbar;
Expand All @@ -41,6 +32,7 @@

import com.dmplayer.R;
import com.dmplayer.manager.MediaController;
import com.dmplayer.manager.MusicPreferance;
import com.dmplayer.manager.NotificationManager;
import com.dmplayer.models.SongDetail;
import com.dmplayer.observablelib.ObservableScrollView;
Expand Down Expand Up @@ -84,7 +76,7 @@ public class AlbumAndArtisDetailsActivity extends ActionBarActivity implements V
private String title_one = "";
private String title_sec = "";
private ImageView banner;
private ImageView fab_button;
private FloatingActionButton fab_button;
private TextView tv_albumname, tv_title_fst, tv_title_sec;
private ExpandableHeightListView recycler_songslist;
private AllSongsListAdapter mAllSongsListAdapter;
Expand Down Expand Up @@ -163,11 +155,18 @@ public void onClick(View v) {
break;

case R.id.btn_suffel:

v.setSelected(v.isSelected() ? false : true);
MediaController.getInstance().shuffleMusic = v.isSelected() ? true : false;
MusicPreferance.setShuffel(context, (v.isSelected() ? true : false));
MediaController.getInstance().shuffleList(MusicPreferance.playlist);
DMPlayerUtility.changeColorSet(context, (ImageView) v, v.isSelected());
break;

case R.id.btn_toggle:

v.setSelected(v.isSelected() ? false : true);
MediaController.getInstance().repeatMode = v.isSelected() ? 1 : 0;
MusicPreferance.setRepeat(context, (v.isSelected() ? 1 : 0));
DMPlayerUtility.changeColorSet(context, (ImageView) v, v.isSelected());
break;

case R.id.bottombar_img_Favorite:
Expand Down Expand Up @@ -247,7 +246,7 @@ private void initialize() {
.cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();

try {
fab_button = (ImageView) findViewById(R.id.fab_button);
fab_button = (FloatingActionButton) findViewById(R.id.fab_button);
fab_button.setColorFilter(color);
if (Build.VERSION.SDK_INT > 15) {
fab_button.setImageAlpha(255);
Expand Down Expand Up @@ -561,6 +560,14 @@ public void onClick(View v) {
((PlayPauseView) findViewById(R.id.bottombar_play)).setOnClickListener(this);
((PlayPauseView) findViewById(R.id.btn_play)).setOnClickListener(this);

imgbtn_toggle.setSelected((MusicPreferance.getRepeat(context) == 1) ? true : false);
MediaController.getInstance().shuffleMusic = imgbtn_toggle.isSelected() ? true : false;
DMPlayerUtility.changeColorSet(context, (ImageView) imgbtn_toggle, imgbtn_toggle.isSelected());

imgbtn_suffel.setSelected(MusicPreferance.getShuffel(context) ? true : false);
MediaController.getInstance().repeatMode = imgbtn_suffel.isSelected() ? 1 : 0;
DMPlayerUtility.changeColorSet(context, (ImageView) imgbtn_suffel, imgbtn_suffel.isSelected());

mLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
Expand Down
@@ -1,3 +1,8 @@
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.activities;

import android.app.Activity;
Expand Down Expand Up @@ -196,11 +201,18 @@ public void onClick(View v) {
break;

case R.id.btn_suffel:

v.setSelected(v.isSelected() ? false : true);
MediaController.getInstance().shuffleMusic = v.isSelected() ? true : false;
MusicPreferance.setShuffel(context, (v.isSelected() ? true : false));
MediaController.getInstance().shuffleList(MusicPreferance.playlist);
DMPlayerUtility.changeColorSet(context, (ImageView) v, v.isSelected());
break;

case R.id.btn_toggle:

v.setSelected(v.isSelected() ? false : true);
MediaController.getInstance().repeatMode = v.isSelected() ? 1 : 0;
MusicPreferance.setRepeat(context, (v.isSelected() ? 1 : 0));
DMPlayerUtility.changeColorSet(context, (ImageView) v, v.isSelected());
break;

case R.id.bottombar_img_Favorite:
Expand Down Expand Up @@ -463,6 +475,16 @@ public void onClick(View v) {
((PlayPauseView) findViewById(R.id.bottombar_play)).setOnClickListener(this);
((PlayPauseView) findViewById(R.id.btn_play)).setOnClickListener(this);

imgbtn_toggle.setSelected((MusicPreferance.getRepeat(context) == 1) ? true : false);
MediaController.getInstance().shuffleMusic = imgbtn_toggle.isSelected() ? true : false;
DMPlayerUtility.changeColorSet(context, (ImageView) imgbtn_toggle, imgbtn_toggle.isSelected());

imgbtn_suffel.setSelected(MusicPreferance.getShuffel(context) ? true : false);
MediaController.getInstance().repeatMode = imgbtn_suffel.isSelected() ? 1 : 0;
DMPlayerUtility.changeColorSet(context, (ImageView) imgbtn_suffel, imgbtn_suffel.isSelected());

MediaController.getInstance().shuffleList(MusicPreferance.playlist);

mLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
@Override
public void onPanelSlide(View panel, float slideOffset) {
Expand Down
@@ -1,3 +1,8 @@
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.activities;

import android.content.Context;
Expand Down
@@ -1,20 +1,7 @@
/**
* Copyright (C) 2015 Open DMPLayer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* author @DibakarMistry(dibakar.ece@gmail.com).
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.adapter;

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/dmplayer/adapter/DrawerAdapter.java
@@ -1,3 +1,8 @@
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.adapter;


Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/dmplayer/adapter/SongsPagerAdapter.java
@@ -1,3 +1,8 @@
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.adapter;

import android.content.Context;
Expand Down
@@ -1,3 +1,8 @@
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.dbhandler;

import android.content.Context;
Expand Down
@@ -1,3 +1,8 @@
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.dbhandler;

import android.content.ContentValues;
Expand Down
@@ -1,3 +1,8 @@
/*
* This is the source code of DMPLayer for Android v. 1.0.0.
* You should have received a copy of the license in this archive (see LICENSE).
* Copyright @Dibakar_Mistry, 2015.
*/
package com.dmplayer.dbhandler;

import android.content.ContentValues;
Expand Down
53 changes: 50 additions & 3 deletions app/src/main/java/com/dmplayer/manager/MediaController.java
Expand Up @@ -28,6 +28,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;

Expand All @@ -50,7 +51,8 @@ public class MediaController implements NotificationManager.NotificationCenterDe

private int lastTag = 0;
public int currentPlaylistNum;
private boolean shuffleMusic;
public static boolean shuffleMusic = false;
public static int repeatMode = 0;

private final Object progressTimerSync = new Object();
private Timer progressTimer = null;
Expand All @@ -63,7 +65,6 @@ public class MediaController implements NotificationManager.NotificationCenterDe
public int type = 0;
public int id = -1;
public String path = "";
private int repeatMode;

private static volatile MediaController Instance = null;

Expand Down Expand Up @@ -252,7 +253,7 @@ public void onCompletion(MediaPlayer mediaPlayer) {
private void playNextSong(boolean byStop) {
ArrayList<SongDetail> currentPlayList = shuffleMusic ? MusicPreferance.shuffledPlaylist : MusicPreferance.playlist;

if (byStop && repeatMode == 2) {
if (byStop && repeatMode == 1) {
cleanupPlayer(false, false);
playAudio(currentPlayList.get(currentPlaylistNum));
return;
Expand Down Expand Up @@ -464,6 +465,39 @@ public boolean setPlaylist(ArrayList<SongDetail> allSongsList, SongDetail curren
return playAudio(current);
}


/**
* Shuffle The SongList
*
* @param songList
*/
public static void shuffleList(ArrayList<SongDetail> songs) {
if (MusicPreferance.shuffledPlaylist.isEmpty()) {
ArrayList<SongDetail> songList = new ArrayList<SongDetail>(songs);
int n = songList.size();
Random random = new Random();
random.nextInt();
for (int i = 0; i < n; i++) {
int change = i + random.nextInt(n - i);
swap(songList, i, change);
}
MusicPreferance.shuffledPlaylist = songList;
}
}

private static void swap(ArrayList<SongDetail> songList, int i, int change) {
SongDetail helper = songList.get(i);
songList.set(i, songList.get(change));
songList.set(change, helper);
}

/**
* seekToProgress functionsl for Audio Progress
*
* @param mSongDetail
* @param progress
* @return
*/
public boolean seekToProgress(SongDetail mSongDetail, float progress) {
if (audioTrackPlayer == null && audioPlayer == null) {
return false;
Expand All @@ -480,6 +514,13 @@ public boolean seekToProgress(SongDetail mSongDetail, float progress) {
return true;
}

/**
* When Get Stop Player, clear the Object instance
*
* @param context
* @param notify
* @param stopService
*/
public void cleanupPlayer(Context context, boolean notify, boolean stopService) {
MusicPreferance.saveLastSong(context, getPlayingSongDetail());
MusicPreferance.saveLastSongListType(context, type);
Expand All @@ -489,6 +530,12 @@ public void cleanupPlayer(Context context, boolean notify, boolean stopService)
cleanupPlayer(notify, stopService);
}

/**
* When Get Stop Player, clear the Object instance
*
* @param notify
* @param stopService
*/
public void cleanupPlayer(boolean notify, boolean stopService) {
pauseAudio(getPlayingSongDetail());
stopProximitySensor();
Expand Down
Expand Up @@ -127,6 +127,7 @@ private void createNotification(SongDetail mSongDetail) {
try {
String songName = mSongDetail.getTitle();
String authorName = mSongDetail.getArtist();
String albumName = mSongDetail.getDisplay_name();
SongDetail audioInfo = MediaController.getInstance().getPlayingSongDetail();

RemoteViews simpleContentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.player_small_notification);
Expand Down Expand Up @@ -196,6 +197,7 @@ private void createNotification(SongDetail mSongDetail) {
if (supportBigNotifications) {
notification.bigContentView.setTextViewText(R.id.player_song_name, songName);
notification.bigContentView.setTextViewText(R.id.player_author_name, authorName);
// notification.bigContentView.setTextViewText(R.id.player_albumname, albumName);
}
notification.flags |= Notification.FLAG_ONGOING_EVENT;
startForeground(5, notification);
Expand Down

0 comments on commit a4558b3

Please sign in to comment.