Skip to content
Open

Knji #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions app/src/main/java/com/karan/hashin/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
package com.karan.hashin

import android.app.Activity
import android.graphics.Color.TRANSPARENT
import android.os.Build
import android.os.Bundle
import android.view.View
import android.view.Window
import android.view.WindowInsets
import android.view.WindowInsetsController
import android.view.WindowManager
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.LocalActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.annotation.RequiresApi
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.karan.hashin.navigation.NavGraph
Expand All @@ -13,12 +32,15 @@ class MainActivity : ComponentActivity() {

private lateinit var navController: NavHostController


Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Remove the unnecessary blank line 35.

Suggested change

Copilot uses AI. Check for mistakes.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()

WindowCompat.setDecorFitsSystemWindows(window, false)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify redundant edge-to-edge configuration.

WindowCompat.setDecorFitsSystemWindows(window, false) is set here, but HashinTheme (Theme.kt lines 120-136) also calls enableEdgeToEdge in a DisposableEffect. The enableEdgeToEdge API internally manages window insets, making this manual call potentially redundant or conflicting.

Run the following script to confirm the edge-to-edge handling in Theme.kt:


🏁 Script executed:

#!/bin/bash
# Verify edge-to-edge handling in Theme.kt
rg -nP -A5 'enableEdgeToEdge' --type=kt

Length of output: 26


🏁 Script executed:

#!/bin/bash
# Search for enableEdgeToEdge in all Kotlin files without type filter
rg -nP -A5 'enableEdgeToEdge' --type-list | grep -i kotlin

Length of output: 389


🏁 Script executed:

#!/bin/bash
# Find Theme.kt and search for enableEdgeToEdge directly
fd -e kt -path '*Theme.kt' --exec grep -n 'enableEdgeToEdge' {} \;

Length of output: 168


🏁 Script executed:

#!/bin/bash
# Broader search for enableEdgeToEdge without type filtering
rg -nP -A5 'enableEdgeToEdge'

Length of output: 1729


🏁 Script executed:

#!/bin/bash
# Also verify WindowCompat.setDecorFitsSystemWindows usage in MainActivity
rg -nP -B3 -A3 'WindowCompat.setDecorFitsSystemWindows' 

Length of output: 563


🏁 Script executed:

#!/bin/bash
# Check if MainActivity actually calls enableEdgeToEdge (not just imports)
rg -nP 'enableEdgeToEdge\s*\(' app/src/main/java/com/karan/hashin/MainActivity.kt

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Get full context of Theme.kt lines 120-145 to see the DisposableEffect structure
sed -n '120,145p' app/src/main/java/com/karan/hashin/ui/theme/Theme.kt

Length of output: 662


🏁 Script executed:

#!/bin/bash
# Get context around setContent in MainActivity to see when HashinTheme is called
rg -nP -B2 -A8 'setContent' app/src/main/java/com/karan/hashin/MainActivity.kt

Length of output: 748


🌐 Web query:

androidx.activity enableEdgeToEdge setDecorFitsSystemWindows redundant

💡 Result:

Short answer: Yes — calling ComponentActivity.enableEdgeToEdge and then also calling WindowCompat.setDecorFitsSystemWindows(false) is usually redundant. enableEdgeToEdge is a convenience helper that sets up edge‑to‑edge for you (including turning off decor fitting and configuring system bars), so you normally only need enableEdgeToEdge. [1][2]

If you need custom behavior (different insets handling or bar styles) you can skip enableEdgeToEdge and call WindowCompat.setDecorFitsSystemWindows / WindowInsetsController APIs yourself. [1][2]

Sources:

  • enableEdgeToEdge docs (androidx.activity ComponentActivity). [1]
  • Explanation / guidance (Stack Overflow). [2]

Remove redundant window configuration at line 39.

Calling WindowCompat.setDecorFitsSystemWindows(window, false) and enableEdgeToEdge() together is redundant—enableEdgeToEdge() is a convenience helper that internally handles turning off decor fitting and configuring system bars. Since HashinTheme calls activity.enableEdgeToEdge() at Theme.kt lines 131-134, the manual call at line 39 in MainActivity should be removed.

🤖 Prompt for AI Agents
In app/src/main/java/com/karan/hashin/MainActivity.kt around line 39, remove the
redundant call to WindowCompat.setDecorFitsSystemWindows(window, false) since
HashinTheme already calls activity.enableEdgeToEdge() (Theme.kt lines 131-134)
which configures edge-to-edge and system bars; simply delete the line so
edge-to-edge configuration is only handled by the theme helper.



setContent {
HashinTheme {
HashinTheme(dynamicColor = false) {
navController = rememberNavController()
NavGraph(navController)
}
Expand Down
44 changes: 35 additions & 9 deletions app/src/main/java/com/karan/hashin/components/Element.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.karan.hashin.components

import android.content.res.Configuration
import com.karan.hashin.R
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -15,13 +17,16 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
Expand All @@ -37,7 +42,7 @@ fun Element(

Card(
colors = CardDefaults.cardColors(
containerColor = Color.White
containerColor = MaterialTheme.colorScheme.surface
),
elevation = CardDefaults.cardElevation(
defaultElevation = 4.dp
Expand All @@ -54,12 +59,13 @@ fun Element(
modifier = Modifier
.fillMaxSize()
) {
Image(
Icon (
imageVector = ImageVector.vectorResource(id = R.drawable.people),
contentDescription = "Element Icon Image",
tint = MaterialTheme.colorScheme.primary,
modifier = Modifier
.padding(start = 16.dp)
.size(52.dp)
.size(36.dp)
)

Column(
Expand All @@ -68,15 +74,15 @@ fun Element(
) {
Text(
text = passKey.service.ifEmpty { "Website" },
fontSize = 22.sp,
fontSize = 20.sp,
color = getColorForLabel(passKey.label)
)

Text(
text = passKey.userName,
fontSize = 14.sp,
modifier = Modifier
.padding(start = 4.dp)
.padding(start = 2.dp)
)
}
Spacer(
Expand All @@ -92,19 +98,39 @@ fun Element(
) {
Text(
text = passKey.label.firstOrNull()?.uppercase() ?: "",
color = Color.White,
color = MaterialTheme.colorScheme.onPrimaryContainer,
fontWeight = FontWeight.W300,
fontSize = 36.sp,
)
}
}
}
}

@Preview(showBackground = true, showSystemUi = true)
@Preview(
name = "Dark Theme",
showBackground = true,
showSystemUi = false,
uiMode = Configuration.UI_MODE_NIGHT_YES
)
@Preview(
name = "Light Theme",
showBackground = true,
showSystemUi = false,
uiMode = Configuration.UI_MODE_NIGHT_NO
)
@Composable
private fun PreviewElement() {
HashinTheme {
Element(PassKey("", "", "", ""), Modifier.padding(top = 144.dp)) {}
HashinTheme(dynamicColor = false) {
Element(PassKey(
service = "Github",
userName = "KaranJoshi1208",
desc = "My passkey",
label = "Work"
),
modifier = Modifier,
onClick = {}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,75 +1,74 @@
package com.karan.hashin.components

import android.content.res.Configuration
import com.karan.hashin.ui.theme.iconTintDark
import androidx.compose.ui.graphics.Color
import com.karan.hashin.R
import androidx.compose.foundation.background
import androidx.compose.runtime.getValue
import com.karan.hashin.ui.theme.iconTintDark
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Key
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.karan.hashin.ui.theme.HashinTheme
import com.karan.hashin.ui.theme.PurpleA700
import com.karan.hashin.ui.theme.iconTintLight

@Composable
fun BottomAppBar(
fun NavigationBar(
toVault: () -> Unit = {},
toPassKey: () -> Unit = {},
toSetting: () -> Unit = {},
selection: Int,
modifier: Modifier = Modifier
) {
val iconTint = iconTintDark
val iconTint by remember { mutableStateOf(iconTintDark) }
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using remember { mutableStateOf() } for a constant value is unnecessary. Either use val iconTint = iconTintDark directly, or if this needs to be dynamic based on theme, derive it from the current theme instead of hardcoding to iconTintDark.

Suggested change
val iconTint by remember { mutableStateOf(iconTintDark) }
val iconTint = iconTintDark

Copilot uses AI. Check for mistakes.
Card(
shape = RectangleShape,
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.primaryContainer
containerColor = MaterialTheme.colorScheme.tertiaryContainer
),
elevation = CardDefaults.cardElevation(
defaultElevation = 4.dp
),
modifier = modifier
.fillMaxWidth()
.navigationBarsPadding()
.height(80.dp)
.wrapContentHeight()

) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceEvenly,
modifier = modifier
.fillMaxSize()
.fillMaxWidth()
.padding(top = 8.dp)
.height(64.dp)

) {
Icon(
imageVector =Icons.Default.Key ,
Expand All @@ -92,7 +91,6 @@ fun BottomAppBar(
color = if(selection == 2) iconTint else MaterialTheme.colorScheme.primary,
shape = RoundedCornerShape(percent = 33)
)
//
) {
Icon(
imageVector = Icons.Rounded.Add,
Expand All @@ -119,17 +117,26 @@ fun BottomAppBar(
}
)
}
Spacer(Modifier.navigationBarsPadding())
}
}

@Preview(
name = "BottomAppBar Preview Light",
// uiMode = Configuration.UI_MODE_NIGHT_NO,
showBackground = true
uiMode = Configuration.UI_MODE_NIGHT_YES,
showBackground = true,
showSystemUi = true
)
@Composable
private fun p1() {
private fun P1() {
HashinTheme(darkTheme = true, dynamicColor = false) {
BottomAppBar({}, {}, {}, 2)
Column(
verticalArrangement = Arrangement.Bottom,
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background)
) {
NavigationBar({}, {}, {}, 2)
}
}
}
14 changes: 4 additions & 10 deletions app/src/main/java/com/karan/hashin/screens/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ package com.karan.hashin.screens.home

import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.viewmodel.compose.viewModel
Expand All @@ -19,7 +16,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.karan.hashin.components.BottomAppBar
import com.karan.hashin.components.NavigationBar
import com.karan.hashin.navigation.Screens
import com.karan.hashin.ui.theme.HashinTheme
import com.karan.hashin.viewmodel.HomeViewModel
Expand All @@ -32,11 +29,11 @@ fun HomeScreen(
modifier: Modifier = Modifier
) {
val innerNav = rememberNavController()
var selection by remember { mutableIntStateOf(1) }
var selection by rememberSaveable { mutableIntStateOf(1) }

Scaffold(
bottomBar = {
BottomAppBar(
NavigationBar(
toVault = {
selection = 1
innerNav.navigate(Screens.HomeGraph.Vault.route) {
Expand Down Expand Up @@ -70,9 +67,6 @@ fun HomeScreen(
modifier = Modifier
)
},
modifier = Modifier
.navigationBarsPadding()
.statusBarsPadding()
) { pd ->
NavHost(
navController = innerNav,
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/karan/hashin/screens/home/NewProfile.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package com.karan.hashin.screens.home

Loading