Skip to content

Commit

Permalink
autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
boerwastaken committed Apr 28, 2020
1 parent 7f859e6 commit 42009af
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions app/src/main/java/info/aario/mywifipasswords/WifiList.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
}

private String _findLineContaining(String[] Lines, String text) {
for (String Line: Lines) {
for (String Line : Lines) {
if (Line.contains(text)) {
return Line;
}
Expand All @@ -113,10 +113,10 @@ private String _findLineContaining(String[] Lines, String text) {
}

private String _getValueFromConfigLine(String Line) {
return Line.split("=")[1].replace("\"","");
return Line.split("=")[1].replace("\"", "");
}

private String _getConfigValueByKey(String[]Lines, String Key) {
private String _getConfigValueByKey(String[] Lines, String Key) {
String Line = _findLineContaining(Lines, Key + '=');
if (Line.isEmpty()) {
return "";
Expand All @@ -135,7 +135,7 @@ private String _getPskFromNetworkSectionLines(String[] NetworkSectionLines) {

private Map<String, String> _readWpaSupplicant(String FileContent) {
String[] NetworkSections = FileContent.split("network[=][{]");
Map<String, String> Connections = new HashMap<String, String>();;
Map<String, String> Connections = new HashMap<String, String>();
for (String NetworkSection : NetworkSections) {
String[] NetworkSectionLines = NetworkSection.split("[}]")[0].split("\n");
String Ssid = _getSsidFromNetworkSectionLines(NetworkSectionLines);
Expand Down Expand Up @@ -163,7 +163,7 @@ private Map<String, String> _readWifiConfigStore(String FileContent) {
String ssid = (String) xpather.evaluate("./string[@name='SSID']/text()", conf, XPathConstants.STRING);
String psk = (String) xpather.evaluate("./string[@name='PreSharedKey']/text()", conf, XPathConstants.STRING);
if (ssid.length() > 0 && psk.length() > 0) {
Connections.put(ssid.substring(1, ssid.length() -1), psk.substring(1, psk.length() -1));
Connections.put(ssid.substring(1, ssid.length() - 1), psk.substring(1, psk.length() - 1));
}
}
} catch (ParserConfigurationException | IOException | SAXException | XPathExpressionException e) {
Expand All @@ -177,10 +177,7 @@ private void _populateWifiList(Map<String, String> Connections, String SearchTex
SortedSet<String> Ssids = new TreeSet<>(Connections.keySet());
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
for (String Ssid : Ssids) {
if (
(!SearchText.isEmpty())
&& (!Ssid.toLowerCase().contains(SearchText.toLowerCase()))
) {
if ((!SearchText.isEmpty()) && (!Ssid.toLowerCase().contains(SearchText.toLowerCase()))) {
continue;
}
String Psk = Connections.get(Ssid);
Expand All @@ -196,13 +193,13 @@ private void _populateWifiList(Map<String, String> Connections, String SearchTex
android.R.layout.simple_list_item_2,
new String[]{"ssid", "psk"},
new int[]{
android.R.id.text1,
android.R.id.text2
android.R.id.text1,
android.R.id.text2
}
) {
@Override
public View getView(int position, View convertView, ViewGroup parent){
View ItemView = super.getView(position,convertView,parent);
public View getView(int position, View convertView, ViewGroup parent) {
View ItemView = super.getView(position, convertView, parent);
((TextView) ItemView.findViewById(android.R.id.text1)).setTextColor(Color.GRAY);
((TextView) ItemView.findViewById(android.R.id.text2)).setTextColor(Color.WHITE);
return ItemView;
Expand Down Expand Up @@ -237,6 +234,7 @@ private Map<String, String> _getNetworks() {
if (wifi_config_store != null) connmap.putAll(_readWifiConfigStore(wifi_config_store));
return connmap;
}

private void _reloadWifiList(String SearchText) {
Map<String, String> Connections = _getNetworks();
_populateWifiList(Connections, SearchText);
Expand Down

0 comments on commit 42009af

Please sign in to comment.