Skip to content

Commit 28ce03d

Browse files
committed
feat: update launcher bg color, refractor dynamic shortcuts and update themes
1 parent 46561d8 commit 28ce03d

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

app/src/main/java/com/mrepol742/webappp/MainActivity.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.activity.compose.setContent
88
import androidx.activity.enableEdgeToEdge
99
import androidx.compose.foundation.layout.fillMaxSize
1010
import androidx.compose.foundation.layout.padding
11+
import androidx.compose.foundation.layout.systemBarsPadding
1112
import androidx.compose.material3.Scaffold
1213
import androidx.compose.runtime.mutableStateOf
1314
import androidx.compose.ui.Modifier
@@ -18,6 +19,13 @@ import com.mrepol742.webappp.utils.DynamicShortcut
1819
class MainActivity : ComponentActivity() {
1920
private val allowedDomain = "www.melvinjonesrepol.com"
2021
private var currentUrl: String = "https://$allowedDomain"
22+
private val shortcuts = listOf(
23+
"/projects" to "My Projects",
24+
"/gaming" to "The Games I Played",
25+
"https://go.melvinjonesrepol.com" to "ShortLink",
26+
"https://ai.melvinjonesrepol.com" to "Melvin AI",
27+
"/contact-me" to "Contact Me",
28+
)
2129
private val webViewState = mutableStateOf<WebView?>(null)
2230

2331
override fun onCreate(savedInstanceState: Bundle?) {
@@ -26,7 +34,7 @@ class MainActivity : ComponentActivity() {
2634

2735
setContent {
2836
WebApppTheme {
29-
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
37+
Scaffold(modifier = Modifier.fillMaxSize().systemBarsPadding()) { innerPadding ->
3038
WebViewScreen(
3139
allowedDomain = allowedDomain,
3240
initialUrl = currentUrl,
@@ -37,7 +45,7 @@ class MainActivity : ComponentActivity() {
3745
}
3846
}
3947

40-
DynamicShortcut(this, allowedDomain).createDynamicShortcut()
48+
DynamicShortcut(this, allowedDomain, shortcuts).createDynamicShortcut()
4149
}
4250

4351
override fun onResume() {

app/src/main/java/com/mrepol742/webappp/client/SecureWebViewClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class SecureWebViewClient(
8282
}
8383
"http", "https" -> {
8484
val host = uri.host ?: return false
85-
val allowedDomainRegex = Regex("(^|\\.)${Regex.escape(allowedDomain)}$")
85+
val allowedDomainRegex = Regex("(^|\\.)${Regex.escape(allowedDomain)}$", RegexOption.IGNORE_CASE)
8686
if (allowedDomainRegex.matches(host)) {
8787
false // load in WebView
8888
} else {

app/src/main/java/com/mrepol742/webappp/ui/theme/Theme.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ fun WebApppTheme(
5555
val systemUiController = rememberSystemUiController()
5656
SideEffect {
5757
systemUiController.setStatusBarColor(
58-
color = Color.Transparent,
58+
color = Color.White,
5959
darkIcons = true
6060
)
61+
62+
systemUiController.setNavigationBarColor(
63+
color = Color(0xFF101828),
64+
)
6165
}
6266

6367
MaterialTheme(

app/src/main/java/com/mrepol742/webappp/utils/DynamicShortcut.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,21 @@ import android.graphics.drawable.Icon
88
import com.mrepol742.webappp.MainActivity
99
import com.mrepol742.webappp.R
1010

11-
class DynamicShortcut(private val context: Context, private val allowedDomain: String) {
11+
class DynamicShortcut(private val context: Context, private val allowedDomain: String,
12+
private val shortcuts: List<Pair<String, String>>) {
1213

1314
fun createDynamicShortcut() {
1415
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
1516
val shortcutManager = context.getSystemService(ShortcutManager::class.java)
1617

17-
val shortcuts = listOf(
18-
"projects" to "My Projects",
19-
"gaming" to "The Games I Played",
20-
"contact-me" to "Contact Me",
21-
)
22-
2318
val dynamicShortcuts = shortcuts.map { (idSuffix, label) ->
2419
ShortcutInfo.Builder(context, "shortcut_$idSuffix")
2520
.setShortLabel(label)
2621
.setIcon(Icon.createWithResource(context, R.mipmap.ic_launcher_round))
2722
.setIntent(
2823
Intent(context, MainActivity::class.java).apply {
2924
action = Intent.ACTION_VIEW
30-
putExtra("url", "https://$allowedDomain/$idSuffix")
25+
putExtra("url", if (idSuffix.startsWith("https://")) idSuffix else "https://$allowedDomain$idSuffix")
3126
}
3227
)
3328
.build()

app/src/main/res/drawable/ic_launcher_background.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
android:viewportWidth="108"
66
android:viewportHeight="108">
77
<path
8-
android:fillColor="#FF5722"
8+
android:fillColor="#101828"
99
android:pathData="M0,0h108v108h-108z" />
1010
<path
1111
android:fillColor="#00000000"

0 commit comments

Comments
 (0)