Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VisionGlass] Improve phone UI #1273

Merged
merged 4 commits into from
Feb 28, 2024
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
3 changes: 3 additions & 0 deletions app/src/aosp/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.view.View;
import android.view.WindowManager;

import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;
import com.igalia.wolvic.utils.SystemUtils;

public class PlatformActivity extends NativeActivity {
Expand All @@ -30,6 +31,8 @@ public static boolean isPositionTrackingSupported() {
return true;
}

public final PlatformActivityPlugin createPlatformPlugin(WidgetManagerDelegate delegate) { return null; }

protected Intent getStoreIntent() {
// Dummy implementation.
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.igalia.wolvic;

public interface PlatformActivityPlugin {
void onKeyboardVisibilityChange(boolean isVisible);
void onVideoAvailabilityChange();
}
17 changes: 17 additions & 0 deletions app/src/common/shared/com/igalia/wolvic/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public void run() {
private boolean mIsPassthroughEnabled = false;
private long mLastBatteryUpdate = System.nanoTime();
private int mLastBatteryLevel = -1;
private PlatformActivityPlugin mPlatformPlugin;

private boolean callOnAudioManager(Consumer<AudioManager> fn) {
if (mAudioManager == null) {
Expand Down Expand Up @@ -439,6 +440,10 @@ public void onWindowVideoAvailabilityChanged(@NonNull WindowWidget aWindow) {
WidgetManagerDelegate.CPU_LEVEL_NORMAL;

queueRunnable(() -> setCPULevelNative(cpuLevel));

if (mPlatformPlugin != null) {
mPlatformPlugin.onVideoAvailabilityChange();
}
}
});

Expand All @@ -450,6 +455,9 @@ public void onWindowVideoAvailabilityChanged(@NonNull WindowWidget aWindow) {

addWidgets(Arrays.asList(mRootWidget, mNavigationBar, mKeyboard, mTray, mWebXRInterstitial));

// Create the platform plugin after widgets are created to be extra safe.
mPlatformPlugin = createPlatformPlugin(this);

mWindows.restoreSessions();
}

Expand Down Expand Up @@ -1676,6 +1684,10 @@ public void updateWidget(final Widget aWidget) {
view.setVisibility(visible ? View.VISIBLE : View.GONE);
}

if (aWidget == mKeyboard && mPlatformPlugin != null) {
mPlatformPlugin.onKeyboardVisibilityChange(visible);
}

for (UpdateListener listener: mWidgetUpdateListeners) {
listener.onWidgetUpdate(aWidget);
}
Expand Down Expand Up @@ -1899,6 +1911,8 @@ public void setWindowSize(float targetWidth, float targetHeight) {
@Override
public void keyboardDismissed() {
mNavigationBar.showVoiceSearch();
if (mPlatformPlugin != null)
mPlatformPlugin.onKeyboardVisibilityChange(false);
}

@Override
Expand Down Expand Up @@ -2108,6 +2122,9 @@ public AppServicesProvider getServicesProvider() {
return (AppServicesProvider)getApplication();
}

@Override
public KeyboardWidget getKeyboard() { return mKeyboard; }

private native void addWidgetNative(int aHandle, WidgetPlacement aPlacement);
private native void updateWidgetNative(int aHandle, WidgetPlacement aPlacement);
private native void updateVisibleWidgetsNative();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1496,4 +1496,9 @@ public void onSessionChanged(@NonNull Session aOldSession, @NonNull Session aSes
aOldSession.removeTextInputListener(this);
aSession.addTextInputListener(this);
}

public void simulateVoiceButtonClick() {
mKeyboardVoiceButton.performClick();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,5 @@ interface WebXRListener {
void updateLocale(@NonNull Context context);
@NonNull
AppServicesProvider getServicesProvider();
KeyboardWidget getKeyboard();
}
2 changes: 2 additions & 0 deletions app/src/hvr/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ public void surfaceDestroyed(SurfaceHolder holder)
queueRunnable(this::nativeOnSurfaceDestroyed);
}

public final PlatformActivityPlugin createPlatformPlugin(WidgetManagerDelegate delegate) { return null; }

protected boolean platformExit() {
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/lynx/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.view.View;
import android.view.WindowManager;

import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;
import com.igalia.wolvic.utils.SystemUtils;

public class PlatformActivity extends NativeActivity {
Expand Down Expand Up @@ -44,6 +45,9 @@ public void run() {
}
});
}

public final PlatformActivityPlugin createPlatformPlugin(WidgetManagerDelegate delegate) { return null; }

protected native void queueRunnable(Runnable aRunnable);
protected native boolean platformExit();
}
61 changes: 58 additions & 3 deletions app/src/main/res/layout/visionglass_layout.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

Expand Down Expand Up @@ -28,14 +29,13 @@
android:textOn="" />

<ImageButton
android:id="@+id/voice_button"
android:id="@+id/phoneUIVoiceButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:contentDescription="@string/voice_search_tooltip"
android:scaleType="fitCenter"
android:src="@drawable/ic_icon_microphone"
android:visibility="invisible"/>
android:src="@drawable/ic_icon_microphone" />
</LinearLayout>

<View
Expand All @@ -48,6 +48,61 @@
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"/>

<LinearLayout
android:id="@+id/phoneUIMediaControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">

<SeekBar
android:id="@+id/phoneUIMediaSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.10"
android:orientation="horizontal">

<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />

<ImageButton
android:id="@+id/phoneUISeekBackward10Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:src="@drawable/ic_icon_media_seek_backward_10" />

<ImageButton
android:id="@+id/phoneUIPlayButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@android:drawable/ic_media_play" />

<ImageButton
android:id="@+id/phoneUISeekForward30Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:src="@drawable/ic_icon_media_seek_forward_30" />

<ImageButton
android:id="@+id/phoneUIMuteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:src="@drawable/ic_icon_media_volume" />
</LinearLayout>

</LinearLayout>

<LinearLayout
android:gravity="center_vertical"
android:layout_width="match_parent"
Expand Down
3 changes: 3 additions & 0 deletions app/src/noapi/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import androidx.annotation.Keep;

import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;
import com.igalia.wolvic.utils.SystemUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -163,6 +164,8 @@ public boolean onGenericMotionEvent(MotionEvent aEvent) {
return true;
}

public final PlatformActivityPlugin createPlatformPlugin(WidgetManagerDelegate delegate) { return null; }

@Override
protected void onPause() {
Log.d(LOGTAG, "PlatformActivity onPause");
Expand Down
2 changes: 2 additions & 0 deletions app/src/oculusvr/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;
import com.igalia.wolvic.utils.SystemUtils;

public class PlatformActivity extends NativeActivity {
Expand Down Expand Up @@ -122,6 +123,7 @@ public WindowInsetsCompat onApplyWindowInsets(
);
}

public final PlatformActivityPlugin createPlatformPlugin(WidgetManagerDelegate delegate) { return null; }

protected native void queueRunnable(Runnable aRunnable);
protected native boolean platformExit();
Expand Down
4 changes: 4 additions & 0 deletions app/src/picoxr/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.content.Intent;
import android.view.KeyEvent;

import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;

public class PlatformActivity extends NativeActivity {

public static boolean filterPermission(final String aPermission) {
Expand All @@ -26,6 +28,8 @@ public static boolean isPositionTrackingSupported() {
return true;
}

public final PlatformActivityPlugin createPlatformPlugin(WidgetManagerDelegate delegate) { return null; }

protected Intent getStoreIntent() {
// Dummy implementation.
return null;
Expand Down
3 changes: 3 additions & 0 deletions app/src/spaces/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.view.View;
import android.view.WindowManager;

import com.igalia.wolvic.ui.widgets.WidgetManagerDelegate;
import com.igalia.wolvic.utils.SystemUtils;

public class PlatformActivity extends NativeActivity {
Expand All @@ -35,6 +36,8 @@ protected Intent getStoreIntent() {
return null;
}

public final PlatformActivityPlugin createPlatformPlugin(WidgetManagerDelegate delegate) { return null; }

@Override
public void onBackPressed() {
queueRunnable(new Runnable() {
Expand Down
Loading