mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Fix custom actions on sdk >= 34
This commit is contained in:
parent
965e22bf34
commit
98cc6c5497
@ -22,6 +22,7 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.externalevents;
|
package nodomain.freeyourgadget.gadgetbridge.externalevents;
|
||||||
|
|
||||||
|
import android.app.ActivityOptions;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@ -243,7 +244,14 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
RemoteInput.addResultsToIntent(new RemoteInput[]{remoteInput}, localIntent, extras);
|
RemoteInput.addResultsToIntent(new RemoteInput[]{remoteInput}, localIntent, extras);
|
||||||
actionIntent.send(context, 0, localIntent);
|
actionIntent.send(context, 0, localIntent);
|
||||||
} else {
|
} else {
|
||||||
actionIntent.send();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
|
final ActivityOptions activityOptions = ActivityOptions.makeBasic();
|
||||||
|
final Bundle bundle = activityOptions.setPendingIntentBackgroundActivityStartMode(ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED)
|
||||||
|
.toBundle();
|
||||||
|
actionIntent.send(bundle);
|
||||||
|
} else {
|
||||||
|
actionIntent.send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mActionLookup.remove(handle);
|
mActionLookup.remove(handle);
|
||||||
} catch (final PendingIntent.CanceledException e) {
|
} catch (final PendingIntent.CanceledException e) {
|
||||||
@ -500,7 +508,7 @@ public class NotificationListener extends NotificationListenerService {
|
|||||||
notificationSpec.attachedActions.add(customAction);
|
notificationSpec.attachedActions.add(customAction);
|
||||||
customAction.handle = ((long) notificationSpec.getId() << 4) + notificationSpec.attachedActions.size();
|
customAction.handle = ((long) notificationSpec.getId() << 4) + notificationSpec.attachedActions.size();
|
||||||
mActionLookup.add((int) customAction.handle, new NotificationAction(act.actionIntent, remoteInput));
|
mActionLookup.add((int) customAction.handle, new NotificationAction(act.actionIntent, remoteInput));
|
||||||
LOG.info("Found custom action {}: {} - {} {}", notificationSpec.attachedActions.size(), (int) customAction.handle, act.title, sbn.getTag());
|
LOG.info("Found custom action {}: {} - {}", notificationSpec.attachedActions.size(), (int) customAction.handle, act.title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user