Search in sources :

Example 6 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project android_packages_apps_Settings by DirtyUnicorns.

the class WifiSettings method configureConnectedAccessPointPreferenceCategory.

/**
 * Configure the ConnectedAccessPointPreferenceCategory and return true if the Category was
 * shown.
 */
private boolean configureConnectedAccessPointPreferenceCategory(List<AccessPoint> accessPoints) {
    if (accessPoints.size() == 0) {
        removeConnectedAccessPointPreference();
        return false;
    }
    AccessPoint connectedAp = accessPoints.get(0);
    if (!connectedAp.isActive()) {
        removeConnectedAccessPointPreference();
        return false;
    }
    // Is the preference category empty?
    if (mConnectedAccessPointPreferenceCategory.getPreferenceCount() == 0) {
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Is the previous currently connected SSID different from the new one?
    AccessPointPreference preference = (AccessPointPreference) (mConnectedAccessPointPreferenceCategory.getPreference(0));
    // in the UI.
    if (preference.getAccessPoint() != connectedAp) {
        removeConnectedAccessPointPreference();
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Else same AP is connected, simply refresh the connected access point preference
    // (first and only access point in this category).
    ((LongPressAccessPointPreference) mConnectedAccessPointPreferenceCategory.getPreference(0)).refresh();
    return true;
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 7 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project android_packages_apps_Settings by SudaMod.

the class WifiSettings method configureConnectedAccessPointPreferenceCategory.

/**
 * Configure the ConnectedAccessPointPreferenceCategory and return true if the Category was
 * shown.
 */
private boolean configureConnectedAccessPointPreferenceCategory(List<AccessPoint> accessPoints) {
    if (accessPoints.size() == 0) {
        removeConnectedAccessPointPreference();
        return false;
    }
    AccessPoint connectedAp = accessPoints.get(0);
    if (!connectedAp.isActive()) {
        removeConnectedAccessPointPreference();
        return false;
    }
    // Is the preference category empty?
    if (mConnectedAccessPointPreferenceCategory.getPreferenceCount() == 0) {
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Is the previous currently connected SSID different from the new one?
    AccessPointPreference preference = (AccessPointPreference) (mConnectedAccessPointPreferenceCategory.getPreference(0));
    // in the UI.
    if (preference.getAccessPoint() != connectedAp) {
        removeConnectedAccessPointPreference();
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Else same AP is connected, simply refresh the connected access point preference
    // (first and only access point in this category).
    ((LongPressAccessPointPreference) mConnectedAccessPointPreferenceCategory.getPreference(0)).refresh();
    return true;
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 8 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project platform_packages_apps_Settings by BlissRoms.

the class WifiSettings method configureConnectedAccessPointPreferenceCategory.

/**
 * Configure the ConnectedAccessPointPreferenceCategory and return true if the Category was
 * shown.
 */
private boolean configureConnectedAccessPointPreferenceCategory(List<AccessPoint> accessPoints) {
    if (accessPoints.size() == 0) {
        removeConnectedAccessPointPreference();
        return false;
    }
    AccessPoint connectedAp = accessPoints.get(0);
    if (!connectedAp.isActive()) {
        removeConnectedAccessPointPreference();
        return false;
    }
    // Is the preference category empty?
    if (mConnectedAccessPointPreferenceCategory.getPreferenceCount() == 0) {
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Is the previous currently connected SSID different from the new one?
    AccessPointPreference preference = (AccessPointPreference) (mConnectedAccessPointPreferenceCategory.getPreference(0));
    // in the UI.
    if (preference.getAccessPoint() != connectedAp) {
        removeConnectedAccessPointPreference();
        addConnectedAccessPointPreference(connectedAp);
        return true;
    }
    // Else same AP is connected, simply refresh the connected access point preference
    // (first and only access point in this category).
    ((LongPressAccessPointPreference) mConnectedAccessPointPreferenceCategory.getPreference(0)).refresh();
    return true;
}
Also used : AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 9 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SavedAccessPointsPreferenceController method refreshSavedAccessPoints.

@VisibleForTesting
void refreshSavedAccessPoints() {
    if (mPreferenceGroup == null) {
        Log.w(TAG, "PreferenceGroup is null, skipping.");
        return;
    }
    final Context prefContext = mPreferenceGroup.getContext();
    final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
    Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
    mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
    final int accessPointsSize = accessPoints.size();
    for (int i = 0; i < accessPointsSize; ++i) {
        AccessPoint ap = accessPoints.get(i);
        if (mHost != null && mHost.isSubscriptionsFeatureEnabled() && ap.isPasspointConfig()) {
            continue;
        }
        String key = ap.getKey();
        AccessPointPreference preference = (AccessPointPreference) mChildrenCache.getCachedPreference(key);
        if (preference == null) {
            preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
            preference.setKey(key);
            preference.setIcon(null);
            preference.setOnPreferenceClickListener(this);
            mPreferenceGroup.addPreference(preference);
        }
        preference.setOrder(i);
    }
    mChildrenCache.removeCachedPrefs(mPreferenceGroup);
    if (mPreferenceGroup.getPreferenceCount() < 1) {
        Log.w(TAG, "Saved networks activity loaded, but there are no saved networks!");
        mPreferenceGroup.setVisible(false);
    } else {
        mPreferenceGroup.setVisible(true);
    }
    if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
        mPreferenceGroup.setVisible(true);
        mPreferenceGroup.setTitle(null);
        mPreferenceGroup.setLayoutResource(R.layout.preference_category_no_label);
    }
}
Also used : Context(android.content.Context) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 10 with AccessPointPreference

use of com.android.settingslib.wifi.AccessPointPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SubscribedAccessPointsPreferenceController method refreshSubscribedAccessPoints.

@VisibleForTesting
void refreshSubscribedAccessPoints() {
    if (mPreferenceGroup == null) {
        Log.w(TAG, "PreferenceGroup is null, skipping.");
        return;
    }
    if (mHost != null && !mHost.isSubscriptionsFeatureEnabled()) {
        mPreferenceGroup.setVisible(false);
        return;
    }
    final Context prefContext = mPreferenceGroup.getContext();
    final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(mContext, mWifiManager);
    Collections.sort(accessPoints, SavedNetworkComparator.INSTANCE);
    mChildrenCache.cacheRemoveAllPrefs(mPreferenceGroup);
    final int accessPointsSize = accessPoints.size();
    for (int i = 0; i < accessPointsSize; ++i) {
        AccessPoint ap = accessPoints.get(i);
        if (!ap.isPasspointConfig()) {
            continue;
        }
        final String key = ap.getKey();
        AccessPointPreference preference = (AccessPointPreference) mChildrenCache.getCachedPreference(key);
        if (preference == null) {
            preference = new AccessPointPreference(ap, prefContext, mUserBadgeCache, true);
            preference.setKey(key);
            preference.setIcon(null);
            preference.setOnPreferenceClickListener(this);
            mPreferenceGroup.addPreference(preference);
        }
        preference.setOrder(i);
    }
    mChildrenCache.removeCachedPrefs(mPreferenceGroup);
    if (mPreferenceGroup.getPreferenceCount() < 1) {
        Log.w(TAG, "Subscribed networks activity loaded," + " but there are no subscribed networks!");
        mPreferenceGroup.setVisible(false);
    } else {
        mPreferenceGroup.setVisible(true);
    }
}
Also used : Context(android.content.Context) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) AccessPoint(com.android.settingslib.wifi.AccessPoint) AccessPoint(com.android.settingslib.wifi.AccessPoint) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

AccessPointPreference (com.android.settingslib.wifi.AccessPointPreference)16 AccessPoint (com.android.settingslib.wifi.AccessPoint)12 Test (org.junit.Test)4 Context (android.content.Context)3 WifiConfiguration (android.net.wifi.WifiConfiguration)3 Bundle (android.os.Bundle)2 View (android.view.View)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)2 Config (org.robolectric.annotation.Config)2 Activity (android.app.Activity)1 SettingsEnums (android.app.settings.SettingsEnums)1 Intent (android.content.Intent)1 WifiEnterpriseConfig (android.net.wifi.WifiEnterpriseConfig)1 WifiManager (android.net.wifi.WifiManager)1 Log (android.util.Log)1 Toast (android.widget.Toast)1 Preference (androidx.preference.Preference)1 PreferenceCategory (androidx.preference.PreferenceCategory)1 R (com.android.settings.R)1