Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update libraries and code according to 06.2022 #517

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -10,7 +10,7 @@ buildscript {

dependencies {
classpath "com.android.tools.build:gradle:$versions.androidGradlePlugin"

classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

Expand Down
30 changes: 0 additions & 30 deletions config/quality/quality.gradle
Expand Up @@ -11,7 +11,6 @@
*/

apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'

dependencies {
Expand All @@ -38,35 +37,6 @@ task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code
classpath = files()
}

task findbugs(type: FindBugs,
group: 'Verification',
description: 'Inspect java bytecode for bugs',
dependsOn: ['compileDebugSources', 'compileReleaseSources']) {

ignoreFailures = false
effort = "max"
reportLevel = "high"
excludeFilter = new File("$qualityConfigDir/findbugs/android-exclude-filter.xml")
classes = files("$project.rootDir/folioreader/build/intermediates/javac")

source 'src'
include '**/*.java'
exclude '**/gen/**'

reports {
xml.enabled = false
html.enabled = true
xml {
destination = file("$reportsDir/findbugs/findbugs.xml")
}
html {
destination = file("$reportsDir/findbugs/findbugs.html")
}
}

classpath = files()
}


task pmd(type: Pmd, group: 'Verification', description: 'Inspect sourcecode for bugs') {
ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml")
Expand Down
1 change: 1 addition & 0 deletions folioreader/AndroidManifest.xml
Expand Up @@ -28,6 +28,7 @@
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:exported="true"
android:name="com.folioreader.ui.activity.SearchActivity"
android:launchMode="singleTop">
<intent-filter>
Expand Down
42 changes: 0 additions & 42 deletions folioreader/bintray/installv1.gradle

This file was deleted.

4 changes: 1 addition & 3 deletions folioreader/build.gradle
@@ -1,6 +1,5 @@
apply plugin: 'com.android.library'
apply from: '../config/quality/quality.gradle'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Expand Down Expand Up @@ -76,15 +75,14 @@ android {
}
}

apply from: '../folioreader/bintray/installv1.gradle'
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation "androidx.appcompat:appcompat:$versions.appcompat"
implementation "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
implementation "androidx.recyclerview:recyclerview:$versions.recyclerview"
implementation "com.google.android.material:material:$versions.material"
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.1'

implementation 'org.slf4j:slf4j-android:1.7.25'
implementation 'com.daimajia.swipelayout:library:1.2.0@aar'
Expand Down
2 changes: 1 addition & 1 deletion folioreader/res/layout/progress_dialog.xml
Expand Up @@ -14,7 +14,7 @@
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/android:progressBarStyle" />
style="?android:attr/progressBarStyle" />

<TextView
android:id="@+id/label_loading"
Expand Down
12 changes: 11 additions & 1 deletion folioreader/src/main/assets/css/Style.css
Expand Up @@ -297,9 +297,19 @@ body {
-webkit-hyphens: auto !important;
hyphens: auto !important;
}
p, span, div {
p.press_image {
margin-right: 1em;
}

p {
line-height: 1.5 !important;
margin-right: 0.3em;
}

span, div {
line-height: 1.5 !important;
}

@media only screen and (min-device-width: 600px) {
div {
font-size: 1rem;
Expand Down
Expand Up @@ -6,13 +6,18 @@
import android.os.Build;
import android.os.Handler;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.folioreader.Constants;
import com.folioreader.model.event.MediaOverlayPlayPauseEvent;
import com.folioreader.model.event.MediaOverlaySpeedEvent;
import com.folioreader.model.media_overlay.OverlayItems;
import com.folioreader.util.UiUtil;

import org.readium.r2.shared.Clip;
import org.readium.r2.shared.MediaOverlays;

Expand Down Expand Up @@ -54,7 +59,9 @@ public enum MediaType {
//*********************************//
// TTS //
//*********************************//
@Nullable
private TextToSpeech mTextToSpeech;

private boolean mIsSpeaking = false;

public MediaController(Context context, MediaType mediaType, MediaControllerCallbacks callbacks) {
Expand Down Expand Up @@ -101,27 +108,32 @@ public void next() {
}

public void setTextToSpeech(final Context context) {
mTextToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status != TextToSpeech.ERROR) {
mTextToSpeech.setLanguage(Locale.UK);
mTextToSpeech.setSpeechRate(0.70f);
}
mTextToSpeech = new TextToSpeech(context, status -> {
if (status != TextToSpeech.ERROR && mTextToSpeech!=null) {
mTextToSpeech.setLanguage(Locale.UK);
mTextToSpeech.setSpeechRate(0.70f);
}
if(mTextToSpeech!=null){
mTextToSpeech.setOnUtteranceProgressListener(
new UtteranceProgressListener() {
@Override
public void onStart(String utteranceId) {

}

mTextToSpeech.setOnUtteranceCompletedListener(
new TextToSpeech.OnUtteranceCompletedListener() {
@Override
public void onUtteranceCompleted(String utteranceId) {
((AppCompatActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
if (mIsSpeaking) {
callbacks.highLightTTS();
}
public void onDone(String utteranceId) {
((AppCompatActivity) context).runOnUiThread(() -> {
if (mIsSpeaking) {
callbacks.highLightTTS();
}
});
}

@Override
public void onError(String utteranceId) {

}
});
}
});
Expand Down
Expand Up @@ -785,6 +785,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)

if (requestCode == RequestCode.SEARCH.value) {
Log.v(LOG_TAG, "-> onActivityResult -> " + RequestCode.SEARCH)
Expand Down Expand Up @@ -815,11 +816,11 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
val type = data.getStringExtra(TYPE)

if (type == CHAPTER_SELECTED) {
goToChapter(data.getStringExtra(SELECTED_CHAPTER_POSITION))
goToChapter(data.getStringExtra(SELECTED_CHAPTER_POSITION)!!)

} else if (type == HIGHLIGHT_SELECTED) {
val highlightImpl = data.getParcelableExtra<HighlightImpl>(HIGHLIGHT_ITEM)
currentChapterIndex = highlightImpl.pageNumber
currentChapterIndex = highlightImpl!!.pageNumber
mFolioPageViewPager!!.currentItem = currentChapterIndex
val folioPageFragment = currentFragment ?: return
folioPageFragment.scrollToHighlightId(highlightImpl.rangy)
Expand Down
Expand Up @@ -127,7 +127,7 @@ class SearchActivity : AppCompatActivity(), OnItemClickListener {
}

spineSize = intent.getIntExtra(BUNDLE_SPINE_SIZE, 0)
searchUri = intent.getParcelableExtra(BUNDLE_SEARCH_URI)
searchUri = intent.getParcelableExtra(BUNDLE_SEARCH_URI)!!

searchAdapter = SearchAdapter(this)
searchAdapter.onItemClickListener = this
Expand Down Expand Up @@ -155,10 +155,11 @@ class SearchActivity : AppCompatActivity(), OnItemClickListener {
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
Log.v(LOG_TAG, "-> onNewIntent")

if (intent.hasExtra(BUNDLE_SEARCH_URI)) {
searchUri = intent.getParcelableExtra(BUNDLE_SEARCH_URI)
searchUri = intent.getParcelableExtra(BUNDLE_SEARCH_URI)!!
} else {
intent.putExtra(BUNDLE_SEARCH_URI, searchUri)
intent.putExtra(BUNDLE_SPINE_SIZE, spineSize)
Expand All @@ -173,7 +174,7 @@ class SearchActivity : AppCompatActivity(), OnItemClickListener {
private fun handleSearch() {
Log.v(LOG_TAG, "-> handleSearch")

val query: String = intent.getStringExtra(SearchManager.QUERY)
val query: String = intent.getStringExtra(SearchManager.QUERY)!!
val newDataBundle = Bundle()
newDataBundle.putString(ListViewType.KEY, ListViewType.PAGINATION_IN_PROGRESS_VIEW.toString())
newDataBundle.putParcelableArrayList("DATA", ArrayList<SearchLocator>())
Expand Down Expand Up @@ -288,9 +289,9 @@ class SearchActivity : AppCompatActivity(), OnItemClickListener {
return true
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
override fun onOptionsItemSelected(item: MenuItem): Boolean {

val itemId = item?.itemId
val itemId = item.itemId

if (itemId == R.id.itemSearch) {
Log.v(LOG_TAG, "-> onOptionsItemSelected -> ${item.title}")
Expand Down
Expand Up @@ -375,9 +375,9 @@ class FolioPageFragment : Fragment(),

mWebview!!.addJavascriptInterface(this, "Highlight")
mWebview!!.addJavascriptInterface(this, "FolioPageFragment")
mWebview!!.addJavascriptInterface(webViewPager, "WebViewPager")
mWebview!!.addJavascriptInterface(loadingView, "LoadingView")
mWebview!!.addJavascriptInterface(mWebview, "FolioWebView")
mWebview!!.addJavascriptInterface(webViewPager!!, "WebViewPager")
mWebview!!.addJavascriptInterface(loadingView!!, "LoadingView")
mWebview!!.addJavascriptInterface(mWebview!!, "FolioWebView")

mWebview!!.setScrollListener(object : FolioWebView.ScrollListener {
override fun onScrollChange(percent: Int) {
Expand Down Expand Up @@ -428,7 +428,7 @@ class FolioPageFragment : Fragment(),
mWebview!!.loadUrl(callHighlightSearchLocator)

} else if (isCurrentFragment) {
val cfi = lastReadLocator!!.locations.cfi
val cfi = lastReadLocator?.locations?.cfi
mWebview!!.loadUrl(String.format(getString(R.string.callScrollToCfi), cfi))

} else {
Expand Down
Expand Up @@ -17,8 +17,8 @@ class FolioAppBarLayout : AppBarLayout {
var navigationBarHeight: Int = 0
var insets: Rect? = null

constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {

ViewCompat.setOnApplyWindowInsetsListener(this) { _, insets ->
Log.v(LOG_TAG, "-> onApplyWindowInsets")
Expand Down
Expand Up @@ -25,9 +25,9 @@ class FolioSearchView : SearchView {

private lateinit var searchAutoComplete: SearchView.SearchAutoComplete

constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)

fun init(componentName: ComponentName, config: Config) {
Log.v(LOG_TAG, "-> init")
Expand Down