save rotated images automatically

This commit is contained in:
tibbi 2019-01-29 13:41:33 +01:00
parent 82d97bb380
commit 18277c13e2
2 changed files with 13 additions and 9 deletions

View file

@ -142,12 +142,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
currentMedium.isFavorite = mFavoritePaths.contains(currentMedium.path)
val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0
getCurrentFragment()?.let {
(it as? PhotoFragment)?.apply {
mRotationDegrees = mCurrentRotationDegrees
}
}
getCurrentPhotoFragment()?.mCurrentRotationDegrees = mRotationDegrees
menu.apply {
findItem(R.id.menu_show_on_map).isVisible = visibleBottomActions and BOTTOM_ACTION_SHOW_ON_MAP == 0
findItem(R.id.menu_slideshow).isVisible = visibleBottomActions and BOTTOM_ACTION_SLIDESHOW == 0
@ -569,9 +564,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
private fun rotateBy(degrees: Int) {
mRotationDegrees = (mRotationDegrees + degrees) % 360
getCurrentFragment()?.let {
(it as? PhotoFragment)?.rotateImageViewBy(mRotationDegrees)
}
getCurrentPhotoFragment()?.rotateImageViewBy(mRotationDegrees)
supportInvalidateOptionsMenu()
}
@ -602,6 +595,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
saveRotatedImageToFile(currPath, it, mRotationDegrees, true) {
toast(R.string.file_saved)
mRotationDegrees = 0
getCurrentPhotoFragment()?.mCurrentRotationDegrees = 0
invalidateOptionsMenu()
}
}.start()
@ -609,6 +603,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
}
}
private fun getCurrentPhotoFragment() = getCurrentFragment() as? PhotoFragment
private fun isShowHiddenFlagNeeded(): Boolean {
val file = File(mPath)
if (file.isHidden) {

View file

@ -32,6 +32,7 @@ import com.davemorrissey.labs.subscaleview.DecoderFactory
import com.davemorrissey.labs.subscaleview.ImageDecoder
import com.davemorrissey.labs.subscaleview.ImageRegionDecoder
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.OTG_PATH
import com.simplemobiletools.gallery.pro.R
@ -223,7 +224,14 @@ class PhotoFragment : ViewPagerFragment() {
if (activity?.isDestroyed == false) {
mView.subsampling_view.recycle()
}
mLoadZoomableViewHandler.removeCallbacksAndMessages(null)
if (mCurrentRotationDegrees != 0) {
Thread {
val path = mMedium.path
(activity as? BaseSimpleActivity)?.saveRotatedImageToFile(path, path, mCurrentRotationDegrees, false) {}
}.start()
}
}
override fun onConfigurationChanged(newConfig: Configuration) {