Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] enable deep linking for unconfigured home screen widgets

r4khul4f9af32b55d2
diff --git a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteAlbumsWidgetProvider.kt b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteAlbumsWidgetProvider.kt
index f4f2c154f9..b2a8691eef 100644
--- a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteAlbumsWidgetProvider.kt
+++ b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteAlbumsWidgetProvider.kt
@@ -124,6 +124,10 @@ class EnteAlbumsWidgetProvider : HomeWidgetProvider() {
R.id.widget_placeholder,
View.GONE
)
+ setViewVisibility(
+ R.id.widget_placeholder_title,
+ View.GONE
+ )
setViewVisibility(
R.id.widget_placeholder_text,
View.GONE
@@ -143,10 +147,15 @@ class EnteAlbumsWidgetProvider : HomeWidgetProvider() {
)
} else {
// Open App on Widget Click
+ val deepLinkUri =
+ Uri.parse(
+ "albumwidget://configure?homeWidget"
+ )
val pendingIntent =
HomeWidgetLaunchIntent.getActivity(
context,
- MainActivity::class.java
+ MainActivity::class.java,
+ deepLinkUri
)
setOnClickPendingIntent(
R.id.widget_container,
@@ -173,14 +182,18 @@ class EnteAlbumsWidgetProvider : HomeWidgetProvider() {
R.id.widget_overlay,
View.GONE
)
- setViewVisibility(
- R.id.widget_placeholder,
- View.VISIBLE
- )
- setViewVisibility(
- R.id.widget_placeholder_text,
- View.VISIBLE
- )
+ setViewVisibility(
+ R.id.widget_placeholder,
+ View.VISIBLE
+ )
+ setViewVisibility(
+ R.id.widget_placeholder_title,
+ View.VISIBLE
+ )
+ setViewVisibility(
+ R.id.widget_placeholder_text,
+ View.VISIBLE
+ )
setViewVisibility(
R.id.widget_placeholder_container,
View.VISIBLE
diff --git a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteMemoryWidgetProvider.kt b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteMemoryWidgetProvider.kt
index 70b68f22af..5703404839 100644
--- a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteMemoryWidgetProvider.kt
+++ b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EnteMemoryWidgetProvider.kt
@@ -117,6 +117,10 @@ class EnteMemoryWidgetProvider : HomeWidgetProvider() {
R.id.widget_placeholder,
View.GONE
)
+ setViewVisibility(
+ R.id.widget_placeholder_title,
+ View.GONE
+ )
setViewVisibility(
R.id.widget_placeholder_text,
View.GONE
@@ -136,10 +140,15 @@ class EnteMemoryWidgetProvider : HomeWidgetProvider() {
)
} else {
// Open App on Widget Click
+ val deepLinkUri =
+ Uri.parse(
+ "memorywidget://configure?homeWidget"
+ )
val pendingIntent =
HomeWidgetLaunchIntent.getActivity(
context,
- MainActivity::class.java
+ MainActivity::class.java,
+ deepLinkUri
)
setOnClickPendingIntent(
R.id.widget_container,
@@ -170,6 +179,10 @@ class EnteMemoryWidgetProvider : HomeWidgetProvider() {
R.id.widget_placeholder,
View.VISIBLE
)
+ setViewVisibility(
+ R.id.widget_placeholder_title,
+ View.VISIBLE
+ )
setViewVisibility(
R.id.widget_placeholder_text,
View.VISIBLE
diff --git a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EntePeopleWidgetProvider.kt b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EntePeopleWidgetProvider.kt
index 55a3e714e8..488df04b07 100644
--- a/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EntePeopleWidgetProvider.kt
+++ b/mobile/apps/photos/android/app/src/main/kotlin/io/ente/photos/EntePeopleWidgetProvider.kt
@@ -123,6 +123,10 @@ class EntePeopleWidgetProvider : HomeWidgetProvider() {
R.id.widget_placeholder,
View.GONE
)
+ setViewVisibility(
+ R.id.widget_placeholder_title,
+ View.GONE
+ )
setViewVisibility(
R.id.widget_placeholder_text,
View.GONE
@@ -142,10 +146,15 @@ class EntePeopleWidgetProvider : HomeWidgetProvider() {
)
} else {
// Open App on Widget Click
+ val deepLinkUri =
+ Uri.parse(
+ "peoplewidget://configure?homeWidget"
+ )
val pendingIntent =
HomeWidgetLaunchIntent.getActivity(
context,
- MainActivity::class.java
+ MainActivity::class.java,
+ deepLinkUri
)
setOnClickPendingIntent(
R.id.widget_container,
@@ -176,6 +185,10 @@ class EntePeopleWidgetProvider : HomeWidgetProvider() {
R.id.widget_placeholder,
View.VISIBLE
)
+ setViewVisibility(
+ R.id.widget_placeholder_title,
+ View.VISIBLE
+ )
setViewVisibility(
R.id.widget_placeholder_text,
View.VISIBLE
diff --git a/mobile/apps/photos/android/app/src/main/res/layout/albums_widget_layout.xml b/mobile/apps/photos/android/app/src/main/res/layout/albums_widget_layout.xml
index c703bd5ac4..62ca6410cf 100644
--- a/mobile/apps/photos/android/app/src/main/res/layout/albums_widget_layout.xml
+++ b/mobile/apps/photos/android/app/src/main/res/layout/albums_widget_layout.xml
@@ -68,17 +68,30 @@
android:src="@drawable/ic_albums_widget"
android:scaleType="fitCenter" />
+ <TextView
+ android:id="@+id/widget_placeholder_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Albums"
+ android:textSize="14sp"
+ android:textStyle="bold"
+ android:gravity="center_horizontal"
+ android:textColor="@color/widget_text_color"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"
+ android:layout_marginTop="8dp"/>
+
<TextView
android:id="@+id/widget_placeholder_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Go to Settings -> Widgets to customise the widget"
+ android:text="Click to customise"
android:textSize="12sp"
android:gravity="center_horizontal"
android:textColor="@color/widget_text_color"
android:paddingStart="8dp"
android:paddingEnd="8dp"
- android:layout_marginTop="12dp"/>
+ android:layout_marginTop="2dp"/>
</LinearLayout>
</FrameLayout>
diff --git a/mobile/apps/photos/android/app/src/main/res/layout/memory_widget_layout.xml b/mobile/apps/photos/android/app/src/main/res/layout/memory_widget_layout.xml
index 981ffab566..47ef2d9fb2 100644
--- a/mobile/apps/photos/android/app/src/main/res/layout/memory_widget_layout.xml
+++ b/mobile/apps/photos/android/app/src/main/res/layout/memory_widget_layout.xml
@@ -68,17 +68,30 @@
android:src="@drawable/ic_memories_widget"
android:scaleType="fitCenter" />
+ <TextView
+ android:id="@+id/widget_placeholder_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Memories"
+ android:textSize="14sp"
+ android:textStyle="bold"
+ android:gravity="center_horizontal"
+ android:textColor="@color/widget_text_color"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"
+ android:layout_marginTop="8dp"/>
+
<TextView
android:id="@+id/widget_placeholder_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Go to Settings -> Widgets to customise the widget"
+ android:text="Click to customise"
android:textSize="12sp"
android:gravity="center_horizontal"
android:textColor="@color/widget_text_color"
android:paddingStart="8dp"
android:paddingEnd="8dp"
- android:layout_marginTop="12dp"/>
+ android:layout_marginTop="2dp"/>
</LinearLayout>
</FrameLayout>
diff --git a/mobile/apps/photos/android/app/src/main/res/layout/people_widget_layout.xml b/mobile/apps/photos/android/app/src/main/res/layout/people_widget_layout.xml
index d800561060..812f147f35 100644
--- a/mobile/apps/photos/android/app/src/main/res/layout/people_widget_layout.xml
+++ b/mobile/apps/photos/android/app/src/main/res/layout/people_widget_layout.xml
@@ -68,17 +68,30 @@
android:src="@drawable/ic_people_widget"
android:scaleType="fitCenter" />
+ <TextView
+ android:id="@+id/widget_placeholder_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="People"
+ android:textSize="14sp"
+ android:textStyle="bold"
+ android:gravity="center_horizontal"
+ android:textColor="@color/widget_text_color"
+ android:paddingStart="8dp"
+ android:paddingEnd="8dp"
+ android:layout_marginTop="8dp"/>
+
<TextView
android:id="@+id/widget_placeholder_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Go to Settings -> Widgets to customise the widget"
+ android:text="Click to customise"
android:textSize="12sp"
android:gravity="center_horizontal"
android:textColor="@color/widget_text_color"
android:paddingStart="8dp"
android:paddingEnd="8dp"
- android:layout_marginTop="12dp"/>
+ android:layout_marginTop="2dp"/>
</LinearLayout>
</FrameLayout>
diff --git a/mobile/apps/photos/ios/EnteAlbumWidget/EnteAlbumWidget.swift b/mobile/apps/photos/ios/EnteAlbumWidget/EnteAlbumWidget.swift
index 46eab1d8df..d3d60da4c9 100644
--- a/mobile/apps/photos/ios/EnteAlbumWidget/EnteAlbumWidget.swift
+++ b/mobile/apps/photos/ios/EnteAlbumWidget/EnteAlbumWidget.swift
@@ -198,7 +198,7 @@ struct EnteAlbumWidgetEntryView: View {
)
}
} else if let uiImage = UIImage(named: "AlbumsWidgetDefault") {
- VStack(spacing: 8) {
+ VStack(spacing: 4) {
Spacer()
Image(uiImage: uiImage)
.resizable()
@@ -206,8 +206,15 @@ struct EnteAlbumWidgetEntryView: View {
.aspectRatio(contentMode: .fit)
.padding(8)
- Text("Go to Settings -> Widgets to customise the widget")
- .font(.custom("Inter", size: 12, relativeTo: .caption))
+ Text("Albums")
+ .font(.custom("Inter", size: 14, relativeTo: .caption))
+ .bold()
+ .foregroundStyle(.white)
+ .multilineTextAlignment(.center)
+ .backwardWidgetAccentable(true)
+
+ Text("Click to customise")
+ .font(.custom("Inter", size: 12, relativeTo: .caption2))
.foregroundStyle(.white) // Tint-aware color
.multilineTextAlignment(.center)
.padding(.bottom, 12)
@@ -224,8 +231,9 @@ struct EnteAlbumWidgetEntryView: View {
.edgesIgnoringSafeArea(.all)
.widgetURL(
URL(
- string:
- "albumwidget://message?generatedId=\(entry.generatedId != nil ? String(entry.generatedId!) : "nan")&mainKey=\(entry.mainKey != nil ? entry.mainKey! : "nan")&homeWidget"
+ string: entry.generatedId != nil
+ ? "albumwidget://message?generatedId=\(entry.generatedId!)&mainKey=\(entry.mainKey ?? "")&homeWidget"
+ : "albumwidget://configure?homeWidget"
)
)
}
diff --git a/mobile/apps/photos/ios/EnteMemoryWidget/EnteMemoryWidget.swift b/mobile/apps/photos/ios/EnteMemoryWidget/EnteMemoryWidget.swift
index cb350506ad..0c4fe860b2 100644
--- a/mobile/apps/photos/ios/EnteMemoryWidget/EnteMemoryWidget.swift
+++ b/mobile/apps/photos/ios/EnteMemoryWidget/EnteMemoryWidget.swift
@@ -195,7 +195,7 @@ struct EnteMemoryWidgetEntryView: View {
)
}
} else if let uiImage = UIImage(named: "MemoriesWidgetDefault") {
- VStack(spacing: 8) {
+ VStack(spacing: 4) {
Spacer()
Image(uiImage: uiImage)
.resizable()
@@ -203,8 +203,15 @@ struct EnteMemoryWidgetEntryView: View {
.aspectRatio(contentMode: .fit)
.padding(8)
- Text("Go to Settings -> Widgets to customise the widget")
- .font(.custom("Inter", size: 12, relativeTo: .caption))
+ Text("Memories")
+ .font(.custom("Inter", size: 14, relativeTo: .caption))
+ .bold()
+ .foregroundStyle(.white)
+ .multilineTextAlignment(.center)
+ .backwardWidgetAccentable(true)
+
+ Text("Click to customise")
+ .font(.custom("Inter", size: 12, relativeTo: .caption2))
.foregroundStyle(.white) // Tint-aware color
.multilineTextAlignment(.center)
.padding(.bottom, 12)
@@ -221,8 +228,9 @@ struct EnteMemoryWidgetEntryView: View {
.edgesIgnoringSafeArea(.all)
.widgetURL(
URL(
- string:
- "memorywidget://message?generatedId=\(entry.generatedId != nil ? String(entry.generatedId!) : "nan")&homeWidget"
+ string: entry.generatedId != nil
+ ? "memorywidget://message?generatedId=\(entry.generatedId!)&homeWidget"
+ : "memorywidget://configure?homeWidget"
)
)
}
diff --git a/mobile/apps/photos/ios/EntePeopleWidget/EntePeopleWidget.swift b/mobile/apps/photos/ios/EntePeopleWidget/EntePeopleWidget.swift
index 1ad9ee656a..653e43c3d5 100644
--- a/mobile/apps/photos/ios/EntePeopleWidget/EntePeopleWidget.swift
+++ b/mobile/apps/photos/ios/EntePeopleWidget/EntePeopleWidget.swift
@@ -198,7 +198,7 @@ struct EntePeopleWidgetEntryView: View {
)
}
} else if let uiImage = UIImage(named: "PeopleWidgetDefault") {
- VStack(spacing: 8) {
+ VStack(spacing: 4) {
Spacer()
Image(uiImage: uiImage)
.resizable()
@@ -206,8 +206,15 @@ struct EntePeopleWidgetEntryView: View {
.aspectRatio(contentMode: .fit)
.padding(8)
- Text("Go to Settings -> Widgets to customise the widget")
- .font(.custom("Inter", size: 12, relativeTo: .caption))
+ Text("People")
+ .font(.custom("Inter", size: 14, relativeTo: .caption))
+ .bold()
+ .foregroundStyle(.white)
+ .multilineTextAlignment(.center)
+ .backwardWidgetAccentable(true)
+
+ Text("Click to customise")
+ .font(.custom("Inter", size: 12, relativeTo: .caption2))
.foregroundStyle(.white) // Tint-aware color
.multilineTextAlignment(.center)
.padding(.bottom, 12)
@@ -224,8 +231,9 @@ struct EntePeopleWidgetEntryView: View {
.edgesIgnoringSafeArea(.all)
.widgetURL(
URL(
- string:
- "peoplewidget://message?generatedId=\(entry.generatedId != nil ? String(entry.generatedId!) : "nan")&mainKey=\(entry.mainKey != nil ? entry.mainKey! : "nan")&homeWidget"
+ string: entry.generatedId != nil
+ ? "peoplewidget://message?generatedId=\(entry.generatedId!)&mainKey=\(entry.mainKey ?? "")&homeWidget"
+ : "peoplewidget://configure?homeWidget"
)
)
}
diff --git a/mobile/apps/photos/ios/Runner/AppDelegate.swift b/mobile/apps/photos/ios/Runner/AppDelegate.swift
index 06bc852fc1..127377541f 100644
--- a/mobile/apps/photos/ios/Runner/AppDelegate.swift
+++ b/mobile/apps/photos/ios/Runner/AppDelegate.swift
@@ -44,7 +44,7 @@ import workmanager_apple
// Retrieve the link from parameters
if let url = AppLinks.shared.getLink(launchOptions: launchOptions) {
// only accept non-homewidget urls for AppLinks
- if !url.absoluteString.contains("&homeWidget") {
+ if !url.absoluteString.contains("homeWidget") {
AppLinks.shared.handleLink(url: url)
// link is handled, stop propagation
return true
diff --git a/mobile/apps/photos/lib/services/home_widget_service.dart b/mobile/apps/photos/lib/services/home_widget_service.dart
index ac29910eff..5acb7ba2db 100644
--- a/mobile/apps/photos/lib/services/home_widget_service.dart
+++ b/mobile/apps/photos/lib/services/home_widget_service.dart
@@ -9,10 +9,16 @@ import 'package:path_provider_foundation/path_provider_foundation.dart';
import 'package:photos/core/constants.dart';
import 'package:photos/models/file/file.dart';
import 'package:photos/module/download/thumbnail.dart';
+import 'package:photos/service_locator.dart';
import 'package:photos/services/album_home_widget_service.dart';
+import 'package:photos/services/app_navigation_service.dart';
import 'package:photos/services/memory_home_widget_service.dart';
import 'package:photos/services/people_home_widget_service.dart';
import 'package:photos/services/smart_memories_service.dart';
+import 'package:photos/ui/settings/ml/machine_learning_settings_page.dart';
+import 'package:photos/ui/settings/widgets/albums_widget_settings.dart';
+import 'package:photos/ui/settings/widgets/memories_widget_settings.dart';
+import 'package:photos/ui/settings/widgets/people_widget_settings.dart';
import 'package:synchronized/synchronized.dart';
enum WidgetStatus {
@@ -253,43 +259,74 @@ class HomeWidgetService {
return;
}
+ _logger.info("Handling widget launch with URI: $uri");
+
final generatedId = int.tryParse(
uri.queryParameters[GENERATED_ID_PARAM] ?? "",
);
- if (generatedId == null) {
- _logger.warning("Widget launch failed: Invalid or missing generated ID");
- return;
- }
+
+ final bool isConfigureRoute =
+ uri.host == 'configure' || generatedId == null;
// Route to appropriate handler based on widget scheme
switch (uri.scheme) {
case MEMORY_WIDGET_SCHEME:
- await MemoryHomeWidgetService.instance.onLaunchFromWidget(generatedId);
+ if (isConfigureRoute) {
+ _logger.info("Navigating to Memories widget customization screen");
+ await AppNavigationService.instance.pushPage(
+ const MemoriesWidgetSettings(),
+ );
+ } else {
+ await MemoryHomeWidgetService.instance.onLaunchFromWidget(
+ generatedId,
+ );
+ }
break;
case PEOPLE_WIDGET_SCHEME:
- final personId = uri.queryParameters[MAIN_KEY_PARAM] ?? "";
- await PeopleHomeWidgetService.instance.onLaunchFromWidget(
- generatedId,
- personId,
- );
+ if (isConfigureRoute) {
+ _logger.info("Navigating to People widget customization screen");
+ if (!hasGrantedMLConsent) {
+ await AppNavigationService.instance.pushPage(
+ const MachineLearningSettingsPage(),
+ forceCustomPageRoute: true,
+ );
+ } else {
+ await AppNavigationService.instance.pushPage(
+ const PeopleWidgetSettings(),
+ );
+ }
+ } else {
+ final personId = uri.queryParameters[MAIN_KEY_PARAM] ?? "";
+ await PeopleHomeWidgetService.instance.onLaunchFromWidget(
+ generatedId,
+ personId,
+ );
+ }
break;
case ALBUM_WIDGET_SCHEME:
- final collectionId = int.tryParse(
- uri.queryParameters[MAIN_KEY_PARAM] ?? "",
- );
- if (collectionId == null) {
- _logger.warning(
- "Album widget launch failed: Invalid or missing collection ID",
+ if (isConfigureRoute) {
+ _logger.info("Navigating to Album widget customization screen");
+ await AppNavigationService.instance.pushPage(
+ const AlbumsWidgetSettings(),
+ );
+ } else {
+ final collectionId = int.tryParse(
+ uri.queryParameters[MAIN_KEY_PARAM] ?? "",
+ );
+ if (collectionId == null) {
+ _logger.warning(
+ "Album widget launch failed: Invalid or missing collection ID",
+ );
+ return;
+ }
+
+ await AlbumHomeWidgetService.instance.onLaunchFromWidget(
+ generatedId,
+ collectionId,
);
- return;
}
-
- await AlbumHomeWidgetService.instance.onLaunchFromWidget(
- generatedId,
- collectionId,
- );
break;
default: