Skip to content
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

[Android] Fix for opening links within Tab Groups (uplift to 1.58.x) #20121

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void onCreate(Bundle savedInstanceState) {
ContextUtils.getApplicationContext());
if (isTablet) {
removePreferenceIfPresent(BravePreferenceKeys.BRAVE_BOTTOM_TOOLBAR_ENABLED_KEY);
removePreferenceIfPresent(PREF_BRAVE_ENABLE_TAB_GROUPS);
}

if (!NightModeUtils.isNightModeSupported()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.chromium.base.BraveReflectionUtil;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType;
import org.chromium.chrome.browser.tab.state.CriticalPersistedTabData;
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModelFilter;
Expand All @@ -34,9 +35,10 @@ public BraveTabGroupModelFilter(TabModel tabModel) {
* Call from {@link TabGroupModelFilter} will be redirected here via bytrcode.
*/
public int getParentId(Tab tab) {
if (isTabModelRestored() && !mIsResetting
if (linkClicked(tab.getLaunchType())
&& SharedPreferencesManager.getInstance().readBoolean(
BravePreferenceKeys.BRAVE_TAB_GROUPS_ENABLED, true)) {
BravePreferenceKeys.BRAVE_TAB_GROUPS_ENABLED, true)
&& isTabModelRestored() && !mIsResetting) {
Tab parentTab = TabModelUtils.getTabById(
getTabModel(), CriticalPersistedTabData.from(tab).getParentId());
if (parentTab != null) {
Expand All @@ -48,4 +50,11 @@ public int getParentId(Tab tab) {
return (int) BraveReflectionUtil.InvokeMethod(
TabGroupModelFilter.class, this, "getParentId", Tab.class, tab);
}

/**
* Determine if a launch type is the result of linked being clicked.
*/
private boolean linkClicked(@TabLaunchType int type) {
return type == TabLaunchType.FROM_LINK || type == TabLaunchType.FROM_LONGPRESS_FOREGROUND;
}
}