Example usage for android.view View LAYOUT_DIRECTION_LTR

List of usage examples for android.view View LAYOUT_DIRECTION_LTR

Introduction

In this page you can find the example usage for android.view View LAYOUT_DIRECTION_LTR.

Prototype

int LAYOUT_DIRECTION_LTR

To view the source code for android.view View LAYOUT_DIRECTION_LTR.

Click Source Link

Document

Horizontal layout direction of this view is from Left to Right.

Usage

From source file:Main.java

public static int getLayoutDirection(View v) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return v.getLayoutDirection();
    }//from   ww  w.ja  v  a  2 s .c o  m

    return View.LAYOUT_DIRECTION_LTR;
}

From source file:Main.java

/**
 * @see Configuration#getLayoutDirection()
 *//* ww  w  .  ja  v a2 s .co m*/
public static int getLayoutDirection(Configuration configuration) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return configuration.getLayoutDirection();
    } else {
        // All layouts are LTR before JB MR1.
        return View.LAYOUT_DIRECTION_LTR;
    }
}

From source file:org.dbhatt.d_deleted_contact.Deleted_contact.java

Deleted_contact(ArrayList<org.dbhatt.d_deleted_contact.Data.Contact> all_contact, Context context,
        MainActivity mainActivity) {//from ww w  .j ava  2  s .  c o  m
    try {
        this.deleted_contact = all_contact;
        rnd = new Random();
        paint = new Paint();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            rtl = context.getResources().getConfiguration().getLayoutDirection() != View.LAYOUT_DIRECTION_LTR;
        this.context = context;
        this.mainActivity = mainActivity;
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.dbhatt.d_deleted_contact.All_contact.java

All_contact(ArrayList<org.dbhatt.d_deleted_contact.Data.Contact> all_contact, Context context,
        MainActivity mainActivity) {/*from   w w w . j av a  2 s.co m*/
    try {
        this.all_contact = all_contact;
        resolver = context.getContentResolver();
        rnd = new Random();
        paint = new Paint();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
            rtl = context.getResources().getConfiguration().getLayoutDirection() != View.LAYOUT_DIRECTION_LTR;
        this.context = context;
        this.mainActivity = mainActivity;
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.mozilla.focus.browser.LocalizedContent.java

private static void putLayoutDirectionIntoMap(WebView 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 {// w ww . ja v a2s.com
        direction = "auto";
    }

    substitutionMap.put("%dir%", direction);
}

From source file:android.support.graphics.drawable.VectorDrawableCommon.java

@Override
public int getLayoutDirection() {
    if (mDelegateDrawable != null) {
        DrawableCompat.getLayoutDirection(mDelegateDrawable);
    }/* w  ww .jav  a  2s .  c o  m*/
    return View.LAYOUT_DIRECTION_LTR;
}

From source file:org.jak_linux.dns66.ItemActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();/*from  ww w.j  a  va2  s .co m*/
    if (intent.getIntExtra("STATE_CHOICES", 3) == 2) {
        setContentView(R.layout.activity_item_dns);
        setTitle(R.string.activity_edit_dns_server);
    } else {
        setContentView(R.layout.activity_item);
        setTitle(R.string.activity_edit_filter);
    }

    titleText = (TextInputEditText) findViewById(R.id.title);
    locationText = (TextInputEditText) findViewById(R.id.location);
    stateSpinner = (Spinner) findViewById(R.id.state_spinner);
    stateSwitch = (Switch) findViewById(R.id.state_switch);
    imageView = (ImageView) findViewById(R.id.image_view);

    if (intent.hasExtra("ITEM_TITLE"))
        titleText.setText(intent.getStringExtra("ITEM_TITLE"));
    if (intent.hasExtra("ITEM_LOCATION"))
        locationText.setText(intent.getStringExtra("ITEM_LOCATION"));
    if (intent.hasExtra("ITEM_STATE") && stateSpinner != null)
        stateSpinner.setSelection(intent.getIntExtra("ITEM_STATE", 0));
    if (intent.hasExtra("ITEM_STATE") && stateSwitch != null)
        stateSwitch.setChecked(intent.getIntExtra("ITEM_STATE", 0) % 2 != 0);

    if (stateSpinner != null) {
        stateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                switch (position) {
                case Configuration.Item.STATE_ALLOW:
                    imageView.setImageDrawable(
                            ContextCompat.getDrawable(ItemActivity.this, R.drawable.ic_state_allow));
                    break;
                case Configuration.Item.STATE_DENY:
                    imageView.setImageDrawable(
                            ContextCompat.getDrawable(ItemActivity.this, R.drawable.ic_state_deny));
                    break;
                case Configuration.Item.STATE_IGNORE:
                    imageView.setImageDrawable(
                            ContextCompat.getDrawable(ItemActivity.this, R.drawable.ic_state_ignore));
                    break;
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
    }

    // We have an attachment icon for host files
    if (intent.getIntExtra("STATE_CHOICES", 3) == 3) {
        locationText.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                    boolean isAttachIcon;
                    if (locationText.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR)
                        isAttachIcon = event.getRawX() >= locationText.getRight()
                                - locationText.getTotalPaddingRight();
                    else
                        isAttachIcon = event.getRawX() <= locationText.getTotalPaddingLeft()
                                - locationText.getLeft();

                    if (isAttachIcon) {
                        performFileSearch();
                        return true;
                    }

                }
                return false;
            }
        });

        // Tint the attachment icon, if any.
        TypedValue typedValue = new TypedValue();
        getTheme().resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);

        Drawable[] compoundDrawables = locationText.getCompoundDrawablesRelative();
        for (Drawable drawable : compoundDrawables) {
            if (drawable != null) {
                drawable.setTint(ContextCompat.getColor(this, typedValue.resourceId));
                Log.d(TAG, "onCreate: Setting tint");
            }
        }
    }

}

