-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Vision Glass] UI to realign controller on startup
Display a dialog informing the user that it is necessary to point the phone straight ahead to set up the controller. This dialog will be dismissed automatically after 5 seconds, clicking the realign button on it will close it faster. A similar dialog is displayed on the VR environment.
- Loading branch information
1 parent
b79eeaf
commit 1f2f8f9
Showing
9 changed files
with
269 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/src/visionglass/java/com/igalia/wolvic/AlignNotificationUIDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.igalia.wolvic; | ||
|
||
import android.content.Context; | ||
import android.content.res.Configuration; | ||
import android.util.AttributeSet; | ||
import android.widget.Button; | ||
|
||
import com.igalia.wolvic.ui.widgets.WidgetPlacement; | ||
import com.igalia.wolvic.ui.widgets.dialogs.UIDialog; | ||
|
||
public class AlignNotificationUIDialog extends UIDialog { | ||
|
||
public AlignNotificationUIDialog(Context aContext) { | ||
super(aContext); | ||
updateUI(); | ||
} | ||
|
||
public AlignNotificationUIDialog(Context aContext, AttributeSet aAttrs) { | ||
super(aContext, aAttrs); | ||
updateUI(); | ||
} | ||
|
||
public AlignNotificationUIDialog(Context aContext, AttributeSet aAttrs, int aDefStyle) { | ||
super(aContext, aAttrs, aDefStyle); | ||
updateUI(); | ||
} | ||
|
||
@Override | ||
public void onConfigurationChanged(Configuration newConfig) { | ||
super.onConfigurationChanged(newConfig); | ||
updateUI(); | ||
} | ||
|
||
private void updateUI() { | ||
removeAllViews(); | ||
inflate(getContext(), R.layout.dialog_align, this); | ||
|
||
Button okButton = findViewById(R.id.okButton); | ||
okButton.setOnClickListener(view -> { | ||
post(this::onDismiss); | ||
}); | ||
} | ||
|
||
@Override | ||
protected void initializeWidgetPlacement(WidgetPlacement aPlacement) { | ||
aPlacement.visible = false; | ||
aPlacement.width = WidgetPlacement.dpDimension(getContext(), R.dimen.prompt_dialog_width); | ||
aPlacement.height = WidgetPlacement.dpDimension(getContext(), R.dimen.prompt_dialog_height); | ||
aPlacement.anchorX = 0.5f; | ||
aPlacement.anchorY = 0.5f; | ||
aPlacement.parentAnchorY = 0.0f; | ||
aPlacement.parentAnchorX = 0.5f; | ||
aPlacement.translationY = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_y) - | ||
WidgetPlacement.unitFromMeters(getContext(), R.dimen.window_world_y); | ||
updatePlacementTranslationZ(); | ||
} | ||
|
||
@Override | ||
public void updatePlacementTranslationZ() { | ||
getPlacement().translationZ = WidgetPlacement.unitFromMeters(getContext(), R.dimen.settings_world_z) - | ||
WidgetPlacement.getWindowWorldZMeters(getContext()); | ||
} | ||
|
||
@Override | ||
public void show(@ShowFlags int aShowFlags) { | ||
mWidgetPlacement.parentHandle = mWidgetManager.getFocusedWindow().getHandle(); | ||
|
||
super.show(aShowFlags); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/visionglass/java/com/igalia/wolvic/AlignPhoneDialogFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.igalia.wolvic; | ||
|
||
import android.os.Bundle; | ||
import android.view.ContextThemeWrapper; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.fragment.app.DialogFragment; | ||
|
||
public class AlignPhoneDialogFragment extends DialogFragment { | ||
private final int mThemeResId; | ||
private AlignDynamicButton mRealignButton; | ||
private View.OnClickListener mRealignButtonClickListener; | ||
|
||
public AlignPhoneDialogFragment(int themeResId) { | ||
mThemeResId = themeResId; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
ContextThemeWrapper themedContext = new ContextThemeWrapper(getContext(), mThemeResId); | ||
LayoutInflater themedInflater = getLayoutInflater().cloneInContext(themedContext); | ||
View view = themedInflater.inflate(R.layout.dialog_align_phone, container); | ||
mRealignButton = view.findViewById(R.id.realign_button); | ||
if (mRealignButtonClickListener != null) | ||
mRealignButton.setOnClickListener(mRealignButtonClickListener); | ||
|
||
return view; | ||
} | ||
|
||
public void updatePosition(float x, float y) { | ||
mRealignButton.updatePosition(x, y); | ||
} | ||
|
||
public void setOnRealignButtonClickListener(View.OnClickListener listener) { | ||
mRealignButtonClickListener = listener; | ||
if (mRealignButton != null) | ||
mRealignButton.setOnClickListener(listener); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="500dp" | ||
android:height="300dp" | ||
android:viewportWidth="132.29" | ||
android:viewportHeight="79.38"> | ||
<path | ||
android:pathData="m32.06,31.22 l34.16,-13.23 34.11,13.23 -17.8,-0.23 5.24,21.4L44.61,52.39l5.21,-21.44 -17.76,0.27" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="3.175" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#f9f9f9" | ||
android:strokeLineCap="round"/> | ||
<path | ||
android:pathData="m2.16,60.59 l0.84,11.91h126.37l0.75,-11.91M35.25,6.88 L2.16,60.59L130.13,60.59L97.11,6.88L35.25,6.88" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="3.175" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#f9f9f9" | ||
android:strokeLineCap="round"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="@dimen/prompt_dialog_width" | ||
android:orientation="vertical" | ||
android:layout_height="@dimen/prompt_dialog_height" | ||
android:background="@drawable/dialog_background" | ||
android:paddingStart="30dp" | ||
android:paddingTop="20dp" | ||
android:paddingEnd="30dp" | ||
android:paddingBottom="30dp"> | ||
|
||
<TextView | ||
android:id="@+id/title" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_above="@id/reorientImage" | ||
android:layout_centerHorizontal="true" | ||
android:layout_gravity="center_horizontal" | ||
android:singleLine="false" | ||
android:text="@string/vision_glass_realign_dialog_explanation" | ||
android:textColor="@color/fog" | ||
android:textSize="@dimen/text_big_size" | ||
android:textStyle="bold" /> | ||
|
||
<ImageView | ||
android:id="@+id/reorientImage" | ||
android:layout_width="250dp" | ||
android:layout_height="0dp" | ||
android:layout_gravity="center_horizontal" | ||
android:layout_weight="1" | ||
android:src="@drawable/reorient_phone" /> | ||
|
||
<Button | ||
android:id="@+id/okButton" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="end" | ||
android:background="@drawable/dialog_highlighted_button_background" | ||
android:fontFamily="sans-serif" | ||
android:minWidth="120dp" | ||
android:padding="10dp" | ||
android:scaleType="fitCenter" | ||
android:text="@string/ok_button" | ||
android:textColor="@drawable/prompt_button_text_color" | ||
android:textStyle="bold" /> | ||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:background="?colorPrimary" | ||
android:orientation="vertical" | ||
android:paddingStart="16dp" | ||
android:paddingTop="48dp" | ||
android:paddingEnd="16dp" | ||
android:paddingBottom="48dp"> | ||
|
||
<com.igalia.wolvic.AlignDynamicButton | ||
android:id="@+id/realign_button" | ||
android:layout_width="144dp" | ||
android:layout_height="144dp" | ||
android:layout_gravity="center" | ||
android:backgroundTint="@color/azure" | ||
app:iconTint="@color/white" /> | ||
|
||
<TextView | ||
android:id="@+id/tvMessage" | ||
style="@style/TextAppearance.AppCompat.Subhead" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:text="@string/vision_glass_realign_dialog_explanation" | ||
android:textAlignment="center" | ||
android:textColor="?colorOnPrimary" /> | ||
|
||
</LinearLayout> |