Code Monkey home page Code Monkey logo

glance-experimental-tools's Introduction

Glance Experimental Tools

🚧 Work in-progress: this library is under heavy development, APIs might change frequently

This project aims to supplement Jetpack Glance with features that are commonly required by developers but not yet available.

It is a labs like environment for Glance tooling. We use it to help fill known gaps in the framework, experiment with new APIs and to gather insight into the development experience of developing a Glance library.

Libraries

A simple composable to display RemoteViews inside your app or in @Previews enabling "Live Edits" or "Apply Changes".

A debug tool to view and interact with AppWidget snapshots embedded inside the app.

An activity to host a Glance composable for screenshot testing, without binding the entire appWidget.

A Material3 Scaffold implementation for appwidget configuration activities.

Future?

Any of the features available in this group of libraries may become obsolete in the future, at which point they will (probably) become deprecated.

We will aim to provide a migration path (where possible), to whatever supersedes the functionality.

Why a separate repository?

We want to iterate, explore and experiment with some new APIs and tooling more freely, without adding overhead to the main API and avoid API commitments. In addition, some of these features might not be allowed in AndroidX.

Note: this repository follows the Accompanist pattern but in a much more narrow scope (read more about the idea behind this pattern here)

Contributions

Please contribute! We will gladly review any pull requests. Make sure to read the Contributing page first though.

License

Copyright 2020 The Android Open Source Project
 
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

glance-experimental-tools's People

Contributors

marcelpinto avatar secondsun avatar shamalip avatar w-v-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

glance-experimental-tools's Issues

Parameter specified as non-null is null - rememberModalBottomSheetState

Hi, I have this bug with "com.google.android.glance.tools:appwidget-viewer:0.2.2" with this librairies :

  • Compose/compose material 1.4.3
  • Kotlin 1.10.1

FATAL EXCEPTION: main
Process: incubator.skoot_app_android, PID: 2922
java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.compose.material.ModalBottomSheetKt.rememberModalBottomSheetState, parameter confirmStateChange
at androidx.compose.material.ModalBottomSheetKt.rememberModalBottomSheetState(Unknown Source:9)
at com.google.android.glance.tools.viewer.ui.ViewerScreenKt.ViewerScreen-_ngmBi8(ViewerScreen.kt:91)
at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:95)
at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:94)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:132)
at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:114)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material3.SurfaceKt.Surface-T9BRK9s(Surface.kt:111)
at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1.invoke(GlanceViewerActivity.kt:91)
at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1.invoke(GlanceViewerActivity.kt:90)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material3.TextKt.ProvideTextStyle(Text.kt:360)
at androidx.compose.material3.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)
at androidx.compose.material3.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.material3.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:73)
at com.google.android.glance.tools.viewer.ui.theme.ThemeKt.ViewerTheme(Theme.kt:70)
at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1.invoke(GlanceViewerActivity.kt:90)
at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1.invoke(GlanceViewerActivity.kt:89)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:428)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:194)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:123)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:122)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:114)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:156)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:155)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:155)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:140)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3373)
at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:3363)
at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source:1)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3363)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3298)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:587)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:966)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1099)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:131)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:181)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:138)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:131)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1174)
at android.view.View.dispatchAttachedToWindow(View.java:21290)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3491)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2820)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2328)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9087)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
at android.view.Choreographer.doCallbacks(Choreographer.java:899)
at android.view.Choreographer.doFrame(Choreographer.java:832)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Feature Request - Add Demo on how to have tile that can be configured from an activity

Hi, I'm currently using Glance for wear tiles (version 1.0.0-alpha04) but I'm really struggling to develop a tile that can be configured from another activity.

Imaging you have a tile where you show the current balance (money) from a given subscription. The user can have more than one subscription.

The idea is:

  • The user adds the tile which initially shows a message explaining that he needs to choose first the subscription to be displayed. This means that when the tile is clicked it should launch an activity where the user can do the selection.

Issues I found:

NPE when running app widget viewer activity: parameter confirmStateChange

Describe the bug

Trying to run the AppWidget Viewer as described here: https://github.com/google/glance-experimental-tools/tree/main/appwidget-viewer fails with the error below:

FATAL EXCEPTION: main
                                                                                                    Process: io.flaxoos.lineup, PID: 18602
                                                                                                    java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.compose.material.ModalBottomSheetKt.rememberModalBottomSheetState, parameter confirmStateChange
                                                                                                    	at androidx.compose.material.ModalBottomSheetKt.rememberModalBottomSheetState(Unknown Source:9)
                                                                                                    	at com.google.android.glance.tools.viewer.ui.ViewerScreenKt.ViewerScreen-_ngmBi8(ViewerScreen.kt:91)
                                                                                                    	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:95)
                                                                                                    	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:94)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:132)
                                                                                                    	at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:114)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
                                                                                                    	at androidx.compose.material3.SurfaceKt.Surface-T9BRK9s(Surface.kt:111)
                                                                                                    	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1.invoke(GlanceViewerActivity.kt:91)
                                                                                                    	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1.invoke(GlanceViewerActivity.kt:90)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
                                                                                                    	at androidx.compose.material3.TextKt.ProvideTextStyle(Text.kt:360)
                                                                                                    	at androidx.compose.material3.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:81)
                                                                                                    	at androidx.compose.material3.MaterialThemeKt$MaterialTheme$1.invoke(MaterialTheme.kt:80)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
                                                                                                    	at androidx.compose.material3.MaterialThemeKt.MaterialTheme(MaterialTheme.kt:73)
                                                                                                    	at com.google.android.glance.tools.viewer.ui.theme.ThemeKt.ViewerTheme(Theme.kt:70)
                                                                                                    	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1.invoke(GlanceViewerActivity.kt:90)
                                                                                                    	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1.invoke(GlanceViewerActivity.kt:89)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:428)
                                                                                                    	at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:252)
                                                                                                    	at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:251)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
                                                                                                    	at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:195)
                                                                                                    	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:119)
                                                                                                    	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:118)
2023-12-18 12:25:13.034 18602-18602 AndroidRuntime          io.flaxoos.lineup                    E  	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
                                                                                                    	at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:110)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:158)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$2.invoke(Wrapper.android.kt:157)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:228)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:157)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:142)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
                                                                                                    	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
                                                                                                    	at androidx.compose.runtime.ActualJvm_jvmKt.invokeComposable(ActualJvm.jvm.kt:78)
                                                                                                    	at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3340)
                                                                                                    	at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:3273)
                                                                                                    	at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:588)
                                                                                                    	at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1013)
                                                                                                    	at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:520)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
                                                                                                    	at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1191)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:133)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:183)
                                                                                                    	at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
                                                                                                    	at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
                                                                                                    	at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
                                                                                                    	at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:1266)
                                                                                                    	at android.view.View.dispatchAttachedToWindow(View.java:21980)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3490)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
                                                                                                    	at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3497)
                                                                                                    	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3014)
                                                                                                    	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2465)
                                                                                                    	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9305)
                                                                                                    	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1339)
                                                                                                    	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348)
                                                                                                    	at android.view.Choreographer.doCallbacks(Choreographer.java:952)
                                                                                                    	at android.view.Choreographer.doFrame(Choreographer.java:882)
                                                                                                    	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:958)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
2023-12-18 12:25:13.034 18602-18602 AndroidRuntime          io.flaxoos.lineup                    E  	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

To Reproduce

Steps to reproduce the behavior:

        <activity android:name="io.flaxoos.lineapp.widget.LineAppWidgetViewerActivity" android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
@OptIn(ExperimentalGlanceRemoteViewsApi::class)
class LineAppWidgetViewerActivity : GlanceViewerActivity() {

    override suspend fun getGlanceSnapshot(
        receiver: Class<out GlanceAppWidgetReceiver>
    ): GlanceSnapshot {
        val snapshotSerializer: Json = Json
        val instance = LineAppWidget()
        val state = preferencesOf(
            stringPreferencesKey(eventKey) to snapshotSerializer.encodeToString(
                Event.serializer(), testEvent()
            )
        )
        return when (receiver) {
            LineAppWidgetReceiver::class.java -> GlanceSnapshot(
                instance = instance,
                state = state
            )
            else -> throw IllegalArgumentException()
        }
    }

    override fun getProviders() = listOf(LineAppWidgetReceiver::class.java)
}
<component name="ProjectRunConfigurationManager">
  <configuration default="false" name="DebugLineappWidget" type="AndroidRunConfigurationType" factoryName="Android App" singleton="true">
    <module name="Lineup.composeApp.main" />
    <option name="DEPLOY" value="true" />
    <option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
    <option name="DEPLOY_AS_INSTANT" value="false" />
    <option name="ARTIFACT_NAME" value="" />
    <option name="PM_INSTALL_OPTIONS" value="" />
    <option name="ALL_USERS" value="false" />
    <option name="ALWAYS_INSTALL_WITH_PM" value="false" />
    <option name="CLEAR_APP_STORAGE" value="false" />
    <option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
    <option name="ACTIVITY_EXTRA_FLAGS" value="" />
    <option name="MODE" value="specific_activity" />
    <option name="CLEAR_LOGCAT" value="false" />
    <option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
    <option name="INSPECTION_WITHOUT_ACTIVITY_RESTART" value="false" />
    <option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
    <option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
    <option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
    <option name="DEBUGGER_TYPE" value="Auto" />
    <Auto>
      <option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
      <option name="SHOW_STATIC_VARS" value="true" />
      <option name="WORKING_DIR" value="" />
      <option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
      <option name="SHOW_OPTIMIZED_WARNING" value="true" />
      <option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
      <option name="DEBUG_SANDBOX_SDK" value="false" />
    </Auto>
    <Hybrid>
      <option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
      <option name="SHOW_STATIC_VARS" value="true" />
      <option name="WORKING_DIR" value="" />
      <option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
      <option name="SHOW_OPTIMIZED_WARNING" value="true" />
      <option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
      <option name="DEBUG_SANDBOX_SDK" value="false" />
    </Hybrid>
    <Java>
      <option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
      <option name="DEBUG_SANDBOX_SDK" value="false" />
    </Java>
    <Native>
      <option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
      <option name="SHOW_STATIC_VARS" value="true" />
      <option name="WORKING_DIR" value="" />
      <option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
      <option name="SHOW_OPTIMIZED_WARNING" value="true" />
      <option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
      <option name="DEBUG_SANDBOX_SDK" value="false" />
    </Native>
    <Profilers>
      <option name="ADVANCED_PROFILING_ENABLED" value="false" />
      <option name="STARTUP_PROFILING_ENABLED" value="false" />
      <option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
      <option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="Java/Kotlin Method Sample (legacy)" />
      <option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
      <option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
    </Profilers>
    <option name="DEEP_LINK" value="" />
    <option name="ACTIVITY_CLASS" value="io.flaxoos.lineapp.widget.LineAppWidgetViewerActivity" />
    <option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
    <option name="SKIP_ACTIVITY_VALIDATION" value="false" />
    <method v="2">
      <option name="Android.Gradle.BeforeRunTask" enabled="true" />
    </method>
  </configuration>
</component>

build:

kotlin {
    jvmToolchain(libs.versions.java.get().toInt())
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = libs.versions.java.get()
            }
        }
    }

...

    sourceSets {

        androidMain.dependencies {
            // Compose
            implementation(libs.compose.ui)

            // AndroidX
            implementation(libs.androidx.splashscreen)
            implementation(libs.androidx.activity.compose)
            implementation(libs.androidx.startup.runtime)
            implementation(libs.androidx.work.runtime)

            // Glance
            implementation(libs.glance)
            implementation(libs.glance.appwidget)
            implementation(libs.glance.material3)

            val composeBom =
                project.dependencies.platform("androidx.compose:compose-bom:2023.10.01")
            implementation(composeBom)
        }

...

android {
    namespace = "io.flaxoos.lineup"
    compileSdk = libs.versions.android.compileSdk.get().toInt()

    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    sourceSets["main"].res.srcDirs("src/androidMain/res")
    sourceSets["main"].resources.srcDirs("src/commonMain/resources")

    defaultConfig {
        applicationId = "io.flaxoos.lineup"
        minSdk = libs.versions.android.minSdk.get().toInt()
        targetSdk = libs.versions.android.targetSdk.get().toInt()
        versionCode = 1
        versionName = "1.0"
    }
    buildFeatures {
        compose = true
        viewBinding = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
    }
    dependencies {
        testImplementation(libs.androidx.test.uiautomator)
        debugImplementation(libs.compose.ui.tooling)
        debugImplementation(libs.compose.ui.tooling.preview)
        debugImplementation(libs.glance.appwidget.viewer)
    }
androidx-glance = "1.0.0"
glance-ex-tools = "0.2.2"

glance = { module = "androidx.glance:glance", version.ref = "androidx-glance" }
glance-material3 = { module = "androidx.glance:glance-material3", version.ref = "androidx-glance" }
glance-appwidget = { module = "androidx.glance:glance-appwidget", version.ref = "androidx-glance" }
glance-appwidget-viewer = { module = "com.google.android.glance.tools:appwidget-viewer", version.ref = "glance-ex-tools" }
glance-appwidget-configuration = { module = "com.google.android.glance.tools:appwidget-configuration", version.ref = "glance-ex-tools" }

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots?

If applicable, add screenshots to help explain your problem.

Environment:

Android Studio Hedgehog | 2023.1.1
Build #AI-231.9392.1.2311.11076708, built on November 9, 2023
Runtime version: 17.0.7+0-17.0.7b1000.6-10550314 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.4
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Metal Rendering is ON
Registry:
    external.system.auto.import.disabled=true
    debugger.new.tool.window.layout=true
    ide.text.editor.with.preview.show.floating.toolbar=false
    ide.experimental.ui=true
    ide.images.show.chessboard=true

Non-Bundled Plugins:
    com.c5inco.modifiers (1.0.14)
    com.levinzonr.arch.jetpackcompose.plugin (1.1.0)
    com.codeium.intellij (1.4.22)
    com.ivyapps.composehammer (2023.10.11)
    com.google.d2c.androidstudio.plugin (0.3.10-hotfix)
    com.mistamek.drawablepreview.drawable-preview (1.1.6)
    org.jetbrains.compose.desktop.ide (1.5.11)
    com.suusan2go.kotlin-fill-class (1.0.22)
    ru.ztrap.plugin.idea.compose-color-preview (0.0.1)
    com.thelumiereguy.compose_helper (2.0.4)

Additional context

Add any other context about the problem here.

Support Glance beta01 API breaking changes

Describe the bug

AppWidgetConfigurationScaffold crashes with androidx.glance:glance-*:1.0.0-beta01. Content() function of GlanceAppWidget got deprecated and AppWidgetConfigurationScaffold is trying to call that function.

"Updated GlanceAppWidget to use provideGlance as the main entrypoint. GlanceAppWidget.Content is now deprecated. "

Environment:

  • androidx.glance:glance-*:1.0.0-beta01
  • Glance Experimental Tools version: 0.2.2

Unclear import for GlanceViewerActivity

Describe the bug

Unclear what the import should be for "value" in the GlanceViewerActivity sample code

To Reproduce

Steps to reproduce the behavior:

  1. Copy-paste the activity code from https://github.com/google/glance-experimental-tools/tree/main/appwidget-viewer
  2. A single auto-import suggestion is given for value in state = mutablePreferencesOf(intPreferencesKey("state") to value).
    This import is import androidx.compose.foundation.gestures.ModifierLocalScrollableContainerProvider.value, which doesn't seem correct and does not compile.

Expected behavior

Ain import which compiles

Environment:

  • using glance 1.0.0-alpha05 of glance
  • using 0.2.2 of appwidget-viewer

[appwidget-host] Improve compatibility with PagerApi

Describe the bug

Render GlanceAppWidgetHostPreview on the page element of Pager, nothing appears on the page it was hidden.
However, when I manually click on the element, it seems to reappear when the updateContent() specified for clickable is called.

To Reproduce

use GlanceAppWidgetHostPreview in HorizontalPager's page content

HorizontalPager(
            ...
        ) { page ->
            GlanceAppWidgetHostPreview()
}
screen-20221010-185355_2.mp4

Expected behavior

From the above event, I know that could display it by manually calling updateContent().
So I delayed updateContent() by 100 millis when it was mounted, and the element was always displayed before and after paging.

glance-experimental-tools/GlanceAppWidgetHostPreview.kt at b903edb88c898ca36c4a1b5099c2ebebd32ec6c9 · google/glance-experimental-tools

 if (hostState.isReady) {
   LaunchedEffect(hostState.value) {
+    delay(100)
     updateContent()
  }
}
screen-20221010-185448_2.mp4

Environment:

compose_version = '1.2.1'
androidx.glance:glance-appwidget:1.0.0-alpha04
com.google.android.glance.tools:appwidget-configuration:0.2.2
com.google.accompanist:accompanist-pager:0.26.5-rc

java.lang.NoSuchMethodError: No virtual method Content

The exception is being thowed here:

@ExperimentalGlanceRemoteViewsApi
private suspend fun GlanceAppWidget.compose(
context: Context,
size: DpSize,
state: Any?
): RemoteViews = glanceRemoteViews.compose(
context = context,
size = size,
state = state,
content = { Content() }
).remoteViews

here is my widget:
object NoteWidget : GlanceAppWidget() {

override val stateDefinition: GlanceStateDefinition<*> = PreferencesGlanceStateDefinition
override suspend fun provideGlance(context: Context, id: GlanceId) {
    provideContent {
        GlanceTheme(colors =MyAppWidgetGlanceColorScheme.colors) { /* a normal content */ } 
}

}

the exception appears as soon as the user try to add a widget and the configuration activity is launched

Environment:

  • Android OS version: 14
  • Device:Resizable expermental api 34
  • Glance Experimental Tools version: 0.2.2

[AppWidget Viewer] NoSuchMethodError: No static method ModalBottomSheetLayout

Describe the bug

The project is currently using outdated version of many dependencies, including Compose and Glance.
This is causing crashes like the following:

 java.lang.NoSuchMethodError: No static method ModalBottomSheetLayout-BzaUkTc(Lkotlin/jvm/functions/Function3;Landroidx/compose/ui/Modifier;Landroidx/compose/material/ModalBottomSheetState;Landroidx/compose/ui/graphics/Shape;FJJJLkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;II)V in class Landroidx/compose/material/ModalBottomSheetKt; or its super classes (declaration of 'androidx.compose.material.ModalBottomSheetKt' appears in /data/app/com.leinardi.ubuntucountdownwidget.debug-1/base.apk)
 	at com.google.android.glance.tools.viewer.ui.ViewerScreenKt.ViewerScreen-_ngmBi8(ViewerScreen.kt:118)
 	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:95)
 	at com.google.android.glance.tools.viewer.AppWidgetViewerActivity$onCreate$1$1$1.invoke(GlanceViewerActivity.kt:94)
 	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:108)
 	at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
 	at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:133)
 	at androidx.compose.material3.SurfaceKt$Surface$1.invoke(Surface.kt:114)
[...]

To Reproduce

Steps to reproduce the behavior:

  1. Use the viewer library with the latest version of Compose and Material 3.

Expected behavior

The viewer should work as expected

Environment:

  • Android OS version: API 24
  • Device: Emulator
  • Glance Experimental Tools version: 0.2.2

Additional context

I would be happy to work on a PR that bumps the dependencies but, before investing effort on it, I would like to have a confirmation that it would be appreciated and merged if successful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.