Java Code Examples for android.view.View.LAYOUT_DIRECTION_RTL

The following are Jave code examples for showing how to use LAYOUT_DIRECTION_RTL of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: firefox-tv   File: LocalizedContent.java   Source Code and License Vote up 6 votes
private static void putLayoutDirectionIntoMap(AmazonWebView webView, Map<String, String> substitutionMap) {
    ViewCompat.setLayoutDirection(webView, View.LAYOUT_DIRECTION_LOCALE);
    final int layoutDirection = ViewCompat.getLayoutDirection(webView);

    final String direction;

    if (layoutDirection == View.LAYOUT_DIRECTION_LTR) {
        direction = "ltr";
    } else if (layoutDirection == View.LAYOUT_DIRECTION_RTL) {
        direction = "rtl";
    } else {
        direction = "auto";
    }

    substitutionMap.put("%dir%", direction);
}
 
Example 2
Project: aos-Video   File: TitleHelper.java   Source Code and License Vote up 6 votes
@Override
public View onFocusSearch(View focused, int direction) {
    if (focused != mTitleView && direction == View.FOCUS_UP) {
        return mTitleView;
    }
    final boolean isRtl = ViewCompat.getLayoutDirection(focused) ==
            View.LAYOUT_DIRECTION_RTL;
    //final int forward = isRtl ? View.FOCUS_LEFT : View.FOCUS_RIGHT;
    if (mTitleView.hasFocus() && direction == View.FOCUS_DOWN /*|| direction == forward*/) {
        return mSceneRoot;
    }
    return null;
}
 
Example 3
Project: GitHub   File: MaterialAutoCompleteTextView.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private boolean isRTL() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
    return false;
  }
  Configuration config = getResources().getConfiguration();
  return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 4
Project: GitHub   File: MaterialMultiAutoCompleteTextView.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private boolean isRTL() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
    return false;
  }
  Configuration config = getResources().getConfiguration();
  return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 5
Project: GitHub   File: MaterialEditText.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private boolean isRTL() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
    return false;
  }
  Configuration config = getResources().getConfiguration();
  return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 6
Project: GitHub   File: GravityDelegate.java   Source Code and License Vote up 5 votes
public void attachToRecyclerView(@NonNull RecyclerView recyclerView) {
    if (recyclerView != null) {
        if ((gravity == Gravity.START || gravity == Gravity.END)
                && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            isRtlHorizontal
                    = recyclerView.getContext().getResources().getConfiguration()
                    .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        }
        if (listener != null) {
            recyclerView.addOnScrollListener(mScrollListener);
        }
    }
}
 
Example 7
Project: RetroMusicPlayer   File: Util.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isRTL(@NonNull Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Configuration config = context.getResources().getConfiguration();
        return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    } else return false;
}
 
Example 8
Project: GravityBox   File: TouchInterceptor.java   Source Code and License Vote up 5 votes
private boolean shouldStartDragging(int x, int draggerWidth) {
    Configuration c = getResources().getConfiguration();
    switch (c.getLayoutDirection()) {
        case View.LAYOUT_DIRECTION_RTL:
            return (x >= (getWidth() - draggerWidth));
        default:
            return (x <= draggerWidth);
    }
}
 
Example 9
Project: Espresso   File: FastScrollPopup.java   Source Code and License Vote up 5 votes
public void draw(Canvas canvas) {
    if (isVisible()) {
        // Draw the fast scroller popup
        int restoreCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
        canvas.translate(mBgBounds.left, mBgBounds.top);
        mTmpRect.set(mBgBounds);
        mTmpRect.offsetTo(0, 0);

        mBackgroundPath.reset();
        mBackgroundRect.set(mTmpRect);

        float[] radii;

        if (mRes.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
            radii = new float[]{mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, 0, 0};
        } else {

            radii = new float[]{mCornerRadius, mCornerRadius, mCornerRadius, mCornerRadius, 0, 0, mCornerRadius, mCornerRadius};
        }

        mBackgroundPath.addRoundRect(mBackgroundRect, radii, Path.Direction.CW);

        mBackgroundPaint.setAlpha((int) (mAlpha * 255));
        mTextPaint.setAlpha((int) (mAlpha * 255));
        canvas.drawPath(mBackgroundPath, mBackgroundPaint);
        canvas.drawText(mSectionName, (mBgBounds.width() - mTextBounds.width()) / 2,
                mBgBounds.height() - (mBgBounds.height() - mTextBounds.height()) / 2,
                mTextPaint);
        canvas.restoreToCount(restoreCount);
    }
}
 
Example 10
Project: AcademApp   File: MaterialIn.java   Source Code and License Vote up 5 votes
private static int convertGravity(View view, int gravity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        boolean isRtl = view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        if (gravity == Gravity.START) {
            gravity = isRtl ? Gravity.RIGHT : Gravity.LEFT;
        } else if (gravity == Gravity.END) {
            gravity = isRtl ? Gravity.LEFT : Gravity.RIGHT;
        }
    }
    return gravity;
}
 
Example 11
Project: SetupWizardLibCompat   File: DrawableLayoutDirectionHelper.java   Source Code and License Vote up 5 votes
/**
 * Creates an {@link android.graphics.drawable.InsetDrawable} according to the layout direction
 * of {@code view}.
 */
public static InsetDrawable createRelativeInsetDrawable(Drawable drawable,
        int insetStart, int insetTop, int insetEnd, int insetBottom, View view) {
    boolean isRtl = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1
            && view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
    return createRelativeInsetDrawable(drawable, insetStart, insetTop, insetEnd, insetBottom,
            isRtl);
}
 