From source file:com.android.contacts.common.list.ContactListItemView.java

static public final PhotoPosition getDefaultPhotoPosition(boolean opposite) {
    final Locale locale = Locale.getDefault();
    final int layoutDirection = TextUtils.getLayoutDirectionFromLocale(locale);
    switch (layoutDirection) {
    case View.LAYOUT_DIRECTION_RTL:
        return (opposite ? PhotoPosition.LEFT : PhotoPosition.RIGHT);
    case View.LAYOUT_DIRECTION_LTR:
    default://from  w w  w  . j a  v  a 2  s .c om
        return (opposite ? PhotoPosition.RIGHT : PhotoPosition.LEFT);
    }
}

From source file:io.plaidapp.ui.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);

    drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

    //toolbar.inflateMenu(R.menu.main);
    setActionBar(toolbar);//from  www  .j  ava2 s  . com
    if (savedInstanceState == null) {
        animateToolbar();
    }

    dribbblePrefs = DribbblePrefs.get(this);
    designerNewsPrefs = DesignerNewsPrefs.get(this);
    filtersAdapter = new FilterAdapter(this, SourceManager.getSources(this),
            new FilterAdapter.FilterAuthoriser() {
                @Override
                public void requestDribbbleAuthorisation(View sharedElemeent, Source forSource) {
                    Intent login = new Intent(HomeActivity.this, DribbbleLogin.class);
                    login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR,
                            ContextCompat.getColor(HomeActivity.this, R.color.background_dark));
                    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(HomeActivity.this,
                            sharedElemeent, getString(R.string.transition_dribbble_login));
                    startActivityForResult(login, getAuthSourceRequestCode(forSource), options.toBundle());
                }
            });
    dataManager = new DataManager(this, filtersAdapter) {
        @Override
        public void onDataLoaded(List<? extends PlaidItem> data) {
            adapter.addAndResort(data);
            checkEmptyState();
        }
    };
    adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this));
    grid.setAdapter(adapter);
    layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.getItemColumnSpan(position);
        }
    });
    grid.setLayoutManager(layoutManager);
    grid.addOnScrollListener(gridScroll);
    grid.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
        @Override
        public void onLoadMore() {
            dataManager.loadAllDataSources();
        }
    });
    grid.setHasFixedSize(true);
    grid.addItemDecoration(new GridItemDividerDecoration(adapter.getDividedViewHolderClasses(), this,
            R.dimen.divider_height, R.color.divider));
    grid.setItemAnimator(new HomeGridItemAnimator());

    // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves
    drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // inset the toolbar down by the status bar height
            ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
            lpToolbar.topMargin += insets.getSystemWindowInsetTop();
            lpToolbar.rightMargin += insets.getSystemWindowInsetRight();
            toolbar.setLayoutParams(lpToolbar);

            // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip)
            grid.setPadding(grid.getPaddingLeft(),
                    insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this),
                    grid.getPaddingRight() + insets.getSystemWindowInsetRight(), // landscape
                    grid.getPaddingBottom());

            // inset the fab for the navbar
            ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams();
            lpFab.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait
            lpFab.rightMargin += insets.getSystemWindowInsetRight(); // landscape
            fab.setLayoutParams(lpFab);

            // we place a background behind the status bar to combine with it's semi-transparent
            // color to get the desired appearance.  Set it's height to the status bar height
            View statusBarBackground = findViewById(R.id.status_bar_background);
            FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground
                    .getLayoutParams();
            lpStatus.height = insets.getSystemWindowInsetTop();
            statusBarBackground.setLayoutParams(lpStatus);

            // inset the filters list for the status bar / navbar
            // need to set the padding end for landscape case
            final boolean ltr = filtersList.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
            filtersList.setPaddingRelative(filtersList.getPaddingStart(),
                    filtersList.getPaddingTop() + insets.getSystemWindowInsetTop(),
                    filtersList.getPaddingEnd() + (ltr ? insets.getSystemWindowInsetRight() : 0),
                    filtersList.getPaddingBottom() + insets.getSystemWindowInsetBottom());

            // clear this listener so insets aren't re-applied
            drawer.setOnApplyWindowInsetsListener(null);

            return insets.consumeSystemWindowInsets();
        }
    });
    setupTaskDescription();

    filtersList.setAdapter(filtersAdapter);
    filtersAdapter.addFilterChangedListener(filtersChangedListener);
    filtersAdapter.addFilterChangedListener(dataManager);
    dataManager.loadAllDataSources();
    ItemTouchHelper.Callback callback = new FilterTouchHelperCallback(filtersAdapter);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
    itemTouchHelper.attachToRecyclerView(filtersList);
    checkEmptyState();
    checkConnectivity();
}

