1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

BookInfoActivity has been moved to the ":library" process

This commit is contained in:
Nikolay Pultsin 2010-11-14 19:58:22 +00:00
parent 1718b58dea
commit 1b7e6b6471
8 changed files with 47 additions and 15 deletions

View file

@ -83,7 +83,7 @@
</activity>
<activity android:name="org.geometerplus.android.fbreader.BookmarkEditActivity" android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden" />
<activity android:name="org.geometerplus.android.fbreader.preferences.PreferenceActivity" android:configChanges="orientation|keyboardHidden" />
<activity android:name="org.geometerplus.android.fbreader.preferences.BookInfoActivity" android:configChanges="orientation|keyboardHidden" />
<activity android:name="org.geometerplus.android.fbreader.preferences.BookInfoActivity" android:process=":library" android:configChanges="orientation|keyboardHidden" />
<activity android:name="org.geometerplus.android.fbreader.network.BookDownloader" android:process=":bookDownloader" android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View file

@ -40,7 +40,7 @@ import org.geometerplus.fbreader.library.*;
import org.geometerplus.fbreader.tree.FBTree;
public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuItemClickListener {
public static final String CURRENT_BOOK_PATH_KEY = "LibraryCurrentBookPath";
public static final String CURRENT_BOOK_PATH_KEY = "CurrentBookPath";
static LibraryTabActivity Instance;

View file

@ -38,11 +38,11 @@ import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
import org.geometerplus.fbreader.library.*;
final class SQLiteBooksDatabase extends BooksDatabase {
public final class SQLiteBooksDatabase extends BooksDatabase {
private final String myInstanceId;
private final SQLiteDatabase myDatabase;
SQLiteBooksDatabase(String instanceId) {
public SQLiteBooksDatabase(String instanceId) {
myInstanceId = instanceId;
myDatabase = ZLAndroidApplication.Instance().openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
migrate();

View file

@ -21,8 +21,11 @@ package org.geometerplus.android.fbreader;
import android.content.Intent;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.fbreader.fbreader.FBAction;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
import org.geometerplus.fbreader.bookmodel.BookModel;
import org.geometerplus.android.fbreader.preferences.BookInfoActivity;
@ -39,9 +42,20 @@ class ShowBookInfoAction extends FBAction {
}
public void run() {
final Intent intent = new Intent(myBaseActivity.getApplicationContext(), BookInfoActivity.class);
final BookModel model = Reader.Model;
if (model != null && model.Book != null) {
final ZLFile file = model.Book.File;
final ZLFile physicalFile = file.getPhysicalFile();
if (physicalFile == null || physicalFile == file) {
intent.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, file.getPath());
} else {
intent.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, physicalFile.getPath());
intent.putExtra(BookInfoActivity.CURRENT_BOOK_ARCHIVE_ENTRY_KEY, file.getName(false));
}
}
myBaseActivity.startActivityForResult(
new Intent(myBaseActivity.getApplicationContext(), BookInfoActivity.class),
FBReader.REPAINT_CODE
intent, FBReader.REPAINT_CODE
);
}
}

View file

@ -19,19 +19,21 @@
package org.geometerplus.android.fbreader.preferences;
import java.util.Map;
import java.util.TreeMap;
import android.content.Context;
import android.content.Intent;
import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.zlibrary.core.language.ZLLanguageUtil;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
import org.geometerplus.fbreader.library.Book;
import org.geometerplus.android.fbreader.SQLiteBooksDatabase;
class BookTitlePreference extends ZLStringPreference {
private final Book myBook;
@ -60,7 +62,7 @@ class LanguagePreference extends ZLStringListPreference {
String[] codes = new String[size + 1];
String[] names = new String[size + 1];
int index = 0;
for (Map.Entry<String,String> entry : map.entrySet()) {
for (TreeMap.Entry<String,String> entry : map.entrySet()) {
codes[index] = entry.getValue();
names[index] = entry.getKey();
++index;
@ -84,6 +86,9 @@ class LanguagePreference extends ZLStringListPreference {
}
public class BookInfoActivity extends ZLPreferenceActivity {
public static final String CURRENT_BOOK_PATH_KEY = "CurrentBookPath";
public static final String CURRENT_BOOK_ARCHIVE_ENTRY_KEY = "CurrentArchiveEntryPath";
private Book myBook;
public BookInfoActivity() {
@ -91,9 +96,20 @@ public class BookInfoActivity extends ZLPreferenceActivity {
}
@Override
protected void init() {
protected void init(Intent intent) {
if (SQLiteBooksDatabase.Instance() == null) {
new SQLiteBooksDatabase("LIBRARY");
}
final String path = intent.getStringExtra(CURRENT_BOOK_PATH_KEY);
final String archiveEntry = intent.getStringExtra(CURRENT_BOOK_ARCHIVE_ENTRY_KEY);
ZLFile file = ZLFile.createFile(null, path);
if (archiveEntry != null) {
file = ZLFile.createFile(file, archiveEntry);
}
myBook = Book.getByFile(file);
final Category commonCategory = createCategory(null);
myBook = ((FBReaderApp)FBReaderApp.Instance()).Model.Book;
if (myBook.File.getPhysicalFile() != null) {
commonCategory.addPreference(new InfoPreference(
this,

View file

@ -19,6 +19,7 @@
package org.geometerplus.android.fbreader.preferences;
import android.content.Intent;
import android.preference.Preference;
import android.preference.PreferenceScreen;
@ -70,7 +71,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
}*/
@Override
protected void init() {
protected void init(Intent intent) {
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
final ZLAndroidApplication androidApp = ZLAndroidApplication.Instance();

View file

@ -23,6 +23,7 @@ import java.util.ArrayList;
import android.os.Bundle;
import android.preference.*;
import android.content.Intent;
import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.zlibrary.core.resources.ZLResource;
@ -105,7 +106,7 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
return new Category(myScreen, myResource, resourceKey);
}
protected abstract void init();
protected abstract void init(Intent intent);
@Override
protected void onCreate(Bundle bundle) {
@ -115,7 +116,7 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
myScreen = getPreferenceManager().createPreferenceScreen(this);
init();
init(getIntent());
setPreferenceScreen(myScreen);
}

View file

@ -318,7 +318,7 @@ public class Book {
} else {
myId = database.insertBookInfo(File, myEncoding, myLanguage, myTitle);
}
long index = 0;
database.deleteAllBookAuthors(myId);
for (Author author : authors()) {