-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96487eb
commit b7fe919
Showing
9 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
core/ui/src/main/kotlin/org/michaelbel/movies/ui/tile/MoviesTileService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.michaelbel.movies.ui.tile | ||
|
||
import android.app.PendingIntent | ||
import android.content.Intent | ||
import android.graphics.drawable.Icon | ||
import android.os.Build | ||
import android.service.quicksettings.TileService | ||
import android.widget.Toast | ||
import org.michaelbel.movies.ui.R | ||
import org.michaelbel.movies.ui.icons.MoviesIcons | ||
|
||
class MoviesTileService: TileService() { | ||
|
||
override fun onTileAdded() { | ||
super.onTileAdded() | ||
Toast.makeText(this, R.string.tile_added, Toast.LENGTH_SHORT).show() | ||
} | ||
|
||
override fun onStartListening() { | ||
super.onStartListening() | ||
val tile = qsTile | ||
tile.label = getString(R.string.tile_title) | ||
tile.icon = Icon.createWithResource(this, MoviesIcons.MovieFilter24) | ||
tile.updateTile() | ||
} | ||
|
||
override fun onClick() { | ||
super.onClick() | ||
runCatching { | ||
val intent = packageManager.getLaunchIntentForPackage(packageName)?.apply { | ||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
} | ||
val pendingIntent = PendingIntent.getActivity( | ||
this, | ||
0, | ||
intent, | ||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE | ||
) | ||
if (Build.VERSION.SDK_INT >= 34) { | ||
startActivityAndCollapse(pendingIntent) | ||
} else { | ||
@Suppress("deprecation") | ||
startActivityAndCollapse(intent) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters