Skip to content

Commit

Permalink
more info on NetworkActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzilladev committed Feb 20, 2011
1 parent b0b5827 commit 47968c6
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 49 deletions.
2 changes: 0 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="libs/slf4j-android-1.5.8.jar"/>
<classpathentry kind="lib" path="libs/TTS_library_stub.jar"/>
<classpathentry kind="lib" path="libs/httpmime-4.0.1.jar"/>
<classpathentry kind="lib" path="libs/apache-mime4j-0.6.jar"/>
<classpathentry kind="lib" path="libs/osmdroid-android.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
7 changes: 6 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ kismet drone support
some response/info/stat about uploaded files
try tabs on bottom in landscape mode

--- before release ---
net-connect with password
map ssid filter
maybe: goog maps hax

--- done ---
* 1.34 ()
Show ssid on map when zoomed in
Click on network in list to bring up info on it
Click on network in list to bring up info, map, and connect button
Save location every minute so map is nearby if location was lost
First-seen time on list view
Cell tower technology on list view (HSPDA, etc)
Expand Down
111 changes: 107 additions & 4 deletions res/layout/network.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,129 @@
android:layout_width="fill_parent" android:layout_height="wrap_content">

<ImageView android:text="wepicon" android:id="@+id/wepicon" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:paddingTop="2px"
android:paddingLeft="2px" android:paddingRight="13px"/>
android:layout_height="wrap_content" android:paddingTop="4px"
android:paddingLeft="4px" android:paddingRight="4px"
android:layout_weight="1"
/>

<TextView
android:layout_width="fill_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ssid"
android:textSize="24sp"
android:textColor="#AAEE50"
android:gravity="center"
android:layout_weight="10"
/>

<ImageView android:text="wepicon" android:id="@+id/wepicon2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:paddingTop="4px"
android:paddingLeft="4px" android:paddingRight="4px"
android:layout_weight="1"
/>
</LinearLayout>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/bssid"
android:textSize="24sp"
android:textSize="20sp"
android:textColor="#AAAA00"
android:gravity="center"
/>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/na_signal_text"
android:text="Signal:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="@+id/na_signal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>

<TextView
android:id="@+id/na_type_text"
android:text=" Type:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="@+id/na_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>

<TextView
android:id="@+id/na_firsttime_text"
android:text=" First Seen:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<TextView
android:id="@+id/na_firsttime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>

</LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/na_cap_text"
android:text="Capabilities: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/na_cap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/na_chan_text"
android:text="Channel: "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/na_chan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>

<LinearLayout
android:id="@+id/horizontalLine"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#A07070"
/>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
Expand Down
86 changes: 62 additions & 24 deletions src/net/wigle/wigleandroid/NetworkActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.wigle.wigleandroid;

import java.text.SimpleDateFormat;

import net.wigle.wigleandroid.MainActivity.Doer;

