Java Code Examples for android.content.res.Configuration#getLayoutDirection()

The following examples show how to use android.content.res.Configuration#getLayoutDirection() . 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: FlexibleSpaceWithImageGridViewActivity.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void setPivotXToTitle() {
    Configuration config = getResources().getConfiguration();
    if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT
            && config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        ViewHelper.setPivotX(mTitleView, findViewById(android.R.id.content).getWidth());
    } else {
        ViewHelper.setPivotX(mTitleView, 0);
    }
}
 
Example 2
Source File: DocumentsActivity.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int getGravity() {
    if(Utils.hasJellyBeanMR1()){
        Configuration config = getResources().getConfiguration();
        if(config.getLayoutDirection() != View.LAYOUT_DIRECTION_LTR){
            return Gravity.LEFT;
        }
    }
    return Gravity.RIGHT;
}
 
Example 3
Source File: DocumentsActivity.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int getGravity() {
    if(Utils.hasJellyBeanMR1()){
        Configuration config = getResources().getConfiguration();
        if(config.getLayoutDirection() != View.LAYOUT_DIRECTION_LTR){
            return Gravity.LEFT;
        }
    }
    return Gravity.RIGHT;
}
 
Example 4
Source File: MaterialMultiAutoCompleteTextView.java    From Social with Apache License 2.0 5 votes vote down vote up
@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
Source File: ShowHidePasswordEditText.java    From showhidepasswordedittext with Apache License 2.0 5 votes vote down vote up
private boolean isLeftToRight() {
    // If we are pre JB assume always LTR
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return true;
    }

    // Other methods, seemingly broken when testing though.
    // return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL
    // return !ViewUtils.isLayoutRtl(this);

    Configuration config = getResources().getConfiguration();
    return !(config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}
 
Example 6
Source File: Util.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
@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 7
Source File: FlexibleSpaceWithImageWithViewPagerTab2Activity.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void setPivotXToTitle() {
    Configuration config = getResources().getConfiguration();
    if (Build.VERSION_CODES.JELLY_BEAN_MR1 <= Build.VERSION.SDK_INT
            && config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        ViewHelper.setPivotX(mTitleView, findViewById(android.R.id.content).getWidth());
    } else {
        ViewHelper.setPivotX(mTitleView, 0);
    }
}
 
Example 8
Source File: Util.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
@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 9
Source File: Util.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@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 10
Source File: MaterialSimpleListAdapter.java    From talk-android with MIT License 5 votes vote down vote up
@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 = getContext().getResources().getConfiguration();
    return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 11
Source File: Util.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
@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 12
Source File: ShowHidePasswordEditText.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private boolean isLeftToRight() {
    // If we are pre JB assume always LTR
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return true;
    }

    // Other methods, seemingly broken when testing though.
    // return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL
    // return !ViewUtils.isLayoutRtl(this);

    Configuration config = getResources().getConfiguration();
    return !(config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}
 
Example 13
Source File: RecyclerFastScrollerUtils.java    From recycler-fast-scroll with Apache License 2.0 5 votes vote down vote up
public static boolean isRTL(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 14
Source File: MaterialMultiAutoCompleteTextView.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@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
Source File: Utils.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
public static boolean isRTL(Context ctx) {
    Configuration config = ctx.getResources().getConfiguration();
    return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 16
Source File: Utils.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
public static boolean isRTL(Context ctx) {
    Configuration config = ctx.getResources().getConfiguration();
    return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 17
Source File: BaseActivity.java    From prayer-times-android with Apache License 2.0 4 votes vote down vote up
protected boolean isRTL() {
    Configuration config = getResources().getConfiguration();
    return config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
 
Example 18
Source File: DynamicLanguage.java    From deltachat-android with GNU General Public License v3.0 4 votes vote down vote up
@RequiresApi(VERSION_CODES.JELLY_BEAN_MR1)
public static int getLayoutDirection(Context context) {
  Configuration configuration = context.getResources().getConfiguration();
  return configuration.getLayoutDirection();
}
 
Example 19
Source File: SettingsPinnedHeaderAdapter.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
@Override
protected void bindView(View v, int partition, Cursor cursor, int position) {
    TextView text = (TextView)v.findViewById(R.id.item_name);
    
 
    Configuration config = mLauncher.getResources().getConfiguration();
    if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
        text.setGravity(Gravity.RIGHT);
    }
    
    String title = cursor.getString(1);
    text.setText(title);

    v.setTag(new SettingsPosition(partition, position));

    Resources res = mLauncher.getResources();
    
    boolean current = false;
    String state = "";
    
    
    switch (partition) {
    case SettingsPanel.HOME_SETTINGS_POSITION:
        switch (position) {
            case 0:
                current = mLauncher.shouldShowSearchBar();
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 1:
                state = mLauncher.getWorkspaceTransitionEffect();
                state = mapEffectToValue(state);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 2:
                current = mLauncher.shouldHideWorkspaceIconLables();
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 3:
                current = SettingsProvider.getBoolean(mContext,
                        SettingsProvider.SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL,
                        R.bool.preferences_interface_homescreen_scrolling_wallpaper_scroll_default);
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            default:
                ((TextView) v.findViewById(R.id.item_state)).setText("");
        }
        break;
    case SettingsPanel.DRAWER_SETTINGS_POSITION:
        switch (position) {
            case 0:
                state = mLauncher.getAppsCustomizeTransitionEffect();
                state = mapEffectToValue(state);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            case 1:
                updateDrawerSortSettingsItem(v);
                break;
            case 2:
                current = SettingsProvider.getBoolean(mContext,
                        SettingsProvider.SETTINGS_UI_DRAWER_HIDE_ICON_LABELS,
                        R.bool.preferences_interface_drawer_hide_icon_labels_default);
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
            default:
                ((TextView) v.findViewById(R.id.item_state)).setText("");
        }
        break;
    default:
        switch (position) {
            case 0:
                current = SettingsProvider.getBoolean(mContext,
                        SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
                        R.bool.preferences_interface_general_icons_large_default);
                state = current ? res.getString(R.string.setting_state_on)
                        : res.getString(R.string.setting_state_off);
                ((TextView) v.findViewById(R.id.item_state)).setText(state);
                break;
           
                
            default:
                ((TextView) v.findViewById(R.id.item_state)).setText("");
        }
}

v.setOnClickListener(mSettingsItemListener);
    
}
 
Example 20
Source File: DynamicLanguage.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
static int getLayoutDirection(Context context) {
  Configuration configuration = context.getResources().getConfiguration();
  return configuration.getLayoutDirection();
}