From 4bab383aa9ee5e20f570367a39fd4e37ce7deb65 Mon Sep 17 00:00:00 2001 From: Emmanouil Nicolas Date: Wed, 24 Jun 2020 19:47:24 -0300 Subject: [PATCH 1/3] Updated gradle & kotlin --- build.gradle | 9 ++++++- config/quality/quality.gradle | 31 +++++++++++----------- folioreader/res/layout/progress_dialog.xml | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +-- sample/build.gradle | 7 ----- versions.gradle | 4 +-- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/build.gradle b/build.gradle index 143e57b76..ba432242b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,4 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { apply from: 'versions.gradle' @@ -20,6 +19,14 @@ buildscript { } } +plugins { + id "com.github.spotbugs" version "2.0.0" apply(false) +} + +// Workaround to be able to access SpotBugsTask from external gradle script. +// More info: https://discuss.gradle.org/t/buildscript-dependencies-in-external-script/23243 +project.extensions.extraProperties.set('SpotBugsTask', com.github.spotbugs.SpotBugsTask) + allprojects { configurations.all { diff --git a/config/quality/quality.gradle b/config/quality/quality.gradle index f7f6f45ec..f76738cbd 100755 --- a/config/quality/quality.gradle +++ b/config/quality/quality.gradle @@ -3,7 +3,7 @@ * * Gradle tasks added: * - checkstyle - * - findbugs + * - spotbugs * - pmd * * The three tasks above are added as dependencies of the check task so running check will @@ -11,7 +11,7 @@ */ apply plugin: 'checkstyle' -apply plugin: 'findbugs' +apply plugin: 'com.github.spotbugs' apply plugin: 'pmd' dependencies { @@ -21,7 +21,7 @@ dependencies { def qualityConfigDir = "$project.rootDir/config/quality" def reportsDir = "$project.buildDir/reports" -check.dependsOn 'checkstyle', 'findbugs', 'pmd' +check.dependsOn 'checkstyle', 'spotbugs', 'pmd' task checkstyle(type: Checkstyle, group: 'Verification', description: 'Runs code style checks') { configFile file("$qualityConfigDir/checkstyle/checkstyle-config.xml") @@ -38,36 +38,37 @@ 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']) { - +spotbugs { ignoreFailures = false effort = "max" reportLevel = "high" - excludeFilter = new File("$qualityConfigDir/findbugs/android-exclude-filter.xml") + + includeFilter = file("**/*.java") + excludeFilter = file("**/gen/**") +} + +tasks.withType(SpotBugsTask) { + dependsOn 'assemble' + group = "verification" + excludeFilter = new File("$qualityConfigDir/spotbugs/android-exclude-filter.xml") classes = files("$project.rootDir/folioreader/build/intermediates/javac") - source 'src' - include '**/*.java' - exclude '**/gen/**' + source = fileTree('src') reports { xml.enabled = false html.enabled = true xml { - destination = file("$reportsDir/findbugs/findbugs.xml") + destination = file("$reportsDir/spotbugs/spotbugs.xml") } html { - destination = file("$reportsDir/findbugs/findbugs.html") + destination = file("$reportsDir/spotbugs/spotbugs.html") } } classpath = files() } - task pmd(type: Pmd, group: 'Verification', description: 'Inspect sourcecode for bugs') { ruleSetFiles = files("$qualityConfigDir/pmd/pmd-ruleset.xml") ignoreFailures = false diff --git a/folioreader/res/layout/progress_dialog.xml b/folioreader/res/layout/progress_dialog.xml index 0d823fe0e..7f7d5ee62 100644 --- a/folioreader/res/layout/progress_dialog.xml +++ b/folioreader/res/layout/progress_dialog.xml @@ -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" /> - config.resolutionStrategy.eachDependency { details -> - details.useVersion("3.3.2-5309881") - } - } - } diff --git a/versions.gradle b/versions.gradle index ec456b157..bf833f022 100644 --- a/versions.gradle +++ b/versions.gradle @@ -11,8 +11,8 @@ versions.androidMinSdk = 21 versions.androidCompileSdk = 28 versions.androidTargetSdk = 28 -versions.androidGradlePlugin = "3.5.3" -versions.kotlin = "1.3.11" +versions.androidGradlePlugin = '4.0.0' +versions.kotlin = "1.3.72" versions.appcompat = "1.1.0" versions.constraintLayout = "1.1.3" From 9a1f584ad4a24878ccaaa79bdc2d468cd6657987 Mon Sep 17 00:00:00 2001 From: Emmanouil Nicolas Date: Fri, 3 Jul 2020 14:50:29 -0300 Subject: [PATCH 2/3] Fix: appBarLayout not hiding --- folioreader/res/layout/folio_activity.xml | 1 + .../folioreader/ui/activity/FolioActivity.kt | 52 ++++++------------- 2 files changed, 17 insertions(+), 36 deletions(-) diff --git a/folioreader/res/layout/folio_activity.xml b/folioreader/res/layout/folio_activity.xml index b4a01b5ee..39381dd3b 100644 --- a/folioreader/res/layout/folio_activity.xml +++ b/folioreader/res/layout/folio_activity.xml @@ -25,6 +25,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> + android:animateLayoutChanges="true"> distractionFreeMode = $distractionFreeMode") - if (actionBar != null) { - if (distractionFreeMode) { - actionBar!!.hide() - } else { - actionBar!!.show() - } + if (distractionFreeMode) { + appBarLayout?.visibility = View.GONE + actionBar?.hide() + } else { + appBarLayout?.visibility = View.VISIBLE + actionBar?.show() } + } override fun toggleSystemUI() { @@ -717,41 +718,20 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle private fun showSystemUI() { Log.v(LOG_TAG, "-> showSystemUI") - if (Build.VERSION.SDK_INT >= 16) { - val decorView = window.decorView - decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE - or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) - } else { - window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) - if (appBarLayout != null) - appBarLayout!!.setTopMargin(statusBarHeight) - onSystemUiVisibilityChange(View.SYSTEM_UI_FLAG_VISIBLE) - } + window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) } private fun hideSystemUI() { Log.v(LOG_TAG, "-> hideSystemUI") - if (Build.VERSION.SDK_INT >= 16) { - val decorView = window.decorView - decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE - // Set the content to appear under the system bars so that the - // content doesn't resize when the system bars hide and show. - or View.SYSTEM_UI_FLAG_LAYOUT_STABLE - or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - // Hide the nav bar and status bar - or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - or View.SYSTEM_UI_FLAG_FULLSCREEN) - } else { - window.setFlags( - WindowManager.LayoutParams.FLAG_FULLSCREEN or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, - WindowManager.LayoutParams.FLAG_FULLSCREEN or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS - ) - // Specified 1 just to mock anything other than View.SYSTEM_UI_FLAG_VISIBLE - onSystemUiVisibilityChange(1) - } + window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + or View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + or View.SYSTEM_UI_FLAG_IMMERSIVE) } override fun getEntryReadLocator(): ReadLocator? { From 87a073517347d24d0b3bbadc6ef423f0df50c62e Mon Sep 17 00:00:00 2001 From: Emmanouil Nicolas Date: Fri, 3 Jul 2020 15:10:48 -0300 Subject: [PATCH 3/3] Small fix --- folioreader/res/layout/folio_activity.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/folioreader/res/layout/folio_activity.xml b/folioreader/res/layout/folio_activity.xml index 39381dd3b..fc65623ba 100644 --- a/folioreader/res/layout/folio_activity.xml +++ b/folioreader/res/layout/folio_activity.xml @@ -24,7 +24,7 @@ android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent"> + app:layout_constraintTop_toTopOf="parent" android:animateLayoutChanges="true">