Skip to content

Support RTL 🌐 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 7, 2017
Merged

Support RTL 🌐 #1

merged 8 commits into from
Jun 7, 2017

Conversation

konifar
Copy link
Contributor

@konifar konifar commented Jun 6, 2017

Overview

Thanks for the cool library.
This library didn't support RTL attributes such as drawableStart and drawableEnd.
I added these two in this PR.

  • Added cit_drawableStart and cit_drawableEnd attributes.
  • Added set methods.
  • Added a sample for RTL.
  • Updated README.

Screenshot

See the text on the bottom.

Locale: ja Locale: ar

Note

This contains a little refactoring. If you don't like it, feel free to comment. Thanks!

@@ -176,7 +176,7 @@ public void setIconColor(@ColorInt final int color) {
/**
* Change drawable icon size
*
* @param widthRes Set width resource id
* @param widthRes Set width resource id
Copy link
Contributor Author

@konifar konifar Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this was auto formatted 🙇

updateIcons();
} else {
setVectorDrawable(INDEX_LEFT, resourceId);
}
Copy link
Contributor Author

@konifar konifar Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is same in several method so I moved it to setVectorDrawable() method.

@@ -278,7 +284,7 @@ private static Bitmap drawable2Bitmap(final Drawable drawable, final int iconWid
* {@link android.content.res.Resources} or a {@link android.content.res.TypedArray}.
*/
private static void fixDrawable(@NonNull final Drawable drawable) {
if (Build.VERSION.SDK_INT == 21
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just changed.

Resources resources = getContext().getResources();
Locale locale = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
? resources.getConfiguration().getLocales().getFirstMatch(resources.getAssets().getLocales())
: resources.getConfiguration().locale;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After Android N, configuration.locale became deprecated.

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Copy link
Contributor Author

@konifar konifar Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFYI: You might have known.
If you use this chrome plugin, you can see VectorDrawable icon on GitHub page like this. It helps you to review PR.

android:textColor="#795548"
android:textSize="@dimen/text_large"
app:cit_drawableStart="@drawable/ic_language_black_24px"
app:cit_iconColor="#4E342E"
Copy link
Contributor Author

@konifar konifar Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I choosed Brown 500 and 800 here from https://material.io/guidelines/style/color.html
because it reminds me something like Earth 🌍

@@ -131,4 +133,4 @@ See the License for the specific language governing permissions and
limitations under the License.
```

[preview]: /arts/preview.png
[preview]: /arts/preview.jpg
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was too big so I changed the width to 300 px.

@AAkira
Copy link
Owner

AAkira commented Jun 7, 2017

@konifar

Thank you so much! 😄
I'll release this PR as 1.1.0. 👍

@AAkira AAkira merged commit e4213fe into AAkira:master Jun 7, 2017
@konifar
Copy link
Contributor Author

konifar commented Jun 7, 2017

Thanks for the quick review! 😄

@konifar konifar deleted the support_rtl branch June 7, 2017 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants