Android Open Source - twawm2 Icon Selector






From Project

Back to project page twawm2.

License

The source code is released under:

Copyright (c) 2014, afnf All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistr...

If you think the Android project twawm2 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.appspot.afnf4199ga.twawm;
//w  ww .j a  va2s .c  o  m
import net.afnf.and.twawm2.R;

import com.appspot.afnf4199ga.twawm.StateMachine.NETWORK_STATE;
import com.appspot.afnf4199ga.twawm.router.RouterInfo.COM_TYPE;

public class IconSelector {

    public static int selectNotifyIcon(int antennaLevel, int batteryLevel, NETWORK_STATE netState, COM_TYPE comState) {

        int battOffset = battOffset(batteryLevel);

        if (netState == NETWORK_STATE.AP_NOT_FOUND || netState == NETWORK_STATE.NOT_WM_ROUTER) {
            return R.drawable.ntficon_wimax_gray_batt_000 + battOffset;
        }
        else if (netState == NETWORK_STATE.OFFLINE) {
            antennaLevel = 0;
        }

        switch (comState) {
        case HIGH_SPEED:
            switch (antennaLevel) {
            case 1:
                return R.drawable.ntficon_hs_wimax_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.ntficon_hs_wimax_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.ntficon_hs_wimax_green_4_batt_000 + battOffset;
            case 4:
            case 5:
            case 6:
                return R.drawable.ntficon_hs_wimax_green_6_batt_000 + battOffset;
            default:
                return R.drawable.ntficon_hs_wimax_white_batt_000 + battOffset;
            }

        case NO_LIMIT:
            switch (antennaLevel) {
            case 1:
                return R.drawable.ntficon_wimax_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.ntficon_wimax_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.ntficon_wimax_green_4_batt_000 + battOffset;
            case 4:
                return R.drawable.ntficon_wimax_green_5_batt_000 + battOffset;
            case 5:
            case 6:
                return R.drawable.ntficon_wimax_green_6_batt_000 + battOffset;
            default:
                return R.drawable.ntficon_wimax_white_batt_000 + battOffset;
            }

        case WIFI_SPOT:
            switch (antennaLevel) {
            case 1:
                return R.drawable.ntficon_wifi_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.ntficon_wifi_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.ntficon_wifi_green_3_batt_000 + battOffset;
            case 4:
                return R.drawable.ntficon_wifi_green_4_batt_000 + battOffset;
            case 5:
                return R.drawable.ntficon_wifi_green_5_batt_000 + battOffset;
            case 6:
                return R.drawable.ntficon_wifi_green_6_batt_000 + battOffset;
            default:
                return R.drawable.ntficon_wifi_white_batt_000 + battOffset;
            }

            // WM????
        default:
            switch (antennaLevel) {
            case 1:
                return R.drawable.ntficon_wimax_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.ntficon_wimax_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.ntficon_wimax_green_3_batt_000 + battOffset;
            case 4:
                return R.drawable.ntficon_wimax_green_4_batt_000 + battOffset;
            case 5:
                return R.drawable.ntficon_wimax_green_5_batt_000 + battOffset;
            case 6:
                return R.drawable.ntficon_wimax_green_6_batt_000 + battOffset;
            default:
                return R.drawable.ntficon_wimax_white_batt_000 + battOffset;
            }
        }
    }

    public static int selectWdIcon(int antennaLevel, int batteryLevel, NETWORK_STATE netState, COM_TYPE comState) {

        int battOffset = battOffset(batteryLevel);

        if (netState == NETWORK_STATE.AP_NOT_FOUND || netState == NETWORK_STATE.NOT_WM_ROUTER) {
            return R.drawable.icon_wimax_gray_batt_000 + battOffset;
        }
        else if (netState == NETWORK_STATE.OFFLINE) {
            antennaLevel = 0;
        }

        switch (comState) {
        case HIGH_SPEED:
            switch (antennaLevel) {
            case 1:
                return R.drawable.icon_hs_wimax_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.icon_hs_wimax_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.icon_hs_wimax_green_4_batt_000 + battOffset;
            case 4:
            case 5:
            case 6:
                return R.drawable.icon_hs_wimax_green_6_batt_000 + battOffset;
            default:
                return R.drawable.icon_hs_wimax_white_batt_000 + battOffset;
            }

        case NO_LIMIT:
            switch (antennaLevel) {
            case 1:
                return R.drawable.icon_wimax_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.icon_wimax_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.icon_wimax_green_4_batt_000 + battOffset;
            case 4:
                return R.drawable.icon_wimax_green_5_batt_000 + battOffset;
            case 5:
            case 6:
                return R.drawable.icon_wimax_green_6_batt_000 + battOffset;
            default:
                return R.drawable.icon_wimax_white_batt_000 + battOffset;
            }

        case WIFI_SPOT:
            switch (antennaLevel) {
            case 1:
                return R.drawable.icon_wifi_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.icon_wifi_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.icon_wifi_green_3_batt_000 + battOffset;
            case 4:
                return R.drawable.icon_wifi_green_4_batt_000 + battOffset;
            case 5:
                return R.drawable.icon_wifi_green_5_batt_000 + battOffset;
            case 6:
                return R.drawable.icon_wifi_green_6_batt_000 + battOffset;
            default:
                return R.drawable.icon_wifi_white_batt_000 + battOffset;
            }
            // WM????
        default:
            switch (antennaLevel) {
            case 1:
                return R.drawable.icon_wimax_green_1_batt_000 + battOffset;
            case 2:
                return R.drawable.icon_wimax_green_2_batt_000 + battOffset;
            case 3:
                return R.drawable.icon_wimax_green_3_batt_000 + battOffset;
            case 4:
                return R.drawable.icon_wimax_green_4_batt_000 + battOffset;
            case 5:
                return R.drawable.icon_wimax_green_5_batt_000 + battOffset;
            case 6:
                return R.drawable.icon_wimax_green_6_batt_000 + battOffset;
            default:
                return R.drawable.icon_wimax_white_batt_000 + battOffset;
            }
        }
    }

