Loading packages/SystemUI/src/com/android/systemui/qs/SideLabelTileLayout.kt +17 −1 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.qs import android.content.Context import android.content.Context import android.util.AttributeSet import android.util.AttributeSet import com.android.systemui.R open class SideLabelTileLayout( open class SideLabelTileLayout( context: Context, context: Context, Loading @@ -26,7 +27,7 @@ open class SideLabelTileLayout( override fun updateResources(): Boolean { override fun updateResources(): Boolean { return super.updateResources().also { return super.updateResources().also { mMaxAllowedRows = 4 mMaxAllowedRows = context.resources.getInteger(R.integer.quick_settings_max_rows) } } } } Loading @@ -44,4 +45,19 @@ open class SideLabelTileLayout( val row = index / mColumns val row = index / mColumns return getRowTop(row) return getRowTop(row) } } override fun updateMaxRows(allowedHeight: Int, tilesCount: Int): Boolean { val previousRows = mRows mRows = mMaxAllowedRows // We want at most mMaxAllowedRows, but it could be that we don't have enough tiles to fit // that many rows. In that case, we want // `tilesCount = (mRows - 1) * mColumns + X` // where X is some remainder between 1 and `mColumns - 1` // Adding `mColumns - 1` will guarantee that the final value F will satisfy // `mRows * mColumns <= F < (mRows + 1) * mColumns if (mRows > (tilesCount + mColumns - 1) / mColumns) { mRows = (tilesCount + mColumns - 1) / mColumns } return previousRows != mRows } } } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/qs/SideLabelTileLayout.kt +17 −1 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.qs import android.content.Context import android.content.Context import android.util.AttributeSet import android.util.AttributeSet import com.android.systemui.R open class SideLabelTileLayout( open class SideLabelTileLayout( context: Context, context: Context, Loading @@ -26,7 +27,7 @@ open class SideLabelTileLayout( override fun updateResources(): Boolean { override fun updateResources(): Boolean { return super.updateResources().also { return super.updateResources().also { mMaxAllowedRows = 4 mMaxAllowedRows = context.resources.getInteger(R.integer.quick_settings_max_rows) } } } } Loading @@ -44,4 +45,19 @@ open class SideLabelTileLayout( val row = index / mColumns val row = index / mColumns return getRowTop(row) return getRowTop(row) } } override fun updateMaxRows(allowedHeight: Int, tilesCount: Int): Boolean { val previousRows = mRows mRows = mMaxAllowedRows // We want at most mMaxAllowedRows, but it could be that we don't have enough tiles to fit // that many rows. In that case, we want // `tilesCount = (mRows - 1) * mColumns + X` // where X is some remainder between 1 and `mColumns - 1` // Adding `mColumns - 1` will guarantee that the final value F will satisfy // `mRows * mColumns <= F < (mRows + 1) * mColumns if (mRows > (tilesCount + mColumns - 1) / mColumns) { mRows = (tilesCount + mColumns - 1) / mColumns } return previousRows != mRows } } } No newline at end of file