Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Closed
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 @@ -280,6 +280,7 @@ protected void initializeWidgets() {
mTray.addListeners(mWindows);

attachToWindow(mWindows.getFocusedWindow(), null);
mWindows.setTray(mTray);

addWidgets(Arrays.asList(mRootWidget, mNavigationBar, mKeyboard, mTray));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public void run() {

mTooltipView = new TooltipWidget(getContext());
mTooltipView.setText(getTooltip());
mTooltipView.setCurvedMode(false);
mTooltipView.setLayoutParams(UIButton.this, mTooltipPosition, mTooltipDensity);
mTooltipView.show(UIWidget.CLEAR_FOCUS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class NavigationBarWidget extends UIWidget implements GeckoSession.Naviga
WidgetManagerDelegate.UpdateListener, SessionChangeListener,
NavigationURLBar.NavigationURLBarDelegate, VoiceSearchWidget.VoiceSearchDelegate,
SharedPreferences.OnSharedPreferenceChangeListener, SuggestionsWidget.URLBarPopupDelegate,
BookmarkListener, TrayListener {
BookmarkListener, TrayWidget.Delegate {

private static final String LOGTAG = "VRB";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public void setLayoutParams(View targetView, ViewUtils.TooltipPosition position)
this.setLayoutParams(targetView, position, mWidgetPlacement.density);
}

public void setCurvedMode(boolean enabled) {
mWidgetPlacement.cylinder = enabled;
}

public void setLayoutParams(View targetView, ViewUtils.TooltipPosition position, float density) {
mTargetView = targetView;
mParentWidget = ViewUtils.getParentWidget(mTargetView);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@
import java.util.List;

public class TrayWidget extends UIWidget implements SessionChangeListener, BookmarkListener, WidgetManagerDelegate.UpdateListener {
static final String LOGTAG = "VRB";

private static final String LOGTAG = TrayWidget.class.getSimpleName();

public interface Delegate {
default void onBookmarksClicked() {}
default void onPrivateBrowsingClicked() {}
default void onAddWindowClicked() {}
}

private static final int ICON_ANIMATION_DURATION = 200;

private UIButton mSettingsButton;
Expand All @@ -39,7 +47,7 @@ public class TrayWidget extends UIWidget implements SessionChangeListener, Bookm
private AudioEngine mAudio;
private int mSettingsDialogHandle = -1;
private boolean mIsLastSessionPrivate;
private List<TrayListener> mTrayListeners;
private List<Delegate> mTrayListeners;
private int mMinPadding;
private int mMaxPadding;
private boolean mKeyboardVisible;
Expand Down Expand Up @@ -184,11 +192,11 @@ public void onAnimationRepeat(Animator animator) {
}
}

public void addListeners(TrayListener... listeners) {
public void addListeners(Delegate... listeners) {
mTrayListeners.addAll(Arrays.asList(listeners));
}

public void removeListeners(TrayListener... listeners) {
public void removeListeners(Delegate... listeners) {
mTrayListeners.removeAll(Arrays.asList(listeners));
}

Expand All @@ -197,15 +205,15 @@ public void onDestroy() {
}

private void notifyBookmarksClicked() {
mTrayListeners.forEach(TrayListener::onBookmarksClicked);
mTrayListeners.forEach(Delegate::onBookmarksClicked);
}

private void notifyPrivateBrowsingClicked() {
mTrayListeners.forEach(TrayListener::onPrivateBrowsingClicked);
mTrayListeners.forEach(Delegate::onPrivateBrowsingClicked);
}

private void notifyAddWindowClicked() {
mTrayListeners.forEach(TrayListener::onAddWindowClicked);
mTrayListeners.forEach(Delegate::onAddWindowClicked);
}

@Override
Expand All @@ -220,8 +228,6 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.anchorY = 0.5f;
aPlacement.parentAnchorX = 0.5f;
aPlacement.parentAnchorY = 0.5f;
aPlacement.rotationAxisX = 1.0f;
aPlacement.rotation = (float)Math.toRadians(-45);
aPlacement.opaque = false;
aPlacement.cylinder = false;
aPlacement.textureScale = 1.0f;
Expand Down Expand Up @@ -276,7 +282,9 @@ public void attachToWindow(@NonNull WindowWidget aWindow) {
}
detachFromWindow();

mWidgetPlacement.parentHandle = aWindow.getHandle();
mAttachedWindow = aWindow;
updatePlacement();
mAttachedWindow.addBookmarksListener(this);

mSessionStack = aWindow.getSessionStack();
Expand All @@ -292,6 +300,42 @@ public void attachToWindow(@NonNull WindowWidget aWindow) {
}
}

public void updatePlacement() {
switch (mAttachedWindow.getWindowPlacement()) {
case FRONT:
mWidgetPlacement.translationX = 0;
mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_y);
mWidgetPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z);
mWidgetPlacement.rotationAxisX = 0.0f;
mWidgetPlacement.rotationAxisY = 0.0f;
mWidgetPlacement.rotationAxisZ = 0.0f;
mWidgetPlacement.rotation = 0;
break;

case LEFT:
mWidgetPlacement.translationX = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_x_sides);
mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_y);
mWidgetPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z_sides);
mWidgetPlacement.rotationAxisX = 0.0f;
mWidgetPlacement.rotationAxisY = 1.0f;
mWidgetPlacement.rotationAxisZ = 0.0f;
mWidgetPlacement.rotation = -(float) Math.toRadians(-WidgetPlacement.floatDimension(getContext(), R.dimen.multi_window_angle));
break;

case RIGHT:
mWidgetPlacement.translationX = -WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_x_sides);
mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_y);
mWidgetPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.tray_world_z_sides);
mWidgetPlacement.rotationAxisX = 0.0f;
mWidgetPlacement.rotationAxisY = 1.0f;
mWidgetPlacement.rotationAxisZ = 0.0f;
mWidgetPlacement.rotation = (float) Math.toRadians(-WidgetPlacement.floatDimension(getContext(), R.dimen.multi_window_angle));
break;
}

