/*
 * Copyright 2015 - 2019 Michael Rapp
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package de.mrapp.android.util.view;

import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.appcompat.widget.Toolbar;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * By default, the AppCompat support library's Toolbar does consume all touch events,
 * regardless of whether the "focusable" attribute is set, or not. This class extend the class
 * Toolbar to enable touch events to be passed to other views in the event processing chain,
 * if the "focusable" attribute is set to false. If it is set to true, the toolbar behaves exactly
 * like the original one.
 *
 * @author Michael Rapp
 * @since 1.16.0
 */
public class UnfocusableToolbar extends Toolbar {

    /**
     * Creates a toolbar, which enables touch events to be passed to other views in the event
     * processing chain, if the "focusable" attribute is set to false.
     *
     * @param context
     *         The context, which should be used by the image view, as an instance of the class
     *         {@link Context}. The context may not be null
     */
    public UnfocusableToolbar(@NonNull final Context context) {
        super(context);
    }

    /**
     * Creates a toolbar, which enables touch events to be passed to other views in the event
     * processing chain, if the "focusable" attribute is set to false.
     *
     * @param context
     *         The context, which should be used by the image view, as an instance of the class
     *         {@link Context}. The context may not be null
     * @param attributeSet
     *         The attributes of the XML tag that is inflating the view, as an instance of the type
     *         {@link AttributeSet} or null, if no attributes are available
     */
    public UnfocusableToolbar(@NonNull final Context context,
                              @Nullable final AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    /**
     * Creates a toolbar, which enables touch events to be passed to other views in the event
     * processing chain, if the "focusable" attribute is set to false.
     *
     * @param context
     *         The context, which should be used by the image view, as an instance of the class
     *         {@link Context}. The context may not be null
     * @param attributeSet
     *         The attributes of the XML tag that is inflating the view, as an instance of the type
     *         {@link AttributeSet} or null, if no attributes are available
     * @param defaultStyle
     *         The default style to apply to this view. If 0, no style will be applied (beyond what
     *         is included in the theme). This may either be an attribute resource, whose value will
     *         be retrieved from the current theme, or an explicit style resource
     */
    public UnfocusableToolbar(@NonNull final Context context,
                              @Nullable final AttributeSet attributeSet,
                              @StyleRes final int defaultStyle) {
        super(context, attributeSet, defaultStyle);
    }

    @Override
    public final boolean onTouchEvent(final MotionEvent event) {
        boolean handled = super.onTouchEvent(event);
        return isFocusable() && handled;
    }

}
@@ -655,16 +655,84 @@
 ontext;%0A
+import android.util.AttributeSet;%0Aimport android.view.MotionEvent;%0A%0A
 import a
@@ -878,75 +878,8 @@
 bar;
-%0Aimport android.util.AttributeSet;%0Aimport android.view.MotionEvent;
 %0A%0A/*
@@ -965,19 +965,16 @@
  events,
-%0A *
  regardl
@@ -979,16 +979,19 @@
 dless of
+%0A *
  whether
@@ -1060,19 +1060,16 @@
 he class
-%0A *
  Toolbar
@@ -1078,16 +1078,19 @@
 o enable
+%0A *
  touch e
@@ -1153,19 +1153,16 @@
 g chain,
-%0A *
  if the 
@@ -1164,32 +1164,35 @@
  the %22focusable%22
+%0A *
  attribute is se
@@ -1252,19 +1252,16 @@
  exactly
-%0A *
  like th
@@ -1270,16 +1270,19 @@
 original
+%0A *
  one.%0A *
@@ -3754,22 +3754,16 @@
  public 
-final 
 boolean 
@@ -3901,11 +3901,109 @@
 d;%0A    %7D
+%0A    %0A    @Override%0A    public boolean performClick() %7B%0A        return super.performClick();%0A    %7D
 %0A%0A%7D

Fix warning.