List of usage examples for android.net.wifi WifiInfo FREQUENCY_UNITS
String FREQUENCY_UNITS
To view the source code for android.net.wifi WifiInfo FREQUENCY_UNITS.
Click Source Link
From source file:com.aqnote.app.wifianalyzer.wifi.AccessPointsDetail.java
void setView(@NonNull Resources resources, @NonNull View view, @NonNull WiFiDetail wiFiDetail, boolean isChild) { TextView textSSID = (TextView) view.findViewById(R.id.ssid); textSSID.setText(wiFiDetail.getTitle()); view.findViewById(R.id.ipAddress).setVisibility(View.GONE); view.findViewById(R.id.linkSpeed).setVisibility(View.GONE); ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); WiFiAdditional wiFiAdditional = wiFiDetail.getWiFiAdditional(); if (wiFiAdditional.isConfiguredNetwork()) { configuredImage.setVisibility(View.VISIBLE); configuredImage.setColorFilter(resources.getColor(R.color.connected)); } else {/*from w w w .j a v a2s. co m*/ configuredImage.setVisibility(View.GONE); } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(wiFiSignal.getLevel() + "dBm"); textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)).setText(wiFiSignal.getChannelDisplay()); ((TextView) view.findViewById(R.id.primaryFrequency)) .setText(wiFiSignal.getPrimaryFrequency() + WifiInfo.FREQUENCY_UNITS); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.channel_frequency_range)) .setText(wiFiSignal.getFrequencyStart() + " - " + wiFiSignal.getFrequencyEnd()); ((TextView) view.findViewById(R.id.width)) .setText("(" + wiFiSignal.getWiFiWidth().getFrequencyWidth() + WifiInfo.FREQUENCY_UNITS + ")"); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); TextView textVendor = ((TextView) view.findViewById(R.id.vendor)); String vendor = wiFiAdditional.getVendorName(); if (StringUtils.isBlank(vendor)) { textVendor.setVisibility(View.GONE); } else { textVendor.setVisibility(View.VISIBLE); textVendor.setText(vendor.substring(0, Math.min(VENDOR_NAME_MAX, vendor.length()))); } if (isChild) { view.findViewById(R.id.tab).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.tab).setVisibility(View.GONE); } }
From source file:com.vrem.wifianalyzer.wifi.AccessPointsDetail.java
public void setView(@NonNull Resources resources, @NonNull View view, @NonNull WiFiDetail wiFiDetail, boolean child, boolean frequencyRange) { ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle()); TextView textIPAddress = (TextView) view.findViewById(R.id.ipAddress); TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed); String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress(); if (StringUtils.isBlank(ipAddress)) { textIPAddress.setVisibility(View.GONE); textLinkSpeed.setVisibility(View.GONE); } else {//from ww w . j a v a 2 s. c om textIPAddress.setVisibility(View.VISIBLE); textIPAddress.setText(ipAddress); int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed(); if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) { textLinkSpeed.setVisibility(View.GONE); } else { textLinkSpeed.setVisibility(View.VISIBLE); textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS)); } } ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); if (wiFiDetail.getWiFiAdditional().isConfiguredNetwork()) { configuredImage.setVisibility(View.VISIBLE); configuredImage.setColorFilter(resources.getColor(R.color.connected)); } else { configuredImage.setVisibility(View.GONE); } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)) .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel())); ((TextView) view.findViewById(R.id.frequency)) .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); TextView textVendor = ((TextView) view.findViewById(R.id.vendor)); String vendor = wiFiDetail.getWiFiAdditional().getVendorName(); if (StringUtils.isBlank(vendor)) { textVendor.setVisibility(View.GONE); } else { textVendor.setVisibility(View.VISIBLE); textVendor.setText(vendor); } if (child) { view.findViewById(R.id.tab).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.tab).setVisibility(View.GONE); } if (frequencyRange) { view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.VISIBLE); ((TextView) view.findViewById(R.id.channel_frequency_range)).setText(String.format("%d - %d %s", wiFiSignal.getFrequencyStart(), wiFiSignal.getFrequencyEnd(), WifiInfo.FREQUENCY_UNITS)); } else { view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.GONE); } }
From source file:com.vrem.wifianalyzer.wifi.AccessPointsDetailTest.java
@Test public void testSetViewWithWiFiDetailAsScanResult() throws Exception { // setup//from w ww . jav a 2 s .c om WiFiDetail wiFiDetail = new WiFiDetail(StringUtils.EMPTY, "BSSID", "capabilities", new WiFiSignal(1, WiFiWidth.MHZ_20, 2), new WiFiAdditional(StringUtils.EMPTY, false)); // execute fixture.setView(mainActivity.getResources(), view, wiFiDetail, true, true); // validate validateTextViewValues(wiFiDetail, "***"); WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); validateTextViewValue(String.format("%d - %d %s", wiFiSignal.getFrequencyStart(), wiFiSignal.getFrequencyEnd(), WifiInfo.FREQUENCY_UNITS), R.id.channel_frequency_range); assertEquals(View.GONE, view.findViewById(R.id.ipAddress).getVisibility()); assertEquals(View.GONE, view.findViewById(R.id.configuredImage).getVisibility()); assertEquals(View.GONE, view.findViewById(R.id.vendor).getVisibility()); assertEquals(View.VISIBLE, view.findViewById(R.id.tab).getVisibility()); assertEquals(View.GONE, view.findViewById(R.id.groupIndicator).getVisibility()); assertEquals(View.VISIBLE, view.findViewById(R.id.channel_frequency_range_row).getVisibility()); }
From source file:eu.operando.proxy.wifi.AccessPointsDetail.java
public void setView(@NonNull Resources resources, @NonNull View view, @NonNull final WiFiDetail wiFiDetail) { TextView ssidLabel = (TextView) view.findViewById(R.id.ssid); ssidLabel.setText(wiFiDetail.getTitle()); TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed); String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress(); boolean isConnected = StringUtils.isNotBlank(ipAddress); if (!isConnected) { textLinkSpeed.setVisibility(View.GONE); ssidLabel.setTextColor(resources.getColor(android.R.color.white)); } else {//from ww w. j av a 2 s .c om ssidLabel.setTextColor(resources.getColor(R.color.connected)); int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed(); if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) { textLinkSpeed.setVisibility(View.GONE); } else { textLinkSpeed.setVisibility(View.VISIBLE); textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS)); } } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)) .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel())); ((TextView) view.findViewById(R.id.frequency)) .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); LayoutInflater layoutInflater = mainContext.getLayoutInflater(); final WiFiApConfig wiFiApConfig = wiFiDetail.getWiFiAdditional().getWiFiApConfig(); ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); if (wiFiApConfig != null) { configuredImage.setVisibility(View.VISIBLE); if (isOperandoCompatible(wiFiApConfig)) { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_green_light)); view.setOnClickListener( new ConfiguredClickListener(context, wiFiDetail, wiFiApConfig, isConnected)); } else { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_red_light)); view.setOnClickListener(new ForgetClickListener(context, wiFiDetail)); } } else { configuredImage.setVisibility(View.GONE); view.setOnClickListener(new ConnectClickListener(context, wiFiDetail, layoutInflater)); } }
From source file:eu.operando.operandoapp.wifi.AccessPointsDetail.java
public void setView(@NonNull Resources resources, @NonNull View view, @NonNull final WiFiDetail wiFiDetail) { TextView ssidLabel = (TextView) view.findViewById(R.id.ssid); ssidLabel.setText(wiFiDetail.getTitle()); TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed); textLinkSpeed.setTextColor(Color.BLACK); String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress(); boolean isConnected = StringUtils.isNotBlank(ipAddress); if (!isConnected) { textLinkSpeed.setVisibility(View.GONE); ssidLabel.setTextColor(resources.getColor(android.R.color.black)); } else {/*from w ww . j a v a 2 s . c om*/ ssidLabel.setTextColor(resources.getColor(R.color.connected)); int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed(); if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) { textLinkSpeed.setVisibility(View.GONE); } else { textLinkSpeed.setVisibility(View.VISIBLE); textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS)); } } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(Color.BLACK); //textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)) .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel())); ((TextView) view.findViewById(R.id.frequency)) .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); LayoutInflater layoutInflater = mainContext.getLayoutInflater(); final WiFiApConfig wiFiApConfig = wiFiDetail.getWiFiAdditional().getWiFiApConfig(); ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); if (wiFiApConfig != null) { configuredImage.setVisibility(View.VISIBLE); if (isOperandoCompatible(wiFiApConfig)) { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_green_light)); view.setOnClickListener( new ConfiguredClickListener(context, wiFiDetail, wiFiApConfig, isConnected)); } else { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_red_light)); view.setOnClickListener(new ForgetClickListener(context, wiFiDetail)); } } else { configuredImage.setVisibility(View.GONE); view.setOnClickListener(new ConnectClickListener(context, wiFiDetail, layoutInflater)); } }
From source file:com.vrem.wifianalyzer.wifi.AccessPointsDetailTest.java
private void validateTextViewValues(@NonNull WiFiDetail wiFiDetail, @NonNull String ssid) { WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); validateTextViewValue(ssid + " (" + wiFiDetail.getBSSID() + ")", R.id.ssid); validateTextViewValue(String.format("%ddBm", wiFiSignal.getLevel()), R.id.level); validateTextViewValue(String.format("%d", wiFiSignal.getWiFiChannel().getChannel()), R.id.channel); validateTextViewValue(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS), R.id.frequency);/*w w w. ja v a 2s. com*/ validateTextViewValue(String.format("%.1fm", wiFiSignal.getDistance()), R.id.distance); validateTextViewValue(wiFiDetail.getCapabilities(), R.id.capabilities); }
From source file:com.aqnote.app.wifianalyzer.wifi.AccessPointsDetailTest.java
private void validateTextViewValues(@NonNull WiFiDetail wiFiDetail, @NonNull String ssid) { WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); validateTextViewValue(ssid + " (" + wiFiDetail.getBSSID() + ")", R.id.ssid); validateTextViewValue(wiFiSignal.getLevel() + "dBm", R.id.level); validateTextViewValue(wiFiSignal.getChannelDisplay(), R.id.channel); validateTextViewValue(wiFiSignal.getPrimaryFrequency() + WifiInfo.FREQUENCY_UNITS, R.id.primaryFrequency); validateTextViewValue(wiFiSignal.getFrequencyStart() + " - " + wiFiSignal.getFrequencyEnd(), R.id.channel_frequency_range); validateTextViewValue("(" + wiFiSignal.getWiFiWidth().getFrequencyWidth() + WifiInfo.FREQUENCY_UNITS + ")", R.id.width);// ww w . j av a2 s. c om validateTextViewValue(String.format("%.1fm", wiFiSignal.getDistance()), R.id.distance); validateTextViewValue(wiFiDetail.getCapabilities(), R.id.capabilities); }