Commit 010dce34 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Remove workaround for GVR UI not updating when S8 resolution changes.

The GVR bugs have been fixed, we can remove our workaround.

Workaround was added in
https://chromium-review.googlesource.com/c/chromium/src/+/682107

Bug: 769005
Change-Id: I2ff8edc388de04fa2c4f662406ab7687c13eb88e
Reviewed-on: https://chromium-review.googlesource.com/775864
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarYash Malik <ymalik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517461}
parent bbac322d
...@@ -85,9 +85,4 @@ public interface VrShell { ...@@ -85,9 +85,4 @@ public interface VrShell {
* Triggers VrShell to navigate backward. * Triggers VrShell to navigate backward.
*/ */
void navigateBack(); void navigateBack();
/**
* Should be called when the density changes. Updates UI in response to the new density.
*/
void onDensityChanged(float oldDpi, float newDpi);
} }
...@@ -430,7 +430,6 @@ public class VrShellDelegate ...@@ -430,7 +430,6 @@ public class VrShellDelegate
return true; return true;
} }
if (sInstance.mInVr || sInstance.mDonSucceeded) { if (sInstance.mInVr || sInstance.mDonSucceeded) {
sInstance.onDensityChangedInternal(oldDpi, newDpi);
sInstance.mDensityChanged = true; sInstance.mDensityChanged = true;
return true; return true;
} }
...@@ -1625,10 +1624,6 @@ public class VrShellDelegate ...@@ -1625,10 +1624,6 @@ public class VrShellDelegate
decor.removeView(mVrShell.getContainer()); decor.removeView(mVrShell.getContainer());
} }
private void onDensityChangedInternal(float oldDpi, float newDpi) {
if (mVrShell != null) mVrShell.onDensityChanged(oldDpi, newDpi);
}
/** /**
* Clean up VrShell, and associated native objects. * Clean up VrShell, and associated native objects.
*/ */
......
...@@ -14,12 +14,8 @@ import android.view.Surface; ...@@ -14,12 +14,8 @@ import android.view.Surface;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewTreeObserver.OnPreDrawListener; import android.view.ViewTreeObserver.OnPreDrawListener;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import com.google.vr.ndk.base.AndroidCompat; import com.google.vr.ndk.base.AndroidCompat;
import com.google.vr.ndk.base.GvrLayout; import com.google.vr.ndk.base.GvrLayout;
...@@ -657,46 +653,6 @@ public class VrShellImpl ...@@ -657,46 +653,6 @@ public class VrShellImpl
return this; return this;
} }
@Override
public void onDensityChanged(float oldDpi, float newDpi) {
// TODO(mthiesse, crbug.com/767603): Remove this workaround for b/66493165.
// This is extremely hacky. The GvrUiLayout doesn't update in response to density changes,
// so we manually go in and scale their elements to be the correct size (though due to the
// scaling they don't actually look pixel-perfectly identical to what they should be).
// These elements are dynamically loaded and inserted into the view hierarchy so we don't
// have IDs for them that we can look up.
try {
float scale = newDpi / oldDpi;
ViewGroup gvrLayoutImpl = (ViewGroup) getContainer().getChildAt(0);
RelativeLayout relativeLayout = (RelativeLayout) gvrLayoutImpl.getChildAt(1);
ImageButton x_button = (ImageButton) relativeLayout.getChildAt(0);
RelativeLayout alignment_marker = (RelativeLayout) relativeLayout.getChildAt(1);
ImageButton settings_button = (ImageButton) relativeLayout.getChildAt(2);
ViewGroup.LayoutParams params = alignment_marker.getLayoutParams();
params.width = (int) (params.width * scale);
params.height = (int) (params.height * scale);
alignment_marker.setLayoutParams(params);
int padding = (int) (x_button.getPaddingLeft() * scale);
x_button.setImageDrawable(x_button.getDrawable().getConstantState().newDrawable(
mActivity.getResources()));
x_button.setPadding(padding, padding, padding, padding);
settings_button.setImageDrawable(
settings_button.getDrawable().getConstantState().newDrawable(
mActivity.getResources()));
settings_button.setPadding(padding, padding, padding, padding);
} catch (Throwable e) {
// Ignore any errors. We're working around a bug in dynamically loaded code, so if it
// goes wrong that means the loaded code changed. ¯\_(ツ)_/¯
// In the worst case the close and settings buttons won't be drawn for the correct
// density.
}
}
@Override @Override
public void surfaceCreated(SurfaceHolder holder) { public void surfaceCreated(SurfaceHolder holder) {
nativeSetSurface(mNativeVrShell, holder.getSurface()); nativeSetSurface(mNativeVrShell, holder.getSurface());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment