From 733d8e58d9bf68854d384e6e7c83b42979da50c4 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 14 Nov 2016 23:14:35 +0100 Subject: [PATCH] move the UI toggle functions out of extensions, as they arent --- .../gallery/activities/PhotoVideoActivity.kt | 6 ++--- .../gallery/activities/SimpleActivity.kt | 20 ++++++++++++---- .../gallery/activities/ViewPagerActivity.kt | 6 ++--- .../gallery/extensions/activity.kt | 23 ------------------- 4 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 8fcf6ec05..f73ceed32 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -42,7 +42,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic mFragment.arguments = bundle supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit() } - hideUI() + hideSystemUI() if (mUri.scheme == "content") { val proj = arrayOf(MediaStore.Images.Media.TITLE) @@ -91,9 +91,9 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentClic override fun fragmentClicked() { mIsFullScreen = !mIsFullScreen if (mIsFullScreen) { - hideUI() + hideSystemUI() } else { - showUI() + showSystemUI() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt index ee24abfcd..a7015c1ec 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt @@ -7,12 +7,11 @@ import android.os.Build import android.os.Bundle import android.support.v7.app.AppCompatActivity import android.view.MenuItem +import android.view.View import com.simplemobiletools.filepicker.extensions.isShowingWritePermissions import com.simplemobiletools.gallery.Config import com.simplemobiletools.gallery.OPEN_DOCUMENT_TREE import com.simplemobiletools.gallery.R -import com.simplemobiletools.gallery.extensions.hideSystemUI -import com.simplemobiletools.gallery.extensions.showSystemUI import java.io.File open class SimpleActivity : AppCompatActivity() { @@ -56,7 +55,20 @@ open class SimpleActivity : AppCompatActivity() { fun isShowingPermDialog(file: File) = isShowingWritePermissions(file, mConfig.treeUri, OPEN_DOCUMENT_TREE) - fun hideUI() = hideSystemUI(supportActionBar, window) + fun showSystemUI() { + supportActionBar?.show() + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + } - fun showUI() = showSystemUI(supportActionBar, window) + fun hideSystemUI() { + supportActionBar?.hide() + window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or + View.SYSTEM_UI_FLAG_LOW_PROFILE or + View.SYSTEM_UI_FLAG_FULLSCREEN or + View.SYSTEM_UI_FLAG_IMMERSIVE + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index 22ecb4a8d..fd2d434c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -82,7 +82,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View mIsFullScreen = true mToBeDeleted = "" mBeingDeleted = "" - hideUI() + hideSystemUI() scanPath(mPath) {} addUndoMargin() @@ -401,9 +401,9 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View deleteFile() mIsFullScreen = !mIsFullScreen if (mIsFullScreen) { - hideUI() + hideSystemUI() } else { - showUI() + showSystemUI() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt deleted file mode 100644 index 789719158..000000000 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.simplemobiletools.gallery.extensions - -import android.app.Activity -import android.support.v7.app.ActionBar -import android.view.View -import android.view.Window - -fun Activity.showSystemUI(actionbar: ActionBar?, window: Window) { - actionbar?.show() - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN -} - -fun Activity.hideSystemUI(actionbar: ActionBar?, window: Window) { - actionbar?.hide() - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or - View.SYSTEM_UI_FLAG_LOW_PROFILE or - View.SYSTEM_UI_FLAG_FULLSCREEN or - View.SYSTEM_UI_FLAG_IMMERSIVE -}