11package com.joebuildsthings.gamedeck
22
3+ import android.Manifest
34import android.content.Intent
5+ import android.content.pm.PackageManager
46import android.net.Uri
7+ import android.os.Build
58import android.os.Bundle
69import android.provider.Settings
710import androidx.activity.ComponentActivity
11+ import androidx.activity.compose.rememberLauncherForActivityResult
812import androidx.activity.compose.setContent
13+ import androidx.activity.result.contract.ActivityResultContracts
914import androidx.compose.foundation.background
1015import androidx.compose.foundation.layout.*
1116import androidx.compose.material.icons.Icons
@@ -16,9 +21,11 @@ import androidx.compose.material3.*
1621import androidx.compose.runtime.*
1722import androidx.compose.ui.Modifier
1823import androidx.compose.ui.graphics.vector.ImageVector
24+ import androidx.compose.ui.platform.LocalContext
1925import androidx.compose.ui.text.font.FontWeight
2026import androidx.compose.ui.unit.dp
2127import androidx.compose.ui.unit.sp
28+ import androidx.core.content.ContextCompat
2229import com.joebuildsthings.gamedeck.screens.GamesScreen
2330import com.joebuildsthings.gamedeck.screens.HomeScreen
2431import com.joebuildsthings.gamedeck.screens.SettingsScreen
@@ -64,7 +71,11 @@ class MainActivity : ComponentActivity() {
6471 val intent = Intent (this , OverlayService ::class .java).apply {
6572 action = if (enable) OverlayService .ACTION_START else OverlayService .ACTION_STOP
6673 }
67- if (enable) startForegroundService(intent) else startService(intent)
74+ if (enable) {
75+ ContextCompat .startForegroundService(this , intent)
76+ } else {
77+ startService(intent)
78+ }
6879 }
6980}
7081
@@ -74,13 +85,27 @@ fun GameDeckApp(
7485 onRequestOverlay : () -> Unit ,
7586 onToggleOverlay : (Boolean ) -> Unit ,
7687) {
88+ val context = LocalContext .current
7789 val tabs = listOf (
7890 Tab (" Home" , Icons .Filled .Home ),
7991 Tab (" Games" , Icons .Filled .SportsEsports ),
8092 Tab (" Settings" , Icons .Filled .Settings ),
8193 )
8294 var current by remember { mutableIntStateOf(0 ) }
8395
96+ val notifLauncher = rememberLauncherForActivityResult(
97+ ActivityResultContracts .RequestPermission ()
98+ ) { }
99+
100+ LaunchedEffect (Unit ) {
101+ if (Build .VERSION .SDK_INT >= 33 ) {
102+ val granted = ContextCompat .checkSelfPermission(
103+ context, Manifest .permission.POST_NOTIFICATIONS
104+ ) == PackageManager .PERMISSION_GRANTED
105+ if (! granted) notifLauncher.launch(Manifest .permission.POST_NOTIFICATIONS )
106+ }
107+ }
108+
84109 Scaffold (
85110 containerColor = BgDark ,
86111 topBar = {
@@ -90,30 +115,25 @@ fun GameDeckApp(
90115 Text (
91116 " GameDeck" ,
92117 color = InkLight ,
93- fontWeight = FontWeight .SemiBold ,
94- fontSize = 18 .sp,
118+ fontWeight = FontWeight .Bold ,
119+ fontSize = 19 .sp,
120+ letterSpacing = (- 0.5 ).sp,
95121 )
96122 Spacer (Modifier .width(10 .dp))
97- Text (
98- " v0.1" ,
99- color = MutedGrey ,
100- fontSize = 11 .sp,
101- )
123+ Text (" v0.1" , color = MutedGrey , fontSize = 11 .sp)
102124 }
103125 },
104- colors = TopAppBarDefaults .topAppBarColors(
105- containerColor = BgDark ,
106- )
126+ colors = TopAppBarDefaults .topAppBarColors(containerColor = BgDark )
107127 )
108128 },
109129 bottomBar = {
110- NavigationBar (containerColor = BgDark ) {
130+ NavigationBar (containerColor = BgDark , tonalElevation = 0 .dp ) {
111131 tabs.forEachIndexed { i, tab ->
112132 NavigationBarItem (
113133 selected = current == i,
114134 onClick = { current = i },
115135 icon = { Icon (tab.icon, contentDescription = tab.label) },
116- label = { Text (tab.label, fontSize = 11 .sp) },
136+ label = { Text (tab.label, fontSize = 11 .sp, fontWeight = FontWeight . Medium ) },
117137 colors = NavigationBarItemDefaults .colors(
118138 selectedIconColor = AccentRed ,
119139 selectedTextColor = AccentRed ,
0 commit comments