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

Commit

Permalink
Ovr hotfix (#1432)
Browse files Browse the repository at this point in the history
* User enum in widget show (#1352)

* User enum in widget show

Refactored the show methods into a single method that uses a enum for readability.

* Fixed Suggestions widget show override

(cherry picked from commit 374f724)

* Fixes choice prompt crash (#1393)

Also fixed the dialog min with we don't get correct height measures when lists are included in the layout.

(cherry picked from commit c7b95ea)
  • Loading branch information
philip-lamb authored and MortimerGoro committed Jul 19, 2019
1 parent d842444 commit 55fb36a
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.mozilla.vrbrowser.ui.widgets.TopBarWidget;
import org.mozilla.vrbrowser.ui.widgets.TrayListener;
import org.mozilla.vrbrowser.ui.widgets.TrayWidget;
import org.mozilla.vrbrowser.ui.widgets.UIWidget;
import org.mozilla.vrbrowser.ui.widgets.VideoProjectionMenuWidget;
import org.mozilla.vrbrowser.ui.widgets.Widget;
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
Expand Down Expand Up @@ -447,7 +448,7 @@ private void handleCrashIntent(final Intent intent) {
mCrashDialog.setCrashDialogDelegate(() -> sendCrashData(intent));
}

mCrashDialog.show();
mCrashDialog.show(UIWidget.REQUEST_FOCUS);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ private void handleVoiceInput() {
}
mIsInVoiceInput = true;
TelemetryWrapper.voiceInputEvent();
mVoiceSearchWidget.show(false);
mVoiceSearchWidget.show(CLEAR_FOCUS);
mWidgetPlacement.visible = false;
mWidgetManager.updateWidget(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ public void OnVoiceSearchClicked() {
mVoiceSearchWidget.hide(REMOVE_WIDGET);

} else {
mVoiceSearchWidget.show();
mVoiceSearchWidget.show(REQUEST_FOCUS);
}
}

Expand Down Expand Up @@ -881,7 +881,7 @@ public void OnShowSearchPopup() {

if (!mPopup.isVisible()) {
mPopup.updatePlacement((int)WidgetPlacement.convertPixelsToDp(getContext(), mURLBar.getWidth()));
mPopup.show();
mPopup.show(CLEAR_FOCUS);
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
}

@Override
public void show() {
super.show(false);
public void show(@ShowFlags int aShowFlags) {
super.show(aShowFlags);
mList.startAnimation(mScaleUpAnimation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ private void toggleSettingsDialog() {
if (widget.isVisible()) {
widget.hide(REMOVE_WIDGET);
} else {
widget.show();
widget.show(REQUEST_FOCUS);
}
}

Expand All @@ -281,14 +281,14 @@ public void setTrayVisible(boolean aVisible) {

private void updateVisibility() {
if (mTrayVisible && !mKeyboardVisible) {
this.show();
this.show(REQUEST_FOCUS);
} else {
this.hide(UIWidget.KEEP_WIDGET);
}
}

@Override
public void show() {
public void show(@ShowFlags int aShowFlags) {
if (!mWidgetPlacement.visible) {
mWidgetPlacement.visible = true;
mWidgetManager.addWidget(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,28 @@ public void toggle() {
hide(REMOVE_WIDGET);

} else {
show();
show(REQUEST_FOCUS);
}
}

public void show() {
show(true);
}
@IntDef(value = { REQUEST_FOCUS, CLEAR_FOCUS })
public @interface ShowFlags {}
public static final int REQUEST_FOCUS = 0;
public static final int CLEAR_FOCUS = 1;

public void show(boolean focus) {
public void show(@ShowFlags int aShowFlags) {
if (!mWidgetPlacement.visible) {
mWidgetPlacement.visible = true;
mWidgetManager.addWidget(this);
mWidgetManager.pushBackHandler(mBackHandler);
}

if (focus) {
setFocusableInTouchMode(true);
setFocusableInTouchMode(false);
if (aShowFlags == REQUEST_FOCUS) {
requestFocusFromTouch();

} else {
clearFocus();
}
}

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

@Override
public void show(boolean focus) {
public void show(@ShowFlags int aShowFlags) {
if (!mWidgetPlacement.visible) {
mWidgetPlacement.visible = true;
}

mWidgetManager.updateWidget(this);

if (focus) {
setFocusableInTouchMode(true);
setFocusableInTouchMode(false);
if (aShowFlags == REQUEST_FOCUS) {
requestFocusFromTouch();

} else {
clearFocus();
}
}

Expand Down Expand Up @@ -581,7 +584,7 @@ public void setNoInternetToastVisible(boolean aVisible) {
mNoInternetToast.mWidgetPlacement.parentHandle = getHandle();
}
if (aVisible && !mNoInternetToast.isVisible()) {
mNoInternetToast.show();
mNoInternetToast.show(REQUEST_FOCUS);
} else if (!aVisible && mNoInternetToast.isVisible()) {
mNoInternetToast.hide(REMOVE_WIDGET);
}
Expand All @@ -593,7 +596,7 @@ public void showAlert(String title, @NonNull String msg, @NonNull AlertCallback
mAlertPrompt.setTitle(title);
mAlertPrompt.setMessage(msg);
mAlertPrompt.setDelegate(callback);
mAlertPrompt.show();
mAlertPrompt.show(REQUEST_FOCUS);
}

// PromptDelegate
Expand All @@ -605,7 +608,7 @@ public void onAlert(GeckoSession session, String title, String msg, AlertCallbac
mAlertPrompt.setTitle(title);
mAlertPrompt.setMessage(msg);
mAlertPrompt.setDelegate(callback);
mAlertPrompt.show();
mAlertPrompt.show(REQUEST_FOCUS);
}

@Override
Expand All @@ -616,7 +619,7 @@ public void onButtonPrompt(GeckoSession session, String title, String msg, Strin
mConfirmPrompt.setMessage(msg);
mConfirmPrompt.setButtons(btnMsg);
mConfirmPrompt.setDelegate(callback);
mConfirmPrompt.show();
mConfirmPrompt.show(REQUEST_FOCUS);
}

@Override
Expand All @@ -627,7 +630,7 @@ public void onTextPrompt(GeckoSession session, String title, String msg, String
mTextPrompt.setMessage(msg);
mTextPrompt.setDefaultText(value);
mTextPrompt.setDelegate(callback);
mTextPrompt.show();
mTextPrompt.show(REQUEST_FOCUS);
}

@Override
Expand All @@ -637,7 +640,7 @@ public void onAuthPrompt(GeckoSession session, String title, String msg, AuthOpt
mAuthPrompt.setTitle(title);
mAuthPrompt.setMessage(msg);
mAuthPrompt.setAuthOptions(options, callback);
mAuthPrompt.show();
mAuthPrompt.show(REQUEST_FOCUS);
}

@Override
Expand All @@ -649,7 +652,7 @@ public void onChoicePrompt(GeckoSession session, String title, String msg, int t
mChoicePrompt.setChoices(choices);
mChoicePrompt.setMenuType(type);
mChoicePrompt.setDelegate(callback);
mChoicePrompt.show();
mChoicePrompt.show(REQUEST_FOCUS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
}

@Override
public void show() {
super.show();
public void show(@ShowFlags int aShowFlags) {
super.show(aShowFlags);

mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
}

@Override
public void show() {
super.show();
public void show(@ShowFlags int aShowFlags) {
super.show(aShowFlags);

mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);
}
Expand Down Expand Up @@ -141,7 +141,7 @@ public void showPrompt(String aUri, PermissionType aType, GeckoSession.Permissio
mPermissionMessage.setText(str);
mPermissionIcon.setImageResource(iconId);

show();
show(REQUEST_FOCUS);
}

String getRequesterName(String aUri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,18 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
}

if (granted) {
show();
show(REQUEST_FOCUS);

} else {
super.show(true);
super.show(REQUEST_FOCUS);
setPermissionNotGranted();
}
}
}

@Override
public void show(boolean aFocus) {
super.show(aFocus);
public void show(@ShowFlags int aShowFlags) {
super.show(aShowFlags);

setStartListeningState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,19 @@ protected void onDismiss() {
}

@Override
public void show() {
show(true);
public void show(@ShowFlags int aShowFlags) {
super.show(aShowFlags);
for (int i = 0; i < mListItems.length; i++) {
mList.setItemChecked(i, mListItems[i].mChoice.selected);
}
mAdapter.notifyDataSetChanged();
}

@Override
public int getMinHeight() {
return WidgetPlacement.dpDimension(getContext(), R.dimen.prompt_min_height);
}

public void setDelegate(GeckoSession.PromptDelegate.ChoiceCallback delegate) {
mCallback = delegate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {


@Override
public void show() {
public void show(@ShowFlags int aShowFlags) {
mLayout.measure(View.MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
mWidgetPlacement.height = (int)(mLayout.getMeasuredHeight()/mWidgetPlacement.density);
super.show();
mWidgetPlacement.height = (getMinHeight() == 0) ?
(int)(mLayout.getMeasuredHeight()/mWidgetPlacement.density) :
getMinHeight();
super.show(aShowFlags);

mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);

ViewTreeObserver viewTreeObserver = mLayout.getViewTreeObserver();
if (viewTreeObserver.isAlive()) {
Expand All @@ -84,11 +88,6 @@ public void onGlobalLayout() {
}
}

public void show(boolean focus) {
super.show(focus);
mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);
}

public void hide(@HideFlags int aHideFlags) {
super.hide(aHideFlags);
mWidgetManager.popWorldBrightness(this);
Expand All @@ -102,4 +101,8 @@ public void onGlobalFocusChanged(View oldFocus, View newFocus) {
}
}

public int getMinHeight() {
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,8 @@ public void onGlobalFocusChanged(View oldFocus, View newFocus) {
}

@Override
public void show() {
super.show();
public void show(@ShowFlags int aShowFlags) {
super.show(aShowFlags);

mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);
}
Expand Down Expand Up @@ -413,10 +413,10 @@ public void showRestartDialog() {
if (widget == null) {
widget = createChild(RestartDialogWidget.class, false);
mRestartDialogHandle = widget.getHandle();
widget.setDelegate(this::show);
widget.setDelegate(() -> show(REQUEST_FOCUS));
}

widget.show();
widget.show(REQUEST_FOCUS);
}

@Override
Expand All @@ -427,13 +427,13 @@ public void showAlert(String aTitle, String aMessage) {
if (widget == null) {
widget = createChild(AlertPromptWidget.class, false);
mAlertDialogHandle = widget.getHandle();
widget.setDelegate(this::show);
widget.setDelegate(() -> show(REQUEST_FOCUS));
}
widget.getPlacement().translationZ = 0;
widget.getPlacement().parentHandle = mHandle;
widget.setTitle(aTitle);
widget.setMessage(aMessage);

widget.show();
widget.show(REQUEST_FOCUS);
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<dimen name="prompt_content_max_height">450dp</dimen>
<dimen name="prompt_choice_min_height">300dp</dimen>
<dimen name="prompt_choice_max_height">520dp</dimen>
<dimen name="prompt_min_height">400dp</dimen>

<!-- Crash Dialog prompt -->
<dimen name="crash_dialog_width">640dp</dimen>
Expand Down

0 comments on commit 55fb36a

Please sign in to comment.