From source file:com.android.printspooler.widget.PrintContentView.java

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    mStaticContent.layout(left, top, right, mStaticContent.getMeasuredHeight());

    if (mSummaryContent.getVisibility() != View.GONE) {
        mSummaryContent.layout(left, mStaticContent.getMeasuredHeight(), right,
                mStaticContent.getMeasuredHeight() + mSummaryContent.getMeasuredHeight());
    }//from  w  ww .  j a v  a  2 s.co  m

    final int dynContentTop = mStaticContent.getMeasuredHeight() + mCurrentOptionsOffsetY;
    final int dynContentBottom = dynContentTop + mDynamicContent.getMeasuredHeight();

    mDynamicContent.layout(left, dynContentTop, right, dynContentBottom);

    MarginLayoutParams params = (MarginLayoutParams) mPrintButton.getLayoutParams();

    final int printButtonLeft;
    if (getLayoutDirection() == View.LAYOUT_DIRECTION_LTR) {
        printButtonLeft = right - mPrintButton.getMeasuredWidth() - params.getMarginStart();
    } else {
        printButtonLeft = left + params.getMarginStart();
    }
    final int printButtonTop = dynContentBottom - mPrintButton.getMeasuredHeight() / 2;
    final int printButtonRight = printButtonLeft + mPrintButton.getMeasuredWidth();
    final int printButtonBottom = printButtonTop + mPrintButton.getMeasuredHeight();

    mPrintButton.layout(printButtonLeft, printButtonTop, printButtonRight, printButtonBottom);

    final int embContentTop = mStaticContent.getMeasuredHeight() + mClosedOptionsOffsetY
            + mDynamicContent.getMeasuredHeight();
    final int embContentBottom = embContentTop + mEmbeddedContentContainer.getMeasuredHeight();

    mEmbeddedContentContainer.layout(left, embContentTop, right, embContentBottom);
}