Skip to content

⚡ An Android menu library from Chromium-Android. Touch, move and select in one gesture.

License

Notifications You must be signed in to change notification settings

DeweyReed/ChromeMenu

Repository files navigation

ChromeMenu

Download API

The menu from Chromium Android appmenu(Github Mirror). It can do this:

Example GIF

Notice the press, move, selection, up are finished in one gesture.

I love this design. It significantly improves the efficiency of using an app. So I dig into chromium, extract related code and pack them into this library.

Update: Recently, I found that getDragToOpenListener provides a similar effect.

Usage

  1. Install dependency

    • JitPack: implementation 'com.github.DeweyReed:ChromeMenu:0.2.0'
  2. Set up touch listener

    val coordinator = AppMenuCoordinatorFactory.createAppMenuCoordinator(
        this,
        { binding.btn },
        object : AppMenuDelegate {
            override fun onOptionsItemSelected(item: MenuItem, menuItemData: Bundle?): Boolean {
                onMenuItemClicked(item)
                return true
            }
    
            override fun createAppMenuPropertiesDelegate(): AppMenuPropertiesDelegate {
                return object : AbstractAppMenuPropertiesDelegate() {
                    override fun getAppMenuLayoutId(): Int = R.menu.menu
                }
            }
    
            override fun shouldShowAppMenu(): Boolean = true
        },
        window.decorView
    )
    
    binding.btn.setOnTouchListener(
        coordinator.appMenuHandler.createAppMenuButtonHelper()
    )
  3. Check the sample for more customization.

More Usage

  • Change menu width

    Add this line to dimens.xml:

    <!-- 256dp is the original width -->
    <dimen name="cm_menu_width">258dp</dimen>

ChangeLog and Migration

  • 0.2.0

    • New usage
    • Target Android SDK 34, Min Android SDK 21, AGP 8.3.2, AppCompat 1.7.0
  • 0.1.1

    • Pull changes from chromium
      • fffabbc: IPH : Set focus to highlighted menu item after opening app menu
      • ead7304: Add common colors in night- and some initial clean up on themes
    • Add proguard rules #1.
  • 0.1.0

    To set custom menu width, use cm_menu_width instead of the old menu_width.

About

⚡ An Android menu library from Chromium-Android. Touch, move and select in one gesture.

Resources

License

Stars

Watchers

Forks

Packages

No packages published