mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 13:08:00 +01:00
moving some extension functions into Commons
This commit is contained in:
parent
aae07cabd5
commit
3e401bb3af
3 changed files with 2 additions and 64 deletions
|
@ -78,7 +78,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
|
||||||
implementation 'androidx.multidex:multidex:2.0.1'
|
implementation 'androidx.multidex:multidex:2.0.1'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -11,10 +11,7 @@ import android.view.Window
|
||||||
import android.widget.RelativeLayout
|
import android.widget.RelativeLayout
|
||||||
import com.google.vr.sdk.widgets.pano.VrPanoramaEventListener
|
import com.google.vr.sdk.widgets.pano.VrPanoramaEventListener
|
||||||
import com.google.vr.sdk.widgets.pano.VrPanoramaView
|
import com.google.vr.sdk.widgets.pano.VrPanoramaView
|
||||||
import com.simplemobiletools.commons.extensions.beVisible
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.extensions.onGlobalLayout
|
|
||||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.extensions.*
|
import com.simplemobiletools.gallery.pro.extensions.*
|
||||||
|
|
|
@ -4,13 +4,10 @@ import android.appwidget.AppWidgetManager
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.graphics.Point
|
|
||||||
import android.graphics.drawable.PictureDrawable
|
import android.graphics.drawable.PictureDrawable
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.view.WindowManager
|
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.Priority
|
import com.bumptech.glide.Priority
|
||||||
|
@ -39,63 +36,7 @@ import java.util.LinkedHashSet
|
||||||
import kotlin.Comparator
|
import kotlin.Comparator
|
||||||
import kotlin.collections.ArrayList
|
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.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 {
|
fun Context.getHumanizedFilename(path: String): String {
|
||||||
val humanized = humanizePath(path)
|
val humanized = humanizePath(path)
|
||||||
|
|
Loading…
Reference in a new issue