From 9aa8f553ca9507eccf2461dd9cbb30ed8d90634a Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Jun 2018 23:52:03 +0200 Subject: [PATCH] add the bottom action buttons to third party intent handling activity too --- .../gallery/activities/PhotoVideoActivity.kt | 43 +++++++++++++- .../gallery/activities/ViewPagerActivity.kt | 1 + app/src/main/res/layout/activity_medium.xml | 54 +----------------- app/src/main/res/layout/bottom_actions.xml | 56 +++++++++++++++++++ app/src/main/res/layout/fragment_holder.xml | 15 ++++- 5 files changed, 114 insertions(+), 55 deletions(-) create mode 100644 app/src/main/res/layout/bottom_actions.xml 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 6871069c2..d1528b092 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.activities import android.content.Intent +import android.content.res.Configuration import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.net.Uri @@ -20,6 +21,7 @@ import com.simplemobiletools.gallery.fragments.VideoFragment import com.simplemobiletools.gallery.fragments.ViewPagerFragment import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.models.Medium +import kotlinx.android.synthetic.main.bottom_actions.* import kotlinx.android.synthetic.main.fragment_holder.* import java.io.File @@ -46,6 +48,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList finish() } } + + initBottomActions() } override fun onResume() { @@ -99,7 +103,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList mFragment = if (mIsVideo) VideoFragment() else PhotoFragment() mFragment!!.listener = this mFragment!!.arguments = bundle - supportFragmentManager.beginTransaction().replace(R.id.fragment_holder, mFragment).commit() + supportFragmentManager.beginTransaction().replace(R.id.fragment_placeholder, mFragment).commit() } if (config.blackBackground) { @@ -112,6 +116,11 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } } + override fun onConfigurationChanged(newConfig: Configuration?) { + super.onConfigurationChanged(newConfig) + initBottomActionsLayout() + } + private fun sendViewPagerIntent(path: String) { Intent(this, ViewPagerActivity::class.java).apply { putExtra(IS_VIEW_INTENT, true) @@ -153,6 +162,34 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList PropertiesDialog(this, mUri!!.path) } + private fun initBottomActions() { + initBottomActionsLayout() + initBottomActionButtons() + } + + private fun initBottomActionsLayout() { + bottom_actions.layoutParams.height = resources.getDimension(R.dimen.bottom_actions_height).toInt() + navigationBarHeight + if (config.bottomActions) { + bottom_actions.beVisible() + } else { + bottom_actions.beGone() + } + } + + private fun initBottomActionButtons() { + bottom_properties.setOnClickListener { + } + + bottom_edit.setOnClickListener { + } + + bottom_share.setOnClickListener { + } + + bottom_delete.setOnClickListener { + } + } + override fun fragmentClicked() { mIsFullScreen = !mIsFullScreen if (mIsFullScreen) { @@ -160,6 +197,10 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } else { showSystemUI() } + + if (!bottom_actions.isGone()) { + bottom_actions.animate().alpha(if (mIsFullScreen) 0f else 1f).start() + } } override fun videoEnded() = false 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 9579a727f..7e25ad59c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -45,6 +45,7 @@ import com.simplemobiletools.gallery.fragments.ViewPagerFragment import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.models.Medium import kotlinx.android.synthetic.main.activity_medium.* +import kotlinx.android.synthetic.main.bottom_actions.* import java.io.File import java.io.FileOutputStream import java.io.InputStream diff --git a/app/src/main/res/layout/activity_medium.xml b/app/src/main/res/layout/activity_medium.xml index 0a1dcc508..63559ebf0 100644 --- a/app/src/main/res/layout/activity_medium.xml +++ b/app/src/main/res/layout/activity_medium.xml @@ -1,7 +1,6 @@ @@ -11,57 +10,8 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> - + layout="@layout/bottom_actions"/> - - - - - - - - - diff --git a/app/src/main/res/layout/bottom_actions.xml b/app/src/main/res/layout/bottom_actions.xml new file mode 100644 index 000000000..dec089e89 --- /dev/null +++ b/app/src/main/res/layout/bottom_actions.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_holder.xml b/app/src/main/res/layout/fragment_holder.xml index 9a0863df0..d10a3a193 100644 --- a/app/src/main/res/layout/fragment_holder.xml +++ b/app/src/main/res/layout/fragment_holder.xml @@ -1,6 +1,17 @@ - + android:layout_height="match_parent"> + + + + + +