diff --git a/.gitignore b/.gitignore index 1428103..f8338d3 100644 --- a/.gitignore +++ b/.gitignore @@ -145,7 +145,7 @@ fabric.properties # End of https://www.toptal.com/developers/gitignore/api/androidstudio - +output-metadata.json /app/app-release.apk Automation_settings.xml /app/googlePlayFlavor/ diff --git a/app/googlePlayFlavor/release/output-metadata.json b/app/googlePlayFlavor/release/output-metadata.json deleted file mode 100644 index a8fd6ec..0000000 --- a/app/googlePlayFlavor/release/output-metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": 3, - "artifactType": { - "type": "APK", - "kind": "Directory" - }, - "applicationId": "com.jens.automation2", - "variantName": "googlePlayFlavorRelease", - "elements": [ - { - "type": "SINGLE", - "filters": [], - "attributes": [], - "versionCode": 121, - "versionName": "1.7.6-googlePlay", - "outputFile": "app-googlePlayFlavor-release.apk" - } - ], - "elementType": "File" -} \ No newline at end of file diff --git a/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java b/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java index 92aa50c..8603a35 100644 --- a/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java +++ b/app/src/main/java/com/jens/automation2/receivers/NotificationListener.java @@ -2,6 +2,7 @@ package com.jens.automation2.receivers; import android.annotation.SuppressLint; import android.app.Notification; +import android.app.PendingIntent; import android.bluetooth.BluetoothDevice; import android.content.IntentFilter; import android.os.Build; @@ -149,51 +150,6 @@ public class NotificationListener extends NotificationListenerService// implemen return returnNotification; } - /*@Override - public void startListener(AutomationService automationService) - { - if(instance == null) - instance = new NotificationListener(); - - if(notificationReceiverIntentFilter == null) - { - notificationReceiverIntentFilter = new IntentFilter(); - notificationReceiverIntentFilter.addAction("android.service.notification.NotificationListenerService"); - } - - try - { - if(!listenerRunning) - { - Miscellaneous.logEvent("i", "NotificationListener", "Starting NotificationListener", 4); - listenerRunning = true; - AutomationService.getInstance().registerReceiver(instance, notificationReceiverIntentFilter); - } - } - catch(Exception ex) - { - Miscellaneous.logEvent("e", "BluetoothReceiver", "Error starting BluetoothReceiver: " + Log.getStackTraceString(ex), 3); - } - } - - @Override - public void stopListener(AutomationService automationService) - { - - } - - @Override - public boolean isListenerRunning() - { - return false; - } - - @Override - public Trigger.Trigger_Enum[] getMonitoredTrigger() - { - return new Trigger.Trigger_Enum[0]; - }*/ - public static class SimpleNotification { boolean created; @@ -283,4 +239,32 @@ public class NotificationListener extends NotificationListenerService// implemen cancelNotification(sbn.getKey()); } + + @RequiresApi(api = Build.VERSION_CODES.KITKAT) + public void clickNotificationButton(StatusBarNotification sbn, String buttonText) + { + boolean buttonFound = false; + + for (Notification.Action a : sbn.getNotification().actions) + { + if(a.toString().equalsIgnoreCase(buttonText)) + { + if(!buttonFound) + buttonFound = true; + + try + { + Miscellaneous.logEvent("w", "clickNotificationButton()", "Pressing button with text \"" + a.title.toString() + "\".", 2); + a.actionIntent.send(); + } + catch (PendingIntent.CanceledException e) + { + Miscellaneous.logEvent("w", "clickNotificationButton()", Log.getStackTraceString(e), 2); + } + } + } + + if(!buttonFound) + Miscellaneous.logEvent("w", "clickNotificationButton()", "Button with text \n" + buttonText + "\n could not found.", 2); + } } \ No newline at end of file