Merge "Fix a few lint errors in slices."
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index b89ffba..f028c0d 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -40,7 +40,7 @@
dependencies {
compile build_libs.gradle
compile build_libs.jacoco
- compile build_libs.error_prone
+ compile build_libs.error_prone_gradle
compile build_libs.jarjar_gradle
compile gradleApi()
testCompile "junit:junit:4.12"
diff --git a/buildSrc/build_dependencies.gradle b/buildSrc/build_dependencies.gradle
index 73cdf37..eb414dd 100644
--- a/buildSrc/build_dependencies.gradle
+++ b/buildSrc/build_dependencies.gradle
@@ -34,7 +34,7 @@
// jarjar plugin
build_libs.jarjar_gradle = 'org.anarres.jarjar:jarjar-gradle:1.0.0'
-build_libs.error_prone = 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
+build_libs.error_prone_gradle = 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
build_libs.jacoco = 'org.jacoco:org.jacoco.core:0.7.8'
build_libs.jacoco_ant = 'org.jacoco:org.jacoco.ant:0.7.8'
build_libs.jetifier = 'androidx.tools.jetifier:gradle-plugin:0.1'
diff --git a/buildSrc/src/main/kotlin/android/support/ErrorProneConfiguration.kt b/buildSrc/src/main/kotlin/android/support/ErrorProneConfiguration.kt
index 55f010f..74f0505 100644
--- a/buildSrc/src/main/kotlin/android/support/ErrorProneConfiguration.kt
+++ b/buildSrc/src/main/kotlin/android/support/ErrorProneConfiguration.kt
@@ -19,6 +19,8 @@
import net.ltgt.gradle.errorprone.ErrorProneToolChain
import org.gradle.api.tasks.compile.JavaCompile
+const val ERROR_PRONE_VERSION = "com.google.errorprone:error_prone_core:2.2.0"
+
fun JavaCompile.configureWithErrorProne(toolChain: ErrorProneToolChain) {
this.toolChain = toolChain
diff --git a/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt b/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt
index d2fac6a..6db309e 100644
--- a/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt
+++ b/buildSrc/src/main/kotlin/android/support/SupportAndroidLibraryPlugin.kt
@@ -137,6 +137,7 @@
setUpSoureJarTaskForAndroidProject(project, library)
val toolChain = ErrorProneToolChain.create(project)
+ project.dependencies.add("errorprone", ERROR_PRONE_VERSION)
library.buildTypes.create("errorProne")
library.libraryVariants.all { libraryVariant ->
if (libraryVariant.getBuildType().getName().equals("errorProne")) {
diff --git a/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt b/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt
index cec3629..1604bbe 100644
--- a/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt
+++ b/buildSrc/src/main/kotlin/android/support/SupportAndroidTestAppPlugin.kt
@@ -72,6 +72,7 @@
}
val toolChain = ErrorProneToolChain.create(project)
+ project.dependencies.add("errorprone", ERROR_PRONE_VERSION)
project.afterEvaluate {
if (testAppExtension.enableErrorProne) {
diff --git a/buildSrc/src/main/kotlin/android/support/SupportJavaLibraryPlugin.kt b/buildSrc/src/main/kotlin/android/support/SupportJavaLibraryPlugin.kt
index f37bf03..f3651ab 100644
--- a/buildSrc/src/main/kotlin/android/support/SupportJavaLibraryPlugin.kt
+++ b/buildSrc/src/main/kotlin/android/support/SupportJavaLibraryPlugin.kt
@@ -50,6 +50,7 @@
project.apply(mapOf("plugin" to ErrorProneBasePlugin::class.java))
val toolChain = ErrorProneToolChain.create(project)
+ project.dependencies.add("errorprone", ERROR_PRONE_VERSION)
val compileTasks = project.tasks.withType(JavaCompile::class.java)
compileTasks.all { it.configureWithErrorProne(toolChain) }
diff --git a/samples/SupportSliceDemos/src/main/java/com/example/androidx/slice/demos/SampleSliceProvider.java b/samples/SupportSliceDemos/src/main/java/com/example/androidx/slice/demos/SampleSliceProvider.java
index 16171b1..de764a1 100644
--- a/samples/SupportSliceDemos/src/main/java/com/example/androidx/slice/demos/SampleSliceProvider.java
+++ b/samples/SupportSliceDemos/src/main/java/com/example/androidx/slice/demos/SampleSliceProvider.java
@@ -315,7 +315,8 @@
.addRow(b -> b
.setTitle("Custom toggle")
.setSubtitle("It can support two states")
- .addEndItem(new SliceAction(getBroadcastIntent(ACTION_TOAST, "star toggled"),
+ .setPrimaryAction(new SliceAction(getBroadcastIntent(ACTION_TOAST,
+ "star toggled"),
Icon.createWithResource(getContext(), R.drawable.toggle_star),
"Toggle star", true /* isChecked */)))
.build();
diff --git a/slices/view/src/main/java/androidx/app/slice/widget/RowView.java b/slices/view/src/main/java/androidx/app/slice/widget/RowView.java
index fce819a..5b3e74c 100644
--- a/slices/view/src/main/java/androidx/app/slice/widget/RowView.java
+++ b/slices/view/src/main/java/androidx/app/slice/widget/RowView.java
@@ -197,6 +197,12 @@
SliceItem primaryAction = mRowContent.getPrimaryAction();
if (primaryAction != null) {
mRowAction = new ActionContent(primaryAction);
+ if (mRowAction.isToggle()) {
+ // If primary action is a toggle, add it and we're done
+ addToggle(mRowAction, mTintColor, mEndContainer);
+ setViewClickable(this, true);
+ return;
+ }
}
List<SliceItem> endItems = mRowContent.getEndItems();
@@ -432,7 +438,7 @@
@Override
public void onClick(View view) {
- if (mRowAction != null && mRowAction.getActionItem() != null) {
+ if (mRowAction != null && mRowAction.getActionItem() != null && !mRowAction.isToggle()) {
// Check for a row action
try {
mRowAction.getActionItem().getAction().send();