Add watch specific theming to AlertDialog.
Before/After screenshots:
https://drive.google.com/drive/folders/1fAZgspKCp4QerR9xnPIMKjBVA1u36CdU?usp=sharing
Note: This is a first of a few CLs that offer incremental
improvements to the UX of the AlertDialog. The goal is to
achieve what is described in:
https://docs.google.com/presentation/d/1rz1WgBndpdbrJqyyd7smxGPdKCR2ihfecKZoyJFsmAw/edit#slide=id.g23fc6b05fb_0_0
Test: manual
Change-Id: I3fe85982c83b9cfd5d136405734c3155bff2d686
diff --git a/samples/SupportWearDemos/build.gradle b/samples/SupportWearDemos/build.gradle
index 4dfd91d..ae0f195 100644
--- a/samples/SupportWearDemos/build.gradle
+++ b/samples/SupportWearDemos/build.gradle
@@ -18,7 +18,7 @@
dependencies {
implementation project(':wear')
- compile project(path: ':appcompat-v7')
+ implementation project(path: ':appcompat-v7')
}
android {
diff --git a/samples/SupportWearDemos/src/main/java/com/example/android/support/wear/app/AlertDialogDemo.java b/samples/SupportWearDemos/src/main/java/com/example/android/support/wear/app/AlertDialogDemo.java
index eea165c..4ea448a 100644
--- a/samples/SupportWearDemos/src/main/java/com/example/android/support/wear/app/AlertDialogDemo.java
+++ b/samples/SupportWearDemos/src/main/java/com/example/android/support/wear/app/AlertDialogDemo.java
@@ -34,18 +34,27 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.alert_dialog_demo);
- AlertDialog dialog = createDialog();
+ AlertDialog v7Dialog = createV7Dialog();
+ android.app.AlertDialog frameworkDialog = createFrameworkDialog();
- Button trigger = findViewById(R.id.dialog_button);
- trigger.setOnClickListener(new View.OnClickListener() {
+ Button v7Trigger = findViewById(R.id.v7_dialog_button);
+ v7Trigger.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- dialog.show();
+ v7Dialog.show();
+ }
+ });
+
+ Button frameworkTrigger = findViewById(R.id.framework_dialog_button);
+ frameworkTrigger.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ frameworkDialog.show();
}
});
}
- private AlertDialog createDialog() {
+ private AlertDialog createV7Dialog() {
return new AlertDialog.Builder(this)
.setTitle("AppCompatDialog")
.setMessage("Lorem ipsum dolor...")
@@ -53,4 +62,13 @@
.setNegativeButton("Cancel", null)
.create();
}
+
+ private android.app.AlertDialog createFrameworkDialog() {
+ return new android.app.AlertDialog.Builder(this)
+ .setTitle("FrameworkDialog")
+ .setMessage("Lorem ipsum dolor...")
+ .setPositiveButton("Ok", null)
+ .setNegativeButton("Cancel", null)
+ .create();
+ }
}
diff --git a/samples/SupportWearDemos/src/main/res/layout/alert_dialog_demo.xml b/samples/SupportWearDemos/src/main/res/layout/alert_dialog_demo.xml
index 35fd5d7..833d489 100644
--- a/samples/SupportWearDemos/src/main/res/layout/alert_dialog_demo.xml
+++ b/samples/SupportWearDemos/src/main/res/layout/alert_dialog_demo.xml
@@ -15,17 +15,30 @@
~ 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:orientation="vertical">
+<android.support.wear.widget.BoxInsetLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <Button
- android:id="@+id/dialog_button"
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"
- android:layout_margin="10dp"
- android:text="Show dialog"/>
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ app:boxedEdges="all">
-</FrameLayout>
\ No newline at end of file
+ <Button
+ android:id="@+id/v7_dialog_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="Show V7 dialog"/>
+
+ <Button
+ android:id="@+id/framework_dialog_button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="Show Framework dialog"/>
+ </LinearLayout>
+
+</android.support.wear.widget.BoxInsetLayout>
\ No newline at end of file
diff --git a/v7/appcompat/res/drawable-watch/abc_dialog_material_background.xml b/v7/appcompat/res/drawable-watch/abc_dialog_material_background.xml
new file mode 100644
index 0000000..242761b
--- /dev/null
+++ b/v7/appcompat/res/drawable-watch/abc_dialog_material_background.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@android:color/white" />
+</shape>
diff --git a/v7/appcompat/res/layout-watch/abc_alert_dialog_button_bar_material.xml b/v7/appcompat/res/layout-watch/abc_alert_dialog_button_bar_material.xml
new file mode 100644
index 0000000..1c8bd93
--- /dev/null
+++ b/v7/appcompat/res/layout-watch/abc_alert_dialog_button_bar_material.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2017 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.
+-->
+
+<android.support.v7.widget.ButtonBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/buttonPanel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="bottom"
+ android:layoutDirection="locale"
+ android:orientation="horizontal"
+ android:paddingBottom="4dp"
+ android:paddingLeft="12dp"
+ android:paddingRight="12dp"
+ android:paddingTop="4dp">
+
+ <Button
+ android:id="@android:id/button3"
+ style="?attr/buttonBarNeutralButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <Button
+ android:id="@android:id/button2"
+ style="?attr/buttonBarNegativeButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+ <Button
+ android:id="@android:id/button1"
+ style="?attr/buttonBarPositiveButtonStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"/>
+
+</android.support.v7.widget.ButtonBarLayout>
diff --git a/v7/appcompat/res/layout-watch/abc_alert_dialog_title_material.xml b/v7/appcompat/res/layout-watch/abc_alert_dialog_title_material.xml
new file mode 100644
index 0000000..e100963
--- /dev/null
+++ b/v7/appcompat/res/layout-watch/abc_alert_dialog_title_material.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2017 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/topPanel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:gravity="top|center_horizontal">
+
+ <!-- If the client uses a customTitle, it will be added here. -->
+
+ <LinearLayout
+ android:id="@+id/title_template"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal"
+ android:layout_marginTop="24dp"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@android:id/icon"
+ android:adjustViewBounds="true"
+ android:maxHeight="24dp"
+ android:maxWidth="24dp"
+ android:layout_gravity="center_horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <android.support.v7.widget.DialogTitle
+ android:id="@+id/alertTitle"
+ style="?android:attr/windowTitleStyle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center" />
+
+ </LinearLayout>
+
+ <android.support.v4.widget.Space
+ android:id="@+id/titleDividerNoCustom"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/abc_dialog_title_divider_material"
+ android:visibility="gone"/>
+</LinearLayout>
diff --git a/v7/appcompat/res/values-watch/themes_base.xml b/v7/appcompat/res/values-watch/themes_base.xml
new file mode 100644
index 0000000..20d8a7b
--- /dev/null
+++ b/v7/appcompat/res/values-watch/themes_base.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+
+<resources>
+ <style name="Base.Theme.AppCompat.Dialog" parent="Base.V7.Theme.AppCompat.Dialog" >
+ <item name="android:windowIsFloating">false</item>
+ </style>
+ <style name="Base.Theme.AppCompat.Light.Dialog" parent="Base.V7.Theme.AppCompat.Light.Dialog" >
+ <item name="android:windowIsFloating">false</item>
+ </style>
+ <style name="Base.ThemeOverlay.AppCompat.Dialog" parent="Base.V7.ThemeOverlay.AppCompat.Dialog" >
+ <item name="android:windowIsFloating">false</item>
+ </style>
+</resources>
\ No newline at end of file