diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index bb935dd79..0c9a0e9dd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -308,6 +308,36 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } } + override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { + if (resultCode == Activity.RESULT_OK) { + if (requestCode == PICK_MEDIA && resultData != null) { + val resultIntent = Intent() + var resultUri: Uri? = null + if (mIsThirdPartyIntent) { + when { + intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true && intent.flags and Intent.FLAG_GRANT_WRITE_URI_PERMISSION != 0 -> { + resultUri = fillExtraOutput(resultData) + } + resultData.extras?.containsKey(PICKED_PATHS) == true -> fillPickedPaths(resultData, resultIntent) + else -> fillIntentPath(resultData, resultIntent) + } + } + + if (resultUri != null) { + resultIntent.data = resultUri + resultIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + } + + setResult(Activity.RESULT_OK, resultIntent) + finish() + } else if (requestCode == PICK_WALLPAPER) { + setResult(Activity.RESULT_OK) + finish() + } + } + super.onActivityResult(requestCode, resultCode, resultData) + } + private fun refreshMenuItems() { if (!mIsThirdPartyIntent) { main_menu.getToolbar().menu.apply { @@ -802,36 +832,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun isVideoType(intent: Intent) = (intent.type?.startsWith("video/") == true || intent.type == Video.Media.CONTENT_TYPE) - override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { - if (resultCode == Activity.RESULT_OK) { - if (requestCode == PICK_MEDIA && resultData != null) { - val resultIntent = Intent() - var resultUri: Uri? = null - if (mIsThirdPartyIntent) { - when { - intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true && intent.flags and Intent.FLAG_GRANT_WRITE_URI_PERMISSION != 0 -> { - resultUri = fillExtraOutput(resultData) - } - resultData.extras?.containsKey(PICKED_PATHS) == true -> fillPickedPaths(resultData, resultIntent) - else -> fillIntentPath(resultData, resultIntent) - } - } - - if (resultUri != null) { - resultIntent.data = resultUri - resultIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - } - - setResult(Activity.RESULT_OK, resultIntent) - finish() - } else if (requestCode == PICK_WALLPAPER) { - setResult(Activity.RESULT_OK) - finish() - } - } - super.onActivityResult(requestCode, resultCode, resultData) - } - private fun fillExtraOutput(resultData: Intent): Uri? { val file = File(resultData.data!!.path!!) var inputStream: InputStream? = null diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 9f18db92e..531cb0ea6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -228,6 +228,16 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } } + override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { + if (requestCode == REQUEST_EDIT_IMAGE) { + if (resultCode == Activity.RESULT_OK && resultData != null) { + mMedia.clear() + refreshItems() + } + } + super.onActivityResult(requestCode, resultCode, resultData) + } + private fun refreshMenuItems() { val isDefaultFolder = !config.defaultFolder.isEmpty() && File(config.defaultFolder).compareTo(File(mPath)) == 0 @@ -777,16 +787,6 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun isSetWallpaperIntent() = intent.getBooleanExtra(SET_WALLPAPER_INTENT, false) - override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) { - if (requestCode == REQUEST_EDIT_IMAGE) { - if (resultCode == Activity.RESULT_OK && resultData != null) { - mMedia.clear() - refreshItems() - } - } - super.onActivityResult(requestCode, resultCode, resultData) - } - private fun itemClicked(path: String) { hideKeyboard() if (isSetWallpaperIntent()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt index 9c66ac750..c6708837e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt @@ -85,6 +85,11 @@ open class PanoramaPhotoActivity : SimpleActivity() { } } + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + setupButtonMargins() + } + private fun checkIntent() { val path = intent.getStringExtra(PATH) if (path == null) { @@ -135,11 +140,6 @@ open class PanoramaPhotoActivity : SimpleActivity() { } } - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - setupButtonMargins() - } - private fun getBitmapToLoad(path: String): Bitmap? { val options = BitmapFactory.Options() options.inSampleSize = 1 diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt index 1d7428fc0..07166d2d8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt @@ -88,6 +88,11 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList } } + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + setupButtons() + } + private fun checkIntent() { val path = intent.getStringExtra(PATH) if (path == null) { @@ -168,11 +173,6 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList } } - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - setupButtons() - } - private fun setupDuration(duration: Long) { mDuration = (duration / 1000).toInt() video_seekbar.max = mDuration diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index 698459fc1..efb977a44 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -37,7 +37,6 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList public override fun onCreate(savedInstanceState: Bundle?) { showTransparentTop = true - //showTransparentNavigation = true super.onCreate(savedInstanceState) setContentView(R.layout.fragment_holder) @@ -71,6 +70,19 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } } + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + initBottomActionsLayout() + + top_shadow.layoutParams.height = statusBarHeight + actionBarHeight + (fragment_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight + if (!portrait && navigationBarOnSide && navigationBarWidth > 0) { + fragment_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0) + } else { + fragment_viewer_toolbar.setPadding(0, 0, 0, 0) + } + } + fun refreshMenuItems() { val visibleBottomActions = if (config.bottomActions) config.visibleBottomActions else 0 @@ -279,19 +291,6 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList finish() } - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - initBottomActionsLayout() - - top_shadow.layoutParams.height = statusBarHeight + actionBarHeight - (fragment_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight - if (!portrait && navigationBarOnSide && navigationBarWidth > 0) { - fragment_viewer_toolbar.setPadding(0, 0, navigationBarWidth, 0) - } else { - fragment_viewer_toolbar.setPadding(0, 0, 0, 0) - } - } - private fun sendViewPagerIntent(path: String) { ensureBackgroundThread { if (isPathPresentInMediaStore(path)) { diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index d7adac061..7fbafb70f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -60,8 +60,6 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen public override fun onCreate(savedInstanceState: Bundle?) { showTransparentTop = true - //showTransparentNavigation = true - super.onCreate(savedInstanceState) setContentView(R.layout.activity_video_player) setupOptionsMenu() @@ -189,7 +187,6 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen video_prev_file.beVisibleIf(intent.getBooleanExtra(SHOW_PREV_ITEM, false)) video_prev_file.setOnClickListener { handlePrevFile() } - val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() { override fun onDoubleTap(e: MotionEvent): Boolean { handleDoubleTap(e.rawX) @@ -658,8 +655,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen mIsDragged = false } - override fun onSurfaceTextureUpdated(surface: SurfaceTexture) { - } + override fun onSurfaceTextureUpdated(surface: SurfaceTexture) {} override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = false 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 1e7a796e4..e4d41556c 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 @@ -90,8 +90,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View override fun onCreate(savedInstanceState: Bundle?) { showTransparentTop = true - //showTransparentNavigation = true - super.onCreate(savedInstanceState) setContentView(R.layout.activity_medium) setupOptionsMenu()