mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
image view setting
This commit is contained in:
parent
184b18a9f0
commit
7e81e7f3ea
7 changed files with 85 additions and 22 deletions
|
@ -543,6 +543,15 @@
|
||||||
<node name="summaryOff" value="Key navigation visits hyperlinks only"/>
|
<node name="summaryOff" value="Key navigation visits hyperlinks only"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
|
<node name="images" value="Images">
|
||||||
|
<node name="summary" value="Image displaying options"/>
|
||||||
|
<node name="backgroundColor" value="Background color for image view"/>
|
||||||
|
<node name="tappingAction" value="Long tapping action">
|
||||||
|
<node name="doNothing" value="Long tapping does nothing"/>
|
||||||
|
<node name="selectImage" value="Long tapping selects the image"/>
|
||||||
|
<node name="openImageView" value="Long tapping opens image view"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
<node name="cancelMenu" value="Cancel menu">
|
<node name="cancelMenu" value="Cancel menu">
|
||||||
<node name="summary" value="Back button action list"/>
|
<node name="summary" value="Back button action list"/>
|
||||||
<node name="previousBook" value="Previous book">
|
<node name="previousBook" value="Previous book">
|
||||||
|
|
|
@ -10,4 +10,4 @@
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-8
|
target=android-8
|
||||||
java.encoding=utf-8
|
java.encoding=utf-8
|
||||||
proguard.config=proguard.cfg
|
#proguard.config=proguard.cfg
|
||||||
|
|
|
@ -78,6 +78,10 @@ class ProcessHyperlinkAction extends FBAction {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setClass(myBaseActivity, ImageViewActivity.class);
|
intent.setClass(myBaseActivity, ImageViewActivity.class);
|
||||||
intent.setData(Uri.parse(uriString));
|
intent.setData(Uri.parse(uriString));
|
||||||
|
intent.putExtra(
|
||||||
|
ImageViewActivity.BACKGROUND_COLOR_KEY,
|
||||||
|
Reader.ImageViewBackgroundOption.getValue().getIntValue()
|
||||||
|
);
|
||||||
myBaseActivity.startActivity(intent);
|
myBaseActivity.startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.geometerplus.android.fbreader.image;
|
package org.geometerplus.android.fbreader.image;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -28,12 +29,17 @@ import android.view.*;
|
||||||
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
||||||
import org.geometerplus.zlibrary.core.image.*;
|
import org.geometerplus.zlibrary.core.image.*;
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
|
import org.geometerplus.zlibrary.core.util.ZLColor;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
|
||||||
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageData;
|
import org.geometerplus.zlibrary.ui.android.image.ZLAndroidImageData;
|
||||||
|
import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil;
|
||||||
|
|
||||||
public class ImageViewActivity extends Activity {
|
public class ImageViewActivity extends Activity {
|
||||||
Bitmap myBitmap;
|
public static final String BACKGROUND_COLOR_KEY = "bgColor";
|
||||||
|
|
||||||
|
private Bitmap myBitmap;
|
||||||
|
private ZLColor myBgColor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
|
@ -53,7 +59,13 @@ public class ImageViewActivity extends Activity {
|
||||||
|
|
||||||
setContentView(new ImageView());
|
setContentView(new ImageView());
|
||||||
|
|
||||||
final Uri uri = getIntent().getData();
|
final Intent intent = getIntent();
|
||||||
|
|
||||||
|
myBgColor = new ZLColor(
|
||||||
|
intent.getIntExtra(BACKGROUND_COLOR_KEY, new ZLColor(127, 127, 127).getIntValue())
|
||||||
|
);
|
||||||
|
|
||||||
|
final Uri uri = intent.getData();
|
||||||
if (ZLFileImage.SCHEME.equals(uri.getScheme())) {
|
if (ZLFileImage.SCHEME.equals(uri.getScheme())) {
|
||||||
try {
|
try {
|
||||||
final String[] data = uri.getPath().split("\000");
|
final String[] data = uri.getPath().split("\000");
|
||||||
|
@ -96,7 +108,7 @@ public class ImageViewActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(final Canvas canvas) {
|
protected void onDraw(final Canvas canvas) {
|
||||||
myPaint.setColor(Color.rgb(128, 128, 128));
|
myPaint.setColor(ZLAndroidColorUtil.rgb(myBgColor));
|
||||||
final int w = getWidth();
|
final int w = getWidth();
|
||||||
final int h = getHeight();
|
final int h = getHeight();
|
||||||
canvas.drawRect(0, 0, w, h, myPaint);
|
canvas.drawRect(0, 0, w, h, myPaint);
|
||||||
|
|
|
@ -382,6 +382,10 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
));
|
));
|
||||||
dictionaryScreen.addOption(fbReader.DictionaryTappingActionOption, "tappingAction");
|
dictionaryScreen.addOption(fbReader.DictionaryTappingActionOption, "tappingAction");
|
||||||
|
|
||||||
|
final Screen imagesScreen = createPreferenceScreen("images");
|
||||||
|
imagesScreen.addOption(fbReader.ImageTappingActionOption, "tappingAction");
|
||||||
|
imagesScreen.addOption(fbReader.ImageViewBackgroundOption, "backgroundColor");
|
||||||
|
|
||||||
final Screen cancelMenuScreen = createPreferenceScreen("cancelMenu");
|
final Screen cancelMenuScreen = createPreferenceScreen("cancelMenu");
|
||||||
cancelMenuScreen.addOption(fbReader.ShowPreviousBookInCancelMenuOption, "previousBook");
|
cancelMenuScreen.addOption(fbReader.ShowPreviousBookInCancelMenuOption, "previousBook");
|
||||||
cancelMenuScreen.addOption(fbReader.ShowPositionsInCancelMenuOption, "positions");
|
cancelMenuScreen.addOption(fbReader.ShowPositionsInCancelMenuOption, "positions");
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.geometerplus.zlibrary.core.filesystem.*;
|
||||||
import org.geometerplus.zlibrary.core.application.*;
|
import org.geometerplus.zlibrary.core.application.*;
|
||||||
import org.geometerplus.zlibrary.core.dialogs.ZLDialogManager;
|
import org.geometerplus.zlibrary.core.dialogs.ZLDialogManager;
|
||||||
import org.geometerplus.zlibrary.core.options.*;
|
import org.geometerplus.zlibrary.core.options.*;
|
||||||
|
import org.geometerplus.zlibrary.core.util.ZLColor;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator;
|
||||||
import org.geometerplus.zlibrary.text.view.ZLTextWordCursor;
|
import org.geometerplus.zlibrary.text.view.ZLTextWordCursor;
|
||||||
|
@ -55,6 +56,14 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
public final ZLEnumOption<DictionaryTappingAction> DictionaryTappingActionOption =
|
public final ZLEnumOption<DictionaryTappingAction> DictionaryTappingActionOption =
|
||||||
new ZLEnumOption<DictionaryTappingAction>("Options", "DictionaryTappingAction", DictionaryTappingAction.selectWord);
|
new ZLEnumOption<DictionaryTappingAction>("Options", "DictionaryTappingAction", DictionaryTappingAction.selectWord);
|
||||||
|
|
||||||
|
public final ZLColorOption ImageViewBackgroundOption =
|
||||||
|
new ZLColorOption("Colors", "ImageViewBackground", new ZLColor(127, 127, 127));
|
||||||
|
public static enum ImageTappingAction {
|
||||||
|
doNothing, selectImage, openImageView
|
||||||
|
}
|
||||||
|
public final ZLEnumOption<ImageTappingAction> ImageTappingActionOption =
|
||||||
|
new ZLEnumOption<ImageTappingAction>("Options", "ImageTappingAction", ImageTappingAction.openImageView);
|
||||||
|
|
||||||
public final ZLIntegerRangeOption LeftMarginOption =
|
public final ZLIntegerRangeOption LeftMarginOption =
|
||||||
new ZLIntegerRangeOption("Options", "LeftMargin", 0, 30, 4);
|
new ZLIntegerRangeOption("Options", "LeftMargin", 0, 30, 4);
|
||||||
public final ZLIntegerRangeOption RightMarginOption =
|
public final ZLIntegerRangeOption RightMarginOption =
|
||||||
|
|
|
@ -191,16 +191,26 @@ public final class FBView extends ZLTextView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myReader.DictionaryTappingActionOption.getValue() !=
|
|
||||||
FBReaderApp.DictionaryTappingAction.doNothing) {
|
|
||||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
||||||
if (region != null) {
|
boolean doSelectRegion = false;
|
||||||
|
if (region instanceof ZLTextWordRegion) {
|
||||||
|
doSelectRegion =
|
||||||
|
myReader.DictionaryTappingActionOption.getValue() !=
|
||||||
|
FBReaderApp.DictionaryTappingAction.doNothing;
|
||||||
|
} else if (region instanceof ZLTextImageRegion) {
|
||||||
|
doSelectRegion =
|
||||||
|
myReader.ImageTappingActionOption.getValue() !=
|
||||||
|
FBReaderApp.ImageTappingAction.doNothing;
|
||||||
|
} else if (region instanceof ZLTextHyperlinkRegion) {
|
||||||
|
doSelectRegion = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doSelectRegion) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
myReader.getViewWidget().reset();
|
myReader.getViewWidget().reset();
|
||||||
myReader.getViewWidget().repaint();
|
myReader.getViewWidget().repaint();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -210,15 +220,19 @@ public final class FBView extends ZLTextView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final ZLTextElementRegion selectedRegion = getSelectedRegion();
|
||||||
|
if (selectedRegion instanceof ZLTextHyperlinkRegion ||
|
||||||
|
selectedRegion instanceof ZLTextWordRegion) {
|
||||||
if (myReader.DictionaryTappingActionOption.getValue() !=
|
if (myReader.DictionaryTappingActionOption.getValue() !=
|
||||||
FBReaderApp.DictionaryTappingAction.doNothing) {
|
FBReaderApp.DictionaryTappingAction.doNothing) {
|
||||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
||||||
if (region != null) {
|
if (region instanceof ZLTextHyperlinkRegion || region instanceof ZLTextWordRegion) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
myReader.getViewWidget().reset();
|
myReader.getViewWidget().reset();
|
||||||
myReader.getViewWidget().repaint();
|
myReader.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,8 +241,19 @@ public final class FBView extends ZLTextView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myReader.DictionaryTappingActionOption.getValue() ==
|
boolean doRunAction = false;
|
||||||
FBReaderApp.DictionaryTappingAction.openDictionary) {
|
final ZLTextElementRegion region = getSelectedRegion();
|
||||||
|
if (region instanceof ZLTextWordRegion) {
|
||||||
|
doRunAction =
|
||||||
|
myReader.DictionaryTappingActionOption.getValue() ==
|
||||||
|
FBReaderApp.DictionaryTappingAction.openDictionary;
|
||||||
|
} else if (region instanceof ZLTextImageRegion) {
|
||||||
|
doRunAction =
|
||||||
|
myReader.ImageTappingActionOption.getValue() ==
|
||||||
|
FBReaderApp.ImageTappingAction.openImageView;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doRunAction) {
|
||||||
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue