Browse Source

Worked on generate password types logic, generating password based on the user selected type

Khubaib 4 months ago
parent
commit
922f4bf05e

+ 1 - 1
app/src/main/java/com/fastest/pass/account/domain/model/SliderPasswordTypeList.kt

@@ -2,6 +2,6 @@ package com.fastest.pass.account.domain.model
 
 val sliderPasswordTypeList = listOf(
     SliderPasswordType("Allow all characters", "Any character combination"),
-    SliderPasswordType("Easy to read", "Avoid ambiguous characters, like 0,O,I,l,1"),
+    SliderPasswordType("Easy to read", "Avoid ambiguous characters, like 0,O,I,l"),
     SliderPasswordType("Easy to say", "Just lowercase and uppercase characters")
 )

+ 28 - 6
app/src/main/java/com/fastest/pass/account/presentation/ui/components/AccountScreen.kt

@@ -70,6 +70,7 @@ import androidx.compose.ui.window.DialogProperties
 import com.fastest.pass.R
 import com.fastest.pass.account.domain.model.SliderPasswordType
 import com.fastest.pass.account.domain.model.sliderPasswordTypeList
+import com.google.gson.annotations.SerializedName
 import kotlin.math.roundToInt
 import kotlin.random.Random
 
@@ -845,13 +846,34 @@ fun generatePassword(
     val numbers = "0123456789"
     val specialCharacters = "!@#$%^&*()-_=+<>?/{}[]|"
 
-    val easyToRead = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789"
+    val easyToReadUC = "ABCDEFGHJKLMNPQRSTUVWXYZ"
+    val easyToReadLC = "abcdefghijkmnopqrstuvwxyz"
+    val easyToReadN = "123456789"
+    val easyToReadSC = "!@#\$%^&*()-_=+<>?/{}[]|"
+
+    val easyToSayUC = "BCDFGHJKLMNPQRSTVWXYZ"
+    val easyToSayLC = "bcdfghjkmnpqrstvwxyz"
 
     var charPool = ""
-    if (isLowercaseEnabled) charPool += lowercase
-    if (isUppercaseEnabled) charPool += uppercase
-    if (isNumbersEnabled) charPool += numbers
-    if (isRandomSymbolsEnabled) charPool += specialCharacters
+
+    when (selectedSliderType) {
+        sliderPasswordTypeList[0] -> {
+            if (isLowercaseEnabled) charPool += lowercase
+            if (isUppercaseEnabled) charPool += uppercase
+            if (isNumbersEnabled) charPool += numbers
+            if (isRandomSymbolsEnabled) charPool += specialCharacters
+        }
+        sliderPasswordTypeList[1] -> {
+            if (isLowercaseEnabled) charPool += easyToReadLC
+            if (isUppercaseEnabled) charPool += easyToReadUC
+            if (isNumbersEnabled) charPool += easyToReadN
+            if (isRandomSymbolsEnabled) charPool += easyToReadSC
+        }
+        sliderPasswordTypeList[2] -> {
+            if (isLowercaseEnabled) charPool += easyToSayLC
+            if (isUppercaseEnabled) charPool += easyToSayUC
+        }
+    }
 
     val password = if (charPool.isNotEmpty()) {
         (1..passwordLength)
@@ -868,4 +890,4 @@ fun generatePassword(
     Log.d("test_generate_pass", "password = $password")
 
     return password
-}
+}

+ 8 - 5
app/src/main/java/com/fastest/pass/splash/presentation/ui/components/SplashScreen.kt

@@ -5,6 +5,7 @@ import androidx.compose.foundation.background
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.fillMaxSize
 import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
 import androidx.compose.foundation.layout.width
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.LaunchedEffect
@@ -25,16 +26,18 @@ fun SplashScreen(viewModel: SplashViewModel) {
 
     Box(
         modifier = Modifier
-            .background(colorResource(id = R.color.gray_splash))
-            .fillMaxSize()
+            .background(colorResource(id = R.color.blue_login))
+            .fillMaxSize(),
+        contentAlignment = Alignment.Center
         ) {
         Image(
             modifier = Modifier
-                .width(244.dp)
-                .height(75.dp)
+//                .width(244.dp)
+//                .height(75.dp)
+                .padding(horizontal = 50.dp)
                 .align(Alignment.Center),
             painter = painterResource(
-                id = R.drawable.appicon),
+                id = R.drawable.splashlogo),
             contentDescription = "FastestPass",
         )
     }

BIN
app/src/main/res/drawable/splashlogo.png