Merge "Allow below divider for all EntityHeader"
This commit is contained in:
committed by
Android (Google) Code Review
commit
afc09c5234
@@ -24,7 +24,6 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.content.res.TypedArrayUtils;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
@@ -37,9 +36,7 @@ public class LayoutPreference extends Preference {
|
||||
private final View.OnClickListener mClickListener = v -> performClick(v);
|
||||
private boolean mAllowDividerAbove;
|
||||
private boolean mAllowDividerBelow;
|
||||
|
||||
@VisibleForTesting
|
||||
View mRootView;
|
||||
private View mRootView;
|
||||
|
||||
public LayoutPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -116,4 +113,11 @@ public class LayoutPreference extends Preference {
|
||||
return mRootView.findViewById(id);
|
||||
}
|
||||
|
||||
public void setAllowDividerBelow(boolean allowed) {
|
||||
mAllowDividerBelow = allowed;
|
||||
}
|
||||
|
||||
public boolean isAllowDividerBelow() {
|
||||
return mAllowDividerBelow;
|
||||
}
|
||||
}
|
@@ -238,6 +238,7 @@ public class EntityHeaderController {
|
||||
pref.setOrder(-1000);
|
||||
pref.setSelectable(false);
|
||||
pref.setKey(PREF_KEY_APP_HEADER);
|
||||
pref.setAllowDividerBelow(true);
|
||||
return pref;
|
||||
}
|
||||
|
||||
|
@@ -83,4 +83,11 @@ public class LayoutPreferenceTest {
|
||||
assertThat(mPreference.findViewById(R.id.button1).isEnabled()).isFalse();
|
||||
assertThat(mPreference.findViewById(R.id.button2).isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allowDividerBelow_shouldSaveCorrectDividerStatus() {
|
||||
mPreference.setAllowDividerBelow(true);
|
||||
|
||||
assertThat(mPreference.isAllowDividerBelow()).isTrue();
|
||||
}
|
||||
}
|
||||
|
@@ -96,11 +96,12 @@ public class EntityHeaderControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildView_withContext_shouldBuildPreference() {
|
||||
public void testBuildView_withContext_shouldBuildPreferenceAllowedBelowDivider() {
|
||||
mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
|
||||
Preference preference = mController.done(mActivity, mShadowContext);
|
||||
|
||||
assertThat(preference instanceof LayoutPreference).isTrue();
|
||||
assertThat(((LayoutPreference)preference).isAllowDividerBelow()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user