app/src/main/java/dev/equwal/inkrecents/RecentsTileService.kt (1104 bytes)
1 // SPDX-License-Identifier: GPL-3.0-or-later 2 // Copyright (c) 2026 equwal 3 package dev.equwal.inkrecents 4 5 import android.app.PendingIntent 6 import android.content.Intent 7 import android.os.Build 8 import android.service.quicksettings.TileService 9 10 /** 11 * A tile in the quick settings panel. It opens the recents screen and closes 12 * the panel. 13 * 14 * From Android 14 a tile must hand the system a PendingIntent. The older call 15 * with a plain Intent throws there. 16 */ 17 class RecentsTileService : TileService() { 18 19 override fun onClick() { 20 super.onClick() 21 val intent = Intent(this, RecentsActivity::class.java) 22 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 23 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { 24 startActivityAndCollapse( 25 PendingIntent.getActivity( 26 this, 0, intent, 27 PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT 28 ) 29 ) 30 } else { 31 @Suppress("DEPRECATION") 32 startActivityAndCollapse(intent) 33 } 34 } 35 }