change the way we calculate the navigation bar height
This commit is contained in:
parent
be0f949b19
commit
658977953b
|
@ -22,6 +22,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
|
|||
import com.simplemobiletools.camera.*
|
||||
import com.simplemobiletools.camera.Preview.PreviewListener
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
import com.simplemobiletools.camera.extensions.navBarHeight
|
||||
import com.simplemobiletools.camera.views.FocusRectView
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.models.Release
|
||||
|
@ -124,10 +125,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho
|
|||
setContentView(R.layout.activity_main)
|
||||
initButtons()
|
||||
|
||||
if (mRes.hasNavBar() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
val lp = btn_holder.layoutParams as RelativeLayout.LayoutParams
|
||||
lp.setMargins(0, 0, 0, lp.bottomMargin + mRes.getNavBarHeight())
|
||||
}
|
||||
(btn_holder.layoutParams as RelativeLayout.LayoutParams).setMargins(0, 0, 0, navBarHeight)
|
||||
|
||||
mCurrCameraId = config.lastUsedCamera
|
||||
mPreview = Preview(this, camera_view, this)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.simplemobiletools.camera.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Point
|
||||
import android.view.WindowManager
|
||||
import com.simplemobiletools.camera.Config
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -8,6 +10,8 @@ import java.util.*
|
|||
|
||||
val Context.config: Config get() = Config.newInstance(this)
|
||||
|
||||
internal val Context.windowManager: WindowManager get() = getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
|
||||
fun Context.getOutputMediaFile(isPhoto: Boolean): String {
|
||||
val mediaStorageDir = File(config.savePhotosFolder)
|
||||
|
||||
|
@ -24,3 +28,17 @@ fun Context.getOutputMediaFile(isPhoto: Boolean): String {
|
|||
"${mediaStorageDir.path}${File.separator}VID_$timestamp.mp4"
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
val Context.navBarHeight: Int get() = realScreenSize.y - usableScreenSize.y
|
||||
|
|
Loading…
Reference in New Issue