Skip to content

Fix overlay not full screen in some devices (Issue 114) #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tourguide/src/main/java/tourguide/tourguide/FrameLayoutWithHole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tourguide.tourguide
import android.animation.AnimatorSet
import android.app.Activity
import android.graphics.*
import android.os.Build
import android.support.v4.content.ContextCompat
import android.text.TextPaint
import android.util.AttributeSet
Expand Down Expand Up @@ -70,9 +71,10 @@ open class FrameLayoutWithHole @JvmOverloads constructor(private val mActivity:
textAlign = Paint.Align.LEFT
}

val size = Point()
size.x = mActivity.resources.displayMetrics.widthPixels
size.y = mActivity.resources.displayMetrics.heightPixels
val size = getDefaultResolution(mActivity)

// size.x = mActivity.resources.displayMetrics.widthPixels
// size.y = mActivity.resources.displayMetrics.heightPixels

mEraserBitmap = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.ARGB_8888)
_eraserCanvas = Canvas(mEraserBitmap!!)
Expand All @@ -90,6 +92,16 @@ open class FrameLayoutWithHole @JvmOverloads constructor(private val mActivity:
}
}

fun getDefaultResolution(activity: Activity): Point {
val display = activity.windowManager.defaultDisplay
val size = Point()
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 -> display.getRealSize(size)
Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2 -> display.getSize(size)
}
return size
}

fun setViewHole(viewHole: View) {
this.mViewHole = viewHole
enforceMotionType()
Expand Down