From a7b40995de90e41a6512ba5a8911af4e2cccdf6f Mon Sep 17 00:00:00 2001 From: Doris Ling Date: Thu, 24 Aug 2017 15:24:33 -0700 Subject: [PATCH] Set drawable for the entity header app preference button. In the entity header layout, the action buttons resource is set to null by default. When we bind the button with the app preference action, we should also set the drawable to the settings icon as well. Change-Id: Ic259b4c538f529671ca5a9c67664ef32fbbb25ae Fixes: 64826061 Test: make RunSettingsRoboTests --- .../settings/widget/EntityHeaderController.java | 2 ++ .../settings/widget/EntityHeaderControllerTest.java | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java index 70b040de935..c38ad0297dc 100644 --- a/src/com/android/settings/widget/EntityHeaderController.java +++ b/src/com/android/settings/widget/EntityHeaderController.java @@ -336,6 +336,7 @@ public class EntityHeaderController { final Intent intent = resolveIntent( new Intent(Intent.ACTION_APPLICATION_PREFERENCES).setPackage(mPackageName)); if (intent == null) { + button.setImageDrawable(null); button.setVisibility(View.GONE); return; } @@ -348,6 +349,7 @@ public class EntityHeaderController { mFragment.startActivity(intent); } }); + button.setImageResource(R.drawable.ic_settings_24dp); button.setVisibility(View.VISIBLE); return; } diff --git a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java index fc6071e552a..9c6ee457c42 100644 --- a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java +++ b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java @@ -16,7 +16,6 @@ package com.android.settings.widget; - import android.app.ActionBar; import android.app.Activity; import android.app.Fragment; @@ -30,6 +29,7 @@ import android.os.UserHandle; import android.support.v7.preference.Preference; import android.view.LayoutInflater; import android.view.View; +import android.widget.ImageButton; import android.widget.TextView; import com.android.internal.logging.nano.MetricsProto; @@ -148,8 +148,9 @@ public class EntityHeaderControllerTest { EntityHeaderController.ActionType.ACTION_NONE); mController.done(mActivity); - assertThat(appLinks.findViewById(android.R.id.button1).getVisibility()) - .isEqualTo(View.VISIBLE); + final ImageButton button1 = appLinks.findViewById(android.R.id.button1); + assertThat(button1.getVisibility()).isEqualTo(View.VISIBLE); + assertThat(button1.getDrawable()).isNotNull(); assertThat(appLinks.findViewById(android.R.id.button2).getVisibility()) .isEqualTo(View.GONE); try { @@ -176,8 +177,9 @@ public class EntityHeaderControllerTest { EntityHeaderController.ActionType.ACTION_NONE); mController.done(mActivity); - assertThat(appLinks.findViewById(android.R.id.button1).getVisibility()) - .isEqualTo(View.GONE); + final ImageButton button1 = appLinks.findViewById(android.R.id.button1); + assertThat(button1.getVisibility()).isEqualTo(View.GONE); + assertThat(button1.getDrawable()).isNull(); assertThat(appLinks.findViewById(android.R.id.button2).getVisibility()) .isEqualTo(View.GONE); }