Notification trigger.

This commit is contained in:
Jens 2021-03-28 23:23:29 +02:00
parent 7894504791
commit fb44196a0d
7 changed files with 45 additions and 13 deletions

View File

@ -210,7 +210,7 @@
<service <service
android:name=".receivers.NotificationListener" android:name=".receivers.NotificationListener"
android:label="NotificationListener" android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter> <intent-filter>
<action android:name="android.service.notification.NotificationListenerService" /> <action android:name="android.service.notification.NotificationListenerService" />

View File

@ -186,7 +186,7 @@
<service <service
android:name=".receivers.NotificationListener" android:name=".receivers.NotificationListener"
android:label="NotificationListener" android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter> <intent-filter>
<action android:name="android.service.notification.NotificationListenerService" /> <action android:name="android.service.notification.NotificationListenerService" />

View File

@ -181,7 +181,7 @@
<service <service
android:name=".receivers.NotificationListener" android:name=".receivers.NotificationListener"
android:label="NotificationListener" android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter> <intent-filter>
<action android:name="android.service.notification.NotificationListenerService" /> <action android:name="android.service.notification.NotificationListenerService" />

View File

@ -215,9 +215,9 @@ public class Action
{ {
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.wakeupDevice)); returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.wakeupDevice));
} }
else if(this.getAction().equals(Action_Enum.playMusic)) else if(this.getAction().equals(Action_Enum.playSound))
{ {
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.playSound) + " " + getParameter2()); returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.playSound) + ": " + getParameter2());
} }
else else
returnString.append(action.toString()); returnString.append(action.toString());

View File

@ -1255,6 +1255,29 @@ public class ActivityManageRule extends Activity
this.refreshActionList(); this.refreshActionList();
} }
} }
else if(requestCode == requestCodeActionPlaySoundAdd)
{
if(resultCode == RESULT_OK)
{
newAction.setParameter1(data.getBooleanExtra("actionParameter1", false));
newAction.setParameter2(String.valueOf(data.getIntExtra("actionParameter2", 0)));
ruleToEdit.getActionSet().add(newAction);
this.refreshActionList();
}
}
else if(requestCode == requestCodeActionPlaySoundEdit)
{
if(resultCode == RESULT_OK)
{
if(data.hasExtra("actionParameter1"))
ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra("actionParameter1", false));
if(data.hasExtra("actionParameter2"))
ruleToEdit.getActionSet().get(editIndex).setParameter2(String.valueOf(data.getIntExtra("actionParameter2", 0)));
this.refreshActionList();
}
}
//TODO: Check with has data been changed or something like that. //TODO: Check with has data been changed or something like that.
/*try /*try

View File

@ -1443,6 +1443,8 @@ public class ActivityPermissions extends Activity
} }
public static Boolean verifyNotificationPermission() public static Boolean verifyNotificationPermission()
{
try
{ {
String theList = android.provider.Settings.Secure.getString(Miscellaneous.getAnyContext().getContentResolver(), "enabled_notification_listeners"); String theList = android.provider.Settings.Secure.getString(Miscellaneous.getAnyContext().getContentResolver(), "enabled_notification_listeners");
String[] theListList = theList.split(":"); String[] theListList = theList.split(":");
@ -1454,4 +1456,9 @@ public class ActivityPermissions extends Activity
} }
return false; return false;
} }
catch(Exception e)
{
return false;
}
}
} }

View File

@ -899,6 +899,8 @@ public class XmlFileInterface
newTrigger.setTriggerType(Trigger_Enum.bluetoothConnection); newTrigger.setTriggerType(Trigger_Enum.bluetoothConnection);
else if(triggerEventString.equals("headsetPlugged")) else if(triggerEventString.equals("headsetPlugged"))
newTrigger.setTriggerType(Trigger_Enum.headsetPlugged); newTrigger.setTriggerType(Trigger_Enum.headsetPlugged);
else if(triggerEventString.equals("notification"))
newTrigger.setTriggerType(Trigger_Enum.notification);
} }
else if (name.equals("TriggerParameter1")) else if (name.equals("TriggerParameter1"))
{ {