From 3e401bb3af46c98c1baaf561eec6597dc4acd027 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 25 Mar 2020 22:41:44 +0100 Subject: [PATCH] moving some extension functions into Commons --- app/build.gradle | 2 +- .../pro/activities/PanoramaPhotoActivity.kt | 5 +- .../gallery/pro/extensions/Context.kt | 59 ------------------- 3 files changed, 2 insertions(+), 64 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ba15c6e46..ea94efb60 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,7 +78,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.23.8' + implementation 'com.simplemobiletools:commons:5.23.11' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1' 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 8222b9d52..362bd6f8b 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 @@ -11,10 +11,7 @@ import android.view.Window import android.widget.RelativeLayout import com.google.vr.sdk.widgets.pano.VrPanoramaEventListener import com.google.vr.sdk.widgets.pano.VrPanoramaView -import com.simplemobiletools.commons.extensions.beVisible -import com.simplemobiletools.commons.extensions.onGlobalLayout -import com.simplemobiletools.commons.extensions.showErrorToast -import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.extensions.* 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 5834cf4fd..406781435 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 @@ -4,13 +4,10 @@ import android.appwidget.AppWidgetManager import android.content.ComponentName import android.content.Context import android.content.Intent -import android.content.res.Configuration import android.database.Cursor -import android.graphics.Point import android.graphics.drawable.PictureDrawable import android.media.AudioManager import android.provider.MediaStore -import android.view.WindowManager import android.widget.ImageView import com.bumptech.glide.Glide import com.bumptech.glide.Priority @@ -39,63 +36,7 @@ import java.util.LinkedHashSet import kotlin.Comparator import kotlin.collections.ArrayList -val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT val Context.audioManager get() = getSystemService(Context.AUDIO_SERVICE) as AudioManager -val Context.windowManager: WindowManager get() = getSystemService(Context.WINDOW_SERVICE) as WindowManager -val Context.navigationBarRight: Boolean get() = usableScreenSize.x < realScreenSize.x -val Context.navigationBarBottom: Boolean get() = usableScreenSize.y < realScreenSize.y -val Context.navigationBarHeight: Int get() = if (navigationBarBottom) navigationBarSize.y else 0 -val Context.navigationBarWidth: Int get() = if (navigationBarRight) navigationBarSize.x else 0 - -internal val Context.navigationBarSize: Point - get() = when { - navigationBarRight -> Point(newNavigationBarHeight, usableScreenSize.y) - navigationBarBottom -> Point(usableScreenSize.x, newNavigationBarHeight) - else -> Point() - } - -internal val Context.newNavigationBarHeight: Int - get() { - var navigationBarHeight = 0 - val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android") - if (resourceId > 0) { - navigationBarHeight = resources.getDimensionPixelSize(resourceId) - } - return navigationBarHeight - } - -internal val Context.statusBarHeight: Int - get() { - var statusBarHeight = 0 - val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android") - if (resourceId > 0) { - statusBarHeight = resources.getDimensionPixelSize(resourceId) - } - return statusBarHeight - } - -internal val Context.actionBarHeight: Int - get() { - val styledAttributes = theme.obtainStyledAttributes(intArrayOf(android.R.attr.actionBarSize)) - val actionBarHeight = styledAttributes.getDimension(0, 0f) - styledAttributes.recycle() - return actionBarHeight.toInt() - } - - -val Context.usableScreenSize: Point - get() { - val size = Point() - windowManager.defaultDisplay.getSize(size) - return size - } - -val Context.realScreenSize: Point - get() { - val size = Point() - windowManager.defaultDisplay.getRealSize(size) - return size - } fun Context.getHumanizedFilename(path: String): String { val humanized = humanizePath(path)