-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
84 additions
and
66 deletions.
There are no files selected for viewing
15 changes: 3 additions & 12 deletions
15
.../test/com/shtrih/util/LocalizerTests.java → ...shtrih/util/LocalizerAndroidUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 19 additions & 10 deletions
29
Source/android/FptrServiceAndroid/src/com/shtrih/util/StaticContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
package com.shtrih.util; | ||
|
||
import android.content.Context; | ||
import android.os.Environment; | ||
|
||
import java.io.File; | ||
|
||
public class StaticContext { | ||
private static Context context = null; | ||
|
||
public static Context getContext() { | ||
if (context == null) { | ||
throw new RuntimeException("Context is not set"); | ||
} | ||
return context; | ||
public static void setContext(Context context) { | ||
SysUtils.setFilesPath(getFilesPath(context)); | ||
} | ||
|
||
// NOTE: Application must call setContext to provide application instance to | ||
// library | ||
public static void setContext(Context value) { | ||
context = value; | ||
private static String getFilesPath(Context context) | ||
{ | ||
File downloads = context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS); | ||
|
||
if (downloads != null) { | ||
|
||
if (downloads.exists()) | ||
return downloads.getAbsolutePath() + File.separator; | ||
|
||
if (downloads.mkdirs()) | ||
return downloads.getAbsolutePath() + File.separator; | ||
} | ||
|
||
return context.getFilesDir().getAbsolutePath() + File.separator; | ||
} | ||
} |
24 changes: 11 additions & 13 deletions
24
Source/android/FptrServiceAndroid/src/com/shtrih/util/SysUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters