Skip to content

Commit 6b26724

Browse files
committed
update sample UI to match the catalog style and added dark theme support
1 parent d0b75f9 commit 6b26724

File tree

6 files changed

+44
-31
lines changed

6 files changed

+44
-31
lines changed

samples/user-interface/windowmanager/src/main/java/com/example/platform/ui/windowmanager/demos/DemoItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ package com.example.platform.ui.windowmanager.demos
1818

1919
import android.app.Activity
2020

21-
class DemoItem(val description: String, val buttonTitle: String, val clazz: Class<out Activity>)
21+
class DemoItem(val description: String, val title: String, val clazz: Class<out Activity>)

samples/user-interface/windowmanager/src/main/java/com/example/platform/ui/windowmanager/demos/DemoVH.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ import androidx.recyclerview.widget.RecyclerView
2424
import com.example.platform.ui.windowmanager.R
2525

2626
class DemoVH(view: View) : RecyclerView.ViewHolder(view) {
27+
private val container = view.findViewById<View>(R.id.demo_container)
2728
private val description = view.findViewById<TextView>(R.id.demo_description)
28-
private val launchButton = view.findViewById<Button>(R.id.start_demo_button)
29+
private val title = view.findViewById<TextView>(R.id.demo_title)
2930

3031
fun bind(item: DemoItem) {
3132
description.text = item.description
32-
launchButton.text = item.buttonTitle
33-
launchButton.setOnClickListener { view ->
33+
title.text = item.title
34+
container.setOnClickListener { view ->
3435
val context = view.context
3536
val intent = Intent(context, item.clazz)
3637
view.context.startActivity(intent)

samples/user-interface/windowmanager/src/main/java/com/example/platform/ui/windowmanager/demos/WindowDemosActivity.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,47 +47,47 @@ class WindowDemosActivity : AppCompatActivity() {
4747

4848
val demoItems = listOf(
4949
DemoItem(
50-
buttonTitle = getString(R.string.activity_embedding),
50+
title = getString(R.string.activity_embedding),
5151
description = getString(R.string.activity_embedding_description),
5252
clazz = SplitActivityList::class.java,
5353
),
5454
DemoItem(
55-
buttonTitle = getString(R.string.display_features),
55+
title = getString(R.string.display_features),
5656
description = getString(R.string.show_all_display_features_config_change_description),
5757
clazz = DisplayFeaturesActivity::class.java,
5858
),
5959
DemoItem(
60-
buttonTitle = getString(R.string.window_metrics),
60+
title = getString(R.string.window_metrics),
6161
description = getString(R.string.window_metrics_description),
6262
clazz = WindowMetricsActivity::class.java,
6363
),
6464
DemoItem(
65-
buttonTitle = getString(R.string.split_layout),
65+
title = getString(R.string.split_layout),
6666
description = getString(R.string.split_layout_demo_description),
6767
clazz = SplitLayoutActivity::class.java,
6868
),
6969
DemoItem(
70-
buttonTitle = getString(R.string.split_layout_with_attributes),
70+
title = getString(R.string.split_layout_with_attributes),
7171
description = getString(R.string.split_layout_attributes_demo_description),
7272
clazz = SplitAttributesToggleMainActivity::class.java,
7373
),
7474
DemoItem(
75-
buttonTitle = getString(R.string.split_layout_with_state),
75+
title = getString(R.string.split_layout_with_state),
7676
description = getString(R.string.split_layout_with_state_demo_description),
7777
clazz = SplitDeviceStateActivityA::class.java,
7878
),
7979
DemoItem(
80-
buttonTitle = getString(R.string.media_player_activity),
80+
title = getString(R.string.media_player_activity),
8181
description = getString(R.string.media_player_activity_demo_description),
8282
clazz = MediaPlayerActivity::class.java,
8383
),
8484
DemoItem(
85-
buttonTitle = getString(R.string.rear_display_activity),
85+
title = getString(R.string.rear_display_activity),
8686
description = getString(R.string.rear_display_activity_demo_description),
8787
clazz = RearDisplayModeActivity::class.java,
8888
),
8989
DemoItem(
90-
buttonTitle = getString(R.string.dual_screen_activity),
90+
title = getString(R.string.dual_screen_activity),
9191
description = getString(R.string.dual_screen_activity_demo_description),
9292
clazz = DualScreenActivity::class.java,
9393
),

samples/user-interface/windowmanager/src/main/res/layout/view_holder_demo_item.xml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,33 @@
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
-->
16-
17-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
16+
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
1817
android:layout_width="match_parent"
1918
android:layout_height="wrap_content"
20-
android:orientation="vertical">
21-
22-
<Button
23-
android:layout_width="wrap_content"
19+
xmlns:app="http://schemas.android.com/apk/res-auto"
20+
android:clickable="true"
21+
android:focusable="true"
22+
app:strokeWidth="1dp"
23+
android:layout_margin="10dp"
24+
android:id="@+id/demo_container">
25+
<LinearLayout
26+
android:layout_width="match_parent"
2427
android:layout_height="wrap_content"
25-
android:id="@+id/start_demo_button"/>
28+
android:layout_margin="10dp"
29+
android:orientation="vertical">
2630

27-
<TextView
28-
android:layout_width="wrap_content"
29-
android:layout_height="wrap_content"
30-
android:id="@+id/demo_description"/>
31+
<TextView
32+
android:layout_width="wrap_content"
33+
android:layout_height="wrap_content"
34+
android:id="@+id/demo_title"
35+
android:padding="4dp"
36+
android:textStyle="bold"/>
37+
38+
<TextView
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:padding="4dp"
42+
android:id="@+id/demo_description"/>
3143

32-
</LinearLayout>
44+
</LinearLayout>
45+
</com.google.android.material.card.MaterialCardView>

samples/user-interface/windowmanager/src/main/res/values/colors.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
-->
1717

1818
<resources>
19-
<color name="colorPrimary">#6200EE</color>
20-
<color name="colorPrimaryDark">#3700B3</color>
21-
<color name="colorAccent">#03DAC5</color>
19+
<color name="colorPrimary">#FF6650a4</color>
20+
<color name="colorPrimaryDark">#FFD0BCFF</color>
2221

2322
<color name="colorFeatureFold">#7700FF00</color>
2423

samples/user-interface/windowmanager/src/main/res/values/styles.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
<resources>
1818

1919
<!-- Base application theme. -->
20-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
20+
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
2121
<!-- Customize your theme here. -->
2222
<item name="colorPrimary">@color/colorPrimary</item>
2323
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
24-
<item name="colorAccent">@color/colorAccent</item>
24+
2525
</style>
2626

27-
<style name="FoldableMediaPlayer" parent="Theme.AppCompat.DayNight.NoActionBar">
27+
<style name="FoldableMediaPlayer" parent="Theme.MaterialComponents.DayNight.NoActionBar">
2828
<item name="android:windowBackground">@null</item>
2929
</style>
3030

0 commit comments

Comments
 (0)