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

Standarize dialogs y & z positions #1949

Merged
merged 1 commit into from
Oct 10, 2019
Merged
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 @@ -10,13 +10,10 @@
import android.widget.Button;

import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.audio.AudioEngine;

public class NoInternetWidget extends UIWidget {

private Button mAcceptButton;
private AudioEngine mAudio;
private UIWidget mBrowserWidget;

public NoInternetWidget(Context aContext) {
super(aContext);
Expand Down Expand Up @@ -48,7 +45,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
Context context = getContext();
aPlacement.width = WidgetPlacement.dpDimension(context, R.dimen.no_internet_width);
aPlacement.height = WidgetPlacement.dpDimension(context, R.dimen.no_internet_height);
aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.no_internet_z_distance);
aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_z_distance);
aPlacement.anchorX = 0.5f;
aPlacement.anchorY = 0.5f;
aPlacement.parentAnchorX = 0.5f;
Expand All @@ -57,10 +54,4 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.visible = false;
}

public void setBrowserWidget(UIWidget aWidget) {
if (aWidget != null) {
mWidgetPlacement.parentHandle = aWidget.getHandle();
}
mBrowserWidget = aWidget;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,8 @@ public void setNoInternetToastVisible(boolean aVisible) {
if (mNoInternetToast == null) {
mNoInternetToast = new NoInternetWidget(getContext());
mNoInternetToast.mWidgetPlacement.parentHandle = getHandle();
mNoInternetToast.mWidgetPlacement.parentAnchorY = 0.0f;
mNoInternetToast.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
}
if (aVisible && !mNoInternetToast.isVisible()) {
mNoInternetToast.show(REQUEST_FOCUS);
Expand All @@ -1094,6 +1096,8 @@ public void setNoInternetToastVisible(boolean aVisible) {
public void showAlert(String title, @NonNull String msg, @NonNull PromptWidget.PromptDelegate callback) {
mAlertPrompt = new AlertPromptWidget(getContext());
mAlertPrompt.mWidgetPlacement.parentHandle = getHandle();
mAlertPrompt.mWidgetPlacement.parentAnchorY = 0.0f;
mAlertPrompt.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mAlertPrompt.setTitle(title);
mAlertPrompt.setMessage(msg);
mAlertPrompt.setPromptDelegate(callback);
Expand All @@ -1103,6 +1107,8 @@ public void showAlert(String title, @NonNull String msg, @NonNull PromptWidget.P
public void showButtonPrompt(String title, @NonNull String msg, @NonNull String[] btnMsg, @NonNull ConfirmPromptWidget.ConfirmPromptDelegate callback) {
mConfirmPrompt = new ConfirmPromptWidget(getContext());
mConfirmPrompt.mWidgetPlacement.parentHandle = getHandle();
mConfirmPrompt.mWidgetPlacement.parentAnchorY = 0.0f;
mConfirmPrompt.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mConfirmPrompt.setTitle(title);
mConfirmPrompt.setMessage(msg);
mConfirmPrompt.setButtons(btnMsg);
Expand All @@ -1114,6 +1120,8 @@ public void showAppDialog(@NonNull String title, @NonNull @StringRes int descri
@NonNull BaseAppDialogWidget.Delegate buttonsCallback, @NonNull MessageDialogWidget.Delegate messageCallback) {
mAppDialog = new MessageDialogWidget(getContext());
mAppDialog.mWidgetPlacement.parentHandle = getHandle();
mAppDialog.mWidgetPlacement.parentAnchorY = 0.0f;
mAppDialog.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mAppDialog.setTitle(title);
mAppDialog.setMessage(description);
mAppDialog.setButtons(btnMsg);
Expand All @@ -1125,6 +1133,8 @@ public void showAppDialog(@NonNull String title, @NonNull @StringRes int descri
public void showClearCacheDialog() {
mClearCacheDialog = new ClearCacheDialogWidget(getContext());
mClearCacheDialog.mWidgetPlacement.parentHandle = getHandle();
mClearCacheDialog.mWidgetPlacement.parentAnchorY = 0.0f;
mClearCacheDialog.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mClearCacheDialog.setTitle(R.string.history_clear);
mClearCacheDialog.setButtons(new int[] {
R.string.history_clear_cancel,
Expand Down Expand Up @@ -1169,6 +1179,8 @@ public void showClearCacheDialog() {

public void showMaxWindowsDialog(int maxDialogs) {
mMaxWindowsDialog = new MaxWindowsWidget(getContext());
mMaxWindowsDialog.mWidgetPlacement.parentAnchorY = 0.0f;
mMaxWindowsDialog.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mMaxWindowsDialog.mWidgetPlacement.parentHandle = getHandle();
mMaxWindowsDialog.setMessage(getContext().getString(R.string.max_windows_msg, String.valueOf(maxDialogs)));
mMaxWindowsDialog.show(REQUEST_FOCUS);
Expand Down Expand Up @@ -1310,6 +1322,8 @@ public GeckoResult<PromptResponse> onAlertPrompt(@NonNull GeckoSession geckoSess

mAlertPrompt = new AlertPromptWidget(getContext());
mAlertPrompt.mWidgetPlacement.parentHandle = getHandle();
mAlertPrompt.mWidgetPlacement.parentAnchorY = 0.0f;
mAlertPrompt.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mAlertPrompt.setTitle(alertPrompt.title);
mAlertPrompt.setMessage(alertPrompt.message);
mAlertPrompt.setPromptDelegate(() -> result.complete(alertPrompt.dismiss()));
Expand All @@ -1325,6 +1339,8 @@ public GeckoResult<PromptResponse> onButtonPrompt(@NonNull GeckoSession geckoSes

mConfirmPrompt = new ConfirmPromptWidget(getContext());
mConfirmPrompt.mWidgetPlacement.parentHandle = getHandle();
mConfirmPrompt.mWidgetPlacement.parentAnchorY = 0.0f;
mConfirmPrompt.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mConfirmPrompt.setTitle(buttonPrompt.title);
mConfirmPrompt.setMessage(buttonPrompt.message);
mConfirmPrompt.setButtons(new String[] {
Expand Down Expand Up @@ -1354,6 +1370,8 @@ public GeckoResult<PromptResponse> onTextPrompt(@NonNull GeckoSession geckoSessi

mTextPrompt = new TextPromptWidget(getContext());
mTextPrompt.mWidgetPlacement.parentHandle = getHandle();
mTextPrompt.mWidgetPlacement.parentAnchorY = 0.0f;
mTextPrompt.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mTextPrompt.setTitle(textPrompt.title);
mTextPrompt.setMessage(textPrompt.message);
mTextPrompt.setDefaultText(textPrompt.defaultValue);
Expand All @@ -1380,6 +1398,8 @@ public GeckoResult<PromptResponse> onAuthPrompt(@NonNull GeckoSession geckoSessi

mAuthPrompt = new AuthPromptWidget(getContext());
mAuthPrompt.mWidgetPlacement.parentHandle = getHandle();
mAuthPrompt.mWidgetPlacement.parentAnchorY = 0.0f;
mAuthPrompt.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mAuthPrompt.setTitle(authPrompt.title);
mAuthPrompt.setMessage(authPrompt.message);
mAuthPrompt.setAuthOptions(authPrompt.authOptions);
Expand Down Expand Up @@ -1411,6 +1431,8 @@ public GeckoResult<PromptResponse> onChoicePrompt(@NonNull GeckoSession geckoSes

mChoicePrompt = new ChoicePromptWidget(getContext());
mChoicePrompt.mWidgetPlacement.parentHandle = getHandle();
mChoicePrompt.mWidgetPlacement.parentAnchorY = 0.0f;
mChoicePrompt.mWidgetPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.base_app_dialog_y_distance);
mChoicePrompt.setTitle(choicePrompt.title);
mChoicePrompt.setMessage(choicePrompt.message);
mChoicePrompt.setChoices(choicePrompt.choices);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/dimen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
<!-- No Internet toast -->
<dimen name="no_internet_width">400dp</dimen>
<dimen name="no_internet_height">200dp</dimen>
<dimen name="no_internet_z_distance" format="float" type="dimen">2.5</dimen>

<!-- Autocompletion Widget -->
<dimen name="autocompletion_widget_line_height">36dp</dimen>
Expand Down Expand Up @@ -263,6 +262,7 @@
<!-- Base App Dialog -->
<dimen name="base_app_dialog_width">420dp</dimen>
<item name="base_app_dialog_z_distance" format="float" type="dimen">2</item>
<item name="base_app_dialog_y_distance" format="float" type="dimen">1.2</item>

<!-- Cache Dialog -->
<dimen name="cache_app_dialog_width">585dp</dimen>
Expand Down