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
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 70b040d..c38ad02 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -336,6 +336,7 @@
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 @@
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 fc6071e..9c6ee45 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.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 @@
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 @@
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);
}