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] Style phone UI #1274

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
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ android {
visionglass {
dimension "platform"
applicationIdSuffix ".visionglass"
resValue "string", "app_name", "Wolvic VisionGlass"
resValue "string", "app_name", "Wolvic Vision"
externalNativeBuild {
cmake {
cppFlags " -DVISIONGLASS"
Expand Down
133 changes: 0 additions & 133 deletions app/src/main/res/layout/visionglass_layout.xml

This file was deleted.

Binary file added app/src/visionglass/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 12 additions & 38 deletions app/src/visionglass/java/com/igalia/wolvic/PlatformActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,29 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.hardware.display.DisplayManager;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.ToggleButton;

import androidx.activity.ComponentActivity;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;

import com.google.android.material.button.MaterialButton;
import com.huawei.usblib.DisplayMode;
import com.huawei.usblib.DisplayModeCallback;
import com.huawei.usblib.OnConnectionListener;
Expand Down Expand Up @@ -168,6 +166,8 @@ public void onConnectionChange(boolean b) {
}

private void initVisionGlassPhoneUI() {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setTheme(R.style.Theme_WolvicPhone);
setContentView(R.layout.visionglass_layout);

mVoiceSearchButton = findViewById(R.id.phoneUIVoiceButton);
Expand All @@ -193,13 +193,11 @@ private void initVisionGlassPhoneUI() {
// user and system activated clicks (e.g. a11y) will work.
view.performClick();
break;
default:
return false;
}
return true;
return false;
});

ImageButton backButton = findViewById(R.id.back_button);
Button backButton = findViewById(R.id.back_button);
backButton.setOnClickListener(v -> onBackPressed());

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Expand Down Expand Up @@ -332,7 +330,6 @@ protected void onResume() {
mActivePresentation.mGLView.onResume();

queueRunnable(activityResumedRunnable);
setImmersiveSticky();
}

@Override
Expand All @@ -351,27 +348,6 @@ protected void onDestroy() {
}
}

void setImmersiveSticky() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);
WindowInsetsController controller = getWindow().getInsetsController();
if (controller != null) {
controller.hide(WindowInsets.Type.statusBars() | WindowInsets.Type.navigationBars());
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
} else {
getWindow()
.getDecorView()
.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}

boolean queueRunnable(@NonNull Runnable aRunnable) {
if (mActivePresentation != null) {
mActivePresentation.mGLView.queueEvent(aRunnable);
Expand Down Expand Up @@ -454,12 +430,12 @@ public void onVideoAvailabilityChange() {
media.addMediaListener(new WMediaSession.Delegate() {
@Override
public void onPlay(@NonNull WSession session, @NonNull WMediaSession mediaSession) {
((ImageButton) findViewById(R.id.phoneUIPlayButton)).setImageResource(R.drawable.ic_icon_media_pause);
((MaterialButton) findViewById(R.id.phoneUIPlayButton)).setIconResource(R.drawable.ic_icon_media_pause);
}

@Override
public void onPause(@NonNull WSession session, @NonNull WMediaSession mediaSession) {
((ImageButton) findViewById(R.id.phoneUIPlayButton)).setImageResource(R.drawable.ic_icon_media_play);
((MaterialButton) findViewById(R.id.phoneUIPlayButton)).setIconResource(R.drawable.ic_icon_media_play);
}

@Override
Expand All @@ -481,7 +457,7 @@ private void setupPhoneUI() {
mDelegate.getWindows().getFocusedWindow().loadHome();
});

ToggleButton headlockButton = findViewById(R.id.headlock_toggle_button);
MaterialButton headlockButton = findViewById(R.id.headlock_toggle_button);
headlockButton.setOnClickListener(v -> {
mDelegate.setHeadLockEnabled(headlockButton.isChecked());
});
Expand Down Expand Up @@ -522,7 +498,7 @@ private void setupPhoneUI() {
if (media == null)
return;
media.setMuted(!media.isMuted());
((ImageButton) findViewById(R.id.phoneUIMuteButton)).setImageResource(!media.isMuted() ? R.drawable.ic_icon_media_volume : R.drawable.ic_icon_media_volume_muted);
((MaterialButton) findViewById(R.id.phoneUIMuteButton)).setIconResource(!media.isMuted() ? R.drawable.ic_icon_media_volume : R.drawable.ic_icon_media_volume_muted);
});

mMediaSeekbar = findViewById(R.id.phoneUIMediaSeekBar);
Expand Down Expand Up @@ -646,9 +622,7 @@ public void onDrawFrame(GL10 gl) {

@Keep
@SuppressWarnings("unused")
private void setRenderMode(final int aMode) {
runOnUiThread(this::setImmersiveSticky);
}
private void setRenderMode(final int aMode) {}

private native void activityCreated(Object aAssetManager);
private native void updateViewport(int width, int height);
Expand Down
4 changes: 4 additions & 0 deletions app/src/visionglass/res/color/bg_button_checkable.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/azure" android:state_checked="true" />
<item android:color="@color/ocean" />
</selector>
8 changes: 8 additions & 0 deletions app/src/visionglass/res/drawable/ff_logo_icon_48.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="48dp"
android:height="48dp"
android:drawable="@drawable/ff_logo"
android:gravity="fill" />
</layer-list>
8 changes: 8 additions & 0 deletions app/src/visionglass/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#040615"
android:endColor="#283073"
android:angle="90"/>
</shape>
15 changes: 15 additions & 0 deletions app/src/visionglass/res/drawable/touchpad_ripple_bg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/azure">
<item
android:id="@android:id/mask"
android:drawable="@android:color/white" />
<item>
<selector>
<item
android:drawable="@color/silver"
android:state_pressed="true" />
<item android:drawable="@color/silver" />
</selector>
</item>
</ripple>
Loading