Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Commit

Permalink
fix isHiDpi is more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
befora committed Jul 13, 2018
1 parent e712baf commit 99b3a6c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/sethchhim/kuboo_client/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ object Constants {
internal const val URL_PATH_FOLDER_INDEX = "?index="
internal const val URL_PATH_GRID_INDEX = "&index="

internal const val HI_DPI_VALUE = 2400
internal const val HI_DPI_VALUE = 2560
internal const val PAGE_NOT_FOUND_LENGTH = 10796L
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ open class BaseActivityImpl0_View : DaggerAppCompatActivity() {
}
}

internal fun isHiDpi() = systemUtil.getSystemWidth() >= Constants.HI_DPI_VALUE || systemUtil.getSystemHeight() >= Constants.HI_DPI_VALUE
internal fun isHiDpi() = systemUtil.getSystemWidth() >= Constants.HI_DPI_VALUE || systemUtil.getSystemHeight() >= Constants.HI_DPI_VALUE && systemUtil.getDensity() <= 3

internal fun isLandscape() = resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ open class HomeFragmentImpl0_View : DaggerFragment() {
val orientation = resources.configuration.orientation
setGuidelinePercent(when (mainActivity.isHiDpi()) {
true -> when (orientation) {
Configuration.ORIENTATION_PORTRAIT -> 0.8F
else -> 0.7F
Configuration.ORIENTATION_PORTRAIT -> 0.7F
else -> 0.6F
}
false -> when (orientation) {
Configuration.ORIENTATION_PORTRAIT -> 0.6F
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,21 @@ class SystemUtil(private val context: Context) {

//==============================================================================================

fun getDensity() = context.resources.displayMetrics.density

fun getSystemWidth(): Int {
val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val display = windowManager.defaultDisplay
val size = Point()
display.getSize(size)
display.getRealSize(size)
return size.x
}

fun getSystemHeight(): Int {
val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val display = windowManager.defaultDisplay
val size = Point()
display.getSize(size)
display.getRealSize(size)
return size.y
}

Expand Down

0 comments on commit 99b3a6c

Please sign in to comment.