From 050bd8dd17097e588e408c387b4be7adce4c8009 Mon Sep 17 00:00:00 2001 From: Alexander Kostyuchenko <397355+random-ua@users.noreply.github.com> Date: Mon, 19 Oct 2026 04:31:04 +0300 Subject: [PATCH 1/2] Launch ChatGPT voice and Gemini Live through app deeplinks --- .../wstxda/switchai/assistant/ChatGPTAssistant.kt | 14 ++++++++++++-- .../wstxda/switchai/assistant/GeminiAssistant.kt | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/wstxda/switchai/assistant/ChatGPTAssistant.kt b/app/src/main/java/com/wstxda/switchai/assistant/ChatGPTAssistant.kt index 3787edf..0d475da 100644 --- a/app/src/main/java/com/wstxda/switchai/assistant/ChatGPTAssistant.kt +++ b/app/src/main/java/com/wstxda/switchai/assistant/ChatGPTAssistant.kt @@ -1,11 +1,14 @@ package com.wstxda.switchai.assistant +import android.content.Intent +import androidx.core.net.toUri import com.wstxda.switchai.R import com.wstxda.switchai.activity.AssistantActivity import com.wstxda.switchai.logic.PreferenceHelper import com.wstxda.switchai.logic.openAssistant import com.wstxda.switchai.logic.openAssistantShizuku import com.wstxda.switchai.utils.AssistantProperties +import com.wstxda.switchai.utils.Constants class ChatGPTAssistant : AssistantActivity() { private val preferences by lazy { PreferenceHelper(this) } @@ -30,8 +33,15 @@ class ChatGPTAssistant : AssistantActivity() { } private fun openChatGPT() { + val intents = buildList { + if (preferences.getBoolean(Constants.VOICE_INPUT_PREF_KEY, true)) { + add(Intent(Intent.ACTION_VIEW, "https://chatgpt.com/voice".toUri()) + .setPackage(Companion.packageName)) + } + add(createChatGPTIntent()) + } openAssistant( - intents = listOf(createChatGPTIntent()), + intents = intents, errorMessage = R.string.assistant_application_not_found ) } @@ -47,4 +57,4 @@ class ChatGPTAssistant : AssistantActivity() { defaultActivity = "com.openai.chatgpt.MainActivity", voiceInputActivity = "com.openai.voice.assistant.AssistantActivity" ) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt b/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt index b89f22c..2bae717 100644 --- a/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt +++ b/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt @@ -1,11 +1,14 @@ package com.wstxda.switchai.assistant +import android.content.Intent +import androidx.core.net.toUri import com.wstxda.switchai.R import com.wstxda.switchai.activity.AssistantActivity import com.wstxda.switchai.logic.PreferenceHelper import com.wstxda.switchai.logic.openAssistant import com.wstxda.switchai.logic.openAssistantShizuku import com.wstxda.switchai.utils.AssistantProperties +import com.wstxda.switchai.utils.Constants class GeminiAssistant : AssistantActivity() { private val preferences by lazy { PreferenceHelper(this) } @@ -30,8 +33,15 @@ class GeminiAssistant : AssistantActivity() { } private fun openGemini() { + val intents = buildList { + if (preferences.getBoolean(Constants.VOICE_INPUT_PREF_KEY, true)) { + add(Intent(Intent.ACTION_VIEW, "https://gemini.google.com/app?target=live".toUri()) + .setPackage("com.google.android.googlequicksearchbox")) + } + add(createGeminiIntent()) + } openAssistant( - intents = listOf(createGeminiIntent()), + intents = intents, errorMessage = R.string.assistant_application_not_found ) } @@ -47,4 +57,4 @@ class GeminiAssistant : AssistantActivity() { defaultActivity = "com.google.android.apps.search.assistant.surfaces.voice.robin.main.MainActivity", voiceInputActivity = "com.google.android.apps.search.assistant.surfaces.voice.robin.ui.floaty.activity.FloatyActivity" ) -} \ No newline at end of file +} From c76e699ebdcba5c5cdd0d15c29a2baebfeef151c Mon Sep 17 00:00:00 2001 From: Alexander Kostyuchenko <397355+random-ua@users.noreply.github.com> Date: Mon, 19 Oct 2026 05:30:55 +0300 Subject: [PATCH 2/2] Keep Gemini store fallback pointed at the Gemini package --- .../java/com/wstxda/switchai/assistant/GeminiAssistant.kt | 3 ++- .../main/java/com/wstxda/switchai/logic/AssistantLauncher.kt | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt b/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt index 2bae717..11d8754 100644 --- a/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt +++ b/app/src/main/java/com/wstxda/switchai/assistant/GeminiAssistant.kt @@ -42,7 +42,8 @@ class GeminiAssistant : AssistantActivity() { } openAssistant( intents = intents, - errorMessage = R.string.assistant_application_not_found + errorMessage = R.string.assistant_application_not_found, + storePackageName = Companion.packageName ) } diff --git a/app/src/main/java/com/wstxda/switchai/logic/AssistantLauncher.kt b/app/src/main/java/com/wstxda/switchai/logic/AssistantLauncher.kt index 8c30fce..d19fcdc 100644 --- a/app/src/main/java/com/wstxda/switchai/logic/AssistantLauncher.kt +++ b/app/src/main/java/com/wstxda/switchai/logic/AssistantLauncher.kt @@ -21,6 +21,7 @@ fun Context.onAssistantOpened() { fun Context.openAssistant( intents: List, errorMessage: Int, + storePackageName: String? = null, ): Boolean { intents.forEach { intent -> if (openAssistant(intent)) { @@ -29,7 +30,7 @@ fun Context.openAssistant( } } - val pkg = intents.firstNotNullOfOrNull { intent -> + val pkg = storePackageName ?: intents.firstNotNullOfOrNull { intent -> (intent.component?.packageName ?: intent.`package`)?.takeIf { it.isNotBlank() } } ?: runCatching { (this::class.companionObjectInstance as? AssistantProperties)?.packageName?.takeIf { it.isNotBlank() } @@ -111,4 +112,4 @@ fun Context.openOnStore(packageName: String): Boolean { fun Context.showToast(message: Int) { Toast.makeText(this, message, Toast.LENGTH_SHORT).show() -} \ No newline at end of file +}