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
android:name=".receivers.NotificationListener"
android:label="NotificationListener"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />

View File

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

View File

@ -181,7 +181,7 @@
<service
android:name=".receivers.NotificationListener"
android:label="NotificationListener"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter>
<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));
}
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
returnString.append(action.toString());

View File

@ -1255,6 +1255,29 @@ public class ActivityManageRule extends Activity
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.
/*try

View File

@ -1444,14 +1444,21 @@ public class ActivityPermissions extends Activity
public static Boolean verifyNotificationPermission()
{
String theList = android.provider.Settings.Secure.getString(Miscellaneous.getAnyContext().getContentResolver(), "enabled_notification_listeners");
String[] theListList = theList.split(":");
String me = (new ComponentName(Miscellaneous.getAnyContext(), NotificationListener.class)).flattenToString();
for ( String next : theListList )
try
{
if ( me.equals(next) )
return true;
String theList = android.provider.Settings.Secure.getString(Miscellaneous.getAnyContext().getContentResolver(), "enabled_notification_listeners");
String[] theListList = theList.split(":");
String me = (new ComponentName(Miscellaneous.getAnyContext(), NotificationListener.class)).flattenToString();
for (String next : theListList)
{
if (me.equals(next))
return true;
}
return false;
}
catch(Exception e)
{
return false;
}
return false;
}
}
}

View File

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