blob: 3d8ba3e65148f8f8f7a148399a1c12c37295ffef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package com.mapswithme.maps;
import java.io.File;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Environment;
import com.mapswithme.maps.location.LocationService;
public class MWMApplication extends android.app.Application
{
public final static String PACKAGE_NAME = "com.mapswithme.maps";
private LocationService mLocationService = null;
@Override
public void onCreate()
{
super.onCreate();
final String extStoragePath = getDataStoragePath();
final String extTmpPath = getExtAppDirectoryPath("caches");
// Create folders if they don't exist
new File(extStoragePath).mkdirs();
new File(extTmpPath).mkdirs();
nativeInit(getApkPath(),
extStoragePath,
getTmpPath(),
extTmpPath,
getSettingsPath());
}
public LocationService getLocationService()
{
if (mLocationService == null)
mLocationService = new LocationService(this);
return mLocationService;
}
public String getApkPath()
{
try
{
return getPackageManager().getApplicationInfo(PACKAGE_NAME, 0).sourceDir;
}
catch (NameNotFoundException e)
{
e.printStackTrace();
return "";
}
}
public String getDataStoragePath()
{
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/MapsWithMe/";
}
public String getExtAppDirectoryPath(String folder)
{
final String storagePath = Environment.getExternalStorageDirectory().getAbsolutePath();
return storagePath.concat(String.format("/Android/data/%s/%s/", PACKAGE_NAME, folder));
}
public boolean isProVersion()
{
return true;
}
private String getTmpPath()
{
return getCacheDir().getAbsolutePath() + "/";
}
private String getSettingsPath()
{
return getFilesDir().getAbsolutePath() + "/";
}
@Override
public String getPackageName()
{
return PACKAGE_NAME;
}
static
{
System.loadLibrary("mapswithme");
}
private native void nativeInit(String apkPath,
String storagePath,
String tmpPath,
String extTmpPath,
String settingsPath);
}
|