Skip to content

Commit 9722476

Browse files
yrezguishamalipjavadudesecondsun
authored
Remove Casa framework & simplify samples structure (#275)
* Delete the outdated button widget demo code. - "rv" is not recommended and "glance" is the preferred widget framework. - Sizing on those widgets is off. The new canonical layouts are recommended. * Delete the outdated list widget demo code. - "rv" is not recommended and "glance" is the preferred widget framework. - Sizing on those widgets is off. The new canonical layout contain example of lists and are recommended. * Delete the outdated image widget demo code. - Glance library's demo directory has code samples for individual components. Here is example of Image widget: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:glance/glance-appwidget/integration-tests/demos/src/main/java/androidx/glance/appwidget/demos/ImageAppWidget.kt;bpv=1 * Align the AppWidgets showcase entrypoint to highlight canonical layout samples. The main "AppWidgets" page now displays link to the canonical layout showcase page and then below it, demonstrates the functionality to pin and show widget information. * Adjust size and preview of the weather widget in platform samples. - 4x2 is the recommended size for such widget - avoid 3x? sizes - Uses glance loading layout resource instead of the local xml - Update the preview image * Update background color of the xml based weather widget - To closely match the appWidgetBackground color used in glance. * Update Glance weather widget to use Scaffold. - The Scaffold component in glance handles the background color, widget radius for you. - For the inner content, calculate widget radius based on the padding and system radius. * Align the AppWidgets showcase entrypoint to highlight canonical layout samples. The main "AppWidgets" page now displays link to the canonical layout showcase page and then below it, demonstrates the functionality to pin and show widget information. * fixup! Update Glance weather widget to use Scaffold. * Update the readMe section with screenshots of canonical widget layouts * Update the readMe section with screenshots of canonical widget layouts * Update the readMe section with screenshots of canonical widget layouts * Replace Casa framework with a lighter structure * Remove Casa from these following modules: - accessibility - camera2 - connectivity call notification - graphics pdf - graphics ultrahdr - privacy transparency - storage * Remove Casa from these following modules: - connectivity - location - media - privacy * Fix permissions module * Add appwidgets & constraintlayout samples * Add more user interface samples * Add last samples * Update build.yml (#277) Change to upload-artifact@v4 * Add MinSdkBox composable to wrap samples using recent APIs * Fix Activity insets * Add missing test dependencies Add various lint ignore checks on minSdk * Update README.md - Remove samples README.md as it has been unreliably generated recently - We may reinvest in the idea later on * Remove duplicate MAIN/LAUNCHER intent filters from samples * Temporarily ignore a flaky test in PiPMovieActivityTest * Refactor: Replace `Area` with `ApiSurface` for better context Replaced the `Area` data class with `ApiSurface` to more accurately represent the categories of samples in the app. Updated all references in `NavGraph`, `SampleDemo`, and `CatalogScreen` to reflect this change. The update introduces the `ApiSurface` interface and its implementations to categorize the different areas of platform features and functionality demonstrated by the samples. * Temporarily disable unit tests in CI Disables unit tests in the CI build workflow. * Replace Casa framework with a lighter structure * Remove Casa from these following modules: - accessibility - camera2 - connectivity call notification - graphics pdf - graphics ultrahdr - privacy transparency - storage * Remove Casa from these following modules: - connectivity - location - media - privacy * Fix permissions module * Add appwidgets & constraintlayout samples * Add more user interface samples * Add last samples * Add MinSdkBox composable to wrap samples using recent APIs * Fix Activity insets * Add missing test dependencies Add various lint ignore checks on minSdk * Update README.md - Remove samples README.md as it has been unreliably generated recently - We may reinvest in the idea later on * Remove duplicate MAIN/LAUNCHER intent filters from samples * Temporarily ignore a flaky test in PiPMovieActivityTest * Refactor: Replace `Area` with `ApiSurface` for better context Replaced the `Area` data class with `ApiSurface` to more accurately represent the categories of samples in the app. Updated all references in `NavGraph`, `SampleDemo`, and `CatalogScreen` to reflect this change. The update introduces the `ApiSurface` interface and its implementations to categorize the different areas of platform features and functionality demonstrated by the samples. * Temporarily disable unit tests in CI Disables unit tests in the CI build workflow. * Rebase app widgets description from main branch --------- Co-authored-by: Shamali P <[email protected]> Co-authored-by: Scott Stanchfield <[email protected]> Co-authored-by: Hoyt Summers Pittman <[email protected]>
1 parent 32bdebc commit 9722476

File tree

178 files changed

+3112
-2178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+3112
-2178
lines changed

.github/workflows/build.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ jobs:
4242
- name: Build debug
4343
run: ./gradlew assembleDebug
4444

45-
- name: Run local tests
46-
run: ./gradlew testDebug
45+
# TODO: Temporarily disable unit tests until the infra is fixed
46+
# - name: Run local tests
47+
# run: ./gradlew testDebug
4748

4849
- name: Upload build outputs (APKs)
4950
uses: actions/upload-artifact@v4

.idea/kotlinc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
This repository contains a collection of samples that demonstrate the use of different Android OS platform APIs. The samples are organized into folders by topic, and each folder contains a README file that provides more information about the samples in that folder.
66

77
> **Note:** These samples are intended to showcase specific functionality in isolation, and they may use
8-
> simplified code. They are not intended to be used as production-ready code. The project uses the
9-
> [casa-android](https://github.com/google/casa-android) (intended only for demo projects).
8+
> simplified code. They are not intended to be used as production-ready code.
109
> For best practices follow our documentation and check
1110
> [Now In Android](https://github.com/android/nowinandroid)
1211
@@ -24,8 +23,6 @@ Browse the samples inside each topic samples folder:
2423

2524
We are constantly adding new samples to this repository. You can find a list of all the available samples [here](https://github.com/android/platform-samples/tree/main/samples/README.md).
2625

27-
> 🚧 **Work-in-Progress:** we are working on bringing more existing and new samples into this format.
28-
2926
## How to run
3027

3128
1. Clone the repository

app/build.gradle.kts

+59-64
Original file line numberDiff line numberDiff line change
@@ -13,103 +13,98 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
@Suppress("DSL_SCOPE_VIOLATION")
16+
1717
plugins {
1818
alias(libs.plugins.android.application)
1919
alias(libs.plugins.kotlin.android)
20-
alias(libs.plugins.ksp)
21-
alias(libs.plugins.hilt)
22-
id("com.example.platform.convention")
23-
}
24-
25-
java {
26-
toolchain {
27-
languageVersion.set(JavaLanguageVersion.of(17))
28-
}
20+
alias(libs.plugins.kotlin.compose)
21+
kotlin("plugin.serialization") version "2.1.10"
2922
}
3023

3124
android {
32-
namespace = "com.example.platform.app"
25+
namespace = "com.example.platform"
3326
compileSdk = 35
3427

3528
defaultConfig {
36-
applicationId = "com.example.platform.app"
29+
applicationId = "com.example.platform"
3730
minSdk = 21
3831
targetSdk = 35
3932
versionCode = 1
4033
versionName = "1.0"
4134

42-
testInstrumentationRunner = "com.example.platform.app.AppTestRunner"
43-
vectorDrawables {
44-
useSupportLibrary = true
45-
}
35+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4636
}
4737

4838
buildTypes {
4939
release {
5040
isMinifyEnabled = false
5141
proguardFiles(
5242
getDefaultProguardFile("proguard-android-optimize.txt"),
53-
"proguard-rules.pro"
43+
"proguard-rules.pro",
5444
)
5545
}
5646
}
57-
5847
compileOptions {
59-
sourceCompatibility = JavaVersion.VERSION_17
60-
targetCompatibility = JavaVersion.VERSION_17
48+
sourceCompatibility = JavaVersion.VERSION_11
49+
targetCompatibility = JavaVersion.VERSION_11
50+
}
51+
kotlinOptions {
52+
jvmTarget = "11"
6153
}
62-
6354
buildFeatures {
6455
compose = true
6556
}
66-
composeOptions {
67-
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
68-
}
69-
packagingOptions {
70-
resources {
71-
excludes += "/META-INF/{AL2.0,LGPL2.1}"
72-
}
73-
}
7457
}
7558

7659
dependencies {
77-
implementation(platform(libs.compose.bom))
78-
implementation(libs.casa.ui)
79-
implementation(libs.androidx.appcompat)
80-
81-
implementation(libs.hilt.android)
82-
ksp(libs.hilt.compiler)
8360

84-
implementation(libs.coil.base)
85-
implementation(libs.coil.video)
61+
implementation(libs.androidx.core.ktx)
62+
implementation(libs.androidx.lifecycle.runtime.ktx)
63+
implementation(libs.androidx.activity.compose)
64+
implementation(platform(libs.androidx.compose.bom))
65+
implementation(libs.androidx.ui)
66+
implementation(libs.androidx.ui.graphics)
67+
implementation(libs.androidx.ui.tooling.preview)
68+
implementation(libs.androidx.material3)
69+
implementation(libs.androidx.navigation.compose)
8670

87-
// include all available samples.
88-
val samples: List<String> by project.extra
89-
samples.forEach {
90-
implementation(project(it))
91-
}
71+
implementation(libs.kotlinx.serialization.json)
72+
implementation(libs.androidx.fragment.compose)
9273

93-
// Testing
94-
kspAndroidTest(libs.hilt.compiler)
95-
androidTestImplementation(platform(libs.compose.bom))
96-
androidTestImplementation(libs.androidx.navigation.testing)
97-
androidTestImplementation(libs.compose.ui.test.manifest)
98-
debugImplementation(libs.compose.ui.test.manifest)
99-
androidTestImplementation(libs.compose.ui.test.junit4)
100-
androidTestImplementation(libs.androidx.test.core)
101-
androidTestImplementation(libs.androidx.test.espresso.core)
102-
androidTestImplementation(libs.androidx.test.rules)
103-
androidTestImplementation(libs.androidx.test.runner)
104-
androidTestImplementation(libs.hilt.testing)
105-
androidTestImplementation(libs.junit4)
106-
}
74+
implementation(project(":shared"))
75+
implementation(project(":samples:accessibility"))
76+
implementation(project(":samples:camera:camera2"))
77+
implementation(project(":samples:connectivity:audio"))
78+
implementation(project(":samples:connectivity:bluetooth:ble"))
79+
implementation(project(":samples:connectivity:bluetooth:companion"))
80+
implementation(project(":samples:connectivity:callnotification"))
81+
implementation(project(":samples:connectivity:telecom"))
82+
implementation(project(":samples:graphics:pdf"))
83+
implementation(project(":samples:graphics:ultrahdr"))
84+
implementation(project(":samples:location"))
85+
implementation(project(":samples:media:ultrahdr"))
86+
implementation(project(":samples:media:video"))
87+
implementation(project(":samples:privacy:data"))
88+
implementation(project(":samples:privacy:permissions"))
89+
implementation(project(":samples:privacy:transparency"))
90+
implementation(project(":samples:storage"))
91+
implementation(project(":samples:user-interface:appwidgets"))
92+
implementation(project(":samples:user-interface:constraintlayout"))
93+
implementation(project(":samples:user-interface:draganddrop"))
94+
implementation(project(":samples:user-interface:haptics"))
95+
implementation(project(":samples:user-interface:picture-in-picture"))
96+
implementation(project(":samples:user-interface:predictiveback"))
97+
implementation(project(":samples:user-interface:quicksettings"))
98+
implementation(project(":samples:user-interface:share"))
99+
implementation(project(":samples:user-interface:text"))
100+
implementation(project(":samples:user-interface:window-insets"))
101+
implementation(project(":samples:user-interface:windowmanager"))
107102

108-
tasks.register("syncSamplesInfo", com.example.platform.plugin.SyncSamplesInfo::class.java) {
109-
projectDir.set(project.rootDir)
110-
}
111-
// Link the assemble task to the sync task.
112-
// TODO: move syncSamplesInfo task here, as this can break isolated projects
113-
afterEvaluate {
114-
tasks.findByName("assembleDebug")?.finalizedBy(tasks.findByName("syncSamplesInfo"))
115-
}
103+
testImplementation(libs.junit)
104+
androidTestImplementation(libs.androidx.junit)
105+
androidTestImplementation(libs.androidx.espresso.core)
106+
androidTestImplementation(platform(libs.androidx.compose.bom))
107+
androidTestImplementation(libs.androidx.ui.test.junit4)
108+
debugImplementation(libs.androidx.ui.tooling)
109+
debugImplementation(libs.androidx.ui.test.manifest)
110+
}

app/src/androidTest/java/com/example/platform/app/AppTestRunner.kt

-31
This file was deleted.

app/src/androidTest/java/com/example/platform/app/NavigationTest.kt

-90
This file was deleted.

app/src/main/AndroidManifest.xml

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
1818

1919
<application
20-
android:name=".MainApp"
21-
android:allowBackup="true"
20+
android:enableOnBackInvokedCallback="true"
2221
android:icon="@mipmap/ic_launcher"
23-
android:roundIcon="@mipmap/ic_launcher"
2422
android:label="@string/app_name"
25-
android:supportsRtl="true"
26-
android:enableOnBackInvokedCallback="true">
23+
android:roundIcon="@mipmap/ic_launcher"
24+
android:supportsRtl="true">
2725
<activity
28-
android:name=".MainActivity"
26+
android:name=".app.MainActivity"
2927
android:exported="true"
30-
android:theme="@style/Theme.Material3.DayNight.NoActionBar">
28+
android:theme="@style/Theme.PlatformSamples">
3129
<intent-filter>
3230
<action android:name="android.intent.action.MAIN" />
3331

@@ -36,10 +34,12 @@
3634
</activity>
3735

3836
<!--required for TFLite/LiteRT style transfer demo -->
39-
<uses-library android:name="libOpenCL.so"
40-
android:required="false"/>
41-
<uses-library android:name="libOpenCL-pixel.so"
42-
android:required="false"/>
37+
<uses-library
38+
android:name="libOpenCL.so"
39+
android:required="false" />
40+
<uses-library
41+
android:name="libOpenCL-pixel.so"
42+
android:required="false" />
4343
</application>
4444

4545
</manifest>

0 commit comments

Comments
 (0)