Android RTL Support

The majority of mobile apps are designed LTR (Left to Right), that is because the vast majority of the world languages are written from Left to Right and only a small number of languages are written from Right to Left such as Arabic. Most of mobile developers never worry about this issue since most of the apps are not intended to target users from regions using languages written from Right to Left also because it was not as easy as it is now to support both directions. As the competition started heating up, it became important to globalize the apps and provide localized versions in order to reach more users and improve app downloads. Moreover,  the rise of mobile apps development in these Arabic-speaking countries made it crucial to provide RTL support.

It is very easy to provide localized versions for different LTR languages in android apps by just providing another strings.xml file under values-XX folder where XX is the language code which contains all the translations for the strings used in this app.

Android 4.2(API 17) released in 2013 has provided full Native support for RTL layouts; it has become very easy to take advantage of this feature and all you need are just few simple changes in your code.

How to start:

First of all, in your Manifest.xml file, you need to declare under the <application> element android:supportsRtl=”true”

Use Start and End layout properties instead of Left and Right, respectively. In LTR layouts, start means left and end means right; however, in RTL start means right and end means left.

Examples for these properties are Padding, Margin, TextView Drawables, Gravity, LayoutGravity, and layout alignments.

In case you need a custom layout in for RTL, just provide the layout with the same name under ldrtl qualifier

Drawables:

Usually the icons you are using are direction independent, so you will not need alternative drawable for RTL; however, there are some cases where you will have to, for example, the back button.

Normally for LTR this is how it looks like:

Screen Shot 2017-02-13 at 10.26.39 PM

If you use the same button for RTL this is how it will look like:

Screen Shot 2017-02-13 at 10.26.54 PM

While what you need is this:

Screen Shot 2017-02-13 at 10.49.45 PM

You can achieve this by mirroring the icon using an external tool and add the new icon with the same name in drawable-ldrtl folder, or just use the forward navigation button and change it’s name in “drawable-ldrtl” folder

In case your minimum SDK is 19, you can use android:autoMirrored=”true” attribute in vector drawables where as the name implies will automatically mirror the icon vertically in case the direction is RTL

Text appearance:

For more control over the text appearance, you can use these attributes

android:textAlignment — attribute for setting the alignment of a component’s text.

android:textDirection — attribute for setting the direction of a component’s text.

Use gravity for textAlignment which is default for the root view. The gravity determines the alignment, ALIGN_NORMAL, ALIGN_CENTER, or ALIGN_OPPOSITE, which are relative to each paragraph’s text direction

Use locale for textDirection which makes the paragraph direction is coming from the system Locale.

To apply these attributes you can add it each textview or globally by adding it to main AppTheme in styles.xml

<item name="android:textAlignment">gravity</item>
<item name="android:textDirection">locale</item>

To know about the variations of textAlignment and textDirection attributes check

https://developer.android.com/reference/android/R.attr.html#textAlignment

https://developer.android.com/reference/android/R.attr.html#textDirection

Application Language Preference:

All the mentioned-above is sufficient to provide RTL layout and in case the app is supposed to follow the device’s language then nothing more is needed. However, in case the user is supposed to be able to choose a specific language, then few more lines of code are needed.

To change the Locale of the application programmatically use the following

String langCode=”ar”;
getContext().getApplicationContext().getResources().updateConfiguration(changeLanguage(code)),
getResources().getDisplayMetrics());
public static Configuration changeLanguage(String code) {
  Locale locale = new Locale(code);
  Locale.setDefault(locale);
  Configuration config = new Configuration();
  config.locale = locale;
  return config;
}

Then restart the activity to apply the changes

startActivity(getIntent());
finish();

However, if the user changed the language of the device, the app will be affected, and in order to prevent that use configChanges attribute under each <activity> element in the Manifest and list Locale and layoutDirection as the changes you would like to handle manually.

android:configChanges=”locale|layoutDirection”

This prevents the application from recreating the activity then override onConfigurationChanged in the activity

@Override
public void onConfigurationChanged(Configuration newConfig) {
  super.onConfigurationChanged(newConfig);
…
…
}

Then you can reapply the user’s configuration for the app again in onConfigurationChanged

getContext().getApplicationContext().getResources().updateConfiguration(
changeLanguage(Session.getLanguage()), getResources().getDisplayMetrics());

Fallback to LTR:

