Skip to content

Commit

Permalink
Remove reduntdant changes and enable back to New Tab from library panel
Browse files Browse the repository at this point in the history
  • Loading branch information
haanhvu committed Nov 22, 2024
1 parent a61e93d commit 8198bdd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -788,22 +788,14 @@ 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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;

Expand Down Expand Up @@ -51,6 +50,7 @@ public class WindowViewModel extends AndroidViewModel {
private MediatorLiveData<ObservableBoolean> isTitleBarVisible;
private MutableLiveData<ObservableBoolean> isLibraryVisible;
private MutableLiveData<ObservableBoolean> isNewTabVisible;
private MutableLiveData<ObservableBoolean> backToNewTabEnabled;
private MutableLiveData<ObservableBoolean> isLoading;
private MutableLiveData<ObservableBoolean> isMicrophoneEnabled;
private MutableLiveData<ObservableBoolean> isBookmarked;
Expand Down Expand Up @@ -132,6 +132,7 @@ public WindowViewModel(Application application) {

isLibraryVisible = new MutableLiveData<>(new ObservableBoolean(false));
isNewTabVisible = new MutableLiveData<>(new ObservableBoolean(false));
backToNewTabEnabled = new MutableLiveData<>(new ObservableBoolean(false));

isLoading = new MutableLiveData<>(new ObservableBoolean(false));
isMicrophoneEnabled = new MutableLiveData<>(new ObservableBoolean(true));
Expand Down Expand Up @@ -597,11 +598,20 @@ public void setIsNewTabVisible(boolean isNewTabVisible) {
this.url.postValue(this.getUrl().getValue());
}

public void enableBackToNewTab(boolean backToNewTabEnabled) {
this.backToNewTabEnabled.postValue(new ObservableBoolean(backToNewTabEnabled));
}

@NonNull
public MutableLiveData<ObservableBoolean> getIsNewTabVisible() {
return isNewTabVisible;
}

@NonNull
public MutableLiveData<ObservableBoolean> getBackToNewTabEnabled() {
return backToNewTabEnabled;
}

@NonNull
public MutableLiveData<ObservableBoolean> getIsLoading() {
return isLoading;
Expand Down Expand Up @@ -698,7 +708,6 @@ public MutableLiveData<ObservableBoolean> getCanGoBack() {
}

public void setCanGoBack(boolean canGoBack) {
Log.e("New Tab PR", "canGoBack: " + canGoBack);
this.canGoBack.postValue(new ObservableBoolean(canGoBack));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public interface NavigationListener {
private WidgetPlacement mBeforeFullscreenPlacement;
private float mSavedCylinderDensity = 0.0f;
private Animation mAnimation;
public boolean setBackButtonForNewTab;

private class MoveTouchListener implements OnTouchListener {
@Override
Expand Down Expand Up @@ -241,14 +240,12 @@ 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) {
if (mViewModel.getBackToNewTabEnabled().getValue().get()) {
mAttachedWindow.showNewTab();
mViewModel.enableBackToNewTab(false);
}

if (getSession().canGoBack()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,6 @@ public void showNewTab() {
}
};
}
mViewModel.setCanGoBack(true);
mWidgetManager.getNavigationBar().setBackButtonForNewTab = true;
mSession.setCanGoBackForNewTab();
}
}

Expand Down Expand Up @@ -590,12 +587,17 @@ private void hidePanel(boolean switchSurface) {
mRestoreFirstPaint.run();
mRestoreFirstPaint = null;
}
if (mViewModel.getBackToNewTabEnabled().getValue().get()) {
showNewTab();
mViewModel.enableBackToNewTab(false);
}
}

public void hideNewTab() {
if (mViewModel.getIsNewTabVisible().getValue().get()) {
hideNewTab(true);
//mViewModel.setIsNewTabVisible(false);
mViewModel.setIsNewTabVisible(false);
mViewModel.enableBackToNewTab(true);
}
}

Expand Down
115 changes: 0 additions & 115 deletions app/src/main/res/layout/bookmark_item_in_new_tab.xml

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/res/layout/navigation_bar_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
android:src="@drawable/ic_icon_back"
android:tint="@color/midnight"
android:tooltipText="@string/back_tooltip"
android:enabled="@{viewmodel.canGoBack || viewmodel.isNewTabVisible}"
android:enabled="@{viewmodel.canGoBack || viewmodel.backToNewTabEnabled}"
app:privateMode="@{viewmodel.isPrivateSession}" />

<com.igalia.wolvic.ui.views.UIButton
Expand Down

0 comments on commit 8198bdd

Please sign in to comment.