Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add loading animation to Android as separate template (#520)

Leendert de Borst1db63bbc6b89
diff --git a/apps/mobile-app/android/app/src/main/AndroidManifest.xml b/apps/mobile-app/android/app/src/main/AndroidManifest.xml
index ce0beadc6..594cce14f 100644
--- a/apps/mobile-app/android/app/src/main/AndroidManifest.xml
+++ b/apps/mobile-app/android/app/src/main/AndroidManifest.xml
@@ -47,7 +47,9 @@
<activity
android:name=".credentialprovider.PasskeyRegistrationActivity"
android:exported="true"
- android:theme="@style/PasskeyRegistrationTheme" />
+ android:theme="@style/PasskeyRegistrationTheme"
+ android:windowSoftInputMode="adjustResize"
+ android:fitsSystemWindows="true" />
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/components/LoadingIndicator.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/components/LoadingIndicator.kt
new file mode 100644
index 000000000..96a74235f
--- /dev/null
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/components/LoadingIndicator.kt
@@ -0,0 +1,106 @@
+package net.aliasvault.app.components
+
+import android.animation.ObjectAnimator
+import android.content.Context
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.view.View
+import android.widget.LinearLayout
+import android.widget.TextView
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.delay
+import kotlinx.coroutines.launch
+import net.aliasvault.app.R
+
+/**
+ * LoadingIndicator
+ *
+ * A reusable loading indicator component with animated dots and a customizable message.
+ * Matches the design of the React Native LoadingIndicator component.
+ */
+class LoadingIndicator @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ defStyleAttr: Int = 0,
+) : LinearLayout(context, attrs, defStyleAttr) {
+
+ private val loadingMessage: TextView
+ private val loadingDot1: View
+ private val loadingDot2: View
+ private val loadingDot3: View
+ private val loadingDot4: View
+
+ private var animators: List<ObjectAnimator> = emptyList()
+
+ init {
+ // Inflate the layout
+ LayoutInflater.from(context).inflate(R.layout.loading_indicator, this, true)
+
+ // Initialize views
+ loadingMessage = findViewById(R.id.loadingMessage)
+ loadingDot1 = findViewById(R.id.loadingDot1)
+ loadingDot2 = findViewById(R.id.loadingDot2)
+ loadingDot3 = findViewById(R.id.loadingDot3)
+ loadingDot4 = findViewById(R.id.loadingDot4)
+ }
+
+ /**
+ * Set the loading message text
+ */
+ fun setMessage(message: String) {
+ loadingMessage.text = message
+ }
+
+ /**
+ * Start the pulsing animation on the dots
+ */
+ fun startAnimation() {
+ // Stop any existing animations
+ stopAnimation()
+
+ // Start pulsing animation on dots with staggered delays
+ val newAnimators = mutableListOf<ObjectAnimator>()
+ newAnimators.add(startDotAnimation(loadingDot1, 0))
+ newAnimators.add(startDotAnimation(loadingDot2, 200))
+ newAnimators.add(startDotAnimation(loadingDot3, 400))
+ newAnimators.add(startDotAnimation(loadingDot4, 600))
+
+ animators = newAnimators
+ }
+
+ /**
+ * Stop the pulsing animation
+ */
+ fun stopAnimation() {
+ animators.forEach { it.cancel() }
+ animators = emptyList()
+ }
+
+ /**
+ * Start the pulsing animation on a single dot with a delay
+ */
+ private fun startDotAnimation(dot: View, delayMillis: Long): ObjectAnimator {
+ val animator = ObjectAnimator.ofFloat(dot, "alpha", 0.3f, 1.0f).apply {
+ duration = 700
+ repeatCount = ObjectAnimator.INFINITE
+ repeatMode = ObjectAnimator.REVERSE
+ }
+
+ if (delayMillis > 0) {
+ CoroutineScope(Dispatchers.Main).launch {
+ delay(delayMillis)
+ animator.start()
+ }
+ } else {
+ animator.start()
+ }
+
+ return animator
+ }
+
+ override fun onDetachedFromWindow() {
+ super.onDetachedFromWindow()
+ stopAnimation()
+ }
+}
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.kt
index 094e5f9cd..fbbb9c0de 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/credentialprovider/PasskeyRegistrationActivity.kt
@@ -1,6 +1,5 @@
package net.aliasvault.app.credentialprovider
-import android.animation.ObjectAnimator
import android.app.Activity
import android.content.Intent
import android.os.Bundle
@@ -18,6 +17,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.aliasvault.app.R
+import net.aliasvault.app.components.LoadingIndicator
import net.aliasvault.app.credentialprovider.AliasVaultCredentialProviderService.Companion.EXTRA_CREATE_REQUEST_JSON
import net.aliasvault.app.credentialprovider.AliasVaultCredentialProviderService.Companion.EXTRA_CREATE_RP_ID
import net.aliasvault.app.credentialprovider.AliasVaultCredentialProviderService.Companion.EXTRA_CREATE_USER_DISPLAY_NAME
@@ -61,11 +61,7 @@ class PasskeyRegistrationActivity : Activity() {
private lateinit var cancelButton: MaterialButton
private lateinit var scrollView: View
private lateinit var loadingOverlay: View
- private lateinit var loadingMessage: TextView
- private lateinit var loadingDot1: View
- private lateinit var loadingDot2: View
- private lateinit var loadingDot3: View
- private lateinit var loadingDot4: View
+ private lateinit var loadingIndicator: LoadingIndicator
// Request data
private var providerRequest: ProviderCreateCredentialRequest? = null
@@ -157,11 +153,7 @@ class PasskeyRegistrationActivity : Activity() {
cancelButton = findViewById(R.id.cancelButton)
scrollView = findViewById(R.id.scrollView)
loadingOverlay = findViewById(R.id.loadingOverlay)
- loadingMessage = findViewById(R.id.loadingMessage)
- loadingDot1 = findViewById(R.id.loadingDot1)
- loadingDot2 = findViewById(R.id.loadingDot2)
- loadingDot3 = findViewById(R.id.loadingDot3)
- loadingDot4 = findViewById(R.id.loadingDot4)
+ loadingIndicator = findViewById(R.id.loadingIndicator)
}
private fun populateUI() {
@@ -170,7 +162,6 @@ class PasskeyRegistrationActivity : Activity() {
// Set display name (default to rpId)
displayNameInput.setText(rpId)
- displayNameInput.requestFocus()
// Set website
websiteText.text = rpId
@@ -208,35 +199,20 @@ class PasskeyRegistrationActivity : Activity() {
}
private fun showLoading(message: String) {
- loadingMessage.text = message
+ loadingIndicator.setMessage(message)
+ loadingIndicator.startAnimation()
loadingOverlay.visibility = View.VISIBLE
scrollView.alpha = 0.3f
scrollView.isEnabled = false
-
- // Start pulsing animation on dots
- startDotAnimation(loadingDot1, 0)
- startDotAnimation(loadingDot2, 200)
- startDotAnimation(loadingDot3, 400)
- startDotAnimation(loadingDot4, 600)
}
private fun hideLoading() {
+ loadingIndicator.stopAnimation()
loadingOverlay.visibility = View.GONE
scrollView.alpha = 1.0f
scrollView.isEnabled = true
}
- private fun startDotAnimation(dot: View, delayMillis: Long) {
- CoroutineScope(Dispatchers.Main).launch {
- delay(delayMillis)
- val animator = ObjectAnimator.ofFloat(dot, "alpha", 0.3f, 1.0f)
- animator.duration = 700
- animator.repeatCount = ObjectAnimator.INFINITE
- animator.repeatMode = ObjectAnimator.REVERSE
- animator.start()
- }
- }
-
private fun showError(message: String) {
hideLoading()
errorText.text = message
@@ -252,6 +228,9 @@ class PasskeyRegistrationActivity : Activity() {
showLoading(getString(R.string.passkey_creating))
}
+ // wait for 10 seconds to test interface
+ delay(10000)
+
Log.d(TAG, "Creating passkey for RP: $rpId, user: $userName")
// Extract favicon (optional)
diff --git a/apps/mobile-app/android/app/src/main/res/drawable/loading_container_background.xml b/apps/mobile-app/android/app/src/main/res/drawable/loading_container_background.xml
new file mode 100644
index 000000000..11b724f66
--- /dev/null
+++ b/apps/mobile-app/android/app/src/main/res/drawable/loading_container_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Border -->
+ <item>
+ <shape android:shape="rectangle">
+ <corners android:radius="20dp" />
+ <solid android:color="@color/av_tertiary" />
+ </shape>
+ </item>
+ <!-- Inner background -->
+ <item
+ android:left="5dp"
+ android:right="5dp"
+ android:top="5dp"
+ android:bottom="5dp">
+ <shape android:shape="rectangle">
+ <corners android:radius="16dp" />
+ <solid android:color="@color/av_accent_background" />
+ </shape>
+ </item>
+</layer-list>
diff --git a/apps/mobile-app/android/app/src/main/res/drawable/loading_dot.xml b/apps/mobile-app/android/app/src/main/res/drawable/loading_dot.xml
index cf07da626..0185715ee 100644
--- a/apps/mobile-app/android/app/src/main/res/drawable/loading_dot.xml
+++ b/apps/mobile-app/android/app/src/main/res/drawable/loading_dot.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
- <solid android:color="@color/av_primary" />
+ <solid android:color="@color/av_tertiary" />
</shape>
diff --git a/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration.xml b/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration.xml
index d724b2cb5..7a77670e7 100644
--- a/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration.xml
+++ b/apps/mobile-app/android/app/src/main/res/layout/activity_passkey_registration.xml
@@ -3,20 +3,23 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/av_background">
+ android:background="@color/av_background"
+ android:fitsSystemWindows="true">
<!-- Main content -->
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:fillViewport="true">
+ android:fillViewport="true"
+ android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:padding="24dp">
+ android:padding="24dp"
+ android:paddingBottom="80dp">
<!-- Logo -->
<ImageView
@@ -105,38 +108,34 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
- android:padding="12dp"
- android:background="@drawable/info_row_background"
- android:layout_marginBottom="8dp">
+ android:paddingVertical="8dp"
+ android:layout_marginBottom="4dp">
<ImageView
- android:layout_width="20dp"
- android:layout_height="20dp"
+ android:layout_width="16dp"
+ android:layout_height="16dp"
android:src="@android:drawable/ic_menu_compass"
android:tint="@color/av_icon"
- android:layout_marginEnd="12dp"
+ android:layout_marginEnd="8dp"
android:contentDescription="@string/passkey_website_label" />
- <LinearLayout
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/passkey_website_label"
+ android:textSize="14sp"
+ android:textColor="@color/av_text_muted"
+ android:layout_marginEnd="8dp" />
+
+ <TextView
+ android:id="@+id/websiteText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/passkey_website_label"
- android:textSize="12sp"
- android:textColor="@color/av_text_muted" />
-
- <TextView
- android:id="@+id/websiteText"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="16sp"
- android:textColor="@color/av_text" />
- </LinearLayout>
+ android:textSize="14sp"
+ android:textColor="@color/av_text"
+ android:ellipsize="end"
+ android:maxLines="1" />
</LinearLayout>
<!-- Username (Read-only, optional) -->
@@ -146,39 +145,35 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
- android:padding="12dp"
- android:background="@drawable/info_row_background"
- android:layout_marginBottom="32dp"
+ android:paddingVertical="8dp"
+ android:layout_marginBottom="24dp"
android:visibility="gone">
<ImageView
- android:layout_width="20dp"
- android:layout_height="20dp"
+ android:layout_width="16dp"
+ android:layout_height="16dp"
android:src="@android:drawable/ic_menu_myplaces"
android:tint="@color/av_icon"
- android:layout_marginEnd="12dp"
+ android:layout_marginEnd="8dp"
android:contentDescription="@string/passkey_username_label" />
- <LinearLayout
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/passkey_username_label"
+ android:textSize="14sp"
+ android:textColor="@color/av_text_muted"
+ android:layout_marginEnd="8dp" />
+
+ <TextView
+ android:id="@+id/usernameText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:orientation="vertical">
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/passkey_username_label"
- android:textSize="12sp"
- android:textColor="@color/av_text_muted" />
-
- <TextView
- android:id="@+id/usernameText"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="16sp"
- android:textColor="@color/av_text" />
- </LinearLayout>
+ android:textSize="14sp"
+ android:textColor="@color/av_text"
+ android:ellipsize="end"
+ android:maxLines="1" />
</LinearLayout>
<View
@@ -234,66 +229,10 @@
android:clickable="true"
android:focusable="true">
- <LinearLayout
+ <net.aliasvault.app.components.LoadingIndicator
+ android:id="@+id/loadingIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:orientation="vertical"
- android:gravity="center">
-
- <!-- Loading animation container -->
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/rounded_corner_background"
- android:padding="24dp">
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:gravity="center">
-
- <!-- Four pulsing dots -->
- <View
- android:id="@+id/loadingDot1"
- android:layout_width="10dp"
- android:layout_height="10dp"
- android:layout_margin="6dp"
- android:background="@drawable/loading_dot" />
-
- <View
- android:id="@+id/loadingDot2"
- android:layout_width="10dp"
- android:layout_height="10dp"
- android:layout_margin="6dp"
- android:background="@drawable/loading_dot" />
-
- <View
- android:id="@+id/loadingDot3"
- android:layout_width="10dp"
- android:layout_height="10dp"
- android:layout_margin="6dp"
- android:background="@drawable/loading_dot" />
-
- <View
- android:id="@+id/loadingDot4"
- android:layout_width="10dp"
- android:layout_height="10dp"
- android:layout_margin="6dp"
- android:background="@drawable/loading_dot" />
- </LinearLayout>
- </FrameLayout>
-
- <!-- Loading message -->
- <TextView
- android:id="@+id/loadingMessage"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="20dp"
- android:textColor="@color/av_text"
- android:textSize="16sp"
- android:gravity="center" />
- </LinearLayout>
+ android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
diff --git a/apps/mobile-app/android/app/src/main/res/layout/loading_indicator.xml b/apps/mobile-app/android/app/src/main/res/layout/loading_indicator.xml
new file mode 100644
index 000000000..6f30dd000
--- /dev/null
+++ b/apps/mobile-app/android/app/src/main/res/layout/loading_indicator.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:gravity="center">
+
+ <!-- Loading animation container -->
+ <FrameLayout
+ android:id="@+id/dotsContainer"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:background="@drawable/loading_container_background"
+ android:padding="16dp"
+ android:paddingStart="24dp"
+ android:paddingEnd="24dp"
+ android:elevation="2dp">
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:gravity="center">
+
+ <!-- Four pulsing dots -->
+ <View
+ android:id="@+id/loadingDot1"
+ android:layout_width="8dp"
+ android:layout_height="8dp"
+ android:layout_marginStart="5dp"
+ android:layout_marginEnd="5dp"
+ android:background="@drawable/loading_dot" />
+
+ <View
+ android:id="@+id/loadingDot2"
+ android:layout_width="8dp"
+ android:layout_height="8dp"
+ android:layout_marginStart="5dp"
+ android:layout_marginEnd="5dp"
+ android:background="@drawable/loading_dot" />
+
+ <View
+ android:id="@+id/loadingDot3"
+ android:layout_width="8dp"
+ android:layout_height="8dp"
+ android:layout_marginStart="5dp"
+ android:layout_marginEnd="5dp"
+ android:background="@drawable/loading_dot" />
+
+ <View
+ android:id="@+id/loadingDot4"
+ android:layout_width="8dp"
+ android:layout_height="8dp"
+ android:layout_marginStart="5dp"
+ android:layout_marginEnd="5dp"
+ android:background="@drawable/loading_dot" />
+ </LinearLayout>
+ </FrameLayout>
+
+ <!-- Loading message -->
+ <TextView
+ android:id="@+id/loadingMessage"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="20dp"
+ android:textColor="@color/av_text"
+ android:textSize="16sp"
+ android:gravity="center" />
+</LinearLayout>