forked from jens/Automation
		
	Notification trigger.
This commit is contained in:
		| @@ -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" /> | ||||
|   | ||||
| @@ -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" /> | ||||
|   | ||||
| @@ -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" /> | ||||
|   | ||||
| @@ -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()); | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
| } | ||||
| } | ||||
| @@ -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")) | ||||
|             { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user