From 50e39315a59fe398e3222d5baf11bb54b0680a27 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 7 Sep 2019 22:53:07 +0200 Subject: [PATCH] fix #1576, properly handle fullscreen toggling on Chromebooks --- .../pro/activities/ViewPagerActivity.kt | 33 +++++++++++-------- .../gallery/pro/extensions/Context.kt | 2 ++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 08e46f7c4..53276bf15 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -323,19 +323,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View visibility and View.SYSTEM_UI_FLAG_FULLSCREEN != 0 } - view_pager.adapter?.let { - (it as MyPagerAdapter).toggleFullscreen(mIsFullScreen) - checkSystemUI() - val newAlpha = if (mIsFullScreen) 0f else 1f - top_shadow.animate().alpha(newAlpha).start() - if (bottom_actions.isVisible()) { - bottom_actions.animate().alpha(newAlpha).start() - arrayOf(bottom_favorite, bottom_edit, bottom_share, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, - bottom_slideshow, bottom_show_on_map, bottom_toggle_file_visibility, bottom_rename).forEach { - it.isClickable = !mIsFullScreen - } - } - } + checkSystemUI() + fullscreenToggled() } if (intent.action == "com.android.camera.action.REVIEW") { @@ -1082,6 +1071,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View override fun fragmentClicked() { mIsFullScreen = !mIsFullScreen checkSystemUI() + if (isChromebook()) { + fullscreenToggled() + } } override fun videoEnded(): Boolean { @@ -1138,6 +1130,21 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } } + private fun fullscreenToggled() { + view_pager.adapter?.let { + (it as MyPagerAdapter).toggleFullscreen(mIsFullScreen) + val newAlpha = if (mIsFullScreen) 0f else 1f + top_shadow.animate().alpha(newAlpha).start() + if (bottom_actions.isVisible()) { + bottom_actions.animate().alpha(newAlpha).start() + arrayOf(bottom_favorite, bottom_edit, bottom_share, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, + bottom_slideshow, bottom_show_on_map, bottom_toggle_file_visibility, bottom_rename).forEach { + it.isClickable = !mIsFullScreen + } + } + } + } + private fun updateActionbarTitle() { runOnUiThread { if (mPos < getCurrentMedia().size) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 34676a6a2..6132bb2ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -876,3 +876,5 @@ fun Context.getFileDateTaken(path: String): Long { return 0L } + +fun Context.isChromebook() = packageManager.hasSystemFeature("org.chromium.arc.device_management")