π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat(appLock):ui-ux-updations
Aswin Asoke3c0090abe71
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsxindex 44688a8c57..def1d62253 100644--- a/web/apps/photos/src/components/Upload.tsx+++ b/web/apps/photos/src/components/Upload.tsx@@ -60,10 +60,10 @@ import {savePublicCollectionUploaderName,} from "ente-new/albums/services/public-albums-fdb";import { CollectionMappingChoice } from "ente-new/photos/components/CollectionMappingChoice";-import { suppressAutoLockOnBlurForTrustedPrompt } from "ente-new/photos/services/app-lock";import type { CollectionSelectorAttributes } from "ente-new/photos/components/CollectionSelector";import type { RemotePullOpts } from "ente-new/photos/components/gallery";import { downloadAppDialogAttributes } from "ente-new/photos/components/utils/download";+import { suppressAutoLockOnBlurForTrustedPrompt } from "ente-new/photos/services/app-lock";import {createAlbum,createHiddenAlbum,diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.jsonindex bcb0df2ccb..c0023c5f00 100644--- a/web/packages/base/locales/en-US/translation.json+++ b/web/packages/base/locales/en-US/translation.json@@ -845,6 +845,9 @@"app_lock_set_password": "Set app lock password","app_lock_password_mismatch": "App lock passwords don't match","app_lock_incorrect": "Incorrect PIN or app lock password",+ "app_lock_enter_pin_to_unlock": "Enter your app lock pin to unlock",+ "app_lock_pin_digit_label": "PIN digit {{index}}",+ "app_lock_please_try_again_in": "Please try again in","app_lock_set_pin": "Set PIN","device_lock": "Device lock","device_lock_not_supported": "Device lock is not supported on this device",diff --git a/web/packages/new/photos/components/AppLockOverlay.tsx b/web/packages/new/photos/components/AppLockOverlay.tsxindex 0f7d235d99..f857819b65 100644--- a/web/packages/new/photos/components/AppLockOverlay.tsx+++ b/web/packages/new/photos/components/AppLockOverlay.tsx@@ -33,9 +33,9 @@ import React, {useState,} from "react";import {- cancelReauthentication,attemptDeviceLockUnlock,attemptUnlock,+ cancelReauthentication,type DeviceLockUnlockResult,type UnlockResult,} from "../services/app-lock";@@ -120,9 +120,8 @@ export const AppLockOverlay: React.FC = () => {slotProps={{backdrop: {sx: {- backgroundColor: "rgba(0, 0, 0, 0.04)",- backdropFilter: "blur(3px)",- WebkitBackdropFilter: "blur(3px)",+ backgroundColor:+ "var(--mui-palette-backdrop-muted)",},},}}@@ -161,9 +160,12 @@ export const AppLockOverlay: React.FC = () => {aria-label={t("app_lock")}slotProps={{backdrop: {- sx: {- backgroundColor: "#000",- },+ sx: (theme) => ({+ backgroundColor: "secondary.main",+ ...theme.applyStyles("dark", {+ backgroundColor: "#000",+ }),+ }),},}}sx={{ zIndex: "calc(var(--mui-zIndex-tooltip) + 1)" }}@@ -246,9 +248,7 @@ const titleTextSx = (theme: Theme) => ({letterSpacing: "-0.48px",color: "#000",textAlign: "center" as const,- ...theme.applyStyles("dark", {- color: "#fff",- }),+ ...theme.applyStyles("dark", { color: "#fff" }),});const subtitleTextSx = (theme: Theme) => ({@@ -258,9 +258,7 @@ const subtitleTextSx = (theme: Theme) => ({color: "#666",textAlign: "center" as const,maxWidth: 295,- ...theme.applyStyles("dark", {- color: "rgba(255, 255, 255, 0.64)",- }),+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.64)" }),});const primaryActionButtonSx = (theme: Theme) => ({@@ -278,10 +276,7 @@ const primaryActionButtonSx = (theme: Theme) => ({textTransform: "none" as const,color: "#fff",boxShadow: "none",- "&:hover": {- backgroundColor: ENTE_GREEN_HOVER,- boxShadow: "none",- },+ "&:hover": { backgroundColor: ENTE_GREEN_HOVER, boxShadow: "none" },"&.Mui-disabled": {backgroundColor: "rgba(0, 0, 0, 0.04)",color: "#999",@@ -311,23 +306,15 @@ const secondaryActionButtonSx = (theme: Theme) => ({textTransform: "none" as const,color: "#333",boxShadow: "none",- "&:hover": {- backgroundColor: "#E8E8E8",- boxShadow: "none",- },+ "&:hover": { backgroundColor: "#E8E8E8", boxShadow: "none" },...theme.applyStyles("dark", {backgroundColor: "rgba(255, 255, 255, 0.08)",color: "rgba(255, 255, 255, 0.9)",- "&:hover": {- backgroundColor: "rgba(255, 255, 255, 0.12)",- },+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.12)" },}),});-const inputFieldSx = (- theme: Theme,- options?: { borderRadius?: number },-) => ({+const inputFieldSx = (theme: Theme, options?: { borderRadius?: number }) => ({borderRadius: options?.borderRadius ?? 12,"& .MuiInputBase-root": {// Enforce shape/height at InputBase level so variant-specific styles@@ -340,13 +327,9 @@ const inputFieldSx = (height: 54,backgroundColor: "#FAFAFA",borderRadius: `${String(options?.borderRadius ?? 12)}px !important`,- "&::before": {- borderBottom: "1px solid #E0E0E0",- },+ "&::before": { borderBottom: "1px solid #E0E0E0" },"&::after": { borderBottom: `2px solid ${ENTE_GREEN}` },- "&.Mui-error::after": {- borderBottomColor: theme.palette.error.main,- },+ "&.Mui-error::after": { borderBottomColor: theme.palette.error.main },"&:hover:not(.Mui-disabled)::before": {borderBottom: "1px solid #BDBDBD",},@@ -357,17 +340,12 @@ const inputFieldSx = (boxSizing: "border-box" as const,fontSize: 16,color: "#000",- "&::placeholder": {- color: "#999",- opacity: 1,- },+ "&::placeholder": { color: "#999", opacity: 1 },},...theme.applyStyles("dark", {"& .MuiInput-root": {backgroundColor: "rgba(255, 255, 255, 0.08)",- "&::before": {- borderBottom: "1px solid rgba(255, 255, 255, 0.3)",- },+ "&::before": { borderBottom: "1px solid rgba(255, 255, 255, 0.3)" },"&:hover:not(.Mui-disabled)::before": {borderBottom: "1px solid rgba(255, 255, 255, 0.5)",},@@ -377,9 +355,7 @@ const inputFieldSx = (},"& .MuiInputBase-input": {color: "#fff",- "&::placeholder": {- color: "rgba(255, 255, 255, 0.5)",- },+ "&::placeholder": { color: "rgba(255, 255, 255, 0.5)" },},}),});@@ -411,11 +387,7 @@ const LockIllustration: React.FC = () => (width: 148,maxWidth: "100%",lineHeight: 0,- "& svg": {- display: "block",- width: "100%",- height: "auto",- },+ "& svg": { display: "block", width: "100%", height: "auto" },}}dangerouslySetInnerHTML={{ __html: LOCK_ILLUSTRATION_SVG }}/>@@ -688,9 +660,7 @@ const PinUnlockForm: React.FC<UnlockFormProps> = ({display: "flex",justifyContent: "center",width: "100%",- "& > *": {- transform: "translateY(-4px)",- },+ "& > *": { transform: "translateY(-4px)" },}}><LockIllustration />@@ -707,10 +677,12 @@ const PinUnlockForm: React.FC<UnlockFormProps> = ({}}><Typography sx={titleTextSx}>- {isReauthentication ? t("authenticate") : t("app_locked")}+ {isReauthentication+ ? t("authenticate")+ : t("app_locked")}</Typography><Typography sx={subtitleTextSx}>- Enter your app lock pin to unlock+ {t("app_lock_enter_pin_to_unlock")}</Typography></Box>@@ -745,7 +717,10 @@ const PinUnlockForm: React.FC<UnlockFormProps> = ({textAlign: "center",WebkitTextSecurity: "disc",},- "aria-label": `PIN digit ${String(i + 1)}`,+ "aria-label": t(+ "app_lock_pin_digit_label",+ { index: i + 1 },+ ),},}}sx={(theme) => ({@@ -770,10 +745,7 @@ const PinUnlockForm: React.FC<UnlockFormProps> = ({onClick={() => {void handleSubmit();}}- sx={(theme) => ({- ...primaryActionButtonSx(theme),- mt: 2,- })}+ sx={(theme) => ({ ...primaryActionButtonSx(theme), mt: 2 })}>{loading ? (<CircularProgress size={18} color="inherit" />@@ -862,9 +834,7 @@ const PasswordUnlockForm: React.FC<UnlockFormProps> = ({display: "flex",justifyContent: "center",width: "100%",- "& > *": {- transform: "translateY(-4px)",- },+ "& > *": { transform: "translateY(-4px)" },}}><LockIllustration />@@ -926,10 +896,7 @@ const PasswordUnlockForm: React.FC<UnlockFormProps> = ({fullWidthcolor="accent"disabled={!password || loading}- sx={(theme) => ({- ...primaryActionButtonSx(theme),- mt: 2,- })}+ sx={(theme) => ({ ...primaryActionButtonSx(theme), mt: 2 })}>{isReauthentication ? t("authenticate") : t("unlock")}</FocusVisibleButton>@@ -987,9 +954,7 @@ const DeviceLockUnlockForm: React.FC<{display: "flex",justifyContent: "center",width: "100%",- "& > *": {- transform: "translateY(-4px)",- },+ "& > *": { transform: "translateY(-4px)" },}}><LockIllustration />@@ -1006,7 +971,9 @@ const DeviceLockUnlockForm: React.FC<{}}><Typography sx={titleTextSx}>- {isReauthentication ? t("authenticate") : t("app_locked")}+ {isReauthentication+ ? t("authenticate")+ : t("app_locked")}</Typography><Typography sx={subtitleTextSx}>{t("device_lock_login_instructions")}@@ -1023,9 +990,7 @@ const DeviceLockUnlockForm: React.FC<{sx={(theme) => ({...primaryActionButtonSx(theme),backgroundColor: ENTE_GREEN,- "&:hover": {- backgroundColor: ENTE_GREEN_HOVER,- },+ "&:hover": { backgroundColor: ENTE_GREEN_HOVER },fontWeight: 600,mt: 2,})}@@ -1172,9 +1137,7 @@ const CooldownScreen: React.FC<CooldownScreenProps> = ({display: "flex",justifyContent: "center",width: "100%",- "& > *": {- transform: "translateY(-4px)",- },+ "& > *": { transform: "translateY(-4px)" },}}><LockIllustration />@@ -1191,7 +1154,9 @@ const CooldownScreen: React.FC<CooldownScreenProps> = ({}}><Typography sx={titleTextSx}>{t("app_locked")}</Typography>- <Typography sx={subtitleTextSx}>Please try again in</Typography>+ <Typography sx={subtitleTextSx}>+ {t("app_lock_please_try_again_in")}+ </Typography></Box><Typographydiff --git a/web/packages/new/photos/services/app-lock.ts b/web/packages/new/photos/services/app-lock.tsindex 04829dc60b..791284a3d5 100644--- a/web/packages/new/photos/services/app-lock.ts+++ b/web/packages/new/photos/services/app-lock.ts@@ -891,42 +891,47 @@ export type ReauthenticateWithAppLockResult =export const reauthenticateWithAppLock =async (): Promise<ReauthenticateWithAppLockResult> => {- try {- _wasReauthenticationCancelled = false;- const snapshot = appLockSnapshot();- let canUseAppLock = snapshot.enabled && snapshot.lockType !== "none";- if (canUseAppLock && snapshot.lockType === "device") {- // For device lock, ensure native auth is actually usable right now.- // If unavailable (e.g. Touch ID disabled), fall back to password flow.- const capability = await resolveDeviceLockCapability();- canUseAppLock = capability.usable;- }- if (!canUseAppLock) return "fallback";-- return await new Promise<ReauthenticateWithAppLockResult>((resolve) => {- const unsubscribe = appLockSubscribe(() => {- if (!appLockSnapshot().isLocked) {- unsubscribe();- const wasAuthenticated =- !_wasReauthenticationCancelled;- _wasReauthenticationCancelled = false;- resolve(- wasAuthenticated ? "authenticated" : "cancelled",- );- }- });-- lock("reauthenticate");- if (!appLockSnapshot().isLocked) {- unsubscribe();- resolve("fallback");+ try {+ _wasReauthenticationCancelled = false;+ const snapshot = appLockSnapshot();+ let canUseAppLock =+ snapshot.enabled && snapshot.lockType !== "none";+ if (canUseAppLock && snapshot.lockType === "device") {+ // For device lock, ensure native auth is actually usable right now.+ // If unavailable (e.g. Touch ID disabled), fall back to password flow.+ const capability = await resolveDeviceLockCapability();+ canUseAppLock = capability.usable;}- });- } catch (e) {- log.error("Failed to start app lock reauthentication", e);- return "fallback";- }-};+ if (!canUseAppLock) return "fallback";++ return await new Promise<ReauthenticateWithAppLockResult>(+ (resolve) => {+ const unsubscribe = appLockSubscribe(() => {+ if (!appLockSnapshot().isLocked) {+ unsubscribe();+ const wasAuthenticated =+ !_wasReauthenticationCancelled;+ _wasReauthenticationCancelled = false;+ resolve(+ wasAuthenticated+ ? "authenticated"+ : "cancelled",+ );+ }+ });++ lock("reauthenticate");+ if (!appLockSnapshot().isLocked) {+ unsubscribe();+ resolve("fallback");+ }+ },+ );+ } catch (e) {+ log.error("Failed to start app lock reauthentication", e);+ return "fallback";+ }+ };/*** Lock the app.