mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
BookInfoActivity has been moved to the ":library" process
This commit is contained in:
parent
1718b58dea
commit
1b7e6b6471
8 changed files with 47 additions and 15 deletions
|
@ -83,7 +83,7 @@
|
||||||
</activity>
|
</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.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.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">
|
<activity android:name="org.geometerplus.android.fbreader.network.BookDownloader" android:process=":bookDownloader" android:theme="@android:style/Theme.NoDisplay">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.geometerplus.fbreader.library.*;
|
||||||
import org.geometerplus.fbreader.tree.FBTree;
|
import org.geometerplus.fbreader.tree.FBTree;
|
||||||
|
|
||||||
public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuItemClickListener {
|
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;
|
static LibraryTabActivity Instance;
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,11 @@ import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.library.*;
|
import org.geometerplus.fbreader.library.*;
|
||||||
|
|
||||||
final class SQLiteBooksDatabase extends BooksDatabase {
|
public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
private final String myInstanceId;
|
private final String myInstanceId;
|
||||||
private final SQLiteDatabase myDatabase;
|
private final SQLiteDatabase myDatabase;
|
||||||
|
|
||||||
SQLiteBooksDatabase(String instanceId) {
|
public SQLiteBooksDatabase(String instanceId) {
|
||||||
myInstanceId = instanceId;
|
myInstanceId = instanceId;
|
||||||
myDatabase = ZLAndroidApplication.Instance().openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
|
myDatabase = ZLAndroidApplication.Instance().openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null);
|
||||||
migrate();
|
migrate();
|
||||||
|
|
|
@ -21,8 +21,11 @@ package org.geometerplus.android.fbreader;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.fbreader.FBAction;
|
import org.geometerplus.fbreader.fbreader.FBAction;
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||||
|
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||||
|
|
||||||
import org.geometerplus.android.fbreader.preferences.BookInfoActivity;
|
import org.geometerplus.android.fbreader.preferences.BookInfoActivity;
|
||||||
|
|
||||||
|
@ -39,9 +42,20 @@ class ShowBookInfoAction extends FBAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
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(
|
myBaseActivity.startActivityForResult(
|
||||||
new Intent(myBaseActivity.getApplicationContext(), BookInfoActivity.class),
|
intent, FBReader.REPAINT_CODE
|
||||||
FBReader.REPAINT_CODE
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,19 +19,21 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader.preferences;
|
package org.geometerplus.android.fbreader.preferences;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
import org.geometerplus.zlibrary.core.language.ZLLanguageUtil;
|
import org.geometerplus.zlibrary.core.language.ZLLanguageUtil;
|
||||||
|
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
|
||||||
import org.geometerplus.fbreader.library.Book;
|
import org.geometerplus.fbreader.library.Book;
|
||||||
|
|
||||||
|
import org.geometerplus.android.fbreader.SQLiteBooksDatabase;
|
||||||
|
|
||||||
class BookTitlePreference extends ZLStringPreference {
|
class BookTitlePreference extends ZLStringPreference {
|
||||||
private final Book myBook;
|
private final Book myBook;
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ class LanguagePreference extends ZLStringListPreference {
|
||||||
String[] codes = new String[size + 1];
|
String[] codes = new String[size + 1];
|
||||||
String[] names = new String[size + 1];
|
String[] names = new String[size + 1];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Map.Entry<String,String> entry : map.entrySet()) {
|
for (TreeMap.Entry<String,String> entry : map.entrySet()) {
|
||||||
codes[index] = entry.getValue();
|
codes[index] = entry.getValue();
|
||||||
names[index] = entry.getKey();
|
names[index] = entry.getKey();
|
||||||
++index;
|
++index;
|
||||||
|
@ -84,6 +86,9 @@ class LanguagePreference extends ZLStringListPreference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BookInfoActivity extends ZLPreferenceActivity {
|
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;
|
private Book myBook;
|
||||||
|
|
||||||
public BookInfoActivity() {
|
public BookInfoActivity() {
|
||||||
|
@ -91,9 +96,20 @@ public class BookInfoActivity extends ZLPreferenceActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
final Category commonCategory = createCategory(null);
|
||||||
myBook = ((FBReaderApp)FBReaderApp.Instance()).Model.Book;
|
|
||||||
if (myBook.File.getPhysicalFile() != null) {
|
if (myBook.File.getPhysicalFile() != null) {
|
||||||
commonCategory.addPreference(new InfoPreference(
|
commonCategory.addPreference(new InfoPreference(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.geometerplus.android.fbreader.preferences;
|
package org.geometerplus.android.fbreader.preferences;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init(Intent intent) {
|
||||||
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
final FBReaderApp fbReader = (FBReaderApp)FBReaderApp.Instance();
|
||||||
final ZLAndroidApplication androidApp = ZLAndroidApplication.Instance();
|
final ZLAndroidApplication androidApp = ZLAndroidApplication.Instance();
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.*;
|
import android.preference.*;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.options.*;
|
import org.geometerplus.zlibrary.core.options.*;
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
|
@ -105,7 +106,7 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
|
||||||
return new Category(myScreen, myResource, resourceKey);
|
return new Category(myScreen, myResource, resourceKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void init();
|
protected abstract void init(Intent intent);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
|
@ -115,7 +116,7 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
|
||||||
|
|
||||||
myScreen = getPreferenceManager().createPreferenceScreen(this);
|
myScreen = getPreferenceManager().createPreferenceScreen(this);
|
||||||
|
|
||||||
init();
|
init(getIntent());
|
||||||
|
|
||||||
setPreferenceScreen(myScreen);
|
setPreferenceScreen(myScreen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,7 +318,7 @@ public class Book {
|
||||||
} else {
|
} else {
|
||||||
myId = database.insertBookInfo(File, myEncoding, myLanguage, myTitle);
|
myId = database.insertBookInfo(File, myEncoding, myLanguage, myTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
long index = 0;
|
long index = 0;
|
||||||
database.deleteAllBookAuthors(myId);
|
database.deleteAllBookAuthors(myId);
|
||||||
for (Author author : authors()) {
|
for (Author author : authors()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue