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

Commit

Permalink
Fixes #772 Localization UI adjustments (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo authored and MortimerGoro committed Nov 26, 2018
1 parent 17467e1 commit 4a3d928
Show file tree
Hide file tree
Showing 21 changed files with 258 additions and 115 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ android {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
pseudoLocalesEnabled true
}
}

externalNativeBuild {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected boolean updateTouchTextSelection(View v) {
}

editText.requestFocusFromTouch();

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}
}

}
6 changes: 3 additions & 3 deletions app/src/main/res/layout/crash_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@

<Button
android:id="@+id/learnMoreButton"
style="@style/dialogButtonRegular"
style="@style/dialogButtonWide"
android:layout_marginEnd="@dimen/dialog_button_margin_end"
android:text="@string/learn_more_button"
tools:text="@string/learn_more_button" />

<Button
android:id="@+id/dontSendButton"
style="@style/dialogButtonRegular"
style="@style/dialogButtonWide"
android:layout_marginEnd="@dimen/dialog_button_margin_end"
android:text="@string/do_not_sent_button"
tools:text="@string/do_not_sent_button" />

<Button
android:id="@+id/sendDataButton"
style="@style/dialogButtonHighlighted"
style="@style/dialogButtonWideHighlighted"
android:text="@string/send_data_button"
tools:text="@string/send_data_button" />
</LinearLayout>
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/res/layout/honeycomb_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="@string/settings_privacy"
android:textSize="@dimen/text_smaller_size"
android:fontFamily="sans-serif-light"/>
android:textSize="@dimen/text_smaller_size" />

<TextView
android:id="@+id/settings_secondary_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:text="Secondary text"
android:textSize="@dimen/text_smaller_size"
android:fontFamily="sans-serif-light"/>
android:textSize="@dimen/text_smaller_size" />
</LinearLayout>
</merge>
5 changes: 4 additions & 1 deletion app/src/main/res/layout/honeycomb_switch.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tool="http://schemas.android.com/tools">

<TextView
android:id="@+id/honeycombSwitchText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:fontFamily="sans-serif-light"
android:gravity="center"
android:paddingBottom="5dp"
android:textColor="@color/white"
android:textSize="@dimen/text_smaller_size"
tool:text="Description"/>
tool:text="Description" />

<Switch
android:id="@+id/honeycombSwitchButton"
Expand Down
Loading

0 comments on commit 4a3d928

Please sign in to comment.