From c4c083b77f75a6c7abac4c1f0e97c71de34ea430 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 28 Jan 2018 17:49:29 +0100 Subject: [PATCH] add a toggle for hiding extended details when the statusbar is hidden --- .../gallery/activities/SettingsActivity.kt | 11 ++++++++ .../gallery/fragments/PhotoFragment.kt | 25 +++++++++++++++---- .../gallery/fragments/VideoFragment.kt | 25 +++++++++++++++---- .../gallery/helpers/Config.kt | 4 +++ .../gallery/helpers/Constants.kt | 1 + app/src/main/res/layout/activity_settings.xml | 19 ++++++++++++++ 6 files changed, 75 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt index f3aeeb21e..0e75cdddd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SettingsActivity.kt @@ -58,6 +58,7 @@ class SettingsActivity : SimpleActivity() { setupAllowInstantChange() setupReplaceZoomableImages() setupShowExtendedDetails() + setupHideExtendedDetails() setupManageExtendedDetails() updateTextColors(settings_holder) setupSectionColors() @@ -311,6 +312,16 @@ class SettingsActivity : SimpleActivity() { settings_show_extended_details.toggle() config.showExtendedDetails = settings_show_extended_details.isChecked settings_manage_extended_details_holder.beVisibleIf(config.showExtendedDetails) + settings_hide_extended_details_holder.beVisibleIf(config.showExtendedDetails) + } + } + + private fun setupHideExtendedDetails() { + settings_hide_extended_details_holder.beVisibleIf(config.showExtendedDetails) + settings_hide_extended_details.isChecked = config.hideExtendedDetails + settings_hide_extended_details_holder.setOnClickListener { + settings_hide_extended_details.toggle() + config.hideExtendedDetails = settings_hide_extended_details.isChecked } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index d6934cf78..1cb1d5e23 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -42,11 +42,13 @@ class PhotoFragment : ViewPagerFragment() { private var isFragmentVisible = false private var isFullscreen = false private var wasInit = false - private var storedShowExtendedDetails = false - private var storedExtendedDetails = 0 private var imageOrientation = -1 private var gifDrawable: GifDrawable? = null + private var storedShowExtendedDetails = false + private var storedHideExtendedDetails = false + private var storedExtendedDetails = 0 + lateinit var view: ViewGroup lateinit var medium: Medium @@ -58,6 +60,7 @@ class PhotoFragment : ViewPagerFragment() { instant_next_item.setOnClickListener { listener?.goToNextItem() } } + storeStateVariables() if (!isFragmentVisible && activity is PhotoActivity) { isFragmentVisible = true } @@ -104,8 +107,7 @@ class PhotoFragment : ViewPagerFragment() { override fun onPause() { super.onPause() - storedShowExtendedDetails = context!!.config.showExtendedDetails - storedExtendedDetails = context!!.config.extendedDetails + storeStateVariables() } override fun onResume() { @@ -117,6 +119,7 @@ class PhotoFragment : ViewPagerFragment() { val allowInstantChange = context!!.config.allowInstantChange view.instant_prev_item.beVisibleIf(allowInstantChange) view.instant_next_item.beVisibleIf(allowInstantChange) + storeStateVariables() } override fun setMenuVisibility(menuVisible: Boolean) { @@ -131,6 +134,14 @@ class PhotoFragment : ViewPagerFragment() { } } + private fun storeStateVariables() { + context!!.config.apply { + storedShowExtendedDetails = showExtendedDetails + storedHideExtendedDetails = hideExtendedDetails + storedExtendedDetails = extendedDetails + } + } + private fun gifFragmentVisibilityChanged(isVisible: Boolean) { if (isVisible) { gifDrawable?.start() @@ -362,8 +373,12 @@ class PhotoFragment : ViewPagerFragment() { override fun fullscreenToggled(isFullscreen: Boolean) { this.isFullscreen = isFullscreen view.photo_details.apply { - if (isVisible()) { + if (storedShowExtendedDetails) { animate().y(getExtendedDetailsY(height)) + + if (storedHideExtendedDetails) { + animate().alpha(if (isFullscreen) 0f else 1f).start() + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt index 8b3099e43..0ee831121 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/VideoFragment.kt @@ -43,11 +43,9 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee private var mIsFullscreen = false private var mIsFragmentVisible = false private var mPlayOnPrepare = false - private var mStoredShowExtendedDetails = false private var wasEncoded = false private var wasInit = false private var isPrepared = false - private var mStoredExtendedDetails = 0 private var mCurrTime = 0 private var mDuration = 0 private var mEncodedPath = "" @@ -63,6 +61,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee private var mSlideInfoText = "" private var mSlideInfoFadeHandler = Handler() + private var mStoredShowExtendedDetails = false + private var mStoredHideExtendedDetails = false + private var mStoredExtendedDetails = 0 + lateinit var medium: Medium override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { @@ -72,6 +74,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mTimeHolder = video_time_holder } + storeStateVariables() medium = arguments!!.getSerializable(MEDIUM) as Medium // setMenuVisibility is not called at VideoActivity (third party intent) @@ -107,13 +110,13 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee if (context!!.config.showExtendedDetails != mStoredShowExtendedDetails || context!!.config.extendedDetails != mStoredExtendedDetails) { checkExtendedDetails() } + storeStateVariables() } override fun onPause() { super.onPause() pauseVideo() - mStoredShowExtendedDetails = context!!.config.showExtendedDetails - mStoredExtendedDetails = context!!.config.extendedDetails + storeStateVariables() } override fun onDestroy() { @@ -123,6 +126,14 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee } } + private fun storeStateVariables() { + context!!.config.apply { + mStoredShowExtendedDetails = showExtendedDetails + mStoredHideExtendedDetails = hideExtendedDetails + mStoredExtendedDetails = extendedDetails + } + } + private fun setupPlayer() { if (activity == null) return @@ -614,8 +625,12 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee mIsFullscreen = isFullscreen checkFullscreen() mView!!.video_details.apply { - if (isVisible()) { + if (mStoredShowExtendedDetails) { animate().y(getExtendedDetailsY(height)) + + if (mStoredHideExtendedDetails) { + animate().alpha(if (isFullscreen) 0f else 1f).start() + } } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt index 743cae29e..5002bf781 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Config.kt @@ -309,6 +309,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(SHOW_EXTENDED_DETAILS, false) set(showExtendedDetails) = prefs.edit().putBoolean(SHOW_EXTENDED_DETAILS, showExtendedDetails).apply() + var hideExtendedDetails: Boolean + get() = prefs.getBoolean(HIDE_EXTENDED_DETAILS, false) + set(hideExtendedDetails) = prefs.edit().putBoolean(HIDE_EXTENDED_DETAILS, hideExtendedDetails).apply() + var extendedDetails: Int get() = prefs.getInt(EXTENDED_DETAILS, EXT_RESOLUTION or EXT_LAST_MODIFIED or EXT_EXIF_PROPERTIES) set(extendedDetails) = prefs.edit().putInt(EXTENDED_DETAILS, extendedDetails).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt index f278a6398..821d9f1e8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/helpers/Constants.kt @@ -42,6 +42,7 @@ const val VIEW_TYPE_FOLDERS = "view_type_folders" const val VIEW_TYPE_FILES = "view_type_files" const val SHOW_EXTENDED_DETAILS = "show_extended_details" const val EXTENDED_DETAILS = "extended_details" +const val HIDE_EXTENDED_DETAILS = "hide_extended_details" const val LAST_FILE_CLEANUP = "last_file_cleanup" const val ONE_FINGER_ZOOM = "one_finger_zoom" const val ALLOW_INSTANT_CHANGE = "allow_instant_change" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index a27c81258..6558a9fb1 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -589,6 +589,25 @@ android:text="@string/show_extended_details"/> + + + + +