notification dismiss with button
This commit is contained in:
parent
f97bfbb732
commit
d17e8b70fe
@ -336,6 +336,14 @@ public class Action
|
|||||||
|
|
||||||
if (parts.length > 4 && !StringUtils.isBlank(parts[4]))
|
if (parts.length > 4 && !StringUtils.isBlank(parts[4]))
|
||||||
returnString.append(", " + Miscellaneous.getAnyContext().getResources().getString(R.string.ifString) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.text) + " " + Trigger.getMatchString(parts[3]) + " " + parts[4]);
|
returnString.append(", " + Miscellaneous.getAnyContext().getResources().getString(R.string.ifString) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.text) + " " + Trigger.getMatchString(parts[3]) + " " + parts[4]);
|
||||||
|
|
||||||
|
if(parts.length >= 6)
|
||||||
|
{
|
||||||
|
if(!parts[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
|
||||||
|
{
|
||||||
|
returnString.append(" " + String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.withButton), parts[5]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(this.getAction().equals(Action_Enum.setWifi))
|
else if(this.getAction().equals(Action_Enum.setWifi))
|
||||||
{
|
{
|
||||||
|
@ -125,11 +125,14 @@ public class Actions
|
|||||||
String myTitleDir = params[1];
|
String myTitleDir = params[1];
|
||||||
String requiredTitle = params[2];
|
String requiredTitle = params[2];
|
||||||
String myTextDir = params[3];
|
String myTextDir = params[3];
|
||||||
String requiredText;
|
String requiredText = "";
|
||||||
if (params.length >= 5)
|
String method = ActivityManageActionCloseNotification.dismissRegularString;
|
||||||
|
|
||||||
|
if(params.length >= 5)
|
||||||
requiredText = params[4];
|
requiredText = params[4];
|
||||||
else
|
|
||||||
requiredText = "";
|
if(params.length >= 6 && !params[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
|
||||||
|
method = params[5];
|
||||||
|
|
||||||
for (StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications())
|
for (StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications())
|
||||||
{
|
{
|
||||||
@ -183,7 +186,12 @@ public class Actions
|
|||||||
|
|
||||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "All criteria matches. Closing notification: " + sbn.getNotification().toString(), 3);
|
Miscellaneous.logEvent("i", "NotificationCloseCheck", "All criteria matches. Closing notification: " + sbn.getNotification().toString(), 3);
|
||||||
if(NotificationListener.getInstance() != null)
|
if(NotificationListener.getInstance() != null)
|
||||||
NotificationListener.getInstance().dismissNotification(sbn);
|
{
|
||||||
|
if(method == ActivityManageActionCloseNotification.dismissRegularString)
|
||||||
|
NotificationListener.getInstance().dismissNotification(sbn);
|
||||||
|
else
|
||||||
|
NotificationListener.getInstance().clickNotificationButton(sbn, method);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "NotificationListener instance is null. Can\'t close notification.", 3);
|
Miscellaneous.logEvent("i", "NotificationCloseCheck", "NotificationListener instance is null. Can\'t close notification.", 3);
|
||||||
}
|
}
|
||||||
|
@ -314,13 +314,6 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
String text = etNotificationText.getText().toString();
|
String text = etNotificationText.getText().toString();
|
||||||
|
|
||||||
Intent responseData = new Intent();
|
Intent responseData = new Intent();
|
||||||
// if(edit)
|
|
||||||
// {
|
|
||||||
// responseData.putExtra(ActivityManageRule.intentNameActionParameter2, app + Action.actionParameter2Split + titleDir + Action.actionParameter2Split + title + Action.actionParameter2Split + textDir + Action.actionParameter2Split + text);
|
|
||||||
// ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
|
|
||||||
String dismissMethod;
|
String dismissMethod;
|
||||||
if (rbNotificationDismissSimple.isChecked())
|
if (rbNotificationDismissSimple.isChecked())
|
||||||
@ -336,17 +329,16 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
dismissMethod = etNotificationDismissalButtonText.getText().toString();
|
dismissMethod = etNotificationDismissalButtonText.getText().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData.putExtra(ActivityManageRule.intentNameActionParameter2,
|
responseData.putExtra(ActivityManageRule.intentNameActionParameter2,
|
||||||
app + Action.actionParameter2Split +
|
app + Action.actionParameter2Split +
|
||||||
titleDir + Action.actionParameter2Split +
|
titleDir + Action.actionParameter2Split +
|
||||||
title + Action.actionParameter2Split +
|
title + Action.actionParameter2Split +
|
||||||
textDir + Action.actionParameter2Split +
|
textDir + Action.actionParameter2Split +
|
||||||
text + Action.actionParameter2Split +
|
text + Action.actionParameter2Split +
|
||||||
dismissMethod
|
dismissMethod
|
||||||
);
|
);
|
||||||
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -387,14 +379,17 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
be incorrectly interpreted as a text notification text.
|
be incorrectly interpreted as a text notification text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (params.length >= 6)
|
if (params.length >= 6 && !params[5].equals(dismissRegularString))
|
||||||
{
|
{
|
||||||
rbNotificationDismissButton.setChecked(true);
|
rbNotificationDismissButton.setChecked(true);
|
||||||
etNotificationDismissalButtonText.setText(params[5]);
|
etNotificationDismissalButtonText.setText(params[5]);
|
||||||
|
etNotificationDismissalButtonText.setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rbNotificationDismissSimple.setChecked(true);
|
rbNotificationDismissSimple.setChecked(true);
|
||||||
|
etNotificationDismissalButtonText.setText("");
|
||||||
|
etNotificationDismissalButtonText.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!app.equals(Trigger.anyAppString))
|
if(!app.equals(Trigger.anyAppString))
|
||||||
|
@ -245,21 +245,24 @@ public class NotificationListener extends NotificationListenerService// implemen
|
|||||||
{
|
{
|
||||||
boolean buttonFound = false;
|
boolean buttonFound = false;
|
||||||
|
|
||||||
for (Notification.Action a : sbn.getNotification().actions)
|
if(sbn.getNotification().actions != null)
|
||||||
{
|
{
|
||||||
if(a.toString().equalsIgnoreCase(buttonText))
|
for (Notification.Action a : sbn.getNotification().actions)
|
||||||
{
|
{
|
||||||
if(!buttonFound)
|
if((Miscellaneous.isRegularExpression(buttonText) && a.title.toString().matches(buttonText)) || a.title.toString().equalsIgnoreCase(buttonText))
|
||||||
buttonFound = true;
|
{
|
||||||
|
if (!buttonFound)
|
||||||
|
buttonFound = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("w", "clickNotificationButton()", "Pressing button with text \"" + a.title.toString() + "\".", 2);
|
Miscellaneous.logEvent("w", "clickNotificationButton()", "Pressing button with text \"" + a.title.toString() + "\".", 2);
|
||||||
a.actionIntent.send();
|
a.actionIntent.send();
|
||||||
}
|
}
|
||||||
catch (PendingIntent.CanceledException e)
|
catch (PendingIntent.CanceledException e)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("w", "clickNotificationButton()", Log.getStackTraceString(e), 2);
|
Miscellaneous.logEvent("w", "clickNotificationButton()", Log.getStackTraceString(e), 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,6 +120,22 @@
|
|||||||
android:layout_marginVertical="@dimen/default_margin"
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
android:background="#aa000000" />
|
android:background="#aa000000" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/comparisonCaseInsensitive"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/regularExpressionsIfEquals"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||||
|
|
||||||
@ -177,13 +193,41 @@
|
|||||||
<EditText
|
<EditText
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:id="@+id/etNotificationDismissalButtonText"
|
android:id="@+id/etNotificationDismissalButtonText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/comparisonCaseInsensitive"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/mayUseRegularExpressions"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -519,7 +519,7 @@
|
|||||||
<string name="notification">Benachrichtigung</string>
|
<string name="notification">Benachrichtigung</string>
|
||||||
<string name="title">Titel</string>
|
<string name="title">Titel</string>
|
||||||
<string name="text">Text</string>
|
<string name="text">Text</string>
|
||||||
<string name="anyApp">Irgendeine Anwendung</string>
|
<string name="anyApp">irgendeine Anwendung</string>
|
||||||
<string name="postsNotification">%1$s zeigt eine Benachrichtung an</string>
|
<string name="postsNotification">%1$s zeigt eine Benachrichtung an</string>
|
||||||
<string name="removedNotification">Benachrichtigung von %1$s wurde entfernt</string>
|
<string name="removedNotification">Benachrichtigung von %1$s wurde entfernt</string>
|
||||||
<string name="notificationAppears">Benachrichtigung wird angezeigt</string>
|
<string name="notificationAppears">Benachrichtigung wird angezeigt</string>
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
<string name="anotherProfileByThatName">Nome già usato per un altro profilo.</string>
|
<string name="anotherProfileByThatName">Nome già usato per un altro profilo.</string>
|
||||||
<string name="anotherRuleByThatName">Nome già usato per un\'altra regola.</string>
|
<string name="anotherRuleByThatName">Nome già usato per un\'altra regola.</string>
|
||||||
<string name="any">qualsiasi</string>
|
<string name="any">qualsiasi</string>
|
||||||
<string name="anyApp">Qualsiasi applicazione</string>
|
<string name="anyApp">qualsiasi applicazione</string>
|
||||||
<string name="anyDevice">qualsiasi dispositivo</string>
|
<string name="anyDevice">qualsiasi dispositivo</string>
|
||||||
<string name="anyLocation">qualsiasi posizione</string>
|
<string name="anyLocation">qualsiasi posizione</string>
|
||||||
<string name="anyNumber">qualsiasi numero</string>
|
<string name="anyNumber">qualsiasi numero</string>
|
||||||
|
@ -516,7 +516,7 @@
|
|||||||
<string name="directionStringStartsWith">begint met</string>
|
<string name="directionStringStartsWith">begint met</string>
|
||||||
<string name="directionStringEndsWith">eindigt met</string>
|
<string name="directionStringEndsWith">eindigt met</string>
|
||||||
<string name="directionStringNotEquals">is niet gelijk aan</string>
|
<string name="directionStringNotEquals">is niet gelijk aan</string>
|
||||||
<string name="anyApp">Elke app</string>
|
<string name="anyApp">elke app</string>
|
||||||
<string name="notificationTriggerExplanation">Deze trigger zal reageren op andere applicaties die meldingen openen in het meldingsgebied (of die worden gesloten). Je kunt een andere applicatie specificeren waar de melding vandaan moet komen. Als je dat niet doet, tellen de meldingen van een andere toepassing mee. U kunt ook tekenreeksen opgeven die wel of niet in de titel of de body van de melding moeten voorkomen. De vergelijking gebeurt hoofdletter-IN-sensitief.</string>
|
<string name="notificationTriggerExplanation">Deze trigger zal reageren op andere applicaties die meldingen openen in het meldingsgebied (of die worden gesloten). Je kunt een andere applicatie specificeren waar de melding vandaan moet komen. Als je dat niet doet, tellen de meldingen van een andere toepassing mee. U kunt ook tekenreeksen opgeven die wel of niet in de titel of de body van de melding moeten voorkomen. De vergelijking gebeurt hoofdletter-IN-sensitief.</string>
|
||||||
<string name="postsNotification">%1$s berichten notificatie</string>
|
<string name="postsNotification">%1$s berichten notificatie</string>
|
||||||
<string name="removedNotification">kennisgeving van %1$s verwijderd</string>
|
<string name="removedNotification">kennisgeving van %1$s verwijderd</string>
|
||||||
|
@ -618,7 +618,7 @@
|
|||||||
<string name="directionStringStartsWith">starts with</string>
|
<string name="directionStringStartsWith">starts with</string>
|
||||||
<string name="directionStringEndsWith">ends with</string>
|
<string name="directionStringEndsWith">ends with</string>
|
||||||
<string name="directionStringNotEquals">not equals</string>
|
<string name="directionStringNotEquals">not equals</string>
|
||||||
<string name="anyApp">Any app</string>
|
<string name="anyApp">any app</string>
|
||||||
<string name="notificationTriggerExplanation">This trigger will respond to other applications opening notifications in the notification area (or such being closed). You can specify another application from which the notification has to come from. If you don\'t the notifications from any other application will count. You can also specify strings that must be or must not be in their title or notification body. The comparison is done case-INsensitive.</string>
|
<string name="notificationTriggerExplanation">This trigger will respond to other applications opening notifications in the notification area (or such being closed). You can specify another application from which the notification has to come from. If you don\'t the notifications from any other application will count. You can also specify strings that must be or must not be in their title or notification body. The comparison is done case-INsensitive.</string>
|
||||||
<string name="postsNotification">%1$s posts notification</string>
|
<string name="postsNotification">%1$s posts notification</string>
|
||||||
<string name="removedNotification">notification from %1$s removed</string>
|
<string name="removedNotification">notification from %1$s removed</string>
|
||||||
@ -844,4 +844,5 @@
|
|||||||
<string name="locationRequiredToDetermineWifiName">To get the wifi SSID, the app requires location permissions. Because the Google version cannot get that, you can only use this trigger if you do not specify an SSID. So it can only be used to detect if wifi is connected or not.</string>
|
<string name="locationRequiredToDetermineWifiName">To get the wifi SSID, the app requires location permissions. Because the Google version cannot get that, you can only use this trigger if you do not specify an SSID. So it can only be used to detect if wifi is connected or not.</string>
|
||||||
<string name="simplyDismissNotification">Simply dismiss</string>
|
<string name="simplyDismissNotification">Simply dismiss</string>
|
||||||
<string name="clickNotificationButton">Click a button</string>
|
<string name="clickNotificationButton">Click a button</string>
|
||||||
|
<string name="withButton">with button %1$s</string>
|
||||||
</resources>
|
</resources>
|
@ -1,5 +1,6 @@
|
|||||||
* New action: Keep phone turned on
|
* New action: Keep phone turned on
|
||||||
* New: Regular expressions enabled where comparisons apply (one has to use "equals")
|
* New: Regular expressions enabled where comparisons apply (one has to use "equals")
|
||||||
|
* New: Notification closing can now also be achieved by clicking a button of the target notification.
|
||||||
* Fixed: Changed input type for decimal numbers when adding intent data
|
* Fixed: Changed input type for decimal numbers when adding intent data
|
||||||
* Fixed: Battery level trigger not working when using direction falling-below
|
* Fixed: Battery level trigger not working when using direction falling-below
|
||||||
* New: Wifi trigger can now use Regex for SSID
|
* New: Wifi trigger can now use Regex for SSID
|
Loading…
Reference in New Issue
Block a user