Skip to content

Commit

Permalink
Media notification podcast style
Browse files Browse the repository at this point in the history
  • Loading branch information
snaebjornl committed Jan 4, 2019
1 parent 58535b0 commit 4f10824
Show file tree
Hide file tree
Showing 45 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public void onMethodCall(MethodCall call, Result result) {
final String title = call.argument("title");
final String author = call.argument("author");
final boolean play = call.argument("play");
show(title, author, play);
final boolean beint = call.argument("beint");
show(title, author, play, beint);
result.success(null);
break;

Expand Down Expand Up @@ -88,7 +89,7 @@ public void notImplemented() { }
}
}

public static void show(String title, String author, boolean play) {
public static void show(String title, String author, boolean play, boolean beint) {
Log.i(TAG, "show");
if (nPanel != null) {
nPanel.releaseLocks();
Expand All @@ -103,7 +104,7 @@ public static void show(String title, String author, boolean play) {
notificationManager.createNotificationChannel(channel);
}
}
nPanel = new NotificationPanel(registrar.context(), title, author, play);
nPanel = new NotificationPanel(registrar.context(), title, author, play, beint);
}

private void hide() {
Expand All @@ -117,7 +118,7 @@ private void stopSound() {
if (nPanel != null) {
nPanel.stopSound();
} else {
show("RÚV", "", false);
//show("RÚV", "", false);
nPanel.stopSound();
hide();
}
Expand All @@ -128,7 +129,7 @@ private void getWifiLock() {
if (nPanel != null) {
nPanel.getWifiLock();
} else {
show("RÚV", "", false);
//show("RÚV", "", false);
nPanel.getWifiLock();
hide();
}
Expand All @@ -140,7 +141,7 @@ private void releaseLocks() {
if (nPanel != null) {
nPanel.releaseLocks();
} else {
show("RÚV", "", false);
//show("RÚV", "", false);
nPanel.releaseLocks();
hide();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ public class NotificationPanel extends Activity {
private String title;
private String author;
private boolean play;
private boolean beint;
private WifiManager.WifiLock wifiLock;
private PowerManager.WakeLock wakeLock;
private AudioManager audioManager;
PowerManager powerManager;

public NotificationPanel(Context parent, String title, String author, boolean play) {
public NotificationPanel(Context parent, String title, String author, boolean play, boolean beint) {
this.parent = parent;
this.title = title;
this.author = author;
this.play = play;
this.beint = beint;

Intent dismissIntent = new Intent(parent, NotificationReturnSlot.class)
.setAction("dismiss");
Expand Down Expand Up @@ -73,6 +75,15 @@ public NotificationPanel(Context parent, String title, String author, boolean pl
remoteView.setImageViewResource(R.id.toggle, R.drawable.baseline_play_arrow_black_48);
}

if (this.beint) {
remoteView.setImageViewResource(R.id.prev, R.drawable.baseline_replay_30_black_36);
remoteView.setImageViewResource(R.id.next, R.drawable.baseline_skip_next_black_36);
} else {
remoteView.setImageViewResource(R.id.prev, R.drawable.baseline_replay_30_black_36);
remoteView.setImageViewResource(R.id.next, R.drawable.baseline_forward_30_black_36
);
}

setListeners(remoteView);
nBuilder.setContent(remoteView);

Expand Down Expand Up @@ -198,7 +209,9 @@ public void setListeners(RemoteViews view){
.setAction("toggle")
.putExtra("title", this.title)
.putExtra("author", this.author)
.putExtra("action", !this.play ? "play" : "pause");
.putExtra("action", !this.play ? "play" : "pause")
.putExtra("beint", this.beint);

PendingIntent pendingIntent = PendingIntent.getBroadcast(parent, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
view.setOnClickPendingIntent(R.id.toggle, pendingIntent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ public void onReceive(Context context, Intent intent) {
String title = intent.getStringExtra("title");
String author = intent.getStringExtra("author");
String action = intent.getStringExtra("action");
boolean beint = intent.getBooleanExtra("beint",false);

MediaNotificationPlugin.show(title, author, action.equals("play"));
MediaNotificationPlugin.show(title, author, action.equals("play"), beint);
MediaNotificationPlugin.callEvent(action);
break;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions android/src/main/res/layout/notificationlayout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
android:layout_toLeftOf="@id/toggle"
android:padding="4dp"
android:paddingRight="0dp"
android:src="@drawable/baseline_skip_previous_black_36"
/>
<ImageView
android:id="@+id/toggle"
Expand All @@ -53,6 +52,5 @@
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:padding="4dp"
android:src="@drawable/baseline_skip_next_black_36"
/>
</RelativeLayout>
5 changes: 3 additions & 2 deletions lib/media_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ class MediaNotification {
});
}

static Future show({@required title, @required author, play = true}) async {
static Future show({@required title, @required author, play = true, beint = false}) async {
final Map<String, dynamic> params = <String, dynamic>{
'title': title,
'author': author,
'play': play
'play': play,
'beint': beint
};
await _channel.invokeMethod('show', params);

Expand Down

0 comments on commit 4f10824

Please sign in to comment.