    private static int battOffset(int batteryLevel) {
        if (batteryLevel >= 95) {
            return 10;
        }
        else if (batteryLevel >= 90) {
            return 9;
        }
        else if (batteryLevel >= 80) {
            return 8;
        }
        else if (batteryLevel >= 70) {
            return 7;
        }
        else if (batteryLevel >= 60) {
            return 6;
        }
        else if (batteryLevel >= 50) {
            return 5;
        }
        else if (batteryLevel >= 40) {
            return 4;
        }
        else if (batteryLevel >= 30) {
            return 3;
        }
        else if (batteryLevel >= 20) {
            return 2;
        }
        else if (batteryLevel >= 10) {
            return 1;
        }
        else if (batteryLevel >= 0) {
            return 0;
        }
        else {
            return 11;
        }
    }
}




Java Source Code List

com.appspot.afnf4199ga.twawm.BluetoothHelper.java
com.appspot.afnf4199ga.twawm.Const.java
com.appspot.afnf4199ga.twawm.Const.java
com.appspot.afnf4199ga.twawm.HostnameListTest.java
com.appspot.afnf4199ga.twawm.HostnameList.java
com.appspot.afnf4199ga.twawm.IconSelectorTest.java
com.appspot.afnf4199ga.twawm.IconSelector.java
com.appspot.afnf4199ga.twawm.OnlineChecker.java
com.appspot.afnf4199ga.twawm.StateMachineTest.java
com.appspot.afnf4199ga.twawm.StateMachine.java
com.appspot.afnf4199ga.twawm.TwawmUtils.java
com.appspot.afnf4199ga.twawm.app.BackgroundServiceTest.java
com.appspot.afnf4199ga.twawm.app.BackgroundService.java
com.appspot.afnf4199ga.twawm.app.DefaultWidgetProvider.java
com.appspot.afnf4199ga.twawm.app.InfoActivity.java
com.appspot.afnf4199ga.twawm.app.InitialConfigurationWizardActivity.java
com.appspot.afnf4199ga.twawm.app.LogSendActivity.java
com.appspot.afnf4199ga.twawm.app.MainActivity.java
com.appspot.afnf4199ga.twawm.app.MainApp.java
com.appspot.afnf4199ga.twawm.app.MyPreferenceActivity.java
com.appspot.afnf4199ga.twawm.app.NetworkSwitcher.java
com.appspot.afnf4199ga.twawm.app.StaticIntentListener.java
com.appspot.afnf4199ga.twawm.app.UIAct.java
com.appspot.afnf4199ga.twawm.ctl.CustomizeActionsActivityTest.java
com.appspot.afnf4199ga.twawm.ctl.CustomizeActionsActivity.java
com.appspot.afnf4199ga.twawm.ctl.CwacTouchListView.java
com.appspot.afnf4199ga.twawm.ctl.ListItem.java
com.appspot.afnf4199ga.twawm.router.EcoModeControlTest.java
com.appspot.afnf4199ga.twawm.router.EcoModeControl.java
com.appspot.afnf4199ga.twawm.router.InetLookupWrappter.java
com.appspot.afnf4199ga.twawm.router.InetLookupWrappter.java
com.appspot.afnf4199ga.twawm.router.MyHttpClientTest.java
com.appspot.afnf4199ga.twawm.router.MyHttpClient.java
com.appspot.afnf4199ga.twawm.router.MyHttpClient.java
com.appspot.afnf4199ga.twawm.router.RouterControlByHttpTest.java
com.appspot.afnf4199ga.twawm.router.RouterControlByHttp.java
com.appspot.afnf4199ga.twawm.router.RouterControlByHttp.java
com.appspot.afnf4199ga.twawm.router.RouterControl.java
com.appspot.afnf4199ga.twawm.router.RouterControl.java
com.appspot.afnf4199ga.twawm.router.RouterInfo.java
com.appspot.afnf4199ga.twawm.router.RouterInfo.java
com.appspot.afnf4199ga.utils.AndroidUtilsTest.java
com.appspot.afnf4199ga.utils.AndroidUtils.java
com.appspot.afnf4199ga.utils.AndroidUtils.java
com.appspot.afnf4199ga.utils.Logger.java
com.appspot.afnf4199ga.utils.Logger.java
com.appspot.afnf4199ga.utils.MyStringUtlisTest.java
com.appspot.afnf4199ga.utils.MyStringUtlis.java
com.appspot.afnf4199ga.utils.MyStringUtlis.java
com.appspot.afnf4199ga.utils.MyTestUtils.java
com.appspot.afnf4199ga.utils.MyUncaughtExceptionHandler.java
com.appspot.afnf4199ga.utils.MyUncaughtExceptionHandler.java
com.appspot.afnf4199ga.wmgraph.app.FetchThread.java
com.appspot.afnf4199ga.wmgraph.app.InetLookupThread.java
com.appspot.afnf4199ga.wmgraph.app.InfoActivity.java
com.appspot.afnf4199ga.wmgraph.app.MainActivity.java
com.appspot.afnf4199ga.wmgraph.app.MyPreferenceActivity.java
com.appspot.afnf4199ga.wmgraph.app.UIAct.java
net.afnf.and.twawm2.DexmakerInstrumentationTestCase.java
net.afnf.and.twawm2.MyInstrumentationTestRunner.java