26
26
27
27
import org .scid .android .engine .Engine ;
28
28
29
+ import android .annotation .TargetApi ;
29
30
import android .app .Activity ;
30
31
import android .app .AlertDialog ;
32
+ import android .content .Context ;
31
33
import android .content .DialogInterface ;
32
34
import android .content .Intent ;
33
35
import android .content .pm .PackageManager ;
34
36
import android .content .pm .ResolveInfo ;
35
37
import android .net .Uri ;
38
+ import android .os .Build ;
36
39
import android .os .Environment ;
37
40
import android .util .Log ;
38
41
import android .view .WindowManager ;
@@ -52,7 +55,7 @@ public class Tools {
52
55
53
56
/**
54
57
* Extract links from html using regular expressions
55
- *
58
+ *
56
59
* @param html
57
60
* html content for validation
58
61
* @return List of links
@@ -78,7 +81,7 @@ public static List<Link> getLinks(final String html) {
78
81
/**
79
82
* Add names of engine files (files which not have an ignored extension) to
80
83
* the specified set of already found engines.
81
- *
84
+ *
82
85
* @param foundEngines
83
86
* Set of already found engines or null if a new set should be
84
87
* created.
@@ -93,6 +96,7 @@ public static final SortedSet<Engine> findEnginesInDirectory(
93
96
File dir = new File (dirPath );
94
97
final Set <String > _ignore = ignoreExtensions ;
95
98
File [] files = dir .listFiles (new FileFilter () {
99
+ @ Override
96
100
public boolean accept (File pathname ) {
97
101
if (pathname .isFile () && !pathname .getName ().startsWith ("." )) {
98
102
int index = pathname .getName ().lastIndexOf ('.' );
@@ -119,7 +123,7 @@ public boolean accept(File pathname) {
119
123
/**
120
124
* Download file to scid directory with file name from HTTP header or create
121
125
* temp file if the HTTP header does not provide enough information
122
- *
126
+ *
123
127
* @param path
124
128
* the path to the URL
125
129
* @return the downloaded file
@@ -205,13 +209,15 @@ public static void importPgn(final Activity activity, String baseName,
205
209
fileExistsDialog .setIcon (android .R .drawable .ic_dialog_alert );
206
210
fileExistsDialog .setButton (activity .getString (android .R .string .ok ),
207
211
new DialogInterface .OnClickListener () {
212
+ @ Override
208
213
public void onClick (DialogInterface dialog , int which ) {
209
214
startPgnImport (activity , pgnFileName , resultId );
210
215
}
211
216
});
212
217
fileExistsDialog .setButton2 (
213
218
activity .getString (android .R .string .cancel ),
214
219
new DialogInterface .OnClickListener () {
220
+ @ Override
215
221
public void onClick (DialogInterface dialog , int which ) {
216
222
Toast .makeText (
217
223
activity .getApplicationContext (),
@@ -270,6 +276,7 @@ public static String getFileNameFromUrl(String path) {
270
276
public static void showErrorMessage (final Activity activity ,
271
277
final String message ) {
272
278
activity .runOnUiThread (new Runnable () {
279
+ @ Override
273
280
public void run () {
274
281
final AlertDialog .Builder builder = new AlertDialog .Builder (
275
282
activity );
@@ -479,4 +486,14 @@ public static String getScidDirectory() {
479
486
return Environment .getExternalStorageDirectory () + File .separator
480
487
+ Constants .SCID_DIRECTORY ;
481
488
}
489
+
490
+ @ TargetApi (Build .VERSION_CODES .GINGERBREAD )
491
+ public static String getNativeLibraryDir (Context context ) {
492
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .GINGERBREAD ) {
493
+ return context .getApplicationInfo ().nativeLibraryDir ;
494
+ } else {
495
+ return context .getApplicationInfo ().dataDir + File .separator
496
+ + "lib" ;
497
+ }
498
+ }
482
499
}
0 commit comments