diff options
author | jandegr <jandegr@users.noreply.github.com> | 2018-05-28 14:52:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-28 14:52:10 +0200 |
commit | a1fd5a0735177f504afc29bb894dd13bfbc52384 (patch) | |
tree | 741a3d3df825a9363ba0698c633a0d23eba2e176 | |
parent | b54898370d112ec0fed80b8afc5ac9f2db7cbcb8 (diff) | |
download | navit-a1fd5a0735177f504afc29bb894dd13bfbc52384.tar.gz |
refactor-cleanup
-rw-r--r-- | navit/android/src/org/navitproject/navit/Navit.java | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java index a6e349859..f689f034e 100644 --- a/navit/android/src/org/navitproject/navit/Navit.java +++ b/navit/android/src/org/navitproject/navit/Navit.java @@ -120,8 +120,9 @@ public class Navit extends Activity { public void removeFileIfExists(String source) { File file = new File(source); - if (!file.exists()) + if (!file.exists()) { return; + } file.delete(); } @@ -129,8 +130,9 @@ public class Navit extends Activity { public void copyFileIfExists(String source, String destination) throws IOException { File file = new File(source); - if (!file.exists()) + if (!file.exists()) { return; + } FileInputStream is = null; FileOutputStream os = null; @@ -171,15 +173,17 @@ public class Navit extends Activity { Log.e(TAG, "Res Name " + resname + ", result " + result); int id = NavitResources.getIdentifier(resname, "raw", NAVIT_PACKAGE_NAME); Log.e(TAG, "Res ID " + id); - if (id == 0) + if (id == 0) { return false; + } File resultfile = new File(result); if (!resultfile.exists()) { needsUpdate = true; File path = resultfile.getParentFile(); - if ( !path.exists() && !resultfile.getParentFile().mkdirs()) + if (!path.exists() && !resultfile.getParentFile().mkdirs()) { return false; + } } else { PackageManager pm = getPackageManager(); ApplicationInfo appInfo; @@ -191,8 +195,9 @@ public class Navit extends Activity { Log.e(TAG, "Could not read package infos"); e.printStackTrace(); } - if (apkUpdateTime > resultfile.lastModified()) + if (apkUpdateTime > resultfile.lastModified()) { needsUpdate = true; + } } if (needsUpdate) { @@ -242,9 +247,9 @@ public class Navit extends Activity { } }); infobox.show(); - SharedPreferences.Editor edit_settings = settings.edit(); - edit_settings.putBoolean("firstStart", false); - edit_settings.apply(); + SharedPreferences.Editor editSettings = settings.edit(); + editSettings.putBoolean("firstStart", false); + editSettings.apply(); } } @@ -304,7 +309,7 @@ public class Navit extends Activity { action_bar_default_height, navigation_bar_height, navigation_bar_height_landscape, navigation_bar_width)); if ((ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != - PackageManager.PERMISSION_GRANTED)|| (ContextCompat.checkSelfPermission(this, + PackageManager.PERMISSION_GRANTED) || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) { Log.d (TAG,"ask for permission(s)"); ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE, @@ -346,7 +351,7 @@ public class Navit extends Activity { int height = display.getHeight(); metrics = new DisplayMetrics(); display.getMetrics(Navit.metrics); - int densityDpi = (int)(( Navit.metrics.density * 160) - .5f); + int densityDpi = (int)((Navit.metrics.density * 160) - .5f); Log.d(TAG, "Navit -> pixels x=" + width + " pixels y=" + height); Log.d(TAG, "Navit -> dpi=" + densityDpi); Log.d(TAG, "Navit -> density=" + Navit.metrics.density); @@ -361,7 +366,7 @@ public class Navit extends Activity { Log.e(TAG, "Failed to extract language resource " + langc); } - String my_display_density = "mdpi"; + String my_display_density; if (densityDpi <= 120) { my_display_density = "ldpi"; } else if (densityDpi <= 160) { @@ -413,8 +418,8 @@ public class Navit extends Activity { if (System.currentTimeMillis() <= Navit.startup_intent_timestamp + 4000L) { Log.d(TAG, "**2**A " + startup_intent.getAction()); Log.d(TAG, "**2**D " + startup_intent.getDataString()); - String navi_scheme = startup_intent.getScheme(); - if ( navi_scheme != null && navi_scheme.equals("google.navigation")) { + String naviScheme = startup_intent.getScheme(); + if (naviScheme != null && naviScheme.equals("google.navigation")) { parseNavigationURI(startup_intent.getData().getSchemeSpecificPart()); } } else { @@ -473,8 +478,8 @@ public class Navit extends Activity { String[] naviData = schemeSpecificPart.split("&"); Pattern p = Pattern.compile("(.*)=(.*)"); Map<String,String> params = new HashMap<>(); - for (int count = 0; count < naviData.length; count++) { - Matcher m = p.matcher(naviData[count]); + for (String aNaviData : naviData) { + Matcher m = p.matcher(aNaviData); if (m.matches()) { params.put(m.group(1), m.group(2)); @@ -593,7 +598,7 @@ public class Navit extends Activity { return true; } - public void runOptionsItem(int id) { + private void runOptionsItem(int id) { switch (id) { case 1 : // zoom in @@ -611,8 +616,8 @@ public class Navit extends Activity { break; case 3 : // map download menu - Intent map_download_list_activity = new Intent(this, NavitDownloadSelectMapActivity.class); - startActivityForResult(map_download_list_activity, Navit.NavitDownloaderSelectMap_id); + Intent mapDownloadListActivity = new Intent(this, NavitDownloadSelectMapActivity.class); + startActivityForResult(mapDownloadListActivity, Navit.NavitDownloaderSelectMap_id); break; case 5 : // toggle the normal POI layers and labels (to avoid double POIs) @@ -674,7 +679,7 @@ public class Navit extends Activity { /** * @brief Shows the native keyboard or other input method. */ - public int showNativeKeyboard() { + int showNativeKeyboard() { /* * Apologies for the huge mess that this function is, but Android's soft input API is a big * nightmare. Its devs have mercifully given us an option to show or hide the keyboard, but @@ -683,7 +688,7 @@ public class Navit extends Activity { */ Configuration config = getResources().getConfiguration(); if ((config.keyboard == Configuration.KEYBOARD_QWERTY) - && (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)){ + && (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)) { /* physical keyboard present, exit */ return 0; } @@ -715,7 +720,7 @@ public class Navit extends Activity { /** * @brief Hides the native keyboard or other input method. */ - public void hideNativeKeyboard() { + void hideNativeKeyboard() { mgr.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); show_soft_keyboard_now_showing = false; } |