1
0
Fork 0
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:
Nikolay Pultsin 2013-01-03 03:34:21 +00:00
parent 9711842566
commit e94e59ef5b
18 changed files with 145 additions and 17 deletions

View file

@ -5,6 +5,7 @@
* Fixed issue with rendering during backward page turning with no amimation * Fixed issue with rendering during backward page turning with no amimation
* xlarge screens support declared in AndroidManifest.xml * xlarge screens support declared in AndroidManifest.xml
* ePub: fixed svg namespace processing * ePub: fixed svg namespace processing
* main activity orientation is used in all dependent activities
===== 1.6.8 (Nov 30, 2012) ===== ===== 1.6.8 (Nov 30, 2012) =====
* Fixed NPE during adding a custom catalog with no search link * Fixed NPE during adding a custom catalog with no search link

View file

@ -101,8 +101,16 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
findViewById(R.id.search_results).setVisibility(View.GONE); findViewById(R.id.search_results).setVisibility(View.GONE);
} }
@Override
protected void onStart() {
super.onStart();
OrientationUtil.setOrientation(this, getIntent());
}
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
OrientationUtil.setOrientation(this, intent);
if (!Intent.ACTION_SEARCH.equals(intent.getAction())) { if (!Intent.ACTION_SEARCH.equals(intent.getAction())) {
return; return;
} }
@ -193,7 +201,7 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
return true; return true;
case EDIT_ITEM_ID: case EDIT_ITEM_ID:
final Intent intent = new Intent(this, BookmarkEditActivity.class); final Intent intent = new Intent(this, BookmarkEditActivity.class);
startActivityForResult(intent, 1); OrientationUtil.startActivityForResult(this, intent, 1);
// TODO: implement // TODO: implement
return true; return true;
case DELETE_ITEM_ID: case DELETE_ITEM_ID:

View 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() {
}
}

View file

