diff --git a/app/src/common/shared/com/igalia/wolvic/browser/engine/Session.java b/app/src/common/shared/com/igalia/wolvic/browser/engine/Session.java index 6a21ea7f74f..68c8c8c10e2 100644 --- a/app/src/common/shared/com/igalia/wolvic/browser/engine/Session.java +++ b/app/src/common/shared/com/igalia/wolvic/browser/engine/Session.java @@ -788,14 +788,22 @@ public boolean isInputActive() { return mState.mIsInputActive; } + public void setCanGoBackForNewTab() { + mState.mCanGoBack = true; + } + public boolean canGoBack() { if (mState.mCanGoBack || isInFullScreen()) { + Log.e("New Tab PR", "Session canGoBack() - First case (mState.mCanGoBack): true"); return true; } if (mState.mParentId != null) { Session parent = SessionStore.get().getSession(mState.mParentId); + Log.e("New Tab PR", "Session canGoBack() - Second case - parent != null: " + (parent != null)); + Log.e("New Tab PR", "Session canGoBack() - Second case - parent.mState.mDisplay == null: " + (parent.mState.mDisplay == null)); return parent != null && parent.mState.mDisplay == null; } + Log.e("New Tab PR", "Session canGoBack() - Third case: false"); return false; } diff --git a/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java b/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java index 9a09be8bda5..72ca93b8684 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/WindowViewModel.java @@ -6,6 +6,7 @@ import android.text.Spannable; import android.text.SpannableString; import android.text.style.ForegroundColorSpan; +import android.util.Log; import android.util.TypedValue; import android.webkit.URLUtil; @@ -697,6 +698,7 @@ public MutableLiveData getCanGoBack() { } public void setCanGoBack(boolean canGoBack) { + Log.e("New Tab PR", "canGoBack: " + canGoBack); this.canGoBack.postValue(new ObservableBoolean(canGoBack)); } diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java index 5e62273569a..997867243cd 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/NavigationBarWidget.java @@ -136,6 +136,7 @@ public interface NavigationListener { private WidgetPlacement mBeforeFullscreenPlacement; private float mSavedCylinderDensity = 0.0f; private Animation mAnimation; + public boolean setBackButtonForNewTab; private class MoveTouchListener implements OnTouchListener { @Override @@ -240,9 +241,16 @@ private void updateUI() { mBinding.navigationBarFullscreen.fullScreenModeContainer.setVisibility(View.GONE); + if (setBackButtonForNewTab) { + mBinding.navigationBarNavigation.backButton.setEnabled(true); + } mBinding.navigationBarNavigation.backButton.setOnClickListener(v -> { v.requestFocusFromTouch(); + if (setBackButtonForNewTab) { + mAttachedWindow.showNewTab(); + } + if (getSession().canGoBack()) { getSession().goBack(); } diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java index 49c98c94e53..a113a1fc983 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/WindowWidget.java @@ -527,8 +527,8 @@ public void showPanel(@Windows.PanelType int panelType) { } public void showNewTab() { - hidePanel(); if (mNewTab != null) { + hidePanel(); setView(mNewTab, true); mViewModel.setIsFindInPage(false); mViewModel.setIsNewTabVisible(true); @@ -544,6 +544,9 @@ public void showNewTab() { } }; } + mViewModel.setCanGoBack(true); + mWidgetManager.getNavigationBar().setBackButtonForNewTab = true; + mSession.setCanGoBackForNewTab(); } } @@ -592,7 +595,7 @@ private void hidePanel(boolean switchSurface) { public void hideNewTab() { if (mViewModel.getIsNewTabVisible().getValue().get()) { hideNewTab(true); - mViewModel.setIsNewTabVisible(false); + //mViewModel.setIsNewTabVisible(false); } } diff --git a/app/src/main/res/layout/navigation_bar_navigation.xml b/app/src/main/res/layout/navigation_bar_navigation.xml index f20e9caac80..bf81d40f0e2 100644 --- a/app/src/main/res/layout/navigation_bar_navigation.xml +++ b/app/src/main/res/layout/navigation_bar_navigation.xml @@ -26,7 +26,7 @@ android:src="@drawable/ic_icon_back" android:tint="@color/midnight" android:tooltipText="@string/back_tooltip" - android:enabled="@{viewmodel.canGoBack}" + android:enabled="@{viewmodel.canGoBack || viewmodel.isNewTabVisible}" app:privateMode="@{viewmodel.isPrivateSession}" />