Make contextual card count configurable.
Decide how many card we should show at once on the homepage based on the value in Settings Global for more flexibility. Fall back to the default value if there is nothing set up. Bug: 138754406 Test: robotests Change-Id: I8d31d98eafb636a5e72af76ffec7e3dae0be3cbc
This commit is contained in:
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verify;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
@@ -110,6 +111,20 @@ public class ContextualCardLoaderTest {
|
||||
eq(SettingsEnums.ACTION_CONTEXTUAL_CARD_NOT_SHOW), any(String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCardCount_noConfiguredCardCount_returnDefaultCardCount() {
|
||||
assertThat(mContextualCardLoader.getCardCount()).isEqualTo(DEFAULT_CARD_COUNT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCardCount_hasConfiguredCardCount_returnConfiguredCardCount() {
|
||||
int configCount = 4;
|
||||
Settings.Global.putLong(mContext.getContentResolver(),
|
||||
ContextualCardLoader.CONTEXTUAL_CARD_COUNT, configCount);
|
||||
|
||||
assertThat(mContextualCardLoader.getCardCount()).isEqualTo(configCount);
|
||||
}
|
||||
|
||||
private List<ContextualCard> getContextualCardList() {
|
||||
final List<ContextualCard> cards = new ArrayList<>();
|
||||
cards.add(new ContextualCard.Builder()
|
||||
|
Reference in New Issue
Block a user