public interface

IFloatingToolbar

 androidx.textclassifier.widget.IFloatingToolbar

Gradle dependencies

compile group: 'androidx.textclassifier', name: 'textclassifier', version: '1.0.0-alpha04'

  • groupId: androidx.textclassifier
  • artifactId: textclassifier
  • version: 1.0.0-alpha04

Artifact androidx.textclassifier:textclassifier:1.0.0-alpha04 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.textclassifier:textclassifier com.android.support:textclassifier

Overview

A floating toolbar for showing contextual menu items.

Summary

Fields
public static final intMENU_ID_SMART_ACTION

Methods
public voiddismiss()

Dismisses this floating toolbar.

public SupportMenugetMenu()

Returns the currently set menu.

public voidhide()

Hides this floating toolbar.

public booleanisHidden()

Returns true if this toolbar is currently hidden.

public booleanisShowing()

Returns true if this toolbar is currently showing.

public voidsetContentRect(Rect rect)

Sets the content rectangle.

public voidsetDismissOnMenuItemClick(boolean dismiss)

Sets whether or not to dismiss the floating toolbar after a menu item click has been handled.

public voidsetMenu(SupportMenu menu)

Sets the menu to be shown in this floating toolbar.

public voidsetOnDismissListener(PopupWindow.OnDismissListener onDismiss)

Sets the floating toolbar's onDismissListener.

public voidsetOnMenuItemClickListener(androidx.core.internal.view.SupportMenuItem.OnMenuItemClickListener menuItemClickListener)

Sets the custom listener for invocation of menu items in this floating toolbar.

public voidsetSuggestedWidth(int suggestedWidth)

Sets the suggested width of this floating toolbar.

public voidshow()

Shows this floating toolbar.

public voidupdateLayout()

Updates this floating toolbar to reflect recent position and view updates.

Fields

public static final int MENU_ID_SMART_ACTION

Methods

public void setMenu(SupportMenu menu)

Sets the menu to be shown in this floating toolbar. NOTE: Call IFloatingToolbar.updateLayout() or IFloatingToolbar.show() to effect visual changes to the toolbar.

public SupportMenu getMenu()

Returns the currently set menu.

public void setOnMenuItemClickListener(androidx.core.internal.view.SupportMenuItem.OnMenuItemClickListener menuItemClickListener)

Sets the custom listener for invocation of menu items in this floating toolbar.

public void setContentRect(Rect rect)

Sets the content rectangle. This is the area of the interesting content that this toolbar should avoid obstructing. NOTE: Call IFloatingToolbar.updateLayout() or IFloatingToolbar.show() to effect visual changes to the toolbar.

public void setSuggestedWidth(int suggestedWidth)

Sets the suggested width of this floating toolbar. The actual width will be about this size but there are no guarantees that it will be exactly the suggested width. NOTE: Call IFloatingToolbar.updateLayout() or IFloatingToolbar.show() to effect visual changes to the toolbar.

public void show()

Shows this floating toolbar.

public void updateLayout()

Updates this floating toolbar to reflect recent position and view updates. NOTE: This method is a no-op if the toolbar isn't showing.

public void dismiss()

Dismisses this floating toolbar.

public void hide()

Hides this floating toolbar. This is a no-op if the toolbar is not showing. Use IFloatingToolbar.isHidden() to distinguish between a hidden and a dismissed toolbar.

public boolean isShowing()

Returns true if this toolbar is currently showing. false otherwise.

public boolean isHidden()

Returns true if this toolbar is currently hidden. false otherwise.

public void setOnDismissListener(PopupWindow.OnDismissListener onDismiss)

Sets the floating toolbar's onDismissListener.

public void setDismissOnMenuItemClick(boolean dismiss)

Sets whether or not to dismiss the floating toolbar after a menu item click has been handled.

Source

/*
 * Copyright 2019 The Android Open Source Project
 *
 * 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 androidx.textclassifier.widget;

import static androidx.annotation.RestrictTo.Scope.LIBRARY;

import android.graphics.Rect;
import android.widget.PopupWindow;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.internal.view.SupportMenu;
import androidx.core.internal.view.SupportMenuItem;
import androidx.textclassifier.R;

/**
 * A floating toolbar for showing contextual menu items.
 *
 * @hide
 */
@RestrictTo(LIBRARY)
public interface IFloatingToolbar {
    int MENU_ID_SMART_ACTION = R.id.smartAction;

    /**
     * Sets the menu to be shown in this floating toolbar.
     * NOTE: Call {@link #updateLayout()} or {@link #show()} to effect visual changes to the
     * toolbar.
     */
    void setMenu(@NonNull SupportMenu menu);

    /**
     * Returns the currently set menu.
     */
    @Nullable
    SupportMenu getMenu();

    /**
     * Sets the custom listener for invocation of menu items in this floating toolbar.
     */
    void setOnMenuItemClickListener(
            @Nullable SupportMenuItem.OnMenuItemClickListener menuItemClickListener);

    /**
     * Sets the content rectangle. This is the area of the interesting content that this toolbar
     * should avoid obstructing.
     * NOTE: Call {@link #updateLayout()} or {@link #show()} to effect visual changes to the
     * toolbar.
     */
    void setContentRect(@NonNull Rect rect);

    /**
     * Sets the suggested width of this floating toolbar.
     * The actual width will be about this size but there are no guarantees that it will be exactly
     * the suggested width.
     * NOTE: Call {@link #updateLayout()} or {@link #show()} to effect visual changes to the
     * toolbar.
     */
    void setSuggestedWidth(int suggestedWidth);

    /**
     * Shows this floating toolbar.
     */
    void show();

    /**
     * Updates this floating toolbar to reflect recent position and view updates.
     * NOTE: This method is a no-op if the toolbar isn't showing.
     */
    void updateLayout();

    /**
     * Dismisses this floating toolbar.
     */
    void dismiss();

    /**
     * Hides this floating toolbar. This is a no-op if the toolbar is not showing.
     * Use {@link #isHidden()} to distinguish between a hidden and a dismissed toolbar.
     */
    void hide();

    /**
     * Returns {@code true} if this toolbar is currently showing. {@code false} otherwise.
     */
    boolean isShowing();

    /**
     * Returns {@code true} if this toolbar is currently hidden. {@code false} otherwise.
     */
    boolean isHidden();

    /**
     * Sets the floating toolbar's onDismissListener.
     */
    void setOnDismissListener(@Nullable PopupWindow.OnDismissListener onDismiss);

    /**
     * Sets whether or not to dismiss the floating toolbar after a menu item click has been handled.
     */
    void setDismissOnMenuItemClick(boolean dismiss);
}