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

Commit

Permalink
refactor, fix "Settings" > "Controller Options" icons (fixes issue #1138
Browse files Browse the repository at this point in the history
)
  • Loading branch information
cvan committed May 3, 2019
1 parent 2fa1142 commit 14c81cf
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import org.mozilla.vrbrowser.input.DeviceType;
import org.mozilla.vrbrowser.R;

import androidx.annotation.Nullable;

public class HoneycombButton extends LinearLayout {

private static final String LOGTAG = "VRB";

private ImageView mIcon;
private TextView mText;
private TextView mSecondaryText;
Expand All @@ -35,6 +39,39 @@ public HoneycombButton(Context context, @Nullable AttributeSet attrs, int defSty
mButtonText = attributes.getString(R.styleable.HoneycombButton_honeycombButtonText);
mButtonTextSize = attributes.getDimension(R.styleable.HoneycombButton_honeycombButtonTextSize, 0.0f);
mButtonIcon = attributes.getDrawable(R.styleable.HoneycombButton_honeycombButtonIcon);

String iconIdStr = attributes.getString(R.styleable.HoneycombButton_honeycombButtonIcon);
int deviceTypeId = DeviceType.getType();
switch (deviceTypeId) {
case DeviceType.OculusGo:
if (attributes.hasValue(R.styleable.HoneycombButton_honeycombButtonIconOculus3dof)) {
Log.d(LOGTAG, "Using Oculus 3DoF icon for '" + iconIdStr + "' honeycomb icon");
try {
mButtonIcon = attributes.getDrawable(R.styleable.HoneycombButton_honeycombButtonIconOculus3dof);
} catch (Exception ex) {
Log.d(LOGTAG, "Could not use Oculus 3DoF icon for '" + iconIdStr + "' honeycomb icon: " + ex.getMessage());
}
}
break;
case DeviceType.OculusQuest:
if (attributes.hasValue(R.styleable.HoneycombButton_honeycombButtonIconOculus6dof)) {
Log.d(LOGTAG, "Using Oculus 6DoF icon for '" + iconIdStr + "' honeycomb icon");
try {
mButtonIcon = attributes.getDrawable(R.styleable.HoneycombButton_honeycombButtonIconOculus6dof);
} catch (Exception ex) {
Log.d(LOGTAG, "Could not use Oculus 6DoF icon for '" + iconIdStr + "' honeycomb icon: " + ex.getMessage());
}
}
break;
default:
if (attributes.hasValue(R.styleable.HoneycombButton_honeycombButtonIconOculus3dof) ||
attributes.hasValue(R.styleable.HoneycombButton_honeycombButtonIconOculus6dof)) {
Log.d(LOGTAG, "Using generic icon for '" + iconIdStr + "' honeycomb icon");
}
mButtonIcon = attributes.getDrawable(R.styleable.HoneycombButton_honeycombButtonIcon);
break;
}

mSecondaryButtonText = attributes.getString(R.styleable.HoneycombButton_honeycombSecondaryText);
initialize(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.mozilla.vrbrowser.audio.AudioEngine;
import org.mozilla.vrbrowser.browser.SessionStore;
import org.mozilla.vrbrowser.browser.SettingsStore;
import org.mozilla.vrbrowser.input.DeviceType;
import org.mozilla.vrbrowser.ui.views.HoneycombButton;
import org.mozilla.vrbrowser.ui.views.HoneycombSwitch;
import org.mozilla.vrbrowser.ui.widgets.UIWidget;
Expand Down Expand Up @@ -195,25 +194,6 @@ private void initialize(Context aContext) {
});

HoneycombButton controllerOptionsButton = findViewById(R.id.controllerOptionsButton);
int deviceTypeId = DeviceType.getType();
switch (deviceTypeId) {
case DeviceType.OculusGo:
Log.d(LOGTAG, "Using Oculus 3DoF icon for Controller Options");
controllerOptionsButton.setVisibility(View.GONE);
controllerOptionsButton = findViewById(R.id.controllerOptionsButtonOculus3dof);
controllerOptionsButton.setVisibility(View.VISIBLE);
break;
case DeviceType.OculusQuest:
Log.d(LOGTAG, "Using Oculus 6DoF icon for Controller Options");
controllerOptionsButton.setVisibility(View.GONE);
controllerOptionsButton = findViewById(R.id.controllerOptionsButtonOculus6dof);
controllerOptionsButton.setVisibility(View.VISIBLE);
break;
default:
Log.d(LOGTAG, "Using default icon for Controller Options");
controllerOptionsButton.setVisibility(View.VISIBLE);
break;
}
controllerOptionsButton.setOnClickListener(view -> {
if (mAudio != null) {
mAudio.playSound(AudioEngine.Sound.CLICK);
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/res/drawable/ic_settings_controlleroptions.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<vector android:height="35dp" android:viewportHeight="200"
android:viewportWidth="200" android:width="35dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@color/fog" android:pathData="M198.3,40.5c-0.2,10.8 -3.8,20 -11.3,27.6c-3.9,4 -7.9,7.9 -11.8,11.8c-35.6,35.6 -71.2,71.3 -106.9,106.9c-6.5,6.5 -14.4,10
.3 -23.6,11.2c-20.9,2.2 -39.9,-12.5 -42.7,-33.2c-1.7,-12.1 1.7,-22.7 9.6,-31.8c0.3,-0.4 0.6,-0.7 1,-1C51.9,92.8 91,53.6 130.2,14.5c1.9,-1.9 3.8,-3.7 5.9,-5.2c22.7,-16.6 54.9,-4.8
61.2,23c0.3,1.4 0.5,2.8 0.7,4.2C198.2,37.9 198.3,39.3 198.3,40.5zM159.5,6.9c-18.9,0 -34.2,15.2 -34.3,34.1c0,18.6 14.9,33.6 33.6,33.7c18.9,0.1 34.3,-15.3 34.3,-34.2C193.2,21.9 178.
2,7 159.5,6.9zM84,128.3c7,0 12.6,-5.5 12.6,-12.4c0,-6.9 -5.6,-12.6 -12.5,-12.6c-6.9,0 -12.5,5.6 -12.5,12.5C71.6,122.8 77.1,128.3 84,128.3zM113.3,99c7.1,0 12.6,-5.5 12.6,-12.4c0,-6
.9 -5.6,-12.6 -12.5,-12.6c-6.9,0 -12.5,5.6 -12.5,12.5C101,93.4 106.5,99 113.3,99z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="204" android:viewportHeight="204">
<path android:fillColor="@color/fog" android:pathData="M127.9,72.1A27.11,27.11,0,1,1,166.08,72,26.93,26.93,0,0,1,127.9,72.1ZM103.67,96.33a10,10,0,1,1,14.11,0A10.08,10.08,0,0,1,103.67,96.33ZM80.36,119.64a10,10,0,1,1,14.12,0A10.11,10.11,0,0,1,80.36,119.64Zm-4.75,48.61,93.08-93.08.31-.31A31,31,0,0,0,125.14,31l-.46.47L31.75,124.39l-.77.77-.77.77a31,31,0,0,0,43.87,43.85l.77-.77.76-.76Z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<vector android:height="24dp" android:viewportHeight="200"
android:viewportWidth="200" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFFFFFFF" android:pathData="M183.31,156.74c-1.69,-3.73 -47.45,-62.51 -50.13,-66 -2,-2.53 -50,-62.29 -52.63,-64.91C76.28,21.59 71.8,18 66.48,16c-14.2,-5.18 -30.23,-2.59 -41.62,8.8s-14,27.46 -8.78,41.67c1.94,5.3 5.55,9.77 9.81,14 2.65,2.66 62.17,50.53 65,52.7 3.71,2.8 62.07,48.45 66,50.1 4.24,1.77 14.27,7.35 24,-2.38S184.89,160.19 183.31,156.74ZM110.31,93.82c-0.24,4.79 -3.3,9 -5.36,11.07s-6.39,5.31 -11.23,5.66a27.46,27.46 0,0 1,-9 -0.86c-6.56,-1.6 -14.19,-5.76 -15.67,-6.55 -1.8,-1 -34.83,-21.88 -41.49,-28.54A33.28,33.28 0,0 1,74.63 27.53c6.75,6.75 27,40.32 27.84,42.35 0.68,1.61 4.85,8.51 6.82,15.54A26.2,26.2 0,0 1,110.28 93.82Z"/>
<path android:fillColor="#FFFFFFFF" android:pathData="M51.1,51.08m-30.93,0a30.93,30.93 0,1 1,61.86 0a30.93,30.93 0,1 1,-61.86 0"/>
<path android:fillColor="#FFFFFFFF" android:pathData="M91.36,82.31a6.38,6.38 0,1 0,0 9A6.38,6.38 0,0 0,91.36 82.31Z"/>
<path android:fillColor="#FFFFFFFF" android:pathData="M93.35,93.32a6.37,6.37 0,1 0,9 0A6.37,6.37 0,0 0,93.35 93.32Z"/>
<path android:fillColor="@color/fog" android:pathData="M183.31,156.74c-1.69,-3.73 -47.45,-62.51 -50.13,-66 -2,-2.53 -50,-62.29 -52.63,-64.91C76.28,21.59 71.8,18 66.48,16c-14.2,-5.18 -30.23,-2.59 -41.62,8.8s-14,27.46 -8.78,41.67c1.94,5.3 5.55,9.77 9.81,14 2.65,2.66 62.17,50.53 65,52.7 3.71,2.8 62.07,48.45 66,50.1 4.24,1.77 14.27,7.35 24,-2.38S184.89,160.19 183.31,156.74ZM110.31,93.82c-0.24,4.79 -3.3,9 -5.36,11.07s-6.39,5.31 -11.23,5.66a27.46,27.46 0,0 1,-9 -0.86c-6.56,-1.6 -14.19,-5.76 -15.67,-6.55 -1.8,-1 -34.83,-21.88 -41.49,-28.54A33.28,33.28 0,0 1,74.63 27.53c6.75,6.75 27,40.32 27.84,42.35 0.68,1.61 4.85,8.51 6.82,15.54A26.2,26.2 0,0 1,110.28 93.82Z"/>
<path android:fillColor="@color/fog" android:pathData="M51.1,51.08m-30.93,0a30.93,30.93 0,1 1,61.86 0a30.93,30.93 0,1 1,-61.86 0"/>
<path android:fillColor="@color/fog" android:pathData="M91.36,82.31a6.38,6.38 0,1 0,0 9A6.38,6.38 0,0 0,91.36 82.31Z"/>
<path android:fillColor="@color/fog" android:pathData="M93.35,93.32a6.37,6.37 0,1 0,9 0A6.37,6.37 0,0 0,93.35 93.32Z"/>
</vector>
26 changes: 5 additions & 21 deletions app/src/main/res/layout/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
android:layout_gravity="center_horizontal"
android:clickable="true"
android:contextClickable="false"
android:orientation="vertical">
android:orientation="vertical"
android:focusable="true">

<ImageView
android:id="@+id/ff_logo_settings"
Expand Down Expand Up @@ -156,27 +157,10 @@
<org.mozilla.vrbrowser.ui.views.HoneycombButton
android:id="@+id/controllerOptionsButton"
style="?attr/honeycombButtonStyle"
android:layout_marginRight="10dp"
android:visibility="gone"
android:layout_marginEnd="10dp"
app:honeycombButtonIcon="@drawable/ic_settings_controlleroptions"
app:honeycombButtonText="@string/settings_controller_options"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />

<org.mozilla.vrbrowser.ui.views.HoneycombButton
android:id="@+id/controllerOptionsButtonOculus3dof"
style="?attr/honeycombButtonStyle"
android:layout_marginRight="10dp"
android:visibility="gone"
app:honeycombButtonIcon="@drawable/ic_settings_controlleroptions_oculusvr_3dof"
app:honeycombButtonText="@string/settings_controller_options"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />

<org.mozilla.vrbrowser.ui.views.HoneycombButton
android:id="@+id/controllerOptionsButtonOculus6dof"
style="?attr/honeycombButtonStyle"
android:layout_marginRight="10dp"
android:visibility="gone"
app:honeycombButtonIcon="@drawable/ic_settings_controlleroptions_oculusvr_6dof"
app:honeycombButtonIconOculus3dof="@drawable/ic_settings_controlleroptions_oculusvr_3dof"
app:honeycombButtonIconOculus6dof="@drawable/ic_settings_controlleroptions_oculusvr_6dof"
app:honeycombButtonText="@string/settings_controller_options"
app:honeycombButtonTextSize="@dimen/settings_main_button_text_width" />

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<resources>
<declare-styleable name="HoneycombButton">
<attr name="honeycombButtonIcon" format="integer" />
<attr name="honeycombButtonIconOculus3dof" format="integer" />
<attr name="honeycombButtonIconOculus6dof" format="integer" />
<attr name="honeycombButtonText" format="string" />
<attr name="honeycombButtonTextSize" format="dimension" />
<attr name="honeycombSecondaryText" format="string" />
Expand Down Expand Up @@ -48,4 +50,4 @@
<attr name="description" />
<attr name="buttonText" format="string" />
</declare-styleable>
</resources>
</resources>

0 comments on commit 14c81cf

Please sign in to comment.