From 4a3d9286cdcf2df02fbc4a97b64a4a3ec96e2fb2 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Mon, 26 Nov 2018 03:00:58 -0800 Subject: [PATCH] Fixes #772 Localization UI adjustments (#827) --- app/build.gradle | 3 ++ .../ui/views/settings/ButtonSetting.java | 7 +-- .../ui/views/settings/SingleEditSetting.java | 2 +- .../ui/widgets/dialogs/SettingsWidget.java | 11 +---- .../options/DeveloperOptionsWidget.java | 36 +++++++++++++- .../widgets/options/DisplayOptionsWidget.java | 37 ++++++++++++++- .../VoiceSearchLanguageOptionsWidget.java | 35 +++++++++++++- app/src/main/res/layout/crash_dialog.xml | 6 +-- app/src/main/res/layout/honeycomb_button.xml | 17 +++---- app/src/main/res/layout/honeycomb_switch.xml | 5 +- app/src/main/res/layout/options_developer.xml | 47 ++++++++++++------- app/src/main/res/layout/options_display.xml | 45 ++++++++++++------ app/src/main/res/layout/options_language.xml | 29 +++++++++--- app/src/main/res/layout/setting_button.xml | 4 +- app/src/main/res/layout/setting_edit.xml | 9 ++-- .../main/res/layout/setting_radio_group.xml | 7 +-- app/src/main/res/layout/setting_switch.xml | 18 +++---- app/src/main/res/layout/settings.xml | 17 ++++--- .../main/res/layout/voice_search_dialog.xml | 2 +- app/src/main/res/values/dimen.xml | 20 ++++---- app/src/main/res/values/styles.xml | 16 +++++-- 21 files changed, 258 insertions(+), 115 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index cf224cf59..b5f75ab35 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,6 +61,9 @@ android { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + debug { + pseudoLocalesEnabled true + } } externalNativeBuild { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/ButtonSetting.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/ButtonSetting.java index bea09c17d..4d9c61cb1 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/ButtonSetting.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/ButtonSetting.java @@ -46,12 +46,7 @@ private void initialize(Context aContext) { mButton.setOnClickListener(mInternalClickListener); } - private View.OnClickListener mInternalClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - onClickListener(v); - } - }; + private View.OnClickListener mInternalClickListener = v -> onClickListener(v); protected void onClickListener(View v) { if (mAudio != null) { diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java index 0369d58da..abe78befb 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/settings/SingleEditSetting.java @@ -140,7 +140,7 @@ protected boolean updateTouchTextSelection(View v) { } editText.requestFocusFromTouch(); - + return false; } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SettingsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SettingsWidget.java index 63c3aed81..6f89c5b62 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SettingsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/dialogs/SettingsWidget.java @@ -361,16 +361,7 @@ private void onOptionsDialogDismissed() { // WindowManagerDelegate.FocusChangeListener @Override public void onGlobalFocusChanged(View oldFocus, View newFocus) { - boolean dismiss = false; - UIWidget widget = getChild(mCurrentlyOpenedDialogHandle); - if (widget != null && oldFocus == widget && widget.isVisible()) { - dismiss = true; - - } else if (oldFocus == this && isVisible()) { - dismiss = true; - } - - if (dismiss) { + if (oldFocus == this && isVisible()) { onDismiss(); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DeveloperOptionsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DeveloperOptionsWidget.java index 3d45cb9a5..a2079b2e1 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DeveloperOptionsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DeveloperOptionsWidget.java @@ -18,13 +18,16 @@ import org.mozilla.vrbrowser.ui.views.settings.ButtonSetting; import org.mozilla.vrbrowser.ui.views.settings.RadioGroupSetting; import org.mozilla.vrbrowser.ui.views.settings.SwitchSetting; +import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate; import org.mozilla.vrbrowser.ui.widgets.dialogs.RestartDialogWidget; import org.mozilla.vrbrowser.ui.widgets.UIWidget; import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement; import static org.mozilla.vrbrowser.utils.ServoUtils.isServoAvailable; -public class DeveloperOptionsWidget extends UIWidget { +public class DeveloperOptionsWidget extends UIWidget implements + WidgetManagerDelegate.WorldClickListener, + WidgetManagerDelegate.FocusChangeListener { private AudioEngine mAudio; private UIButton mBackButton; @@ -63,8 +66,11 @@ private void initialize(Context aContext) { mAudio = AudioEngine.fromContext(aContext); + mWidgetManager.addFocusChangeListener(this); + mWidgetManager.addWorldClickListener(this); + mBackButton = findViewById(R.id.backButton); - mBackButton.setOnClickListener((OnClickListener) view -> { + mBackButton.setOnClickListener(view -> { if (mAudio != null) { mAudio.playSound(AudioEngine.Sound.CLICK); } @@ -125,6 +131,14 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.restart_dialog_world_z); } + @Override + public void releaseWidget() { + mWidgetManager.removeFocusChangeListener(this); + mWidgetManager.removeWorldClickListener(this); + + super.releaseWidget(); + } + @Override public void show() { super.show(); @@ -282,4 +296,22 @@ private void setPointerColor(int checkedId, boolean doApply) { } } + // WindowManagerDelegate.FocusChangeListener + + @Override + public void onGlobalFocusChanged(View oldFocus, View newFocus) { + if (oldFocus == this && isVisible() && findViewById(newFocus.getId()) == null) { + onDismiss(); + } + } + + // WorldClickListener + + @Override + public void onWorldClick() { + if (isVisible()) { + onDismiss(); + } + } + } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DisplayOptionsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DisplayOptionsWidget.java index d540140d4..33e8a4cc5 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DisplayOptionsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/DisplayOptionsWidget.java @@ -7,6 +7,7 @@ import android.content.Context; import android.util.AttributeSet; +import android.view.View; import android.widget.ScrollView; import org.mozilla.vrbrowser.R; @@ -18,11 +19,14 @@ import org.mozilla.vrbrowser.ui.views.settings.DoubleEditSetting; import org.mozilla.vrbrowser.ui.views.settings.RadioGroupSetting; import org.mozilla.vrbrowser.ui.views.settings.SingleEditSetting; +import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate; import org.mozilla.vrbrowser.ui.widgets.dialogs.RestartDialogWidget; import org.mozilla.vrbrowser.ui.widgets.UIWidget; import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement; -public class DisplayOptionsWidget extends UIWidget { +public class DisplayOptionsWidget extends UIWidget implements + WidgetManagerDelegate.WorldClickListener, + WidgetManagerDelegate.FocusChangeListener { private AudioEngine mAudio; private UIButton mBackButton; @@ -60,8 +64,11 @@ private void initialize(Context aContext) { mAudio = AudioEngine.fromContext(aContext); + mWidgetManager.addFocusChangeListener(this); + mWidgetManager.addWorldClickListener(this); + mBackButton = findViewById(R.id.backButton); - mBackButton.setOnClickListener((OnClickListener) view -> { + mBackButton.setOnClickListener(view -> { if (mAudio != null) { mAudio.playSound(AudioEngine.Sound.CLICK); } @@ -126,6 +133,14 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.restart_dialog_world_z); } + @Override + public void releaseWidget() { + mWidgetManager.removeFocusChangeListener(this); + mWidgetManager.removeWorldClickListener(this); + + super.releaseWidget(); + } + @Override public void show() { super.show(); @@ -329,4 +344,22 @@ private void setMaxWindowSize(int newMaxWindowWidth, int newMaxWindowHeight, boo String newMaxWindowHeightStr = Integer.toString(newMaxWindowHeight); mMaxWindowSizeEdit.setSecondText(newMaxWindowHeightStr); } + + // WindowManagerDelegate.FocusChangeListener + + @Override + public void onGlobalFocusChanged(View oldFocus, View newFocus) { + if (oldFocus == this && isVisible() && findViewById(newFocus.getId()) == null) { + onDismiss(); + } + } + + // WorldClickListener + + @Override + public void onWorldClick() { + if (isVisible()) { + onDismiss(); + } + } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/VoiceSearchLanguageOptionsWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/VoiceSearchLanguageOptionsWidget.java index 1e55495a5..fbe6e71d6 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/VoiceSearchLanguageOptionsWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/options/VoiceSearchLanguageOptionsWidget.java @@ -7,6 +7,7 @@ import android.content.Context; import android.util.AttributeSet; +import android.view.View; import android.widget.ScrollView; import org.mozilla.vrbrowser.R; @@ -16,10 +17,13 @@ import org.mozilla.vrbrowser.ui.views.settings.ButtonSetting; import org.mozilla.vrbrowser.ui.views.settings.RadioGroupSetting; import org.mozilla.vrbrowser.ui.widgets.UIWidget; +import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate; import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement; import org.mozilla.vrbrowser.utils.LocaleUtils; -public class VoiceSearchLanguageOptionsWidget extends UIWidget { +public class VoiceSearchLanguageOptionsWidget extends UIWidget implements + WidgetManagerDelegate.WorldClickListener, + WidgetManagerDelegate.FocusChangeListener { private AudioEngine mAudio; private UIButton mBackButton; @@ -50,6 +54,9 @@ private void initialize(Context aContext) { mAudio = AudioEngine.fromContext(aContext); + mWidgetManager.addFocusChangeListener(this); + mWidgetManager.addWorldClickListener(this); + mBackButton = findViewById(R.id.backButton); mBackButton.setOnClickListener(view -> { if (mAudio != null) { @@ -83,6 +90,14 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.restart_dialog_world_z); } + @Override + public void releaseWidget() { + mWidgetManager.removeFocusChangeListener(this); + mWidgetManager.removeWorldClickListener(this); + + super.releaseWidget(); + } + @Override public void show() { super.show(); @@ -109,4 +124,22 @@ private void setLanguage(int checkedId, boolean doApply) { SettingsStore.getInstance(getContext()).setVoiceSearchLanguage(mLanguage.getValueForId(checkedId).toString()); } + // WindowManagerDelegate.FocusChangeListener + + @Override + public void onGlobalFocusChanged(View oldFocus, View newFocus) { + if (oldFocus == this && isVisible() && findViewById(newFocus.getId()) == null) { + onDismiss(); + } + } + + // WorldClickListener + + @Override + public void onWorldClick() { + if (isVisible()) { + onDismiss(); + } + } + } diff --git a/app/src/main/res/layout/crash_dialog.xml b/app/src/main/res/layout/crash_dialog.xml index 38f1f52c8..8e435e19d 100644 --- a/app/src/main/res/layout/crash_dialog.xml +++ b/app/src/main/res/layout/crash_dialog.xml @@ -72,21 +72,21 @@