It is possible to force a certain layout direction using android:layoutDirection, it can be useful, for example, when using a ViewPager and TabLayout, the default sliding animation is LTR when doesn’t change in RTL. So a possible solution is to keep the android:layoutDirection=”ltr” and reverse the tabs orders and fragments programmatically. You can check at runtime if the layout is RTL using this method in TextUtils getLayoutDirectionFromLocale .

Another example  is the phone number field, numbers direction are always LTR which means it does not change with language direction, so a possible solution is to use Left and Right instead of Start and End or use android:layoutDirection=”ltr” for the parent view.

Screen Shot 2017-03-13 at 11.21.45 AM

Hopefully these tips could help you with your developing any application in Arabic. Please don’t hesitate to comment below if you have any questions regarding RTL support in android or anything regarding android development in general. Finally please refer to the official android blog for more information about native RTL support.

https://android-developers.googleblog.com/2013/03/native-rtl-support-in-android-42.html

Capitalizing on Technology in Charity

Charity has always been one of the fundamental themes in the lives of Egyptians. With the continuous declination of the standard of living for both the lower-middle and lower classes in the society, NGOs and people working in the charity and CSR fields are facing a huge challenge to provide an adequate support to those social classes that the country’s government is failing to provide.

Charity and community service in Egypt comes in many forms such as NGOs, CSR departments in corporates, clubs in universities, small groups of friends or even individuals. Activities in all these entities are typically more centralized around some seasons that are mostly religion-related. However, to give you a hint of how huge this theme is in Egypt, during Ramadan only in 2015 approximately EGP 30 Billion donations were collected according to the official numbers. (For more details about the economics of donations in Ramadan, we recommend this article by Omar El Shenety.)

In spite of this huge amount of spending and donations, the relationship between charity and technology in Egypt remains very shallow. From my personal experience in this field and what we have reached in robusta throughout the different engagements with NGOs and CSR departments, I believe that technology isn’t being fully utilized or even slightly utilized at a minimum level to help in the charity work here in Egypt.

During our previous engagements in robusta with lots of NGOs, we noticed that most of them are only willing to make use of technology superficially by building simple websites to use them only as an online informative tool. While on the other side there are several serious problems that are present in the current charity/CSR model that technology would really help in resolving but utilizing technology isn’t on their roadmap.

Below are some examples of the current problems and how technology can help resolve that.

Accessibility of Donating

It is such a pity that people are creating WhatsApp groups to collect money for certain cases. Meanwhile a simple web/mobile application listing the cases by their different types and with detailed information can be very handy especially when it is integrated with an online payment gateway provided by bank or independent platforms like Payfort.

Cases Reach

Lots of people sometimes want to donate money/furniture/…etc and actually don’t know where or how to donate despite the huge number of NGOs. The idea is that you want a simple way to do so which is quite feasible by a location based mobile app that detects users’ locations and can show the different cases around them with their needs. Location based apps can be used in an opposite way by NGOs to see the donors around them and get in contact with them.

Reaching out to more people around the globe

A lot of Egyptians all over the globe would mostly prefer to give their money donations or Zakah to the poor in Egypt or to help the people here to establish microprojects via microloans or similar models yet unfortunately there are no easy to use, credible and transparent platforms where they can do that. Then what about a mobile application that aggregates the cases from the different NGOs with their statuses and integrates with a payment gateway allowing people from other countries to donate their money online to specific cases.

Transparency

Any donor usually needs answers to some questions, where am I putting my donations exactly? which case am I supporting? and the more the donor pays, the more details and follow up they would expect to be provided with. This type of transparency is typically very difficult when you donate, for instance, via SMS or when you donate to an NGO via bank transfer but you aren’t sure where this amount of money was placed. The issue of transparency normally hinders some people from donating to NGOs. Again, this can be achieved by personalization of the donation experience when the user can have a dashboard listing the cases they are donating to and follow up on their progress with whatever amounts of money paid and with some history and statistics about the previous donations and cases.

Recurring Reminders and Notifications

We all usually get consumed in our daily work so we continuously need those reminders from NGOs or our friends if we pay a recurring donation to help some cases and technology definitely can help automating all of that with a combination of simple cron jobs on the server side and push notifications via an almost free service like Amazon SNS.

Follow up and Reconnecting

Technology in general will easily help the NGOs and the donors in several other aspects. One of those is following up on some cases that they donated for via SMSs or Push notifications which will definitely increase the credibility of the NGO.

Another one is reconnecting with the donors in case they are interested in helping specific types of cases when those cases appear or even sending and receiving feedback between Donors and NGOs.

Some Inspiring Examples

There are several inspiring examples in the charity world. I will just demonstrate the idea of three of them and there are others of course all over the globe.

Kiva is an amazing platform that provides microloans to different people all over the world to use them in unique and useful projects that would fit in their environment. The donations are mainly crowd-sourced and you can actually even choose to lend some people to help them do their project and then return your money back after they pay  and if you’re worried about being getting your money back, the loan repayment rate is 97% which indicates how successful they are.

Watsi is another adorable non-profit platform that focuses on crowd-sourcing donations to patients all over the world who are facing difficulties in paying for their treatments. They have an extensive database about the patients with their detailed cases, their stories and so on.

Farmraiser is a web and mobile platform that was built by robusta. It is a very good example for a community-service-like profitable platform. It is built to help organizations like schools, clubs,…etc raise funds for their campaigns by making students sell healthy food and these profits go to funding campaigns so there are four parties that are benefiting and profiting here, vendors who sell their products, campaign organizers who receive  funds for their campaigns, customers who buy healthy products and are encouraged to lead a healthy lifestyle and finally students who participate in the whole community service experience and learn to give back to their community.

There are definitely tons of other platforms with various ideas out there yet those three examples are just simple examples on the different types of platforms we are talking about and hope they would be utilized, implemented and followed instead of going for an informative website for an NGO.
To sum up, it is crucial for all NGOs and people working in the CSR field to pay attention to capitalizing on the available technologies and think creatively about new ideas that would make the lives of everyone easier and gets the most benefit out of the available tools that are already utilized by many and are becoming part of the people’s daily lives and culture.

To Infinity and Beyond

 

Arguably, one of the movies’ most famous catchwords, and despite the fact that my number 1 early-morning activity with my 3-year-old has recently been watching and reciting Toy Story at 7am on a weekend with one eye open and the other half-asleep, this post plays to a more serious note about an organization’s own journey of self-exploration…

2015 was a particularly interesting year for robusta particularly because, for a change, we rethought our strategy, structure and, believe it or not, our robustivity vision, too!

Lots of concerns have triggered such exercise. It was mostly about the pursuit of profitability, sustainability, scalability and where we see robusta in 5 years from now. It was quite regular of a discussion between the managing partners to question the scalability of robusta and if it’s ever a candidate for exceptional growth that fulfills ours and the team’s aspirations for humongous growth. Don’t get me wrong! robusta was doing quite well already but we’ve always seen robusta not as a boutique agency but rather a flagship empire and been questioning a lot the way to get there.

Inspired by Gallup’s Strengths Finder and our IGNITE Development Program designed and implemented by our good friends at Mirqah ( more on this in upcoming episodes), we decided to start our pursuit by identifying and playing to our organizational strengths.

Cutting a long story of several client meetings (more of disguised interviews), internal workshops and self-reflections, it was becoming clearer that our top 3 strengths were our solid development skills and portfolio, a strong and influential culture fueled by an exceptionally competent team and robusta’s brand equity, reputation and reach within diverse verticals. Our weaknesses have always been lack of clarity to what we aspire to become that translated into stretching ourselves too thin across several streams which eventually lead to subpar profitability.

Building on this understanding, we made some bold decisions of exiting some of our service offerings and accounts. We’ve completely abandoned Branding, Social Media, Microsoft-based technologies, and trivial/low potential tickets. The reasons why we stopped each are quite interesting and each deserves a blog post on its own. We naturally decided to focus on our leading services which are E-Commerce, Mobile, Websites and Web Apps.

We also turned around our perspective looking at our team and decided to get rid of the illusion of growth that comes with growing our headcount after figuring out this is, in most cases, nothing but a sign of lack of efficiency. Comes next naturally is an overpowering need to look after productivity and a sharply pruned work force that makes it easier to invest in our culture & human capital development.

Ironically, we’ve also figured out that there’s such a HUGE local market that we need to dominate first before crawling beyond borders. Last but not least, we’ve done what turned out to be a pretty good job standardizing and innovating our retainer-based project development/support packages.

The said resolutions automatically put us on track with total clarity on how to go about restructuring the organization to achieve what became our solid vision.

“To serve as a flagship of national economy and become one of the top listed EGX companies by 2030”

This also fits perfectly with our designated 4-fold mission towards our clients, our people, shareholders and the community.

Finally, what we’ve mostly learned the hard way is that although focus seems to be an obvious strategic recommendation for any organization, it takes a lot of wisdom and learning about your customers, competitors, team and, of course, yourself to really be able to tell what focus means and how it applies to your organization.