diff options
Diffstat (limited to 'navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java')
-rw-r--r-- | navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java index bb66a8df7..8f816df60 100644 --- a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java +++ b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java @@ -1,4 +1,4 @@ -/** +/* * Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team * * This program is free software; you can redistribute it and/or modify it under the terms of the @@ -15,6 +15,8 @@ package org.navitproject.navit; +import static org.navitproject.navit.NavitAppConfig.getTstring; + import android.Manifest; import android.app.Activity; import android.app.AlertDialog; @@ -37,58 +39,59 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; + public class NavitDownloadSelectMapActivity extends ExpandableListActivity { private static final String MAP_BULLETPOINT = " * "; - private static SimpleExpandableListAdapter adapter = null; - private static ArrayList<HashMap<String, String>> downloaded_maps_childs = null; - private static ArrayList<HashMap<String, String>> maps_current_position_childs = null; - private static boolean currentLocationKnown = false; - private final String TAG = this.getClass().getName(); + private static SimpleExpandableListAdapter sAdapter = null; + private static ArrayList<HashMap<String, String>> sDownloadedMapsChilds = null; + private static ArrayList<HashMap<String, String>> sMapsCurrentPositionChilds = null; + private static boolean sCurrentLocationKnown = false; + private static final String TAG = "DownloadSelectMapAct"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (adapter == null) { - adapter = createAdapter(); + if (sAdapter == null) { + sAdapter = createAdapter(); } updateDownloadedMaps(); - updateMapsForLocation(NavitMapDownloader.osm_maps); - setListAdapter(adapter); + updateMapsForLocation(); + setListAdapter(sAdapter); try { - setTitle(String.valueOf(getFreeSpace() / 1024 / 1024) + "MB available"); + setTitle(getFreeSpace() / 1024 / 1024 + "MB available"); } catch (Exception e) { Log.e(TAG, "Exception " + e.getClass().getName() + " during getFreeSpace, reporting 'no sdcard present'"); NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null, String.format( - (Navit.getInstance().getTstring(R.string.map_location_unavailable)), - Navit.map_filename_path), + (getTstring(R.string.map_location_unavailable)), + Navit.sMapFilenamePath), -1, 0, 0); finish(); } } private long getFreeSpace() { - StatFs fsInfo = new StatFs(Navit.map_filename_path); + StatFs fsInfo = new StatFs(Navit.sMapFilenamePath); return (long) fsInfo.getAvailableBlocks() * fsInfo.getBlockSize(); } private void updateDownloadedMaps() { - downloaded_maps_childs.clear(); + sDownloadedMapsChilds.clear(); for (NavitMap map : NavitMapDownloader.getAvailableMaps()) { - HashMap<String, String> child = new HashMap<String, String>(); - child.put("map_name", map.mapName + " " + (map.size() / 1024 / 1024) + "MB"); + HashMap<String, String> child = new HashMap<>(); + child.put("map_name", map.mMapName + " " + (map.size() / 1024 / 1024) + "MB"); child.put("map_location", map.getLocation()); - downloaded_maps_childs.add(child); + sDownloadedMapsChilds.add(child); } } - private void updateMapsForLocation(NavitMapDownloader.osm_map_values[] osm_maps) { - Location currentLocation = NavitVehicle.lastLocation; - if (maps_current_position_childs.size() == 0 || (currentLocation != null - && !currentLocationKnown)) { + private void updateMapsForLocation() { + Location currentLocation = NavitVehicle.sLastLocation; + if (sMapsCurrentPositionChilds.size() == 0 || (currentLocation != null + && !sCurrentLocationKnown)) { if (currentLocation == null) { LocationManager mapLocationManager = (LocationManager) getSystemService( Context.LOCATION_SERVICE); @@ -114,22 +117,23 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { } } } else { - currentLocationKnown = true; + sCurrentLocationKnown = true; } if (currentLocation != null) { // if this map contains data to our current position, add it to // the MapsOfCurrentLocation-list - for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; + for (int currentMapIndex = 0; currentMapIndex < NavitMapDownloader.osm_maps.length; currentMapIndex++) { - if (osm_maps[currentMapIndex].isInMap(currentLocation)) { - HashMap<String, String> currentPositionMapChild = new HashMap<String, String>(); - currentPositionMapChild.put("map_name", osm_maps[currentMapIndex].map_name + " " - + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + if (NavitMapDownloader.osm_maps[currentMapIndex].isInMap(currentLocation)) { + HashMap<String, String> currentPositionMapChild = new HashMap<>(); + currentPositionMapChild.put("map_name", NavitMapDownloader.osm_maps[currentMapIndex].mMapName + + " " + + (NavitMapDownloader.osm_maps[currentMapIndex].mEstSizeBytes / 1024 / 1024) + "MB"); currentPositionMapChild.put("map_index", String.valueOf(currentMapIndex)); - maps_current_position_childs.add(currentPositionMapChild); + sMapsCurrentPositionChilds.add(currentPositionMapChild); } } } @@ -138,45 +142,41 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { private SimpleExpandableListAdapter createAdapter() { - NavitMapDownloader.osm_map_values[] osm_maps = NavitMapDownloader.osm_maps; - - ArrayList<HashMap<String, String>> resultGroups = new ArrayList<HashMap<String, String>>(); - ArrayList<ArrayList<HashMap<String, String>>> resultChilds = - new ArrayList<ArrayList<HashMap<String, String>>>(); + ArrayList<HashMap<String, String>> resultGroups = new ArrayList<>(); // add already downloaded maps (group and empty child list - HashMap<String, String> downloaded_maps_hash = new HashMap<String, String>(); - downloaded_maps_hash - .put("category_name", Navit.getInstance().getTstring(R.string.maps_installed)); - resultGroups.add(downloaded_maps_hash); - downloaded_maps_childs = new ArrayList<HashMap<String, String>>(); - resultChilds.add(downloaded_maps_childs); + HashMap<String, String> downloadedMapsHash = new HashMap<>(); + downloadedMapsHash.put("category_name", getTstring(R.string.maps_installed)); + resultGroups.add(downloadedMapsHash); + sDownloadedMapsChilds = new ArrayList<>(); + ArrayList<ArrayList<HashMap<String, String>>> resultChilds = new ArrayList<>(); + resultChilds.add(sDownloadedMapsChilds); - ArrayList<HashMap<String, String>> secList = new ArrayList<HashMap<String, String>>(); - maps_current_position_childs = new ArrayList<HashMap<String, String>>(); + ArrayList<HashMap<String, String>> secList = new ArrayList<>(); + sMapsCurrentPositionChilds = new ArrayList<>(); // maps containing the current location - HashMap<String, String> matching_maps = new HashMap<String, String>(); - matching_maps.put("category_name", - Navit.getInstance().getTstring(R.string.maps_for_current_location)); - resultGroups.add(matching_maps); - resultChilds.add(maps_current_position_childs); - + HashMap<String, String> matchingMaps = new HashMap<>(); + matchingMaps.put("category_name", + getTstring(R.string.maps_for_current_location)); + resultGroups.add(matchingMaps); + resultChilds.add(sMapsCurrentPositionChilds); + NavitMapDownloader.OsmMapValues[] osmMaps = NavitMapDownloader.osm_maps; // add all maps - for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; currentMapIndex++) { - if (osm_maps[currentMapIndex].level == 0) { + for (int currentMapIndex = 0; currentMapIndex < osmMaps.length; currentMapIndex++) { + if (osmMaps[currentMapIndex].mLevel == 0) { if (secList.size() > 0) { resultChilds.add(secList); } - secList = new ArrayList<HashMap<String, String>>(); - HashMap<String, String> map_info_hash = new HashMap<String, String>(); - map_info_hash.put("category_name", osm_maps[currentMapIndex].map_name); - resultGroups.add(map_info_hash); + secList = new ArrayList<>(); + HashMap<String, String> mapInfoHash = new HashMap<>(); + mapInfoHash.put("category_name", osmMaps[currentMapIndex].mMapName); + resultGroups.add(mapInfoHash); } - HashMap<String, String> child = new HashMap<String, String>(); - child.put("map_name", (osm_maps[currentMapIndex].level > 1 ? MAP_BULLETPOINT : "") - + osm_maps[currentMapIndex].map_name + " " - + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB"); + HashMap<String, String> child = new HashMap<>(); + child.put("map_name", (osmMaps[currentMapIndex].mLevel > 1 ? MAP_BULLETPOINT : "") + + osmMaps[currentMapIndex].mMapName + " " + + (osmMaps[currentMapIndex].mEstSizeBytes / 1024 / 1024) + "MB"); child.put("map_index", String.valueOf(currentMapIndex)); secList.add(child); @@ -197,14 +197,14 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { Log.d(TAG, "p:" + groupPosition + ", child_pos:" + childPosition); @SuppressWarnings("unchecked") - HashMap<String, String> child = (HashMap<String, String>) adapter.getChild(groupPosition, childPosition); + HashMap<String, String> child = (HashMap<String, String>) sAdapter.getChild(groupPosition, childPosition); - String map_index = child.get("map_index"); - if (map_index != null) { - int mi = Integer.parseInt(map_index); - if (NavitMapDownloader.osm_maps[mi].est_size_bytes / 1024 / 1024 / 950 >= 4) { + String mapIndex = child.get("map_index"); + if (mapIndex != null) { + int mi = Integer.parseInt(mapIndex); + if (NavitMapDownloader.osm_maps[mi].mEstSizeBytes / 1024 / 1024 / 950 >= 4) { NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null, - Navit.getInstance().getTstring(R.string.map_download_oversize), + getTstring(R.string.map_download_oversize), -1, 0, 0); return true; } @@ -219,25 +219,25 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { return true; } - private void askForMapDeletion(final String map_location) { + private void askForMapDeletion(final String mapLocation) { AlertDialog.Builder deleteMapBox = new AlertDialog.Builder(this); - deleteMapBox.setTitle(Navit.getInstance().getTstring(R.string.map_delete)); + deleteMapBox.setTitle(getTstring(R.string.map_delete)); deleteMapBox.setCancelable(true); - NavitMap maptoDelete = new NavitMap(map_location); + NavitMap maptoDelete = new NavitMap(mapLocation); deleteMapBox.setMessage( - maptoDelete.mapName + " " + String.valueOf(maptoDelete.size() / 1024 / 1024) + maptoDelete.mMapName + " " + maptoDelete.size() / 1024 / 1024 + "MB"); // TRANS - deleteMapBox.setPositiveButton(Navit.getInstance().getTstring(R.string.yes), + deleteMapBox.setPositiveButton(getTstring(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.d(TAG, "Delete Map"); - Message msg = Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler, - NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal()); + Message msg = Message.obtain(NavitGraphics.sCallbackHandler, + NavitGraphics.MsgType.CLB_DELETE_MAP.ordinal()); Bundle b = new Bundle(); - b.putString("title", map_location); + b.putString("title", mapLocation); msg.setData(b); msg.sendToTarget(); finish(); @@ -245,7 +245,7 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { }); // TRANS - deleteMapBox.setNegativeButton((Navit.getInstance().getTstring(R.string.no)), + deleteMapBox.setNegativeButton((getTstring(R.string.no)), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.d(TAG, "don't delete map"); |