Merge "[Provider Model] Remove the footer of WFC" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
18eeaad6e3
@@ -51,12 +51,4 @@
|
|||||||
settings:controller="com.android.settings.network.telephony.NetworkProviderBackupCallingPreferenceController"
|
settings:controller="com.android.settings.network.telephony.NetworkProviderBackupCallingPreferenceController"
|
||||||
settings:allowDividerAbove="true"
|
settings:allowDividerAbove="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
|
||||||
android:key="provider_model_calls_sms_footer"
|
|
||||||
android:title="@string/calls_sms_footnote"
|
|
||||||
android:selectable="false"
|
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
settings:searchable="false"
|
|
||||||
settings:controller="com.android.settings.network.telephony.NetworkProviderWfcFooterPreferenceController"/>
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -27,7 +27,6 @@ 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;
|
||||||
@@ -46,8 +45,6 @@ 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";
|
||||||
@@ -74,12 +71,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,77 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user