Open ManuelTS opened 6 years ago
Thanks for the detailed explanation of what you are trying to do and the issues you encountered! ViewRenderable works with the View hierarchy, and as you noticed, Preferences are not view based, so they do not work. So for now, if you want to use Preferences in the scene, you'll need to create your own layout and then populate the layout with your preferences. I have not tried, but you might be able to use PreferenceFragmentCompat to inflate it and pass the listview from the fragment to the viewRenderable?
I'll pass along the request to support Preferences directly.
Using com.android.support:preference-v7:27.1.1
I get
08-11 14:34:49.843 6713-6713/at.mts.arnatomy.app E/ViewRenderable: Unable to load Renderable registryId='null'
java.lang.AssertionError: ViewRenderable must have a source.
at com.google.ar.sceneform.rendering.ViewRenderable$Builder.checkPreconditions(ViewRenderable.java:509)
at com.google.ar.sceneform.rendering.Renderable$Builder.build(Renderable.java:305)
at com.google.ar.sceneform.rendering.ViewRenderable$Builder.build(ViewRenderable.java:470)
at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:70)
at at.mts.arnatomy.controller.ar.renderable.PreferencesView.<init>(PreferencesView.java:22)
at at.mts.arnatomy.controller.ar.renderable.BaseView.build(BaseView.java:96)
at at.mts.arnatomy.controller.ar.ARnatomyFragment.onFling(ARnatomyFragment.java:147)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:655)
at android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480)
at android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543)
at at.mts.arnatomy.controller.ar.ARnatomyFragment.onPeekTouch(ARnatomyFragment.java:103)
at com.google.ar.sceneform.TouchEventSystem.onTouchEvent(Unknown Source:42)
at com.google.ar.sceneform.Scene.onTouchEvent(Unknown Source:11)
at com.google.ar.sceneform.SceneView.onTouchEvent(Unknown Source:9)
at android.view.View.dispatchTouchEvent(View.java:11788)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:599)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1839)
at android.app.Activity.dispatchTouchEvent(Activity.java:3334)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:550)
at android.view.View.dispatchPointerEvent(View.java:12027)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4809)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4623)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4307)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4364)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6682)
08-11 14:34:49.844 6713-6713/at.mts.arnatomy.app E/ViewRenderable: at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6656)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6617)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6785)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
08-11 14:34:49.866 6713-6713/at.mts.arnatomy.app W/System.err: java.util.concurrent.CompletionException: java.lang.AssertionError: ViewRenderable must have a source.
08-11 14:34:49.867 6713-6713/at.mts.arnatomy.app W/System.err: at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:294)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:310)
08-11 14:34:49.868 6713-6713/at.mts.arnatomy.app W/System.err: at java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:655)
at java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:677)
at java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2023)
08-11 14:34:49.869 6713-6713/at.mts.arnatomy.app W/System.err: at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:71)
at at.mts.arnatomy.controller.ar.renderable.PreferencesView.<init>(PreferencesView.java:22)
08-11 14:34:49.870 6713-6713/at.mts.arnatomy.app W/System.err: at at.mts.arnatomy.controller.ar.renderable.BaseView.build(BaseView.java:96)
at at.mts.arnatomy.controller.ar.ARnatomyFragment.onFling(ARnatomyFragment.java:147)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:655)
at android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480)
08-11 14:34:49.871 6713-6713/at.mts.arnatomy.app W/System.err: at android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543)
at at.mts.arnatomy.controller.ar.ARnatomyFragment.onPeekTouch(ARnatomyFragment.java:103)
at com.google.ar.sceneform.TouchEventSystem.onTouchEvent(Unknown Source:42)
at com.google.ar.sceneform.Scene.onTouchEvent(Unknown Source:11)
at com.google.ar.sceneform.SceneView.onTouchEvent(Unknown Source:9)
08-11 14:34:49.872 6713-6713/at.mts.arnatomy.app W/System.err: at android.view.View.dispatchTouchEvent(View.java:11788)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
08-11 14:34:49.873 6713-6713/at.mts.arnatomy.app W/System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
08-11 14:34:49.874 6713-6713/at.mts.arnatomy.app W/System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2979)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2668)
08-11 14:34:49.875 6713-6713/at.mts.arnatomy.app W/System.err: at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:599)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1839)
at android.app.Activity.dispatchTouchEvent(Activity.java:3334)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:68)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:550)
at android.view.View.dispatchPointerEvent(View.java:12027)
08-11 14:34:49.876 6713-6713/at.mts.arnatomy.app W/System.err: at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4809)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4623)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
08-11 14:34:49.877 6713-6713/at.mts.arnatomy.app W/System.err: at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4307)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
08-11 14:34:49.877 6713-6713/at.mts.arnatomy.app W/System.err: at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4364)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
08-11 14:34:49.878 6713-6713/at.mts.arnatomy.app W/System.err: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6682)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6656)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6617)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6785)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187)
at android.os.MessageQueue.nativePollOnce(Native Method)
08-11 14:34:49.879 6713-6713/at.mts.arnatomy.app W/System.err: at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6501)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
08-11 14:34:49.880 6713-6713/at.mts.arnatomy.app W/System.err: Caused by: java.lang.AssertionError: ViewRenderable must have a source.
08-11 14:34:49.881 6713-6713/at.mts.arnatomy.app W/System.err: at com.google.ar.sceneform.rendering.ViewRenderable$Builder.checkPreconditions(ViewRenderable.java:509)
at com.google.ar.sceneform.rendering.Renderable$Builder.build(Renderable.java:305)
at com.google.ar.sceneform.rendering.ViewRenderable$Builder.build(ViewRenderable.java:470)
at at.mts.arnatomy.controller.ar.renderable.BaseView.<init>(BaseView.java:70)
... 56 more
again on .build()
when i use
PreferencesView.PrefsFragment pf = new PreferencesView.PrefsFragment();
ViewRenderable.builder()
.setSizer(new DpToMetersViewSizer(dp2MeterScale))
.setView(context, pf.getListView())
.build()
.thenAccept(r -> {
this.renderable = r;
renderable.setShadowCaster(false);
renderable.setShadowReceiver(false);})
.thenRun(()-> onAfterLoad())
.exceptionally(t -> {
Toast.makeText(context, "Unable to load view renderable", Toast.LENGTH_LONG).show();
t.printStackTrace();
return null;
});
Where PrefsFragment
is exactly implemented in PreferenceView
as in the docs:
public static class PrefsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
// Load the preferences from an XML resource
setPreferencesFromResource(R.xml.preferences, rootKey);
}
}
I want to create an ARCore app as immersive as possible. This encompasses also Android settings of an app implemented in accordance to its material design. I tried to use a minimalist settings implementation to try it, res/xml/preferences.xml is:
which gets loaded as the example code in Create Renderables#Create from Android widgets. I get the following exceptions:
Where
points to the
.build()
ofMy conclusion is I have to implement the AR settings of my app on my own with standard Android components since AR Core does not support PreferenceScreen. As a feature request, will be AR core rendering of PreferenceScreen and all involved classes supported at all, and if yes when?