Move Rally to the demos app
This is the only Material Study we have, and it is easier to
maintain one demo app for now.
Bug: 130636326
Test: build, run, open Rally and check all fine
Change-Id: Id019605034e35db96d52db0a73509daf9ad0c203
diff --git a/ui/integration-tests/demos/build.gradle b/ui/integration-tests/demos/build.gradle
index a9177f3..b774d67 100644
--- a/ui/integration-tests/demos/build.gradle
+++ b/ui/integration-tests/demos/build.gradle
@@ -14,6 +14,7 @@
implementation(project(":ui:ui-framework:integration-tests:ui-framework-demos"))
implementation(project(":ui:ui-layout:integration-tests:ui-layout-demos"))
implementation(project(":ui:ui-material:integration-tests:ui-material-demos"))
+ implementation(project(":ui:ui-material:integration-tests:ui-material-studies"))
implementation(project(":ui:ui-foundation:integration-tests:ui-foundation-demos"))
implementation(project(":ui:ui-text:integration-tests:ui-text-demos"))
implementation(KOTLIN_STDLIB)
diff --git a/ui/ui-material/integration-tests/material-studies/build.gradle b/ui/ui-material/integration-tests/material-studies/build.gradle
index 9423426..a3ee02a 100644
--- a/ui/ui-material/integration-tests/material-studies/build.gradle
+++ b/ui/ui-material/integration-tests/material-studies/build.gradle
@@ -15,15 +15,18 @@
*/
+import androidx.build.LibraryGroups
+import androidx.build.LibraryVersions
+import androidx.build.Publish
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import static androidx.build.dependencies.DependenciesKt.*
plugins {
id("AndroidXPlugin")
- id("com.android.application")
- id("org.jetbrains.kotlin.android")
+ id("com.android.library")
id("AndroidXUiPlugin")
+ id("org.jetbrains.kotlin.android")
}
dependencies {
@@ -54,3 +57,14 @@
}
}
}
+
+androidx {
+ name = "Compose Material Studies"
+ publish = Publish.NONE
+ // b/142788501: Set toolingProject to true so Dokka does not generate reference docs for this project
+ toolingProject = true
+ mavenVersion = LibraryVersions.UI
+ mavenGroup = LibraryGroups.UI
+ inceptionYear = "2020"
+ description = "This is a project for Material Studies demos."
+}
diff --git a/ui/ui-material/integration-tests/material-studies/src/main/AndroidManifest.xml b/ui/ui-material/integration-tests/material-studies/src/main/AndroidManifest.xml
index a035b92..a22480a 100644
--- a/ui/ui-material/integration-tests/material-studies/src/main/AndroidManifest.xml
+++ b/ui/ui-material/integration-tests/material-studies/src/main/AndroidManifest.xml
@@ -18,26 +18,14 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="androidx.ui.material.studies">
- <application
- android:label="Material Studies"
- android:supportsRtl="true"
- android:allowBackup="false" android:icon="@drawable/material_logo">
-
- <activity android:name=".MainActivity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
+ <application>
<activity android:name=".rally.RallyActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:configChanges="orientation|screenSize"
- android:label="Rally">
+ android:label="Material Studies/Rally">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
- <category android:name="androidx.ui.material.studies.SAMPLE_CODE" />
+ <category android:name="androidx.ui.demos.SAMPLE_CODE" />
</intent-filter>
</activity>
</application>
diff --git a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/MainActivity.kt b/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/MainActivity.kt
deleted file mode 100644
index acfaa53..0000000
--- a/ui/ui-material/integration-tests/material-studies/src/main/java/androidx/ui/material/studies/MainActivity.kt
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2019 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
- *
- * http://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 androidx.ui.material.studies
-
-import android.app.ListActivity
-import android.content.Intent
-import android.os.Bundle
-import android.view.View
-import android.widget.ListView
-import android.widget.SimpleAdapter
-import java.text.Collator
-import java.util.ArrayList
-import java.util.Comparator
-import java.util.HashMap
-
-class MainActivity : ListActivity() {
-
- public override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
-
- val path: String? = intent.getStringExtra("com.example.android.apis.Path")
-
- listAdapter = SimpleAdapter(
- this,
- getData(path),
- android.R.layout.simple_list_item_1,
- arrayOf("title"),
- intArrayOf(android.R.id.text1)
- )
- listView.isTextFilterEnabled = true
- }
-
- override fun onListItemClick(l: ListView, v: View, position: Int, id: Long) {
- @Suppress("UNCHECKED_CAST")
- val map = l.getItemAtPosition(position) as Map<String, Intent>
- startActivity(map["intent"])
- }
-
- private fun getData(prefix: String?): List<Map<String, Any>> {
- val prefixPath: Array<String>? = prefix?.split("/".toRegex())?.toTypedArray()
- val prefixWithSlash: String? = if (prefix != null) "$prefix/" else null
-
- val pm = packageManager
-
- val entries = HashMap<String, Boolean>()
- val mainIntent = Intent(Intent.ACTION_MAIN, null).apply {
- addCategory("androidx.ui.material.studies.SAMPLE_CODE")
- }
- val myData = ArrayList<Map<String, Any>>()
- val list = pm.queryIntentActivities(mainIntent, 0) ?: return myData
-
- list.forEach {
- val label = it.loadLabel(pm)?.toString() ?: it.activityInfo.name
-
- // If prefixWithSlash is null, we are at the top level so include everything.
- // Otherwise, we are down a level, so only include the activity if it's label starts
- // with our current path.
- if (prefixWithSlash == null || label.startsWith(prefixWithSlash)) {
-
- val labelPath = label.split("/".toRegex()).toTypedArray()
-
- // Get the next label in the path for the given activity. This may be the name of
- // activity itself, or may be a directory.
- val nextLabel = if (prefixPath == null) labelPath[0] else labelPath[prefixPath.size]
-
- // If the labelPath has one more item in it then the prefixPath does, we are at a
- // leaf node, so we know we are launching an Activity. Otherwise, we won't be at
- // a leaf node so we are going to open another sub menu.
- if ((prefixPath?.size ?: 0) == labelPath.size - 1) {
- addItem(
- myData, nextLabel, activityIntent(
- it.activityInfo.applicationInfo.packageName,
- it.activityInfo.name
- )
- )
- } else if (entries[nextLabel] == null) {
- // We only end up here if we are going to launch into another "directory" and if
- // we haven't already setup an item for that directory.
-
- addItem(
- myData, nextLabel, browseIntent(
- if (prefix == null) nextLabel else "$prefix/$nextLabel"
- )
- )
- entries[nextLabel] = true
- }
- }
- }
-
- return myData.sortedWith(sDisplayNameComparator)
- }
-
- private fun activityIntent(pkg: String, componentName: String): Intent {
- return Intent().apply {
- setClassName(pkg, componentName)
- }
- }
-
- private fun browseIntent(path: String): Intent {
- return Intent().apply {
- setClass(this@MainActivity, MainActivity::class.java)
- putExtra("com.example.android.apis.Path", path)
- }
- }
-
- private fun addItem(data: MutableList<Map<String, Any>>, name: String, intent: Intent) {
- data.add(mutableMapOf("title" to name, "intent" to intent))
- }
-
- companion object {
-
- private val sDisplayNameComparator = object : Comparator<Map<String, Any>> {
- private val collator = Collator.getInstance()
-
- override fun compare(map1: Map<String, Any>, map2: Map<String, Any>): Int {
- return collator.compare(map1["title"], map2["title"])
- }
- }
- }
-}