Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cba88994 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

update tile launch logic for API 34 compatibility

parent 6dd4f908
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
package org.dmfs.tasks.quicksettings;

import android.app.PendingIntent;
import android.content.Intent;
import android.os.Build;
import android.service.quicksettings.Tile;
@@ -12,10 +13,23 @@ public class TaskQuickSettingsTile extends TileService {

    @Override
    public void onClick() {
        final Intent taskCreateIntent = new Intent(getApplicationContext(), EditTaskActivity.class);
        Intent taskCreateIntent = new Intent(getApplicationContext(), EditTaskActivity.class);
        taskCreateIntent.setFlags(
                Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        unlockAndRun(() -> startActivityAndCollapse(taskCreateIntent));

        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, taskCreateIntent,
                PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);

        unlockAndRun(() -> {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
                startActivityAndCollapse(pendingIntent);
            } else {
                try {
                    pendingIntent.send();
                } catch (PendingIntent.CanceledException ignored) {
                }
            }
        });
    }

    @Override