Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Oct 29, 2019
1 parent 7dd48a2 commit 39b1868
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.mozilla.vrbrowser.ui.views.NavigationURLBar;
import org.mozilla.vrbrowser.ui.views.UIButton;
import org.mozilla.vrbrowser.ui.views.UITextButton;
import org.mozilla.vrbrowser.ui.widgets.dialogs.BaseAppDialogWidget;
import org.mozilla.vrbrowser.ui.widgets.dialogs.SelectionActionWidget;
import org.mozilla.vrbrowser.ui.widgets.dialogs.SendTabDialogWidget;
import org.mozilla.vrbrowser.ui.widgets.dialogs.VoiceSearchWidget;
Expand Down Expand Up @@ -1111,7 +1110,7 @@ private void showMenu() {
if (mHamburgerMenu == null) {
mHamburgerMenu = new HamburgerMenuWidget(getContext());
mHamburgerMenu.getPlacement().parentHandle = getHandle();
mHamburgerMenu.setDelegate(new HamburgerMenuWidget.MenuDelegate() {
mHamburgerMenu.setMenuDelegate(new HamburgerMenuWidget.MenuDelegate() {
@Override
public void onSendTab() {
hideMenu();
Expand Down Expand Up @@ -1149,19 +1148,17 @@ public void onSwitchMode() {

private void hideMenu() {
if (mHamburgerMenu != null) {
mHamburgerMenu.setDelegate((HamburgerMenuWidget.Delegate) null);
mHamburgerMenu.hide(UIWidget.REMOVE_WIDGET);
}
}

public void showSendTabDialog() {
if (mSendTabDialog == null) {
mSendTabDialog = new SendTabDialogWidget(getContext());
mSendTabDialog.mWidgetPlacement.parentAnchorY = 0.0f;
mSendTabDialog.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
}

mSendTabDialog = new SendTabDialogWidget(getContext());
mSendTabDialog.mWidgetPlacement.parentHandle = mAttachedWindow.getHandle();
mSendTabDialog.setDelegate(() -> {
mSendTabDialog.releaseWidget();
mSendTabDialog = null;
});
mSendTabDialog.show(REQUEST_FOCUS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.mozilla.vrbrowser.ui.views.TabView;
import org.mozilla.vrbrowser.ui.views.UIButton;
import org.mozilla.vrbrowser.ui.views.UITextButton;
import org.mozilla.vrbrowser.ui.widgets.dialogs.SendTabDialogWidget;
import org.mozilla.vrbrowser.ui.widgets.dialogs.UIDialog;
import org.mozilla.vrbrowser.utils.BitmapCache;
import org.mozilla.vrbrowser.utils.ViewUtils;
Expand All @@ -39,6 +40,7 @@ public class TabsWidget extends UIDialog implements WidgetManagerDelegate.WorldC
protected UITextButton mSelectAllButton;
protected UITextButton mUnselectTabs;
protected LinearLayout mTabsSelectModeView;
protected SendTabDialogWidget mSendTabDialog;

protected boolean mSelecting;
protected ArrayList<Session> mSelectedTabs = new ArrayList<>();
Expand All @@ -47,7 +49,6 @@ public interface TabDelegate {
void onTabSelect(Session aTab);
void onTabAdd();
void onTabsClose(ArrayList<Session> aTabs);
void onTabSend(Session aTab);
}

public TabsWidget(Context aContext) {
Expand Down Expand Up @@ -274,10 +275,15 @@ public void onAdd(TabView aSender) {

@Override
public void onSend(TabView aSender) {
if (mTabDelegate != null) {
mTabDelegate.onTabSend(aSender.getSession());
}
onDismiss();
hide(KEEP_WIDGET);
mSendTabDialog = new SendTabDialogWidget(getContext());
mSendTabDialog.mWidgetPlacement.parentHandle = mWidgetManager.getFocusedWindow().getHandle();
mSendTabDialog.setDelegate(() -> {
mSendTabDialog.releaseWidget();
mSendTabDialog = null;
show(REQUEST_FOCUS);
});
mSendTabDialog.show(UIWidget.REQUEST_FOCUS);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
import org.mozilla.vrbrowser.browser.engine.SessionState;
import org.mozilla.vrbrowser.browser.engine.SessionStore;
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
import org.mozilla.vrbrowser.ui.widgets.dialogs.SendTabDialogWidget;
import org.mozilla.vrbrowser.ui.widgets.settings.SettingsWidget;
import org.mozilla.vrbrowser.utils.BitmapCache;
import org.mozilla.vrbrowser.ui.widgets.settings.SettingsWidget;
import org.mozilla.vrbrowser.utils.BitmapCache;
import org.mozilla.vrbrowser.utils.SystemUtils;
Expand Down Expand Up @@ -106,7 +103,6 @@ class WindowsState {
private boolean mIsPaused = false;
private PromptDelegate mPromptDelegate;
private TabsWidget mTabsWidget;
private SendTabDialogWidget mSendTabDialog;
private Accounts mAccounts;
private Services mServices;

Expand Down Expand Up @@ -1237,17 +1233,4 @@ public void onTabsReceived(@NotNull List<TabData> aTabs) {
mTabsWidget.refreshTabs();
}
}


@Override
public void onTabSend(Session aTab) {
if (mSendTabDialog == null) {
mSendTabDialog = new SendTabDialogWidget(mContext);
mSendTabDialog.mWidgetPlacement.parentHandle = mFocusedWindow.getHandle();
mSendTabDialog.mWidgetPlacement.parentAnchorY = 0.0f;
mSendTabDialog.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(mContext, R.dimen.base_app_dialog_y_distance);
}

mSendTabDialog.show(UIWidget.REQUEST_FOCUS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.mozilla.vrbrowser.browser.Accounts;
import org.mozilla.vrbrowser.browser.engine.SessionStore;
import org.mozilla.vrbrowser.databinding.SendTabsDisplayBinding;
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement;

import java.util.ArrayList;
Expand All @@ -30,7 +31,9 @@
import mozilla.components.concept.sync.DeviceCapability;
import mozilla.components.concept.sync.DeviceConstellationObserver;

public class SendTabDialogWidget extends SettingDialogWidget implements DeviceConstellationObserver {
public class SendTabDialogWidget extends SettingDialogWidget implements
DeviceConstellationObserver,
WidgetManagerDelegate.WorldClickListener {

private SendTabsDisplayBinding mSendTabsDialogBinding;
private Accounts mAccounts;
Expand Down Expand Up @@ -73,6 +76,17 @@ protected void initialize(@NonNull Context aContext) {
mWidgetPlacement.width = WidgetPlacement.dpDimension(getContext(), R.dimen.cache_app_dialog_width);
}

@Override
protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
super.initializeWidgetPlacement(aPlacement);

mWidgetPlacement.parentAnchorY = 0.0f;
mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_y) -
WidgetPlacement.unitFromMeters(getContext(), R.dimen.window_world_y);
mWidgetPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_z) -
WidgetPlacement.unitFromMeters(getContext(), R.dimen.window_world_z);
}

@Override
public void releaseWidget() {
mAccounts.removeDeviceConstellationListener(this);
Expand All @@ -91,9 +105,20 @@ public void show(int aShowFlags) {
mBinding.footerLayout.setFooterButtonVisibility(View.GONE);
}

mWidgetManager.addWorldClickListener(this);
mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);

super.show(aShowFlags);
}

@Override
public void hide(int aHideFlags) {
super.hide(aHideFlags);

mWidgetManager.popWorldBrightness(this);
mWidgetManager.removeWorldClickListener(this);
}

@Override
public void onDevicesUpdate(@NotNull ConstellationState constellationState) {
post(() -> {
Expand All @@ -113,4 +138,11 @@ public void onDevicesUpdate(@NotNull ConstellationState constellationState) {
mBinding.footerLayout.setFooterButtonVisibility(mDevicesList.isEmpty() ? View.GONE : View.VISIBLE);
});
}

// WidgetManagerDelegate.WorldClickListener

@Override
public void onWorldClick() {
onDismiss();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void setUAMode(int uaMode) {
mListView.invalidateViews();
}

public void setDelegate(MenuDelegate delegate) {
public void setMenuDelegate(MenuDelegate delegate) {
mMenuDelegate = Optional.ofNullable(delegate);
}

Expand Down Expand Up @@ -123,7 +123,7 @@ private void createMenuItems() {
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (!ViewUtils.isChildrenOf(menuContainer, newFocus)) {
onDismiss();
hide(KEEP_WIDGET);
}
}
}

0 comments on commit 39b1868

Please sign in to comment.