mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 09:49:19 +02:00
Merge branch 'fc' of github.com:geometer/FBReaderJ into fc
This commit is contained in:
commit
c85431c150
12 changed files with 68 additions and 42 deletions
|
@ -1,5 +1,6 @@
|
|||
===== 1.10 (Apr ??, 2014) =====
|
||||
* Fixed current position storing
|
||||
* New directory settings
|
||||
* Experimental video support
|
||||
* CSS parsing optimization for ePubs (do not parse css files multiple times)
|
||||
* CSS support improvement: added support for space-separated classes list
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
DONE does not show hidden folders (like '.FBReader')
|
||||
DONE does not show parent if the parent's name is '.FBReader' (see 'temporary files' option)
|
||||
* open 'Book path preference', 'New folder' button is active; press 'Root', 'New folder' button is disabled; press 'Back' -- 'New folder' button is still disabled, this is wrong
|
||||
* same problem with 'Ok' button
|
||||
* all/writable only option (use writable only for books & temp, all for fonts & wallpapers)
|
||||
* activity orientation (use fbreader's OrientaionUtil mechanism)
|
||||
* resource strings
|
||||
DONE open 'Book path preference', 'New folder' button is active; press 'Root', 'New folder' button is disabled; press 'Back' -- 'New folder' button is still disabled, this is wrong
|
||||
DONE same problem with 'Ok' button
|
||||
DONE all/writable only option (use writable only for books & temp, all for fonts & wallpapers)
|
||||
NOT NECESSARY activity orientation (use fbreader's OrientaionUtil mechanism)
|
||||
DONE resource strings
|
||||
* use in fix book catalog dialog
|
||||
* standard temp dir (?)
|
||||
DONE layout for versions < v11
|
||||
* create missing catalogs for fonts/wallpapers (if possible)
|
||||
* special icon for inaccessible folders
|
||||
* set impossible value for temp folder & check
|
||||
* set impossible value for downloads folder & check
|
||||
|
|
|
@ -30,7 +30,7 @@ import android.widget.Button;
|
|||
import android.widget.*;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.Config;
|
||||
import org.geometerplus.zlibrary.core.options.ZLStringListOption;
|
||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
import org.geometerplus.fbreader.Paths;
|
||||
|
@ -61,16 +61,12 @@ public class FixBooksDirectoryActivity extends Activity {
|
|||
|
||||
Config.Instance().runOnStart(new Runnable() {
|
||||
public void run() {
|
||||
final ZLStringListOption bookPathOption = Paths.BookPathOption;
|
||||
directoryView.setText(Paths.mainBookDirectory());
|
||||
final ZLStringOption tempDirectoryOption = Paths.TempDirectoryOption();
|
||||
directoryView.setText(tempDirectoryOption.getValue());
|
||||
okButton.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
final List<String> bookPath =
|
||||
new LinkedList<String>(bookPathOption.getValue());
|
||||
final String newDirectory = directoryView.getText().toString();
|
||||
bookPath.remove(newDirectory);
|
||||
bookPath.add(0, newDirectory);
|
||||
bookPathOption.setValue(bookPath);
|
||||
tempDirectoryOption.setValue(newDirectory);
|
||||
startActivity(new Intent(FixBooksDirectoryActivity.this, FBReader.class));
|
||||
finish();
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class LibraryService extends Service {
|
|||
|
||||
LibraryImplementation() {
|
||||
myDatabase = new SQLiteBooksDatabase(LibraryService.this);
|
||||
myCollection = new BookCollection(myDatabase, Paths.BookPathOption.getValue());
|
||||
myCollection = new BookCollection(myDatabase, Paths.bookPath());
|
||||
reset(true);
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class LibraryService extends Service {
|
|||
}
|
||||
|
||||
private void resetInternal(boolean force) {
|
||||
final List<String> bookDirectories = Paths.BookPathOption.getValue();
|
||||
final List<String> bookDirectories = Paths.bookPath();
|
||||
if (!force &&
|
||||
myCollection.status() != BookCollection.Status.NotStarted &&
|
||||
bookDirectories.equals(myCollection.BookDirectories)
|
||||
|
@ -115,8 +115,8 @@ public class LibraryService extends Service {
|
|||
myFileObservers.clear();
|
||||
|
||||
myCollection = new BookCollection(myDatabase, bookDirectories);
|
||||
for (String path : bookDirectories) {
|
||||
final Observer observer = new Observer(path, myCollection);
|
||||
for (String dir : bookDirectories) {
|
||||
final Observer observer = new Observer(dir, myCollection);
|
||||
observer.startWatching();
|
||||
myFileObservers.add(observer);
|
||||
}
|
||||
|
|
|
@ -104,6 +104,9 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
|||
}
|
||||
}
|
||||
));
|
||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||
directoriesScreen.Resource, "downloadDir", Paths.DownloadsDirectoryOption()
|
||||
));
|
||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||
directoriesScreen.Resource, "fontPath", Paths.FontPathOption
|
||||
));
|
||||
|
|
|
@ -36,11 +36,13 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
|
|||
abstract class FileChooserPreference extends Preference {
|
||||
private final int myRegCode;
|
||||
private final ZLResource myResource;
|
||||
private final IFileProvider.FilterMode myFilterMode;
|
||||
|
||||
FileChooserPreference(Context context, ZLResource rootResource, String resourceKey, int regCode) {
|
||||
FileChooserPreference(Context context, ZLResource rootResource, String resourceKey, IFileProvider.FilterMode filterMode, int regCode) {
|
||||
super(context);
|
||||
|
||||
myRegCode = regCode;
|
||||
myFilterMode = filterMode;
|
||||
myResource = rootResource.getResource(resourceKey);
|
||||
setTitle(myResource.getValue());
|
||||
}
|
||||
|
@ -73,10 +75,11 @@ abstract class FileChooserPreference extends Preference {
|
|||
intent.putExtra(FileChooserActivity._ActionBar, true);
|
||||
intent.putExtra(FileChooserActivity._SaveLastLocation, false);
|
||||
intent.putExtra(FileChooserActivity._DisplayHiddenFiles, true);
|
||||
intent.putExtra(FileChooserActivity._FilterMode, myFilterMode);
|
||||
//intent.putExtra(FileChooserActivity._FilterMode, IFileProvider.FilterMode.AnyDirectories);
|
||||
//intent.putExtra(FileChooserActivity._FilterMode, IFileProvider.FilterMode.DirectoriesOnly);
|
||||
//intent.putExtra(FileChooserActivity._FilterMode, IFileProvider.FilterMode.FilesOnly);
|
||||
//intent.putExtra(FileChooserActivity._FilterMode, IFileProvider.FilterMode.FilesAndDirectories);
|
||||
intent.putExtra(FileChooserActivity._FilterMode, IFileProvider.FilterMode.DirectoriesOnly);
|
||||
((Activity)getContext()).startActivityForResult(intent, myRegCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.List;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import group.pals.android.lib.ui.filechooser.services.IFileProvider;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLStringListOption;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||
|
@ -33,7 +35,7 @@ class FileChooserStringListPreference extends FileChooserPreference {
|
|||
private final Runnable myOnValueSetAction;
|
||||
|
||||
FileChooserStringListPreference(Context context, ZLResource rootResource, String resourceKey, ZLStringListOption option, int regCode, Runnable onValueSetAction) {
|
||||
super(context, rootResource, resourceKey, regCode);
|
||||
super(context, rootResource, resourceKey, IFileProvider.FilterMode.AnyDirectories, regCode);
|
||||
|
||||
myOption = option;
|
||||
myOnValueSetAction = onValueSetAction;
|
||||
|
|
|
@ -21,6 +21,8 @@ package org.geometerplus.android.fbreader.preferences.fileChooser;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import group.pals.android.lib.ui.filechooser.services.IFileProvider;
|
||||
|
||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||
|
@ -29,7 +31,7 @@ class FileChooserStringPreference extends FileChooserPreference {
|
|||
private final ZLStringOption myOption;
|
||||
|
||||
FileChooserStringPreference(Context context, ZLResource rootResource, String resourceKey, ZLStringOption option, int regCode) {
|
||||
super(context, rootResource, resourceKey, regCode);
|
||||
super(context, rootResource, resourceKey, IFileProvider.FilterMode.DirectoriesOnly, regCode);
|
||||
myOption = option;
|
||||
|
||||
setSummary(getStringValue());
|
||||
|
|
|
@ -37,12 +37,22 @@ public abstract class Paths {
|
|||
public static ZLStringListOption WallpaperPathOption =
|
||||
pathOption("WallpapersDirectory", cardDirectory() + "/Wallpapers");
|
||||
|
||||
public static ZLStringOption TempDirectoryOption() {
|
||||
final ZLStringOption option = new ZLStringOption("Files", "tmp", "");
|
||||
if ("".equals(option.getValue())) {
|
||||
option.setValue(mainBookDirectory() + "/.FBReader");
|
||||
private static ZLStringOption ourDownloadsDirectoryOption =
|
||||
new ZLStringOption("Files", "DownloadsDirectory", "");
|
||||
public static ZLStringOption DownloadsDirectoryOption() {
|
||||
if ("".equals(ourDownloadsDirectoryOption.getValue())) {
|
||||
ourDownloadsDirectoryOption.setValue(mainBookDirectory());
|
||||
}
|
||||
return option;
|
||||
return ourDownloadsDirectoryOption;
|
||||
}
|
||||
|
||||
private static ZLStringOption ourTempDirectoryOption =
|
||||
new ZLStringOption("Files", "TempDirectory", "");
|
||||
public static ZLStringOption TempDirectoryOption() {
|
||||
if ("".equals(ourTempDirectoryOption.getValue())) {
|
||||
ourTempDirectoryOption.setValue(mainBookDirectory() + "/.FBReader");
|
||||
}
|
||||
return ourTempDirectoryOption;
|
||||
}
|
||||
|
||||
public static String cardDirectory() {
|
||||
|
@ -102,7 +112,16 @@ public abstract class Paths {
|
|||
return option;
|
||||
}
|
||||
|
||||
public static String mainBookDirectory() {
|
||||
public static List<String> bookPath() {
|
||||
final List<String> path = new ArrayList<String>(Paths.BookPathOption.getValue());
|
||||
final String downloadsDirectory = Paths.DownloadsDirectoryOption().getValue();
|
||||
if (!"".equals(downloadsDirectory) && !path.contains(downloadsDirectory)) {
|
||||
path.add(downloadsDirectory);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
private static String mainBookDirectory() {
|
||||
final List<String> bookPath = BookPathOption.getValue();
|
||||
return bookPath.isEmpty() ? defaultBookDirectory() : bookPath.get(0);
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class BookUrlInfo extends UrlInfo {
|
|||
path.insert(0, "Demos");
|
||||
path.insert(0, File.separator);
|
||||
}
|
||||
path.insert(0, Paths.mainBookDirectory());
|
||||
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.mainBookDirectory() + "/keymap.xml"));
|
||||
new Reader(keys).readQuietly(ZLFile.createFileByPath(Paths.DownloadsDirectoryOption().getValue() + "/keymap.xml"));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
|
|
|
@ -634,7 +634,7 @@ public class FileChooserActivity extends Activity {
|
|||
mRoot = mFileProvider.defaultPath();
|
||||
|
||||
IFileProvider.FilterMode filterMode = (FilterMode) getIntent().getSerializableExtra(_FilterMode);
|
||||
if (filterMode == null){
|
||||
if (filterMode == null) {
|
||||
filterMode = IFileProvider.FilterMode.DirectoriesOnly;
|
||||
}
|
||||
|
||||
|
@ -1649,15 +1649,12 @@ public class FileChooserActivity extends Activity {
|
|||
};// mBtnGoForwardOnClickListener
|
||||
|
||||
private void checkUIForFolderCreation(IFile dir){
|
||||
if(mFileProvider.getFilterMode() != IFileProvider.FilterMode.AnyDirectories){
|
||||
if(!(((File) dir).canWrite()) ){
|
||||
mBtnOk.setEnabled(false);
|
||||
mViewCreateFolder.setEnabled(false);
|
||||
}else{
|
||||
mBtnOk.setEnabled(true);
|
||||
mViewCreateFolder.setEnabled(true);
|
||||
}
|
||||
}
|
||||
final boolean isDirectoryWriteable = ((File)dir).canWrite();
|
||||
mViewCreateFolder.setEnabled(isDirectoryWriteable);
|
||||
mBtnOk.setEnabled(
|
||||
isDirectoryWriteable ||
|
||||
mFileProvider.getFilterMode() == IFileProvider.FilterMode.AnyDirectories
|
||||
);
|
||||
}
|
||||
|
||||
private final View.OnLongClickListener mBtnGoBackForwardOnLongClickListener = new View.OnLongClickListener() {
|
||||
|
@ -1712,9 +1709,9 @@ public class FileChooserActivity extends Activity {
|
|||
private final View.OnClickListener mBtnOk_ActionBar_OnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if ((getLocation() instanceof File)){
|
||||
if(mFileProvider.getFilterMode() != IFileProvider.FilterMode.AnyDirectories){
|
||||
if(!((File)getLocation()).canWrite()){
|
||||
if (getLocation() instanceof File) {
|
||||
if (mFileProvider.getFilterMode() != IFileProvider.FilterMode.AnyDirectories) {
|
||||
if (!((File)getLocation()).canWrite()) {
|
||||
Dlg.toast(FileChooserActivity.this, R.string.afc_msg_app_cant_choose_folder, Dlg._LengthShort);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue