-
Notifications
You must be signed in to change notification settings - Fork 289
Add home screen long-press shortcuts with localized labels #5950
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ 2FA sichern!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Login erfordert 2FA & Zugangsdaten!</string> | ||
| <string name="shortcut_contact_support_short">Support kontakt.</string> | ||
| <string name="shortcut_contact_support_long">Hilfe von unseren Live-Support-Mitarbeitern</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ ¡Guarda tu 2FA!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Inicio requiere 2FA y credenciales!</string> | ||
| <string name="shortcut_contact_support_short">Contactar soporte</string> | ||
| <string name="shortcut_contact_support_long">Obtén ayuda de nuestros agentes en vivo</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ ¡Guarda tu 2FA!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Inicio requiere 2FA y credenciales!</string> | ||
| <string name="shortcut_contact_support_short">Contactar soporte</string> | ||
| <string name="shortcut_contact_support_long">Obtén ayuda de nuestros agentes en vivo</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ Sauvez le 2FA !</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Connexion nécessite 2FA & identifiants !</string> | ||
| <string name="shortcut_contact_support_short">Nous contacter</string> | ||
| <string name="shortcut_contact_support_long">Aide de nos agents de support en direct</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ Salva il 2FA!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Il login richiede 2FA & credenziali!</string> | ||
| <string name="shortcut_contact_support_short">Contatta supporto</string> | ||
| <string name="shortcut_contact_support_long">Aiuto dai nostri agenti di supporto live</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ 2FAを先に保存!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ ログインには2FAと認証情報が必要です!</string> | ||
| <string name="shortcut_contact_support_short">サポートに連絡</string> | ||
| <string name="shortcut_contact_support_long">ライブサポートスタッフに相談する</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ 2FA 먼저 저장!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ 로그인에 2FA 및 자격 증명이 필요합니다!</string> | ||
| <string name="shortcut_contact_support_short">지원 문의</string> | ||
| <string name="shortcut_contact_support_long">실시간 지원 상담원에게 도움 받기</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ Salve o 2FA!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Login requer 2FA & credenciais!</string> | ||
| <string name="shortcut_contact_support_short">Contatar suporte</string> | ||
| <string name="shortcut_contact_support_long">Obtenha ajuda dos nossos agentes ao vivo</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ Сохрани 2FA!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Для входа нужны 2FA & учётные данные!</string> | ||
| <string name="shortcut_contact_support_short">Связаться</string> | ||
| <string name="shortcut_contact_support_long">Помощь от наших агентов поддержки</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ Lưu 2FA trước!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Đăng nhập cần 2FA & mật khẩu!</string> | ||
| <string name="shortcut_contact_support_short">Liên hệ hỗ trợ</string> | ||
| <string name="shortcut_contact_support_long">Nhận hỗ trợ từ nhân viên trực tuyến</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <resources> | ||
| <string name="shortcut_do_not_uninstall_short">⚠️ 先保存2FA!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ 登录需要2FA和凭证!</string> | ||
| <string name="shortcut_contact_support_short">联系客服</string> | ||
| <string name="shortcut_contact_support_long">从我们的在线客服获取帮助</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| <resources> | ||
| <string name="app_name">Edge</string> | ||
| <string name="shortcut_contact_support_short">Contact Support</string> | ||
| <string name="shortcut_contact_support_long">Contact support for help from a live agent</string> | ||
|
JP0P marked this conversation as resolved.
|
||
| <string name="shortcut_do_not_uninstall_short">⚠️ Save 2FA First!</string> | ||
| <string name="shortcut_do_not_uninstall_long">⚠️ Login requires 2FA & credentials!</string> | ||
| </resources> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <shortcut | ||
|
JP0P marked this conversation as resolved.
|
||
| android:shortcutId="do_not_uninstall" | ||
| android:enabled="true" | ||
| android:icon="@android:drawable/ic_dialog_alert" | ||
| android:shortcutShortLabel="@string/shortcut_do_not_uninstall_short" | ||
| android:shortcutLongLabel="@string/shortcut_do_not_uninstall_long"> | ||
| <intent | ||
| android:action="android.intent.action.VIEW" | ||
| android:data="https://support.edge.app/en/articles/14439418-warning-don-t-uninstall-edge-without-your-login-credentials" /> | ||
| </shortcut> | ||
| <shortcut | ||
| android:shortcutId="contact_support" | ||
| android:enabled="true" | ||
| android:icon="@android:drawable/ic_menu_help" | ||
| android:shortcutShortLabel="@string/shortcut_contact_support_short" | ||
| android:shortcutLongLabel="@string/shortcut_contact_support_long"> | ||
| <intent | ||
| android:action="android.intent.action.VIEW" | ||
| android:data="https://support.edge.app/en/articles/14054649-need-help-reach-out-via-our-chat-bubble?chat=open" /> | ||
| </shortcut> | ||
| </shortcuts> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
| var window: UIWindow? | ||
| var securityView: UIView? | ||
|
|
||
| // Deferred until React Native is fully initialized in didFinishLaunchingWithOptions | ||
| private var pendingShortcutItem: UIApplicationShortcutItem? | ||
|
JP0P marked this conversation as resolved.
|
||
|
|
||
| var reactNativeDelegate: ReactNativeDelegate? | ||
| var reactNativeFactory: RCTReactNativeFactory? | ||
|
|
||
|
|
@@ -49,6 +52,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
| _ application: UIApplication, | ||
| didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil | ||
| ) -> Bool { | ||
| let launchedFromShortcut = launchOptions?[.shortcutItem] is UIApplicationShortcutItem | ||
| if let shortcutItem = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem { | ||
| pendingShortcutItem = shortcutItem | ||
| } | ||
|
|
||
| // Initialize SDK's: | ||
| initializeSentry() | ||
| FirebaseApp.configure() | ||
|
|
@@ -72,7 +80,37 @@ class AppDelegate: UIResponder, UIApplicationDelegate { | |
| launchOptions: launchOptions | ||
| ) | ||
|
|
||
| return true | ||
| if let shortcutItem = pendingShortcutItem { | ||
| _ = handleShortcutItem(shortcutItem) | ||
| pendingShortcutItem = nil | ||
| } | ||
|
|
||
| return !launchedFromShortcut | ||
|
Comment on lines
14
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Can be collapsed to a local, e.g.: let shortcutItem = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem
// ... init Sentry/Firebase/RN ...
if let shortcutItem = shortcutItem {
_ = handleShortcutItem(shortcutItem)
}
return shortcutItem == nilRemoves the ivar, the bool, and the stale comment. |
||
| } | ||
|
|
||
| func application( | ||
| _ application: UIApplication, | ||
| performActionFor shortcutItem: UIApplicationShortcutItem, | ||
| completionHandler: @escaping (Bool) -> Void | ||
| ) { | ||
| let handled = handleShortcutItem(shortcutItem) | ||
| completionHandler(handled) | ||
| } | ||
|
|
||
| private func handleShortcutItem(_ shortcutItem: UIApplicationShortcutItem) -> Bool { | ||
| guard let urlString = shortcutItem.userInfo?["url"] as? String, | ||
| let url = URL(string: urlString) else { return false } | ||
|
|
||
|
JP0P marked this conversation as resolved.
|
||
| if url.scheme == "https" || url.scheme == "http" { | ||
| UIApplication.shared.open(url, options: [:]) { success in | ||
| if !success { | ||
| print("Failed to open shortcut URL: \(urlString)") | ||
| } | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| return RCTLinkingManager.application(UIApplication.shared, open: url, options: [:]) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| "SHORTCUT_UNINSTALL_TITLE" = "⚠️ 2FA sichern!"; | ||
| "SHORTCUT_UNINSTALL_SUBTITLE" = "Login erfordert 2FA & Zugangsdaten!"; | ||
| "SHORTCUT_SUPPORT_TITLE" = "Support anfragen"; | ||
| "SHORTCUT_SUPPORT_SUBTITLE" = "Hilfe von unseren Live-Support-Mitarbeitern"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* Home screen shortcut: uninstall warning */ | ||
| "SHORTCUT_UNINSTALL_TITLE" = "⚠️ Save 2FA First!"; | ||
| "SHORTCUT_UNINSTALL_SUBTITLE" = "Login requires 2FA & credentials!"; | ||
|
|
||
| /* Home screen shortcut: contact support */ | ||
| "SHORTCUT_SUPPORT_TITLE" = "Contact Support"; | ||
| "SHORTCUT_SUPPORT_SUBTITLE" = "Get help from our live support agents"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| "SHORTCUT_UNINSTALL_TITLE" = "⚠️ ¡Guarda tu 2FA!"; | ||
| "SHORTCUT_UNINSTALL_SUBTITLE" = "Inicio requiere 2FA y credenciales!"; | ||
| "SHORTCUT_SUPPORT_TITLE" = "Contactar ayuda"; | ||
| "SHORTCUT_SUPPORT_SUBTITLE" = "Obtén ayuda de nuestros agentes en vivo"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| "SHORTCUT_UNINSTALL_TITLE" = "⚠️ ¡Guarda tu 2FA!"; | ||
| "SHORTCUT_UNINSTALL_SUBTITLE" = "Inicio requiere 2FA y credenciales!"; | ||
| "SHORTCUT_SUPPORT_TITLE" = "Contactar ayuda"; | ||
| "SHORTCUT_SUPPORT_SUBTITLE" = "Obtén ayuda de nuestros agentes en vivo"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| "SHORTCUT_UNINSTALL_TITLE" = "⚠️ Sauvez le 2FA !"; | ||
| "SHORTCUT_UNINSTALL_SUBTITLE" = "Connexion nécessite 2FA & identifiants !"; | ||
| "SHORTCUT_SUPPORT_TITLE" = "Nous contacter"; | ||
| "SHORTCUT_SUPPORT_SUBTITLE" = "Aide de nos agents de support en direct"; |
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.
Warning:
startActivity(browserIntent)can throwActivityNotFoundExceptionif no activity is registered to handle theACTION_VIEW+httpsintent (e.g., device with no default browser, stripped-down enterprise builds, browsers disabled). The exception would propagate and crash the app when the user taps a shortcut.Wrap in try-catch and fall through to
super.onNewIntent/ RN handling, or at minimum log and returnfalseso the normal path runs: