Skip to content
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/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Removing this would otherwise cause a Manifest merger issue.
See https://developer.android.com/build/manage-manifests#merge_conflict_heuristics
-->
<uses-sdk tools:overrideLibrary="com.example.platform.storage, androidx.photopicker.compose, com.example.platform.connectivity.uwb" />
<uses-sdk tools:overrideLibrary="com.example.platform.storage, androidx.photopicker.compose, com.example.platform.connectivity.uwb, androidx.compose.remote.creation.compose, androidx.compose.remote.creation, androidx.compose.remote.core" />

<application
android:enableOnBackInvokedCallback="true"
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ playServicesMlkitBarcodeScanning = "18.3.1"
protobuf = "0.10.0"
firebaseCrashlyticsBuildtools = "3.0.7"
uwb = "1.0.0"
remoteCompose = "1.0.0-alpha20"
Comment thread
ashnohe marked this conversation as resolved.
telecom = "1.1.0-SNAPSHOT"


Expand Down Expand Up @@ -124,6 +125,9 @@ androidx-glance-appwidget = {group = "androidx.glance", name = "glance-appwidget
androidx-glance-preview = {group = "androidx.glance", name = "glance-preview", version.ref = "glance"}
androidx-glance-appwidget-preview = {group = "androidx.glance", name = "glance-appwidget-preview", version.ref = "glance"}
androidx-glance-material3 = {group = "androidx.glance", name = "glance-material3", version.ref = "glance"}
androidx-compose-remote-core = { group = "androidx.compose.remote", name = "remote-core", version.ref = "remoteCompose" }
androidx-compose-remote-creation = { group = "androidx.compose.remote", name = "remote-creation", version.ref = "remoteCompose" }
androidx-compose-remote-creation-compose = { group = "androidx.compose.remote", name = "remote-creation-compose", version.ref = "remoteCompose" }
androidx-graphics-core = { group = "androidx.graphics", name = "graphics-core", version = "1.0.4" }
androidx-startup = 'androidx.startup:startup-runtime:1.2.0'
androidx-window = { module = "androidx.window:window", version.ref = "androidx-window" }
Expand Down
5 changes: 5 additions & 0 deletions samples/user-interface/appwidgets/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ dependencies {
// For building appwidgets with Glance
implementation(libs.androidx.glance.appwidget)
implementation(libs.androidx.glance.material3)

// For building appwidgets with Remote Compose
implementation(libs.androidx.compose.remote.core)
implementation(libs.androidx.compose.remote.creation)
implementation(libs.androidx.compose.remote.creation.compose)
// Recommended to use WorkManager to load data for widgets
implementation(libs.androidx.work.runtime.ktx)
implementation(libs.material)
Expand Down
16 changes: 16 additions & 0 deletions samples/user-interface/appwidgets/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<manifest xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-sdk tools:overrideLibrary="androidx.compose.remote.creation.compose, androidx.compose.remote.creation, androidx.compose.remote.core" />

<uses-permission android:name="android.permission.INTERNET" />

<queries>
Expand Down Expand Up @@ -196,6 +198,20 @@
android:name="android.appwidget.provider"
android:resource="@xml/app_widget_weather_forecast_glance" />
</receiver>

<!-- Remote Compose Android Pet Widget -->
<receiver
android:name=".remote_compose.AndroidPetWidget"
android:exported="true"
android:label="@string/appwidget_android_pet_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="androidx.compose.remote.ACTION_CLICKED" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/android_pet_widget_info" />
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright 2026 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.
*/

package com.example.platform.ui.appwidgets.remote_compose

import android.annotation.SuppressLint
import android.appwidget.AppWidgetManager
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.remote.creation.compose.layout.RemoteAlignment
import androidx.compose.remote.creation.compose.layout.RemoteBox
import androidx.compose.remote.creation.compose.layout.RemoteComposable
import androidx.compose.remote.creation.compose.layout.RemoteText
import androidx.compose.remote.creation.compose.modifier.RemoteModifier
import androidx.compose.remote.creation.compose.modifier.background
import androidx.compose.remote.creation.compose.modifier.fillMaxSize
import androidx.compose.remote.creation.compose.state.rc
import androidx.compose.remote.creation.compose.state.rs
import androidx.compose.remote.creation.compose.widgets.RemoteComposeWidget
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

@SuppressLint("RestrictedApiAndroidX", "RestrictedApi")
class AndroidPetWidget : RemoteComposeWidget() {

@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
override fun onUpdate(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetIds: IntArray
) {
super.onUpdate(context, appWidgetManager, appWidgetIds)
appWidgetIds.forEach { id ->
widget.updateRemoteView(context, appWidgetManager, this, id, -1)
}
}

@SuppressLint("RestrictedApiAndroidX", "RestrictedApi")
@RemoteComposable
@Composable
override fun Content(context: Context, widgetId: Int) {
RemoteBox(
modifier = RemoteModifier.fillMaxSize().background(Color.White.rc),
contentAlignment = RemoteAlignment.Center
) {
RemoteText(
text = "Android Pet Coming Soon".rs,
color = Color.Black.rc
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2026 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.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:padding="16dp">

<TextView
android:id="@+id/fallback_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="@string/android_pet_widget_fallback_message"
android:textColor="@android:color/black"
android:textSize="14sp" />
</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<string name="glance_weather">Glance Weather</string>
<string name="app_widget_weather_description">Widget for weather forecast</string>
<string name="mostly_cloudy">Mostly cloudy</string>

<!-- Remote Compose Android Pet Widget -->
<string name="appwidget_android_pet_name">Android Pet</string>
<string name="android_pet_widget_description">An animated interactive pet widget powered by Remote Compose.</string>
<string name="android_pet_widget_fallback_message">Remote Compose widgets work on Android 17 and higher devices. Use an Android 17 device.</string>
Comment thread
ashnohe marked this conversation as resolved.
<!-- Common texts-->
<string name="sample_app_name">LayoutSamples</string>
<string name="sample_action_list_settings_label">Settings</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2026 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.
-->
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/android_pet_widget_description"
android:initialLayout="@layout/android_pet_widget_fallback"
android:minWidth="180dp"
android:minHeight="110dp"
android:previewImage="@drawable/sample_placeholder_image"
android:resizeMode="horizontal|vertical"
android:updatePeriodMillis="0"
android:widgetCategory="home_screen" />
Loading