Skip to content

Commit f7a8384

Browse files
committed
Added option to open links in system browser by default.
1 parent 9af70c1 commit f7a8384

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

TMessagesProj/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ android {
111111
buildConfigField 'int', 'VERSION_CODE', Utils['getVersionCode']()
112112

113113
buildConfigField 'boolean', 'SKIP_DNS_RESOLVER', (Utils['isFdroid']() ? 'true' : 'false')
114+
buildConfigField 'boolean', 'SKIP_INTERNAL_BROWSER_BY_DEFAULT', (Utils['isFdroid']() ? 'true' : 'false')
114115

115116
externalNativeBuild {
116117
cmake {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ public static void openUrl(final Context context, Uri uri, boolean _allowCustom,
424424
SharedConfig.inappBrowser &&
425425
TextUtils.isEmpty(browserPackage) &&
426426
!RestrictedDomainsList.getInstance().isRestricted(AndroidUtilities.getHostAuthority(uri, true)) &&
427+
!MessagesController.getGlobalMainSettings().getBoolean("disableDefaultInAppBrowser", org.telegram.messenger.BuildConfig.SKIP_INTERNAL_BROWSER_BY_DEFAULT) &&
427428
(uri.getScheme() == null || "https".equals(uri.getScheme()) || "http".equals(uri.getScheme()) || "tonsite".equals(uri.getScheme()))
428429
||
429430
isTonsite(uri.toString())

TMessagesProj/src/main/java/org/telegram/ui/ForkSettingsActivity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public void invalidate() {
165165
private int disableRecentFilesAttachment;
166166
private int botSkipShare;
167167
private int botSkipFullscreen;
168+
private int disableDefaultInAppBrowser;
168169

169170
private int stickerSizeRow;
170171

@@ -235,6 +236,7 @@ public boolean onFragmentCreate() {
235236
largePhoto = rowCount++;
236237
disableSlideToNextChannel = rowCount++;
237238
disableRecentFilesAttachment = rowCount++;
239+
disableDefaultInAppBrowser = rowCount++;
238240

239241
emptyRows.add(rowCount++);
240242
botSkipShare = rowCount++;
@@ -351,6 +353,8 @@ public boolean supportsPredictiveItemAnimations() {
351353
toggleGlobalMainSetting("disableSlideToNextChannel", view, false);
352354
} else if (position == disableRecentFilesAttachment) {
353355
toggleGlobalMainSetting("disableRecentFilesAttachment", view, false);
356+
} else if (position == disableDefaultInAppBrowser) {
357+
toggleGlobalMainSetting("disableDefaultInAppBrowser", view, false);
354358
} else if (position == botSkipShare) {
355359
toggleGlobalMainSetting("botSkipShare", view, false);
356360
} else if (position == botSkipFullscreen) {
@@ -501,6 +505,9 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
501505
} else if (position == disableRecentFilesAttachment) {
502506
String t = LocaleController.getString("DisableRecentFilesAttachment", R.string.DisableRecentFilesAttachment);
503507
textCell.setTextAndCheck(t, preferences.getBoolean("disableRecentFilesAttachment", false), false);
508+
} else if (position == disableDefaultInAppBrowser) {
509+
String t = LocaleController.getString("DisableDefaultInAppBrowser", R.string.DisableDefaultInAppBrowser);
510+
textCell.setTextAndCheck(t, preferences.getBoolean("disableDefaultInAppBrowser", false), false);
504511
} else if (position == botSkipShare) {
505512
String t = LocaleController.getString("BotSkipShare", R.string.BotSkipShare);
506513
textCell.setTextAndCheck(t, preferences.getBoolean("botSkipShare", false), false);
@@ -576,6 +583,7 @@ public boolean isEnabled(RecyclerView.ViewHolder holder) {
576583
|| position == largePhoto
577584
|| position == disableSlideToNextChannel
578585
|| position == disableRecentFilesAttachment
586+
|| position == disableDefaultInAppBrowser
579587
|| position == botSkipShare
580588
|| position == botSkipFullscreen
581589
|| position == lockPremium
@@ -646,6 +654,7 @@ public int getItemViewType(int position) {
646654
|| position == largePhoto
647655
|| position == disableSlideToNextChannel
648656
|| position == disableRecentFilesAttachment
657+
|| position == disableDefaultInAppBrowser
649658
|| position == botSkipShare
650659
|| position == botSkipFullscreen
651660
|| position == lockPremium

TMessagesProj/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9549,4 +9549,5 @@
95499549
<string name="BotSetPlatformTitle">Change bot platform</string>
95509550
<string name="BotSetPlatformAbout">Please restart after change to apply a new platform for the current bot.</string>
95519551
<string name="BotCopyUrl">Copy every clicked link</string>
9552+
<string name="DisableDefaultInAppBrowser">Open links in system browser</string>
95529553
</resources>

0 commit comments

Comments
 (0)