mWidgetManager.updateWidget(this);
}

// SessionStack.SessionChangeListener

@Override
Expand Down Expand Up @@ -328,6 +372,8 @@ private void toggleSettingsDialog() {
mSettingsDialogHandle = widget.getHandle();
}

widget.getPlacement().parentHandle = mAttachedWindow.getHandle();

if (widget.isVisible()) {
widget.hide(REMOVE_WIDGET);
} else {
Expand Down Expand Up @@ -375,6 +421,10 @@ public void onBookmarksHidden(WindowWidget aWindow) {
// WidgetManagerDelegate.UpdateListener
@Override
public void onWidgetUpdate(Widget aWidget) {
if (aWidget == mAttachedWindow) {
mWidgetManager.updateWidget(this);
}

if (!aWidget.getClass().equals(KeyboardWidget.class)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.lang.reflect.Type;
import java.util.ArrayList;

public class Windows implements TrayListener, TopBarWidget.Delegate, GeckoSession.ContentDelegate {
public class Windows implements TrayWidget.Delegate, TopBarWidget.Delegate, GeckoSession.ContentDelegate {

private static final String WINDOWS_SAVE_FILENAME = "windows_state.json";

Expand Down Expand Up @@ -66,6 +66,7 @@ class WindowsState {
private WindowWidget mFullscreenWindow;
private WindowPlacement mPrevWindowPlacement;
private boolean mCurvedMode = false;
private TrayWidget mTray;

public enum WindowPlacement{
FRONT(0),
Expand Down Expand Up @@ -147,6 +148,10 @@ public void setDelegate(Delegate aDelegate) {
mDelegate = aDelegate;
}

public void setTray(@NonNull TrayWidget tray) {
mTray = tray;
}

public WindowWidget getFocusedWindow() {
if (mFullscreenWindow != null) {
return mFullscreenWindow;
Expand Down Expand Up @@ -600,6 +605,9 @@ private void updateViews() {
}

updateTopBars();
if (mTray != null)
mTray.updatePlacement();

ArrayList<WindowWidget> windows = getCurrentWindows();
// Sort windows so frontWindow is the first one. Required for proper native matrix updates.
windows.sort((o1, o2) -> o1 == frontWindow ? -1 : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.parentAnchorY = 0.5f;
aPlacement.anchorX = 0.5f;
aPlacement.anchorY = 0.5f;
aPlacement.cylinder = true;
aPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_y);
aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_z);
}
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/tray.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:rotationX="15"
android:layout_margin="2dp">

<LinearLayout
android:layout_width="wrap_content"
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
<dimen name="keyboard_popup_left_margin">116dp</dimen>

<!-- Settings Dialog -->
<item name="settings_world_y" format="float" type="dimen">1.6</item>
<item name="settings_world_z" format="float" type="dimen">-2.0</item>
<item name="settings_world_y" format="float" type="dimen">0.0</item>
<item name="settings_world_z" format="float" type="dimen">2.0</item>
<dimen name="settings_width">770dp</dimen>
<dimen name="settings_height">490dp</dimen>
<dimen name="settings_button_height">320dp</dimen>
Expand Down Expand Up @@ -119,11 +119,14 @@
<dimen name="autocompletion_widget_item_padding">20dp</dimen>

<!-- Tray -->
<item name="tray_world_y" format="float" type="dimen">0.25</item>
<item name="tray_world_z" format="float" type="dimen">-2.5</item>
<item name="tray_world_x" format="float" type="dimen">1.8</item>
<item name="tray_world_y" format="float" type="dimen">-1.4</item>
<item name="tray_world_z" format="float" type="dimen">1.6</item>
<item name="tray_world_x_sides" format="float" type="dimen">2.1</item>
<item name="tray_world_z_sides" format="float" type="dimen">2.6</item>
<item name="tray_world_width" format="float" type="dimen">1.2</item>
<dimen name="tray_width">206dp</dimen>
<dimen name="tray_height">40dp</dimen>
<dimen name="tray_width">172dp</dimen>
<dimen name="tray_height">45dp</dimen>
<item name="tray_tooltip_density" format="float" type="dimen">4.0</item>

<!-- Developer Options Panel -->
Expand Down