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

Commit

Permalink
Fixes #634 Selecting language for voice input (#728)
Browse files Browse the repository at this point in the history
@cvan Filled the Spanish locale issue #826.
  • Loading branch information
keianhzo authored Nov 23, 2018
1 parent 40bfeac commit a1f7bdc
Show file tree
Hide file tree
Showing 47 changed files with 1,475 additions and 1,017 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.mozilla.vrbrowser.ui.widgets.BookmarkListener;
import org.mozilla.vrbrowser.ui.widgets.BookmarksWidget;
import org.mozilla.vrbrowser.ui.widgets.BrowserWidget;
import org.mozilla.vrbrowser.ui.widgets.CrashDialogWidget;
import org.mozilla.vrbrowser.ui.widgets.dialogs.CrashDialogWidget;
import org.mozilla.vrbrowser.ui.widgets.KeyboardWidget;
import org.mozilla.vrbrowser.ui.widgets.NavigationBarWidget;
import org.mozilla.vrbrowser.ui.widgets.RootWidget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.vrbrowser.PlatformActivity;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.ui.widgets.PermissionWidget;
import org.mozilla.vrbrowser.ui.widgets.dialogs.PermissionWidget;
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.mozilla.vrbrowser.BuildConfig;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.telemetry.TelemetryWrapper;
import org.mozilla.vrbrowser.utils.LocaleUtils;

import androidx.annotation.NonNull;

Expand Down Expand Up @@ -307,11 +308,27 @@ public void setMSAALevel(int level) {
editor.commit();
}


public boolean getLayersEnabled() {
if (BuildConfig.FLAVOR_platform.equalsIgnoreCase("oculusvr")) {
return true;
}
return false;
}

public String getVoiceSearchLanguage() {
String language = mPrefs.getString(
mContext.getString(R.string.settings_key_voice_search_language), null);
if (language == null) {
return LocaleUtils.getDefaultVoiceSearchLanguage(mContext);
}
return language;
}

public void setVoiceSearchLanguage(String language) {
SharedPreferences.Editor editor = mPrefs.edit();
editor.putString(mContext.getString(R.string.settings_key_voice_search_language), language);
editor.commit();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,10 @@ public void unregisterForUpdates() {
}

public String getSearchURL(String aQuery) {
try {
aQuery = URLEncoder.encode(aQuery, "UTF-8");

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return mSearchEngine.buildSearchUrl(aQuery);
}

public String getSuggestionURL(String aQuery) {
try {
aQuery = URLEncoder.encode(aQuery, "UTF-8");

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return mSearchEngine.buildSuggestionsURL(aQuery);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

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

import androidx.annotation.Nullable;

Expand All @@ -24,10 +24,9 @@ public class HoneycombButton extends LinearLayout {
private float mButtonTextSize;
private String mSecondaryButtonText;
private Drawable mButtonIcon;
private AudioEngine mAudio;

public HoneycombButton(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.style.settingsButtonTheme);
this(context, attrs, R.style.honeycombButtonTheme);
}

public HoneycombButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
Expand All @@ -43,8 +42,6 @@ public HoneycombButton(Context context, @Nullable AttributeSet attrs, int defSty
private void initialize(Context aContext) {
inflate(aContext, R.layout.honeycomb_button, this);

mAudio = AudioEngine.fromContext(aContext);

setClickable(true);

mIcon = findViewById(R.id.settings_button_icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface OnCheckedChangeListener {
private OnCheckedChangeListener mSwitchListener;

public HoneycombSwitch(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, R.style.settingsButtonTheme);
this(context, attrs, R.style.honeycombButtonTheme);
}

public HoneycombSwitch(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mozilla.vrbrowser.ui.settings;
package org.mozilla.vrbrowser.ui.views.settings;

import android.content.Context;
import android.content.res.TypedArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mozilla.vrbrowser.ui.settings;
package org.mozilla.vrbrowser.ui.views.settings;

import android.content.Context;
import android.content.res.TypedArray;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mozilla.vrbrowser.ui.settings;
package org.mozilla.vrbrowser.ui.views.settings;

import android.content.Context;
import android.content.res.TypedArray;
Expand All @@ -14,6 +14,7 @@
import org.mozilla.vrbrowser.audio.AudioEngine;

import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;

public class RadioGroupSetting extends LinearLayout {

Expand All @@ -25,9 +26,10 @@ public interface OnCheckedChangeListener {
private String mDecription;
private CharSequence[] mOptions;
private Object[] mValues;
private RadioGroup mRadioGroup;
protected RadioGroup mRadioGroup;
private TextView mRadioDescription;
private OnCheckedChangeListener mRadioGroupListener;
private @LayoutRes int mLayout;

public RadioGroupSetting(Context context, AttributeSet attrs) {
this(context, attrs, 0);
Expand All @@ -39,6 +41,7 @@ public RadioGroupSetting(Context context, AttributeSet attrs, int defStyleAttr)
TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.RadioGroupSetting, defStyleAttr, 0);
mDecription = attributes.getString(R.styleable.RadioGroupSetting_description);
mOptions = attributes.getTextArray(R.styleable.RadioGroupSetting_options);
mLayout = attributes.getResourceId(R.styleable.RadioGroupSetting_layout, R.layout.setting_radio_group);
int id = attributes.getResourceId(R.styleable.RadioGroupSetting_values, 0);
TypedArray array = context.getResources().obtainTypedArray(id);
if (array.getType(0) == TypedValue.TYPE_STRING) {
Expand All @@ -54,16 +57,18 @@ public RadioGroupSetting(Context context, AttributeSet attrs, int defStyleAttr)
}
attributes.recycle();

initialize(context);
initialize(context, mLayout);
}

private void initialize(Context aContext) {
inflate(aContext, R.layout.setting_radio_group, this);
protected void initialize(Context aContext, @LayoutRes int layout) {
inflate(aContext, layout, this);

mAudio = AudioEngine.fromContext(aContext);

mRadioDescription = findViewById(R.id.setting_description);
mRadioDescription.setText(mDecription);
if (mRadioDescription != null) {
mRadioDescription.setText(mDecription);
}

mRadioGroup = findViewById(R.id.radio_group);
mRadioGroup.setSoundEffectsEnabled(false);
Expand Down Expand Up @@ -124,7 +129,7 @@ public int getIdForValue(Object value) {
}
}

return -1;
return 0;
}

public int getCheckedRadioButtonId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.mozilla.vrbrowser.ui.views.settings;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.RadioButton;

import androidx.annotation.LayoutRes;

public class RadioGroupVSetting extends RadioGroupSetting {

public RadioGroupVSetting(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}

public RadioGroupVSetting(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

@Override
protected void initialize(Context aContext, @LayoutRes int layout) {
super.initialize(aContext, layout);

for (int i=0; i<mRadioGroup.getChildCount(); i++) {
RadioButton button = (RadioButton)mRadioGroup.getChildAt(i);
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.topMargin = 20;
params.bottomMargin = 20;
button.setLayoutParams(params);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mozilla.vrbrowser.ui.settings;
package org.mozilla.vrbrowser.ui.views.settings;

import android.content.Context;
import android.content.res.ColorStateList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.mozilla.vrbrowser.ui.settings;
package org.mozilla.vrbrowser.ui.views.settings;

import android.content.Context;
import android.content.res.TypedArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.browser.SessionStore;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.ui.prompts.ChoicePromptWidget;
import org.mozilla.vrbrowser.ui.widgets.prompts.ChoicePromptWidget;


public class BrowserWidget extends UIWidget implements SessionStore.SessionChangeListener,
Expand Down
Loading

0 comments on commit a1f7bdc

Please sign in to comment.