Skip to content

Commit

Permalink
Allow tile to collapse on newer Android versions
Browse files Browse the repository at this point in the history
  • Loading branch information
papjul committed Nov 8, 2024
1 parent 4d5c2f9 commit 54b7d9e
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.example.deeplviewer.service

import android.annotation.SuppressLint
import android.app.PendingIntent
import android.content.Intent
import android.os.Build
import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
import android.annotation.SuppressLint
import com.example.deeplviewer.activity.FloatingTextSelection

@RequiresApi(Build.VERSION_CODES.N)
Expand All @@ -15,10 +15,12 @@ class QSTileService : TileService() {
intent.putExtra(Intent.EXTRA_TEXT, "")

@SuppressLint("StartActivityAndCollapseDeprecated")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startActivity(intent)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
this.startActivityAndCollapse(
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)
)
} else {
startActivityAndCollapse(intent)
this.startActivityAndCollapse(intent)
}
}
}

0 comments on commit 54b7d9e

Please sign in to comment.