Merge "Create a set icon visibility interface for footer" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7cb4f13fc3
@@ -40,6 +40,8 @@ public class FooterPreference extends Preference {
|
|||||||
static final int ORDER_FOOTER = Integer.MAX_VALUE - 1;
|
static final int ORDER_FOOTER = Integer.MAX_VALUE - 1;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
View.OnClickListener mLearnMoreListener;
|
View.OnClickListener mLearnMoreListener;
|
||||||
|
@VisibleForTesting
|
||||||
|
int mIconVisibility = View.VISIBLE;
|
||||||
private CharSequence mContentDescription;
|
private CharSequence mContentDescription;
|
||||||
private CharSequence mLearnMoreText;
|
private CharSequence mLearnMoreText;
|
||||||
private CharSequence mLearnMoreContentDescription;
|
private CharSequence mLearnMoreContentDescription;
|
||||||
@@ -84,6 +86,9 @@ public class FooterPreference extends Preference {
|
|||||||
} else {
|
} else {
|
||||||
learnMore.setVisibility(View.GONE);
|
learnMore.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
View icon = holder.itemView.findViewById(R.id.icon_frame);
|
||||||
|
icon.setVisibility(mIconVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -165,6 +170,17 @@ public class FooterPreference extends Preference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set visibility of footer icon.
|
||||||
|
*/
|
||||||
|
public void setIconVisibility(int iconVisibility) {
|
||||||
|
if (mIconVisibility == iconVisibility) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mIconVisibility = iconVisibility;
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
setLayoutResource(R.layout.preference_footer);
|
setLayoutResource(R.layout.preference_footer);
|
||||||
if (getIcon() == null) {
|
if (getIcon() == null) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
@@ -61,7 +62,7 @@ public class FooterPreferenceTest {
|
|||||||
mFooterPreference.onBindViewHolder(holder);
|
mFooterPreference.onBindViewHolder(holder);
|
||||||
|
|
||||||
assertThat(((TextView) holder.findViewById(
|
assertThat(((TextView) holder.findViewById(
|
||||||
R.id.settingslib_learn_more)).getText().toString())
|
R.id.settingslib_learn_more)).getText().toString())
|
||||||
.isEqualTo("Custom learn more");
|
.isEqualTo("Custom learn more");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,4 +87,11 @@ public class FooterPreferenceTest {
|
|||||||
|
|
||||||
assertThat(mFooterPreference.mLearnMoreListener).isNotNull();
|
assertThat(mFooterPreference.mLearnMoreListener).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setIconVisibility_shouldReturnSameVisibilityType() {
|
||||||
|
mFooterPreference.setIconVisibility(View.GONE);
|
||||||
|
|
||||||
|
assertThat(mFooterPreference.mIconVisibility).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user