initial commit
8
.claude/settings.local.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"mcp__plugin_figma_figma__use_figma",
|
||||||
|
"mcp__plugin_figma_figma__get_screenshot"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
6
.idea/AndroidProjectSystem.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidProjectSystem">
|
||||||
|
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
26
.idea/appInsightsSettings.xml
generated
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AppInsightsSettings">
|
||||||
|
<option name="tabSettings">
|
||||||
|
<map>
|
||||||
|
<entry key="Firebase Crashlytics">
|
||||||
|
<value>
|
||||||
|
<InsightsFilterSettings>
|
||||||
|
<option name="connection">
|
||||||
|
<ConnectionSetting>
|
||||||
|
<option name="appId" value="PLACEHOLDER" />
|
||||||
|
<option name="mobileSdkAppId" value="" />
|
||||||
|
<option name="projectId" value="" />
|
||||||
|
<option name="projectNumber" value="" />
|
||||||
|
</ConnectionSetting>
|
||||||
|
</option>
|
||||||
|
<option name="signal" value="SIGNAL_UNSPECIFIED" />
|
||||||
|
<option name="timeIntervalDays" value="THIRTY_DAYS" />
|
||||||
|
<option name="visibilityType" value="ALL" />
|
||||||
|
</InsightsFilterSettings>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="21" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
15
.idea/deploymentTargetSelector.xml
generated
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="deploymentTargetSelector">
|
||||||
|
<selectionStates>
|
||||||
|
<SelectionState runConfigName="app">
|
||||||
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
<DialogSelection />
|
||||||
|
</SelectionState>
|
||||||
|
<SelectionState runConfigName="OnboardingWelcomePagePreview">
|
||||||
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
<DialogSelection />
|
||||||
|
</SelectionState>
|
||||||
|
</selectionStates>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
13
.idea/deviceManager.xml
generated
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DeviceTable">
|
||||||
|
<option name="columnSorters">
|
||||||
|
<list>
|
||||||
|
<ColumnSorterState>
|
||||||
|
<option name="column" value="Name" />
|
||||||
|
<option name="order" value="ASCENDING" />
|
||||||
|
</ColumnSorterState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
18
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
61
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="GlancePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewAnnotationInFunctionWithParameters" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewApiLevelMustBeValid" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewFontScaleMustBeGreaterThanZero" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewMultipleParameterProviders" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewParameterProviderOnFirstParameter" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||||
|
<option name="composableFile" value="true" />
|
||||||
|
<option name="previewFile" value="true" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
22
.idea/misc.xml
generated
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
<component name="StoredSessionsInfoStore">
|
||||||
|
<option name="sessions">
|
||||||
|
<list>
|
||||||
|
<SessionInfoState>
|
||||||
|
<option name="id" value="20260412-104614-28ade3b2-7f77-4694-8321-e3f33ff7f75a" />
|
||||||
|
<option name="lastUpdateTimestamp" value="1775965574149" />
|
||||||
|
<option name="responseMode" value="Agent" />
|
||||||
|
<option name="title" value="New Agent Session" />
|
||||||
|
<option name="user" value="longnh15@vng.com.vn" />
|
||||||
|
</SessionInfoState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
17
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
79
app/build.gradle.kts
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.compose)
|
||||||
|
alias(libs.plugins.devtool.ksp)
|
||||||
|
alias(libs.plugins.serialization)
|
||||||
|
alias(libs.plugins.koin.compiler)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "com.longnh15.heimdall"
|
||||||
|
compileSdk {
|
||||||
|
version = release(37)
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "com.longnh15.heimdall"
|
||||||
|
minSdk = 26
|
||||||
|
targetSdk = 37
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
signingConfig = signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(platform(libs.androidx.compose.bom))
|
||||||
|
implementation(libs.androidx.activity.compose)
|
||||||
|
implementation(libs.androidx.compose.material3)
|
||||||
|
implementation(libs.androidx.lifecycle.process)
|
||||||
|
implementation(libs.icon.pack)
|
||||||
|
implementation(libs.androidx.compose.ui)
|
||||||
|
implementation(libs.androidx.compose.ui.graphics)
|
||||||
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||||
|
implementation(libs.androidx.core.ktx)
|
||||||
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||||
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
||||||
|
testImplementation(libs.junit)
|
||||||
|
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||||
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||||
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
androidTestImplementation(libs.androidx.junit)
|
||||||
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||||
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||||
|
|
||||||
|
implementation(libs.navigation.compose)
|
||||||
|
implementation(libs.androidx.datastore.preferences)
|
||||||
|
implementation(libs.biometric.compose)
|
||||||
|
|
||||||
|
// Koin
|
||||||
|
implementation(libs.koin)
|
||||||
|
implementation(libs.koin.compose)
|
||||||
|
implementation(libs.koin.annotations)
|
||||||
|
implementation(libs.koin.compose.viewmodel)
|
||||||
|
implementation(libs.koin.compose.viewmodel.navigation)
|
||||||
|
|
||||||
|
// Room
|
||||||
|
implementation(libs.androidx.room)
|
||||||
|
ksp(libs.androidx.room.compiler)
|
||||||
|
implementation(libs.androidx.room.ktx)
|
||||||
|
}
|
||||||
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
assertEquals("com.longnh15.heimdall", appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".HeimdallApplication"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.Heimdall">
|
||||||
|
<service
|
||||||
|
android:name=".HeimdallAutofillService"
|
||||||
|
android:exported="true"
|
||||||
|
android:label="Heimdall"
|
||||||
|
android:permission="android.permission.BIND_AUTOFILL_SERVICE">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.service.autofill.AutofillService" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data
|
||||||
|
android:name="android.autofill"
|
||||||
|
android:resource="@xml/service_configuration" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/Theme.Heimdall">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
BIN
app/src/main/ic_launcher-playstore.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,36 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
|
import androidx.lifecycle.LifecycleOwner
|
||||||
|
import androidx.lifecycle.ProcessLifecycleOwner
|
||||||
|
import com.longnh15.heimdall.di.appModule
|
||||||
|
import com.longnh15.heimdall.domain.vault.VaultSessionManager
|
||||||
|
import org.koin.android.ext.android.inject
|
||||||
|
import org.koin.android.ext.koin.androidContext
|
||||||
|
import org.koin.android.ext.koin.androidLogger
|
||||||
|
import org.koin.core.annotation.ComponentScan
|
||||||
|
import org.koin.core.annotation.KoinApplication
|
||||||
|
import org.koin.plugin.module.dsl.startKoin
|
||||||
|
|
||||||
|
//@KoinApplication(modules = [DatabaseModule::class])
|
||||||
|
//@ComponentScan
|
||||||
|
class HeimdallApplication: Application() {
|
||||||
|
private val vaultSessionManager: VaultSessionManager by inject()
|
||||||
|
private val vaultSessionLifecycleObserver = object : DefaultLifecycleObserver {
|
||||||
|
override fun onStart(owner: LifecycleOwner) {
|
||||||
|
vaultSessionManager.refreshSession()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
startKoin<HeimdallApplication> {
|
||||||
|
androidLogger()
|
||||||
|
androidContext(this@HeimdallApplication)
|
||||||
|
modules(appModule)
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessLifecycleOwner.get().lifecycle.addObserver(vaultSessionLifecycleObserver)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import android.app.assist.AssistStructure
|
||||||
|
import android.os.CancellationSignal
|
||||||
|
import android.service.autofill.AutofillService
|
||||||
|
import android.service.autofill.Dataset
|
||||||
|
import android.service.autofill.FillCallback
|
||||||
|
import android.service.autofill.FillContext
|
||||||
|
import android.service.autofill.FillRequest
|
||||||
|
import android.service.autofill.FillResponse
|
||||||
|
import android.service.autofill.SaveCallback
|
||||||
|
import android.service.autofill.SaveRequest
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.autofill.AutofillValue
|
||||||
|
import android.widget.RemoteViews
|
||||||
|
|
||||||
|
class HeimdallAutofillService : AutofillService() {
|
||||||
|
|
||||||
|
private fun buildFillResponse(
|
||||||
|
parsedFields: ParsedField
|
||||||
|
): FillResponse {
|
||||||
|
val responseBuilder = FillResponse.Builder()
|
||||||
|
val datasetBuilder = Dataset.Builder()
|
||||||
|
|
||||||
|
parsedFields.usernameId?.let { id ->
|
||||||
|
datasetBuilder.setValue(
|
||||||
|
id,
|
||||||
|
AutofillValue.forText("+84826552595"),
|
||||||
|
RemoteViews(packageName, android.R.layout.simple_list_item_1).also {
|
||||||
|
it.setTextViewText(android.R.id.text1, "Long Nguyễn")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedFields.passwordId?.let { id ->
|
||||||
|
datasetBuilder.setValue(
|
||||||
|
id,
|
||||||
|
AutofillValue.forText("123123123"),
|
||||||
|
RemoteViews(packageName, android.R.layout.simple_list_item_1).also {
|
||||||
|
it.setTextViewText(android.R.id.text1, "••••••••")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
responseBuilder.addDataset(datasetBuilder.build())
|
||||||
|
|
||||||
|
return responseBuilder.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFillRequest(
|
||||||
|
request: FillRequest,
|
||||||
|
cancellationSignal: CancellationSignal,
|
||||||
|
callback: FillCallback
|
||||||
|
) {
|
||||||
|
// Get the structure from the request
|
||||||
|
val context: List<FillContext> = request.fillContexts
|
||||||
|
val structure: AssistStructure = context[context.size - 1].structure
|
||||||
|
|
||||||
|
Log.d("Heimdall", "Package: ${structure.activityComponent.packageName}")
|
||||||
|
Log.d("Heimdall", "Window nodes: ${structure.windowNodeCount}")
|
||||||
|
|
||||||
|
// Traverse the structure looking for nodes to fill out
|
||||||
|
val parser = StructureParser(structure)
|
||||||
|
val parsedFields = parser.parse()
|
||||||
|
Log.d("Heimdall", "Parsed fields: $parsedFields")
|
||||||
|
if (parsedFields.isEmpty()) {
|
||||||
|
callback.onSuccess(null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val fillResponse = buildFillResponse(parsedFields)
|
||||||
|
callback.onSuccess(fillResponse)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSaveRequest(
|
||||||
|
p0: SaveRequest,
|
||||||
|
p1: SaveCallback
|
||||||
|
) {
|
||||||
|
// Empty for now
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
40
app/src/main/java/com/longnh15/heimdall/MainActivity.kt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.autofill.AutofillManager
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import com.longnh15.heimdall.navigation.HeimdallNavGraph
|
||||||
|
import com.longnh15.heimdall.navigation.Screen
|
||||||
|
import com.longnh15.heimdall.ui.theme.HeimdallTheme
|
||||||
|
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||||
|
|
||||||
|
class MainActivity : ComponentActivity() {
|
||||||
|
private val viewModel: MainViewModel by viewModel()
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
enableEdgeToEdge()
|
||||||
|
setContent {
|
||||||
|
HeimdallTheme {
|
||||||
|
val isFirstLaunch by viewModel.isFirstLaunch.collectAsStateWithLifecycle()
|
||||||
|
HeimdallNavGraph(
|
||||||
|
modifier = Modifier.fillMaxSize(),
|
||||||
|
startDestination = if (isFirstLaunch != false) Screen.Onboarding else Screen.Vault,
|
||||||
|
isAutofillServiceEnabled = ::isAutofillServiceEnabled,
|
||||||
|
onCompleteOnboarding = viewModel::onCompleteOnboarding,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isAutofillServiceEnabled(): Boolean {
|
||||||
|
val afm = getSystemService(AutofillManager::class.java)
|
||||||
|
return afm?.hasEnabledAutofillServices() ?: false
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/src/main/java/com/longnh15/heimdall/MainViewModel.kt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.longnh15.heimdall.data.preferences.PreferenceDataSource
|
||||||
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlinx.coroutines.flow.stateIn
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.core.annotation.KoinViewModel
|
||||||
|
|
||||||
|
@KoinViewModel
|
||||||
|
class MainViewModel (
|
||||||
|
private val preferenceDataSource: PreferenceDataSource
|
||||||
|
) : ViewModel() {
|
||||||
|
val isFirstLaunch: StateFlow<Boolean?> = preferenceDataSource.preferences
|
||||||
|
.map { it.isFirstLaunch }
|
||||||
|
.stateIn(
|
||||||
|
scope = viewModelScope,
|
||||||
|
started = SharingStarted.WhileSubscribed(5000),
|
||||||
|
initialValue = null
|
||||||
|
)
|
||||||
|
|
||||||
|
fun onCompleteOnboarding() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
preferenceDataSource.setFirstLaunchDone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/src/main/java/com/longnh15/heimdall/ParsedField.kt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import android.view.autofill.AutofillId
|
||||||
|
|
||||||
|
data class ParsedField(
|
||||||
|
val usernameId: AutofillId?,
|
||||||
|
val passwordId: AutofillId?
|
||||||
|
) {
|
||||||
|
fun isEmpty() = usernameId == null && passwordId == null
|
||||||
|
}
|
||||||
93
app/src/main/java/com/longnh15/heimdall/StructureParser.kt
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import android.app.assist.AssistStructure
|
||||||
|
import android.text.InputType
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.view.autofill.AutofillId
|
||||||
|
|
||||||
|
class StructureParser(private val structure: AssistStructure) {
|
||||||
|
|
||||||
|
fun parse(): ParsedField {
|
||||||
|
var usernameId: AutofillId? = null
|
||||||
|
var passwordId: AutofillId? = null
|
||||||
|
|
||||||
|
for (i in 0 until structure.windowNodeCount) {
|
||||||
|
val windowNode = structure.getWindowNodeAt(i)
|
||||||
|
Log.d("Heimdall", "Root children: ${windowNode.rootViewNode.childCount}")
|
||||||
|
traverseNode(windowNode.rootViewNode) { node ->
|
||||||
|
when (classifyNode(node)) {
|
||||||
|
FieldType.USERNAME -> if (usernameId == null) usernameId = node.autofillId
|
||||||
|
FieldType.PASSWORD -> if (passwordId == null) passwordId = node.autofillId
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ParsedField(usernameId, passwordId)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun traverseNode(node: AssistStructure.ViewNode, visitor: (AssistStructure.ViewNode) -> Unit) {
|
||||||
|
visitor(node)
|
||||||
|
for (i in 0 until node.childCount) {
|
||||||
|
traverseNode(node.getChildAt(i), visitor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum class FieldType { USERNAME, PASSWORD, NONE }
|
||||||
|
|
||||||
|
private fun classifyNode(node: AssistStructure.ViewNode): FieldType {
|
||||||
|
// Must be an autofill-able text field
|
||||||
|
if (node.autofillId == null) return FieldType.NONE
|
||||||
|
if (node.visibility != View.VISIBLE) return FieldType.NONE
|
||||||
|
|
||||||
|
// --- Heuristic 1: autofillHints (most reliable, respect first) ---
|
||||||
|
node.autofillHints?.forEach { hint ->
|
||||||
|
when (hint) {
|
||||||
|
View.AUTOFILL_HINT_USERNAME,
|
||||||
|
View.AUTOFILL_HINT_EMAIL_ADDRESS -> return FieldType.USERNAME
|
||||||
|
|
||||||
|
View.AUTOFILL_HINT_PASSWORD -> return FieldType.PASSWORD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Heuristic 2: inputType flags ---
|
||||||
|
val inputType = node.inputType
|
||||||
|
if (inputType and InputType.TYPE_TEXT_VARIATION_PASSWORD != 0 ||
|
||||||
|
inputType and InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD != 0 ||
|
||||||
|
inputType and InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD != 0
|
||||||
|
) return FieldType.PASSWORD
|
||||||
|
|
||||||
|
if (inputType and InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS != 0 ||
|
||||||
|
inputType and InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != 0 ||
|
||||||
|
inputType and InputType.TYPE_CLASS_PHONE != 0
|
||||||
|
) return FieldType.USERNAME
|
||||||
|
|
||||||
|
// --- Heuristic 3: htmlInfo for web views ---
|
||||||
|
val htmlAttrs = node.htmlInfo?.attributes
|
||||||
|
htmlAttrs?.forEach { pair ->
|
||||||
|
if (pair.first.equals("type", ignoreCase = true)) {
|
||||||
|
when (pair.second.lowercase()) {
|
||||||
|
"password" -> return FieldType.PASSWORD
|
||||||
|
"email" -> return FieldType.USERNAME // "text" is a weak signal, see note
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Heuristic 4: hint / idEntry / contentDescription text matching ---
|
||||||
|
val textSignals = listOfNotNull(
|
||||||
|
node.hint,
|
||||||
|
node.idEntry,
|
||||||
|
node.contentDescription?.toString(),
|
||||||
|
node.text?.toString()
|
||||||
|
).map { it.lowercase() }
|
||||||
|
|
||||||
|
val usernameKeywords = listOf("user", "email", "login", "account", "phone", "username")
|
||||||
|
val passwordKeywords = listOf("pass", "pwd", "secret", "pin")
|
||||||
|
|
||||||
|
if (textSignals.any { s -> passwordKeywords.any { s.contains(it) } }) return FieldType.PASSWORD
|
||||||
|
if (textSignals.any { s -> usernameKeywords.any { s.contains(it) } }) return FieldType.USERNAME
|
||||||
|
|
||||||
|
return FieldType.NONE
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.longnh15.heimdall.data.preferences
|
||||||
|
|
||||||
|
data class AppPreferences(
|
||||||
|
val isFirstLaunch: Boolean = true,
|
||||||
|
)
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.longnh15.heimdall.data.preferences
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.datastore.preferences.core.booleanPreferencesKey
|
||||||
|
import androidx.datastore.preferences.core.edit
|
||||||
|
import androidx.datastore.preferences.preferencesDataStore
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import org.koin.core.annotation.Singleton
|
||||||
|
|
||||||
|
private val Context.dataStore by preferencesDataStore("settings")
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class PreferenceDataSource(
|
||||||
|
appContext: Context
|
||||||
|
) {
|
||||||
|
private object Keys {
|
||||||
|
val IS_FIRST_LAUNCH = booleanPreferencesKey("is_first_launch")
|
||||||
|
}
|
||||||
|
|
||||||
|
private val dataStore = appContext.dataStore
|
||||||
|
val preferences: Flow<AppPreferences> = dataStore.data.map { prefs ->
|
||||||
|
AppPreferences(
|
||||||
|
isFirstLaunch = prefs[Keys.IS_FIRST_LAUNCH] ?: true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun setFirstLaunchDone() {
|
||||||
|
dataStore.edit { it[Keys.IS_FIRST_LAUNCH] = false }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.longnh15.heimdall.data.repository
|
||||||
|
|
||||||
|
import com.longnh15.heimdall.data.source.local.LocalDataSource
|
||||||
|
import com.longnh15.heimdall.domain.model.Credential
|
||||||
|
import com.longnh15.heimdall.domain.repository.CredentialRepository
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import org.koin.core.annotation.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class CredentialRepositoryImpl(
|
||||||
|
val localDataSource: LocalDataSource
|
||||||
|
) : CredentialRepository {
|
||||||
|
override suspend fun save(credential: Credential) {
|
||||||
|
localDataSource.save(credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getAll(): Flow<List<Credential>> {
|
||||||
|
return localDataSource.getAllCredentials()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.longnh15.heimdall.data.source.local
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import com.longnh15.heimdall.data.source.local.entity.CredentialEntity
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface CredentialDao {
|
||||||
|
@Query("SELECT * FROM credential")
|
||||||
|
fun getAll(): Flow<List<CredentialEntity>>
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
suspend fun insert(credential: CredentialEntity)
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.longnh15.heimdall.data.source.local
|
||||||
|
|
||||||
|
import androidx.room.Database
|
||||||
|
import androidx.room.RoomDatabase
|
||||||
|
import com.longnh15.heimdall.data.source.local.entity.CredentialEntity
|
||||||
|
|
||||||
|
@Database(
|
||||||
|
entities = [CredentialEntity::class],
|
||||||
|
version = 1,
|
||||||
|
)
|
||||||
|
abstract class HeimdallDatabase: RoomDatabase() {
|
||||||
|
abstract fun credentialDao(): CredentialDao
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.longnh15.heimdall.data.source.local
|
||||||
|
|
||||||
|
import com.longnh15.heimdall.data.source.local.entity.toDomain
|
||||||
|
import com.longnh15.heimdall.data.source.local.entity.toEntity
|
||||||
|
import com.longnh15.heimdall.domain.model.Credential
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
|
class LocalDataSource(
|
||||||
|
private val credentialDao: CredentialDao
|
||||||
|
) {
|
||||||
|
fun getAllCredentials(): Flow<List<Credential>> {
|
||||||
|
return credentialDao.getAll().map { entities -> entities.map { it.toDomain() } }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun save(credential: Credential) {
|
||||||
|
credentialDao.insert(credential.toEntity())
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.longnh15.heimdall.data.source.local.entity
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(tableName = "credential")
|
||||||
|
data class CredentialEntity(
|
||||||
|
@PrimaryKey(autoGenerate = true) val id: Long = 0L,
|
||||||
|
val name: String,
|
||||||
|
val url: String?,
|
||||||
|
val username: String,
|
||||||
|
val password: String
|
||||||
|
)
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.longnh15.heimdall.data.source.local.entity
|
||||||
|
|
||||||
|
import com.longnh15.heimdall.domain.model.Credential
|
||||||
|
|
||||||
|
fun Credential.toEntity(): CredentialEntity {
|
||||||
|
return CredentialEntity(
|
||||||
|
name = name,
|
||||||
|
url = url,
|
||||||
|
username = username,
|
||||||
|
password = password
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun CredentialEntity.toDomain(): Credential {
|
||||||
|
return Credential(
|
||||||
|
name = name,
|
||||||
|
url = url.orEmpty(),
|
||||||
|
username = username,
|
||||||
|
password = password
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.longnh15.heimdall.data.vault
|
||||||
|
|
||||||
|
import com.longnh15.heimdall.domain.vault.VaultSessionManager
|
||||||
|
import com.longnh15.heimdall.domain.vault.VaultSessionState
|
||||||
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.update
|
||||||
|
import org.koin.core.annotation.Singleton
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
import kotlin.time.TimeSource
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class VaultSessionManagerImpl: VaultSessionManager {
|
||||||
|
private companion object {
|
||||||
|
const val TIMEOUT_DURATION = 5 // 5 sec
|
||||||
|
}
|
||||||
|
|
||||||
|
private val _sessionState = MutableStateFlow<VaultSessionState>(VaultSessionState.Locked)
|
||||||
|
override val sessionState: StateFlow<VaultSessionState>
|
||||||
|
get() = _sessionState
|
||||||
|
|
||||||
|
override fun unlock() {
|
||||||
|
val now = TimeSource.Monotonic.markNow()
|
||||||
|
_sessionState.update { VaultSessionState.Unlocked(now + TIMEOUT_DURATION.seconds) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun lock() {
|
||||||
|
_sessionState.update { VaultSessionState.Locked }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun refreshSession() {
|
||||||
|
val currentState = sessionState.value
|
||||||
|
if (currentState is VaultSessionState.Unlocked) {
|
||||||
|
val now = TimeSource.Monotonic.markNow()
|
||||||
|
if (currentState.expiredAt <= now) {
|
||||||
|
_sessionState.update { VaultSessionState.Locked }
|
||||||
|
} else {
|
||||||
|
_sessionState.update { VaultSessionState.Unlocked(now + TIMEOUT_DURATION.seconds) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
40
app/src/main/java/com/longnh15/heimdall/di/AppModule.kt
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package com.longnh15.heimdall.di
|
||||||
|
|
||||||
|
import com.longnh15.heimdall.MainViewModel
|
||||||
|
import com.longnh15.heimdall.data.preferences.PreferenceDataSource
|
||||||
|
import com.longnh15.heimdall.data.repository.CredentialRepositoryImpl
|
||||||
|
import com.longnh15.heimdall.data.source.local.LocalDataSource
|
||||||
|
import com.longnh15.heimdall.data.vault.VaultSessionManagerImpl
|
||||||
|
import com.longnh15.heimdall.domain.repository.CredentialRepository
|
||||||
|
import com.longnh15.heimdall.domain.vault.VaultSessionManager
|
||||||
|
import com.longnh15.heimdall.ui.onboarding.OnboardingViewModel
|
||||||
|
import com.longnh15.heimdall.ui.vault.VaultViewModel
|
||||||
|
import com.longnh15.heimdall.ui.vault.edit.AddEditVaultViewModel
|
||||||
|
import org.koin.core.annotation.Module
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
import org.koin.dsl.bind
|
||||||
|
import org.koin.dsl.module
|
||||||
|
import org.koin.plugin.module.dsl.single
|
||||||
|
import org.koin.plugin.module.dsl.viewModel
|
||||||
|
|
||||||
|
//@Module
|
||||||
|
//class AppModule {
|
||||||
|
// @Single
|
||||||
|
// fun provideVaultSessionManager(): VaultSessionManager = VaultSessionManagerImpl()
|
||||||
|
|
||||||
|
// @Single
|
||||||
|
// fun bindCredentialRepository(
|
||||||
|
// localDataSource: LocalDataSource
|
||||||
|
// ): CredentialRepository = CredentialRepositoryImpl(localDataSource)
|
||||||
|
//}
|
||||||
|
|
||||||
|
val appModule = module {
|
||||||
|
single<VaultSessionManagerImpl>() bind VaultSessionManager::class
|
||||||
|
single<CredentialRepositoryImpl>() bind CredentialRepository::class
|
||||||
|
single<PreferenceDataSource>()
|
||||||
|
|
||||||
|
viewModel<MainViewModel>()
|
||||||
|
viewModel<OnboardingViewModel>()
|
||||||
|
viewModel<VaultViewModel>()
|
||||||
|
viewModel<AddEditVaultViewModel>()
|
||||||
|
}
|
||||||
30
app/src/main/java/com/longnh15/heimdall/di/DatabaseModule.kt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package com.longnh15.heimdall.di
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.room.Room
|
||||||
|
import com.longnh15.heimdall.data.source.local.CredentialDao
|
||||||
|
import com.longnh15.heimdall.data.source.local.HeimdallDatabase
|
||||||
|
import com.longnh15.heimdall.data.source.local.LocalDataSource
|
||||||
|
import org.koin.core.annotation.Module
|
||||||
|
import org.koin.core.annotation.Single
|
||||||
|
|
||||||
|
@Module
|
||||||
|
class DatabaseModule {
|
||||||
|
@Single
|
||||||
|
fun provideDatabase(context: Context): HeimdallDatabase =
|
||||||
|
Room.databaseBuilder(
|
||||||
|
context,
|
||||||
|
HeimdallDatabase::class.java,
|
||||||
|
"heimdall.db"
|
||||||
|
).build()
|
||||||
|
|
||||||
|
@Single
|
||||||
|
fun provideCredentialDao(db: HeimdallDatabase): CredentialDao {
|
||||||
|
return db.credentialDao()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Single
|
||||||
|
fun provideLocalDataSource(credentialDao: CredentialDao): LocalDataSource {
|
||||||
|
return LocalDataSource(credentialDao)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.longnh15.heimdall.domain.model
|
||||||
|
|
||||||
|
data class Credential(
|
||||||
|
val name: String,
|
||||||
|
val url: String,
|
||||||
|
val username: String,
|
||||||
|
val password: String,
|
||||||
|
)
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.longnh15.heimdall.domain.repository
|
||||||
|
|
||||||
|
import com.longnh15.heimdall.domain.model.Credential
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
interface CredentialRepository {
|
||||||
|
fun getAll(): Flow<List<Credential>>
|
||||||
|
suspend fun save(credential: Credential)
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.longnh15.heimdall.domain.vault
|
||||||
|
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import org.koin.core.annotation.Singleton
|
||||||
|
|
||||||
|
interface VaultSessionManager {
|
||||||
|
val sessionState: StateFlow<VaultSessionState>
|
||||||
|
|
||||||
|
fun unlock()
|
||||||
|
fun lock()
|
||||||
|
fun refreshSession()
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.longnh15.heimdall.domain.vault
|
||||||
|
|
||||||
|
import kotlin.time.TimeSource
|
||||||
|
|
||||||
|
sealed class VaultSessionState {
|
||||||
|
data object Locked: VaultSessionState()
|
||||||
|
data class Unlocked(val expiredAt: TimeSource.Monotonic.ValueTimeMark): VaultSessionState()
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.longnh15.heimdall.navigation
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.navigation.NavHostController
|
||||||
|
import androidx.navigation.compose.NavHost
|
||||||
|
import androidx.navigation.compose.composable
|
||||||
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
import com.longnh15.heimdall.ui.onboarding.OnboardingPage
|
||||||
|
import com.longnh15.heimdall.ui.onboarding.OnboardingViewModel
|
||||||
|
import com.longnh15.heimdall.ui.vault.VaultScreen
|
||||||
|
import com.longnh15.heimdall.ui.vault.VaultViewModel
|
||||||
|
import com.longnh15.heimdall.ui.vault.edit.AddEditVaultItemScreen
|
||||||
|
import com.longnh15.heimdall.ui.vault.edit.AddEditVaultViewModel
|
||||||
|
import org.koin.compose.viewmodel.koinViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HeimdallNavGraph(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
navController: NavHostController = rememberNavController(),
|
||||||
|
startDestination: Screen = Screen.Onboarding,
|
||||||
|
isAutofillServiceEnabled: () -> Boolean,
|
||||||
|
onCompleteOnboarding: () -> Unit,
|
||||||
|
) {
|
||||||
|
NavHost(
|
||||||
|
navController = navController,
|
||||||
|
startDestination = startDestination,
|
||||||
|
modifier = modifier
|
||||||
|
) {
|
||||||
|
composable<Screen.Onboarding> {
|
||||||
|
OnboardingPage(
|
||||||
|
viewModel = koinViewModel<OnboardingViewModel>(),
|
||||||
|
isAutofillEnabled = isAutofillServiceEnabled,
|
||||||
|
navigateToVault = {
|
||||||
|
onCompleteOnboarding()
|
||||||
|
navController.navigate(Screen.Vault) {
|
||||||
|
popUpTo(Screen.Onboarding) { inclusive = true }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
composable<Screen.Vault> {
|
||||||
|
VaultScreen(
|
||||||
|
viewModel = koinViewModel<VaultViewModel>(),
|
||||||
|
navigateToAddScreen = {
|
||||||
|
navController.navigate(Screen.NewVaultItem)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
composable<Screen.NewVaultItem> {
|
||||||
|
AddEditVaultItemScreen(
|
||||||
|
viewModel = koinViewModel<AddEditVaultViewModel>(),
|
||||||
|
popScreen = {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/src/main/java/com/longnh15/heimdall/navigation/Screen.kt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.longnh15.heimdall.navigation
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
sealed class Screen {
|
||||||
|
@Serializable
|
||||||
|
data object Onboarding: Screen()
|
||||||
|
@Serializable
|
||||||
|
data object Vault: Screen()
|
||||||
|
@Serializable
|
||||||
|
data object NewVaultItem: Screen()
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.longnh15.heimdall.ui.common
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Warning
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AutofillNotEnabledDialog(
|
||||||
|
onRetry: () -> Unit,
|
||||||
|
onDismiss: () -> Unit
|
||||||
|
) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
icon = {
|
||||||
|
Icon(Icons.Outlined.Warning, contentDescription = null)
|
||||||
|
},
|
||||||
|
title = { Text("Autofill not enabled") },
|
||||||
|
text = {
|
||||||
|
Text("Heimdall wasn't selected as your autofill provider. Open settings and tap Heimdall to enable it.")
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = onRetry) { Text("Open settings") }
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = onDismiss) { Text("Skip for now") }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.RowScope
|
||||||
|
import androidx.compose.material3.Badge
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OnboardingBadge(modifier: Modifier = Modifier, content: @Composable (RowScope.() -> Unit)? = null) {
|
||||||
|
Badge(
|
||||||
|
modifier = modifier,
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
sealed class OnboardingEvent {
|
||||||
|
data object OpenAutofillSettings : OnboardingEvent()
|
||||||
|
data object NavigateToVault : OnboardingEvent()
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
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.res.painterResource
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.longnh15.heimdall.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OnboardingFinalPage(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
navigateToVault: () -> Unit
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = modifier.padding(48.dp, 32.dp).fillMaxSize(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(32.dp)
|
||||||
|
) {
|
||||||
|
OnboardingBadge {
|
||||||
|
Text("You're all set")
|
||||||
|
}
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(72.dp)
|
||||||
|
.background(Color(0xFF0A2E1A), shape = RoundedCornerShape(20.dp)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painterResource(R.drawable.tick_icon),
|
||||||
|
"Page icon",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Text("Heimdall is watching", style = MaterialTheme.typography.headlineMedium)
|
||||||
|
Text(
|
||||||
|
text = "Your vault is ready. Start adding passwords or import from your browser to get going.",
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(Modifier.weight(1f))
|
||||||
|
|
||||||
|
Button(onClick = navigateToVault) {
|
||||||
|
Text("Enter my vault ↗")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
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.res.painterResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.longnh15.heimdall.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OnboardingIntroducePage(modifier: Modifier = Modifier) {
|
||||||
|
Column(
|
||||||
|
modifier = modifier.padding(48.dp, 32.dp).fillMaxSize(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(32.dp)
|
||||||
|
) {
|
||||||
|
OnboardingBadge {
|
||||||
|
Text("What you get")
|
||||||
|
}
|
||||||
|
Text("Everything in one vault", style = MaterialTheme.typography.headlineMedium)
|
||||||
|
Text(
|
||||||
|
text = "Heimdall keeps your passwords safe and fills them in automatically",
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(12.dp),
|
||||||
|
) {
|
||||||
|
FeatureItem(
|
||||||
|
iconDrawableRes = R.drawable.lock_icon,
|
||||||
|
text = "End-to-end encrypted",
|
||||||
|
sub = "Only you can see your data"
|
||||||
|
)
|
||||||
|
FeatureItem(
|
||||||
|
iconDrawableRes = R.drawable.crosshair_icon,
|
||||||
|
text = "Autofill anywhere",
|
||||||
|
sub = "Works across all your apps"
|
||||||
|
)
|
||||||
|
FeatureItem(
|
||||||
|
iconDrawableRes = R.drawable.person_icon,
|
||||||
|
text = "Biometric unlock",
|
||||||
|
sub = "Fingerprint or face to open"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun FeatureItem(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
@DrawableRes iconDrawableRes: Int,
|
||||||
|
text: String,
|
||||||
|
sub: String
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.background(MaterialTheme.colorScheme.secondary, shape = RoundedCornerShape(8.dp))
|
||||||
|
.border(
|
||||||
|
0.5.dp,
|
||||||
|
MaterialTheme.colorScheme.tertiary,
|
||||||
|
RoundedCornerShape(8.dp)
|
||||||
|
)
|
||||||
|
.padding(12.dp, 14.dp),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(32.dp)
|
||||||
|
.background(Color(0xFFEEEDFE), RoundedCornerShape(8.dp)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Image(painterResource(iconDrawableRes), "Icon")
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
Text(text = text, fontSize = 13.sp, fontWeight = FontWeight(500), color = MaterialTheme.colorScheme.onPrimary)
|
||||||
|
Text(text = sub, fontSize = 12.sp, color = MaterialTheme.colorScheme.onSecondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,134 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.provider.Settings
|
||||||
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.compose.animation.animateColorAsState
|
||||||
|
import androidx.compose.animation.core.animateDpAsState
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
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.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.layout.wrapContentHeight
|
||||||
|
import androidx.compose.foundation.pager.HorizontalPager
|
||||||
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
import com.longnh15.heimdall.ui.common.AutofillNotEnabledDialog
|
||||||
|
|
||||||
|
private sealed class OnboardingPages {
|
||||||
|
data object Welcome : OnboardingPages()
|
||||||
|
data object Introduce : OnboardingPages()
|
||||||
|
data object EnableAutofill : OnboardingPages()
|
||||||
|
data object Final : OnboardingPages()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val onboardingPages = listOf(
|
||||||
|
OnboardingPages.Welcome,
|
||||||
|
OnboardingPages.Introduce,
|
||||||
|
OnboardingPages.EnableAutofill,
|
||||||
|
OnboardingPages.Final
|
||||||
|
)
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OnboardingPage(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
viewModel: OnboardingViewModel = viewModel(),
|
||||||
|
isAutofillEnabled: () -> Boolean,
|
||||||
|
navigateToVault: () -> Unit
|
||||||
|
) {
|
||||||
|
val pagerState = rememberPagerState { onboardingPages.size }
|
||||||
|
var showDialog by remember { mutableStateOf(false) }
|
||||||
|
val context = LocalContext.current
|
||||||
|
val launcher = rememberLauncherForActivityResult(
|
||||||
|
contract = ActivityResultContracts.StartActivityForResult()
|
||||||
|
) {
|
||||||
|
if (isAutofillEnabled()) {
|
||||||
|
pagerState.requestScrollToPage(3)
|
||||||
|
} else {
|
||||||
|
showDialog = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
viewModel.uiEvent.collect { event ->
|
||||||
|
when (event) {
|
||||||
|
OnboardingEvent.OpenAutofillSettings -> {
|
||||||
|
val intent = Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE).apply {
|
||||||
|
data = "package:${context.packageName}".toUri()
|
||||||
|
}
|
||||||
|
launcher.launch(intent)
|
||||||
|
}
|
||||||
|
OnboardingEvent.NavigateToVault -> navigateToVault()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Scaffold(Modifier.fillMaxSize()) { paddingValues ->
|
||||||
|
Column(modifier.padding(paddingValues)) {
|
||||||
|
HorizontalPager(
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
state = pagerState
|
||||||
|
) { pageState ->
|
||||||
|
when (onboardingPages[pageState]) {
|
||||||
|
OnboardingPages.Welcome -> OnboardingWelcomePage()
|
||||||
|
OnboardingPages.Introduce -> OnboardingIntroducePage()
|
||||||
|
OnboardingPages.EnableAutofill -> OnboardingRequestEnablePage(onOpenAutofillSettings = viewModel::onOpenAutofillSettings)
|
||||||
|
OnboardingPages.Final -> OnboardingFinalPage(navigateToVault = navigateToVault)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Indicator
|
||||||
|
Row(
|
||||||
|
Modifier.wrapContentHeight().padding(bottom = 32.dp).align(Alignment.CenterHorizontally),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
|
repeat(pagerState.pageCount) { iteration ->
|
||||||
|
val isSelected = pagerState.currentPage == iteration
|
||||||
|
val width by animateDpAsState(targetValue = if (isSelected) 24.dp else 8.dp)
|
||||||
|
val color by animateColorAsState(targetValue = if (isSelected) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.inversePrimary)
|
||||||
|
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.clip(RoundedCornerShape(3.dp))
|
||||||
|
.background(color)
|
||||||
|
.width(width).height(6.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showDialog) {
|
||||||
|
AutofillNotEnabledDialog(
|
||||||
|
onRetry = {
|
||||||
|
showDialog = false
|
||||||
|
val intent = Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE).apply {
|
||||||
|
data = "package:${context.packageName}".toUri()
|
||||||
|
}
|
||||||
|
launcher.launch(intent)
|
||||||
|
},
|
||||||
|
onDismiss = { showDialog = false }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.Badge
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
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.res.painterResource
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.longnh15.heimdall.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OnboardingRequestEnablePage(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onOpenAutofillSettings: () -> Unit
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = modifier.padding(48.dp, 32.dp).fillMaxSize(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(32.dp)
|
||||||
|
) {
|
||||||
|
OnboardingBadge {
|
||||||
|
Text("Setup · 1 of 2")
|
||||||
|
}
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(72.dp)
|
||||||
|
.background(Color(0xFF1A1A2E), shape = RoundedCornerShape(20.dp)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painterResource(R.drawable.page_icon),
|
||||||
|
"Page icon",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Text("Enable autofill", style = MaterialTheme.typography.headlineMedium)
|
||||||
|
Text(
|
||||||
|
text = "Let Heimdall fill your passwords automatically. You'll be taken to Android settings — tap Heimdall and you're done.",
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(Modifier.weight(1f))
|
||||||
|
|
||||||
|
Button(onClick = onOpenAutofillSettings) {
|
||||||
|
Text("Open settings")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import kotlinx.coroutines.channels.Channel
|
||||||
|
import kotlinx.coroutines.flow.receiveAsFlow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.core.annotation.KoinViewModel
|
||||||
|
|
||||||
|
@KoinViewModel
|
||||||
|
class OnboardingViewModel : ViewModel() {
|
||||||
|
private val _uiEvent = Channel<OnboardingEvent>()
|
||||||
|
val uiEvent = _uiEvent.receiveAsFlow()
|
||||||
|
|
||||||
|
fun onOpenAutofillSettings() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
_uiEvent.send(OnboardingEvent.OpenAutofillSettings)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.longnh15.heimdall.ui.onboarding
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
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.res.painterResource
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.longnh15.heimdall.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun OnboardingWelcomePage(modifier: Modifier = Modifier) {
|
||||||
|
Column(
|
||||||
|
modifier = modifier.padding(48.dp, 32.dp).fillMaxSize(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(32.dp)
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(72.dp)
|
||||||
|
.background(Color(0xFF1A1A2E), shape = RoundedCornerShape(20.dp)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painterResource(R.drawable.shield_icon),
|
||||||
|
"Heimdall Logo",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Text("Welcome to Heimdall", style = MaterialTheme.typography.headlineMedium)
|
||||||
|
Text(
|
||||||
|
text = "Your all-seeing guardian for passwords. Secure, private, and always watching over your credentials",
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(showBackground = true, backgroundColor = 0xFFFFFFFF)
|
||||||
|
@Composable
|
||||||
|
fun OnboardingWelcomePagePreview() {
|
||||||
|
OnboardingWelcomePage(Modifier.background(Color.White))
|
||||||
|
}
|
||||||
67
app/src/main/java/com/longnh15/heimdall/ui/theme/Color.kt
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package com.longnh15.heimdall.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.darkColorScheme
|
||||||
|
import androidx.compose.material3.lightColorScheme
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
|
||||||
|
val HeimdallLightColors = lightColorScheme(
|
||||||
|
primary = Color(0xFF534AB7),
|
||||||
|
onPrimary = Color(0xFFFFFFFF),
|
||||||
|
primaryContainer = Color(0xFFEEEDFE),
|
||||||
|
onPrimaryContainer = Color(0xFF26215C),
|
||||||
|
|
||||||
|
secondary = Color(0xFF1D9E75),
|
||||||
|
onSecondary = Color(0xFFFFFFFF),
|
||||||
|
secondaryContainer = Color(0xFFE1F5EE),
|
||||||
|
onSecondaryContainer = Color(0xFF04342C),
|
||||||
|
|
||||||
|
tertiary = Color(0xFF7F77DD),
|
||||||
|
onTertiary = Color(0xFFFFFFFF),
|
||||||
|
tertiaryContainer = Color(0xFFCECBF6),
|
||||||
|
onTertiaryContainer = Color(0xFF26215C),
|
||||||
|
|
||||||
|
error = Color(0xFFE24B4A),
|
||||||
|
onError = Color(0xFFFFFFFF),
|
||||||
|
errorContainer = Color(0xFFFCEBEB),
|
||||||
|
onErrorContainer = Color(0xFF501313),
|
||||||
|
|
||||||
|
background = Color(0xFFF8F8FC),
|
||||||
|
onBackground = Color(0xFF1A1A2E),
|
||||||
|
surface = Color(0xFFFFFFFF),
|
||||||
|
onSurface = Color(0xFF1A1A2E),
|
||||||
|
surfaceVariant = Color(0xFFEEEDFE),
|
||||||
|
onSurfaceVariant = Color(0xFF534AB7),
|
||||||
|
outline = Color(0xFFAFA9EC),
|
||||||
|
outlineVariant = Color(0xFFCECBF6),
|
||||||
|
)
|
||||||
|
|
||||||
|
val HeimdallDarkColors = darkColorScheme(
|
||||||
|
primary = Color(0xFF7F77DD),
|
||||||
|
onPrimary = Color(0xFF26215C),
|
||||||
|
primaryContainer = Color(0xFF3C3489),
|
||||||
|
onPrimaryContainer = Color(0xFFCECBF6),
|
||||||
|
|
||||||
|
secondary = Color(0xFF5DCAA5),
|
||||||
|
onSecondary = Color(0xFF04342C),
|
||||||
|
secondaryContainer = Color(0xFF0F6E56),
|
||||||
|
onSecondaryContainer = Color(0xFF9FE1CB),
|
||||||
|
|
||||||
|
tertiary = Color(0xFFAFA9EC),
|
||||||
|
onTertiary = Color(0xFF26215C),
|
||||||
|
tertiaryContainer = Color(0xFF534AB7),
|
||||||
|
onTertiaryContainer = Color(0xFFEEEDFE),
|
||||||
|
|
||||||
|
error = Color(0xFFF09595),
|
||||||
|
onError = Color(0xFF501313),
|
||||||
|
errorContainer = Color(0xFFA32D2D),
|
||||||
|
onErrorContainer = Color(0xFFF7C1C1),
|
||||||
|
|
||||||
|
background = Color(0xFF1A1A2E),
|
||||||
|
onBackground = Color(0xFFEEEDFE),
|
||||||
|
surface = Color(0xFF26215C),
|
||||||
|
onSurface = Color(0xFFEEEDFE),
|
||||||
|
surfaceVariant = Color(0xFF3C3489),
|
||||||
|
onSurfaceVariant = Color(0xFFAFA9EC),
|
||||||
|
outline = Color(0xFF7F77DD),
|
||||||
|
outlineVariant = Color(0xFF534AB7),
|
||||||
|
)
|
||||||
49
app/src/main/java/com/longnh15/heimdall/ui/theme/Theme.kt
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package com.longnh15.heimdall.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Typography
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun HeimdallTheme(
|
||||||
|
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||||
|
content: @Composable () -> Unit
|
||||||
|
) {
|
||||||
|
val colorScheme = if (darkTheme) {
|
||||||
|
HeimdallDarkColors
|
||||||
|
} else {
|
||||||
|
HeimdallLightColors
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialTheme(
|
||||||
|
colorScheme = colorScheme,
|
||||||
|
typography = HeimdallTypography,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ui/theme/Type.kt
|
||||||
|
val HeimdallTypography = Typography(
|
||||||
|
headlineLarge = TextStyle(
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
fontSize = 28.sp
|
||||||
|
),
|
||||||
|
titleMedium = TextStyle(
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 16.sp
|
||||||
|
),
|
||||||
|
bodyMedium = TextStyle(
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 14.sp,
|
||||||
|
lineHeight = 22.sp
|
||||||
|
),
|
||||||
|
labelSmall = TextStyle(
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
letterSpacing = 0.5.sp
|
||||||
|
)
|
||||||
|
)
|
||||||
34
app/src/main/java/com/longnh15/heimdall/ui/theme/Type.kt
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.longnh15.heimdall.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.Typography
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
// Set of Material typography styles to start with
|
||||||
|
val Typography = Typography(
|
||||||
|
bodyLarge = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
lineHeight = 24.sp,
|
||||||
|
letterSpacing = 0.5.sp
|
||||||
|
)
|
||||||
|
/* Other default text styles to override
|
||||||
|
titleLarge = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Normal,
|
||||||
|
fontSize = 22.sp,
|
||||||
|
lineHeight = 28.sp,
|
||||||
|
letterSpacing = 0.sp
|
||||||
|
),
|
||||||
|
labelSmall = TextStyle(
|
||||||
|
fontFamily = FontFamily.Default,
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
lineHeight = 16.sp,
|
||||||
|
letterSpacing = 0.5.sp
|
||||||
|
)
|
||||||
|
*/
|
||||||
|
)
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Fingerprint
|
||||||
|
import androidx.compose.material.icons.outlined.Lock
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
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.unit.dp
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun LockOverlay(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
requestBiometric: () -> Unit,
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.background(MaterialTheme.colorScheme.background),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Lock,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = MaterialTheme.colorScheme.primary,
|
||||||
|
modifier = Modifier.size(48.dp)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Vault is locked",
|
||||||
|
style = MaterialTheme.typography.titleMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onBackground
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = "Authenticate to access your credentials",
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
Button(onClick = requestBiometric) {
|
||||||
|
Icon(
|
||||||
|
Icons.Outlined.Fingerprint,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(18.dp)
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
|
Text("Unlock with biometrics")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.items
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Add
|
||||||
|
import androidx.compose.material3.FloatingActionButton
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.longnh15.heimdall.domain.model.Credential
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun VaultContent(
|
||||||
|
credentials: List<Credential>,
|
||||||
|
navigateToAddScreen: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
Scaffold(
|
||||||
|
modifier = modifier,
|
||||||
|
topBar = { VaultHeader() },
|
||||||
|
floatingActionButton = {
|
||||||
|
FloatingActionButton(onClick = navigateToAddScreen) {
|
||||||
|
Icon(Icons.Filled.Add, null)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
) { paddingValues ->
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(paddingValues)
|
||||||
|
.padding(14.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
|
) {
|
||||||
|
items(credentials) { credential ->
|
||||||
|
VaultItem(credential)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.AccessTime
|
||||||
|
import androidx.compose.material.icons.outlined.Person
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.IconButtonDefaults
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun VaultHeader() {
|
||||||
|
TopAppBar(
|
||||||
|
title = {
|
||||||
|
Text("My vault")
|
||||||
|
},
|
||||||
|
colors = TopAppBarDefaults.topAppBarColors().copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.background
|
||||||
|
),
|
||||||
|
actions = {
|
||||||
|
IconButton(
|
||||||
|
colors = IconButtonDefaults.iconButtonColors().copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
),
|
||||||
|
onClick = {}
|
||||||
|
) {
|
||||||
|
Icon(Icons.Outlined.Person, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
IconButton(
|
||||||
|
colors = IconButtonDefaults.iconButtonColors().copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.primaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onPrimaryContainer
|
||||||
|
),
|
||||||
|
onClick = {}
|
||||||
|
) {
|
||||||
|
Icon(Icons.Outlined.AccessTime, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
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.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.ContentCopy
|
||||||
|
import androidx.compose.material.icons.outlined.Lock
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.IconButtonDefaults
|
||||||
|
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.draw.clip
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.longnh15.heimdall.domain.model.Credential
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun VaultItem(
|
||||||
|
credential: Credential,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = modifier
|
||||||
|
.clip(RoundedCornerShape(12.dp))
|
||||||
|
.background(MaterialTheme.colorScheme.onPrimary)
|
||||||
|
.border(0.5.dp, MaterialTheme.colorScheme.primaryContainer, shape = RoundedCornerShape(12.dp))
|
||||||
|
.padding(12.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(36.dp)
|
||||||
|
.clip(RoundedCornerShape(10.dp))
|
||||||
|
.background(Color(0xFF4A1B0C)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Text(credential.name.first().uppercase(), color = Color.White)
|
||||||
|
}
|
||||||
|
|
||||||
|
Column(modifier = Modifier) {
|
||||||
|
Text(
|
||||||
|
text = credential.name,
|
||||||
|
fontSize = 13.sp,
|
||||||
|
color = MaterialTheme.colorScheme.onTertiaryContainer,
|
||||||
|
fontWeight = FontWeight(500)
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = credential.username,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
color = MaterialTheme.colorScheme.outline
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(Modifier.weight(1f))
|
||||||
|
|
||||||
|
VaultItemAction(icon = Icons.Outlined.ContentCopy, onClick = {})
|
||||||
|
VaultItemAction(icon = Icons.Outlined.Lock, onClick = {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun VaultItemAction(
|
||||||
|
icon: ImageVector,
|
||||||
|
onClick: () -> Unit
|
||||||
|
) {
|
||||||
|
IconButton(
|
||||||
|
modifier = Modifier.size(32.dp),
|
||||||
|
onClick = onClick,
|
||||||
|
shape = RoundedCornerShape(8.dp),
|
||||||
|
colors = IconButtonDefaults.iconButtonColors().copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.surfaceVariant,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Icon(icon, null, modifier = Modifier.size(16.dp))
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault
|
||||||
|
|
||||||
|
import androidx.biometric.AuthenticationRequest
|
||||||
|
import androidx.biometric.AuthenticationRequest.Companion.biometricRequest
|
||||||
|
import androidx.biometric.AuthenticationResult
|
||||||
|
import androidx.biometric.AuthenticationResultCallback
|
||||||
|
import androidx.biometric.compose.rememberAuthenticationLauncher
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun VaultScreen(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
viewModel: VaultViewModel = viewModel(),
|
||||||
|
navigateToAddScreen: () -> Unit,
|
||||||
|
) {
|
||||||
|
val isUnlocked by viewModel.isUnlocked.collectAsStateWithLifecycle()
|
||||||
|
val credentials by viewModel.credentials.collectAsStateWithLifecycle()
|
||||||
|
val launcher = rememberAuthenticationLauncher(
|
||||||
|
resultCallback = object : AuthenticationResultCallback {
|
||||||
|
override fun onAuthResult(result: AuthenticationResult) {
|
||||||
|
viewModel.requestUnlock()
|
||||||
|
}
|
||||||
|
override fun onAuthAttemptFailed() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
val requestBiometric = remember { {
|
||||||
|
val request = biometricRequest(
|
||||||
|
title = "Unlock Heimdall",
|
||||||
|
AuthenticationRequest.Biometric.Fallback.DeviceCredential,
|
||||||
|
) {
|
||||||
|
setSubtitle("Confirm your identity to access your vault")
|
||||||
|
}
|
||||||
|
launcher.launch(request)
|
||||||
|
} }
|
||||||
|
|
||||||
|
LaunchedEffect(isUnlocked) {
|
||||||
|
if (!isUnlocked) {
|
||||||
|
requestBiometric()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VaultContent(
|
||||||
|
credentials = credentials,
|
||||||
|
navigateToAddScreen = navigateToAddScreen
|
||||||
|
)
|
||||||
|
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = !isUnlocked,
|
||||||
|
enter = fadeIn(),
|
||||||
|
exit = fadeOut()
|
||||||
|
) {
|
||||||
|
LockOverlay(
|
||||||
|
modifier = modifier,
|
||||||
|
requestBiometric = requestBiometric
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.longnh15.heimdall.domain.repository.CredentialRepository
|
||||||
|
import com.longnh15.heimdall.domain.vault.VaultSessionManager
|
||||||
|
import com.longnh15.heimdall.domain.vault.VaultSessionState
|
||||||
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
|
import kotlinx.coroutines.flow.stateIn
|
||||||
|
import org.koin.core.annotation.KoinViewModel
|
||||||
|
|
||||||
|
@KoinViewModel
|
||||||
|
class VaultViewModel (
|
||||||
|
private val vaultSessionManager: VaultSessionManager,
|
||||||
|
private val credentialRepository: CredentialRepository,
|
||||||
|
): ViewModel() {
|
||||||
|
val isUnlocked: StateFlow<Boolean> = vaultSessionManager.sessionState
|
||||||
|
.map { it is VaultSessionState.Unlocked }
|
||||||
|
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false)
|
||||||
|
val credentials = credentialRepository.getAll()
|
||||||
|
.stateIn(
|
||||||
|
viewModelScope,
|
||||||
|
SharingStarted.WhileSubscribed(),
|
||||||
|
listOf()
|
||||||
|
)
|
||||||
|
|
||||||
|
fun requestUnlock() {
|
||||||
|
vaultSessionManager.unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault.edit
|
||||||
|
|
||||||
|
sealed class AddEditEvent {
|
||||||
|
data object SaveSuccess: AddEditEvent()
|
||||||
|
data class SaveError(val message: String): AddEditEvent()
|
||||||
|
}
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault.edit
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.RowScope
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.foundation.text.BasicTextField
|
||||||
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
|
import androidx.compose.material3.HorizontalDivider
|
||||||
|
import androidx.compose.material3.LocalContentColor
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
|
import androidx.compose.ui.text.input.VisualTransformation
|
||||||
|
import androidx.compose.ui.tooling.preview.AndroidUiModes.UI_MODE_NIGHT_YES
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.longnh15.heimdall.ui.theme.HeimdallTheme
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AddEditForm(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
content: @Composable ColumnScope.() -> Unit
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clip(RoundedCornerShape(12.dp))
|
||||||
|
.background(MaterialTheme.colorScheme.onPrimary)
|
||||||
|
.border(0.5.dp, MaterialTheme.colorScheme.outline, RoundedCornerShape(12.dp)),
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AddEditFormTextField(
|
||||||
|
value: String,
|
||||||
|
onValueChange: (String) -> Unit,
|
||||||
|
label: String,
|
||||||
|
placeholder: String,
|
||||||
|
isHideContent: Boolean = false,
|
||||||
|
isLastField: Boolean = false,
|
||||||
|
autoCorrectEnabled: Boolean = true,
|
||||||
|
actions: @Composable RowScope.() -> Unit = {},
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 12.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = label,
|
||||||
|
modifier = Modifier.width(100.dp).padding(vertical = 12.dp),
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
fontSize = 14.sp
|
||||||
|
)
|
||||||
|
BasicTextField(
|
||||||
|
value = value,
|
||||||
|
onValueChange = onValueChange,
|
||||||
|
modifier = Modifier.weight(1f),
|
||||||
|
textStyle = TextStyle(
|
||||||
|
color = MaterialTheme.colorScheme.onSurface,
|
||||||
|
fontSize = 16.sp
|
||||||
|
),
|
||||||
|
keyboardOptions = if (isLastField)
|
||||||
|
KeyboardOptions.Default.copy(
|
||||||
|
autoCorrectEnabled = autoCorrectEnabled,
|
||||||
|
imeAction = ImeAction.Done
|
||||||
|
)
|
||||||
|
else
|
||||||
|
KeyboardOptions.Default.copy(
|
||||||
|
autoCorrectEnabled = autoCorrectEnabled,
|
||||||
|
imeAction = ImeAction.Next
|
||||||
|
),
|
||||||
|
singleLine = true,
|
||||||
|
visualTransformation = if (isHideContent) PasswordVisualTransformation() else VisualTransformation.None,
|
||||||
|
decorationBox = { innerTextField ->
|
||||||
|
if (value.isEmpty()) {
|
||||||
|
Text(
|
||||||
|
text = placeholder,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
color = MaterialTheme.colorScheme.surfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
innerTextField()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.primary) {
|
||||||
|
actions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AddEditFormHeader(text: String) {
|
||||||
|
Text(
|
||||||
|
text = text.uppercase(),
|
||||||
|
fontSize = 13.sp,
|
||||||
|
fontWeight = FontWeight(500),
|
||||||
|
color = MaterialTheme.colorScheme.primary,
|
||||||
|
letterSpacing = 0.8.sp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AddEditDivider() {
|
||||||
|
HorizontalDivider(thickness = 0.5.dp, color = MaterialTheme.colorScheme.outline)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(uiMode = UI_MODE_NIGHT_YES)
|
||||||
|
@Composable
|
||||||
|
fun AddEditFormPreview() {
|
||||||
|
HeimdallTheme {
|
||||||
|
AddEditForm {
|
||||||
|
AddEditFormTextField(
|
||||||
|
value = "",
|
||||||
|
onValueChange = {},
|
||||||
|
label = "Name",
|
||||||
|
placeholder = "e.g. Google"
|
||||||
|
)
|
||||||
|
HorizontalDivider(thickness = 0.5.dp, color = MaterialTheme.colorScheme.outline)
|
||||||
|
AddEditFormTextField(
|
||||||
|
value = "abc",
|
||||||
|
onValueChange = {},
|
||||||
|
label = "URL",
|
||||||
|
placeholder = "google.com"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault.edit
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.alpha
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun AddEditHeader(
|
||||||
|
isSaveEnable: Boolean,
|
||||||
|
isSaving: Boolean,
|
||||||
|
popScreen: () -> Unit,
|
||||||
|
onSaveClick: () -> Unit,
|
||||||
|
) {
|
||||||
|
TopAppBar(
|
||||||
|
title = {
|
||||||
|
Text("New item")
|
||||||
|
},
|
||||||
|
modifier = Modifier.padding(end = 16.dp),
|
||||||
|
colors = TopAppBarDefaults.topAppBarColors().copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.background
|
||||||
|
),
|
||||||
|
navigationIcon = { IconButton(onClick = popScreen) {
|
||||||
|
Icon(Icons.AutoMirrored.Filled.ArrowBack, null)
|
||||||
|
}},
|
||||||
|
actions = {
|
||||||
|
Button(
|
||||||
|
onClick = onSaveClick,
|
||||||
|
contentPadding = PaddingValues(14.dp, 6.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors().copy(
|
||||||
|
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
||||||
|
contentColor = MaterialTheme.colorScheme.onTertiaryContainer,
|
||||||
|
disabledContainerColor = MaterialTheme.colorScheme.tertiaryContainer,
|
||||||
|
disabledContentColor = MaterialTheme.colorScheme.onTertiaryContainer,
|
||||||
|
),
|
||||||
|
enabled = isSaveEnable,
|
||||||
|
modifier = Modifier.alpha(if (isSaveEnable) 1f else 0.4f)
|
||||||
|
) {
|
||||||
|
if (isSaving) {
|
||||||
|
CircularProgressIndicator(
|
||||||
|
modifier = Modifier.size(16.dp),
|
||||||
|
strokeWidth = 2.dp,
|
||||||
|
)
|
||||||
|
Spacer(Modifier.width(8.dp))
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = if (isSaving) "Saving…" else "Save",
|
||||||
|
fontSize = 13.sp,
|
||||||
|
fontWeight = FontWeight(500),
|
||||||
|
color = MaterialTheme.colorScheme.onTertiaryContainer
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault.edit
|
||||||
|
|
||||||
|
import com.longnh15.heimdall.domain.model.Credential
|
||||||
|
|
||||||
|
data class AddEditState(
|
||||||
|
val name: String = "",
|
||||||
|
val url: String = "",
|
||||||
|
val username: String = "",
|
||||||
|
val password: String = "",
|
||||||
|
|
||||||
|
val nameTouched: Boolean = false,
|
||||||
|
val urlTouched: Boolean = false,
|
||||||
|
val usernameTouched: Boolean = false,
|
||||||
|
val passwordTouched: Boolean = false,
|
||||||
|
|
||||||
|
val isShowPassword: Boolean = false,
|
||||||
|
val isSaving: Boolean = false,
|
||||||
|
) {
|
||||||
|
val nameError: String?
|
||||||
|
get() = if (nameTouched && name.isBlank()) "Name is required" else null
|
||||||
|
val usernameError: String?
|
||||||
|
get() = if (urlTouched && url.isBlank()) "Url is required" else null
|
||||||
|
val passwordError: String?
|
||||||
|
get() = if (passwordTouched && password.isBlank()) "Password is required" else null
|
||||||
|
|
||||||
|
val isFormValid: Boolean
|
||||||
|
get() = name.isNotBlank() && username.isNotBlank() && password.isNotBlank()
|
||||||
|
|
||||||
|
val passwordStrength: PasswordStrength get() {
|
||||||
|
if (password.isBlank()) return PasswordStrength.NONE
|
||||||
|
var score = 0
|
||||||
|
if (password.length >= 8) score++
|
||||||
|
if (password.length >= 14) score++
|
||||||
|
if (password.any { it.isUpperCase() } && password.any { it.isDigit() }) score++
|
||||||
|
if (password.any { !it.isLetterOrDigit() }) score++
|
||||||
|
return when (score) {
|
||||||
|
1 -> PasswordStrength.WEAK
|
||||||
|
2 -> PasswordStrength.FAIR
|
||||||
|
3 -> PasswordStrength.GOOD
|
||||||
|
else -> PasswordStrength.STRONG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toCredential(): Credential {
|
||||||
|
return Credential(
|
||||||
|
name, url, username, password
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,136 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault.edit
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.AccessTime
|
||||||
|
import androidx.compose.material.icons.outlined.Visibility
|
||||||
|
import androidx.compose.material.icons.outlined.VisibilityOff
|
||||||
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.SnackbarHost
|
||||||
|
import androidx.compose.material3.SnackbarHostState
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.focus.focusProperties
|
||||||
|
import androidx.compose.ui.tooling.preview.AndroidUiModes.UI_MODE_NIGHT_YES
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
|
import com.longnh15.heimdall.ui.theme.HeimdallTheme
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun AddEditVaultItemScreen(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
viewModel: AddEditVaultViewModel = viewModel(),
|
||||||
|
popScreen: () -> Unit,
|
||||||
|
) {
|
||||||
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
viewModel.uiEvent.collect { event ->
|
||||||
|
when (event) {
|
||||||
|
AddEditEvent.SaveSuccess -> popScreen()
|
||||||
|
is AddEditEvent.SaveError -> snackbarHostState.showSnackbar(event.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Scaffold(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize(),
|
||||||
|
topBar = {
|
||||||
|
AddEditHeader(
|
||||||
|
isSaveEnable = with(viewModel.state) { isFormValid && !isSaving },
|
||||||
|
isSaving = viewModel.state.isSaving,
|
||||||
|
popScreen = popScreen,
|
||||||
|
onSaveClick = viewModel::save,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
snackbarHost = {
|
||||||
|
SnackbarHost(snackbarHostState)
|
||||||
|
}
|
||||||
|
) { paddingValues ->
|
||||||
|
Column(
|
||||||
|
modifier.padding(paddingValues).padding(horizontal = 16.dp),
|
||||||
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
|
) {
|
||||||
|
AddEditFormHeader("details")
|
||||||
|
AddEditForm {
|
||||||
|
AddEditFormTextField(
|
||||||
|
value = viewModel.state.name,
|
||||||
|
onValueChange = viewModel::onNameChanged,
|
||||||
|
label = "Name",
|
||||||
|
placeholder = "e.g. Google"
|
||||||
|
)
|
||||||
|
AddEditDivider()
|
||||||
|
AddEditFormTextField(
|
||||||
|
value = viewModel.state.url,
|
||||||
|
onValueChange = viewModel::onUrlChanged,
|
||||||
|
label = "URL",
|
||||||
|
placeholder = "google.com",
|
||||||
|
actions = {
|
||||||
|
IconButton(
|
||||||
|
onClick = {},
|
||||||
|
modifier = Modifier.focusProperties { canFocus = false }
|
||||||
|
) {
|
||||||
|
Icon(Icons.Outlined.AccessTime, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
AddEditFormHeader("credentials")
|
||||||
|
AddEditForm {
|
||||||
|
AddEditFormTextField(
|
||||||
|
viewModel.state.username,
|
||||||
|
onValueChange = viewModel::onUsernameChanged,
|
||||||
|
label = "Username",
|
||||||
|
placeholder = "you@email.com"
|
||||||
|
)
|
||||||
|
AddEditDivider()
|
||||||
|
AddEditFormTextField(
|
||||||
|
value = viewModel.state.password,
|
||||||
|
onValueChange = viewModel::onPasswordChanged,
|
||||||
|
label = "Password",
|
||||||
|
placeholder = "••••••••",
|
||||||
|
isHideContent = viewModel.state.isShowPassword.not(),
|
||||||
|
isLastField = true,
|
||||||
|
autoCorrectEnabled = false,
|
||||||
|
actions = {
|
||||||
|
IconButton(
|
||||||
|
onClick = viewModel::toggleShowPassword,
|
||||||
|
modifier = Modifier.focusProperties { canFocus = false }
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = if (viewModel.state.isShowPassword) Icons.Outlined.VisibilityOff else Icons.Outlined.Visibility,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview(
|
||||||
|
showSystemUi = true,
|
||||||
|
uiMode = UI_MODE_NIGHT_YES
|
||||||
|
)
|
||||||
|
@Composable
|
||||||
|
fun AddEditVaultItemScreenPreview() {
|
||||||
|
HeimdallTheme {
|
||||||
|
AddEditVaultItemScreen(popScreen = {})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault.edit
|
||||||
|
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.longnh15.heimdall.domain.repository.CredentialRepository
|
||||||
|
import kotlinx.coroutines.channels.Channel
|
||||||
|
import kotlinx.coroutines.flow.receiveAsFlow
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.koin.core.annotation.KoinViewModel
|
||||||
|
|
||||||
|
@KoinViewModel
|
||||||
|
class AddEditVaultViewModel(
|
||||||
|
private val credentialRepository: CredentialRepository
|
||||||
|
): ViewModel() {
|
||||||
|
var state by mutableStateOf(AddEditState())
|
||||||
|
private set
|
||||||
|
private val _uiEvent = Channel<AddEditEvent>()
|
||||||
|
val uiEvent = _uiEvent.receiveAsFlow()
|
||||||
|
|
||||||
|
fun onNameChanged(value: String) {
|
||||||
|
state = state.copy(name = value, nameTouched = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onUrlChanged(value: String) {
|
||||||
|
state = state.copy(url = value, urlTouched = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onUsernameChanged(value: String) {
|
||||||
|
state = state.copy(username = value, usernameTouched = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onPasswordChanged(value: String) {
|
||||||
|
state = state.copy(password = value, passwordTouched = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toggleShowPassword() {
|
||||||
|
state = state.copy(isShowPassword = !state.isShowPassword)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun save() {
|
||||||
|
if (!state.isFormValid && state.isSaving) {
|
||||||
|
// Just defensive, UI must "blog" this action already
|
||||||
|
return
|
||||||
|
}
|
||||||
|
viewModelScope.launch {
|
||||||
|
state = state.copy(isSaving = true)
|
||||||
|
try {
|
||||||
|
credentialRepository.save(state.toCredential())
|
||||||
|
_uiEvent.send(AddEditEvent.SaveSuccess)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
state = state.copy(isSaving = false)
|
||||||
|
_uiEvent.send(AddEditEvent.SaveError(e.message ?: "Something went wrong."))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.longnh15.heimdall.ui.vault.edit
|
||||||
|
|
||||||
|
enum class PasswordStrength {
|
||||||
|
NONE, WEAK, FAIR, GOOD, STRONG
|
||||||
|
}
|
||||||
32
app/src/main/res/drawable/crosshair_icon.xml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2026 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="16dp"
|
||||||
|
android:height="16dp"
|
||||||
|
android:viewportWidth="16"
|
||||||
|
android:viewportHeight="16">
|
||||||
|
<path
|
||||||
|
android:pathData="M2,8h12M8,2v12"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#534AB7"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M8,8m-5.5,0a5.5,5.5 0,1 1,11 0a5.5,5.5 0,1 1,-11 0"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#534AB7"/>
|
||||||
|
</vector>
|
||||||
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
||||||
29
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2026 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="408.6"
|
||||||
|
android:viewportHeight="512">
|
||||||
|
<group android:scaleX="0.40478712"
|
||||||
|
android:scaleY="0.50722224"
|
||||||
|
android:translateX="121.60199"
|
||||||
|
android:translateY="126.15111">
|
||||||
|
<path
|
||||||
|
android:pathData="M261.5,470.6L261.5,441l10.2,-31.6c71.1,-70.5 127,-136.4 136.9,-156.7l-12.1,4.2s11.3,-14.1 10.2,-22C397.5,96.8 319.6,24.8 298.2,7.1c31.6,38 23,50.4 23,50.4C307.2,31.6 278.6,6.4 273,0L266.2,40.2C293.3,56 286.1,65 286.1,65c-6.4,-9 -23.7,-16.9 -23.7,-16.9l-1.9,11.3c8.3,3.8 45.5,26.3 45.8,84.2 0,70.5 -40.1,89.1 -47.1,91.9 -23.4,-14.1 -48.8,-13.8 -55,-14.4 -6.2,0.6 -31.6,0.3 -55,14.4 -7.1,-2.8 -47.1,-21.4 -47.1,-91.9 0.3,-57.9 37.5,-80.4 45.8,-84.2l-1.9,-11.3S128.7,56 122.3,65c0,0 -7.2,-9 19.9,-24.8L135.4,0C129.8,6.4 101.2,31.6 87.2,57.5c0,0 -8.7,-12.4 23,-50.4 -21.4,17.7 -99.3,89.7 -108.3,227.8 -1.1,7.9 10.2,22 10.2,22l-12.1,-4.2c9.9,20.3 65.8,86.3 136.9,156.7l10.2,31.6v29.6l-9,-31.6 -20.6,-33.8v34.4c8.5,24 41.5,72.4 41.5,72.4L159,411.6L32.3,273.8s79,64.3 101.6,87.4l11.9,-12.1c-14.7,-10.4 -78.5,-74.4 -84.1,-130.8 48,101.5 94,114.2 127.8,153.6v9.7h29.4v-9.7c33.9,-39.5 79.9,-52.2 127.8,-153.6 -5.6,56.4 -69.4,120.4 -84.1,130.8l11.9,12.1c22.6,-23.1 101.6,-87.4 101.6,-87.4L249.6,411.6L249.6,512s33,-48.5 41.5,-72.4v-34.4L270.5,439zM204.2,349.4c-21.2,-14.1 -75.6,-47.1 -98.2,-98.7 12.5,14.9 26.2,28.7 40.9,41.4 0,0 -1.4,-36.4 1.4,-44.3 5.1,43.7 15.5,62.3 55.9,85.4 40.4,-23.1 50.8,-41.7 55.9,-85.4 2.8,7.9 1.4,44.3 1.4,44.3 14.7,-12.7 28.4,-26.6 40.9,-41.4 -22.6,51.6 -77,84.6 -98.2,98.7"
|
||||||
|
android:fillColor="#fff"/>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
29
app/src/main/res/drawable/lock_icon.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2026 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="16dp"
|
||||||
|
android:height="16dp"
|
||||||
|
android:viewportWidth="16"
|
||||||
|
android:viewportHeight="16">
|
||||||
|
<path
|
||||||
|
android:pathData="M5,7L11,7A2,2 0,0 1,13 9L13,12A2,2 0,0 1,11 14L5,14A2,2 0,0 1,3 12L3,9A2,2 0,0 1,5 7z"
|
||||||
|
android:fillColor="#534AB7"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M5,7V5a3,3 0,0 1,6 0v2"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#534AB7"/>
|
||||||
|
</vector>
|
||||||
34
app/src/main/res/drawable/page_icon.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2026 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="38dp"
|
||||||
|
android:height="38dp"
|
||||||
|
android:viewportWidth="38"
|
||||||
|
android:viewportHeight="38">
|
||||||
|
<path
|
||||||
|
android:pathData="M11,5L27,5A4,4 0,0 1,31 9L31,29A4,4 0,0 1,27 33L11,33A4,4 0,0 1,7 29L7,9A4,4 0,0 1,11 5z"
|
||||||
|
android:strokeAlpha="0.2"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#534AB7"
|
||||||
|
android:strokeColor="#AFA9EC"
|
||||||
|
android:fillAlpha="0.2"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M13,14h12M13,19h12M13,24h7"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#AFA9EC"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
</vector>
|
||||||
24
app/src/main/res/drawable/person_icon.xml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2026 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="16dp"
|
||||||
|
android:height="16dp"
|
||||||
|
android:viewportWidth="16"
|
||||||
|
android:viewportHeight="16">
|
||||||
|
<path
|
||||||
|
android:pathData="M8,2a4,4 0,1 1,0 8A4,4 0,0 1,8 2zM8,11c-3.5,0 -6,1.5 -6,2.5v0.5h12v-0.5c0,-1 -2.5,-2.5 -6,-2.5z"
|
||||||
|
android:fillColor="#534AB7"/>
|
||||||
|
</vector>
|
||||||
40
app/src/main/res/drawable/shield_icon.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2026 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="38dp"
|
||||||
|
android:height="38dp"
|
||||||
|
android:viewportWidth="38"
|
||||||
|
android:viewportHeight="38">
|
||||||
|
<path
|
||||||
|
android:pathData="M19,4L6,10v9c0,7.18 5.58,13.89 13,15.93C26.42,32.89 32,26.18 32,19v-9L19,4z"
|
||||||
|
android:strokeAlpha="0.3"
|
||||||
|
android:fillColor="#534AB7"
|
||||||
|
android:fillAlpha="0.3"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M19,4L6,10v9c0,7.18 5.58,13.89 13,15.93C26.42,32.89 32,26.18 32,19v-9L19,4z"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#AFA9EC"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M19,19m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0"
|
||||||
|
android:fillColor="#AFA9EC"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M19,15v-4M19,27v-4M23.5,19h4M10.5,19h4"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#AFA9EC"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
</vector>
|
||||||
35
app/src/main/res/drawable/tick_icon.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2026 The Android Open Source Project
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
-->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="38dp"
|
||||||
|
android:height="38dp"
|
||||||
|
android:viewportWidth="38"
|
||||||
|
android:viewportHeight="38">
|
||||||
|
<path
|
||||||
|
android:pathData="M19,19m-13,0a13,13 0,1 1,26 0a13,13 0,1 1,-26 0"
|
||||||
|
android:strokeAlpha="0.25"
|
||||||
|
android:strokeWidth="1.5"
|
||||||
|
android:fillColor="#1D9E75"
|
||||||
|
android:strokeColor="#5DCAA5"
|
||||||
|
android:fillAlpha="0.25"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M12,19l5,5 9,-9"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#5DCAA5"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
</vector>
|
||||||
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
6
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Normal file
|
After Width: | Height: | Size: 10 KiB |
10
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="purple_200">#FFBB86FC</color>
|
||||||
|
<color name="purple_500">#FF6200EE</color>
|
||||||
|
<color name="purple_700">#FF3700B3</color>
|
||||||
|
<color name="teal_200">#FF03DAC5</color>
|
||||||
|
<color name="teal_700">#FF018786</color>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
||||||
4
app/src/main/res/values/ic_launcher_background.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#3D170B</color>
|
||||||
|
</resources>
|
||||||
3
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Heimdall</string>
|
||||||
|
</resources>
|
||||||
5
app/src/main/res/values/themes.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="Theme.Heimdall" parent="android:Theme.Material.Light.NoActionBar" />
|
||||||
|
</resources>
|
||||||
13
app/src/main/res/xml/backup_rules.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
|
for details.
|
||||||
|
Note: This file is ignored for devices older than API 31
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
|
-->
|
||||||
|
<full-backup-content>
|
||||||
|
<!--
|
||||||
|
<include domain="sharedpref" path="."/>
|
||||||
|
<exclude domain="sharedpref" path="device.xml"/>
|
||||||
|
-->
|
||||||
|
</full-backup-content>
|
||||||
19
app/src/main/res/xml/data_extraction_rules.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
||||||
4
app/src/main/res/xml/service_configuration.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<autofill-service
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:settingsActivity="com.longnh15.heimdall.MainActivity" />
|
||||||
17
app/src/test/java/com/longnh15/heimdall/ExampleUnitTest.kt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.longnh15.heimdall
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
import org.junit.Assert.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
|
*/
|
||||||
|
class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
fun addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
6
build.gradle.kts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application) apply false
|
||||||
|
alias(libs.plugins.kotlin.compose) apply false
|
||||||
|
alias(libs.plugins.devtool.ksp) apply false
|
||||||
|
}
|
||||||
15
gradle.properties
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Project-wide Gradle settings.
|
||||||
|
# IDE (e.g. Android Studio) users:
|
||||||
|
# Gradle settings configured through the IDE *will override*
|
||||||
|
# any settings specified in this file.
|
||||||
|
# For more details on how to configure your build environment visit
|
||||||
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
|
# This option should only be used with decoupled projects. For more details, visit
|
||||||
|
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
|
||||||
|
# org.gradle.parallel=true
|
||||||
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
|
kotlin.code.style=official
|
||||||
12
gradle/gradle-daemon-jvm.properties
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#This file is generated by updateDaemonJvm
|
||||||
|
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
|
||||||
|
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
|
||||||
|
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
|
||||||
|
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
|
||||||
|
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/73bcfb608d1fde9fb62e462f834a3299/redirect
|
||||||
|
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/846ee0d876d26a26f37aa1ce8de73224/redirect
|
||||||
|
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/ec7520a1e057cd116f9544c42142a16b/redirect
|
||||||
|
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/4c4f879899012ff0a8b2e2117df03b0e/redirect
|
||||||
|
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/9482ddec596298c84656d31d16652665/redirect
|
||||||
|
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/39701d92e1756bb2f141eb67cd4c660e/redirect
|
||||||
|
toolchainVersion=21
|
||||||
57
gradle/libs.versions.toml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
[versions]
|
||||||
|
agp = "9.2.1"
|
||||||
|
coreKtx = "1.19.0"
|
||||||
|
junit = "4.13.2"
|
||||||
|
junitVersion = "1.3.0"
|
||||||
|
espressoCore = "3.7.0"
|
||||||
|
lifecycleRuntimeKtx = "2.10.0"
|
||||||
|
activityCompose = "1.13.0"
|
||||||
|
kotlin = "2.3.20"
|
||||||
|
composeBom = "2026.05.01"
|
||||||
|
kspVersion = "2.3.6"
|
||||||
|
koin = "4.2.1"
|
||||||
|
koinKsp = "4.2.1"
|
||||||
|
koinPlugin = "1.0.0"
|
||||||
|
navigation = "2.9.8"
|
||||||
|
serialization = "2.4.0"
|
||||||
|
datastore = "1.2.1"
|
||||||
|
biometric = "1.4.0-alpha07"
|
||||||
|
room = "2.8.4"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||||
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||||
|
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
|
||||||
|
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtx" }
|
||||||
|
androidx-lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycleRuntimeKtx" }
|
||||||
|
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||||
|
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||||
|
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
|
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||||
|
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
|
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
|
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||||
|
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
|
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
|
androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences" , version.ref = "datastore"}
|
||||||
|
icon-pack = { group = "androidx.compose.material", name = "material-icons-extended-android" }
|
||||||
|
koin = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
|
||||||
|
koin-compose = { group = "io.insert-koin", name = "koin-compose", version.ref = "koin" }
|
||||||
|
koin-compose-viewmodel-navigation = { group = "io.insert-koin", name = "koin-compose-viewmodel-navigation", version.ref = "koin" }
|
||||||
|
koin-compose-viewmodel = { group = "io.insert-koin", name = "koin-compose-viewmodel", version.ref = "koin" }
|
||||||
|
koin-annotations = { group = "io.insert-koin", name = "koin-annotations", version.ref = "koinKsp"}
|
||||||
|
navigation-compose = { group = "androidx.navigation" , name = "navigation-compose", version.ref = "navigation" }
|
||||||
|
biometric-compose = { group = "androidx.biometric", name = "biometric-compose", version.ref = "biometric" }
|
||||||
|
androidx-room = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
|
||||||
|
androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
|
||||||
|
androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
devtool-ksp = { id = "com.google.devtools.ksp", version.ref = "kspVersion" }
|
||||||
|
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
|
serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialization" }
|
||||||
|
koin-compiler = { id = "io.insert-koin.compiler.plugin", version.ref = "koinPlugin" }
|
||||||
|
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
9
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
retries=0
|
||||||
|
retryBackOffMs=500
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
248
gradlew
vendored
Executable file
@ -0,0 +1,248 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
82
gradlew.bat
vendored
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
|
setlocal EnableExtensions
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||||
|
@rem which allows us to clear the local environment before executing the java command
|
||||||
|
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||||
|
|
||||||
|
:exitWithErrorLevel
|
||||||
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||