Add subscriptions list to the multi-network header

The new UX for showing multiple active mobile plan subscriptions (SIMs,
eSIMs, etc.)  needs a header at the top of the Network & internet page
that shows wifi status and a list of active mobile subscriptions in the
form of one Preference per subscription.

This CL adds display of the mobile subscriptions to this header. It does
not yet show the correct summary text or do anything when you tap on
them - that will be coming in subsequent CLs. Also, since adding a
variable number of items to the top of the page messes up our current
strategy of having a fixed number of hidden items at the bottom based on
overall item count, this CL just makes all items visible. Subsequent CLs
can restore this behavior with dynamic adjustment.

Bug: 116349402
Test: make RunSettingsRoboTests
Change-Id: Ibfadf8cb61f6f5aff6ce38b7974267b1e4ddc719
This commit is contained in:
Antony Sargent
2018-12-12 09:09:45 -08:00
parent 3f5966bb48
commit e92e07eb97
7 changed files with 594 additions and 5 deletions

View File

@@ -19,18 +19,55 @@ package com.android.settings.network;
import android.content.Context;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.Lifecycle;
import androidx.annotation.VisibleForTesting;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
// This controls a header at the top of the Network & internet page that only appears when there
// are two or more active mobile subscriptions. It shows an overview of available network
// connections with an entry for wifi (if connected) and an entry for each subscription.
public class MultiNetworkHeaderController extends BasePreferenceController {
public class MultiNetworkHeaderController extends BasePreferenceController implements
SubscriptionsPreferenceController.UpdateListener {
public static final String TAG = "MultiNetworkHdrCtrl";
private SubscriptionsPreferenceController mSubscriptionsController;
private PreferenceCategory mPreferenceCategory;
public MultiNetworkHeaderController(Context context, String key) {
super(context, key);
super(context, key);
}
public void init(Lifecycle lifecycle) {
mSubscriptionsController = createSubscriptionsController(lifecycle);
// TODO(asargent) - add in a controller for showing wifi status here
}
@VisibleForTesting
SubscriptionsPreferenceController createSubscriptionsController(Lifecycle lifecycle) {
return new SubscriptionsPreferenceController(mContext, lifecycle, this, mPreferenceKey, 10);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreferenceCategory = (PreferenceCategory) screen.findPreference(mPreferenceKey);
mPreferenceCategory.setVisible(isAvailable());
mSubscriptionsController.displayPreference(screen);
}
@Override
public int getAvailabilityStatus() {
return UNSUPPORTED_ON_DEVICE;
if (mSubscriptionsController == null || !mSubscriptionsController.isAvailable()) {
return CONDITIONALLY_UNAVAILABLE;
} else {
return AVAILABLE;
}
}
@Override
public void onChildrenUpdated() {
mPreferenceCategory.setVisible(isAvailable());
}
}