...
 
Commits (3)
local.properties
.externalNativeBuild/
libs/
This diff is collapsed.
# FBReader
FBReader library based on original FBReader repo + light source code modification most makes method public.
* https://github.com/geometer/FBReaderJ
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'com.github.dcendents.android-maven' // 'gradle install' task
android {
compileSdkVersion 11
buildToolsVersion "27.0.1"
defaultConfig {
minSdkVersion 3
targetSdkVersion 3
versionCode 1
versionName "0.0.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
// http://central.sonatype.org/pages/gradle.html
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
group = "com.github.axet.fbreader"
archivesBaseName = "ambilwarna"
version = android.defaultConfig.versionName
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'Android FBReader Library'
packaging 'jar'
description 'Clone of https://code.google.com/p/android-color-picker/'
url 'https://gitlab.com/axet/android-fbreader-library'
scm {
connection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
developerConnection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
url 'https://gitlab.com/axet/android-fbreader-library'
}
licenses {
license {
name 'Apache License Version 2.0, January 2004'
url 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
developers {
developer {
id 'axet'
name 'Alexey Kuznetsov'
email 'axet@me.com'
}
}
}
}
}
}
repositories {
jcenter()
mavenLocal()
google()
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'com.github.dcendents.android-maven' // 'gradle install' task
android {
compileSdkVersion 14
buildToolsVersion "27.0.1"
defaultConfig {
minSdkVersion 4
targetSdkVersion 16
versionCode 1
versionName "0.0.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
}
}
}
// http://central.sonatype.org/pages/gradle.html
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
group = "com.github.axet.fbreader"
archivesBaseName = "androidfilechooser"
version = android.defaultConfig.versionName
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'Android FBReader Library'
packaging 'jar'
description 'FBReader base classes.'
url 'https://gitlab.com/axet/android-fbreader-library'
scm {
connection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
developerConnection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
url 'https://gitlab.com/axet/android-fbreader-library'
}
licenses {
license {
name 'GNU GENERAL PUBLIC LICENSE 3.0'
url 'https://www.gnu.org/licenses/gpl-3.0.en.html'
}
}
developers {
developer {
id 'axet'
name 'Alexey Kuznetsov'
email 'axet@me.com'
}
}
}
}
}
}
dependencies {
compile 'com.github.axet.fbreader:util:0.0.1' // compile project(':util')
}
buildscript {
repositories {
jcenter()
mavenLocal()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
repositories {
jcenter()
mavenLocal()
google()
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'com.github.dcendents.android-maven' // 'gradle install' task
android {
compileSdkVersion 21
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "0.1.0"
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
lintOptions {
disable 'WrongViewCast'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
}
// http://central.sonatype.org/pages/gradle.html
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
group = "com.github.axet.fbreader"
archivesBaseName = "library"
version = android.defaultConfig.versionName
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'Android FBReader Library'
packaging 'jar'
description 'FBReader base classes.'
url 'https://gitlab.com/axet/android-fbreader-library'
scm {
connection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
developerConnection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
url 'https://gitlab.com/axet/android-fbreader-library'
}
licenses {
license {
name 'custom open-source'
url 'https://gitlab.com/axet/android-fbreader-library/blob/master/androidFileChooser/LICENSE'
}
}
developers {
developer {
id 'axet'
name 'Alexey Kuznetsov'
email 'axet@me.com'
}
}
}
}
}
}
dependencies {
implementation 'com.android.support:support-v4:21.0.3'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.axet.fbreader:androidfilechooser:0.0.5' // compile project(':androidFileChooser')
compile 'com.github.axet.fbreader:dragsortlistview:0.0.5' // compile project(':dragSortListview')
compile 'com.github.axet.fbreader:ambilwarna:0.0.5' // compile project(':ambilWarna')
compile 'com.github.axet.fbreader:supertoasts:0.0.5' // compile project(':superToasts')
compile 'com.github.axet:pdfparse-lib:1.0'
compile('com.googlecode.json-simple:json-simple:1.1.1') {
exclude group: 'junit'
}
compile 'org.apache.httpcomponents:httpmime:4.2.5'
compile 'com.nanohttpd:nanohttpd:2.1.0'
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'com.github.dcendents.android-maven' // 'gradle install' task
android {
compileSdkVersion 14
buildToolsVersion "27.0.1"
defaultConfig {
minSdkVersion 5
targetSdkVersion 7
versionCode 1
versionName "0.0.5"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
// http://central.sonatype.org/pages/gradle.html
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
options.addStringOption('Xdoclint:none', '-quiet')
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
group = "com.github.axet.fbreader"
archivesBaseName = "dragsortlistview"
version = android.defaultConfig.versionName
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'Android FBReader Library'
packaging 'jar'
description 'Clone of https://github.com/JohnPersano/SuperToasts'
url 'https://gitlab.com/axet/android-fbreader-library'
scm {
connection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
developerConnection 'scm:git:https://gitlab.com/axet/android-fbreader-library'
url 'https://gitlab.com/axet/android-fbreader-library'
}
licenses {
license {
name 'Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
developers {
developer {
id 'axet'
name 'Alexey Kuznetsov'
email 'axet@me.com'
}
}
}
}
}
}
dependencies {
implementation 'com.android.support:support-v4:19.1.0'
}
include ':util'
include ':dragSortListview'
include ':ambilWarna'
include ':superToasts'
include ':androidFileChooser'
This diff is collapsed.
/*
* Copyright (C) 2013 Paragon Software Group
* Author: Andrey Tumanov <Andrey_Tumanov@penreader.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 com.paragon.dictionary.fbreader;
import java.io.FileOutputStream;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.WebView;
import android.widget.*;
import com.paragon.open.dictionary.api.*;
import org.geometerplus.zlibrary.core.util.MiscUtil;
import org.geometerplus.zlibrary.ui.android.R;
public class OpenDictionaryActivity extends Activity {
public final static String OPEN_DICTIONARY_QUERY_KEY = "open_dictionary_query";
public final static String OPEN_DICTIONARY_HEIGHT_KEY = "open_dictionary_height";
public final static String OPEN_DICTIONARY_GRAVITY_KEY = "open_dictionary_gravity";
private WebView myArticleView = null;
private TextView myTitleLabel = null;
private ImageButton myOpenDictionaryButton = null;
private String myQuery = null;
private int myHeight;
private int myGravity;
private static Dictionary ourDictionary = null;
static void setDictionary(Dictionary dictionary) {
ourDictionary = dictionary;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.opendictionary_flyout);
myArticleView = (WebView) findViewById(R.id.opendictionary_article_view);
myTitleLabel = (TextView) findViewById(R.id.opendictionary_title_label);
myOpenDictionaryButton = (ImageButton) findViewById(R.id.opendictionary_open_button);
myOpenDictionaryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
openTextInDictionary(myQuery);
}
});
}
@Override
protected void onResume() {
super.onResume();
myQuery = getIntent().getStringExtra(OPEN_DICTIONARY_QUERY_KEY);
if (myQuery == null)
myQuery = "";
myHeight = getIntent().getIntExtra(OPEN_DICTIONARY_HEIGHT_KEY, -1);
myGravity = getIntent().getIntExtra(OPEN_DICTIONARY_GRAVITY_KEY, android.view.Gravity.BOTTOM);
setViewSize(myHeight, myGravity);
myArticleView.loadData("", "text/text", "UTF-8");
if (ourDictionary != null) {
myTitleLabel.setText(ourDictionary.getName());
Log.d("FBReader", "OpenDictionaryActivity: get translation as text");
ourDictionary.getTranslationAsText(myQuery, TranslateMode.SHORT, TranslateFormat.HTML, new Dictionary.TranslateAsTextListener() {
@Override
public void onComplete(String s, TranslateMode translateMode) {
final String url = saveArticle(s.replace("</BODY>", "<br><br></BODY>"), getApplicationContext());
if (MiscUtil.isEmptyString(url)) {
openTextInDictionary(myQuery);
} else {
myArticleView.loadUrl(url);
}
Log.d("FBReader", "OpenDictionaryActivity: translation ready");
}
@Override
public void onWordNotFound(ArrayList<String> similarWords) {
finish();
openTextInDictionary(myQuery);
Log.d("FBReader", "OpenDictionaryActivity: word not found");
}
@Override
public void onError(com.paragon.open.dictionary.api.Error error) {
finish();
Log.e("FBReader", error.getName());
Log.e("FBReader", error.getMessage());
}
@Override
public void onIPCError(String s) {
finish();
Log.e("FBReader", s);
}
});
}
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setViewSize(myHeight, myGravity);
}
private void setViewSize(int height, int gravity) {
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (height < 0)
height = metrics.heightPixels / 3;
TableRow bottomRow = (TableRow)findViewById(R.id.bottom_row);
TableRow topRow = (TableRow)findViewById(R.id.top_row);
View.OnTouchListener touchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
finish();
return false;
}
};
topRow.setOnTouchListener(touchListener);
bottomRow.setOnTouchListener(touchListener);
switch (gravity) {
case android.view.Gravity.TOP:
topRow.setMinimumHeight(0);
bottomRow.setMinimumHeight(metrics.heightPixels - height);
break;
case android.view.Gravity.BOTTOM:
default:
bottomRow.setMinimumHeight(0);
topRow.setMinimumHeight(metrics.heightPixels - height);
break;
}
}
private void openTextInDictionary(String text) {
if (ourDictionary != null)
ourDictionary.showTranslation(text);
}
private String saveArticle(String data, Context context) {
final String filename = "open_dictionary_article.html";
final FileOutputStream outputStream;
try {
outputStream = context.openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write(data.getBytes());
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
return null;
}
return "file://" + context.getFilesDir().getAbsolutePath() + "/" + filename;
}
}
/*
* Copyright (C) 2013 Paragon Software Group
* Author: Andrey Tumanov <Andrey_Tumanov@penreader.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 com.paragon.dictionary.fbreader;
import java.util.HashSet;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.paragon.open.dictionary.api.*;
import org.geometerplus.android.fbreader.dict.DictionaryUtil;
public class OpenDictionaryFlyout {
private final Direction myDirection;
private final String myPackageName;
public OpenDictionaryFlyout(Dictionary dictionary) {
myDirection = dictionary.getDirection();
myPackageName = dictionary.getApplicationPackageName();
}
private Dictionary getDictionary(final Context context) {
if (myPackageName == null) {
return null;
}
final OpenDictionaryAPI api = new OpenDictionaryAPI(context);
HashSet<Dictionary> dictionaries = api.getDictionaries(myDirection);
for (Dictionary dictionary : dictionaries) {
if (myPackageName.equalsIgnoreCase(dictionary.getApplicationPackageName())) {
return dictionary;
}
}
Log.e("FBReader", "OpenDictionaryFlyout:getDictionary - Dictionary with direction [" +
myDirection.toString() + "] and package name [" + myPackageName + "] not found");
return null;
}
public void showTranslation(final Activity activity, final String text, DictionaryUtil.PopupFrameMetric frameMetrics) {
Log.d("FBReader", "OpenDictionaryFlyout:showTranslation");
final Dictionary dictionary = getDictionary(activity);
if (dictionary == null) {
Log.e("FBReader", "OpenDictionaryFlyout:showTranslation - null dictionary received");
return;
}
if (!dictionary.isTranslationAsTextSupported()) {
dictionary.showTranslation(text);
} else {
OpenDictionaryActivity.setDictionary(dictionary);
Intent intent = new Intent(activity, OpenDictionaryActivity.class);
intent.putExtra(OpenDictionaryActivity.OPEN_DICTIONARY_QUERY_KEY, text);
intent.putExtra(OpenDictionaryActivity.OPEN_DICTIONARY_HEIGHT_KEY, frameMetrics.Height);
intent.putExtra(OpenDictionaryActivity.OPEN_DICTIONARY_GRAVITY_KEY, frameMetrics.Gravity);
activity.startActivity(intent);
}
}
}
......@@ -35,22 +35,22 @@ import org.geometerplus.zlibrary.ui.android.R;
import org.geometerplus.fbreader.bookmodel.TOCTree;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
final class NavigationPopup extends ZLApplication.PopupPanel {
final static String ID = "NavigationPopup";
public final class NavigationPopup extends ZLApplication.PopupPanel {
public final static String ID = "NavigationPopup";
private volatile NavigationWindow myWindow;
private volatile FBReader myActivity;
private volatile Activity myActivity;
private volatile RelativeLayout myRoot;
private ZLTextWordCursor myStartPosition;
private final FBReaderApp myFBReader;
private volatile boolean myIsInProgress;
NavigationPopup(FBReaderApp fbReader) {
public NavigationPopup(FBReaderApp fbReader) {
super(fbReader);
myFBReader = fbReader;
}
public void setPanelInfo(FBReader activity, RelativeLayout root) {
public void setPanelInfo(Activity activity, RelativeLayout root) {
myActivity = activity;
myRoot = root;
}
......@@ -95,7 +95,7 @@ final class NavigationPopup extends ZLApplication.PopupPanel {
}
}
private void createPanel(FBReader activity, RelativeLayout root) {
private void createPanel(Activity activity, RelativeLayout root) {
if (myWindow != null && activity == myWindow.getContext()) {
return;
}
......
......@@ -29,11 +29,11 @@ import org.geometerplus.zlibrary.text.view.ZLTextWordCursor;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
abstract class PopupPanel extends ZLApplication.PopupPanel {
public abstract class PopupPanel extends ZLApplication.PopupPanel {
public ZLTextWordCursor StartPosition;
protected volatile SimplePopupWindow myWindow;
private volatile FBReader myActivity;
private volatile Activity myActivity;
private volatile RelativeLayout myRoot;
PopupPanel(FBReaderApp fbReader) {
......@@ -107,10 +107,10 @@ abstract class PopupPanel extends ZLApplication.PopupPanel {
}
}
public void setPanelInfo(FBReader activity, RelativeLayout root) {
public void setPanelInfo(Activity activity, RelativeLayout root) {
myActivity = activity;
myRoot = root;
}
public abstract void createControlPanel(FBReader activity, RelativeLayout root);
public abstract void createControlPanel(Activity activity, RelativeLayout root);
}
......@@ -19,6 +19,7 @@
package org.geometerplus.android.fbreader;
import android.app.Activity;
import android.view.View;
import android.widget.RelativeLayout;
......@@ -27,10 +28,10 @@ import org.geometerplus.fbreader.fbreader.ActionCode;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
import org.geometerplus.zlibrary.ui.android.R;
class SelectionPopup extends PopupPanel implements View.OnClickListener {
final static String ID = "SelectionPopup";
public class SelectionPopup extends PopupPanel implements View.OnClickListener {
public final static String ID = "SelectionPopup";
SelectionPopup(FBReaderApp fbReader) {
public SelectionPopup(FBReaderApp fbReader) {
super(fbReader);
}
......@@ -40,7 +41,7 @@ class SelectionPopup extends PopupPanel implements View.OnClickListener {
}
@Override
public void createControlPanel(FBReader activity, RelativeLayout root) {
public void createControlPanel(Activity activity, RelativeLayout root) {
if (myWindow != null && activity == myWindow.getContext()) {
return;
}
......@@ -94,23 +95,17 @@ class SelectionPopup extends PopupPanel implements View.OnClickListener {
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.selection_panel_copy:
Application.runAction(ActionCode.SELECTION_COPY_TO_CLIPBOARD);
break;
case R.id.selection_panel_share:
Application.runAction(ActionCode.SELECTION_SHARE);
break;
case R.id.selection_panel_translate:
Application.runAction(ActionCode.SELECTION_TRANSLATE);
break;
case R.id.selection_panel_bookmark:
Application.runAction(ActionCode.SELECTION_BOOKMARK);
break;
case R.id.selection_panel_close:
Application.runAction(ActionCode.SELECTION_CLEAR);
break;
}
int id = view.getId();
if (id == R.id.selection_panel_copy)
Application.runAction(ActionCode.SELECTION_COPY_TO_CLIPBOARD);
if (id == R.id.selection_panel_share)
Application.runAction(ActionCode.SELECTION_SHARE);
if (id == R.id.selection_panel_translate)
Application.runAction(ActionCode.SELECTION_TRANSLATE);
if (id == R.id.selection_panel_bookmark)
Application.runAction(ActionCode.SELECTION_BOOKMARK);
if (id == R.id.selection_panel_close)
Application.runAction(ActionCode.SELECTION_CLEAR);
Application.hideActivePopup();
}
}
......@@ -19,6 +19,7 @@
package org.geometerplus.android.fbreader;
import android.app.Activity;
import android.view.View;
import android.widget.RelativeLayout;
......@@ -28,10 +29,10 @@ import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.fbreader.fbreader.ActionCode;
import org.geometerplus.fbreader.fbreader.FBReaderApp;
final class TextSearchPopup extends PopupPanel implements View.OnClickListener {
final static String ID = "TextSearchPopup";
public final class TextSearchPopup extends PopupPanel implements View.OnClickListener {
public final static String ID = "TextSearchPopup";
TextSearchPopup(FBReaderApp fbReader) {
public TextSearchPopup(FBReaderApp fbReader) {
super(fbReader);
}
......@@ -47,7 +48,7 @@ final class TextSearchPopup extends PopupPanel implements View.OnClickListener {
}
@Override
public synchronized void createControlPanel(FBReader activity, RelativeLayout root) {
public synchronized void createControlPanel(Activity activity, RelativeLayout root) {
if (myWindow != null && activity == myWindow.getContext()) {
return;
}
......@@ -82,18 +83,16 @@ final class TextSearchPopup extends PopupPanel implements View.OnClickListener {
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.search_panel_previous:
Application.runAction(ActionCode.FIND_PREVIOUS);
break;
case R.id.search_panel_next:
Application.runAction(ActionCode.FIND_NEXT);
break;
case R.id.search_panel_close:
Application.runAction(ActionCode.CLEAR_FIND_RESULTS);
storePosition();
StartPosition = null;
Application.hideActivePopup();
int id = view.getId();
if (id == R.id.search_panel_previous)
Application.runAction(ActionCode.FIND_PREVIOUS);
if (id == R.id.search_panel_next)
Application.runAction(ActionCode.FIND_NEXT);
if (id == R.id.search_panel_close) {
Application.runAction(ActionCode.CLEAR_FIND_RESULTS);
storePosition();
StartPosition = null;
Application.hideActivePopup();
}
}
}
......@@ -19,9 +19,11 @@
package org.geometerplus.android.fbreader.dict;
import android.app.Activity;
import android.content.Intent;
import org.geometerplus.android.fbreader.FBReaderMainActivity;
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidApplication;
final class ColorDict extends DictionaryUtil.PackageInfo {
private interface ColorDict3 {
......@@ -42,11 +44,11 @@ final class ColorDict extends DictionaryUtil.PackageInfo {
}
@Override
void open(String text, Runnable outliner, FBReaderMainActivity fbreader, DictionaryUtil.PopupFrameMetric frameMetrics) {
void open(String text, Runnable outliner, Activity fbreader, DictionaryUtil.PopupFrameMetric frameMetrics) {
final Intent intent = getActionIntent(text);
intent.putExtra(ColorDict3.HEIGHT, frameMetrics.Height);
intent.putExtra(ColorDict3.GRAVITY, frameMetrics.Gravity);
intent.putExtra(ColorDict3.FULLSCREEN, !fbreader.getZLibrary().ShowStatusBarOption.getValue());
intent.putExtra(ColorDict3.FULLSCREEN, !((ZLAndroidApplication)fbreader.getApplication()).library().ShowStatusBarOption.getValue());
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
InternalUtil.startDictionaryActivity(fbreader, intent, this);
......
......@@ -23,6 +23,7 @@ import com.github.johnpersano.supertoasts.SuperActivityToast;
import com.github.johnpersano.supertoasts.SuperToast;
import com.github.johnpersano.supertoasts.util.OnClickWrapper;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Parcelable;
......@@ -40,7 +41,7 @@ final class Dictan extends DictionaryUtil.PackageInfo {
}
@Override
void open(String text, Runnable outliner, FBReaderMainActivity fbreader, DictionaryUtil.PopupFrameMetric frameMetrics) {
void open(String text, Runnable outliner, Activity fbreader, DictionaryUtil.PopupFrameMetric frameMetrics) {
final Intent intent = getActionIntent(text);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
......
......@@ -113,7 +113,7 @@ public abstract class DictionaryUtil {
// does nothing; implement in subclasses
}
abstract void open(String text, Runnable outliner, FBReaderMainActivity fbreader, PopupFrameMetric frameMetrics);
abstract void open(String text, Runnable outliner, Activity fbreader, PopupFrameMetric frameMetrics);
}
private static class PlainPackageInfo extends PackageInfo {
......@@ -122,7 +122,7 @@ public abstract class DictionaryUtil {
}
@Override
void open(String text, Runnable outliner, FBReaderMainActivity fbreader, PopupFrameMetric frameMetrics) {
void open(String text, Runnable outliner, Activity fbreader, PopupFrameMetric frameMetrics) {
final Intent intent = getActionIntent(text);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
......@@ -154,8 +154,6 @@ public abstract class DictionaryUtil {
final PackageInfo info;
if ("dictan".equals(id)) {
info = new Dictan(id, title);
} else if ("ABBYY Lingvo".equals(id)) {
info = new Lingvo(id, title);
} else if ("ColorDict".equals(id)) {
info = new ColorDict(id, title);
} else {
......@@ -225,7 +223,6 @@ public abstract class DictionaryUtil {
);
myActivity.runOnUiThread(new Runnable() {
public void run() {
OpenDictionary.collect(myActivity, ourInfos);
if (myPostAction != null) {
myPostAction.run();
}
......@@ -344,7 +341,7 @@ public abstract class DictionaryUtil {
}
}
public static void openTextInDictionary(final FBReaderMainActivity fbreader, String text, boolean singleWord, int selectionTop, int selectionBottom, final Runnable outliner) {
public static void openTextInDictionary(final Activity fbreader, String text, boolean singleWord, int selectionTop, int selectionBottom, final Runnable outliner) {
final String textToTranslate;
if (singleWord) {
int start = 0;
......
......@@ -45,7 +45,7 @@ abstract class InternalUtil {
activity.startActivity(intent);
}
static void startDictionaryActivity(FBReaderMainActivity fbreader, Intent intent, DictionaryUtil.PackageInfo info) {
static void startDictionaryActivity(Activity fbreader, Intent intent, DictionaryUtil.PackageInfo info) {
try {
fbreader.startActivity(intent);
fbreader.overridePendingTransition(0, 0);
......
/*
* Copyright (C) 2010-2015 FBReader.ORG Limited <contact@fbreader.org>
*
* 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.dict;
import android.content.Intent;
import com.abbyy.mobile.lingvo.api.MinicardContract;
import org.geometerplus.zlibrary.core.language.Language;
import org.geometerplus.android.fbreader.FBReaderMainActivity;
final class Lingvo extends DictionaryUtil.PackageInfo {
Lingvo(String id, String title) {
super(id, title, true);
}
@Override
void open(String text, Runnable outliner, FBReaderMainActivity fbreader, DictionaryUtil.PopupFrameMetric frameMetrics) {
final Intent intent = getActionIntent(text);
intent.putExtra(MinicardContract.EXTRA_GRAVITY, frameMetrics.Gravity);
intent.putExtra(MinicardContract.EXTRA_HEIGHT, frameMetrics.Height);
intent.putExtra(MinicardContract.EXTRA_FORCE_LEMMATIZATION, true);
intent.putExtra(MinicardContract.EXTRA_TRANSLATE_VARIANTS, true);
intent.putExtra(MinicardContract.EXTRA_LIGHT_THEME, true);
final String targetLanguage = DictionaryUtil.TargetLanguageOption.getValue();
if (!Language.ANY_CODE.equals(targetLanguage)) {
intent.putExtra(MinicardContract.EXTRA_LANGUAGE_TO, targetLanguage);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
InternalUtil.startDictionaryActivity(fbreader, intent, this);
}
}
/*
* Copyright (C) 2010-2015 FBReader.ORG Limited <contact@fbreader.org>
*
* 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.dict;
import java.util.*;
import android.content.Context;
import com.paragon.dictionary.fbreader.OpenDictionaryFlyout;
import com.paragon.open.dictionary.api.Dictionary;
import com.paragon.open.dictionary.api.OpenDictionaryAPI;
import org.geometerplus.android.fbreader.FBReaderMainActivity;
final class OpenDictionary extends DictionaryUtil.PackageInfo {
static void collect(Context context, Map<DictionaryUtil.PackageInfo,Integer> dictMap) {
final SortedSet<Dictionary> dictionariesTreeSet =
new TreeSet<Dictionary>(new Comparator<Dictionary>() {
@Override
public int compare(Dictionary lhs, Dictionary rhs) {
return lhs.toString().compareTo(rhs.toString());
}
}
);
dictionariesTreeSet.addAll(
new OpenDictionaryAPI(context).getDictionaries()
);
for (Dictionary dict : dictionariesTreeSet) {
dictMap.put(new OpenDictionary(dict), DictionaryUtil.FLAG_SHOW_AS_DICTIONARY);
}
}
final OpenDictionaryFlyout Flyout;
OpenDictionary(Dictionary dictionary) {
super(dictionary.getUID(), dictionary.getName());
put("package", dictionary.getApplicationPackageName());
put("class", ".Start");
Flyout = new OpenDictionaryFlyout(dictionary);
}
@Override
void open(String text, Runnable outliner, FBReaderMainActivity fbreader, DictionaryUtil.PopupFrameMetric frameMetrics) {
Flyout.showTranslation(fbreader, text, frameMetrics);
}
}
......@@ -57,8 +57,8 @@ import org.geometerplus.android.fbreader.util.AndroidImageSynchronizer;
import org.geometerplus.android.util.*;
public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.ChangeListener {
private NetworkBookTree myTree;
private NetworkBookItem myBook;
public NetworkBookTree myTree;
public NetworkBookItem myBook;
private final ZLResource myResource = ZLResource.resource("bookInfo");
private final BookCollectionShadow myBookCollection = new BookCollectionShadow();
......@@ -194,7 +194,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
super.onDestroy();
}
private final void setupDescription() {
public final void setupDescription() {
setTextFromResource(R.id.network_book_description_title, "description");
CharSequence description = myBook.getSummary();
......@@ -209,7 +209,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
);
}
private final void setupExtraLinks() {
public final void setupExtraLinks() {
final List<UrlInfo> extraLinks = myBook.getAllInfos(UrlInfo.Type.Related);
if (extraLinks.isEmpty()) {
findViewById(R.id.network_book_extra_links_title).setVisibility(View.GONE);
......@@ -245,22 +245,22 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
}
}
private void setPairLabelTextFromResource(int id, String resourceKey) {
public void setPairLabelTextFromResource(int id, String resourceKey) {
((TextView)findViewById(id).findViewById(R.id.book_info_key))
.setText(myResource.getResource(resourceKey).getValue());
}
private void setPairLabelTextFromResource(int id, String resourceKey, int param) {
public void setPairLabelTextFromResource(int id, String resourceKey, int param) {
((TextView)findViewById(id).findViewById(R.id.book_info_key))
.setText(myResource.getResource(resourceKey).getValue(param));
}
private void setPairValueText(int id, CharSequence text) {
public void setPairValueText(int id, CharSequence text) {
final LinearLayout layout = (LinearLayout)findViewById(id);
((TextView)layout.findViewById(R.id.book_info_value)).setText(text);
}
private void setupInfo() {
public void setupInfo() {
setTextFromResource(R.id.network_book_info_title, "bookInfo");
setPairLabelTextFromResource(R.id.network_book_title, "title");
......@@ -325,7 +325,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
setPairValueText(R.id.network_book_catalog, myBook.Link.getTitle());
}
private final void setupCover() {
public final void setupCover() {
final View rootView = findViewById(R.id.network_book_root);
final ImageView coverView = (ImageView)findViewById(R.id.network_book_cover);
......@@ -373,7 +373,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
}
}
private final void setupButtons() {
public final void setupButtons() {
final int buttons[] = new int[] {
R.id.network_book_button0,
R.id.network_book_button1,
......
......@@ -61,7 +61,7 @@ public abstract class Util implements UserRegistrationConstants {
return NetworkLibrary.Instance(Paths.systemInfo(context));
}
static void initLibrary(final Activity activity, final ZLNetworkContext nc, final Runnable action) {
public static void initLibrary(final Activity activity, final ZLNetworkContext nc, final Runnable action) {
Config.Instance().runOnConnect(new Runnable() {
public void run() {
UIUtil.wait("loadingNetworkLibrary", new Runnable() {
......
......@@ -39,7 +39,7 @@ import org.geometerplus.fbreader.formats.*;
import org.geometerplus.fbreader.network.sync.SyncData;
import org.geometerplus.fbreader.util.*;
public final class FBReaderApp extends ZLApplication {
public class FBReaderApp extends ZLApplication {
public interface ExternalFileOpener {
public void openFile(ExternalFormatPlugin plugin, Book book, Bookmark bookmark);
}
......@@ -62,8 +62,8 @@ public final class FBReaderApp extends ZLApplication {
private final ZLKeyBindings myBindings = new ZLKeyBindings();
public final FBView BookTextView;
public final FBView FootnoteView;
public FBView BookTextView;
public FBView FootnoteView;
private String myFootnoteModelId;
public volatile BookModel Model;
......
......@@ -40,12 +40,12 @@ import org.geometerplus.fbreader.fbreader.options.*;
import org.geometerplus.fbreader.util.FixedTextSnippet;
import org.geometerplus.fbreader.util.TextSnippet;
public final class FBView extends ZLTextView {
public class FBView extends ZLTextView {
private final FBReaderApp myReader;
private final ViewOptions myViewOptions;
private final BookElementManager myBookElementManager;
FBView(FBReaderApp reader) {
public FBView(FBReaderApp reader) {
super(reader);
myReader = reader;
myViewOptions = reader.ViewOptions;
......@@ -445,7 +445,7 @@ public final class FBView extends ZLTextView {
return myViewOptions.getColorProfile().HighlightingForegroundOption.getValue();
}
private abstract class Footer implements FooterArea {
public abstract class Footer implements FooterArea {
private Runnable UpdateTask = new Runnable() {
public void run() {
myReader.getViewWidget().repaint();
......@@ -563,7 +563,7 @@ public final class FBView extends ZLTextView {
}
}
private class FooterOldStyle extends Footer {
public class FooterOldStyle extends Footer {
public synchronized void paint(ZLPaintContext context) {
final ZLFile wallpaper = getWallpaperFile();
if (wallpaper != null) {
......@@ -631,7 +631,7 @@ public final class FBView extends ZLTextView {
}
}
private class FooterNewStyle extends Footer {
public class FooterNewStyle extends Footer {
public synchronized void paint(ZLPaintContext context) {
final ColorProfile cProfile = myViewOptions.getColorProfile();
context.clear(cProfile.FooterNGBackgroundOption.getValue());
......@@ -696,7 +696,7 @@ public final class FBView extends ZLTextView {
}
}
private Footer myFooter;
public Footer myFooter;
@Override
public Footer getFooterArea() {
......
......@@ -22,7 +22,7 @@ package org.geometerplus.fbreader.fbreader.options;
import org.geometerplus.zlibrary.core.options.*;
public class FooterOptions {
enum ProgressDisplayType {
public enum ProgressDisplayType {
dontDisplay,
asPages,
asPercentage,
......
......@@ -23,7 +23,7 @@ import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.fbreader.fbreader.DurationEnum;
public class MiscOptions {
public final ZLBooleanOption AllowScreenBrightnessAdjustment;
public ZLBooleanOption AllowScreenBrightnessAdjustment;
public final ZLStringOption TextSearchPattern;
public final ZLBooleanOption EnableDoubleTap;
......
......@@ -32,7 +32,7 @@ public class ViewOptions {
public final ZLIntegerRangeOption TopMargin;
public final ZLIntegerRangeOption BottomMargin;
public final ZLIntegerRangeOption SpaceBetweenColumns;
public final ZLIntegerRangeOption ScrollbarType;
public ZLIntegerRangeOption ScrollbarType;
public final ZLIntegerRangeOption FooterHeight;
public final ZLStringOption ColorProfileName;
......
......@@ -24,7 +24,7 @@ import java.util.regex.Pattern;
import org.geometerplus.zlibrary.core.util.MimeType;
class OpenSearchDescription {
public class OpenSearchDescription {
public static OpenSearchDescription createDefault(String tmpl, MimeType mime) {
return new OpenSearchDescription(tmpl, -1, -1, mime);
}
......@@ -36,7 +36,7 @@ class OpenSearchDescription {
public final int ItemsPerPage = 20;
OpenSearchDescription(String tmpl, int indexOffset, int pageOffset, MimeType mime) {
public OpenSearchDescription(String tmpl, int indexOffset, int pageOffset, MimeType mime) {
Template = tmpl;
IndexOffset = indexOffset;
PageOffset = pageOffset;
......
......@@ -25,11 +25,11 @@ import org.geometerplus.zlibrary.core.network.ZLNetworkException;
import org.geometerplus.fbreader.network.*;
import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;
class CatalogExpander extends NetworkItemsLoader {
public class CatalogExpander extends NetworkItemsLoader {
private final boolean myAuthenticate;
private final boolean myResumeNotLoad;
CatalogExpander(ZLNetworkContext nc, NetworkCatalogTree tree, boolean authenticate, boolean resumeNotLoad) {
public CatalogExpander(ZLNetworkContext nc, NetworkCatalogTree tree, boolean authenticate, boolean resumeNotLoad) {
super(nc, tree);
myAuthenticate = authenticate;
myResumeNotLoad = resumeNotLoad;
......
......@@ -48,7 +48,7 @@ public abstract class ZLApplication {
ourInstance = this;
}
protected final void setView(ZLView view) {
public final void setView(ZLView view) {
if (view != null) {
myView = view;
final ZLViewWidget widget = getViewWidget();
......
......@@ -43,7 +43,7 @@ public abstract class Config {
Collections.synchronizedMap(new HashMap<StringPair,String>());
private final Set<String> myCachedGroups = new HashSet<String>();
public final String getValue(StringPair id, String defaultValue) {
public String getValue(StringPair id, String defaultValue) {
String value = myCache.get(id);
if (value == null) {
if (myCachedGroups.contains(id.Group)) {
......@@ -63,7 +63,7 @@ public abstract class Config {
return value != myNullString ? value : defaultValue;
}
public final void setValue(StringPair id, String value) {
public void setValue(StringPair id, String value) {
final String oldValue = myCache.get(id);
if (oldValue != null && oldValue.equals(value)) {
return;
......
......@@ -19,9 +19,9 @@
package org.geometerplus.zlibrary.core.options;
final class StringPair {
final String Group;
final String Name;
public class StringPair {
public final String Group;
public final String Name;
StringPair(String group, String name) {
Group = group.intern();
......
......@@ -20,10 +20,17 @@
package org.geometerplus.zlibrary.core.options;
public abstract class ZLOption {
private final StringPair myId;
public final StringPair myId;
protected String myDefaultStringValue;
protected String mySpecialName;
public static class ConfigInstance {
public Config Instance() {
return org.geometerplus.zlibrary.core.options.Config.Instance();
}
}
public ConfigInstance Config = new ConfigInstance();
protected ZLOption(String group, String optionName, String defaultStringValue) {
myId = new StringPair(group, optionName);
myDefaultStringValue = defaultStringValue != null ? defaultStringValue : "";
......
......@@ -29,7 +29,7 @@ public final class ZLImageEntry {
public final short VOffset;
public final boolean IsCover;
ZLImageEntry(Map<String,ZLImage> imageMap, String id, short vOffset, boolean isCover) {
public ZLImageEntry(Map<String,ZLImage> imageMap, String id, short vOffset, boolean isCover) {
myImageMap = imageMap;
Id = id;
VOffset = vOffset;
......
......@@ -21,7 +21,7 @@ package org.geometerplus.zlibrary.text.view;
import java.util.*;
final class ZLTextElementAreaVector {
public class ZLTextElementAreaVector {
private final List<ZLTextElementArea> myAreas =
Collections.synchronizedList(new ArrayList<ZLTextElementArea>());
private final List<ZLTextRegion> myElementRegions = new ArrayList<ZLTextRegion>();
......@@ -280,4 +280,39 @@ final class ZLTextElementAreaVector {
}
return null;
}
public boolean swapRtl(boolean rtlMode, int first, int end) {
boolean detected = false;
for (int i = first; i < end; i++) {
ZLTextElementArea e = myAreas.get(i);
if (e.Element instanceof ZLTextWord) {
boolean b = ZLTextView.isRtl(rtlMode, e.Element.toString());
if (rtlMode != b) {
int rangeStart = i;
int rangeEnd = i;
while (rangeEnd < end && b == ZLTextView.isRtl(rtlMode, myAreas.get(rangeEnd).Element.toString()))
rangeEnd++;
int rangeLast = rangeEnd - 1;
e = myAreas.get(rtlMode ? rangeLast : rangeStart);
int XStart = e.XStart;
ZLTextElementArea prev = null;
for (int k = rtlMode ? rangeStart : rangeLast; rtlMode ? k <= rangeLast : k >= rangeStart; k += rtlMode ? 1 : -1) {
e = myAreas.get(k);
if (prev != null) {
detected = true;
XStart += prev.XStart - e.XEnd;
}
prev = e;