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

Fixes #612 #629 New UI with more consistent styles #703

Merged
merged 1 commit into from
Nov 2, 2018
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 @@ -47,14 +47,12 @@
import org.mozilla.vrbrowser.ui.widgets.RootWidget;
import org.mozilla.vrbrowser.ui.widgets.TopBarWidget;
import org.mozilla.vrbrowser.ui.widgets.TrayWidget;
import org.mozilla.vrbrowser.ui.widgets.UIWidget;
import org.mozilla.vrbrowser.ui.widgets.Widget;
import org.mozilla.vrbrowser.ui.widgets.WidgetManagerDelegate;
import org.mozilla.vrbrowser.ui.widgets.WidgetPlacement;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.parentAnchorY = 0.5f;
aPlacement.anchorX = 0.5f;
aPlacement.anchorY = 0.5f;
aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.choice_prompt_world_z);
aPlacement.translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.browser_children_z_distance);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public DoubleEditSetting(Context context, AttributeSet attrs, int defStyleAttr)
}

private void initialize(Context aContext) {
TextView by = findViewById(R.id.setting_by);
TextView by = findViewById(R.id.settingBy);
by.setText(mBy);
by.setVisibility(View.VISIBLE);

mText2 = findViewById(R.id.text2);
mEdit2 = findViewById(R.id.edit2);
mText2 = findViewById(R.id.textValue2);
mEdit2 = findViewById(R.id.editValue2);
mEdit2.setSoundEffectsEnabled(false);

mEdit2.setOnEditorActionListener(mInternalEditorActionListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ private void initialize(Context aContext) {
mDescriptionView = findViewById(R.id.setting_description);
mDescriptionView.setText(mDescription);

mText1 = findViewById(R.id.text1);
mEdit1 = findViewById(R.id.edit1);
mText1 = findViewById(R.id.textValue1);
mEdit1 = findViewById(R.id.editValue1);
mEdit1.setSoundEffectsEnabled(false);

mEdit1.setOnEditorActionListener(mInternalEditorActionListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ public void setValue(boolean value, boolean doApply) {
mSwitch.setOnCheckedChangeListener(null);
mSwitch.setChecked(value);
mSwitch.setOnCheckedChangeListener(mInternalSwitchListener);
mSwitchText.setText(value ? getContext().getString(R.string.on) : getContext().getString(R.string.off));
mSwitchText.setText(value ?
getContext().getString(R.string.on).toUpperCase() :
getContext().getString(R.string.off).toUpperCase());

if (mSwitchListener != null && doApply) {
mSwitchListener.onCheckedChanged(mSwitch, value, doApply);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

public class DeveloperOptionsEditText extends android.support.v7.widget.AppCompatEditText {

public DeveloperOptionsEditText(Context context) {
this(context, null);
}

public DeveloperOptionsEditText(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.developerOptionsEditTextStyle);
super(context, attrs);

initialize();
}

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

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.audio.AudioEngine;

public class HoneycombButton extends LinearLayout {

private ImageView mIcon;
private TextView mText;
private TextView mSecondaryText;
private String mButtonText;
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);
}

public HoneycombButton(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.HoneycombButton, defStyleAttr, 0);
mButtonText = attributes.getString(R.styleable.HoneycombButton_honeycombButtonText);
mButtonTextSize = attributes.getDimension(R.styleable.HoneycombButton_honeycombButtonTextSize, 0.0f);
mButtonIcon = attributes.getDrawable(R.styleable.HoneycombButton_honeycombButtonIcon);
mSecondaryButtonText = attributes.getString(R.styleable.HoneycombButton_honeycombSecondaryText);
initialize(context);
}

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);
if (mIcon != null)
mIcon.setImageDrawable(mButtonIcon);

mText = findViewById(R.id.settings_button_text);
if (mText != null) {
mText.setText(mButtonText);
if (mButtonTextSize > 0) {
mText.getLayoutParams().width = (int) mButtonTextSize;
}
}

mSecondaryText = findViewById(R.id.settings_secondary_text);
if (mSecondaryText != null)
mSecondaryText.setText(mSecondaryButtonText);

setOnHoverListener((view, motionEvent) -> false);

setSoundEffectsEnabled(false);
}

@Override
public void setOnHoverListener(final OnHoverListener l) {
super.setOnHoverListener((view, motionEvent) -> {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_HOVER_ENTER:
if (mIcon != null && mText != null) {
mIcon.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.asphalt, getContext().getTheme()), PorterDuff.Mode.MULTIPLY));
mText.setTextColor(getContext().getColor(R.color.asphalt));
mSecondaryText.setTextColor(getContext().getColor(R.color.asphalt));
}
break;
case MotionEvent.ACTION_HOVER_EXIT:
if (mIcon != null && mText != null) {
mIcon.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.fog, getContext().getTheme()), PorterDuff.Mode.MULTIPLY));
mText.setTextColor(getContext().getColor(R.color.fog));
mSecondaryText.setTextColor(getContext().getColor(R.color.fog));
}
break;
}

return l.onHover(view, motionEvent);
});
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.mozilla.vrbrowser.ui.views;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;

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

public class HoneycombSwitch extends LinearLayout {

public interface OnCheckedChangeListener {
void onCheckedChanged(CompoundButton compoundButton, boolean b);
}

private TextView mText;
private TextView mStateText;
private Switch mSwitch;
private String mSwitchText;
private float mSwitchTextSize;
private OnCheckedChangeListener mSwitchListener;

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

public HoneycombSwitch(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.HoneycombSwitch, defStyleAttr, 0);
mSwitchText = attributes.getString(R.styleable.HoneycombSwitch_honeycombSwitchText);
mSwitchTextSize = attributes.getDimension(R.styleable.HoneycombSwitch_honeycombSwitchTextSize, 0.0f);
initialize(context);
}

private void initialize(Context aContext) {
inflate(aContext, R.layout.honeycomb_switch, this);

mSwitch = findViewById(R.id.honeycombSwitchButton);
mSwitch.setOnCheckedChangeListener(mInternalSwitchListener);
mSwitch.setSoundEffectsEnabled(false);

mText = findViewById(R.id.honeycombSwitchText);
if (mText != null) {
mText.setText(mSwitchText);
if (mSwitchTextSize > 0) {
mText.getLayoutParams().width = (int) mSwitchTextSize;
}
}

mStateText = findViewById(R.id.honeycombSwitchStateText);
}

private CompoundButton.OnCheckedChangeListener mInternalSwitchListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mStateText.setText(b ?
getContext().getString(R.string.on).toUpperCase() :
getContext().getString(R.string.off).toUpperCase());

if (mSwitchListener != null) {
mSwitchListener.onCheckedChanged(compoundButton, b);
}

}
};

public void setOnCheckedChangeListener(OnCheckedChangeListener aListener) {
mSwitchListener = aListener;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
}
});
mURL.addTextChangedListener(mURLTextWatcher);
mURL.setFocusable(true);
mURL.setFocusableInTouchMode(true);

mMicrophoneButton = findViewById(R.id.microphoneButton);
mMicrophoneButton.setTag(R.string.view_id_tag, R.id.microphoneButton);
mMicrophoneButton.setOnClickListener(mMicrophoneListener);
Expand Down

This file was deleted.

Loading