Back to project page wigle-wifi-wardriving.
The source code is released under:
/* * Copyright (c) 2010-2012, Andrew Carra, Robert Hagemann, Hugh Kennedy * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permi...
If you think the Android project wigle-wifi-wardriving listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.wigle.wigleandroid; /* w ww .jav a2s . c o m*/ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import android.content.SharedPreferences; /** * filter matchers */ public final class FilterMatcher { private static boolean isFilterOn( final SharedPreferences prefs, final String prefix ) { return prefs.getBoolean( prefix + ListFragment.PREF_MAPF_ENABLED, true ); } public static Matcher getFilterMatcher( final SharedPreferences prefs, final String prefix ) { final String regex = prefs.getString( prefix + ListFragment.PREF_MAPF_REGEX, "" ); Matcher matcher = null; if ( isFilterOn( prefs, prefix ) && ! "".equals(regex) ) { try { Pattern pattern = Pattern.compile( regex, Pattern.CASE_INSENSITIVE ); matcher = pattern.matcher( "" ); } catch ( PatternSyntaxException ex ) { MainActivity.error("regex pattern exception: " + ex); } } return matcher; } public static boolean isOk( final Matcher matcher, final SharedPreferences prefs, final String prefix, final Network network ) { if ( ! isFilterOn( prefs, prefix ) ) { return true; } boolean retval = true; if ( matcher != null ) { matcher.reset(network.getSsid()); final boolean invert = prefs.getBoolean( prefix + ListFragment.PREF_MAPF_INVERT, false ); final boolean matches = matcher.find(); if ( ! matches && ! invert) { return false; } else if ( matches && invert ) { return false; } } if ( NetworkType.WIFI.equals( network.getType() ) ) { switch ( network.getCrypto() ) { case Network.CRYPTO_NONE: if ( ! prefs.getBoolean( prefix + ListFragment.PREF_MAPF_OPEN, true ) ) { return false; } break; case Network.CRYPTO_WEP: if ( ! prefs.getBoolean( prefix + ListFragment.PREF_MAPF_WEP, true ) ) { return false; } break; case Network.CRYPTO_WPA: if ( ! prefs.getBoolean( prefix + ListFragment.PREF_MAPF_WPA, true ) ) { return false; } break; default: MainActivity.error( "unhandled crypto: " + network ); } } else { if ( ! prefs.getBoolean( prefix + ListFragment.PREF_MAPF_CELL, true ) ) { return false; } } return retval; } }