Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fec2fce7 authored by Zoey Chen's avatar Zoey Chen
Browse files

[Provider Model] Remove the footer of WFC

Reason: Cannot pass the GAR, so UX decides to remove it
https://screenshot.googleplex.com/3Ktq9EBxqUhWivj.png

Bug: 180670301
Test: make
Change-Id: I56d84a45826e14e6cc9093553f1bcfd9c54f70ec
parent 63ed1b3f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -51,12 +51,4 @@
        settings:controller="com.android.settings.network.telephony.NetworkProviderBackupCallingPreferenceController"
        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>
+0 −9
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.network.telephony.CallsDefaultSubscriptionController;
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.SmsDefaultSubscriptionController;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -46,8 +45,6 @@ public class NetworkProviderCallsSmsFragment extends DashboardFragment {
    @VisibleForTesting
    static final String KEY_PREFERENCE_CATEGORY_BACKUP_CALLING =
            "provider_model_backup_calling_category";
    static final String KEY_PREFERENCE_CATEGORY_WFC_FOOTER =
            "provider_model_calls_sms_footer";

    @VisibleForTesting
    static final String KEY_PREFERENCE_CALLS= "provider_model_calls_preference";
@@ -74,12 +71,6 @@ public class NetworkProviderCallsSmsFragment extends DashboardFragment {
        backupCallingPrefCtrl.init(getSettingsLifecycle());
        controllers.add(backupCallingPrefCtrl);

        NetworkProviderWfcFooterPreferenceController wfcFooterPreferenceController =
                new NetworkProviderWfcFooterPreferenceController(context,
                        KEY_PREFERENCE_CATEGORY_WFC_FOOTER);
        wfcFooterPreferenceController.init(getSettingsLifecycle());
        controllers.add(wfcFooterPreferenceController);

        return controllers;
    }

+0 −77
Original line number Diff line number Diff line
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;
        }
    }
}