diff --git a/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/TrayViewModel.java b/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/TrayViewModel.java index 12b09340382..45eb76dcf03 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/TrayViewModel.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/viewmodel/TrayViewModel.java @@ -19,6 +19,7 @@ public class TrayViewModel extends AndroidViewModel { private MutableLiveData isKeyboardVisible; private MutableLiveData downloadsNumber; private MediatorLiveData isVisible; + private MutableLiveData isTabsWidgetVisible; private MutableLiveData time; private MutableLiveData pm; private MutableLiveData wifiConnected; @@ -41,6 +42,7 @@ public TrayViewModel(@NonNull Application application) { isVisible.addSource(shouldBeVisible, mIsVisibleObserver); isVisible.addSource(isKeyboardVisible, mIsVisibleObserver); isVisible.setValue(new ObservableBoolean(false)); + isTabsWidgetVisible = new MutableLiveData<>(new ObservableBoolean(false)); time = new MutableLiveData<>(); pm = new MutableLiveData<>(); pm = new MutableLiveData<>(); @@ -67,6 +69,7 @@ public void refresh() { isMaxWindows.setValue(isMaxWindows.getValue()); shouldBeVisible.setValue(shouldBeVisible.getValue()); isKeyboardVisible.setValue(isKeyboardVisible.getValue()); + isTabsWidgetVisible.postValue(isTabsWidgetVisible.getValue()); time.postValue(time.getValue()); pm.postValue(pm.getValue()); wifiConnected.postValue(wifiConnected.getValue()); @@ -95,6 +98,14 @@ public void setIsKeyboardVisible(boolean isVisible) { this.isKeyboardVisible.setValue(new ObservableBoolean(isVisible)); } + public void setIsTabsWidgetVisible(boolean isTabsWidgetVisible) { + this.isTabsWidgetVisible.setValue(new ObservableBoolean(isTabsWidgetVisible)); + } + + public MutableLiveData getIsTabsWidgetVisible() { + return isTabsWidgetVisible; + } + public void setIsVisible(boolean isVisible) { this.isVisible.setValue(new ObservableBoolean(isVisible)); } diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/TabsWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/TabsWidget.java index 093d1d70892..c23115c844b 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/TabsWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/TabsWidget.java @@ -67,18 +67,12 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { aPlacement.width = WidgetPlacement.dpDimension(getContext(), R.dimen.tabs_width); aPlacement.height = WidgetPlacement.dpDimension(getContext(), R.dimen.tabs_height); aPlacement.parentAnchorX = 0.5f; - aPlacement.parentAnchorY = 0.0f; + aPlacement.parentAnchorY = 1.0f; aPlacement.anchorX = 0.5f; - aPlacement.anchorY = 0.5f; - aPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_y) - - WidgetPlacement.unitFromMeters(getContext(), R.dimen.window_world_y); - updatePlacementTranslationZ(); - } - - @Override - public void updatePlacementTranslationZ() { - getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z) - - WidgetPlacement.getWindowWorldZMeters(getContext()); + aPlacement.anchorY = 0.0f; + // Undo the rotation of the parent widget (tray). + aPlacement.rotationAxisX = 1.0f; + aPlacement.rotation = (float) Math.toRadians(45); } private void initialize() { @@ -168,9 +162,8 @@ public void onConfigurationChanged(Configuration newConfig) { updateUI(); } - public void attachToWindow(WindowWidget aWindow) { - mPrivateMode = aWindow.getSession().isPrivateMode(); - mWidgetPlacement.parentHandle = aWindow.getHandle(); + public void setPrivateMode(boolean privateMode) { + mPrivateMode = privateMode; } @Override @@ -394,6 +387,9 @@ private void updateSelectionMode() { protected void onDismiss() { exitSelectMode(); hide(KEEP_WIDGET); + if (mDelegate != null) { + mDelegate.onDismiss(); + } } public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration { diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/TrayWidget.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/TrayWidget.java index 8c600061750..7afa268a05d 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/TrayWidget.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/TrayWidget.java @@ -659,6 +659,10 @@ public void setAddWindowVisible(boolean aVisible) { mTrayViewModel.setIsMaxWindows(!aVisible); } + public void setTabsWidgetVisible(boolean aVisible) { + mTrayViewModel.setIsTabsWidgetVisible(aVisible); + } + // WidgetManagerDelegate.UpdateListener @Override diff --git a/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java b/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java index 7c65403cc57..6b4d0cb228c 100644 --- a/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java +++ b/app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java @@ -1225,15 +1225,16 @@ public void onTabsClicked() { mTabsWidget.setTabDelegate(this); } - if (mFocusedWindow != null) { - mTabsWidget.getPlacement().parentHandle = mFocusedWindow.getHandle(); - mTabsWidget.attachToWindow(mFocusedWindow); - mTabsWidget.show(UIWidget.KEEP_FOCUS); - // If we're signed-in, poll for any new device events (e.g. received tabs) - // There's no push support right now, so this helps with the perception of speedy tab delivery. - ((VRBrowserApplication)mContext.getApplicationContext()).getAccounts().refreshDevicesAsync(); - ((VRBrowserApplication)mContext.getApplicationContext()).getAccounts().pollForEventsAsync(); - } + mTabsWidget.getPlacement().parentHandle = mWidgetManager.getTray().getHandle(); + mTabsWidget.setPrivateMode(mPrivateMode); + mTabsWidget.setDelegate(() -> mWidgetManager.getTray().setTabsWidgetVisible(false)); + mWidgetManager.getTray().setTabsWidgetVisible(true); + mTabsWidget.show(UIWidget.KEEP_FOCUS); + + // If we're signed-in, poll for any new device events (e.g. received tabs) + // There's no push support right now, so this helps with the perception of speedy tab delivery. + ((VRBrowserApplication)mContext.getApplicationContext()).getAccounts().refreshDevicesAsync(); + ((VRBrowserApplication)mContext.getApplicationContext()).getAccounts().pollForEventsAsync(); // Capture active session snapshots when showing the tabs menu for (WindowWidget window: getCurrentWindows()) { diff --git a/app/src/main/res/layout/tray.xml b/app/src/main/res/layout/tray.xml index a026fb8c10f..5fb72af5d7b 100644 --- a/app/src/main/res/layout/tray.xml +++ b/app/src/main/res/layout/tray.xml @@ -170,6 +170,7 @@ app:tooltipPosition="bottom" app:tooltipLayout="@layout/tooltip_tray" android:src="@drawable/ic_icon_tray_tabs" + app:activeMode="@{traymodel.isTabsWidgetVisible}" app:regularModeBackground="@{traymodel.isMaxWindows ? @drawable/tray_background_unchecked_start : @drawable/tray_background_unchecked_middle}" app:privateModeBackground="@{traymodel.isMaxWindows ? @drawable/tray_background_start_private : @drawable/tray_background_middle_private}" app:activeModeBackground="@{traymodel.isMaxWindows ? @drawable/tray_background_checked_start : @drawable/tray_background_checked_middle}"/>