forked from VREMSoftwareDevelopment/WiFiAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplified item list display; added LICENSE
- Loading branch information
1 parent
9fa3860
commit e48c3aa
Showing
8 changed files
with
532 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright (C) 2010-2015 VREM Software Development | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,61 @@ | ||
package com.vrem.wifianalyzer; | ||
|
||
enum Frequency { | ||
UNKNOWN(0, 0, 0), | ||
TWO_POINT_FOUR(2412, 2472, 1), | ||
TWO_POINT_FOUR_CH_14(2484, 2484, 14), | ||
FIVE(5170, 5825, 34); | ||
|
||
final int CHANNEL_FREQUENCY_SPREAD = 5; | ||
|
||
private int start; | ||
private int end; | ||
private int offset; | ||
|
||
private Frequency(int start, int end, int offset) { | ||
this.start = start; | ||
this.end = end; | ||
this.offset = offset; | ||
} | ||
|
||
boolean inRange(int value) { | ||
return value >= start && value <= end; | ||
} | ||
int channel(int value) { | ||
if (inRange(value)) { | ||
return (value - start) / CHANNEL_FREQUENCY_SPREAD + offset; | ||
} | ||
return 0; | ||
} | ||
|
||
static Frequency find(int value) { | ||
for (Frequency frequency: Frequency.values()) { | ||
if (frequency.inRange(value)) { | ||
return frequency; | ||
} | ||
} | ||
return Frequency.UNKNOWN; | ||
} | ||
} | ||
/* | ||
* Copyright (C) 2010 - 2015 VREM Software Development <VREMSoftwareDevelopment@gmail.com> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.vrem.wifianalyzer; | ||
|
||
enum Frequency { | ||
UNKNOWN(0, 0, 0, ""), | ||
TWO_POINT_FOUR(2412, 2472, 1, "2.4Ghz"), | ||
TWO_POINT_FOUR_CH_14(2484, 2484, 14, "2.4Ghz"), | ||
FIVE(5170, 5825, 34, "5Ghz"); | ||
|
||
final int CHANNEL_FREQUENCY_SPREAD = 5; | ||
|
||
private int start; | ||
private int end; | ||
private int offset; | ||
private String band; | ||
|
||
Frequency(int start, int end, int offset, String band) { | ||
this.start = start; | ||
this.end = end; | ||
this.offset = offset; | ||
this.band = band; | ||
} | ||
|
||
boolean inRange(int value) { | ||
return value >= start && value <= end; | ||
} | ||
|
||
int channel(int value) { | ||
if (inRange(value)) { | ||
return (value - start) / CHANNEL_FREQUENCY_SPREAD + offset; | ||
} | ||
return 0; | ||
} | ||
|
||
String getBand() { | ||
return band; | ||
} | ||
|
||
static Frequency find(int value) { | ||
for (Frequency frequency: Frequency.values()) { | ||
if (frequency.inRange(value)) { | ||
return frequency; | ||
} | ||
} | ||
return Frequency.UNKNOWN; | ||
} | ||
} |
124 changes: 68 additions & 56 deletions
124
app/src/main/java/com/vrem/wifianalyzer/ListViewAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,68 @@ | ||
package com.vrem.wifianalyzer; | ||
|
||
import android.app.Activity; | ||
import android.net.wifi.ScanResult; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import java.util.List; | ||
|
||
public class ListViewAdapter extends ArrayAdapter<ScanResult> { | ||
|
||
public ListViewAdapter(Activity activity, List<ScanResult> scanResults) { | ||
super(activity, android.R.layout.simple_list_item_1, scanResults); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater(); | ||
if (convertView == null){ | ||
convertView = inflater.inflate(R.layout.column_row, null); | ||
} | ||
|
||
convertView.setBackgroundResource(position % 2 == 0 | ||
? R.color.bright_foreground_material_dark | ||
: R.color.background_material_light); | ||
|
||
ScanResult scanResult = getItem(position); | ||
|
||
((TextView) convertView.findViewById(R.id.ssid)).setText( | ||
(scanResult.SSID.length() == 0 ? "HIDDEN" : scanResult.SSID) + " (" + scanResult.BSSID + ")"); | ||
|
||
WifiLevel wifiLevel = WifiLevel.find(scanResult.level); | ||
Security security = Security.find(scanResult.capabilities); | ||
Frequency frequency = Frequency.find(scanResult.frequency); | ||
|
||
ImageView imageView = (ImageView) convertView.findViewById(R.id.levelImage); | ||
imageView.setImageResource(wifiLevel.getImageResource()); | ||
|
||
ImageView securityImage = (ImageView) convertView.findViewById(R.id.securityImage); | ||
securityImage.setImageResource(security.getImageResource()); | ||
|
||
TextView textLevel = (TextView) convertView.findViewById(R.id.level); | ||
textLevel.setText(scanResult.level + "dBm"); | ||
textLevel.setTextColor(getContext().getResources().getColor(wifiLevel.getColorResource())); | ||
|
||
((TextView) convertView.findViewById(R.id.channel)).setText("" + frequency.channel(scanResult.frequency)); | ||
((TextView) convertView.findViewById(R.id.frequency)).setText(" (" + scanResult.frequency + "MHz)"); | ||
((TextView) convertView.findViewById(R.id.capabilities)).setText(scanResult.capabilities); | ||
|
||
return convertView; | ||
} | ||
} | ||
/* | ||
* Copyright (C) 2010 - 2015 VREM Software Development <VREMSoftwareDevelopment@gmail.com> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.vrem.wifianalyzer; | ||
|
||
import android.app.Activity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import java.util.List; | ||
|
||
public class ListViewAdapter extends ArrayAdapter<WifiScan> { | ||
|
||
public ListViewAdapter(Activity activity, List<WifiScan> wifiScanResults) { | ||
super(activity, android.R.layout.simple_list_item_1, wifiScanResults); | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater(); | ||
if (convertView == null){ | ||
convertView = inflater.inflate(R.layout.column_row, null); | ||
} | ||
|
||
WifiScan wifiScan = getItem(position); | ||
|
||
((TextView) convertView.findViewById(R.id.ssid)).setText( | ||
(wifiScan.getSSID().length() == 0 ? "HIDDEN" : wifiScan.getSSID()) + " (" + wifiScan.getBSSID() + ")"); | ||
|
||
WifiLevel wifiLevel = wifiScan.getWifiLevel(); | ||
Security security = wifiScan.getSecurity(); | ||
String securities = wifiScan.getSecurities(); | ||
Frequency frequency = wifiScan.getFrequency(); | ||
int channel = wifiScan.getChannel(); | ||
|
||
ImageView imageView = (ImageView) convertView.findViewById(R.id.levelImage); | ||
imageView.setImageResource(wifiLevel.getImageResource()); | ||
|
||
ImageView securityImage = (ImageView) convertView.findViewById(R.id.securityImage); | ||
securityImage.setImageResource(security.getImageResource()); | ||
|
||
TextView textLevel = (TextView) convertView.findViewById(R.id.level); | ||
textLevel.setText(wifiScan.getLevel() + "dBm"); | ||
textLevel.setTextColor(getContext().getResources().getColor(wifiLevel.getColorResource())); | ||
|
||
((TextView) convertView.findViewById(R.id.channel)).setText("" + channel); | ||
((TextView) convertView.findViewById(R.id.frequency)).setText(" (" + frequency.getBand()+")"); | ||
((TextView) convertView.findViewById(R.id.security)).setText(securities); | ||
|
||
return convertView; | ||
} | ||
} |
Oops, something went wrong.