mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
Temp directory option
This commit is contained in:
parent
487aeb2053
commit
3d49eb8366
8 changed files with 24 additions and 18 deletions
|
@ -39,7 +39,7 @@ Library::~Library() {
|
|||
|
||||
std::string Library::cacheDirectory() const {
|
||||
JNIEnv *env = AndroidUtil::getEnv();
|
||||
jstring res = (jstring)AndroidUtil::StaticMethod_Paths_cacheDirectory->call();
|
||||
jstring res = (jstring)AndroidUtil::StaticMethod_Paths_tempDirectory->call();
|
||||
std::string str = AndroidUtil::fromJavaString(env, res);
|
||||
if (res != 0) {
|
||||
env->DeleteLocalRef(res);
|
||||
|
|
|
@ -101,7 +101,7 @@ shared_ptr<Constructor> AndroidUtil::Constructor_FileEncryptionInfo;
|
|||
|
||||
shared_ptr<Constructor> AndroidUtil::Constructor_ZLFileImage;
|
||||
|
||||
shared_ptr<StaticObjectMethod> AndroidUtil::StaticMethod_Paths_cacheDirectory;
|
||||
shared_ptr<StaticObjectMethod> AndroidUtil::StaticMethod_Paths_tempDirectory;
|
||||
|
||||
shared_ptr<ObjectField> AndroidUtil::Field_Book_File;
|
||||
shared_ptr<StringMethod> AndroidUtil::Method_Book_getTitle;
|
||||
|
@ -185,7 +185,7 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
|||
|
||||
Constructor_ZLFileImage = new Constructor(Class_ZLFileImage, "(Ljava/lang/String;Lorg/geometerplus/zlibrary/core/filesystem/ZLFile;Ljava/lang/String;[I[ILorg/geometerplus/zlibrary/core/drm/FileEncryptionInfo;)V");
|
||||
|
||||
StaticMethod_Paths_cacheDirectory = new StaticObjectMethod(Class_Paths, "cacheDirectory", Class_java_lang_String, "()");
|
||||
StaticMethod_Paths_tempDirectory = new StaticObjectMethod(Class_Paths, "tempDirectory", Class_java_lang_String, "()");
|
||||
|
||||
Field_Book_File = new ObjectField(Class_Book, "File", Class_ZLFile);
|
||||
Method_Book_getTitle = new StringMethod(Class_Book, "getTitle", "()");
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
//static shared_ptr<ObjectMethod> Method_JavaEncodingCollection_getEncoding_int;
|
||||
static shared_ptr<BooleanMethod> Method_JavaEncodingCollection_providesConverterFor;
|
||||
|
||||
static shared_ptr<StaticObjectMethod> StaticMethod_Paths_cacheDirectory;
|
||||
static shared_ptr<StaticObjectMethod> StaticMethod_Paths_tempDirectory;
|
||||
|
||||
static shared_ptr<ObjectField> Field_Book_File;
|
||||
static shared_ptr<StringMethod> Method_Book_getTitle;
|
||||
|
|
|
@ -102,6 +102,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
directoriesScreen.addPreference(new ZLStringListOptionPreference(
|
||||
this, Paths.WallpaperPathOption, directoriesScreen.Resource, "wallpaperPath"
|
||||
));
|
||||
directoriesScreen.addOption(Paths.TempDirectoryOption(), "tempDir");
|
||||
|
||||
final Screen appearanceScreen = createPreferenceScreen("appearance");
|
||||
appearanceScreen.addPreference(new LanguagePreference(
|
||||
|
|
|
@ -29,13 +29,21 @@ import org.geometerplus.zlibrary.core.options.ZLStringListOption;
|
|||
|
||||
public abstract class Paths {
|
||||
public static ZLStringListOption BookPathOption =
|
||||
directoryOption("BooksDirectory", defaultBookDirectory());
|
||||
pathOption("BooksDirectory", defaultBookDirectory());
|
||||
|
||||
public static ZLStringListOption FontPathOption =
|
||||
directoryOption("FontPathOption", cardDirectory() + "/Fonts");
|
||||
pathOption("FontPathOption", cardDirectory() + "/Fonts");
|
||||
|
||||
public static ZLStringListOption WallpaperPathOption =
|
||||
directoryOption("WallpapersDirectory", cardDirectory() + "/Wallpapers");
|
||||
pathOption("WallpapersDirectory", cardDirectory() + "/Wallpapers");
|
||||
|
||||
public static ZLStringOption TempDirectoryOption() {
|
||||
final ZLStringOption option = new ZLStringOption("Files", "tmp", "");
|
||||
if (option.getValue().isEmpty()) {
|
||||
option.setValue(mainBookDirectory() + "/.FBReader");
|
||||
}
|
||||
return option;
|
||||
}
|
||||
|
||||
public static String cardDirectory() {
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
|
@ -84,7 +92,7 @@ public abstract class Paths {
|
|||
return cardDirectory() + "/Books";
|
||||
}
|
||||
|
||||
private static ZLStringListOption directoryOption(String key, String defaultDirectory) {
|
||||
private static ZLStringListOption pathOption(String key, String defaultDirectory) {
|
||||
final ZLStringListOption option = new ZLStringListOption(
|
||||
"Files", key, Collections.<String>emptyList(), "\n"
|
||||
);
|
||||
|
@ -99,16 +107,12 @@ public abstract class Paths {
|
|||
return bookPath.isEmpty() ? defaultBookDirectory() : bookPath.get(0);
|
||||
}
|
||||
|
||||
public static String cacheDirectory() {
|
||||
return mainBookDirectory() + "/.FBReader";
|
||||
}
|
||||
|
||||
public static String tempDirectory() {
|
||||
return mainBookDirectory() + "/.FBReader";
|
||||
return TempDirectoryOption().getValue();
|
||||
}
|
||||
|
||||
public static String networkCacheDirectory() {
|
||||
return cacheDirectory() + "/cache";
|
||||
return tempDirectory() + "/cache";
|
||||
}
|
||||
|
||||
public static String systemShareDirectory() {
|
||||
|
|
|
@ -29,8 +29,8 @@ public class JavaBookModel extends BookModelImpl {
|
|||
|
||||
JavaBookModel(Book book) {
|
||||
super(book);
|
||||
myInternalHyperlinks = new CachedCharStorage(32768, Paths.cacheDirectory(), "links");
|
||||
BookTextModel = new ZLTextWritablePlainModel(null, book.getLanguage(), 1024, 65536, Paths.cacheDirectory(), "cache", myImageMap, FontManager);
|
||||
myInternalHyperlinks = new CachedCharStorage(32768, Paths.tempDirectory(), "links");
|
||||
BookTextModel = new ZLTextWritablePlainModel(null, book.getLanguage(), 1024, 65536, Paths.tempDirectory(), "cache", myImageMap, FontManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,7 @@ public class JavaBookModel extends BookModelImpl {
|
|||
public ZLTextModel getFootnoteModel(String id) {
|
||||
ZLTextModel model = myFootnotes.get(id);
|
||||
if (model == null) {
|
||||
model = new ZLTextWritablePlainModel(id, Book.getLanguage(), 8, 512, Paths.cacheDirectory(), "cache" + myFootnotes.size(), myImageMap, FontManager);
|
||||
model = new ZLTextWritablePlainModel(id, Book.getLanguage(), 8, 512, Paths.tempDirectory(), "cache" + myFootnotes.size(), myImageMap, FontManager);
|
||||
myFootnotes.put(id, model);
|
||||
}
|
||||
return model;
|
||||
|
|
|
@ -41,7 +41,7 @@ final class Base64EncodedImage extends ZLBase64EncodedImage {
|
|||
public Base64EncodedImage(MimeType mimeType, String namePostfix) {
|
||||
// TODO: use contentType
|
||||
super(mimeType);
|
||||
myDirName = Paths.cacheDirectory();
|
||||
myDirName = Paths.tempDirectory();
|
||||
new File(myDirName).mkdirs();
|
||||
myFileNumber = ourCounter++;
|
||||
myNamePostfix = namePostfix;
|
||||
|
|
|
@ -286,6 +286,7 @@ public final class AndroidFontUtil {
|
|||
// ignore
|
||||
}
|
||||
}
|
||||
new File(realFileName).delete();
|
||||
}
|
||||
ourCachedEmbeddedTypefaces.put(spec, cached != null ? cached : NULL_OBJECT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue