Skip to content

Commit

Permalink
updated map pin icons, changed colours as per #166, added neighbourin…
Browse files Browse the repository at this point in the history
…g cell info to map if available, added phone state listener to update the map when cell info changes
  • Loading branch information
tobykurien committed Oct 26, 2014
1 parent 6a7eafe commit d18b44b
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.database.Cursor;
import android.location.Location;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.LocalBroadcastManager;
import android.telephony.CellInfo;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Menu;
Expand Down Expand Up @@ -83,6 +85,18 @@ public class MapViewerOsmDroid extends FragmentActivity implements OnSharedPrefe
private MyLocationNewOverlay mMyLocationOverlay;
private CellTowerItemizedOverlay mOpenCellIdOverlay;

private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
loadEntries();
}

@Override
public void onCellInfoChanged(List<CellInfo> cellInfo) {
loadEntries();
}
};

/**
* Called when the activity is first created.
*/
Expand All @@ -100,6 +114,10 @@ public void onCreate(Bundle savedInstanceState) {
// Bind to LocalService
Intent intent = new Intent(mContext, AimsicdService.class);
mContext.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CELL_LOCATION |
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
}

@Override
Expand Down Expand Up @@ -134,6 +152,9 @@ protected void onDestroy() {
mBound = false;
}

TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);

LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
}

Expand Down Expand Up @@ -363,7 +384,7 @@ protected GeoPoint doInBackground(Void... voids) {
new MarkerData("" + cellID, "" + loc.getLatitude(),"" +
loc.getLongitude(), "" + lac, "" + mcc, "" + mnc, "", false));

ovm.setMarker(getResources().getDrawable(R.drawable.ic_map_pin_green));
ovm.setMarker(getResources().getDrawable(R.drawable.ic_map_pin_blue));
items.add(ovm);


Expand Down Expand Up @@ -410,6 +431,25 @@ public void run() {
c.close();
mDbHelper.close();

// plot neighbouring cells
while (mAimsicdService == null) try { Thread.sleep(100); } catch (Exception e) {};
List<Cell> nc = mAimsicdService.getCellTracker().updateNeighbouringCells();
for (Cell cell : nc) {
try {
loc = new GeoPoint(cell.getLat(), cell.getLon());
CellTowerOverlayItem ovm = new CellTowerOverlayItem("CellID - " + cell.getCID(),
"",
loc,
new MarkerData("" + cell.getCID(), "" + loc.getLatitude(),"" +
loc.getLongitude(), "" + cell.getLAC(), "" + cell.getMCC(), "" + cell.getMNC(), "", false));

ovm.setMarker(getResources().getDrawable(R.drawable.ic_map_pin_orange));
items.add(ovm);
} catch (Exception e) {
Log.e("map", "Error plotting neightbouring cells", e);
}
}

mMap.getOverlays().remove(mOpenCellIdOverlay);
mOpenCellIdOverlay.addItems(items);
mMap.getOverlays().add(mOpenCellIdOverlay);
Expand Down Expand Up @@ -475,9 +515,9 @@ private void loadOpenCellIDMarkers() {
"",
location,
new MarkerData("" + cellID, "" + location.getLatitude(),"" +
location.getLongitude(), "" + lac, "", "", "", false));
location.getLongitude(), "" + lac, "" + mcc, "" + mnc, "" + samples, false));

ovm.setMarker(getResources().getDrawable(R.drawable.ic_map_pin_blue));
ovm.setMarker(getResources().getDrawable(R.drawable.ic_map_pin_green));
items.add(ovm);
} while (c.moveToNext());
}
Expand Down
Binary file modified app/src/main/res/drawable-hdpi/ic_map_pin_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_map_pin_orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_map_pin_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-mdpi/ic_map_pin_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_map_pin_orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_map_pin_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xhdpi/ic_map_pin_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable-xxhdpi/ic_map_pin_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d18b44b

Please sign in to comment.