-
-
Notifications
You must be signed in to change notification settings - Fork 68
Native Android App Shortcuts Integration #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KunalPatilCode
wants to merge
5
commits into
AOSSIE-Org:main
Choose a base branch
from
KunalPatilCode:feature/app-shortcuts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aecdc03
feat(android): implement launcher app shortcuts with Flutter routing β¦
KunalPatilCode 1c9161b
fix: remove sensitive logging and unsafe casts, add cleanup to prevenβ¦
KunalPatilCode 7a74c52
Fix security & navigation issues in existing PR:
KunalPatilCode 2b2af0d
fix: address CodeRabbit review issues
KunalPatilCode 07508f5
Merge branch 'main' into feature/app-shortcuts
KunalPatilCode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 82 additions & 1 deletion
83
android/app/src/main/kotlin/org/aossie/ell_ena/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,86 @@ | ||
| package org.aossie.ell_ena | ||
|
|
||
| import android.content.Intent | ||
| import android.net.Uri | ||
| import android.os.Bundle | ||
| import android.util.Log | ||
| import io.flutter.embedding.android.FlutterActivity | ||
| import io.flutter.embedding.engine.FlutterEngine | ||
| import io.flutter.plugin.common.MethodChannel | ||
|
|
||
| class MainActivity : FlutterActivity() | ||
| class MainActivity : FlutterActivity() { | ||
| private val CHANNEL = "app_shortcuts" | ||
| private var pendingRoute: String? = null | ||
| private var methodChannel: MethodChannel? = null | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| handleIntent(intent) | ||
| } | ||
|
|
||
| override fun onNewIntent(intent: Intent) { | ||
| super.onNewIntent(intent) | ||
| handleIntent(intent) | ||
| setIntent(intent) // Important: update the current intent | ||
|
|
||
| // β Send route to Flutter immediately when app is resumed | ||
| sendRouteToFlutter() | ||
| } | ||
|
|
||
| override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
| super.configureFlutterEngine(flutterEngine) | ||
|
|
||
| methodChannel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL) | ||
|
|
||
| // Setup method call handler | ||
| methodChannel?.setMethodCallHandler { call, result -> | ||
| when (call.method) { | ||
| "getInitialRoute" -> { | ||
| result.success(pendingRoute) | ||
| pendingRoute = null // Clear after sending | ||
| } | ||
| else -> result.notImplemented() | ||
| } | ||
| } | ||
|
|
||
| // Try to send initial route immediately if Flutter is ready | ||
| sendRouteToFlutter() | ||
| } | ||
|
|
||
| private fun handleIntent(intent: Intent?) { | ||
| // Method 1: Try to get route from deep link (app://shortcut/chat) | ||
| val uri: Uri? = intent?.data | ||
|
|
||
| if (uri != null && uri.scheme == "app" && uri.host == "shortcut") { | ||
| val route = uri.path?.removePrefix("/") // Remove leading "/" | ||
| pendingRoute = route | ||
| return | ||
| } | ||
|
|
||
| // Method 2: Try to get screen index from extras (fallback) | ||
| val screenIndex = intent?.getIntExtra("screen", -1) | ||
| if (screenIndex != -1) { | ||
| pendingRoute = when (screenIndex) { | ||
| 0 -> "dashboard" | ||
| 1 -> "calendar" | ||
| 2 -> "workspace" | ||
| 3 -> "chat" | ||
| 4 -> "profile" | ||
| else -> null | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun sendRouteToFlutter() { | ||
| if (pendingRoute != null && methodChannel != null) { | ||
| try { | ||
| methodChannel?.invokeMethod("navigate", pendingRoute) | ||
| pendingRoute = null | ||
| } catch (e: Exception) { | ||
| // β Added logging for observability | ||
| Log.w("MainActivity", "Failed to send pendingRoute to Flutter: ${e.message}") | ||
| // Flutter might not be ready yet, route will be sent when getInitialRoute is called | ||
| } | ||
| } | ||
| } | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <string name="app_name">Ell-ena</string> | ||
|
|
||
| <!-- App Shortcuts Labels --> | ||
| <string name="shortcut_dashboard_short">Dashboard</string> | ||
| <string name="shortcut_dashboard_long">Dashboard</string> | ||
|
|
||
| <string name="shortcut_calendar_short">Calendar</string> | ||
| <string name="shortcut_calendar_long">Calendar</string> | ||
|
|
||
| <string name="shortcut_workspace_short">Workspace</string> | ||
| <string name="shortcut_workspace_long">Workspace</string> | ||
|
|
||
| <string name="shortcut_chat_short">Chat</string> | ||
| <string name="shortcut_chat_long">Chat</string> | ||
|
|
||
| <string name="shortcut_profile_short">Profile</string> | ||
| <string name="shortcut_profile_long">Profile</string> | ||
| </resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,14 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off --> | ||
|
|
||
| <!-- Native splash screen theme --> | ||
| <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar"> | ||
| <!-- Show a splash screen on the activity. Automatically removed when | ||
| the Flutter engine draws its first frame --> | ||
| <item name="android:windowBackground">@drawable/launch_background</item> | ||
| </style> | ||
| <!-- Theme applied to the Android Window as soon as the process has started. | ||
| This theme determines the color of the Android Window while your | ||
| Flutter UI initializes, as well as behind your Flutter UI while its | ||
| running. | ||
|
|
||
| This Theme is only used starting with V2 of Flutter's Android embedding. --> | ||
| <!-- Flutter UI theme (NO flutter logo, NO flash) --> | ||
| <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar"> | ||
| <item name="android:windowBackground">?android:colorBackground</item> | ||
| <item name="android:windowBackground">@android:color/transparent</item> | ||
| </style> | ||
|
|
||
| </resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
|
||
| <!-- Dashboard --> | ||
| <shortcut | ||
| android:shortcutId="dashboard" | ||
| android:enabled="true" | ||
| android:icon="@drawable/ic_dashboard" | ||
| android:shortcutShortLabel="@string/shortcut_dashboard_short" | ||
| android:shortcutLongLabel="@string/shortcut_dashboard_long"> | ||
|
|
||
| <intent | ||
| android:action="android.intent.action.VIEW" | ||
| android:targetPackage="org.aossie.ell_ena" | ||
| android:targetClass="org.aossie.ell_ena.MainActivity"> | ||
| <data android:scheme="app" android:host="shortcut" android:path="/dashboard" /> | ||
| <extra android:name="screen" android:value="0" /> | ||
| </intent> | ||
| </shortcut> | ||
|
|
||
| <!-- Calendar --> | ||
| <shortcut | ||
| android:shortcutId="calendar" | ||
| android:enabled="true" | ||
| android:icon="@drawable/ic_calendar" | ||
| android:shortcutShortLabel="@string/shortcut_calendar_short" | ||
| android:shortcutLongLabel="@string/shortcut_calendar_long"> | ||
|
|
||
| <intent | ||
| android:action="android.intent.action.VIEW" | ||
| android:targetPackage="org.aossie.ell_ena" | ||
| android:targetClass="org.aossie.ell_ena.MainActivity"> | ||
| <data android:scheme="app" android:host="shortcut" android:path="/calendar" /> | ||
| <extra android:name="screen" android:value="1" /> | ||
| </intent> | ||
| </shortcut> | ||
|
|
||
| <!-- Workspace --> | ||
| <shortcut | ||
| android:shortcutId="workspace" | ||
| android:enabled="true" | ||
| android:icon="@drawable/ic_workspace" | ||
| android:shortcutShortLabel="@string/shortcut_workspace_short" | ||
| android:shortcutLongLabel="@string/shortcut_workspace_long"> | ||
|
|
||
| <intent | ||
| android:action="android.intent.action.VIEW" | ||
| android:targetPackage="org.aossie.ell_ena" | ||
| android:targetClass="org.aossie.ell_ena.MainActivity"> | ||
| <data android:scheme="app" android:host="shortcut" android:path="/workspace" /> | ||
| <extra android:name="screen" android:value="2" /> | ||
| </intent> | ||
| </shortcut> | ||
|
|
||
| <!-- Chat --> | ||
| <shortcut | ||
| android:shortcutId="chat" | ||
| android:enabled="true" | ||
| android:icon="@drawable/ic_chat" | ||
| android:shortcutShortLabel="@string/shortcut_chat_short" | ||
| android:shortcutLongLabel="@string/shortcut_chat_long"> | ||
|
|
||
| <intent | ||
| android:action="android.intent.action.VIEW" | ||
| android:targetPackage="org.aossie.ell_ena" | ||
| android:targetClass="org.aossie.ell_ena.MainActivity"> | ||
| <data android:scheme="app" android:host="shortcut" android:path="/chat" /> | ||
| <extra android:name="screen" android:value="3" /> | ||
| </intent> | ||
| </shortcut> | ||
|
|
||
| <!-- Profile --> | ||
| <shortcut | ||
| android:shortcutId="profile" | ||
| android:enabled="true" | ||
| android:icon="@drawable/ic_profile" | ||
| android:shortcutShortLabel="@string/shortcut_profile_short" | ||
| android:shortcutLongLabel="@string/shortcut_profile_long"> | ||
|
|
||
| <intent | ||
| android:action="android.intent.action.VIEW" | ||
| android:targetPackage="org.aossie.ell_ena" | ||
| android:targetClass="org.aossie.ell_ena.MainActivity"> | ||
| <data android:scheme="app" android:host="shortcut" android:path="/profile" /> | ||
| <extra android:name="screen" android:value="4" /> | ||
| </intent> | ||
| </shortcut> | ||
|
|
||
| </shortcuts> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unintended change: NormalTheme meta-data commented out.
This appears unrelated to the app shortcuts feature. The
NormalThememeta-data ensures a smooth visual transition from the launch splash to the Flutter UI. Commenting it out can cause a jarring flash or flicker during app startup.If this was intentional, please clarify the reasoning; otherwise, restore it.
Suggested fix
π Committable suggestion
π€ Prompt for AI Agents