[Provider Model] Add Learn more in the WFC footer
UX deck: https://screenshot.googleplex.com/4DxGCxgEsujhEpy.png Implementation: https://screenshot.googleplex.com/5yZhQMQwwRZQkge.png Bug: 178898044 Test: make Change-Id: Icfde927e6781303b6016b0ec13201fd7052191d3
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
android:key="provider_model_calls_sms_footer"
|
android:key="provider_model_calls_sms_footer"
|
||||||
android:title="@string/calls_sms_footnote"
|
android:title="@string/calls_sms_footnote"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
|
settings:allowDividerAbove="true"
|
||||||
settings:searchable="false"
|
settings:searchable="false"
|
||||||
/>
|
settings:controller="com.android.settings.network.telephony.NetworkProviderWfcFooterPreferenceController"/>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -27,6 +27,7 @@ import com.android.settings.Utils;
|
|||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
import com.android.settings.network.telephony.CallsDefaultSubscriptionController;
|
import com.android.settings.network.telephony.CallsDefaultSubscriptionController;
|
||||||
import com.android.settings.network.telephony.NetworkProviderBackupCallingPreferenceController;
|
import com.android.settings.network.telephony.NetworkProviderBackupCallingPreferenceController;
|
||||||
|
import com.android.settings.network.telephony.NetworkProviderWfcFooterPreferenceController;
|
||||||
import com.android.settings.network.telephony.NetworkProviderWifiCallingPreferenceController;
|
import com.android.settings.network.telephony.NetworkProviderWifiCallingPreferenceController;
|
||||||
import com.android.settings.network.telephony.SmsDefaultSubscriptionController;
|
import com.android.settings.network.telephony.SmsDefaultSubscriptionController;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
@@ -45,6 +46,9 @@ public class NetworkProviderCallsSmsFragment extends DashboardFragment {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_PREFERENCE_CATEGORY_BACKUP_CALLING =
|
static final String KEY_PREFERENCE_CATEGORY_BACKUP_CALLING =
|
||||||
"provider_model_backup_calling_category";
|
"provider_model_backup_calling_category";
|
||||||
|
static final String KEY_PREFERENCE_CATEGORY_WFC_FOOTER =
|
||||||
|
"provider_model_calls_sms_footer";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_PREFERENCE_CALLS= "provider_model_calls_preference";
|
static final String KEY_PREFERENCE_CALLS= "provider_model_calls_preference";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -70,6 +74,12 @@ public class NetworkProviderCallsSmsFragment extends DashboardFragment {
|
|||||||
backupCallingPrefCtrl.init(getSettingsLifecycle());
|
backupCallingPrefCtrl.init(getSettingsLifecycle());
|
||||||
controllers.add(backupCallingPrefCtrl);
|
controllers.add(backupCallingPrefCtrl);
|
||||||
|
|
||||||
|
NetworkProviderWfcFooterPreferenceController wfcFooterPreferenceController =
|
||||||
|
new NetworkProviderWfcFooterPreferenceController(context,
|
||||||
|
KEY_PREFERENCE_CATEGORY_WFC_FOOTER);
|
||||||
|
wfcFooterPreferenceController.init(getSettingsLifecycle());
|
||||||
|
controllers.add(wfcFooterPreferenceController);
|
||||||
|
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,77 @@
|
|||||||
|
package com.android.settings.network.telephony;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.telephony.SubscriptionInfo;
|
||||||
|
import android.telephony.SubscriptionManager;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.network.SubscriptionUtil;
|
||||||
|
import com.android.settings.utils.AnnotationSpan;
|
||||||
|
import com.android.settingslib.HelpUtils;
|
||||||
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NetworkProviderWfcFooterPreferenceController extends BasePreferenceController
|
||||||
|
implements LifecycleObserver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
public NetworkProviderWfcFooterPreferenceController(Context context, String preferenceKey) {
|
||||||
|
super(context, preferenceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the binding with Lifecycle
|
||||||
|
*
|
||||||
|
* @param lifecycle Lifecycle of UI which owns this Preference
|
||||||
|
*/
|
||||||
|
public void init(Lifecycle lifecycle) {
|
||||||
|
lifecycle.addObserver(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateState(Preference preference) {
|
||||||
|
super.updateState(preference);
|
||||||
|
|
||||||
|
if (preference != null) {
|
||||||
|
// This is necessary to ensure that setting the title to the spannable string returned
|
||||||
|
// by getFooterText will be accepted. Internally, setTitle does an equality check on
|
||||||
|
// the spannable string being set to the text already set on the preference. That
|
||||||
|
// equality check apparently only takes into account the raw text and not and spannables
|
||||||
|
// that are part of the text. So we clear the title before applying the spannable
|
||||||
|
// footer to ensure it is accepted.
|
||||||
|
preference.setTitle("");
|
||||||
|
preference.setTitle(getFooterText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CharSequence getFooterText() {
|
||||||
|
final Intent helpIntent = HelpUtils.getHelpIntent(mContext,
|
||||||
|
mContext.getString(R.string.help_uri_wifi_calling),
|
||||||
|
mContext.getClass().getName());
|
||||||
|
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(mContext,
|
||||||
|
"url", helpIntent);
|
||||||
|
|
||||||
|
return AnnotationSpan.linkify(mContext.getText(R.string.calls_sms_footnote), linkInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
final SubscriptionManager subscriptionManager =
|
||||||
|
mContext.getSystemService(SubscriptionManager.class);
|
||||||
|
final List<SubscriptionInfo> subscriptions = SubscriptionUtil.getActiveSubscriptions(
|
||||||
|
subscriptionManager);
|
||||||
|
if (subscriptions.size() >= 1) {
|
||||||
|
return AVAILABLE;
|
||||||
|
} else {
|
||||||
|
return CONDITIONALLY_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings.network.telephony;
|
package com.android.settings.network.telephony;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.telephony.CarrierConfigManager;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
Reference in New Issue
Block a user