aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/setup
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/setup')
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupActivity.java303
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java123
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java10
3 files changed, 342 insertions, 94 deletions
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
index 15d0bac37..affe3a348 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java
@@ -17,18 +17,22 @@
package com.android.inputmethod.latin.setup;
import android.app.Activity;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
+import android.media.MediaPlayer;
+import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.provider.Settings;
+import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
+import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.VideoView;
import com.android.inputmethod.compat.TextViewCompatUtils;
import com.android.inputmethod.compat.ViewCompatUtils;
@@ -38,16 +42,28 @@ import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.SettingsActivity;
import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
-import java.util.HashMap;
-
-public final class SetupActivity extends Activity {
- private SetupStepIndicatorView mStepIndicatorView;
- private final SetupStepGroup mSetupSteps = new SetupStepGroup();
+import java.util.ArrayList;
+
+// TODO: Use Fragment to implement welcome screen and setup steps.
+public final class SetupActivity extends Activity implements View.OnClickListener {
+ private static final String TAG = SetupActivity.class.getSimpleName();
+
+ private View mWelcomeScreen;
+ private View mSetupScreen;
+ private Uri mWelcomeVideoUri;
+ private VideoView mWelcomeVideoView;
+ private View mActionStart;
+ private View mActionNext;
+ private TextView mStep1Bullet;
+ private TextView mActionFinish;
+ private SetupStepGroup mSetupStepGroup;
private static final String STATE_STEP = "step";
private int mStepNumber;
+ private static final int STEP_WELCOME = 0;
private static final int STEP_1 = 1;
private static final int STEP_2 = 2;
private static final int STEP_3 = 3;
+ private boolean mWasLanguageAndInputSettingsInvoked;
private final SettingsPoolingHandler mHandler = new SettingsPoolingHandler(this);
@@ -97,29 +113,40 @@ public final class SetupActivity extends Activity {
if (savedInstanceState == null) {
mStepNumber = determineSetupStepNumber();
+ if (mStepNumber == STEP_1 && !mWasLanguageAndInputSettingsInvoked) {
+ mStepNumber = STEP_WELCOME;
+ }
+ if (mStepNumber == STEP_3) {
+ // This IME already has been enabled and set as current IME.
+ // TODO: Implement tutorial.
+ invokeSettingsOfThisIme();
+ finish();
+ return;
+ }
} else {
mStepNumber = savedInstanceState.getInt(STATE_STEP);
}
- if (mStepNumber == STEP_3) {
- // This IME already has been enabled and set as current IME.
- // TODO: Implement tutorial.
- invokeSettingsOfThisIme();
- finish();
- return;
- }
-
- // TODO: Use sans-serif-thin font family depending on the system locale white list and
- // the SDK version.
- final TextView titleView = (TextView)findViewById(R.id.setup_title);
- final int appName = getApplicationInfo().labelRes;
- titleView.setText(getString(R.string.setup_title, getString(appName)));
-
- mStepIndicatorView = (SetupStepIndicatorView)findViewById(R.id.setup_step_indicator);
-
- final SetupStep step1 = new SetupStep(findViewById(R.id.setup_step1),
- appName, R.string.setup_step1_title, R.string.setup_step1_instruction,
- R.drawable.ic_settings_language, R.string.language_settings);
+ final String applicationName = getResources().getString(getApplicationInfo().labelRes);
+ mWelcomeScreen = findViewById(R.id.setup_welcome_screen);
+ final TextView welcomeTitle = (TextView)findViewById(R.id.setup_welcome_title);
+ welcomeTitle.setText(getString(R.string.setup_welcome_title, applicationName));
+
+ mSetupScreen = findViewById(R.id.setup_steps_screen);
+ final TextView stepsTitle = (TextView)findViewById(R.id.setup_title);
+ stepsTitle.setText(getString(R.string.setup_steps_title, applicationName));
+
+ final SetupStepIndicatorView indicatorView =
+ (SetupStepIndicatorView)findViewById(R.id.setup_step_indicator);
+ mSetupStepGroup = new SetupStepGroup(indicatorView);
+
+ mStep1Bullet = (TextView)findViewById(R.id.setup_step1_bullet);
+ mStep1Bullet.setOnClickListener(this);
+ final SetupStep step1 = new SetupStep(STEP_1, applicationName,
+ mStep1Bullet, findViewById(R.id.setup_step1),
+ R.string.setup_step1_title, R.string.setup_step1_instruction,
+ R.string.setup_step1_finished_instruction, R.drawable.ic_setup_step1,
+ R.string.setup_step1_action);
step1.setAction(new Runnable() {
@Override
public void run() {
@@ -127,11 +154,13 @@ public final class SetupActivity extends Activity {
mHandler.startPollingImeSettings();
}
});
- mSetupSteps.addStep(STEP_1, step1);
+ mSetupStepGroup.addStep(step1);
- final SetupStep step2 = new SetupStep(findViewById(R.id.setup_step2),
- appName, R.string.setup_step2_title, R.string.setup_step2_instruction,
- 0 /* actionIcon */, R.string.select_input_method);
+ final SetupStep step2 = new SetupStep(STEP_2, applicationName,
+ (TextView)findViewById(R.id.setup_step2_bullet), findViewById(R.id.setup_step2),
+ R.string.setup_step2_title, R.string.setup_step2_instruction,
+ 0 /* finishedInstruction */, R.drawable.ic_setup_step2,
+ R.string.setup_step2_action);
step2.setAction(new Runnable() {
@Override
public void run() {
@@ -140,18 +169,84 @@ public final class SetupActivity extends Activity {
.showInputMethodPicker();
}
});
- mSetupSteps.addStep(STEP_2, step2);
+ mSetupStepGroup.addStep(step2);
- final SetupStep step3 = new SetupStep(findViewById(R.id.setup_step3),
- appName, R.string.setup_step3_title, 0 /* instruction */,
- R.drawable.sym_keyboard_language_switch, R.string.setup_step3_instruction);
+ final SetupStep step3 = new SetupStep(STEP_3, applicationName,
+ (TextView)findViewById(R.id.setup_step3_bullet), findViewById(R.id.setup_step3),
+ R.string.setup_step3_title, R.string.setup_step3_instruction,
+ 0 /* finishedInstruction */, R.drawable.ic_setup_step3,
+ R.string.setup_step3_action);
step3.setAction(new Runnable() {
@Override
public void run() {
invokeSubtypeEnablerOfThisIme();
}
});
- mSetupSteps.addStep(STEP_3, step3);
+ mSetupStepGroup.addStep(step3);
+
+ mWelcomeVideoUri = new Uri.Builder()
+ .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
+ .authority(getPackageName())
+ .path(Integer.toString(R.raw.setup_welcome_video))
+ .build();
+ mWelcomeVideoView = (VideoView)findViewById(R.id.setup_welcome_video);
+ mWelcomeVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+ @Override
+ public void onCompletion(final MediaPlayer mp) {
+ mp.start();
+ }
+ });
+ mWelcomeVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
+ @Override
+ public void onPrepared(final MediaPlayer mp) {
+ // Now VideoView has been laid-out and ready to play, remove background of it to
+ // reveal the video.
+ mWelcomeVideoView.setBackgroundResource(0);
+ }
+ });
+ final ImageView welcomeImageView = (ImageView)findViewById(R.id.setup_welcome_image);
+ mWelcomeVideoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
+ @Override
+ public boolean onError(final MediaPlayer mp, final int what, final int extra) {
+ Log.e(TAG, "Playing welcome video causes error: what=" + what + " extra=" + extra);
+ mWelcomeVideoView.setVisibility(View.GONE);
+ welcomeImageView.setImageResource(R.raw.setup_welcome_image);
+ welcomeImageView.setVisibility(View.VISIBLE);
+ return true;
+ }
+ });
+
+ mActionStart = findViewById(R.id.setup_start_label);
+ mActionStart.setOnClickListener(this);
+ mActionNext = findViewById(R.id.setup_next);
+ mActionNext.setOnClickListener(this);
+ mActionFinish = (TextView)findViewById(R.id.setup_finish);
+ TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(mActionFinish,
+ getResources().getDrawable(R.drawable.ic_setup_finish), null, null, null);
+ mActionFinish.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(final View v) {
+ if (v == mActionFinish) {
+ finish();
+ return;
+ }
+ final int currentStep = determineSetupStepNumber();
+ final int nextStep;
+ if (v == mActionStart) {
+ nextStep = STEP_1;
+ } else if (v == mActionNext) {
+ nextStep = mStepNumber + 1;
+ } else if (v == mStep1Bullet && currentStep == STEP_2) {
+ nextStep = STEP_1;
+ } else {
+ nextStep = mStepNumber;
+ }
+ if (mStepNumber != nextStep) {
+ mStepNumber = nextStep;
+ updateSetupStepView();
+ }
}
private void invokeSetupWizardOfThisIme() {
@@ -175,6 +270,7 @@ public final class SetupActivity extends Activity {
intent.setAction(Settings.ACTION_INPUT_METHOD_SETTINGS);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent);
+ mWasLanguageAndInputSettingsInvoked = true;
}
private void invokeSubtypeEnablerOfThisIme() {
@@ -246,15 +342,11 @@ public final class SetupActivity extends Activity {
}
@Override
- protected void onStart() {
- super.onStart();
- mStepNumber = determineSetupStepNumber();
- }
-
- @Override
protected void onRestart() {
super.onRestart();
- mStepNumber = determineSetupStepNumber();
+ if (mStepNumber != STEP_WELCOME) {
+ mStepNumber = determineSetupStepNumber();
+ }
}
@Override
@@ -264,67 +356,92 @@ public final class SetupActivity extends Activity {
}
@Override
- public void onWindowFocusChanged(final boolean hasFocus) {
- super.onWindowFocusChanged(hasFocus);
- if (!hasFocus) {
+ public void onBackPressed() {
+ if (mStepNumber == STEP_1) {
+ mStepNumber = STEP_WELCOME;
+ updateSetupStepView();
return;
}
- mStepNumber = determineSetupStepNumber();
- updateSetupStepView();
+ super.onBackPressed();
}
- private void updateSetupStepView() {
- final int layoutDirection = ViewCompatUtils.getLayoutDirection(mStepIndicatorView);
- mStepIndicatorView.setIndicatorPosition(
- getIndicatorPosition(mStepNumber, mSetupSteps.getTotalStep(), layoutDirection));
- mSetupSteps.enableStep(mStepNumber);
+ @Override
+ protected void onPause() {
+ mWelcomeVideoView.stopPlayback();
+ super.onPause();
}
- private static float getIndicatorPosition(final int step, final int totalStep,
- final int layoutDirection) {
- final float pos = ((step - STEP_1) * 2 + 1) / (float)(totalStep * 2);
- return (layoutDirection == ViewCompatUtils.LAYOUT_DIRECTION_RTL) ? 1.0f - pos : pos;
+ @Override
+ public void onWindowFocusChanged(final boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+ if (hasFocus && mStepNumber != STEP_WELCOME) {
+ mStepNumber = determineSetupStepNumber();
+ updateSetupStepView();
+ }
+ }
+
+ private void updateSetupStepView() {
+ final boolean welcomeScreen = (mStepNumber == STEP_WELCOME);
+ mWelcomeScreen.setVisibility(welcomeScreen ? View.VISIBLE : View.GONE);
+ mSetupScreen.setVisibility(welcomeScreen ? View.GONE: View.VISIBLE);
+ if (welcomeScreen) {
+ mWelcomeVideoView.setVideoURI(mWelcomeVideoUri);
+ mWelcomeVideoView.start();
+ return;
+ }
+ mWelcomeVideoView.stopPlayback();
+ final boolean isStepActionAlreadyDone = mStepNumber < determineSetupStepNumber();
+ mSetupStepGroup.enableStep(mStepNumber, isStepActionAlreadyDone);
+ mActionNext.setVisibility(isStepActionAlreadyDone ? View.VISIBLE : View.GONE);
+ mActionFinish.setVisibility((mStepNumber == STEP_3) ? View.VISIBLE : View.GONE);
}
static final class SetupStep implements View.OnClickListener {
- private final View mRootView;
+ public final int mStepNo;
+ private final View mStepView;
+ private final TextView mBulletView;
+ private final int mActivatedColor;
+ private final int mDeactivatedColor;
+ private final String mInstruction;
+ private final String mFinishedInstruction;
private final TextView mActionLabel;
private Runnable mAction;
- public SetupStep(final View rootView, final int appName, final int title,
- final int instruction, final int actionIcon, final int actionLabel) {
- mRootView = rootView;
- final Resources res = rootView.getResources();
- final String applicationName = res.getString(appName);
-
- final TextView titleView = (TextView)rootView.findViewById(R.id.setup_step_title);
+ public SetupStep(final int stepNo, final String applicationName, final TextView bulletView,
+ final View stepView, final int title, final int instruction,
+ final int finishedInstruction,final int actionIcon, final int actionLabel) {
+ mStepNo = stepNo;
+ mStepView = stepView;
+ mBulletView = bulletView;
+ final Resources res = stepView.getResources();
+ mActivatedColor = res.getColor(R.color.setup_text_action);
+ mDeactivatedColor = res.getColor(R.color.setup_text_dark);
+
+ final TextView titleView = (TextView)mStepView.findViewById(R.id.setup_step_title);
titleView.setText(res.getString(title, applicationName));
+ mInstruction = (instruction == 0) ? null
+ : res.getString(instruction, applicationName);
+ mFinishedInstruction = (finishedInstruction == 0) ? null
+ : res.getString(finishedInstruction, applicationName);
- final TextView instructionView = (TextView)rootView.findViewById(
- R.id.setup_step_instruction);
- if (instruction == 0) {
- instructionView.setVisibility(View.GONE);
- } else {
- instructionView.setText(res.getString(instruction, applicationName));
- }
-
- mActionLabel = (TextView)rootView.findViewById(R.id.setup_step_action_label);
+ mActionLabel = (TextView)mStepView.findViewById(R.id.setup_step_action_label);
mActionLabel.setText(res.getString(actionLabel));
if (actionIcon == 0) {
final int paddingEnd = ViewCompatUtils.getPaddingEnd(mActionLabel);
ViewCompatUtils.setPaddingRelative(mActionLabel, paddingEnd, 0, paddingEnd, 0);
} else {
- final int overrideColor = res.getColor(R.color.setup_text_action);
- final Drawable icon = res.getDrawable(actionIcon);
- icon.setColorFilter(overrideColor, PorterDuff.Mode.MULTIPLY);
- icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
- TextViewCompatUtils.setCompoundDrawablesRelative(
- mActionLabel, icon, null, null, null);
+ TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
+ mActionLabel, res.getDrawable(actionIcon), null, null, null);
}
}
- public void setEnabled(final boolean enabled) {
- mRootView.setVisibility(enabled ? View.VISIBLE : View.GONE);
+ public void setEnabled(final boolean enabled, final boolean isStepActionAlreadyDone) {
+ mStepView.setVisibility(enabled ? View.VISIBLE : View.GONE);
+ mBulletView.setTextColor(enabled ? mActivatedColor : mDeactivatedColor);
+ final TextView instructionView = (TextView)mStepView.findViewById(
+ R.id.setup_step_instruction);
+ instructionView.setText(isStepActionAlreadyDone ? mFinishedInstruction : mInstruction);
+ mActionLabel.setVisibility(isStepActionAlreadyDone ? View.GONE : View.VISIBLE);
}
public void setAction(final Runnable action) {
@@ -334,28 +451,30 @@ public final class SetupActivity extends Activity {
@Override
public void onClick(final View v) {
- if (mAction != null) {
+ if (v == mActionLabel && mAction != null) {
mAction.run();
+ return;
}
}
}
static final class SetupStepGroup {
- private final HashMap<Integer, SetupStep> mGroup = CollectionUtils.newHashMap();
+ private final SetupStepIndicatorView mIndicatorView;
+ private final ArrayList<SetupStep> mGroup = CollectionUtils.newArrayList();
- public void addStep(final int stepNo, final SetupStep step) {
- mGroup.put(stepNo, step);
+ public SetupStepGroup(final SetupStepIndicatorView indicatorView) {
+ mIndicatorView = indicatorView;
}
- public void enableStep(final int enableStepNo) {
- for (final Integer stepNo : mGroup.keySet()) {
- final SetupStep step = mGroup.get(stepNo);
- step.setEnabled(stepNo == enableStepNo);
- }
+ public void addStep(final SetupStep step) {
+ mGroup.add(step);
}
- public int getTotalStep() {
- return mGroup.size();
+ public void enableStep(final int enableStepNo, final boolean isStepActionAlreadyDone) {
+ for (final SetupStep step : mGroup) {
+ step.setEnabled(step.mStepNo == enableStepNo, isStepActionAlreadyDone);
+ }
+ mIndicatorView.setIndicatorPosition(enableStepNo - STEP_1, mGroup.size());
}
}
}
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java b/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
new file mode 100644
index 000000000..974dfddd3
--- /dev/null
+++ b/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.latin.setup;
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.inputmethod.compat.ViewCompatUtils;
+import com.android.inputmethod.latin.R;
+
+public final class SetupStartIndicatorView extends LinearLayout {
+ public SetupStartIndicatorView(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ setOrientation(HORIZONTAL);
+ LayoutInflater.from(context).inflate(R.layout.setup_start_indicator_label, this);
+
+ final LabelView labelView = (LabelView)findViewById(R.id.setup_start_label);
+ labelView.setIndicatorView(findViewById(R.id.setup_start_indicator));
+ }
+
+ public static final class LabelView extends TextView {
+ private View mIndicatorView;
+
+ public LabelView(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public void setIndicatorView(final View indicatorView) {
+ mIndicatorView = indicatorView;
+ }
+
+ // TODO: Once we stop supporting ICS, uncomment {@link #setPressed(boolean)} method and
+ // remove this method.
+ @Override
+ protected void drawableStateChanged() {
+ super.drawableStateChanged();
+ for (final int state : getDrawableState()) {
+ if (state == android.R.attr.state_pressed) {
+ updateIndicatorView(true /* pressed */);
+ return;
+ }
+ }
+ updateIndicatorView(false /* pressed */);
+ }
+
+ // TODO: Once we stop supporting ICS, uncomment this method and remove
+ // {@link #drawableStateChanged()} method.
+// @Override
+// public void setPressed(final boolean pressed) {
+// super.setPressed(pressed);
+// updateIndicatorView(pressed);
+// }
+
+ private void updateIndicatorView(final boolean pressed) {
+ if (mIndicatorView != null) {
+ mIndicatorView.setPressed(pressed);
+ mIndicatorView.invalidate();
+ }
+ }
+ }
+
+ public static final class IndicatorView extends View {
+ private final Path mIndicatorPath = new Path();
+ private final Paint mIndicatorPaint = new Paint();
+ private final ColorStateList mIndicatorColor;
+
+ public IndicatorView(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ mIndicatorColor = getResources().getColorStateList(
+ R.color.setup_step_action_background);
+ mIndicatorPaint.setStyle(Paint.Style.FILL);
+ }
+
+ @Override
+ protected void onDraw(final Canvas canvas) {
+ super.onDraw(canvas);
+ final int layoutDirection = ViewCompatUtils.getLayoutDirection(this);
+ final int width = getWidth();
+ final int height = getHeight();
+ final float halfHeight = height / 2.0f;
+ final Path path = mIndicatorPath;
+ path.rewind();
+ if (layoutDirection == ViewCompatUtils.LAYOUT_DIRECTION_RTL) {
+ // Left arrow
+ path.moveTo(width, 0.0f);
+ path.lineTo(0.0f, halfHeight);
+ path.lineTo(width, height);
+ } else { // LAYOUT_DIRECTION_LTR
+ // Right arrow
+ path.moveTo(0.0f, 0.0f);
+ path.lineTo(width, halfHeight);
+ path.lineTo(0.0f, height);
+ }
+ path.close();
+ final int[] stateSet = getDrawableState();
+ final int color = mIndicatorColor.getColorForState(stateSet, 0);
+ mIndicatorPaint.setColor(color);
+ canvas.drawPath(path, mIndicatorPaint);
+ }
+ }
+}
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java b/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java
index 077a21793..c909507c6 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java
@@ -23,6 +23,7 @@ import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;
+import com.android.inputmethod.compat.ViewCompatUtils;
import com.android.inputmethod.latin.R;
public final class SetupStepIndicatorView extends View {
@@ -36,8 +37,13 @@ public final class SetupStepIndicatorView extends View {
mIndicatorPaint.setStyle(Paint.Style.FILL);
}
- public void setIndicatorPosition(final float xRatio) {
- mXRatio = xRatio;
+ public void setIndicatorPosition(final int stepPos, final int totalStepNum) {
+ final int layoutDirection = ViewCompatUtils.getLayoutDirection(this);
+ // The indicator position is the center of the partition that is equally divided into
+ // the total step number.
+ final float partionWidth = 1.0f / totalStepNum;
+ final float pos = stepPos * partionWidth + partionWidth / 2.0f;
+ mXRatio = (layoutDirection == ViewCompatUtils.LAYOUT_DIRECTION_RTL) ? 1.0f - pos : pos;
invalidate();
}