1
- // SPDX-FileCopyrightText: 2023 Paul Colby <[email protected] >
1
+ // SPDX-FileCopyrightText: 2023-2024 Paul Colby <[email protected] >
2
2
// SPDX-License-Identifier: GPL-3.0-or-later
3
3
4
4
package au.id.colby.nfcquicksettings
@@ -14,18 +14,19 @@ import android.provider.Settings
14
14
import android.service.quicksettings.Tile
15
15
import android.service.quicksettings.TileService
16
16
import android.util.Log
17
- import au.id.colby.nfcquicksettings.R.*
17
+ import au.id.colby.nfcquicksettings.R.string
18
18
import java.util.Timer
19
19
import kotlin.concurrent.fixedRateTimer
20
20
21
+ private const val TAG = " NfcTileService"
22
+
21
23
/* *
22
24
* A custom Quick Settings tile for NFC.
23
25
*
24
26
* The tile shows the current NFC status (On, Off, or Unavailable), and when clicked, starts the
25
27
* device's NFC Settings activity.
26
28
*/
27
29
class NfcTileService : TileService () {
28
- private val TAG = " NfcTileService"
29
30
private var updateTimer: Timer ? = null
30
31
31
32
/* *
@@ -44,7 +45,7 @@ class NfcTileService : TileService() {
44
45
Log .d(TAG , " Updating tile" )
45
46
state = if (adapter == null ) Tile .STATE_INACTIVE else
46
47
if (adapter.isEnabled) Tile .STATE_ACTIVE else Tile .STATE_INACTIVE
47
- if (Build . VERSION . SDK_INT >= Build .VERSION_CODES .Q ) subtitle = getText(
48
+ if (SDK_INT >= Build .VERSION_CODES .Q ) subtitle = getText(
48
49
if (adapter == null ) string.tile_subtitle_unavailable else
49
50
if (adapter.isEnabled) string.tile_subtitle_active else string.tile_subtitle_inactive
50
51
)
@@ -78,6 +79,7 @@ class NfcTileService : TileService() {
78
79
Log .d(TAG , " onClick" )
79
80
val intent = Intent (Settings .ACTION_NFC_SETTINGS )
80
81
intent.flags = Intent .FLAG_ACTIVITY_NEW_TASK
82
+ // noinspection StartActivityAndCollapseDeprecated
81
83
if (SDK_INT < UPSIDE_DOWN_CAKE ) @Suppress(" DEPRECATION" ) startActivityAndCollapse(intent)
82
84
else startActivityAndCollapse(PendingIntent .getActivity(this , 0 , intent, FLAG_IMMUTABLE ))
83
85
}
0 commit comments