oviroa
oviroa

Reputation: 1099

Wearable Action Drawer broke after upgrading to the release of Wear 2.0.0

I have an acton drawer in my view, with 3 items, pulled from a menu xml file.

<android.support.wearable.view.drawer.WearableActionDrawer
    android:id="@+id/bottom_action_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:action_menu="@menu/action_drawer_menu"
    android:background="@color/menu_background"/>

The menu file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/menu_calibrate"
        android:icon="@drawable/ic_balls"
        android:title="@string/calibrate_shots"/>
    <item android:id="@+id/menu_play"
        android:icon="@drawable/ic_tennis"
        android:title="@string/play_session" />
    <item android:id="@+id/menu_sync"
        android:icon="@drawable/ic_synchronize"
        android:title="@string/sync_sessions" />
</menu>

When compiling with com.google.android.support:wearable:2.0.0-alpha3, everything works fine, when I tab on the "peek" edge of the menu, the menu opens up fine. Wut when using com.google.android.support:wearable:2.0.0, tapping on the "peek" edge just runs the onclick event for the first item in the menu. Java code for the onclick:

@Override
    public boolean onMenuItemClick(MenuItem menuItem) {
        if(menuItem.getTitle().toString().equals(getResources().getString(R.string.play_session))) {
            startStartPlayActivity();
        } else if(menuItem.getTitle().toString().equals(getResources().getString(R.string.calibrate_shots))) {
            startStartCalibrationActivity();
        } else if(menuItem.getTitle().toString().equals(getResources().getString(R.string.sync_sessions))) {
            startSyncActiviy();
        } 
        mContainerView.peekDrawer(Gravity.BOTTOM);
        return false;
    }

Any ideas if this is a bug of the release or there's something I'm doing wrong? I am testing on LG Urbane 2nd gen LTE.

Upvotes: 0

Views: 280

Answers (1)

ianhanniballake
ianhanniballake

Reputation: 199825

Per the Peeking Drawers documentation:

By default, the action drawer shows the first action with a chevron symbol when there is more than one action.

Therefore clicking on the peeking drawer is supposed to trigger the first action. It continues to say:

If you prefer to display just the overflow icon (3 vertical dots) without the first action, you can override the default behavior by setting the show_overflow_in_peek flag to true.

 <android.support.wearable.view.drawer.WearableActionDrawer
      android:id="@+id/bottom_drawer"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/holo_blue_dark"
      app:show_overflow_in_peek="true"/>

Upvotes: 2

Related Questions