Java Code Examples for org.chromium.ui.widget.Toast#makeText()

The following examples show how to use org.chromium.ui.widget.Toast#makeText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToolbarLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Shows the content description toast for items on the toolbar.
 * @param view The view to anchor the toast.
 * @param description The string shown in the toast.
 * @return Whether a toast has been shown successfully.
 */
protected boolean showAccessibilityToast(View view, CharSequence description) {
    if (description == null) return false;

    final int screenWidth = getResources().getDisplayMetrics().widthPixels;
    final int[] screenPos = new int[2];
    view.getLocationOnScreen(screenPos);
    final int width = view.getWidth();

    Toast toast = Toast.makeText(getContext(), description, Toast.LENGTH_SHORT);
    toast.setGravity(
            Gravity.TOP | Gravity.END,
            screenWidth - screenPos[0] - width / 2,
            screenPos[1] + getHeight() / 2);
    toast.show();
    return true;
}
 
Example 2
Source File: ToolbarLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Shows the content description toast for items on the toolbar.
 * @param view The view to anchor the toast.
 * @param description The string shown in the toast.
 * @return Whether a toast has been shown successfully.
 */
protected boolean showAccessibilityToast(View view, CharSequence description) {
    if (description == null) return false;

    final int screenWidth = getResources().getDisplayMetrics().widthPixels;
    final int[] screenPos = new int[2];
    view.getLocationOnScreen(screenPos);
    final int width = view.getWidth();

    Toast toast = Toast.makeText(getContext(), description, Toast.LENGTH_SHORT);
    toast.setGravity(
            Gravity.TOP | Gravity.END,
            screenWidth - screenPos[0] - width / 2,
            screenPos[1] + getHeight() / 2);
    toast.show();
    return true;
}
 
Example 3
Source File: AccessibilityUtil.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Shows the content description toast for items on the toolbar.
 * @param context The context to use for the toast.
 * @param view The view to anchor the toast.
 * @param description The string shown in the toast.
 * @return Whether a toast has been shown successfully.
 */
public static boolean showAccessibilityToast(
        Context context, View view, CharSequence description) {
    if (description == null) return false;

    final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
    final int screenHeight = context.getResources().getDisplayMetrics().heightPixels;
    final int[] screenPos = new int[2];
    view.getLocationOnScreen(screenPos);
    final int width = view.getWidth();
    final int height = view.getHeight();

    Toast toast = Toast.makeText(context, description, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.TOP | Gravity.END, screenWidth - screenPos[0] - width / 2,
            (screenPos[1] < screenHeight / 2) ? screenPos[1] + height / 2
                                              : screenPos[1] - height * 3 / 2);
    toast.show();
    return true;
}
 
Example 4
Source File: FullscreenHtmlApiHandler.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Create and show the fullscreen notification toast.
 */
private void showNotificationToast() {
    if (mNotificationToast == null) {
        int resId = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
                ? R.string.immersive_fullscreen_api_notification
                : R.string.fullscreen_api_notification;
        mNotificationToast = Toast.makeText(
                mWindow.getContext(), resId, Toast.LENGTH_LONG);
        mNotificationToast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 0);
    }
    mNotificationToast.show();
}
 
Example 5
Source File: AbstractMediaRouteController.java    From delion with Apache License 2.0 5 votes vote down vote up
protected void showCastError(String routeName) {
    Toast toast = Toast.makeText(
            getContext(),
            getContext().getString(R.string.cast_error_playing_video, routeName),
            Toast.LENGTH_SHORT);
    toast.show();
}
 
Example 6
Source File: FullscreenHtmlApiHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Create and show the fullscreen notification toast.
 */
private void showNotificationToast() {
    if (mNotificationToast == null) {
        int resId = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
                ? R.string.immersive_fullscreen_api_notification
                : R.string.fullscreen_api_notification;
        mNotificationToast = Toast.makeText(
                mWindow.getContext(), resId, Toast.LENGTH_LONG);
        mNotificationToast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 0);
    }
    mNotificationToast.show();
}
 
Example 7
Source File: AbstractMediaRouteController.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
protected void showCastError(String routeName) {
    Toast toast = Toast.makeText(
            getContext(),
            getContext().getString(R.string.cast_error_playing_video, routeName),
            Toast.LENGTH_SHORT);
    toast.show();
}
 
Example 8
Source File: FullscreenHtmlApiHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Create and show the fullscreen notification toast.
 */
private void showNotificationToast() {
    if (mNotificationToast == null) {
        int resId = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
                ? R.string.immersive_fullscreen_api_notification
                : R.string.fullscreen_api_notification;
        mNotificationToast = Toast.makeText(
                mWindow.getContext(), resId, Toast.LENGTH_LONG);
        mNotificationToast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 0);
    }
    mNotificationToast.show();
}
 
Example 9
Source File: AbstractMediaRouteController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
protected void showCastError(String routeName) {
    Toast toast = Toast.makeText(
            getContext(),
            getContext().getString(R.string.cast_error_playing_video, routeName),
            Toast.LENGTH_SHORT);
    toast.show();
}
 
Example 10
Source File: RemoteMediaPlayerController.java    From delion with Apache License 2.0 4 votes vote down vote up
private void showMessageToast(String message) {
    Toast toast = Toast.makeText(mCastContextApplicationContext, message, Toast.LENGTH_SHORT);
    toast.show();
}
 
Example 11
Source File: RemoteMediaPlayerController.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void showMessageToast(String message) {
    Toast toast = Toast.makeText(mCastContextApplicationContext, message, Toast.LENGTH_SHORT);
    toast.show();
}
 
Example 12
Source File: RemoteMediaPlayerController.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private void showMessageToast(String message) {
    Toast toast = Toast.makeText(mCastContextApplicationContext, message, Toast.LENGTH_SHORT);
    toast.show();
}