mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
standard temp files dir
This commit is contained in:
parent
2d08f9e149
commit
05425a170b
7 changed files with 43 additions and 27 deletions
|
@ -6,7 +6,7 @@ DONE all/writable only option (use writable only for books & temp, all for fonts
|
|||
NOT NECESSARY activity orientation (use fbreader's OrientaionUtil mechanism)
|
||||
DONE resource strings
|
||||
DONE use in fix book catalog dialog
|
||||
DELAYED standard temp dir (?)
|
||||
DONE standard temp dir (?)
|
||||
DONE layout for versions < v11
|
||||
DELAYED create missing catalogs for fonts/wallpapers (if possible)
|
||||
DONE special icon for inaccessible folders
|
||||
|
|
|
@ -63,15 +63,14 @@ public class FixBooksDirectoryActivity extends Activity {
|
|||
|
||||
Config.Instance().runOnConnect(new Runnable() {
|
||||
public void run() {
|
||||
final ZLStringOption tempDirectoryOption = Paths.TempDirectoryOption();
|
||||
myDirectoryView.setText(tempDirectoryOption.getValue());
|
||||
myDirectoryView.setText(Paths.TempDirectoryOption.getValue());
|
||||
selectButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
FileChooserUtil.runDirectoryChooser(
|
||||
FixBooksDirectoryActivity.this,
|
||||
1,
|
||||
title,
|
||||
tempDirectoryOption.getValue(),
|
||||
Paths.TempDirectoryOption.getValue(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -79,7 +78,7 @@ public class FixBooksDirectoryActivity extends Activity {
|
|||
okButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
final String newDirectory = myDirectoryView.getText().toString();
|
||||
tempDirectoryOption.setValue(newDirectory);
|
||||
Paths.TempDirectoryOption.setValue(newDirectory);
|
||||
startActivity(new Intent(FixBooksDirectoryActivity.this, FBReader.class));
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
directoriesScreen.Resource, "bookPath", Paths.BookPathOption, libraryUpdater
|
||||
));
|
||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||
directoriesScreen.Resource, "downloadDir", Paths.DownloadsDirectoryOption(), libraryUpdater
|
||||
directoriesScreen.Resource, "downloadDir", Paths.DownloadsDirectoryOption, libraryUpdater
|
||||
));
|
||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||
directoriesScreen.Resource, "fontPath", Paths.FontPathOption, null
|
||||
|
@ -115,7 +115,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
directoriesScreen.Resource, "wallpaperPath", Paths.WallpaperPathOption, null
|
||||
));
|
||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||
directoriesScreen.Resource, "tempDir", Paths.TempDirectoryOption(), null
|
||||
directoriesScreen.Resource, "tempDir", Paths.TempDirectoryOption, null
|
||||
));
|
||||
|
||||
final Screen appearanceScreen = createPreferenceScreen("appearance");
|
||||
|
|
|
@ -37,22 +37,15 @@ public abstract class Paths {
|
|||
public static ZLStringListOption WallpaperPathOption =
|
||||
pathOption("WallpapersDirectory", cardDirectory() + "/Wallpapers");
|
||||
|
||||
private static ZLStringOption ourDownloadsDirectoryOption =
|
||||
new ZLStringOption("Files", "DownloadsDirectory", "");
|
||||
public static ZLStringOption DownloadsDirectoryOption() {
|
||||
if ("".equals(ourDownloadsDirectoryOption.getValue())) {
|
||||
ourDownloadsDirectoryOption.setValue(mainBookDirectory());
|
||||
}
|
||||
return ourDownloadsDirectoryOption;
|
||||
}
|
||||
public static ZLStringOption TempDirectoryOption =
|
||||
new ZLStringOption("Files", "TemporaryDirectory", "");
|
||||
|
||||
private static ZLStringOption ourTempDirectoryOption =
|
||||
new ZLStringOption("Files", "TempDirectory", "");
|
||||
public static ZLStringOption TempDirectoryOption() {
|
||||
if ("".equals(ourTempDirectoryOption.getValue())) {
|
||||
ourTempDirectoryOption.setValue(mainBookDirectory() + "/.FBReader");
|
||||
public static ZLStringOption DownloadsDirectoryOption =
|
||||
new ZLStringOption("Files", "DownloadsDirectory", "");
|
||||
static {
|
||||
if ("".equals(DownloadsDirectoryOption.getValue())) {
|
||||
DownloadsDirectoryOption.setValue(mainBookDirectory());
|
||||
}
|
||||
return ourTempDirectoryOption;
|
||||
}
|
||||
|
||||
public static String cardDirectory() {
|
||||
|
@ -114,20 +107,20 @@ public abstract class Paths {
|
|||
|
||||
public static List<String> bookPath() {
|
||||
final List<String> path = new ArrayList<String>(Paths.BookPathOption.getValue());
|
||||
final String downloadsDirectory = Paths.DownloadsDirectoryOption().getValue();
|
||||
final String downloadsDirectory = DownloadsDirectoryOption.getValue();
|
||||
if (!"".equals(downloadsDirectory) && !path.contains(downloadsDirectory)) {
|
||||
path.add(downloadsDirectory);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
private static String mainBookDirectory() {
|
||||
public static String mainBookDirectory() {
|
||||
final List<String> bookPath = BookPathOption.getValue();
|
||||
return bookPath.isEmpty() ? defaultBookDirectory() : bookPath.get(0);
|
||||
}
|
||||
|
||||
public static String tempDirectory() {
|
||||
return TempDirectoryOption().getValue();
|
||||
return TempDirectoryOption.getValue();
|
||||
}
|
||||
|
||||
public static String networkCacheDirectory() {
|
||||
|
|
|
@ -106,7 +106,7 @@ public class BookUrlInfo extends UrlInfo {
|
|||
path.insert(0, "Demos");
|
||||
path.insert(0, File.separator);
|
||||
}
|
||||
path.insert(0, Paths.DownloadsDirectoryOption().getValue());
|
||||
path.insert(0, Paths.DownloadsDirectoryOption.getValue());
|
||||
|
||||
int index = path.length();
|
||||
final String uriPath = uri.getPath();
|
||||
|
|
|
@ -69,7 +69,7 @@ public final class ZLKeyBindings {
|
|||
// ignore
|
||||
}
|
||||
try {
|
||||
new Reader(keys).readQuietly(ZLFile.createFileByPath(Paths.DownloadsDirectoryOption().getValue() + "/keymap.xml"));
|
||||
new Reader(keys).readQuietly(ZLFile.createFileByPath(Paths.bookPath().get(0) + "/keymap.xml"));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
|
|
@ -19,18 +19,42 @@
|
|||
|
||||
package org.geometerplus.zlibrary.ui.android.library;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.app.Application;
|
||||
import android.os.Build;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
|
||||
|
||||
import org.geometerplus.fbreader.Paths;
|
||||
|
||||
import org.geometerplus.android.fbreader.config.ConfigShadow;
|
||||
|
||||
public abstract class ZLAndroidApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
new ConfigShadow(this);
|
||||
final ConfigShadow config = new ConfigShadow(this);
|
||||
new ZLAndroidImageManager();
|
||||
new ZLAndroidLibrary(this);
|
||||
|
||||
config.runOnConnect(new Runnable() {
|
||||
public void run() {
|
||||
if ("".equals(Paths.TempDirectoryOption.getValue())) {
|
||||
String dir = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
|
||||
final File d = getExternalCacheDir();
|
||||
d.mkdirs();
|
||||
if (d.exists() && d.isDirectory()) {
|
||||
dir = d.getPath();
|
||||
}
|
||||
}
|
||||
if (dir == null) {
|
||||
dir = Paths.mainBookDirectory() + "/.FBReader";
|
||||
}
|
||||
Paths.TempDirectoryOption.setValue(dir);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue