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.kabouzeid.materialmusic.util.MusicUtil;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.nostra13.universalimageloader.core.ImageLoader;
|
||||||
|
|
||||||
public class NotificationHelper {
|
public class PlayingNotificationHelper {
|
||||||
public static final String TAG = NotificationHelper.class.getSimpleName();
|
public static final String TAG = PlayingNotificationHelper.class.getSimpleName();
|
||||||
public static final int NOTIFICATION_ID = 1337;
|
public static final int NOTIFICATION_ID = 1337;
|
||||||
|
|
||||||
private final MusicService service;
|
private final MusicService service;
|
||||||
|
|
@ -34,7 +34,7 @@ public class NotificationHelper {
|
||||||
private RemoteViews notificationLayout;
|
private RemoteViews notificationLayout;
|
||||||
private RemoteViews notificationLayoutExpanded;
|
private RemoteViews notificationLayoutExpanded;
|
||||||
|
|
||||||
public NotificationHelper(final MusicService service) {
|
public PlayingNotificationHelper(final MusicService service) {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
notificationManager = (NotificationManager) service
|
notificationManager = (NotificationManager) service
|
||||||
.getSystemService(Context.NOTIFICATION_SERVICE);
|
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
@ -22,7 +22,7 @@ import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.kabouzeid.materialmusic.R;
|
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.helper.ShuffleHelper;
|
||||||
import com.kabouzeid.materialmusic.interfaces.OnMusicRemoteEventListener;
|
import com.kabouzeid.materialmusic.interfaces.OnMusicRemoteEventListener;
|
||||||
import com.kabouzeid.materialmusic.misc.AppKeys;
|
import com.kabouzeid.materialmusic.misc.AppKeys;
|
||||||
|
|
@ -72,7 +72,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
private boolean thingsRegistered;
|
private boolean thingsRegistered;
|
||||||
private boolean saveQueuesAgain;
|
private boolean saveQueuesAgain;
|
||||||
private boolean isSavingQueues;
|
private boolean isSavingQueues;
|
||||||
private NotificationHelper notificationHelper;
|
private PlayingNotificationHelper playingNotificationHelper;
|
||||||
private AudioManager audioManager;
|
private AudioManager audioManager;
|
||||||
private RemoteControlClient remoteControlClient;
|
private RemoteControlClient remoteControlClient;
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
playingQueue = new ArrayList<>();
|
playingQueue = new ArrayList<>();
|
||||||
originalPlayingQueue = new ArrayList<>();
|
originalPlayingQueue = new ArrayList<>();
|
||||||
onMusicRemoteEventListeners = new ArrayList<>();
|
onMusicRemoteEventListeners = new ArrayList<>();
|
||||||
notificationHelper = new NotificationHelper(this);
|
playingNotificationHelper = new PlayingNotificationHelper(this);
|
||||||
|
|
||||||
shuffleMode = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_SHUFFLE_MODE, 0);
|
shuffleMode = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_SHUFFLE_MODE, 0);
|
||||||
repeatMode = PreferenceManager.getDefaultSharedPreferences(this).getInt(AppKeys.SP_REPEAT_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() {
|
private void killEverythingAndReleaseResources() {
|
||||||
stopPlaying();
|
stopPlaying();
|
||||||
notificationHelper.killNotification();
|
playingNotificationHelper.killNotification();
|
||||||
savePosition();
|
savePosition();
|
||||||
saveQueues();
|
saveQueues();
|
||||||
stopSelf();
|
stopSelf();
|
||||||
|
|
@ -202,7 +202,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
public void stopPlaying() {
|
public void stopPlaying() {
|
||||||
isPlayerPrepared = false;
|
isPlayerPrepared = false;
|
||||||
player.stop();
|
player.stop();
|
||||||
notificationHelper.updatePlayState(isPlaying());
|
playingNotificationHelper.updatePlayState(isPlaying());
|
||||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||||
player.release();
|
player.release();
|
||||||
player = null;
|
player = null;
|
||||||
|
|
@ -257,7 +257,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.SONG_COMPLETED);
|
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.SONG_COMPLETED);
|
||||||
if (isLastTrack()) {
|
if (isLastTrack()) {
|
||||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.QUEUE_COMPLETED);
|
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.QUEUE_COMPLETED);
|
||||||
notificationHelper.updatePlayState(isPlaying());
|
playingNotificationHelper.updatePlayState(isPlaying());
|
||||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STOP);
|
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STOP);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -293,7 +293,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
player.reset();
|
player.reset();
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.unplayable_file), Toast.LENGTH_SHORT).show();
|
||||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STOP);
|
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.STOP);
|
||||||
notificationHelper.updatePlayState(false);
|
playingNotificationHelper.updatePlayState(false);
|
||||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -335,7 +335,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNotification() {
|
private void updateNotification() {
|
||||||
notificationHelper.buildNotification(playingQueue.get(position), isPlaying());
|
playingNotificationHelper.buildNotification(playingQueue.get(position), isPlaying());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Uri getCurrentPositionTrackUri() {
|
private Uri getCurrentPositionTrackUri() {
|
||||||
|
|
@ -384,7 +384,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
public void onPrepared(MediaPlayer mp) {
|
public void onPrepared(MediaPlayer mp) {
|
||||||
player.start();
|
player.start();
|
||||||
isPlayerPrepared = true;
|
isPlayerPrepared = true;
|
||||||
notificationHelper.updatePlayState(isPlaying());
|
playingNotificationHelper.updatePlayState(isPlaying());
|
||||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
||||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.PLAY);
|
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.PLAY);
|
||||||
savePosition();
|
savePosition();
|
||||||
|
|
@ -495,7 +495,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
public void pausePlaying() {
|
public void pausePlaying() {
|
||||||
if (isPlaying()) {
|
if (isPlaying()) {
|
||||||
player.pause();
|
player.pause();
|
||||||
notificationHelper.updatePlayState(isPlaying());
|
playingNotificationHelper.updatePlayState(isPlaying());
|
||||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
|
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
|
||||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.PAUSE);
|
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.PAUSE);
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +505,7 @@ public class MusicService extends Service implements MediaPlayer.OnPreparedListe
|
||||||
if (requestFocus()) {
|
if (requestFocus()) {
|
||||||
if (isPlayerPrepared) {
|
if (isPlayerPrepared) {
|
||||||
player.start();
|
player.start();
|
||||||
notificationHelper.updatePlayState(isPlaying());
|
playingNotificationHelper.updatePlayState(isPlaying());
|
||||||
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
|
||||||
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.RESUME);
|
notifyOnMusicRemoteEventListeners(MusicRemoteEvent.RESUME);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
import com.kabouzeid.materialmusic.R;
|
import com.kabouzeid.materialmusic.R;
|
||||||
|
import com.kabouzeid.materialmusic.helper.AboutDeveloperDialogHelper;
|
||||||
import com.kabouzeid.materialmusic.helper.PlayingQueueDialogHelper;
|
import com.kabouzeid.materialmusic.helper.PlayingQueueDialogHelper;
|
||||||
import com.kabouzeid.materialmusic.interfaces.KabSearchAbleFragment;
|
import com.kabouzeid.materialmusic.interfaces.KabSearchAbleFragment;
|
||||||
import com.kabouzeid.materialmusic.interfaces.KabViewsDisableAble;
|
import com.kabouzeid.materialmusic.interfaces.KabViewsDisableAble;
|
||||||
|
|
@ -252,6 +253,9 @@ public class MainActivity extends AbsFabActivity
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case R.id.action_settings:
|
case R.id.action_settings:
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_about:
|
||||||
|
AboutDeveloperDialogHelper.getDialog(this).show();
|
||||||
|
return true;
|
||||||
case R.id.action_current_playing:
|
case R.id.action_current_playing:
|
||||||
openCurrentPlayingIfPossible(null);
|
openCurrentPlayingIfPossible(null);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -28,4 +28,10 @@
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:title="@string/action_settings"
|
android:title="@string/action_settings"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_about"
|
||||||
|
android:orderInCategory="101"
|
||||||
|
android:title="@string/action_about"
|
||||||
|
app:showAsAction="never"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<string name="navigation_drawer_open">Open navigation drawer</string>
|
<string name="navigation_drawer_open">Open navigation drawer</string>
|
||||||
<string name="navigation_drawer_close">Close navigation drawer</string>
|
<string name="navigation_drawer_close">Close navigation drawer</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
|
<string name="action_about">About</string>
|
||||||
<string name="action_current_playing">Current playing</string>
|
<string name="action_current_playing">Current playing</string>
|
||||||
<string name="action_playing_queue">Playing queue</string>
|
<string name="action_playing_queue">Playing queue</string>
|
||||||
<string name="action_search">Search</string>
|
<string name="action_search">Search</string>
|
||||||
|
|
@ -62,5 +63,7 @@
|
||||||
<string name="label_current_playing_queue">Playing queue</string>
|
<string name="label_current_playing_queue">Playing queue</string>
|
||||||
<string name="close">Close</string>
|
<string name="close">Close</string>
|
||||||
<string name="save_as_playlist">Save as playlist</string>
|
<string name="save_as_playlist">Save as playlist</string>
|
||||||
|
<string name="credits">Material Music is a completely free material designed music player by <b>Karim Abou Zeid</b>.\n\n<a href="https://plus.google.com/+KarimAbouZeid23697">Google+</a>   <a href="https://twitter.com/karim23697">Twitter</a></string>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@
|
||||||
<string name="transition_album_text">album_text_transition</string>
|
<string name="transition_album_text">album_text_transition</string>
|
||||||
<string name="transition_artist_image">artist_image_transition</string>
|
<string name="transition_artist_image">artist_image_transition</string>
|
||||||
<string name="transition_artist_text">artist_text_transition</string>
|
<string name="transition_artist_text">artist_text_transition</string>
|
||||||
<string name="DEV_TAG">karim23697</string>
|
<string name="DEV_TAG">kabouzeid</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue