mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
main activity orientation in all dependent activities
Conflicts: src/org/geometerplus/android/fbreader/TOCActivity.java src/org/geometerplus/android/fbreader/library/BookInfoActivity.java
This commit is contained in:
parent
9711842566
commit
e94e59ef5b
18 changed files with 145 additions and 17 deletions
|
@ -5,6 +5,7 @@
|
|||
* Fixed issue with rendering during backward page turning with no amimation
|
||||
* xlarge screens support declared in AndroidManifest.xml
|
||||
* ePub: fixed svg namespace processing
|
||||
* main activity orientation is used in all dependent activities
|
||||
|
||||
===== 1.6.8 (Nov 30, 2012) =====
|
||||
* Fixed NPE during adding a custom catalog with no search link
|
||||
|
|
|
@ -101,8 +101,16 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
|||
findViewById(R.id.search_results).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
OrientationUtil.setOrientation(this, getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
OrientationUtil.setOrientation(this, intent);
|
||||
|
||||
if (!Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
return;
|
||||
}
|
||||
|
@ -193,7 +201,7 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
|||
return true;
|
||||
case EDIT_ITEM_ID:
|
||||
final Intent intent = new Intent(this, BookmarkEditActivity.class);
|
||||
startActivityForResult(intent, 1);
|
||||
OrientationUtil.startActivityForResult(this, intent, 1);
|
||||
// TODO: implement
|
||||
return true;
|
||||
case DELETE_ITEM_ID:
|
||||
|
|
48
src/org/geometerplus/android/fbreader/OrientationUtil.java
Normal file
48
src/org/geometerplus/android/fbreader/OrientationUtil.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
public abstract class OrientationUtil {
|
||||
private static final String KEY = "fbreader.orientation";
|
||||
|
||||
public static void startActivity(Activity current, Intent intent) {
|
||||
current.startActivity(intent.putExtra(KEY, current.getRequestedOrientation()));
|
||||
}
|
||||
|
||||
public static void startActivityForResult(Activity current, Intent intent, int requestCode) {
|
||||
current.startActivityForResult(intent.putExtra(KEY, current.getRequestedOrientation()), requestCode);
|
||||
}
|
||||
|
||||
public static void setOrientation(Activity activity, Intent intent) {
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
final int orientation = intent.getIntExtra(KEY, Integer.MIN_VALUE);
|
||||
if (orientation != Integer.MIN_VALUE) {
|
||||
activity.setRequestedOrientation(orientation);
|
||||
}
|
||||
}
|
||||
|
||||
private OrientationUtil() {
|
||||
}
|
||||
}
|
|
@ -79,7 +79,7 @@ class ProcessHyperlinkAction extends FBAndroidAction {
|
|||
ImageViewActivity.BACKGROUND_COLOR_KEY,
|
||||
Reader.ImageViewBackgroundOption.getValue().getIntValue()
|
||||
);
|
||||
BaseActivity.startActivity(intent);
|
||||
OrientationUtil.startActivity(BaseActivity, intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class ProcessHyperlinkAction extends FBAndroidAction {
|
|||
BaseActivity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
BaseActivity.startActivity(intent);
|
||||
OrientationUtil.startActivity(BaseActivity, intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ abstract class RunActivityAction extends FBAndroidAction {
|
|||
|
||||
@Override
|
||||
protected void run(Object ... params) {
|
||||
BaseActivity.startActivity(new Intent(BaseActivity.getApplicationContext(), myActivityClass));
|
||||
OrientationUtil.startActivity(
|
||||
BaseActivity, new Intent(BaseActivity.getApplicationContext(), myActivityClass)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,9 @@ class RunPluginAction extends FBAndroidAction {
|
|||
@Override
|
||||
protected void run(Object ... params) {
|
||||
try {
|
||||
BaseActivity.startActivity(new Intent("android.fbreader.action.plugin.RUN", myUri));
|
||||
OrientationUtil.startActivity(
|
||||
BaseActivity, new Intent("android.fbreader.action.plugin.RUN", myUri)
|
||||
);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ class ShowBookInfoAction extends FBAndroidAction {
|
|||
|
||||
@Override
|
||||
protected void run(Object ... params) {
|
||||
BaseActivity.startActivityForResult(
|
||||
OrientationUtil.startActivityForResult(
|
||||
BaseActivity,
|
||||
new Intent(BaseActivity.getApplicationContext(), BookInfoActivity.class)
|
||||
.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, Reader.Model.Book.File.getPath())
|
||||
.putExtra(BookInfoActivity.FROM_READING_MODE_KEY, true),
|
||||
|
|
|
@ -38,6 +38,6 @@ class ShowLibraryAction extends FBAndroidAction {
|
|||
if (model != null && model.Book != null) {
|
||||
intent.putExtra(LibraryActivity.SELECTED_BOOK_PATH_KEY, model.Book.File.getPath());
|
||||
}
|
||||
BaseActivity.startActivity(intent);
|
||||
OrientationUtil.startActivity(BaseActivity, intent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ class ShowPreferencesAction extends FBAndroidAction {
|
|||
if (params.length == 1 && params[0] instanceof String) {
|
||||
intent.putExtra(PreferenceActivity.SCREEN_KEY, (String)params[0]);
|
||||
}
|
||||
BaseActivity.startActivityForResult(intent, FBReader.REQUEST_PREFERENCES);
|
||||
OrientationUtil.startActivityForResult(BaseActivity, intent, FBReader.REQUEST_PREFERENCES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,6 @@ class ShowTOCAction extends RunActivityAction {
|
|||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return (Reader.Model != null) && Reader.Model.TOCTree.hasChildren();
|
||||
return Reader.Model != null && Reader.Model.TOCTree.hasChildren();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
|
||||
package org.geometerplus.android.fbreader;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
import android.app.ListActivity;
|
||||
|
||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
@ -59,6 +61,17 @@ public class TOCActivity extends ListActivity {
|
|||
mySelectedItem = treeToSelect;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
OrientationUtil.setOrientation(this, getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
OrientationUtil.setOrientation(this, intent);
|
||||
}
|
||||
|
||||
private static final int PROCESS_TREE_ITEM_ID = 0;
|
||||
private static final int READ_BOOK_ITEM_ID = 1;
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ import org.geometerplus.zlibrary.ui.android.library.ZLAndroidLibrary;
|
|||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageData;
|
||||
import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil;
|
||||
|
||||
import org.geometerplus.android.fbreader.OrientationUtil;
|
||||
|
||||
public class ImageViewActivity extends Activity {
|
||||
public static final String BACKGROUND_COLOR_KEY = "bgColor";
|
||||
|
||||
|
@ -87,6 +89,17 @@ public class ImageViewActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
OrientationUtil.setOrientation(this, getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
OrientationUtil.setOrientation(this, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
|
|||
import org.geometerplus.fbreader.library.*;
|
||||
import org.geometerplus.fbreader.network.HtmlUtil;
|
||||
|
||||
import org.geometerplus.android.fbreader.FBReader;
|
||||
import org.geometerplus.android.fbreader.*;
|
||||
import org.geometerplus.android.fbreader.preferences.EditBookInfoActivity;
|
||||
|
||||
public class BookInfoActivity extends Activity {
|
||||
|
@ -88,6 +88,8 @@ public class BookInfoActivity extends Activity {
|
|||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
OrientationUtil.setOrientation(this, getIntent());
|
||||
|
||||
final Book book = Book.getByFile(myFile);
|
||||
|
||||
if (book != null) {
|
||||
|
@ -116,7 +118,8 @@ public class BookInfoActivity extends Activity {
|
|||
});
|
||||
setupButton(R.id.book_info_button_edit, "editInfo", new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
startActivityForResult(
|
||||
OrientationUtil.startActivityForResult(
|
||||
BookInfoActivity.this,
|
||||
new Intent(getApplicationContext(), EditBookInfoActivity.class)
|
||||
.putExtra(CURRENT_BOOK_PATH_KEY, myFile.getPath()),
|
||||
1
|
||||
|
@ -140,6 +143,11 @@ public class BookInfoActivity extends Activity {
|
|||
root.requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
OrientationUtil.setOrientation(this, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
final Book book = Book.getByFile(myFile);
|
||||
|
|
|
@ -38,8 +38,7 @@ import org.geometerplus.fbreader.library.*;
|
|||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
import org.geometerplus.android.fbreader.FBReader;
|
||||
import org.geometerplus.android.fbreader.FBUtil;
|
||||
import org.geometerplus.android.fbreader.*;
|
||||
import org.geometerplus.android.fbreader.tree.TreeActivity;
|
||||
|
||||
public class LibraryActivity extends TreeActivity implements MenuItem.OnMenuItemClickListener, View.OnCreateContextMenuListener, Library.ChangeListener {
|
||||
|
@ -129,8 +128,9 @@ public class LibraryActivity extends TreeActivity implements MenuItem.OnMenuItem
|
|||
//
|
||||
private static final int BOOK_INFO_REQUEST = 1;
|
||||
|
||||
protected void showBookInfo(Book book) {
|
||||
startActivityForResult(
|
||||
private void showBookInfo(Book book) {
|
||||
OrientationUtil.startActivityForResult(
|
||||
this,
|
||||
new Intent(getApplicationContext(), BookInfoActivity.class)
|
||||
.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, book.File.getPath()),
|
||||
BOOK_INFO_REQUEST
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.geometerplus.fbreader.network.opds.OPDSBookItem;
|
|||
|
||||
import org.geometerplus.android.fbreader.network.action.OpenCatalogAction;
|
||||
import org.geometerplus.android.fbreader.network.action.NetworkBookActions;
|
||||
import org.geometerplus.android.fbreader.OrientationUtil;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
||||
|
@ -409,9 +410,15 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
|
|||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
OrientationUtil.setOrientation(this, getIntent());
|
||||
NetworkLibrary.Instance().addChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
OrientationUtil.setOrientation(this, intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
NetworkLibrary.Instance().removeChangeListener(this);
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.geometerplus.android.fbreader.network.NetworkBookInfoActivity;
|
|||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
||||
import org.geometerplus.android.fbreader.OrientationUtil;
|
||||
|
||||
public class ShowBookInfoAction extends BookAction {
|
||||
public ShowBookInfoAction(Activity activity) {
|
||||
super(activity, ActionCode.SHOW_BOOK_ACTIVITY, "bookInfo");
|
||||
|
@ -59,7 +61,8 @@ public class ShowBookInfoAction extends BookAction {
|
|||
}
|
||||
|
||||
private void showBookInfo(NetworkTree tree) {
|
||||
myActivity.startActivity(
|
||||
OrientationUtil.startActivity(
|
||||
myActivity,
|
||||
new Intent(myActivity, NetworkBookInfoActivity.class)
|
||||
.putExtra(NetworkLibraryActivity.TREE_KEY_KEY, tree.getUniqueKey())
|
||||
);
|
||||
|
|
|
@ -29,6 +29,8 @@ import android.content.Intent;
|
|||
import org.geometerplus.zlibrary.core.options.*;
|
||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||
|
||||
import org.geometerplus.android.fbreader.OrientationUtil;
|
||||
|
||||
abstract class ZLPreferenceActivity extends android.preference.PreferenceActivity {
|
||||
public static String SCREEN_KEY = "screen";
|
||||
|
||||
|
@ -132,4 +134,15 @@ abstract class ZLPreferenceActivity extends android.preference.PreferenceActivit
|
|||
final Screen screen = myScreenMap.get(intent.getStringExtra(SCREEN_KEY));
|
||||
setPreferenceScreen(screen != null ? screen.myScreen : myScreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
OrientationUtil.setOrientation(this, getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
OrientationUtil.setOrientation(this, intent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ import org.geometerplus.android.util.UIUtil;
|
|||
|
||||
import org.geometerplus.fbreader.tree.FBTree;
|
||||
|
||||
import org.geometerplus.android.fbreader.OrientationUtil;
|
||||
|
||||
public abstract class TreeActivity extends ListActivity {
|
||||
private static final String OPEN_TREE_ACTION = "android.fbreader.action.OPEN_TREE";
|
||||
|
||||
|
@ -50,6 +52,12 @@ public abstract class TreeActivity extends ListActivity {
|
|||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
OrientationUtil.setOrientation(this, getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeAdapter getListAdapter() {
|
||||
return (TreeAdapter)super.getListAdapter();
|
||||
|
@ -61,6 +69,7 @@ public abstract class TreeActivity extends ListActivity {
|
|||
|
||||
@Override
|
||||
protected void onNewIntent(final Intent intent) {
|
||||
OrientationUtil.setOrientation(this, intent);
|
||||
if (OPEN_TREE_ACTION.equals(intent.getAction())) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue