fix(widget): Update widget URL scheme from homewidget to conduit
This commit is contained in:
@@ -57,7 +57,7 @@ class ConduitWidgetProvider : AppWidgetProvider() {
|
|||||||
HomeWidgetLaunchIntent.getActivity(
|
HomeWidgetLaunchIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
MainActivity::class.java,
|
MainActivity::class.java,
|
||||||
Uri.parse("homewidget://$ACTION_NEW_CHAT")
|
Uri.parse("conduit://$ACTION_NEW_CHAT")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
views.setOnClickPendingIntent(
|
views.setOnClickPendingIntent(
|
||||||
@@ -65,7 +65,7 @@ class ConduitWidgetProvider : AppWidgetProvider() {
|
|||||||
HomeWidgetLaunchIntent.getActivity(
|
HomeWidgetLaunchIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
MainActivity::class.java,
|
MainActivity::class.java,
|
||||||
Uri.parse("homewidget://$ACTION_NEW_CHAT")
|
Uri.parse("conduit://$ACTION_NEW_CHAT")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
views.setOnClickPendingIntent(
|
views.setOnClickPendingIntent(
|
||||||
@@ -73,7 +73,7 @@ class ConduitWidgetProvider : AppWidgetProvider() {
|
|||||||
HomeWidgetLaunchIntent.getActivity(
|
HomeWidgetLaunchIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
MainActivity::class.java,
|
MainActivity::class.java,
|
||||||
Uri.parse("homewidget://$ACTION_MIC")
|
Uri.parse("conduit://$ACTION_MIC")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
views.setOnClickPendingIntent(
|
views.setOnClickPendingIntent(
|
||||||
@@ -81,7 +81,7 @@ class ConduitWidgetProvider : AppWidgetProvider() {
|
|||||||
HomeWidgetLaunchIntent.getActivity(
|
HomeWidgetLaunchIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
MainActivity::class.java,
|
MainActivity::class.java,
|
||||||
Uri.parse("homewidget://$ACTION_CAMERA")
|
Uri.parse("conduit://$ACTION_CAMERA")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
views.setOnClickPendingIntent(
|
views.setOnClickPendingIntent(
|
||||||
@@ -89,7 +89,7 @@ class ConduitWidgetProvider : AppWidgetProvider() {
|
|||||||
HomeWidgetLaunchIntent.getActivity(
|
HomeWidgetLaunchIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
MainActivity::class.java,
|
MainActivity::class.java,
|
||||||
Uri.parse("homewidget://$ACTION_PHOTOS")
|
Uri.parse("conduit://$ACTION_PHOTOS")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
views.setOnClickPendingIntent(
|
views.setOnClickPendingIntent(
|
||||||
@@ -97,7 +97,7 @@ class ConduitWidgetProvider : AppWidgetProvider() {
|
|||||||
HomeWidgetLaunchIntent.getActivity(
|
HomeWidgetLaunchIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
MainActivity::class.java,
|
MainActivity::class.java,
|
||||||
Uri.parse("homewidget://$ACTION_CLIPBOARD")
|
Uri.parse("conduit://$ACTION_CLIPBOARD")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ struct ConduitWidgetEntryView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 12) {
|
VStack(spacing: 12) {
|
||||||
// Main "Ask Conduit" pill - ChatGPT style
|
// Main "Ask Conduit" pill - ChatGPT style
|
||||||
Link(destination: URL(string: "homewidget://new_chat")!) {
|
Link(destination: URL(string: "conduit://new_chat")!) {
|
||||||
HStack(spacing: 12) {
|
HStack(spacing: 12) {
|
||||||
Image("HubIcon")
|
Image("HubIcon")
|
||||||
.renderingMode(.template)
|
.renderingMode(.template)
|
||||||
@@ -82,25 +82,25 @@ struct ConduitWidgetEntryView: View {
|
|||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
CircularIconButton(
|
CircularIconButton(
|
||||||
symbol: "camera",
|
symbol: "camera",
|
||||||
url: "homewidget://camera",
|
url: "conduit://camera",
|
||||||
contentColor: contentColor,
|
contentColor: contentColor,
|
||||||
buttonBackground: buttonBackground
|
buttonBackground: buttonBackground
|
||||||
)
|
)
|
||||||
CircularIconButton(
|
CircularIconButton(
|
||||||
symbol: "photo.on.rectangle.angled",
|
symbol: "photo.on.rectangle.angled",
|
||||||
url: "homewidget://photos",
|
url: "conduit://photos",
|
||||||
contentColor: contentColor,
|
contentColor: contentColor,
|
||||||
buttonBackground: buttonBackground
|
buttonBackground: buttonBackground
|
||||||
)
|
)
|
||||||
CircularIconButton(
|
CircularIconButton(
|
||||||
symbol: "waveform",
|
symbol: "waveform",
|
||||||
url: "homewidget://mic",
|
url: "conduit://mic",
|
||||||
contentColor: contentColor,
|
contentColor: contentColor,
|
||||||
buttonBackground: buttonBackground
|
buttonBackground: buttonBackground
|
||||||
)
|
)
|
||||||
CircularIconButton(
|
CircularIconButton(
|
||||||
symbol: "doc.on.clipboard",
|
symbol: "doc.on.clipboard",
|
||||||
url: "homewidget://clipboard",
|
url: "conduit://clipboard",
|
||||||
contentColor: contentColor,
|
contentColor: contentColor,
|
||||||
buttonBackground: buttonBackground
|
buttonBackground: buttonBackground
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,6 +45,16 @@
|
|||||||
<string>ShareMedia-app.cogwheel.conduit</string>
|
<string>ShareMedia-app.cogwheel.conduit</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLName</key>
|
||||||
|
<string>app.cogwheel.conduit.widget</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>conduit</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
<string>$(FLUTTER_BUILD_NUMBER)</string>
|
||||||
|
|||||||
@@ -106,19 +106,53 @@ class HomeWidgetCoordinator extends _$HomeWidgetCoordinator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process initial widget action after ensuring router is ready.
|
/// Process initial widget action after ensuring router and auth are ready.
|
||||||
Future<void> _processInitialWidgetAction() async {
|
Future<void> _processInitialWidgetAction() async {
|
||||||
if (_pendingWidgetAction == null) return;
|
if (_pendingWidgetAction == null) return;
|
||||||
|
|
||||||
// Wait for router to be attached and app to be ready
|
// Wait for router to be attached first
|
||||||
for (var i = 0; i < 50; i++) {
|
for (var i = 0; i < 50; i++) {
|
||||||
// Try for up to 5 seconds
|
// Try for up to 5 seconds
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 100));
|
await Future<void>.delayed(const Duration(milliseconds: 100));
|
||||||
|
|
||||||
// Check if router is available
|
|
||||||
if (NavigationService.currentRoute != null) {
|
if (NavigationService.currentRoute != null) {
|
||||||
DebugLogger.log(
|
DebugLogger.log(
|
||||||
'Widget: Router ready, processing pending action',
|
'Widget: Router ready, waiting for authentication',
|
||||||
|
scope: 'widget',
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NavigationService.currentRoute == null) {
|
||||||
|
DebugLogger.log(
|
||||||
|
'Widget: Timeout waiting for router, clearing pending action',
|
||||||
|
scope: 'widget',
|
||||||
|
);
|
||||||
|
_pendingWidgetAction = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if action was already processed by stream handler while waiting
|
||||||
|
if (_pendingWidgetAction == null) return;
|
||||||
|
|
||||||
|
// Now wait for authentication to complete (up to 30 seconds for login flow)
|
||||||
|
for (var i = 0; i < 300; i++) {
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 100));
|
||||||
|
|
||||||
|
if (!ref.mounted) {
|
||||||
|
DebugLogger.log(
|
||||||
|
'Widget: Provider disposed while waiting for auth',
|
||||||
|
scope: 'widget',
|
||||||
|
);
|
||||||
|
_pendingWidgetAction = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final authState = ref.read(authNavigationStateProvider);
|
||||||
|
if (authState == AuthNavigationState.authenticated) {
|
||||||
|
DebugLogger.log(
|
||||||
|
'Widget: Authenticated, processing pending action',
|
||||||
scope: 'widget',
|
scope: 'widget',
|
||||||
);
|
);
|
||||||
final uri = _pendingWidgetAction;
|
final uri = _pendingWidgetAction;
|
||||||
@@ -126,10 +160,18 @@ class HomeWidgetCoordinator extends _$HomeWidgetCoordinator {
|
|||||||
await _handleWidgetClick(uri);
|
await _handleWidgetClick(uri);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If user is on login page and not loading, they need to authenticate
|
||||||
|
// Don't clear the pending action yet - keep waiting
|
||||||
|
if (authState == AuthNavigationState.needsLogin ||
|
||||||
|
authState == AuthNavigationState.error) {
|
||||||
|
// Continue waiting - user might be logging in
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugLogger.log(
|
DebugLogger.log(
|
||||||
'Widget: Timeout waiting for router, clearing pending action',
|
'Widget: Timeout waiting for authentication, clearing pending action',
|
||||||
scope: 'widget',
|
scope: 'widget',
|
||||||
);
|
);
|
||||||
_pendingWidgetAction = null;
|
_pendingWidgetAction = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user