mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
refactoring: platform-dependent classes have been moved to the android package; FBReader -> FBReaderActivity
This commit is contained in:
parent
6ea4881643
commit
05ec6c3861
18 changed files with 96 additions and 69 deletions
|
@ -8,7 +8,7 @@
|
|||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<application android:name="org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication" android:icon="@drawable/fbreader" android:label="FBReader">
|
||||
<activity android:name=".library.BugReportActivity" android:label="FBReader crash" android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.FBReader" android:launchMode="singleTask" android:icon="@drawable/fbreader" android:label="FBReader" android:configChanges="orientation|keyboardHidden">
|
||||
<activity android:name="org.geometerplus.android.fbreader.FBReaderActivity" android:launchMode="singleTask" android:icon="@drawable/fbreader" android:label="FBReader" android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<application android:name="org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication" android:icon="@drawable/fbreader" android:label="FBReader">
|
||||
<activity android:name=".library.BugReportActivity" android:label="FBReader crash" android:configChanges="orientation|keyboardHidden" />
|
||||
<activity android:name="org.geometerplus.android.fbreader.FBReader" android:launchMode="singleTask" android:icon="@drawable/fbreader" android:label="FBReader" android:configChanges="orientation|keyboardHidden">
|
||||
<activity android:name="org.geometerplus.android.fbreader.FBReaderActivity" android:launchMode="singleTask" android:icon="@drawable/fbreader" android:label="FBReader" android:configChanges="orientation|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
|
|
@ -17,13 +17,15 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
import org.geometerplus.android.fbreader.preferences.BookInfoActivity;
|
||||
|
||||
class BookInfoAction extends RunActivityAction {
|
||||
BookInfoAction(FBReader fbreader) {
|
||||
super(fbreader, BookInfoActivity.class);
|
||||
BookInfoAction(FBReaderActivity baseActivity, FBReader fbreader) {
|
||||
super(baseActivity, fbreader, BookInfoActivity.class);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
|
@ -43,11 +43,12 @@ import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
|||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
|
||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
import org.geometerplus.fbreader.fbreader.ActionCode;
|
||||
import org.geometerplus.fbreader.library.Library;
|
||||
|
||||
public final class FBReader extends ZLAndroidActivity {
|
||||
public static FBReader Instance;
|
||||
public final class FBReaderActivity extends ZLAndroidActivity {
|
||||
static FBReaderActivity Instance;
|
||||
|
||||
private int myFullScreenFlag;
|
||||
|
||||
|
@ -57,16 +58,16 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
|
||||
@Override
|
||||
public void onShow() {
|
||||
if (FBReader.Instance != null && myControlPanel != null) {
|
||||
FBReader.Instance.setupNavigation(myControlPanel);
|
||||
if (Instance != null && myControlPanel != null) {
|
||||
Instance.setupNavigation(myControlPanel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStates() {
|
||||
super.updateStates();
|
||||
if (!NavigateDragging && FBReader.Instance != null && myControlPanel != null) {
|
||||
FBReader.Instance.setupNavigation(myControlPanel);
|
||||
if (!NavigateDragging && Instance != null && myControlPanel != null) {
|
||||
Instance.setupNavigation(myControlPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +125,7 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
startActivity(new Intent(this, this.getClass()));
|
||||
}
|
||||
|
||||
final RelativeLayout root = (RelativeLayout)FBReader.this.findViewById(R.id.root_view);
|
||||
final RelativeLayout root = (RelativeLayout)findViewById(R.id.root_view);
|
||||
if (!myTextSearchPanel.hasControlPanel()) {
|
||||
final ControlPanel panel = new ControlPanel(this);
|
||||
|
||||
|
@ -181,8 +182,20 @@ public final class FBReader extends ZLAndroidActivity {
|
|||
|
||||
protected ZLApplication createApplication(String fileName) {
|
||||
new SQLiteBooksDatabase();
|
||||
String[] args = (fileName != null) ? new String[] { fileName } : new String[0];
|
||||
return new org.geometerplus.fbreader.fbreader.FBReader(args);
|
||||
final String[] args = (fileName != null) ? new String[] { fileName } : new String[0];
|
||||
|
||||
final FBReader fbReader = new FBReader(args);
|
||||
|
||||
fbReader.addAction(ActionCode.SHOW_LIBRARY, new ShowLibraryAction(this, fbReader));
|
||||
fbReader.addAction(ActionCode.SHOW_PREFERENCES, new PreferencesAction(this, fbReader));
|
||||
fbReader.addAction(ActionCode.SHOW_BOOK_INFO, new BookInfoAction(this, fbReader));
|
||||
fbReader.addAction(ActionCode.SHOW_CONTENTS, new ShowTOCAction(this, fbReader));
|
||||
fbReader.addAction(ActionCode.SHOW_BOOKMARKS, new ShowBookmarksAction(this, fbReader));
|
||||
fbReader.addAction(ActionCode.SHOW_NETWORK_LIBRARY, new ShowNetworkLibraryAction(this, fbReader));
|
||||
|
||||
fbReader.addAction(ActionCode.SHOW_NAVIGATION, new ShowNavigationAction(this, fbReader));
|
||||
|
||||
return fbReader;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -258,7 +258,7 @@ public class LibraryTabActivity extends TabActivity implements MenuItem.OnMenuIt
|
|||
}
|
||||
|
||||
private Intent getFBReaderIntent(final File file) {
|
||||
final Intent intent = new Intent(getApplicationContext(), org.geometerplus.android.fbreader.FBReader.class);
|
||||
final Intent intent = new Intent(getApplicationContext(), FBReaderActivity.class);
|
||||
intent.setAction(Intent.ACTION_VIEW);
|
||||
if (file != null) {
|
||||
intent.setData(Uri.fromFile(file));
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
import org.geometerplus.android.fbreader.preferences.PreferenceActivity;
|
||||
|
||||
class PreferencesAction extends RunActivityAction {
|
||||
PreferencesAction(FBReader fbreader) {
|
||||
super(fbreader, PreferenceActivity.class);
|
||||
PreferencesAction(FBReaderActivity baseActivity, FBReader fbreader) {
|
||||
super(baseActivity, fbreader, PreferenceActivity.class);
|
||||
}
|
||||
}
|
|
@ -17,21 +17,24 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.dialogs.ZLAndroidDialogManager;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.FBAction;
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
abstract class RunActivityAction extends FBAction {
|
||||
private final FBReaderActivity myBaseActivity;
|
||||
private final Class<?> myActivityClass;
|
||||
|
||||
RunActivityAction(FBReader fbreader, Class<?> activityClass) {
|
||||
RunActivityAction(FBReaderActivity baseActivity, FBReader fbreader, Class<?> activityClass) {
|
||||
super(fbreader);
|
||||
myBaseActivity = baseActivity;
|
||||
myActivityClass = activityClass;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
final ZLAndroidDialogManager dialogManager =
|
||||
(ZLAndroidDialogManager)ZLAndroidDialogManager.Instance();
|
||||
dialogManager.runActivity(myActivityClass);
|
||||
myBaseActivity.startActivity(new Intent(myBaseActivity.getApplicationContext(), myActivityClass));
|
||||
}
|
||||
}
|
|
@ -17,12 +17,12 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.android.fbreader.BookmarksActivity;
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
class ShowBookmarksAction extends RunActivityAction {
|
||||
ShowBookmarksAction(FBReader fbreader) {
|
||||
super(fbreader, BookmarksActivity.class);
|
||||
ShowBookmarksAction(FBReaderActivity baseActivity, FBReader fbreader) {
|
||||
super(baseActivity, fbreader, BookmarksActivity.class);
|
||||
}
|
||||
}
|
|
@ -17,19 +17,24 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.geometerplus.android.fbreader.LibraryTabActivity;
|
||||
import org.geometerplus.fbreader.fbreader.FBAction;
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
import org.geometerplus.fbreader.bookmodel.BookModel;
|
||||
|
||||
import org.geometerplus.zlibrary.ui.android.dialogs.ZLAndroidDialogManager;
|
||||
|
||||
class ShowLibraryAction extends FBAction {
|
||||
ShowLibraryAction(FBReader fbreader) {
|
||||
private final FBReaderActivity myBaseActivity;
|
||||
|
||||
ShowLibraryAction(FBReaderActivity baseActivity, FBReader fbreader) {
|
||||
super(fbreader);
|
||||
myBaseActivity = baseActivity;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
@ -37,12 +42,13 @@ class ShowLibraryAction extends FBAction {
|
|||
(ZLAndroidDialogManager)ZLAndroidDialogManager.Instance();
|
||||
final HashMap<String,String> data = new HashMap<String,String>();
|
||||
final BookModel model = Reader.Model;
|
||||
if (model != null) {
|
||||
data.put(LibraryTabActivity.CURRENT_BOOK_PATH_KEY, model.Book.File.getPath());
|
||||
}
|
||||
Runnable action = new Runnable() {
|
||||
public void run() {
|
||||
dialogManager.runActivity(LibraryTabActivity.class, data);
|
||||
Intent intent = new Intent(myBaseActivity.getApplicationContext(), LibraryTabActivity.class);
|
||||
if (model != null && model.Book != null) {
|
||||
intent.putExtra(LibraryTabActivity.CURRENT_BOOK_PATH_KEY, model.Book.File.getPath());
|
||||
}
|
||||
myBaseActivity.startActivity(intent);
|
||||
}
|
||||
};
|
||||
dialogManager.wait("loadingBookList", action);
|
|
@ -17,14 +17,20 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.zlibrary.text.model.ZLTextModel;
|
||||
import org.geometerplus.zlibrary.text.view.ZLTextView;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.FBAction;
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
class ShowNavigationAction extends FBAction {
|
||||
ShowNavigationAction(FBReader fbreader) {
|
||||
private final FBReaderActivity myActivity;
|
||||
|
||||
ShowNavigationAction(FBReaderActivity activity, FBReader fbreader) {
|
||||
super(fbreader);
|
||||
myActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +41,6 @@ class ShowNavigationAction extends FBAction {
|
|||
}
|
||||
|
||||
public void run() {
|
||||
org.geometerplus.android.fbreader.FBReader.Instance.navigate();
|
||||
myActivity.navigate();
|
||||
}
|
||||
}
|
|
@ -17,12 +17,14 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
import org.geometerplus.android.fbreader.network.NetworkLibraryActivity;
|
||||
|
||||
class ShowNetworkLibraryAction extends RunActivityAction {
|
||||
ShowNetworkLibraryAction(FBReader fbreader) {
|
||||
super(fbreader, NetworkLibraryActivity.class);
|
||||
ShowNetworkLibraryAction(FBReaderActivity baseActivity, FBReader fbreader) {
|
||||
super(baseActivity, fbreader, NetworkLibraryActivity.class);
|
||||
}
|
||||
}
|
|
@ -17,13 +17,13 @@
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.fbreader.fbreader;
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import org.geometerplus.android.fbreader.TOCActivity;
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
class ShowTOCAction extends RunActivityAction {
|
||||
ShowTOCAction(FBReader fbreader) {
|
||||
super(fbreader, TOCActivity.class);
|
||||
ShowTOCAction(FBReaderActivity baseActivity, FBReader fbreader) {
|
||||
super(baseActivity, fbreader, TOCActivity.class);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
|
@ -21,15 +21,17 @@ package org.geometerplus.android.fbreader;
|
|||
|
||||
import android.app.Activity;
|
||||
|
||||
import org.geometerplus.fbreader.fbreader.FBReader;
|
||||
|
||||
public class TextSearchActivity extends SearchActivity {
|
||||
@Override
|
||||
void onSuccess() {
|
||||
FBReader.Instance.showTextSearchControls(true);
|
||||
FBReaderActivity.Instance.showTextSearchControls(true);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
void onFailure() {
|
||||
FBReader.Instance.showTextSearchControls(false);
|
||||
FBReaderActivity.Instance.showTextSearchControls(false);
|
||||
}*/
|
||||
|
||||
@Override
|
||||
|
@ -44,14 +46,13 @@ public class TextSearchActivity extends SearchActivity {
|
|||
|
||||
@Override
|
||||
boolean runSearch(final String pattern) {
|
||||
final org.geometerplus.fbreader.fbreader.FBReader fbreader =
|
||||
(org.geometerplus.fbreader.fbreader.FBReader)org.geometerplus.fbreader.fbreader.FBReader.Instance();
|
||||
fbreader.TextSearchPatternOption.setValue(pattern);
|
||||
return fbreader.getTextView().search(pattern, true, false, false, false) != 0;
|
||||
final FBReader fbReader = (FBReader)FBReader.Instance();
|
||||
fbReader.TextSearchPatternOption.setValue(pattern);
|
||||
return fbReader.getTextView().search(pattern, true, false, false, false) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
Activity getParentActivity() {
|
||||
return FBReader.Instance;
|
||||
return FBReaderActivity.Instance;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,9 +42,9 @@ import org.geometerplus.zlibrary.core.network.*;
|
|||
|
||||
import org.geometerplus.fbreader.network.BookReference;
|
||||
|
||||
import org.geometerplus.android.fbreader.FBReaderActivity;
|
||||
|
||||
public class BookDownloaderService extends Service {
|
||||
|
||||
public static final String BOOK_FORMAT_KEY = "org.geometerplus.android.fbreader.network.BookFormat";
|
||||
public static final String REFERENCE_TYPE_KEY = "org.geometerplus.android.fbreader.network.ReferenceType";
|
||||
public static final String CLEAN_URL_KEY = "org.geometerplus.android.fbreader.network.CleanURL";
|
||||
|
@ -191,7 +191,7 @@ public class BookDownloaderService extends Service {
|
|||
}
|
||||
|
||||
private Intent getFBReaderIntent(final File file) {
|
||||
final Intent intent = new Intent(getApplicationContext(), org.geometerplus.android.fbreader.FBReader.class);
|
||||
final Intent intent = new Intent(getApplicationContext(), FBReaderActivity.class);
|
||||
if (file != null) {
|
||||
intent.setAction(Intent.ACTION_VIEW).setData(Uri.fromFile(file));
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
|||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
|
||||
import org.geometerplus.android.util.AndroidUtil;
|
||||
import org.geometerplus.android.fbreader.FBReaderActivity;
|
||||
|
||||
import org.geometerplus.fbreader.network.*;
|
||||
import org.geometerplus.fbreader.network.tree.NetworkBookTree;
|
||||
|
@ -48,7 +49,6 @@ import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationMan
|
|||
|
||||
|
||||
class NetworkBookActions extends NetworkTreeActions {
|
||||
|
||||
private static final String PACKAGE = "org.geometerplus.android.fbreader.network";
|
||||
|
||||
public static final int DOWNLOAD_BOOK_ITEM_ID = 0;
|
||||
|
@ -307,7 +307,7 @@ class NetworkBookActions extends NetworkTreeActions {
|
|||
new Intent(Intent.ACTION_VIEW,
|
||||
Uri.fromFile(new File(local)),
|
||||
activity.getApplicationContext(),
|
||||
org.geometerplus.android.fbreader.FBReader.class
|
||||
FBReaderActivity.class
|
||||
).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ package org.geometerplus.fbreader.fbreader;
|
|||
|
||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||
|
||||
abstract class FBAction extends ZLApplication.ZLAction {
|
||||
public abstract class FBAction extends ZLApplication.ZLAction {
|
||||
protected final FBReader Reader;
|
||||
|
||||
FBAction(FBReader fbreader) {
|
||||
public FBAction(FBReader fbreader) {
|
||||
Reader = fbreader;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,20 +75,12 @@ public final class FBReader extends ZLApplication {
|
|||
addAction(ActionCode.INCREASE_FONT, new ChangeFontSizeAction(this, +2));
|
||||
addAction(ActionCode.DECREASE_FONT, new ChangeFontSizeAction(this, -2));
|
||||
addAction(ActionCode.ROTATE, new RotateAction(this));
|
||||
|
||||
addAction(ActionCode.SHOW_LIBRARY, new ShowLibraryAction(this));
|
||||
addAction(ActionCode.SHOW_PREFERENCES, new PreferencesAction(this));
|
||||
addAction(ActionCode.SHOW_BOOK_INFO, new BookInfoAction(this));
|
||||
addAction(ActionCode.SHOW_CONTENTS, new ShowTOCAction(this));
|
||||
addAction(ActionCode.SHOW_BOOKMARKS, new ShowBookmarksAction(this));
|
||||
addAction(ActionCode.SHOW_NETWORK_LIBRARY, new ShowNetworkLibraryAction(this));
|
||||
|
||||
addAction(ActionCode.SEARCH, new SearchAction(this));
|
||||
addAction(ActionCode.FIND_NEXT, new FindNextAction(this));
|
||||
addAction(ActionCode.FIND_PREVIOUS, new FindPreviousAction(this));
|
||||
addAction(ActionCode.CLEAR_FIND_RESULTS, new ClearFindResultsAction(this));
|
||||
|
||||
addAction(ActionCode.SHOW_NAVIGATION, new ShowNavigationAction(this));
|
||||
|
||||
addAction(ActionCode.VOLUME_KEY_SCROLL_FORWARD, new VolumeKeyScrollingAction(this, true));
|
||||
addAction(ActionCode.VOLUME_KEY_SCROLL_BACKWARD, new VolumeKeyScrollingAction(this, false));
|
||||
addAction(ActionCode.TRACKBALL_SCROLL_FORWARD, new TrackballScrollingAction(this, true));
|
||||
|
|
|
@ -111,7 +111,7 @@ public abstract class ZLApplication {
|
|||
hideAllPanels();
|
||||
}
|
||||
|
||||
protected final void addAction(String actionId, ZLAction action) {
|
||||
public final void addAction(String actionId, ZLAction action) {
|
||||
myIdToActionMap.put(actionId, action);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue