Android Open Source - wifi-auto-forget Connectivity Change Model






From Project

Back to project page wifi-auto-forget.

License

The source code is released under:

GNU General Public License

If you think the Android project wifi-auto-forget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.cebesius.wifiautoforget.mvp;
/*from w  w w.  j a v a 2 s .c o  m*/
import android.net.ConnectivityManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

import com.cebesius.wifiautoforget.domain.AutoForgetWifi;
import com.cebesius.wifiautoforget.gateway.AddWifiNotificationUsageStorage;
import com.cebesius.wifiautoforget.gateway.AutoForgetWifiStorage;
import com.cebesius.wifiautoforget.util.AutoForgetDelegate;

/**
 * Implementation of ConnectivityChangeModel
 */
public class ConnectivityChangeModel {

    private final AutoForgetWifiStorage autoForgetWifiStorage;
    private final AddWifiNotificationUsageStorage addWifiNotificationUsageStorage;
    private final ConnectivityManager connectivityManager;
    private final WifiManager wifiManager;
    private final AutoForgetDelegate autoForgetDelegate;

    public ConnectivityChangeModel(AutoForgetWifiStorage autoForgetWifiStorage, ConnectivityManager connectivityManager, WifiManager wifiManager, AddWifiNotificationUsageStorage addWifiNotificationUsageStorage) {
        this.autoForgetWifiStorage = autoForgetWifiStorage;
        this.addWifiNotificationUsageStorage = addWifiNotificationUsageStorage;
        this.connectivityManager = connectivityManager;
        this.wifiManager = wifiManager;
        autoForgetDelegate = new AutoForgetDelegate(autoForgetWifiStorage, wifiManager);
    }

    public boolean isConnectedWifi() {
        return connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
    }

    public void autoForget() {
        autoForgetDelegate.autoForget();
    }

    public boolean isConnectedWifiUnknown() {
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        return !autoForgetWifiStorage.has(wifiInfo.getSSID());
    }

    public boolean isConnectedWifiPermanentAutoForget() {
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        AutoForgetWifi autoForgetWifi = autoForgetWifiStorage.load(wifiInfo.getSSID());
        if (autoForgetWifi == null) {
            return false;
        }
        return AutoForgetWifi.Behavior.PERMANENT == autoForgetWifi.getBehavior();
    }

    public AutoForgetWifi buildNetwork() {
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        return new AutoForgetWifi(
                wifiInfo.getSSID(),
                null
        );
    }

    public int getUsedAddWifiNotificationActionCount() {
        return addWifiNotificationUsageStorage.getActionCount();
    }

    public boolean hasUsedAllAddWifiNotificationActionTypes() {
        return addWifiNotificationUsageStorage.hasUsedSingle()
                && addWifiNotificationUsageStorage.hasUsedPermanent()
                && addWifiNotificationUsageStorage.hasUsedIgnore();
    }
}




Java Source Code List

antoche.HockeySender.java
com.cebesius.wifiautoforget.Secrets.java
com.cebesius.wifiautoforget.WifiAutoForgetApplication.java
com.cebesius.wifiautoforget.activity.AutoForgetWifisActivity.java
com.cebesius.wifiautoforget.adapter.AutoForgetWifisAdapter.java
com.cebesius.wifiautoforget.dialog.ChangeAutoForgetBehaviorDialog.java
com.cebesius.wifiautoforget.domain.AutoForgetWifi.java
com.cebesius.wifiautoforget.gateway.AddWifiNotificationUsageStorage.java
com.cebesius.wifiautoforget.gateway.AutoForgetWifiStorage.java
com.cebesius.wifiautoforget.gateway.NotificationIds.java
com.cebesius.wifiautoforget.gateway.SharedPreferenceKeys.java
com.cebesius.wifiautoforget.gateway.UserPreferenceStorage.java
com.cebesius.wifiautoforget.model.AutoForgetWifiModel.java
com.cebesius.wifiautoforget.mvp.ActivityView.java
com.cebesius.wifiautoforget.mvp.AddWifiModel.java
com.cebesius.wifiautoforget.mvp.AddWifiPresenter.java
com.cebesius.wifiautoforget.mvp.AddWifiView.java
com.cebesius.wifiautoforget.mvp.AppModel.java
com.cebesius.wifiautoforget.mvp.AppPresenter.java
com.cebesius.wifiautoforget.mvp.AppView.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisModel.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisPresenter.java
com.cebesius.wifiautoforget.mvp.AutoForgetWifisView.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangeModel.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangePresenter.java
com.cebesius.wifiautoforget.mvp.ConnectivityChangeView.java
com.cebesius.wifiautoforget.receiver.ConnectivityChangeReceiver.java
com.cebesius.wifiautoforget.service.AddWifiService.java
com.cebesius.wifiautoforget.service.ConnectivityChangeService.java
com.cebesius.wifiautoforget.util.AutoForgetDelegate.java
com.cebesius.wifiautoforget.util.BusPortal.java
com.cebesius.wifiautoforget.widget.AutoForgetWifiItem.java