-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
661 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
build/ | ||
custom_env.gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// sample file for setting custom environment params | ||
// rename it to custom_env.gradle and our build.gradle will apply it | ||
|
||
project.ext { | ||
customPropery = 'customValue' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...wail/sound/SoundNotificationsManager.java → ...ifications/SoundNotificationsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
.../src/main/java/com/artemzin/android/wail/notifications/StatusBarNotificationsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.artemzin.android.wail.notifications; | ||
|
||
import android.app.Activity; | ||
import android.app.Notification; | ||
import android.app.NotificationManager; | ||
import android.app.PendingIntent; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.support.v4.app.NotificationCompat; | ||
import android.support.v4.app.TaskStackBuilder; | ||
|
||
import com.artemzin.android.wail.R; | ||
import com.artemzin.android.wail.storage.WAILSettings; | ||
import com.artemzin.android.wail.storage.model.Track; | ||
import com.artemzin.android.wail.ui.activity.MainActivity; | ||
import com.artemzin.android.wail.util.Loggi; | ||
|
||
/** | ||
* @author Ilya Murzinov [murz42@gmail.com] | ||
*/ | ||
|
||
public class StatusBarNotificationsManager { | ||
private static final int NOTIFICATION_ID = 1; | ||
|
||
private static volatile StatusBarNotificationsManager instance; | ||
private Context context; | ||
|
||
private StatusBarNotificationsManager(Context context) { | ||
this.context = context; | ||
} | ||
|
||
public static StatusBarNotificationsManager getInstance(Context context) { | ||
if (instance == null) { | ||
synchronized (StatusBarNotificationsManager.class) { | ||
if (instance == null) { | ||
instance = new StatusBarNotificationsManager(context); | ||
} | ||
} | ||
} | ||
return instance; | ||
} | ||
|
||
public void showTrackScrobblingStatusBarNotification(Track track) { | ||
if (!WAILSettings.isStatusBarNotificationTrackScrobblingEnabled(context)) { | ||
Loggi.i("StatusBarNotificationsManager: Status bar notifications are disabled, skipping"); | ||
return; | ||
} | ||
|
||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Activity.NOTIFICATION_SERVICE); | ||
|
||
Intent resultIntent = new Intent(context, MainActivity.class); | ||
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context); | ||
taskStackBuilder.addParentStack(MainActivity.class); | ||
taskStackBuilder.addNextIntent(resultIntent); | ||
PendingIntent intent = taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); | ||
|
||
Notification notification = new NotificationCompat.Builder(context) | ||
.setContentTitle("Now scrobbling") | ||
.setContentText(track.getArtist() + " - " + track.getTrack()) | ||
.setSmallIcon(R.drawable.ic_status_wail_notifications) | ||
.setContentIntent(intent) | ||
.build(); | ||
notification.flags = Notification.FLAG_ONGOING_EVENT; | ||
|
||
notificationManager.notify(NOTIFICATION_ID, notification); | ||
} | ||
|
||
public void hideTrackScrobblingStatusBarNotification() { | ||
if (!WAILSettings.isStatusBarNotificationTrackScrobblingEnabled(context)) { | ||
Loggi.i("StatusBarNotificationsManager: Status bar notifications are disabled, skipping"); | ||
return; | ||
} | ||
|
||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Activity.NOTIFICATION_SERVICE); | ||
notificationManager.cancel(NOTIFICATION_ID); | ||
} | ||
|
||
public void cancelAllNotifications() { | ||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Activity.NOTIFICATION_SERVICE); | ||
notificationManager.cancelAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...n/java/com/artemzin/android/wail/ui/activity/settings/SettingsSelectLanguageActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.artemzin.android.wail.ui.activity.settings; | ||
|
||
import android.os.Bundle; | ||
|
||
import com.artemzin.android.wail.R; | ||
|
||
public class SettingsSelectLanguageActivity extends BaseSettingsActivity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_settings_select_language); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...om/artemzin/android/wail/ui/activity/settings/SettingsStatusBarNotificationsActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.artemzin.android.wail.ui.activity.settings; | ||
|
||
import android.os.Bundle; | ||
import com.artemzin.android.wail.R; | ||
|
||
/** | ||
* @author Ilya Murzinov [murz42@gmail.com] | ||
*/ | ||
public class SettingsStatusBarNotificationsActivity extends BaseSettingsActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_settings_status_bar_notifications); | ||
} | ||
} | ||
|
Oops, something went wrong.