summaryrefslogtreecommitdiff
path: root/navit/android
diff options
context:
space:
mode:
Diffstat (limited to 'navit/android')
-rw-r--r--navit/android/src/org/navitproject/navit/Navit.java92
-rwxr-xr-xnavit/android/src/org/navitproject/navit/NavitAppConfig.java3
-rw-r--r--navit/android/src/org/navitproject/navit/NavitDialogs.java12
-rw-r--r--navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java2
-rw-r--r--navit/android/src/org/navitproject/navit/NavitGraphics.java127
-rw-r--r--navit/android/src/org/navitproject/navit/NavitMap.java8
-rw-r--r--navit/android/src/org/navitproject/navit/NavitMapDownloader.java50
-rw-r--r--navit/android/src/org/navitproject/navit/NavitSpeech2.java7
-rw-r--r--navit/android/src/org/navitproject/navit/NavitVehicle.java3
9 files changed, 130 insertions, 174 deletions
diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java
index f0cb5c3b5..9a0df2fb4 100644
--- a/navit/android/src/org/navitproject/navit/Navit.java
+++ b/navit/android/src/org/navitproject/navit/Navit.java
@@ -23,20 +23,13 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
-import android.annotation.TargetApi;
import android.app.Activity;
-import android.app.ActivityManager.TaskDescription;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Notification;
@@ -51,9 +44,6 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Color;
import android.graphics.Point;
import android.Manifest;
import android.media.AudioManager;
@@ -63,11 +53,6 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Message;
import android.os.PowerManager;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
-import android.text.SpannableString;
-import android.text.method.LinkMovementMethod;
-import android.text.util.Linkify;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
@@ -77,11 +62,10 @@ import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
import android.widget.Toast;
import android.support.v4.app.NotificationCompat;
-
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
public class Navit extends Activity
{
@@ -117,8 +101,13 @@ public class Navit extends Activity
Boolean isFullscreen = false;
private static final int MY_PERMISSIONS_REQUEST_ALL = 101;
public static NotificationManager nm;
+ private static Navit navit;
+
+ public static Navit getInstance() {
+ return navit;
+ }
+
-
/**
* @brief A Runnable to restore soft input when the user returns to the activity.
*
@@ -168,7 +157,6 @@ public class Navit extends Activity
if (os != null)
os.close();
}
- return;
}
@@ -259,7 +247,7 @@ public class Navit extends Activity
infobox.show();
SharedPreferences.Editor edit_settings = settings.edit();
edit_settings.putBoolean("firstStart", false);
- edit_settings.commit();
+ edit_settings.apply();
}
}
@@ -273,6 +261,7 @@ public class Navit extends Activity
else
this.getActionBar().hide();
+ navit = this;
dialogs = new NavitDialogs(this);
NavitResources = getResources();
@@ -327,14 +316,13 @@ public class Navit extends Activity
// get the local language -------------
Locale locale = java.util.Locale.getDefault();
String lang = locale.getLanguage();
- String langu = lang;
String langc = lang;
Log.d(TAG, "lang=" + lang);
- int pos = langu.indexOf('_');
+ int pos = lang.indexOf('_');
if (pos != -1)
{
- langc = langu.substring(0, pos);
- NavitLanguage = langc + langu.substring(pos).toUpperCase(locale);
+ langc = lang.substring(0, pos);
+ NavitLanguage = langc + lang.substring(pos).toUpperCase(locale);
Log.d(TAG, "substring lang " + NavitLanguage.substring(pos).toUpperCase(locale));
// set lang. for translation
NavitTextTranslations.main_language = langc;
@@ -420,7 +408,6 @@ public class Navit extends Activity
Log.e(TAG, "Failed to extract navit.xml for " + my_display_density);
}
- // --> dont use android.os.Build.VERSION.SDK_INT, needs API >= 4
Log.d(TAG, "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
NavitMain(this, NavitLanguage, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density, NAVIT_DATA_DIR+"/bin/navit",map_filename_path);
@@ -488,22 +475,20 @@ public class Navit extends Activity
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_ALL: {
if (grantResults.length > 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED
- && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
- // ok, we got permissions
- } else {
- AlertDialog.Builder infobox = new AlertDialog.Builder(this);
- infobox.setTitle(getString(R.string.permissions_info_box_title)); // TRANS
- infobox.setCancelable(false);
- infobox.setMessage(getString(R.string.permissions_not_granted));
- // TRANS
- infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface arg0, int arg1) {
- exit();
- }
- });
- infobox.show();
+ && grantResults[1] == PackageManager.PERMISSION_GRANTED) {
+ return;
}
- return;
+ AlertDialog.Builder infobox = new AlertDialog.Builder(this);
+ infobox.setTitle(getString(R.string.permissions_info_box_title)); // TRANS
+ infobox.setCancelable(false);
+ infobox.setMessage(getString(R.string.permissions_not_granted));
+ // TRANS
+ infobox.setPositiveButton(getString(R.string.initial_info_box_OK), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface arg0, int arg1) {
+ exit();
+ }
+ });
+ infobox.show();
}
}
}
@@ -552,7 +537,9 @@ public class Navit extends Activity
msg.setData(b);
msg.sendToTarget();
Log.e(TAG, "target found (b): " + geoString);
- } catch (NumberFormatException e) { } // nothing to do here
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
}
}
else {
@@ -599,19 +586,24 @@ public class Navit extends Activity
}
// define callback id here
- public static NavitGraphics N_NavitGraphics = null;
+ private NavitGraphics N_NavitGraphics = null;
// callback id gets set here when called from NavitGraphics
- public static void setKeypressCallback(int kp_cb_id, NavitGraphics ng)
+ public void setKeypressCallback(int kp_cb_id, NavitGraphics ng)
{
N_NavitGraphics = ng;
}
- public static void setMotionCallback(int mo_cb_id, NavitGraphics ng)
+ public void setMotionCallback(int mo_cb_id, NavitGraphics ng)
{
N_NavitGraphics = ng;
}
+ public NavitGraphics getNavitGraphics() {
+ return N_NavitGraphics;
+ }
+
+
public void start_targetsearch_from_intent(String target_address)
{
if (target_address == null || target_address.equals(""))
@@ -711,8 +703,6 @@ public class Navit extends Activity
/**
* @brief Shows the native keyboard or other input method.
- *
- * @return {@code true} if an input method is going to be displayed, {@code false} if not
*/
public int showNativeKeyboard() {
/*
@@ -803,7 +793,7 @@ public class Navit extends Activity
SharedPreferences prefs = this.getSharedPreferences(NAVIT_PREFS,MODE_PRIVATE);
SharedPreferences.Editor prefs_editor = prefs.edit();
prefs_editor.putString("filenamePath", newDir);
- prefs_editor.commit();
+ prefs_editor.apply();
Toast.makeText(this, String.format(Navit.T("New location set to %s\nRestart Navit to apply the changes."),newDir),Toast.LENGTH_LONG).show();
}
else Log.w(TAG, "select path failed");
@@ -834,15 +824,13 @@ public class Navit extends Activity
return true;
}
- public boolean setMapLocation()
+ public void setMapLocation()
{
Intent fileExploreIntent = new Intent(this,FileBrowserActivity.class);
fileExploreIntent
.putExtra(FileBrowserActivity.startDirectoryParameter, "/mnt")
.setAction(FileBrowserActivity.INTENT_ACTION_SELECT_DIR);
- startActivityForResult(fileExploreIntent,NavitSelectStorage_id);
-
- return true;
+ startActivityForResult(fileExploreIntent,NavitSelectStorage_id);
}
@Override
diff --git a/navit/android/src/org/navitproject/navit/NavitAppConfig.java b/navit/android/src/org/navitproject/navit/NavitAppConfig.java
index 1a1a61f94..244cef9ce 100755
--- a/navit/android/src/org/navitproject/navit/NavitAppConfig.java
+++ b/navit/android/src/org/navitproject/navit/NavitAppConfig.java
@@ -7,7 +7,6 @@ import org.navitproject.navit.NavitAddressSearchActivity.NavitAddress;
import android.app.Application;
import android.content.SharedPreferences;
-import android.util.Log;
public class NavitAppConfig extends Application {
@@ -66,6 +65,6 @@ public class NavitAppConfig extends Application {
editSettings.putFloat("LastAddress_Lat_" + String.valueOf(mLastAddressField), newAddress.lat);
editSettings.putFloat("LastAddress_Lon_" + String.valueOf(mLastAddressField), newAddress.lon);
- editSettings.commit();
+ editSettings.apply();
}
}
diff --git a/navit/android/src/org/navitproject/navit/NavitDialogs.java b/navit/android/src/org/navitproject/navit/NavitDialogs.java
index 10f30d5b3..7605b7aa9 100644
--- a/navit/android/src/org/navitproject/navit/NavitDialogs.java
+++ b/navit/android/src/org/navitproject/navit/NavitDialogs.java
@@ -19,7 +19,7 @@ public class NavitDialogs extends Handler{
// Dialogs
public static final int DIALOG_MAPDOWNLOAD = 1;
public static final int DIALOG_BACKUP_RESTORE = 2;
- public static final int DIALOG_SELECT_BACKUP = 3;
+ private static final int DIALOG_SELECT_BACKUP = 3;
// dialog messages
static final int MSG_MAP_DOWNLOAD_FINISHED = 0;
@@ -28,15 +28,15 @@ public class NavitDialogs extends Handler{
static final int MSG_TOAST_LONG = 3;
static final int MSG_POSITION_MENU = 6;
static final int MSG_START_MAP_DOWNLOAD = 7;
- static final int MSG_REMOVE_DIALOG_GENERIC = 99;
- static Handler mHandler;
+ private static final int MSG_REMOVE_DIALOG_GENERIC = 99;
+ private static Handler mHandler;
private ProgressDialog mapdownloader_dialog = null;
private NavitMapDownloader mapdownloader = null;
private Navit mActivity;
- public NavitDialogs(Navit activity) {
+ NavitDialogs(Navit activity) {
super();
mActivity = activity;
mHandler = this;
@@ -69,12 +69,12 @@ public class NavitDialogs extends Handler{
mActivity.removeDialog(DIALOG_MAPDOWNLOAD);
if (msg.getData().getInt("value1") == 1) {
Message msg_out =
- Message.obtain(Navit.N_NavitGraphics.callback_handler,
+ Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler,
NavitGraphics.msg_type.CLB_LOAD_MAP.ordinal());
msg_out.setData(msg.getData());
msg_out.sendToTarget();
- msg_out = Message.obtain(Navit.N_NavitGraphics.callback_handler,
+ msg_out = Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler,
NavitGraphics.msg_type.CLB_CALL_CMD.ordinal());
Bundle b = new Bundle();
int mi=msg.getData().getInt("value2");
diff --git a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java
index 9cc056e31..582179492 100644
--- a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java
+++ b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java
@@ -217,7 +217,7 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity {
public void onClick(DialogInterface arg0, int arg1) {
Log.e("Navit", "Delete Map");
Message msg =
- Message.obtain(Navit.N_NavitGraphics.callback_handler,
+ Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler,
NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal());
Bundle b = new Bundle();
b.putString("title", map_location);
diff --git a/navit/android/src/org/navitproject/navit/NavitGraphics.java b/navit/android/src/org/navitproject/navit/NavitGraphics.java
index a2d8e405f..d40dee3a5 100644
--- a/navit/android/src/org/navitproject/navit/NavitGraphics.java
+++ b/navit/android/src/org/navitproject/navit/NavitGraphics.java
@@ -26,10 +26,8 @@ import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
@@ -38,7 +36,6 @@ import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
-import android.util.FloatMath;
import android.util.Log;
import android.view.ContextMenu;
import android.view.Gravity;
@@ -57,27 +54,27 @@ public class NavitGraphics
{
private NavitGraphics parent_graphics;
private ArrayList<NavitGraphics> overlays = new ArrayList<NavitGraphics>();
- int bitmap_w;
- int bitmap_h;
- int pos_x;
- int pos_y;
- int pos_wraparound;
- int overlay_disabled;
- int bgcolor;
- float trackball_x, trackball_y;
- View view;
- SystemBarTintView navigationTintView;
- SystemBarTintView statusTintView;
- FrameLayout frameLayout;
- RelativeLayout relativelayout;
- NavitCamera camera;
- Activity activity;
-
- public static Boolean in_map = false;
+ private int bitmap_w;
+ private int bitmap_h;
+ private int pos_x;
+ private int pos_y;
+ private int pos_wraparound;
+ private int overlay_disabled;
+ private int bgcolor;
+ private float trackball_x, trackball_y;
+ private View view;
+ private SystemBarTintView navigationTintView;
+ private SystemBarTintView statusTintView;
+ private FrameLayout frameLayout;
+ private RelativeLayout relativelayout;
+ private NavitCamera camera;
+ private Navit activity;
+
+ private static Boolean in_map = false;
// for menu key
private static long time_for_long_press = 300L;
- private static long interval_for_long_press = 200L;
+
private Handler timer_handler = new Handler();
@@ -89,7 +86,7 @@ public class NavitGraphics
statusTintView.setBackgroundColor(bgcolor);
}
- public void SetCamera(int use_camera)
+ private void SetCamera(int use_camera)
{
if (use_camera != 0 && camera == null)
{
@@ -100,7 +97,7 @@ public class NavitGraphics
}
}
- protected Rect get_rect()
+ private Rect get_rect()
{
Rect ret=new Rect();
ret.left=pos_x;
@@ -243,7 +240,9 @@ public class NavitGraphics
e.printStackTrace();
}
}
- catch (NoSuchFieldException ex) {}
+ catch (NoSuchFieldException ex) {
+ ex.printStackTrace();
+ }
return ret_value;
}
@@ -385,7 +384,9 @@ public class NavitGraphics
pos.set(x.floatValue(), y.floatValue());
}
- catch (Exception e){}
+ catch (Exception e){
+ e.printStackTrace();
+ }
}
return pos;
}
@@ -396,6 +397,7 @@ public class NavitGraphics
int i;
String s = null;
boolean handled = true;
+ long interval_for_long_press = 200L;
i = event.getUnicodeChar();
//Log.e("NavitGraphics", "onKeyDown " + keyCode + " " + i);
// Log.e("NavitGraphics","Unicode "+event.getUnicodeChar());
@@ -434,17 +436,15 @@ public class NavitGraphics
// if in menu view:
// use as OK (Enter) key
s = java.lang.String.valueOf((char) 13);
- handled = true;
// dont use menu key here (use it in onKeyUp)
- return handled;
+ return true;
}
else
{
// if on map view:
// volume UP
//s = java.lang.String.valueOf((char) 1);
- handled = false;
- return handled;
+ return true;
}
}
else if (keyCode == android.view.KeyEvent.KEYCODE_SEARCH)
@@ -471,15 +471,13 @@ public class NavitGraphics
// if in menu view:
// use as UP key
s = java.lang.String.valueOf((char) 16);
- handled = true;
}
else
{
// if on map view:
// volume UP
//s = java.lang.String.valueOf((char) 21);
- handled = false;
- return handled;
+ return false;
}
}
else if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_DOWN)
@@ -489,15 +487,13 @@ public class NavitGraphics
// if in menu view:
// use as DOWN key
s = java.lang.String.valueOf((char) 14);
- handled = true;
}
else
{
// if on map view:
// volume DOWN
//s = java.lang.String.valueOf((char) 4);
- handled = false;
- return handled;
+ return false;
}
}
else if (keyCode == android.view.KeyEvent.KEYCODE_DPAD_CENTER)
@@ -530,7 +526,7 @@ public class NavitGraphics
{
KeypressCallback(KeypressCallbackID, s);
}
- return handled;
+ return true;
}
@Override
@@ -547,33 +543,11 @@ public class NavitGraphics
{
if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_UP)
{
- if (!in_map)
- {
- //s = java.lang.String.valueOf((char) 16);
- handled = true;
- return handled;
- }
- else
- {
- //s = java.lang.String.valueOf((char) 21);
- handled = false;
- return handled;
- }
+ return (!in_map);
}
else if (keyCode == android.view.KeyEvent.KEYCODE_VOLUME_DOWN)
{
- if (!in_map)
- {
- //s = java.lang.String.valueOf((char) 14);
- handled = true;
- return handled;
- }
- else
- {
- //s = java.lang.String.valueOf((char) 4);
- handled = false;
- return handled;
- }
+ return (!in_map);
}
else if (keyCode == android.view.KeyEvent.KEYCODE_SEARCH) {
/* Handle event in Main Activity if map is shown */
@@ -588,8 +562,7 @@ public class NavitGraphics
}
//Log.e("NavitGraphics", "KEYCODE_BACK up");
//s = java.lang.String.valueOf((char) 27);
- handled = true;
- return handled;
+ return true;
}
else if (keyCode == android.view.KeyEvent.KEYCODE_MENU)
{
@@ -604,7 +577,6 @@ public class NavitGraphics
// if in menu view:
// use as OK (Enter) key
s = java.lang.String.valueOf((char) 13);
- handled = true;
}
}
else
@@ -612,8 +584,7 @@ public class NavitGraphics
// if on map view:
// volume UP
//s = java.lang.String.valueOf((char) 1);
- handled = false;
- return handled;
+ return false;
}
}
}
@@ -626,7 +597,7 @@ public class NavitGraphics
{
KeypressCallback(KeypressCallbackID, s);
}
- return handled;
+ return true;
}
@@ -716,7 +687,7 @@ public class NavitGraphics
{
if (parent == null)
{
- this.activity = activity;
+ this.activity = (Navit) activity;
view = new NavitView(activity);
//activity.registerForContextMenu(view);
view.setClickable(false);
@@ -767,7 +738,7 @@ public class NavitGraphics
, CLB_SET_DISPLAY_DESTINATION, CLB_CALL_CMD, CLB_COUNTRY_CHOOSER, CLB_LOAD_MAP, CLB_UNLOAD_MAP, CLB_DELETE_MAP
};
- static public msg_type[] msg_values = msg_type.values();
+ static private msg_type[] msg_values = msg_type.values();
public Handler callback_handler = new Handler()
{
@@ -849,8 +820,8 @@ public class NavitGraphics
if (frameLayout == null)
return;
- if (!(activity instanceof Navit)) {
- Log.e("NavitGraphics", "Main Activity is not a Navit instance, cannot update padding");
+ if (activity == null) {
+ Log.w("NavitGraphics", "Main Activity is not a Navit instance, cannot update padding");
return;
}
@@ -976,14 +947,18 @@ public class NavitGraphics
public void setMotionCallback(int id)
{
MotionCallbackID = id;
- Navit.setMotionCallback(id, this);
+ if(activity != null){
+ activity.setMotionCallback(id, this);
+ }
}
public void setKeypressCallback(int id)
{
KeypressCallbackID = id;
// set callback id also in main intent (for menus)
- Navit.setKeypressCallback(id, this);
+ if(activity != null) {
+ activity.setKeypressCallback(id, this);
+ }
}
@@ -1140,8 +1115,8 @@ public class NavitGraphics
}
/* These constants must be synchronized with enum draw_mode_num in graphics.h. */
- public static final int draw_mode_begin = 0;
- public static final int draw_mode_end = 1;
+ private static final int draw_mode_begin = 0;
+ private static final int draw_mode_end = 1;
protected void draw_mode(int mode)
{
@@ -1194,9 +1169,7 @@ public class NavitGraphics
public static String getLocalizedString(String text)
{
- String ret = CallbackLocalizedString(text);
- //Log.e("NavitGraphics", "callback_handler -> lozalized string=" + ret);
- return ret;
+ return CallbackLocalizedString(text);
}
diff --git a/navit/android/src/org/navitproject/navit/NavitMap.java b/navit/android/src/org/navitproject/navit/NavitMap.java
index b7bd265a4..274cbdd8b 100644
--- a/navit/android/src/org/navitproject/navit/NavitMap.java
+++ b/navit/android/src/org/navitproject/navit/NavitMap.java
@@ -3,11 +3,11 @@ package org.navitproject.navit;
import java.io.File;
public class NavitMap {
- String fileName;
+ private String fileName;
String mapName;
- String mapPath;
+ private String mapPath;
- public NavitMap(String path, String map_file_name) {
+ NavitMap(String path, String map_file_name) {
mapPath = path;
fileName = map_file_name;
if (map_file_name.endsWith(".bin")) {
@@ -17,7 +17,7 @@ public class NavitMap {
}
}
- public NavitMap(String map_location) {
+ NavitMap(String map_location) {
File mapFile = new File(map_location);
mapPath = mapFile.getParent() + "/";
diff --git a/navit/android/src/org/navitproject/navit/NavitMapDownloader.java b/navit/android/src/org/navitproject/navit/NavitMapDownloader.java
index feda451b8..c3a6aadd0 100644
--- a/navit/android/src/org/navitproject/navit/NavitMapDownloader.java
+++ b/navit/android/src/org/navitproject/navit/NavitMapDownloader.java
@@ -59,7 +59,7 @@ public class NavitMapDownloader extends Thread
int level = 0;
- public osm_map_values(String mapname, String lon_1, String lat_1, String lon_2, String lat_2,
+ private osm_map_values(String mapname, String lon_1, String lat_1, String lon_2, String lat_2,
long bytes_est, int level)
{
this.map_name = mapname;
@@ -305,9 +305,7 @@ public class NavitMapDownloader extends Thread
public static NavitMap[] getAvailableMaps() {
class filterMaps implements FilenameFilter {
public boolean accept(File dir, String filename) {
- if (filename.endsWith(".bin"))
- return true;
- return false;
+ return (filename.endsWith(".bin"));
}
}
NavitMap maps[] = new NavitMap[0];
@@ -337,9 +335,9 @@ public class NavitMapDownloader extends Thread
private static final int MAX_RETRIES = 5;
private static final String TAG = "NavitMapDownloader";
- protected int retry_counter = 0;
+ private int retry_counter = 0;
- public NavitMapDownloader(int map_id) {
+ NavitMapDownloader(int map_id) {
this.map_values = osm_maps[map_id];
this.map_id=map_id;
this.map_filename_path=Navit.map_filename_path;
@@ -381,7 +379,7 @@ public class NavitMapDownloader extends Thread
Log.d(TAG, "stop_me -> true");
}
- protected boolean checkFreeSpace(long needed_bytes) {
+ private boolean checkFreeSpace(long needed_bytes) {
long free_space = getFreeSpace();
if ( needed_bytes <= 0 )
@@ -400,12 +398,12 @@ public class NavitMapDownloader extends Thread
return true;
}
- protected boolean deleteMap() {
+ private boolean deleteMap() {
File finalOutputFile = getMapFile();
if (finalOutputFile.exists()) {
Message msg =
- Message.obtain(Navit.N_NavitGraphics.callback_handler,
+ Message.obtain(Navit.getInstance().getNavitGraphics().callback_handler,
NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal());
Bundle b = new Bundle();
b.putString("title", finalOutputFile.getAbsolutePath());
@@ -420,7 +418,7 @@ public class NavitMapDownloader extends Thread
* @param map_values
* @return
*/
- protected boolean download_osm_map() {
+ private boolean download_osm_map() {
long already_read = 0;
long real_size_bytes = 0;
boolean resume = true;
@@ -479,13 +477,13 @@ public class NavitMapDownloader extends Thread
return false;
}
- protected File getDestinationFile() {
+ private File getDestinationFile() {
File outputFile = new File(map_filename_path, map_values.map_name + ".tmp");
outputFile.getParentFile().mkdir();
return outputFile;
}
- protected boolean downloadData(URLConnection c, long already_read, long real_size_bytes
+ private boolean downloadData(URLConnection c, long already_read, long real_size_bytes
, boolean resume,File outputFile) {
boolean success = false;
BufferedOutputStream buf = getOutputStream(outputFile, resume);
@@ -505,7 +503,7 @@ public class NavitMapDownloader extends Thread
return success;
}
- protected URL getDownloadURL() {
+ private URL getDownloadURL() {
URL url = null;
try {
url =
@@ -520,7 +518,7 @@ public class NavitMapDownloader extends Thread
return url;
}
- protected long getFreeSpace() {
+ private long getFreeSpace() {
try {
StatFs fsInfo = new StatFs(map_filename_path);
return (long)fsInfo.getAvailableBlocks() * fsInfo.getBlockSize();
@@ -529,7 +527,7 @@ public class NavitMapDownloader extends Thread
}
}
- protected BufferedInputStream getInputStream(URLConnection c) {
+ private BufferedInputStream getInputStream(URLConnection c) {
BufferedInputStream bif = null;
try {
bif = new BufferedInputStream(c.getInputStream(), MAP_READ_FILE_BUFFER);
@@ -548,15 +546,15 @@ public class NavitMapDownloader extends Thread
return bif;
}
- protected File getMapFile() {
+ private File getMapFile() {
return new File(map_filename_path, map_values.map_name + ".bin");
}
- protected File getMapInfoFile() {
+ private File getMapInfoFile() {
return new File(map_filename_path, map_values.map_name + ".tmp.info");
}
- protected BufferedOutputStream getOutputStream(File outputFile, boolean resume) {
+ private BufferedOutputStream getOutputStream(File outputFile, boolean resume) {
BufferedOutputStream buf = null;
try {
buf = new BufferedOutputStream(new FileOutputStream(outputFile, resume), MAP_WRITE_FILE_BUFFER);
@@ -567,7 +565,7 @@ public class NavitMapDownloader extends Thread
return buf;
}
- protected URLConnection initConnection(URL url) {
+ private URLConnection initConnection(URL url) {
HttpURLConnection c = null;
try {
c = (HttpURLConnection) url.openConnection();
@@ -583,7 +581,7 @@ public class NavitMapDownloader extends Thread
return c;
}
- protected boolean readData(OutputStream buf, InputStream bif, long already_read, long real_size_bytes) {
+ private boolean readData(OutputStream buf, InputStream bif, long already_read, long real_size_bytes) {
long start_timestamp = System.nanoTime();
byte[] buffer = new byte[MAP_WRITE_MEM_BUFFER];
int len1 = 0;
@@ -633,7 +631,7 @@ public class NavitMapDownloader extends Thread
return success;
}
- protected URL readFileInfo() {
+ private URL readFileInfo() {
URL url = null;
try {
ObjectInputStream infoStream = new ObjectInputStream(new FileInputStream(getMapInfoFile()));
@@ -650,11 +648,11 @@ public class NavitMapDownloader extends Thread
return url;
}
- protected void toast(String message) {
+ private void toast(String message) {
NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST, null, message, -1, 0, 0);
}
- protected void updateProgress(long startTime, long offsetBytes, long readBytes, long maxBytes) {
+ private void updateProgress(long startTime, long offsetBytes, long readBytes, long maxBytes) {
long currentTime = System.nanoTime();
if ((currentTime > uiLastUpdated + UPDATE_PROGRESS_TIME_NS) && startTime!=currentTime) {
@@ -683,13 +681,13 @@ public class NavitMapDownloader extends Thread
}
}
- protected void updateProgress(long positionBytes, long maximumBytes, String infoText) {
+ private void updateProgress(long positionBytes, long maximumBytes, String infoText) {
NavitDialogs.sendDialogMessage(NavitDialogs.MSG_PROGRESS_BAR, Navit.T("Map download"), infoText
, NavitDialogs.DIALOG_MAPDOWNLOAD, (int) (maximumBytes / 1024),
(int) (positionBytes / 1024));
}
- protected void writeFileInfo(URLConnection c, long sizeInBytes) {
+ private void writeFileInfo(URLConnection c, long sizeInBytes) {
ObjectOutputStream infoStream;
try {
infoStream = new ObjectOutputStream(new FileOutputStream(getMapInfoFile()));
@@ -703,7 +701,7 @@ public class NavitMapDownloader extends Thread
}
}
- void enableRetry() {
+ private void enableRetry() {
retryDownload = true;
retry_counter++;
}
diff --git a/navit/android/src/org/navitproject/navit/NavitSpeech2.java b/navit/android/src/org/navitproject/navit/NavitSpeech2.java
index b4ec85d4e..77b79c3c2 100644
--- a/navit/android/src/org/navitproject/navit/NavitSpeech2.java
+++ b/navit/android/src/org/navitproject/navit/NavitSpeech2.java
@@ -20,7 +20,6 @@
package org.navitproject.navit;
import android.content.Intent;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.app.AlertDialog;
@@ -31,17 +30,17 @@ import android.util.Log;
public class NavitSpeech2 implements TextToSpeech.OnInitListener, NavitActivityResult {
private TextToSpeech mTts;
private Navit navit;
- int MY_DATA_CHECK_CODE=1;
+ private int MY_DATA_CHECK_CODE=1;
public void onInit(int status)
{
- Log.e("NavitSpeech2","Status "+status);
+ Log.d("NavitSpeech2","Status "+status);
}
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
- Log.e("NavitSpeech2","onActivityResult "+requestCode+" "+resultCode);
+ Log.d("NavitSpeech2","onActivityResult "+requestCode+" "+resultCode);
if (requestCode == MY_DATA_CHECK_CODE) {
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
// success, create the TTS instance
diff --git a/navit/android/src/org/navitproject/navit/NavitVehicle.java b/navit/android/src/org/navitproject/navit/NavitVehicle.java
index e1a9c70f1..583d044c1 100644
--- a/navit/android/src/org/navitproject/navit/NavitVehicle.java
+++ b/navit/android/src/org/navitproject/navit/NavitVehicle.java
@@ -20,7 +20,6 @@
package org.navitproject.navit;
import java.util.List;
-import android.Manifest;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -40,7 +39,7 @@ import android.support.v4.content.ContextCompat;
public class NavitVehicle {
- public static final String GPS_FIX_CHANGE = "android.location.GPS_FIX_CHANGE";
+ private static final String GPS_FIX_CHANGE = "android.location.GPS_FIX_CHANGE";
public static Location lastLocation = null;