From 45c5ac9fe8dd30a84c4f5920d0c4d0525277ac37 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 12 Feb 2022 12:06:29 +0100 Subject: [PATCH] adding some keyboard hiding --- .../gallery/pro/activities/MainActivity.kt | 3 +++ .../gallery/pro/activities/MediaActivity.kt | 3 +++ .../gallery/pro/activities/PhotoVideoActivity.kt | 3 +++ .../gallery/pro/activities/ViewPagerActivity.kt | 1 + .../simplemobiletools/gallery/pro/extensions/Activity.kt | 6 ++++++ .../com/simplemobiletools/gallery/pro/extensions/Context.kt | 5 +---- 6 files changed, 17 insertions(+), 4 deletions(-) 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 8ef303a5b..ca7ae1e27 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 @@ -485,6 +485,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun launchSearchActivity() { + hideKeyboard() Intent(this, SearchActivity::class.java).apply { startActivity(this) } @@ -522,6 +523,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (mIsThirdPartyIntent) { handleMediaIntent(this) } else { + hideKeyboard() startActivity(this) finish() } @@ -835,6 +837,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { } private fun handleMediaIntent(intent: Intent) { + hideKeyboard() intent.apply { if (mIsSetWallpaperIntent) { putExtra(SET_WALLPAPER_INTENT, true) 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 c8d077376..aa2a69173 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 @@ -288,6 +288,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { private fun startSlideshow() { if (mMedia.isNotEmpty()) { + hideKeyboard() Intent(this, ViewPagerActivity::class.java).apply { val item = mMedia.firstOrNull { it is Medium } as? Medium ?: return putExtra(SKIP_AUTHENTICATION, shouldSkipAuthentication()) @@ -514,6 +515,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } private fun switchToFolderView() { + hideKeyboard() config.showAll = false startActivity(Intent(this, MainActivity::class.java)) finish() @@ -770,6 +772,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } private fun itemClicked(path: String) { + hideKeyboard() if (isSetWallpaperIntent()) { toast(R.string.setting_wallpaper) 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 e7151949e..62ee4e013 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 @@ -72,6 +72,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun checkIntent(savedInstanceState: Bundle? = null) { if (intent.data == null && intent.action == Intent.ACTION_VIEW) { + hideKeyboard() startActivity(Intent(this, MainActivity::class.java)) finish() return @@ -198,6 +199,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } catch (ignored: OutOfMemoryError) { } + hideKeyboard() if (isPanorama) { Intent(applicationContext, PanoramaVideoActivity::class.java).apply { putExtra(PATH, realPath) @@ -224,6 +226,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } private fun sendViewPagerIntent(path: String) { + hideKeyboard() Intent(this, ViewPagerActivity::class.java).apply { putExtra(SKIP_AUTHENTICATION, intent.getBooleanExtra(SKIP_AUTHENTICATION, false)) putExtra(SHOW_FAVORITES, intent.getBooleanExtra(SHOW_FAVORITES, 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 04a2ac467..8170f857d 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 @@ -1261,6 +1261,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View } override fun launchViewVideoIntent(path: String) { + hideKeyboard() ensureBackgroundThread { val newUri = getFinalUriFromPath(path, BuildConfig.APPLICATION_ID) ?: return@ensureBackgroundThread val mimeType = getUriMimeType(path, newUri) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 27bf5e88e..5eb549f6e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -31,6 +31,7 @@ import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.gallery.pro.BuildConfig import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.activities.SettingsActivity import com.simplemobiletools.gallery.pro.activities.SimpleActivity import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN @@ -77,6 +78,11 @@ fun Activity.launchCamera() { launchActivityIntent(intent) } +fun SimpleActivity.launchSettings() { + hideKeyboard() + startActivity(Intent(applicationContext, SettingsActivity::class.java)) +} + fun SimpleActivity.launchAbout() { val licenses = LICENSE_GLIDE or LICENSE_CROPPER or LICENSE_RTL or LICENSE_SUBSAMPLING or LICENSE_PATTERN or LICENSE_REPRINT or LICENSE_GIF_DRAWABLE or LICENSE_PICASSO or LICENSE_EXOPLAYER or LICENSE_PANORAMA_VIEW or LICENSE_SANSELAN or LICENSE_FILTERS or LICENSE_GESTURE_VIEWS or diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index bb451025a..d91d6ce0d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.gallery.pro.extensions +import android.app.Activity import android.appwidget.AppWidgetManager import android.content.ComponentName import android.content.Context @@ -55,10 +56,6 @@ fun Context.getHumanizedFilename(path: String): String { return humanized.substring(humanized.lastIndexOf("/") + 1) } -fun Context.launchSettings() { - startActivity(Intent(applicationContext, SettingsActivity::class.java)) -} - val Context.config: Config get() = Config.newInstance(applicationContext) val Context.widgetsDB: WidgetsDao get() = GalleryDatabase.getInstance(applicationContext).WidgetsDao()