Added about dialog
- about dialog - changed old dev tag „karim23697“ to „kabouzeid“
This commit is contained in:
parent
25387c5338
commit
09f63ac822
7 changed files with 70 additions and 15 deletions
|
|
@ -0,0 +1,42 @@
|
|||
package com.kabouzeid.materialmusic.helper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.kabouzeid.materialmusic.R;
|
||||
|
||||
/**
|
||||
* Created by karim on 05.02.15.
|
||||
*/
|
||||
public class AboutDeveloperDialogHelper {
|
||||
public static final String TAG = AboutDeveloperDialogHelper.class.getSimpleName();
|
||||
|
||||
public static MaterialDialog getDialog(final Context context) {
|
||||
MaterialDialog dialog = new MaterialDialog.Builder(context)
|
||||
.title(context.getResources().getString(R.string.app_name) + " " + getCurrentVersionName(context))
|
||||
.iconRes(R.drawable.ic_launcher)
|
||||
.content(context.getResources().getText(R.string.credits))
|
||||
.positiveText(context.getResources().getString(R.string.ok))
|
||||
.callback(new MaterialDialog.ButtonCallback() {
|
||||
@Override
|
||||
public void onPositive(MaterialDialog dialog) {
|
||||
super.onPositive(dialog);
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.build();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private static String getCurrentVersionName(final Context context) {
|
||||
String versionName = "";
|
||||
try {
|
||||
versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Unable to get current app version number.", e);
|
||||
}
|
||||
return versionName;
|
||||
}
|
||||
}
|
||||
|
|
@ -22,8 +22,8 @@ import com.kabouzeid.materialmusic.ui.activities.MusicControllerActivity;
|
|||
import com.kabouzeid.materialmusic.util.MusicUtil;
|
||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||
|
||||
public class NotificationHelper {
|
||||
public static final String TAG = NotificationHelper.class.getSimpleName();
|
||||
public class PlayingNotificationHelper {
|
||||
public static final String TAG = PlayingNotificationHelper.class.getSimpleName();
|
||||
public static final int NOTIFICATION_ID = 1337;
|
||||
|
||||
private final MusicService service;
|
||||
|
|
@ -34,7 +34,7 @@ public class NotificationHelper {
|
|||
private RemoteViews notificationLayout;
|
||||
private RemoteViews notificationLayoutExpanded;
|
||||
|
||||
public NotificationHelper(final MusicService service) {
|
||||
public PlayingNotificationHelper(final MusicService service) {
|
||||
this.service = service;
|
||||
notificationManager = (NotificationManager) service
|
||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
|
@ -22,7 +22,7 @@ import android.util.Log;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.kabouzeid.materialmusic.R;
|
||||
import com.kabouzeid.materialmusic.helper.NotificationHelper;
|
||||
import com.kabouzeid.materialmusic.helper.PlayingNotificationHelper;
|
||||
import com.kabouzeid.materialmusic.helper.ShuffleHelper;
|
||||
import com.kabouzeid.materialmusic.interfaces.OnMusicRemoteEventListener;
|
||||
import com.kabouzeid.materialmusic.misc.AppKeys;
|
||||
|
|
@ -72,7 +72,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
private boolean thingsRegistered;
|
||||
private boolean saveQueuesAgain;
|
||||
private boolean isSavingQueues;
|
||||
private NotificationHelper notificationHelper;
|
||||
private PlayingNotificationHelper playingNotificationHelper;
|
||||
private AudioManager audioManager;
|
||||
private RemoteControlClient remoteControlClient;
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
playingQueue = new ArrayList<>();
|
||||
originalPlayingQueue = new ArrayList<>();
|
||||
onMusicRemoteEventListeners = new ArrayList<>();
|
||||
notificationHelper = new NotificationHelper(this);
|
||||
playingNotificationHelper = new PlayingNotificationHelper(this);
|
||||
|
||||
shuffleMode = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_SHUFFLE_MODE, 0);
|
||||
repeatMode = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_REPEAT_MODE, 0);
|
||||
|
|
@ -193,7 +193,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
|
||||
private void killEverythingAndReleaseResources() {
|
||||
stopPlaying();
|
||||
notificationHelper.killNotification();
|
||||
playingNotificationHelper.killNotification();
|
||||
savePosition();
|
||||
saveQueues();
|
||||
stopSelf();
|
||||
|
|
@ -202,7 +202,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
public void stopPlaying() {
|
||||
isPlayerPrepared = false;
|
||||
player.stop();
|
||||
notificationHelper.updatePlayState(isPlaying());
|
||||
playingNotificationHelper.updatePlayState(isPlaying());
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
player.release();
|
||||
player = null;
|
||||
|
|
@ -257,7 +257,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.SONG_COMPLETED);
|
||||
if (isLastTrack()) {
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.QUEUE_COMPLETED);
|
||||
notificationHelper.updatePlayState(isPlaying());
|
||||
playingNotificationHelper.updatePlayState(isPlaying());
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STOP);
|
||||
} else {
|
||||
|
|
@ -293,7 +293,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
player.reset();
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show();
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STOP);
|
||||
notificationHelper.updatePlayState(false);
|
||||
playingNotificationHelper.updatePlayState(false);
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -335,7 +335,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
}
|
||||
|
||||
private void updateNotification() {
|
||||
notificationHelper.buildNotification(playingQueue.get(position), isPlaying());
|
||||
playingNotificationHelper.buildNotification(playingQueue.get(position), isPlaying());
|
||||
}
|
||||
|
||||
private Uri getCurrentPositionTrackUri() {
|
||||
|
|
@ -384,7 +384,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
public void onPrepared(MediaPlayer mp) {
|
||||
player.start();
|
||||
isPlayerPrepared = true;
|
||||
notificationHelper.updatePlayState(isPlaying());
|
||||
playingNotificationHelper.updatePlayState(isPlaying());
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.PLAY);
|
||||
savePosition();
|
||||
|
|
@ -495,7 +495,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
public void pausePlaying() {
|
||||
if (isPlaying()) {
|
||||
player.pause();
|
||||
notificationHelper.updatePlayState(isPlaying());
|
||||
playingNotificationHelper.updatePlayState(isPlaying());
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.PAUSE);
|
||||
}
|
||||
|
|
@ -505,7 +505,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
|||
if (requestFocus()) {
|
||||
if (isPlayerPrepared) {
|
||||
player.start();
|
||||
notificationHelper.updatePlayState(isPlaying());
|
||||
playingNotificationHelper.updatePlayState(isPlaying());
|
||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.RESUME);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import android.widget.Toast;
|
|||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.kabouzeid.materialmusic.R;
|
||||
import com.kabouzeid.materialmusic.helper.AboutDeveloperDialogHelper;
|
||||
import com.kabouzeid.materialmusic.helper.PlayingQueueDialogHelper;
|
||||
import com.kabouzeid.materialmusic.interfaces.KabSearchAbleFragment;
|
||||
import com.kabouzeid.materialmusic.interfaces.KabViewsDisableAble;
|
||||
|
|
@ -252,6 +253,9 @@ public class MainActivity extends AbsFabActivity
|
|||
switch (id) {
|
||||
case R.id.action_settings:
|
||||
return true;
|
||||
case R.id.action_about:
|
||||
AboutDeveloperDialogHelper.getDialog(this).show();
|
||||
return true;
|
||||
case R.id.action_current_playing:
|
||||
openCurrentPlayingIfPossible(null);
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue