Skip to content

Commit b4990e7

Browse files
ndk::checks-impl
1 parent 38aa54b commit b4990e7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

core/app/src/main/java/com/itsaky/androidide/activities/editor/EditorHandlerActivity.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler {
214214
open fun prepareOptionsMenu(menu: Menu) {
215215
val data = createToolbarActionData()
216216
val actions = getInstance().getActions(EDITOR_TOOLBAR)
217+
218+
val displayMetrics = resources.displayMetrics
219+
val screenWidth = displayMetrics.widthPixels
220+
val actionButtonWidth = resources.getDimensionPixelSize(R.dimen.action_button_min_width)
221+
val maxVisibleActions = (screenWidth * 0.7 / actionButtonWidth).toInt()
222+
223+
var visibleActionCount = 0
224+
217225
actions.forEach { (_, action) ->
218226
menu.findItem(action.itemId)?.let { item ->
219227
action.prepare(data)
@@ -229,7 +237,10 @@ open class EditorHandlerActivity : ProjectHandlerActivity(), IEditorHandler {
229237

230238
var showAsAction = action.getShowAsActionFlags(data)
231239
if (showAsAction == -1) {
232-
showAsAction = if (action.icon != null) {
240+
showAsAction = if (action.icon != null && action.enabled && visibleActionCount < maxVisibleActions) {
241+
visibleActionCount++
242+
MenuItem.SHOW_AS_ACTION_ALWAYS
243+
} else if (action.icon != null) {
233244
MenuItem.SHOW_AS_ACTION_IF_ROOM
234245
} else {
235246
MenuItem.SHOW_AS_ACTION_NEVER

core/app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
<resources>
1919
<dimen name="editor_mem_usage_view_height">200dp</dimen>
2020
<dimen name="editor_container_corners">28dp</dimen>
21+
<dimen name="action_button_min_width">48dp</dimen>
2122
</resources>

0 commit comments

Comments
 (0)