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

Move prompt dialogs closer to the window and the tray #1664

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class TrayViewModel extends AndroidViewModel {
private MutableLiveData<ObservableBoolean> isKeyboardVisible;
private MutableLiveData<ObservableInt> downloadsNumber;
private MediatorLiveData<ObservableBoolean> isVisible;
private MutableLiveData<ObservableBoolean> isTabsWidgetVisible;
private MutableLiveData<String> time;
private MutableLiveData<String> pm;
private MutableLiveData<ObservableBoolean> wifiConnected;
Expand All @@ -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<>();
Expand All @@ -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());
Expand Down Expand Up @@ -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<ObservableBoolean> getIsTabsWidgetVisible() {
return isTabsWidgetVisible;
}

public void setIsVisible(boolean isVisible) {
this.isVisible.setValue(new ObservableBoolean(isVisible));
}
Expand Down
24 changes: 10 additions & 14 deletions app/src/common/shared/com/igalia/wolvic/ui/widgets/TabsWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.settings_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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@ public void setAddWindowVisible(boolean aVisible) {
mTrayViewModel.setIsMaxWindows(!aVisible);
}

public void setTabsWidgetVisible(boolean aVisible) {
mTrayViewModel.setIsTabsWidgetVisible(aVisible);
}

// WidgetManagerDelegate.UpdateListener

@Override
Expand Down
19 changes: 10 additions & 9 deletions app/src/common/shared/com/igalia/wolvic/ui/widgets/Windows.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {

@Override
public void updatePlacementTranslationZ() {
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_z) -
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z) -
WidgetPlacement.getWindowWorldZMeters(getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {

@Override
public void updatePlacementTranslationZ() {
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_z) -
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z) -
WidgetPlacement.getWindowWorldZMeters(getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {

@Override
public void updatePlacementTranslationZ() {
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_z) -
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z) -
WidgetPlacement.getWindowWorldZMeters(getContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {

@Override
public void updatePlacementTranslationZ() {
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_z) -
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z) -
WidgetPlacement.getWindowWorldZMeters(getContext());
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/tray.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"/>
Expand Down
Loading