Example 12
Project: Orin   File: GravityDelegate.java   Source Code and License Vote up 5 votes
public void attachToRecyclerView(@NonNull RecyclerView recyclerView) {
    if (recyclerView != null) {
        if ((gravity == Gravity.START || gravity == Gravity.END)
                && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            isRtlHorizontal
                    = recyclerView.getContext().getResources().getConfiguration()
                    .getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        }
        if (listener != null) {
            recyclerView.addOnScrollListener(mScrollListener);
        }
    }
}
 
Example 13
Project: iosched-reader   File: UIUtils.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isRtl(final Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return false;
    } else {
        return context.getResources().getConfiguration().getLayoutDirection()
                == View.LAYOUT_DIRECTION_RTL;
    }
}
 
Example 14
Project: XERUNG   File: MaterialEditText.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private boolean isRTL() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
    return false;
  }
  Configuration config = getResources().getConfiguration();
  return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 15
Project: file.io-app   File: MaterialIn.java   Source Code and License Vote up 5 votes
private static int convertGravity(View view, int gravity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        boolean isRtl = view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        if (gravity == Gravity.START) {
            gravity = isRtl ? Gravity.RIGHT : Gravity.LEFT;
        } else if (gravity == Gravity.END) {
            gravity = isRtl ? Gravity.LEFT : Gravity.RIGHT;
        }
    }
    return gravity;
}
 
Example 16
Project: SimpleUILauncher   File: LauncherAccessibilityDelegate.java   Source Code and License Vote up 5 votes
@Thunk void performResizeAction(int action, View host, LauncherAppWidgetInfo info) {
    CellLayout.LayoutParams lp = (CellLayout.LayoutParams) host.getLayoutParams();
    CellLayout layout = (CellLayout) host.getParent().getParent();
    layout.markCellsAsUnoccupiedForView(host);

    if (action == R.string.action_increase_width) {
        if (((host.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL)
                && layout.isRegionVacant(info.cellX - 1, info.cellY, 1, info.spanY))
                || !layout.isRegionVacant(info.cellX + info.spanX, info.cellY, 1, info.spanY)) {
            lp.cellX --;
            info.cellX --;
        }
        lp.cellHSpan ++;
        info.spanX ++;
    } else if (action == R.string.action_decrease_width) {
        lp.cellHSpan --;
        info.spanX --;
    } else if (action == R.string.action_increase_height) {
        if (!layout.isRegionVacant(info.cellX, info.cellY + info.spanY, info.spanX, 1)) {
            lp.cellY --;
            info.cellY --;
        }
        lp.cellVSpan ++;
        info.spanY ++;
    } else if (action == R.string.action_decrease_height) {
        lp.cellVSpan --;
        info.spanY --;
    }

    layout.markCellsAsOccupiedForView(host);
    Rect sizeRange = new Rect();
    AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, sizeRange);
    ((LauncherAppWidgetHostView) host).updateAppWidgetSize(null,
            sizeRange.left, sizeRange.top, sizeRange.right, sizeRange.bottom);
    host.requestLayout();
    LauncherModel.updateItemInDatabase(mLauncher, info);
    announceConfirmation(mLauncher.getString(R.string.widget_resized, info.spanX, info.spanY));
}
 
Example 17
Project: Cable-Android   File: ViewUtil.java   Source Code and License Vote up 5 votes
@SuppressLint("RtlHardcoded")
public static void setTextViewGravityStart(final @NonNull TextView textView, @NonNull Context context) {
  if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
    if (DynamicLanguage.getLayoutDirection(context) == View.LAYOUT_DIRECTION_RTL) {
      textView.setGravity(Gravity.RIGHT);
    } else {
      textView.setGravity(Gravity.LEFT);
    }
  }
}
 
Example 18
Project: FlickLauncher   File: AppWidgetManagerCompatVL.java   Source Code and License Vote up 5 votes
@Override
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
        int imageWidth, int imageHeight) {
    if (info.isCustomWidget || info.getProfile().equals(android.os.Process.myUserHandle())) {
        return bitmap;
    }

    // Add a user badge in the bottom right of the image.
    final Resources res = mContext.getResources();
    final int badgeMinTop = res.getDimensionPixelSize(R.dimen.profile_badge_minimum_top);

    // choose min between badge size defined for widget tray versus width, height of the image.
    // Width, height of the image can be smaller than widget tray badge size when being dropped
    // to the workspace.
    final int badgeSize = Math.min(res.getDimensionPixelSize(R.dimen.profile_badge_size),
            Math.min(imageWidth, imageHeight - badgeMinTop));
    final Rect badgeLocation = new Rect(0, 0, badgeSize, badgeSize);

    final int top = Math.max(imageHeight - badgeSize, badgeMinTop);

    if (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        badgeLocation.offset(0, top);
    } else {
        badgeLocation.offset(bitmap.getWidth() - badgeSize, top);
    }

    Drawable drawable = mPm.getUserBadgedDrawableForDensity(
            new BitmapDrawable(res, bitmap), info.getProfile(), badgeLocation, 0);

    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    }

    bitmap.eraseColor(Color.TRANSPARENT);
    Canvas c = new Canvas(bitmap);
    drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
    drawable.draw(c);
    c.setBitmap(null);
    return bitmap;
}
 
Example 19
Project: GitHub   File: DefaultRvAdapter.java   Source Code and License Vote up 4 votes
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private boolean isRTL() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
        return false;
    Configuration config = dialog.getBuilder().getContext().getResources().getConfiguration();
    return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 20
Project: GravityBox   File: Utils.java   Source Code and License Vote up 4 votes
public static boolean isRTL(Configuration config) {
    return (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}