Skip to content

Commit b0047bf

Browse files
dallo28claude
andcommitted
Respect in-app browser settings when opening links from Instant View
Browser.openUrl forced the in-app browser and skipped Custom Tabs whenever an Instant View was on screen, ignoring the user's browser settings and per-domain exceptions. Drop the isInstantViewOpen() override (now unused, so remove it) and let isWebBrowserOpenInApp() decide, as for links opened anywhere else. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f2908b1 commit b0047bf

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

  • TMessagesProj/src/main/java/org/telegram/messenger/browser

‎TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public static void openUrl(final Context context, Uri uri, boolean _allowCustom,
376376
.appendQueryParameter("autologin_token", autologin_token)
377377
.build();
378378
}
379-
if (allowCustom && !(uri != null && MessagesController.getInstance(currentAccount).isWebBrowserOpenInApp(uri.toString()) || isInstantViewOpen()) && MessagesController.getInstance(currentAccount).isWebBrowserUseCustomTabs() && !internalUri && !scheme.equals("tel") && !isTonsite(uri.toString())) {
379+
if (allowCustom && !(uri != null && MessagesController.getInstance(currentAccount).isWebBrowserOpenInApp(uri.toString())) && MessagesController.getInstance(currentAccount).isWebBrowserUseCustomTabs() && !internalUri && !scheme.equals("tel") && !isTonsite(uri.toString())) {
380380
if (forceBrowser[0] || !openInExternalApp(context, uri.toString(), false) || !hasAppToOpen(context, uri.toString())) {
381381
if (MessagesController.getInstance(currentAccount).authDomains.contains(host)) {
382382
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
@@ -412,7 +412,7 @@ public static void openUrl(final Context context, Uri uri, boolean _allowCustom,
412412

413413
final boolean inappBrowser = (
414414
allowInAppBrowser && BubbleActivity.instance == null &&
415-
(uri != null && MessagesController.getInstance(currentAccount).isWebBrowserOpenInApp(uri.toString()) || isInstantViewOpen()) &&
415+
uri != null && MessagesController.getInstance(currentAccount).isWebBrowserOpenInApp(uri.toString()) &&
416416
TextUtils.isEmpty(browserPackage) &&
417417
(uri.getScheme() == null || "https".equals(uri.getScheme()) || "http".equals(uri.getScheme()) || "tonsite".equals(uri.getScheme()))
418418
||
@@ -473,16 +473,6 @@ public static boolean openAsInternalIntent(Context context, String url, boolean
473473
return true;
474474
}
475475

476-
public static boolean isInstantViewOpen() {
477-
BaseFragment fragment = LaunchActivity.getSafeLastFragment();
478-
if (fragment != null && fragment.getParentLayout() instanceof ActionBarLayout) {
479-
BaseFragment sheetFragment = ((ActionBarLayout) fragment.getParentLayout()).getSheetFragment();
480-
if (sheetFragment != null && sheetFragment.getArticleViewer() != null)
481-
return true;
482-
}
483-
return fragment != null && fragment.getArticleViewer() != null;
484-
}
485-
486476
public static boolean openInTelegramBrowser(Context context, String url, Browser.Progress progress) {
487477
if (LaunchActivity.instance != null) {
488478
BottomSheetTabs tabs = LaunchActivity.instance.getBottomSheetTabs();

0 commit comments

Comments
 (0)