@ -79,7 +79,7 @@ class ProcessHyperlinkAction extends FBAndroidAction {
ImageViewActivity.BACKGROUND_COLOR_KEY, ImageViewActivity.BACKGROUND_COLOR_KEY,
Reader.ImageViewBackgroundOption.getValue().getIntValue() Reader.ImageViewBackgroundOption.getValue().getIntValue()
); );
BaseActivity.startActivity(intent); OrientationUtil.startActivity(BaseActivity, intent);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -111,7 +111,7 @@ class ProcessHyperlinkAction extends FBAndroidAction {
BaseActivity.runOnUiThread(new Runnable() { BaseActivity.runOnUiThread(new Runnable() {
public void run() { public void run() {
try { try {
BaseActivity.startActivity(intent); OrientationUtil.startActivity(BaseActivity, intent);
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -33,6 +33,8 @@ abstract class RunActivityAction extends FBAndroidAction {
@Override @Override
protected void run(Object ... params) { protected void run(Object ... params) {
BaseActivity.startActivity(new Intent(BaseActivity.getApplicationContext(), myActivityClass)); OrientationUtil.startActivity(
BaseActivity, new Intent(BaseActivity.getApplicationContext(), myActivityClass)
);
} }
} }

View file

@ -36,7 +36,9 @@ class RunPluginAction extends FBAndroidAction {
@Override @Override
protected void run(Object ... params) { protected void run(Object ... params) {
try { 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) { } catch (ActivityNotFoundException e) {
} }
} }

View file

@ -37,7 +37,8 @@ class ShowBookInfoAction extends FBAndroidAction {
@Override @Override
protected void run(Object ... params) { protected void run(Object ... params) {
BaseActivity.startActivityForResult( OrientationUtil.startActivityForResult(
BaseActivity,
new Intent(BaseActivity.getApplicationContext(), BookInfoActivity.class) new Intent(BaseActivity.getApplicationContext(), BookInfoActivity.class)
.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, Reader.Model.Book.File.getPath()) .putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, Reader.Model.Book.File.getPath())
.putExtra(BookInfoActivity.FROM_READING_MODE_KEY, true), .putExtra(BookInfoActivity.FROM_READING_MODE_KEY, true),

View file

@ -38,6 +38,6 @@ class ShowLibraryAction extends FBAndroidAction {
if (model != null && model.Book != null) { if (model != null && model.Book != null) {
intent.putExtra(LibraryActivity.SELECTED_BOOK_PATH_KEY, model.Book.File.getPath()); intent.putExtra(LibraryActivity.SELECTED_BOOK_PATH_KEY, model.Book.File.getPath());
} }
BaseActivity.startActivity(intent); OrientationUtil.startActivity(BaseActivity, intent);
} }
} }

View file

@ -37,6 +37,6 @@ class ShowPreferencesAction extends FBAndroidAction {
if (params.length == 1 && params[0] instanceof String) { if (params.length == 1 && params[0] instanceof String) {
intent.putExtra(PreferenceActivity.SCREEN_KEY, (String)params[0]); intent.putExtra(PreferenceActivity.SCREEN_KEY, (String)params[0]);
} }
BaseActivity.startActivityForResult(intent, FBReader.REQUEST_PREFERENCES); OrientationUtil.startActivityForResult(BaseActivity, intent, FBReader.REQUEST_PREFERENCES);
} }
} }

View file

@ -27,6 +27,6 @@ class ShowTOCAction extends RunActivityAction {
} }
public boolean isVisible() { public boolean isVisible() {
return (Reader.Model != null) && Reader.Model.TOCTree.hasChildren(); return Reader.Model != null && Reader.Model.TOCTree.hasChildren();
} }
} }

View file

@ -19,10 +19,12 @@
package org.geometerplus.android.fbreader; package org.geometerplus.android.fbreader;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.*; import android.view.*;
import android.widget.*; import android.widget.*;
import android.app.ListActivity;
import org.geometerplus.zlibrary.core.application.ZLApplication; import org.geometerplus.zlibrary.core.application.ZLApplication;
import org.geometerplus.zlibrary.core.resources.ZLResource; import org.geometerplus.zlibrary.core.resources.ZLResource;
@ -59,6 +61,17 @@ public class TOCActivity extends ListActivity {
mySelectedItem = treeToSelect; 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 PROCESS_TREE_ITEM_ID = 0;
private static final int READ_BOOK_ITEM_ID = 1; private static final int READ_BOOK_ITEM_ID = 1;

View file

@ -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.image.ZLAndroidImageData;
import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil; import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil;
import org.geometerplus.android.fbreader.OrientationUtil;
public class ImageViewActivity extends Activity { public class ImageViewActivity extends Activity {
public static final String BACKGROUND_COLOR_KEY = "bgColor"; 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 @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();

View file

@ -48,7 +48,7 @@ import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageManager;
import org.geometerplus.fbreader.library.*; import org.geometerplus.fbreader.library.*;
import org.geometerplus.fbreader.network.HtmlUtil; import org.geometerplus.fbreader.network.HtmlUtil;
import org.geometerplus.android.fbreader.FBReader; import org.geometerplus.android.fbreader.*;
import org.geometerplus.android.fbreader.preferences.EditBookInfoActivity; import org.geometerplus.android.fbreader.preferences.EditBookInfoActivity;
public class BookInfoActivity extends Activity { public class BookInfoActivity extends Activity {
@ -88,6 +88,8 @@ public class BookInfoActivity extends Activity {
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
OrientationUtil.setOrientation(this, getIntent());
final Book book = Book.getByFile(myFile); final Book book = Book.getByFile(myFile);
if (book != null) { if (book != null) {
@ -116,7 +118,8 @@ public class BookInfoActivity extends Activity {
}); });
setupButton(R.id.book_info_button_edit, "editInfo", new View.OnClickListener() { setupButton(R.id.book_info_button_edit, "editInfo", new View.OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
startActivityForResult( OrientationUtil.startActivityForResult(
BookInfoActivity.this,
new Intent(getApplicationContext(), EditBookInfoActivity.class) new Intent(getApplicationContext(), EditBookInfoActivity.class)
.putExtra(CURRENT_BOOK_PATH_KEY, myFile.getPath()), .putExtra(CURRENT_BOOK_PATH_KEY, myFile.getPath()),
1 1
@ -140,6 +143,11 @@ public class BookInfoActivity extends Activity {
root.requestLayout(); root.requestLayout();
} }
@Override
protected void onNewIntent(Intent intent) {
OrientationUtil.setOrientation(this, intent);
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
final Book book = Book.getByFile(myFile); final Book book = Book.getByFile(myFile);

View file

@ -38,8 +38,7 @@ import org.geometerplus.fbreader.library.*;
import org.geometerplus.fbreader.tree.FBTree; import org.geometerplus.fbreader.tree.FBTree;
import org.geometerplus.android.util.UIUtil; import org.geometerplus.android.util.UIUtil;
import org.geometerplus.android.fbreader.FBReader; import org.geometerplus.android.fbreader.*;
import org.geometerplus.android.fbreader.FBUtil;
import org.geometerplus.android.fbreader.tree.TreeActivity; import org.geometerplus.android.fbreader.tree.TreeActivity;
public class LibraryActivity extends TreeActivity implements MenuItem.OnMenuItemClickListener, View.OnCreateContextMenuListener, Library.ChangeListener { 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; private static final int BOOK_INFO_REQUEST = 1;
protected void showBookInfo(Book book) { private void showBookInfo(Book book) {
startActivityForResult( OrientationUtil.startActivityForResult(
this,
new Intent(getApplicationContext(), BookInfoActivity.class) new Intent(getApplicationContext(), BookInfoActivity.class)
.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, book.File.getPath()), .putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, book.File.getPath()),
BOOK_INFO_REQUEST BOOK_INFO_REQUEST

View file

@ -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.OpenCatalogAction;
import org.geometerplus.android.fbreader.network.action.NetworkBookActions; import org.geometerplus.android.fbreader.network.action.NetworkBookActions;
import org.geometerplus.android.fbreader.OrientationUtil;
import org.geometerplus.android.util.UIUtil; import org.geometerplus.android.util.UIUtil;
@ -409,9 +410,15 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
OrientationUtil.setOrientation(this, getIntent());
NetworkLibrary.Instance().addChangeListener(this); NetworkLibrary.Instance().addChangeListener(this);
} }
@Override
protected void onNewIntent(Intent intent) {
OrientationUtil.setOrientation(this, intent);
}
@Override @Override
protected void onStop() { protected void onStop() {
NetworkLibrary.Instance().removeChangeListener(this); NetworkLibrary.Instance().removeChangeListener(this);

View file

@ -31,6 +31,8 @@ import org.geometerplus.android.fbreader.network.NetworkBookInfoActivity;
import org.geometerplus.android.util.UIUtil; import org.geometerplus.android.util.UIUtil;
import org.geometerplus.android.fbreader.OrientationUtil;
public class ShowBookInfoAction extends BookAction { public class ShowBookInfoAction extends BookAction {
public ShowBookInfoAction(Activity activity) { public ShowBookInfoAction(Activity activity) {
super(activity, ActionCode.SHOW_BOOK_ACTIVITY, "bookInfo"); super(activity, ActionCode.SHOW_BOOK_ACTIVITY, "bookInfo");
@ -59,7 +61,8 @@ public class ShowBookInfoAction extends BookAction {
} }
private void showBookInfo(NetworkTree tree) { private void showBookInfo(NetworkTree tree) {
myActivity.startActivity( OrientationUtil.startActivity(
myActivity,
new Intent(myActivity, NetworkBookInfoActivity.class) new Intent(myActivity, NetworkBookInfoActivity.class)
.putExtra(NetworkLibraryActivity.TREE_KEY_KEY, tree.getUniqueKey()) .putExtra(NetworkLibraryActivity.TREE_KEY_KEY, tree.getUniqueKey())
); );

View file

@ -29,6 +29,8 @@ 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;
import org.geometerplus.android.fbreader.OrientationUtil;
abstract class ZLPreferenceActivity extends android.preference.PreferenceActivity { abstract class ZLPreferenceActivity extends android.preference.PreferenceActivity {
public static String SCREEN_KEY = "screen"; 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)); final Screen screen = myScreenMap.get(intent.getStringExtra(SCREEN_KEY));
setPreferenceScreen(screen != null ? screen.myScreen : myScreen); 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);
}
} }

View file

@ -30,6 +30,8 @@ import org.geometerplus.android.util.UIUtil;
import org.geometerplus.fbreader.tree.FBTree; import org.geometerplus.fbreader.tree.FBTree;
import org.geometerplus.android.fbreader.OrientationUtil;
public abstract class TreeActivity extends ListActivity { public abstract class TreeActivity extends ListActivity {
private static final String OPEN_TREE_ACTION = "android.fbreader.action.OPEN_TREE"; 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); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
} }
@Override
protected void onStart() {
super.onStart();
OrientationUtil.setOrientation(this, getIntent());
}
@Override @Override
public TreeAdapter getListAdapter() { public TreeAdapter getListAdapter() {
return (TreeAdapter)super.getListAdapter(); return (TreeAdapter)super.getListAdapter();
@ -61,6 +69,7 @@ public abstract class TreeActivity extends ListActivity {
@Override @Override
protected void onNewIntent(final Intent intent) { protected void onNewIntent(final Intent intent) {
OrientationUtil.setOrientation(this, intent);
if (OPEN_TREE_ACTION.equals(intent.getAction())) { if (OPEN_TREE_ACTION.equals(intent.getAction())) {
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {