List of usage examples for android.view View LAYOUT_DIRECTION_RTL
int LAYOUT_DIRECTION_RTL
To view the source code for android.view View LAYOUT_DIRECTION_RTL.
Click Source Link
From source file:org.catrobat.paintroid.MainActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); initLocaleConfiguration();//from w ww . j ava2 s . c om Configuration config = getApplicationContext().getResources().getConfiguration(); PaintroidApplication.isRTL = (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL); ColorPickerDialog.getInstance().dismiss(); ColorPickerDialog.init(this); boolean isShowing = IndeterminateProgressDialog.getInstance().isShowing(); IndeterminateProgressDialog.getInstance().dismiss(); IndeterminateProgressDialog.init(this); if (isShowing) { IndeterminateProgressDialog.getInstance().show(); } BrushPickerView.init(this); setContentView(R.layout.main); View mainView = findViewById(R.id.drawer_layout); mainView.setLayoutDirection( PaintroidApplication.isRTL ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR); initActionBar(); mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); hideKeyboard(); PaintroidApplication.orientation = getResources().getConfiguration().orientation; PaintroidApplication.drawingSurface = (DrawingSurface) findViewById(R.id.drawingSurfaceView); PaintroidApplication.perspective = new Perspective(PaintroidApplication.drawingSurface.getHolder()); mDrawingSurfaceListener = new DrawingSurfaceListener(); mBottomBar = new BottomBar(this); mTopBar = new TopBar(this, PaintroidApplication.openedFromCatroid); mLayerSideNav = (NavigationView) findViewById(R.id.nav_view_layer); mLayersAdapter = new LayersAdapter(this, PaintroidApplication.openedFromCatroid, PaintroidApplication.drawingSurface.getBitmapCopy()); int colorPickerBackgroundColor = PaintroidApplication.colorPickerInitialColor; ColorPickerDialog.getInstance().setInitialColor(colorPickerBackgroundColor); PaintroidApplication.drawingSurface.setOnTouchListener(mDrawingSurfaceListener); PaintroidApplication.drawingSurface.resetBitmap(LayerListener.getInstance().getCurrentLayer().getImage()); PaintroidApplication.perspective.resetScaleAndTranslation(); PaintroidApplication.currentTool.resetInternalState(Tool.StateChange.NEW_IMAGE_LOADED); LayerListener.init(this, mLayerSideNav, PaintroidApplication.drawingSurface.getBitmapCopy(), true); initNavigationDrawer(); initKeyboardIsShownListener(); setFullScreen(false); ((CommandManagerImplementation) PaintroidApplication.commandManager).setUpdateTopBarListener(mTopBar); UndoRedoManager.getInstance().update(); }
From source file:com.example.client.activity.imported.FlexibleSpaceWithImageWithViewPagerTab2Activity.java
@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 {//from w w w . j a va 2 s .c o m ViewHelper.setPivotX(mTitleView, 0); } }
From source file:de.azapps.mirakel.custom_views.TaskDetailDueReminder.java
@SuppressLint("NewApi") @Override/*w w w.j a v a 2 s.c o m*/ protected void updateView() { final Drawable reminderImg = this.context.getResources() .getDrawable(android.R.drawable.ic_menu_recent_history); reminderImg.setBounds(0, 1, 42, 42); final Drawable dueImg = this.context.getResources().getDrawable(android.R.drawable.ic_menu_today); dueImg.setBounds(0, 1, 42, 42); final Configuration config = this.context.getResources().getConfiguration(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { this.taskReminder.setCompoundDrawables(null, null, reminderImg, null); this.taskDue.setCompoundDrawables(null, null, dueImg, null); } else { this.taskReminder.setCompoundDrawables(reminderImg, null, null, null); this.taskDue.setCompoundDrawables(dueImg, null, null, null); } setRecurringImage(this.recurrenceDue, this.task.getRecurrenceId()); setRecurringImage(this.recurrenceReminder, this.task.getRecurringReminderId()); setupRecurrenceDrawable(this.recurrenceDue, this.task.getRecurrence()); setupRecurrenceDrawable(this.recurrenceReminder, this.task.getRecurringReminder()); setDue(); setReminder(); }
From source file:com.android.deskclock.alarms.AlarmActivity.java
@Override public boolean onTouch(View view, MotionEvent motionEvent) { if (mAlarmHandled) { LogUtils.v(LOGTAG, "onTouch ignored: %s", motionEvent); return false; }//from ww w.j av a 2s . c om final int[] contentLocation = { 0, 0 }; mContentView.getLocationOnScreen(contentLocation); final float x = motionEvent.getRawX() - contentLocation[0]; final float y = motionEvent.getRawY() - contentLocation[1]; final int alarmLeft = mAlarmButton.getLeft() + mAlarmButton.getPaddingLeft(); final int alarmRight = mAlarmButton.getRight() - mAlarmButton.getPaddingRight(); final float snoozeFraction, dismissFraction; if (mContentView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { snoozeFraction = getFraction(alarmRight, mSnoozeButton.getLeft(), x); dismissFraction = getFraction(alarmLeft, mDismissButton.getRight(), x); } else { snoozeFraction = getFraction(alarmLeft, mSnoozeButton.getRight(), x); dismissFraction = getFraction(alarmRight, mDismissButton.getLeft(), x); } setAnimatedFractions(snoozeFraction, dismissFraction); switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: LogUtils.v(LOGTAG, "onTouch started: %s", motionEvent); // Stop the pulse, allowing the last pulse to finish. mPulseAnimator.setRepeatCount(0); break; case MotionEvent.ACTION_UP: LogUtils.v(LOGTAG, "onTouch ended: %s", motionEvent); if (snoozeFraction == 1.0f) { snooze(); } else if (dismissFraction == 1.0f) { dismiss(); } else { if (snoozeFraction > 0.0f || dismissFraction > 0.0f) { // Animate back to the initial state. AnimatorUtils.reverse(mAlarmAnimator, mSnoozeAnimator, mDismissAnimator); } else if (mAlarmButton.getTop() <= y && y <= mAlarmButton.getBottom()) { // User touched the alarm button, hint the dismiss action hintDismiss(); } // Restart the pulse. mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); if (!mPulseAnimator.isStarted()) { mPulseAnimator.start(); } } break; case MotionEvent.ACTION_CANCEL: resetAnimations(); break; default: break; } return true; }
From source file:com.mishiranu.dashchan.util.DrawerToggle.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private boolean isLayoutRtl() { return C.API_JELLY_BEAN_MR1 ? activity.getWindow().getDecorView().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL : false;/*w w w. j av a2s. c o m*/ }
From source file:com.androidinspain.deskclock.alarms.AlarmActivity.java
@Override public boolean onTouch(View view, MotionEvent event) { if (mAlarmHandled) { LOGGER.v("onTouch ignored: %s", event); return false; }/* w w w .j a va 2 s.c om*/ final int action = event.getActionMasked(); if (action == MotionEvent.ACTION_DOWN) { LOGGER.v("onTouch started: %s", event); // Track the pointer that initiated the touch sequence. mInitialPointerIndex = event.getPointerId(event.getActionIndex()); // Stop the pulse, allowing the last pulse to finish. mPulseAnimator.setRepeatCount(0); } else if (action == MotionEvent.ACTION_CANCEL) { LOGGER.v("onTouch canceled: %s", event); // Clear the pointer index. mInitialPointerIndex = MotionEvent.INVALID_POINTER_ID; // Reset everything. resetAnimations(); } final int actionIndex = event.getActionIndex(); if (mInitialPointerIndex == MotionEvent.INVALID_POINTER_ID || mInitialPointerIndex != event.getPointerId(actionIndex)) { // Ignore any pointers other than the initial one, bail early. return true; } final int[] contentLocation = { 0, 0 }; mContentView.getLocationOnScreen(contentLocation); final float x = event.getRawX() - contentLocation[0]; final float y = event.getRawY() - contentLocation[1]; final int alarmLeft = mAlarmButton.getLeft() + mAlarmButton.getPaddingLeft(); final int alarmRight = mAlarmButton.getRight() - mAlarmButton.getPaddingRight(); final float snoozeFraction, dismissFraction; if (mContentView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { snoozeFraction = getFraction(alarmRight, mSnoozeButton.getLeft(), x); dismissFraction = getFraction(alarmLeft, mDismissButton.getRight(), x); } else { snoozeFraction = getFraction(alarmLeft, mSnoozeButton.getRight(), x); dismissFraction = getFraction(alarmRight, mDismissButton.getLeft(), x); } setAnimatedFractions(snoozeFraction, dismissFraction); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) { LOGGER.v("onTouch ended: %s", event); mInitialPointerIndex = MotionEvent.INVALID_POINTER_ID; if (snoozeFraction == 1.0f) { snooze(); } else if (dismissFraction == 1.0f) { dismiss(); } else { if (snoozeFraction > 0.0f || dismissFraction > 0.0f) { // Animate back to the initial state. AnimatorUtils.reverse(mAlarmAnimator, mSnoozeAnimator, mDismissAnimator); } else if (mAlarmButton.getTop() <= y && y <= mAlarmButton.getBottom()) { // User touched the alarm button, hint the dismiss action. hintDismiss(); } // Restart the pulse. mPulseAnimator.setRepeatCount(ValueAnimator.INFINITE); if (!mPulseAnimator.isStarted()) { mPulseAnimator.start(); } } } return true; }
From source file:com.facebook.litho.LayoutState.java
private static boolean isLayoutDirectionRTL(Context context) { ApplicationInfo applicationInfo = context.getApplicationInfo(); if ((SDK_INT >= JELLY_BEAN_MR1) && (applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0) { int layoutDirection = getLayoutDirection(context); return layoutDirection == View.LAYOUT_DIRECTION_RTL; }//from w w w . j av a 2s . c o m return false; }
From source file:android.support.v17.leanback.widget.AbstractMediaItemPresenter.java
/** * Each media item row can have multiple focusable elements; the details on the left and a set * of optional custom actions on the right. * The selector is a highlight that moves to highlight to cover whichever views is in focus. * * @param selectorView the selector view used to highlight an individual element within a row. * @param focusChangedView The component within the media row whose focus got changed. * @param layoutAnimator the ValueAnimator producing animation frames for the selector's width * and x-translation, generated by this method and stored for the each * {@link ViewHolder}. * @param isDetails Whether the changed-focused view is for a media item details (true) or * an action (false).// w w w. j av a 2 s .c o m */ private static ValueAnimator updateSelector(final View selectorView, View focusChangedView, ValueAnimator layoutAnimator, boolean isDetails) { int animationDuration = focusChangedView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); DecelerateInterpolator interpolator = new DecelerateInterpolator(); int layoutDirection = ViewCompat.getLayoutDirection(selectorView); if (!focusChangedView.hasFocus()) { // if neither of the details or action views are in focus (ie. another row is in focus), // animate the selector out. selectorView.animate().cancel(); selectorView.animate().alpha(0f).setDuration(animationDuration).setInterpolator(interpolator).start(); // keep existing layout animator return layoutAnimator; } else { // cancel existing layout animator if (layoutAnimator != null) { layoutAnimator.cancel(); layoutAnimator = null; } float currentAlpha = selectorView.getAlpha(); selectorView.animate().alpha(1f).setDuration(animationDuration).setInterpolator(interpolator).start(); final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) selectorView.getLayoutParams(); ViewGroup rootView = (ViewGroup) selectorView.getParent(); sTempRect.set(0, 0, focusChangedView.getWidth(), focusChangedView.getHeight()); rootView.offsetDescendantRectToMyCoords(focusChangedView, sTempRect); if (isDetails) { if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { sTempRect.right += rootView.getHeight(); sTempRect.left -= rootView.getHeight() / 2; } else { sTempRect.left -= rootView.getHeight(); sTempRect.right += rootView.getHeight() / 2; } } final int targetLeft = sTempRect.left; final int targetWidth = sTempRect.width(); final float deltaWidth = lp.width - targetWidth; final float deltaLeft = lp.leftMargin - targetLeft; if (deltaLeft == 0f && deltaWidth == 0f) { // no change needed } else if (currentAlpha == 0f) { // change selector to the proper width and marginLeft without animation. lp.width = targetWidth; lp.leftMargin = targetLeft; selectorView.requestLayout(); } else { // animate the selector to the proper width and marginLeft. layoutAnimator = ValueAnimator.ofFloat(0f, 1f); layoutAnimator.setDuration(animationDuration); layoutAnimator.setInterpolator(interpolator); layoutAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // Set width to the proper width for this animation step. float fractionToEnd = 1f - valueAnimator.getAnimatedFraction(); lp.leftMargin = Math.round(targetLeft + deltaLeft * fractionToEnd); lp.width = Math.round(targetWidth + deltaWidth * fractionToEnd); selectorView.requestLayout(); } }); layoutAnimator.start(); } return layoutAnimator; } }
From source file:de.azapps.mirakel.helper.TaskDialogHelpers.java
@SuppressLint("NewApi") public static void handleSubtask(final Context ctx, final Task task, final OnTaskChangedListner taskChanged, final boolean asSubtask) { final List<Pair<Long, String>> names = Task.getTaskNames(); final CharSequence[] values = new String[names.size()]; for (int i = 0; i < names.size(); i++) { values[i] = names.get(i).second; }//from www . j av a 2 s . co m final View v = ((Activity) ctx).getLayoutInflater().inflate(R.layout.select_subtask, null, false); final ListView lv = (ListView) v.findViewById(R.id.subtask_listview); final List<Task> tasks = Task.cursorToTaskList( ctx.getContentResolver().query(MirakelInternalContentProvider.TASK_URI, Task.allColumns, ModelBase.ID + "=" + task.getId() + " AND " + Task.BASIC_FILTER_DISPLAY_TASKS, null, null)); subtaskAdapter = new SubtaskAdapter(ctx, 0, tasks, task, asSubtask); lv.post(new Runnable() { @Override public void run() { lv.setAdapter(subtaskAdapter); } }); searchString = ""; done = false; content = false; reminder = false; optionEnabled = false; newTask = true; listId = SpecialList.firstSpecialSafe().getId(); final EditText search = (EditText) v.findViewById(R.id.subtask_searchbox); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { Drawable left = ctx.getResources().getDrawable(android.R.drawable.ic_menu_search); Drawable right = null; left.setBounds(0, 0, 42, 42); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && ctx.getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { right = ctx.getResources().getDrawable(android.R.drawable.ic_menu_search); right.setBounds(0, 0, 42, 42); left = null; } search.setCompoundDrawables(left, null, right, null); } search.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(final Editable s) { // Nothing } @Override public void beforeTextChanged(final CharSequence s, final int start, final int count, final int after) { // Nothing } @Override public void onTextChanged(final CharSequence s, final int start, final int before, final int count) { searchString = s.toString(); updateListView(subtaskAdapter, task, lv, ctx); } }); final Button options = (Button) v.findViewById(R.id.subtasks_options); final LinearLayout wrapper = (LinearLayout) v.findViewById(R.id.subtask_option_wrapper); wrapper.setVisibility(View.GONE); options.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (optionEnabled) { wrapper.setVisibility(View.GONE); } else { wrapper.setVisibility(View.VISIBLE); final InputMethodManager imm = (InputMethodManager) ctx .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(search.getWindowToken(), 0); } optionEnabled = !optionEnabled; } }); final ViewSwitcher switcher = (ViewSwitcher) v.findViewById(R.id.subtask_switcher); final Button subtaskNewtask = (Button) v.findViewById(R.id.subtask_newtask); final Button subtaskSelectOld = (Button) v.findViewById(R.id.subtask_select_old); final boolean darkTheme = MirakelCommonPreferences.isDark(); if (asSubtask) { v.findViewById(R.id.subtask_header).setVisibility(View.GONE); switcher.showNext(); newTask = false; } else { subtaskNewtask.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (newTask) { return; } switcher.showPrevious(); subtaskNewtask .setTextColor(ctx.getResources().getColor(darkTheme ? R.color.White : R.color.Black)); subtaskSelectOld.setTextColor(ctx.getResources().getColor(R.color.Grey)); newTask = true; } }); subtaskSelectOld.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (!newTask) { return; } switcher.showNext(); subtaskNewtask.setTextColor(ctx.getResources().getColor(R.color.Grey)); subtaskSelectOld .setTextColor(ctx.getResources().getColor(darkTheme ? R.color.White : R.color.Black)); if (subtaskAdapter != null) { subtaskAdapter.notifyDataSetChanged(); } newTask = false; lv.invalidateViews(); updateListView(subtaskAdapter, task, lv, ctx); } }); } final CheckBox doneBox = (CheckBox) v.findViewById(R.id.subtask_done); doneBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { done = isChecked; updateListView(subtaskAdapter, task, lv, ctx); } }); final CheckBox reminderBox = (CheckBox) v.findViewById(R.id.subtask_reminder); reminderBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { reminder = isChecked; updateListView(subtaskAdapter, task, lv, ctx); } }); final Button list = (Button) v.findViewById(R.id.subtask_list); list.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final List<ListMirakel> lists = ListMirakel.all(true); final CharSequence[] names = new String[lists.size()]; for (int i = 0; i < names.length; i++) { names[i] = lists.get(i).getName(); } new AlertDialog.Builder(ctx).setSingleChoiceItems(names, -1, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { listId = lists.get(which).getId(); updateListView(subtaskAdapter, task, lv, ctx); list.setText(lists.get(which).getName()); dialog.dismiss(); } }).show(); } }); final CheckBox contentBox = (CheckBox) v.findViewById(R.id.subtask_content); contentBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { content = isChecked; updateListView(subtaskAdapter, task, lv, ctx); } }); final EditText newTaskEdit = (EditText) v.findViewById(R.id.subtask_add_task_edit); final AlertDialog dialog = new AlertDialog.Builder(ctx).setTitle(ctx.getString(R.string.add_subtask)) .setView(v).setPositiveButton(R.string.add, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { if (newTask && newTaskEdit.getText().length() > 0) { newSubtask(newTaskEdit.getText().toString(), task, ctx); } else if (!newTask) { final List<Task> checked = subtaskAdapter.getSelected(); for (final Task t : checked) { if (!asSubtask) { if (!t.hasSubtasksLoop(task)) { task.addSubtask(t); } else { ErrorReporter.report(ErrorType.TASKS_CANNOT_FORM_LOOP); } } else { if (!task.hasSubtasksLoop(t)) { t.addSubtask(task); } else { ErrorReporter.report(ErrorType.TASKS_CANNOT_FORM_LOOP); } } } } if (taskChanged != null) { taskChanged.onTaskChanged(task); } ((Activity) ctx).getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dialog.dismiss(); } }).setNegativeButton(android.R.string.cancel, dialogDoNothing).show(); newTaskEdit.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEND) { newSubtask(v.getText().toString(), task, ctx); v.setText(null); if (taskChanged != null) { taskChanged.onTaskChanged(task); } dialog.dismiss(); } return false; } }); }
From source file:android.text.BidiFormatter.java
/** * Helper method to return true if the Locale directionality is RTL. * * @param locale The Locale whose directionality will be checked to be RTL or LTR * @return true if the {@code locale} directionality is RTL. False otherwise. *//*from ww w. j a v a 2 s . c o m*/ private static boolean isRtlLocale(Locale locale) { return (TextUtils.getLayoutDirectionFromLocale(locale) == View.LAYOUT_DIRECTION_RTL); }