import org.osmdroid.api.IMapController;
Expand Down Expand Up @@ -27,6 +29,7 @@ public class NetworkActivity extends Activity {
private Network network;
private IMapController mapControl;
private IMapView mapView;
private SimpleDateFormat format;

/** Called when the activity is first created. */
@Override
Expand All @@ -39,6 +42,7 @@ public void onCreate(Bundle savedInstanceState) {
ListActivity.info( "bssid: " + bssid );

network = ListActivity.getNetworkCache().get(bssid);
format = NetworkListAdapter.getConstructionTimeFormater( this );

TextView tv = (TextView) findViewById( R.id.bssid );
tv.setText( bssid );
Expand All @@ -47,39 +51,73 @@ public void onCreate(Bundle savedInstanceState) {
tv = (TextView) findViewById( R.id.ssid );
tv.setText( network.getSsid() );

final int image = NetworkListAdapter.getImage( network );
final ImageView ico = (ImageView) findViewById( R.id.wepicon );
ico.setImageResource( NetworkListAdapter.getImage( network ) );

GeoPoint point = network.getGeoPoint();
// ListActivity.info("point: " + point );
if ( point != null ) {
// view
final RelativeLayout rlView = (RelativeLayout) this.findViewById( R.id.netmap_rl );

// possibly choose goog maps here
OpenStreetMapViewWrapper osmvw = new OpenStreetMapViewWrapper( this );
osmvw.setSingleNetwork( network );
mapView = osmvw;

if ( mapView instanceof MapView ) {
MapView osmMapView = (MapView) mapView;
rlView.addView( osmMapView );
osmMapView.setBuiltInZoomControls( true );
osmMapView.setMultiTouchControls( true );
}
mapControl = mapView.getController();

mapControl.setCenter( point );
mapControl.setZoom( 16 );
mapControl.setCenter( point );
ico.setImageResource( image );
final ImageView ico2 = (ImageView) findViewById( R.id.wepicon2 );
ico2.setImageResource( image );

tv = (TextView) findViewById( R.id.na_signal );
final int level = network.getLevel();
tv.setTextColor( NetworkListAdapter.getSignalColor( level ) );
tv.setText( Integer.toString( level ) );

tv = (TextView) findViewById( R.id.na_type );
tv.setText( network.getType().name() );

tv = (TextView) findViewById( R.id.na_firsttime );
tv.setText( NetworkListAdapter.getConstructionTime( format, network ) );

tv = (TextView) findViewById( R.id.na_chan );
if ( ! NetworkType.WIFI.equals(network.getType()) ) {
tv.setText( "N/A" );
}
else {
Integer chan = network.getChannel();
chan = chan != null ? chan : network.getFrequency();
tv.setText( Integer.toString(chan) );
}

tv = (TextView) findViewById( R.id.na_cap );
tv.setText( network.getCapabilities() );

setupMap( network );
setupButton( network );
}
}

private void setupMap( final Network network ) {
GeoPoint point = network.getGeoPoint();
// ListActivity.info("point: " + point );
if ( point != null ) {
// view
final RelativeLayout rlView = (RelativeLayout) this.findViewById( R.id.netmap_rl );

// possibly choose goog maps here
OpenStreetMapViewWrapper osmvw = new OpenStreetMapViewWrapper( this );
osmvw.setSingleNetwork( network );
mapView = osmvw;

if ( mapView instanceof MapView ) {
MapView osmMapView = (MapView) mapView;
rlView.addView( osmMapView );
osmMapView.setBuiltInZoomControls( true );
osmMapView.setMultiTouchControls( true );
}
mapControl = mapView.getController();

mapControl.setCenter( point );
mapControl.setZoom( 16 );
mapControl.setCenter( point );
}
}

private void setupButton( final Network network ) {
final Button connectButton = (Button) findViewById( R.id.connect_button );
if ( ! NetworkType.WIFI.equals(network.getType()) ) {
connectButton.setEnabled( false );
}

connectButton.setOnClickListener( new OnClickListener() {
public void onClick( final View buttonView ) {
MainActivity.createConfirmation( NetworkActivity.this, "You have permission to access this network?", new Doer() {
Expand Down
49 changes: 31 additions & 18 deletions src/net/wigle/wigleandroid/NetworkListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@ public final class NetworkListAdapter extends ArrayAdapter<Network> {

private final SimpleDateFormat format;

public NetworkListAdapter( Context context, int rowLayout ) {
public NetworkListAdapter( final Context context, final int rowLayout ) {
super( context, rowLayout );
this.mInflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );

format = getConstructionTimeFormater( context );
}

public static SimpleDateFormat getConstructionTimeFormater( final Context context ) {
final int value = Settings.System.getInt(context.getContentResolver(), Settings.System.TIME_12_24, -1);
SimpleDateFormat format = null;
if ( value == 24 ) {
format = new SimpleDateFormat("H:mm:ss");
}
else {
format = new SimpleDateFormat("h:mm:ss a");
}
return format;
}

@Override
Expand All @@ -64,33 +69,41 @@ public View getView( final int position, final View convertView, final ViewGroup
tv.setText( network.getSsid() + " ");

tv = (TextView) row.findViewById( R.id.time );
tv.setText( format.format(new Date(network.getConstructionTime())));
tv.setText( getConstructionTime( format, network ) );

tv = (TextView) row.findViewById( R.id.level_string );
int level = network.getLevel();
final int level = network.getLevel();
tv.setTextColor( getSignalColor( level ) );
tv.setText( Integer.toString( level ) );

tv = (TextView) row.findViewById( R.id.detail );
String det = network.getDetail();
tv.setText( det );
// status( position + " view done. ms: " + (System.currentTimeMillis() - start ) );

return row;
}

public static String getConstructionTime( final SimpleDateFormat format, final Network network ) {
return format.format( new Date( network.getConstructionTime() ) );
}

public static int getSignalColor( final int level ) {
int color = COLOR_1;
if ( level <= -90 ) {
tv.setTextColor( COLOR_5 );
color = COLOR_5;
}
else if ( level <= -80 ) {
tv.setTextColor( COLOR_4 );
color = COLOR_4;
}
else if ( level <= -70 ) {
tv.setTextColor( COLOR_3 );
color = COLOR_3;
}
else if ( level <= -60 ) {
tv.setTextColor( COLOR_2 );
color = COLOR_2;
}
else {
tv.setTextColor( COLOR_1 );
}
tv.setText( Integer.toString( level ) );

tv = (TextView) row.findViewById( R.id.detail );
String det = network.getDetail();
tv.setText( det );
// status( position + " view done. ms: " + (System.currentTimeMillis() - start ) );

return row;
return color;
}

public static int getImage( final Network network ) {
Expand Down

0 comments on commit 47968c6

Please sign in to comment.