Thursday, October 15, 2015

Custom styles for Views and Widgets in Android Studio. A complete guide

On my last freelancer project for Android I was hired to create over 60 layouts (screens) for an App. I was told that there was about 2 weeks to complete all of them and I was already working in a different project for 8 hours a day, leaving only 3 hours to do the layouts if I were stupid enough to say yes.

Did I accept it? Yes. Why? Because I was going to use a Style and get it done in one weekend.

How does a style works and why you sould learn right now how to use them?

A Style in Android is very similar to a CSS style for your HTML; you have to define the visual properties in a file and then you can just apply those visual properties to your widgets. This is a no sweat situation where time is not in your side and there is a lot to be done.

When you use a style, the visual properties will remain in the app so you don't have to remember how much padding you are using or what is the color for this and that. The style has all that things declared so you only apply the style into the views you need. Money!

Creating a basic style for Android and applying it

Let's start creating our first style. We are going to make all our EditText to look the same according to what my customer wants: "rounded but not 'cartoonish' with a slight shadow to make it look 3D and witrh blue borders". Yes, my customer said 'cartoonish'.

Mi first assumption was that my customer wanted rounded corners but with a small radius. Maybe he was aware that the guideliness say that is best to avoid "curves" in your designs. "Bubble-like" buttons are not so popular right now. The seccond guess was the "background". I'ts clear what he meant, so we will use a gradient to do that. Lastly, the border will be blue.

How did I create a custom View with no Adobe skills? My XML is very sharp

The first step is to create the overall eye-candy, the "look-and-feel" with XML using a shape.

Go to you drawable folder, right click on it and select New>Drawable resource file.

Use 'edittext_normal_shape' as the name
Once you have the XML we will start using Android properties to define how our Edit Text is going to look.

First, let's make sure that the root DOM element is not <selector>, replace it by <shape>:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
  
</shape> 

Now, lets use a rectangle as the main shape of this image:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
   
</shape> 

Now we will add a gradient to make the shadow effect:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#FFF"
        android:centerColor="#FFF"
        android:endColor="#F3f3f3"
        android:angle="90">
    </gradient>

</shape> 

The gradient is using 3 colors. The bottom and middle color will be white, and the end color (top) will be grey so there is the shadow effect. We can define the angle of the gradient as a top-bottom color with 90 degrees.

Now lets define the rounded corners:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#FFF"
        android:centerColor="#FFF"
        android:endColor="#F3f3f3"
        android:angle="90">
    </gradient>
    <corners
        android:radius="4dp">
    </corners>

</shape> 

Now, the border line:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#FFF"
        android:centerColor="#FFF"
        android:endColor="#F3f3f3"
        android:angle="90">
    </gradient>
    <corners
        android:radius="4dp">
    </corners>
    <stroke
        android:color="#3d85c6"
        android:width="1dp">
    </stroke>

</shape>

What is this? This is the shape that will be used as image.We are not using any ".jpg" resource. Instead we can provide a valid, well structured description using XML. Actually, you can just use this as a background image for any EditText and the result will be the same as the picture above.

Since I have only 2 weeks to get it done, I will not set the "background" property for each EditText in each layout, let's use this as our Style.

 Open the Project Navigator with <Alt+1> then go to res>values>styles>styles.xml.

The Styles resource file is used to define all of your styles that will be used in your app, as long as you don't define anything there, the system will use the default look using this file with only 1 line of markup:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>
</resources>

The element <style> defines a style and will inherit from "Theme.AppCompat.Light.DarkActionBar" which is a main style already defined using the Android SDK. You can override most of the properties here making the "AppTheme" to look exactly how we want it.

Before we can override directly the style of the EditText using the background defined earlier, we need to create it's own style and use it to override. Since we are going to apply it to the EditText, we are inheriting from "Base.Widget.AppCompat.EditText".

Some of the names are very easy to understand. I don't know every item, but since it has "EditText" and "Widget" on it I can be 100% sure that this is an EditText.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

    <style name="CustomEditText" parent="Base.Widget.AppCompat.EditText">

    </style>

</resources>

Now, our "CustomEditText" style exists. It inherits every single property from the regular EditText but we need to override the background using our shape item.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

    <style name="CustomEditText" parent="Base.Widget.AppCompat.EditText">
        <item name="android:background">@drawable/edittext_normal_shape</item>
    </style>

</resources>

Our style is ready to use. From here, you can apply the style mannualy in every "style" property in each of your EditText or you can override the current style defined by the System.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
       <item name="android:editTextStyle">@style/CustomEditText</item>
    </style>

    <style name="CustomEditText" parent="Base.Widget.AppCompat.EditText">
        <item name="android:background">@drawable/edittext_normal_shape</item>
    </style>

</resources>

After these changes, you can navigate to any layout then drag and drop an EditText. You will see how the changes you have done to the style apply to the widget without writting a single line of code in the XML  properties of the widget.


This is the final result. Only XML then drag and drop

As you can see a simple xml can define the background image of a widget but it can also define the behavior.

The client said that the buttons should be circles, they must be in a blue color when enabled and slightly bigger when pressed but gray when disabled. This means that i have to define 3 different backgrounds, one for each state for the button.

State: Default.

Like in the EditText style, i have to create a shape and define some properties to make it look like a circle.

The default state is the "normal" state. When is neither pressed and disabled.

<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android">
    <size android:height="28dp" android:width="28dp">
    <solid android:color="#1C89AD">
    <stroke android:color="#91999C" android:width="2dp">
</stroke></solid></size></shape>


State: Pressed. 

Now lets make the pressed state, the only difference from the default state is that its slightly bigger.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <size android:height="28dp"
        android:width="28dp"/>
    <solid
        android:color="#1C89AD"/>
    <stroke
        android:color="#91999C"
        android:width="2dp"/>
</shape>

State: Disabled.

And finally let's make the disabled state.

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <size android:height="28dp"
        android:width="28dp"/>
    <solid
        android:color="#B6BFC2"/>
    <stroke
        android:color="#91999C"
        android:width="2dp"/>
</shape>

Now, lets create a selectable.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/btn_circle_default"></item>
    <item android:state_enabled="false"
        android:drawable="@drawable/btn_circle_disabled"></item>
    <item android:state_pressed="true"
        android:drawable="@drawable/btn_circle_pressed"/>
</selector>

As you can see, the selectable declares 3 states: default, disabled and pressed. Those 3 sates will have a drawable resource and will have to change from state to state according to the drawables.

Finally, lets go back to our style layout and assign this selectable to the button.

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:editTextStyle">@style/CustomEditText</item>
    </style>

    <style name="CustomEditText" parent="Base.Widget.AppCompat.EditText">
        <item name="android:background">@drawable/edittext_normal_shape</item>
    </style>

    <style name="CustomCircleButton" parent="Base.Widget.AppCompat.Button">
        <item name="android:background">@drawable/selectable_btn_circle</item>
    </style>

</resources>

Now we have a button ready to be used with a custom style.

After creating a set of styles for my app, I still have to match text styles: Titles, subtitles, description text and link texts. The good part is that I just need to adjust some parameters because there is no need for background drawables or states.

TextView Title

I will use the same color as the  button for the title on the textview and the size will be much bigger. Also, since it's a title it will be on the center.

Since I dont need a drawable for this, I can edit this directly from the style file.

<style name="CustomTitleTextView" parent="TextAppearance.AppCompat">
        <item name="android:textColor">#1C89AD</item>
        <item name="android:textSize">32sp</item>
        <item name="android:textAlignment">center</item>
    </style>

The style will be using a text color, a text size and the alignment by editing the items properly named. Using Android Studio 1.4 I can use the autocomplete to see what else I can edit.

Now I have the subtitle remaining. It will use the same color, so I can extend from the previous style

<style name="CustomSubtitleTextView" parent="CustomTitleTextView">
        <item name="android:textSize">22sp</item>
        <item name="android:textAlignment">left</item>
    </style>

As you can see, I'm extending the style from the previous text so the color is inherited but im overriding the text size and aligning it to left.


Apply the styles

Once you have the styles ready, you can set them in the layout editor. Navigate to a layout and lets add a button.


When the widget is created, you can select from the properties pallete the field "style".




With the "style" selected, press <Shift+Enter> and select the "Project" tab from the resources window. Scroll down to find your custom theme and select it. You can see in the preview the style definition. Click "Ok" to apply it.




Once it's completed, you will be able to see the changes in the style right in the layout preview.

This is a button with a custom style

Apply to all widgets.


Back to the story, I was very lucky to see that all widgets had the same style and I was able to override the Android default style with my own instead of setting the style for each widget every time I use one.

From the styles xml, I can just apply the item "style" to the widget, like the following example:

 <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:buttonStyle">@style/cutsomButtonStyle</item>
    </style>

Once done, you can just drag an drop a button (in this case) and it will inherit the style from the styles value.

So as you can se, it took some time to write all of the styles but in the end I did an awesome job. My customer was not just happy but he actually was amazed that I was able to do all of the work in such a reduced gap of time.

Thank you for reading!

Friday, October 9, 2015

Creating cutom themes in Android Studio with the Theme Editor.

In the early release of the Android Studio 1.4 a new feature caught my attention. I did not include it in the 6 reasons to start building apps in Android Studio because I think it deserves a complete review and at least a quick tutorial.

The Theme Editor allows you to set up the look and feel of the entire app. The theme will dictate the rules of the look of many widgets like Buttons and Text Views. It can also provide the color setup for tabs, selections, backgrounds and much more and save a lot of coding time.

Why you should define a theme?

Well, a theme will help you to use widgets and styles that match your app context. Instead of setting attributes for every widget and screen, you can define a style by default and focus on the model of the app. So let's not waste time and lets get our hands dirty.

1. Opening the Theme Editor


Press <Ctrl+Shift+A> to open the Action Search Bar, then type "Theme Editor". You will be able to pick the Theme Editor Action.



The theme editor will let you see how will the default theme will behave on every SDK. As you can see, the default theme styles are running in my app but we are going to define a theme of our own.



You can see how the default theme will behave by selecting an API level on the top menu of the Theme Editor. See how it changes when it switch from 23 to 10. (If you can't see other API options download the API from the Android SDK Manager).




2. Create a new Theme


Let's start by selecting the pop up menu from "Theme" and selecting "Create new Theme" and add "myNewTheme" as the name.




As you can see the new theme will inherit all the styles from the "AppTheme". Now let's add some changes so our theme looks unique.

Primary Color:


It's the main color of your app. It should be the most important color and identity of your app but it's not supposed to be the same as the background.

When you click on the pop up menu, a "Color picker" will be shown. Pick a color then click "Ok". As you can see, all of the widgets will update to match (if so) the color now playing in the theme.


Color Primary Dark


It's the color in the Android Bar. The Android bar will hold the status of the phone outside the app. Like battery and Wi-Fi signal. Also the clock. Usually the Color Primary Dark matches the Color Primary.

When you select the pop up menu for this field, there will be a color already pre-selected (The Primary Dark). All your colors seleected from the mixer will be added there so you can pick them faster.



If you are working with the api 23, the background text color will adjust from black to white to match the contrast and make ir more "readable". Pretty cool.

Color accent.


It's the color that will be used in most of the features like the progress bar, checkboxes, and radio buttons. Try to match the primary color but don't make it the same.

Color Foreground


According with the official documentation it will be used for displaying the background for imagery. This means that the background of an image will be that color so make sure you match it with the background color.

Navigation Bar


Will set the color of the bottom bar. The LolliPop Api allows you to paint that bar but with lower versions it will have no effect.

The usual GUI suggest that you paint it the same color as the color primary dark.

Text Color primary


When you try to edit this style, Android Studio will warn you about something werid: "@android:color/primary_text_default_material_light is a private Android resource". Ok... Whetever that means...



Basically it says that we cannot override that style so we have to define a new style for this. Click on the first element on the list and select a color. Then change the name of the "Name" to "my_text_color" so you create a unique color.

Use <my_text_color> in this case


As you can see, there is no longer a  "disabled" state or at least, the disabled state now it's in the same color of the enabled and this is a huge mistake un our UI design. All of the text is behaving the same way. Did we break something?

Well yes and no. The text we had previously defined was taking some attributes from different states:  A default (or enabled) state, and a disabled state. So we are going to do the same; we need to create a text that can respond to disabled, enabled states.

Click again in the Text Color field and move to "Project" tab. Select "New Resource" and select "New color File".



In the menu, use "my_text_style" as the file name and leave everything for default then click ok.

You will have to define your 2 states from the selector from the XML text editor. Lets start with the default state. As you can see I'm using the system color pallete then, I define the default state.

The resulting XML code will be like this one:

  <?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <item android:state_enabled="false" android:color="@color/secondary_text_disabled_material_light"/>    <item android:color="@color/my_text_color"/></selector> 

If you did everything right and if im actually explaining this like it's supposed, you will now see that in the preview thet text has a color for your enabled display and a different one for the disabled.

The Text color primary inverse will replace your current text color when the configuration of the theme changes for a dark theme. Just do the same for the previous step but remember now that the background will be black, so choose a brighter color.

Text color secondary


That will be used for the medium and small text colores. You can change it the same way we have been changing text colors and also for the inverse.

Background.


The window background will have this color. I'm not going to change it because i like how it looks now but let me explain a cool feature this thing has. Click on it and move to "Project". You can choose an image here instead of just a plain color. How cool is that?

At the end of the tutorial this is the result of my theme:


Once you have completed your changes you can just close the editor and all of the changes will be applied in your Layout Editor. Can you say "eye candy"?

There is a lot of room for learning and use of this tool. I can't wait to see how much can be accomplished using it but I won't spoil your fun.

Try it now!

Thank you for reading.

Thursday, October 8, 2015

5 Android Apps no one needs you to build

The Google Play store is full of them. We have downloaded at least 10 from each category only to remove them right away.

These are the apps that you don't need to make (unless someone is paying you).

1. Freemium Games


We all know the trending formula in the mobile gaming industry. You download a free app, you spend some time and you realize that you could pay to have more fun.

A lot of games exploit this feature knowing that spending 50 cents is pretty straightforward to anyone that can afford a smartphone but the actual game in many ocasions is hideous; either you have to spend 24 hours so you can make a little progress or you have to wait to try again.

The game by itself won't be able to sell if it's not hooked in the formula of another that has already millions of downloads. You won't believe me? Try searching for the word "crush" or "saga" in the Play Store then buckle up.

2. Theme apps


You are not the only one that saw Iron Man and the Jarvis interface. Deal with it.

There are thousands of apps that turn your phone using cool features and creating a new interface for you. Sure the screenshot looks very cool but in numerous cases you will have to root your phone; rooting a phone not only will decrease the number of downloads but it is a sign that the app is doing something that shold not be allowed and many users take care of what they put in their phones.

Rooting the phone is the first problem, after you test your app you will see how much memory and processor power it spends just for standing idle. Not everyone out there can afford the most powerful smartphone and in the sight of a few bugs the feedbacks will bury your app deep down in the bottom.

3. Steal Wi-Fi signals


It's illegal. Any doubts?

Google can and will scan some of the code in your app. If they find suspicious behavior in your app they will remove it and they could ban your account.

Does it worth it? Absolutely not!. There numerous public spaces with free Wi-Fi now. Most places offer that as part of the service. Hotels, stores, restaurants and the list goes on and on.

4. Fake features app


You are smart enough to realize that an app can't turn your screen into a fingerprint lock screen.

The user will download the app and once they realize of the scam there goes the negative review. Usually the reviews are a heads up for some bugs but with this kind of apps there is nothing to fix because there is no features at all!

Just don't waste your time in this.

5. Hello World apps


We are very proud of the community. I encourage everyone to go out and publish their apps and make a living of it.

But honesly, press a button then here is a kitten it's not going to make it. If you don't have a suitable idea that can actually be useful for at least 1 person then save it, learn more and try again later.

Thank you for reading


Save time with these Android Studio features

Android Studio is a very powerfull IDE. It has features that make it robust, attractive and well fitting for the modern programmer.

But if we are going only for the templates, the visual and the additional plugins we could be missing some important aspects of the IDE. There are many refactoring items that will help you boost your productivity and save some time to watch Netflix.

Generating constructor, setter and getters for any class.


Press <Alt+Insert> to show the "Generate" menu


You write a class to handle a data structure. You find out that it has over 20 properties and according to that guy in that book back at college, properties should remain private and you should acces them via setters and getters. What a dick!

When you write a class, you can invoke the <Alt+Insert> hot key. That will open the "Generate Code menu". You can select "Setters", "Getters" and "Constructor" and it will take the properties in your class and will build all that code just for you.

Overriding methods





An Activity has a lot of implemented methods. I don't even know how many are there but I'm sure i'll find out one day.

When a class can override a method, you can see all of them by using the hotkey <Ctrl+O> (thats an "oh" not a zero"). This will show you all of the methods that you can override from the current class. You just select one and click "Ok" and the IDE will write the code for you.

Creating new methods.




You are doing a big process. The flashback takes you to college again hearing those words "Decompose your code into sub-routines so the abstraction level is low". Whatever that means you figure that you have to create a new method.

In Android Studio you can just call a method then press <Alt+Enter> once the IDE couldn't find the method on the class. Then you can just select "Create method". The editor will create the return type if theree is a way to infere it; calling the method to an int will make a method that returns an int. Try it!

Implementing interface's methods.




Whenever a class implements an interface the IDE will look for any method in the interface and will check against the current methods the class.

After the IDE checks the missing methods of your implemented interfafce, you do the <Alt+Enter> trick over the class name and ask the IDE to implement the missing methods from the interface. It will also add the "Override" annotation.

Sorround code.




When a block of code needs to handle an exception, or you need to nest it inside an <If> you can call the <Ctrl+Alt+T> to sorround the selected code to wrap it betwen an operation like Try and Catch.

This will add the necesary spaces and will keep the code format without doing a mess.

Copy and paste line.


Put the cursor over a line of code then press <Ctrl+D>. This will copy the entire line and paste it right below.

 Now you know, you can boost your code speed with a few tricks from the IDE. Give it a try!.

I will keep adding more cool features for coding in Android Studio.
Thank you for reading.





4 Projects to avoid when you work as an independent mobile developer

When we start working as freelancers or independent developers it's very easy to be optimistic about getting hired for a project.

We usually don't know anything about project management and with the promise of being paid we rush and we accept any project thrown at us without realizing that we are signin a deal with the devil.

Be carefull for the projects you need to run away from

1.They will pay you... with more jobs




Freelancers often are a convenient outsourcing power because the low fees in our services could fit a low budget project, but when the budget is just way too low the managers usually throw the promise to give us more job later instead of the initial payment agreement.

That is just wrong and a very expensive scam for you. You'll work for them for almost-free costs and the profits from the projects will go right to their pockets. After that they will give you the "we don't see any further projects right now" speech and move on. Even if they throw a new project for you they will still try to negotiate a lower fee arguing that things are not going so well but more projects are comming. If you think carefully that doesn't have any sense at all.

It's very likely that if you stand firm and refuse to lower your fees they will never contact you again, but trust me, you are better that way.

2. Nobody knows exaclty what the app is supposed to do.




You meet with someone at the office (if it's on a public space then be warned, they don't even have an office) they will explain you the main idea, they will talk about your experience, they will love you, you will feel very comfortable and if you are lucky they will hire you.

The first warning: A week after you got the job, you haven't heard anything from them. Someone sent you some screenshots of some ugly drawings so you start with it.

The things get ugly: You have some sketches from drawings made in MS Paint, you have to assemble what is the app supposed to do by some words with no sense from an e-mail. Good thing is that there is not a deadline.

You are doomed: The initial draft you made for the app has to be dumped. In the last meeting they brought things up that you never heard before. They added so many features nobody ever told you before and they need some images added but no one know who is making those. Worst part? You already signed.

Don't call me again: The app is a disaster. You wrapped it trying to fit the ridiculous requests from your contractor. You are aware of a thousand bugs and hardcoded functions that you had to do on a monday at 3:00 A.M. because they needed that for the next morning.

When you are signing, you must have a sheet with all the features of the app named requirements agreement. They have to agree that everything out of that sheet will have an additional cost and will extend delivery dates. There can't be anything left unattended or you will have to do it for free. Proctect your job and your quality.

3. You will be doing... everything




"... after the login, the app will load the configuration for the user and it will show you your info and your preferences..." - "That sounds great. (You should always ask this) Are those login services built or how do I get the answer from the service?" - "Oh... well, you could build those first but whatever you do will be fine"

So they not only want you to build an app. They need you to build a web service, a webpage, a database and an admin panel.

Sure it sounds like a lot of money, you could charge a lot and have a decent job for a few months, what could possibly go wrong? The down part is that there is just way too much job to be done. Anything going wrong it's your fault, anything delayed it's your fault, anything left behind is your fault. You will have to deal with several technologies to build an entire framework.

Make sure you can delegate the work to other freelancers or be very clear with the manager that you can't do all by yourself. Get rid of huge projects that will drown you in work for 6 months. You have to work for a living, not a life to work.

4. They will not pay you... at all. 




Charity sounds great... for a church. It doesn't matter that is "for a right cause". You can't pay rent from good actions. I'ts not like you don't want to do any good to the world and create a better society, but unfortunately you have expenses and you can't give away your job for free.

Adding unpaid experience too your resume is a bad idea. Managers will see it as an oportunity to play projects like the #1 in this list. If they need free work, then can get it from colleges and "wanna-be rockstars because they saw 'Social Network' and want to play the 'I'm that guy'". You are a freelancer, you are a pro! you are not the kind of guy that needs them, they need you and you need to get paid for everything you do. Also there is a famous quote: 'If you are good doing something, never do it for free'.

Thanks for reading!

Wednesday, October 7, 2015

5 mistakes to avoid as an independent Android Developer

You are on the street, you stare at the red traffic light and suddenly it hits you (I'm not talking about the bus).

When an idea comes we all enthusiast developers start our engines and we explode in a motivation bomb. We want to get rid of whatever we are doing and go to the desk, launch Android Studio and start a new project! Then we leave it in the depth of our hard drive to be never touched again and then we ask ourselves "When will I publish another app?".

When it comes to be a developer of you own ideas you are on a very thin ice. You don't have deadlines, you don't have a boss harassing you and the lack of motivation is everywhere.
If you strugle to get work done you maybe are making some of the following mistakes.

1. Build an entrire framework at day 1.


When you start a project you are full of ideas, you are like a toddler in a sugar rush inside a toy store. A common mistake we all make is to start building the entire arquitecture of the project. We start developing and chosing final colors, we want to develop the entire API for the project, we build exceptions and they stack up with unused names like "NoValidStringReferenceLayoutDetectionException", then we build so many interfaces that we don't even know what to do with those and we forget what they even do.

When you start stacking all of those elements in your project you will requiere more project management and you'll end up givin up the most important part: Actually making the app do what you wanted to do. After this point, the project is no longer interesting and we delete it to start over again.

Start by focusing on the main model and answer the question: What is the app supposed to do?. Write that down, and start working on that. Forget about the layouts, forget about the Russian and Portuguese translation, forget about coding like a hacker, forget about the laws of proportion and the golden number and get your app do what you wanted to do in the first place.

When you have the heart of the app you can move faster to new modules like the themes or implementing a few interfaces to make it more clean and readable. Work from the inside out.

2. Get (late) job done in a weekend.


It has been a week. The project remains untouched and you say "I'll end it on the weekend".

When the weekend arrives you get up at noon, you get some breakfast and why not?, you could do some laundy while you watch some Netflix, I mean you have all night for your project right? Unless Oscar has invited guests over to your house and you end up waking up naked in yout kitchen.

It's ok if you can be more productive on weekends. I like to go to a coffee shop and do some work there but when I leave it for more that 1 day I forget what was I doing or worse: "What the hell is this interface for?". A weekend rush is very productive but when you haven't accomplished nothing in the week it's like starting a car in the middle of a really cold night and pushing the gas right away. You need some warmup, you'll need to keep track of things that you are doing and things that are already complete.

I usually do a couple of lines every day. One small solution at a time and I left tracks of my work for my future me. When the weekend arrives, I'm ready, motivated and with a lot of punctual tasks to do. I amazes me how fast my projects start evolving to real mature solutions.

3. Starting a new project when you are already in one.


Some companies manage their programmers very well. They know that you have to focus in one thing at a time and sometimes they have to reject projects because there is no spare time to do a good job for it. Get the job done, but get it done the right way.

It's very natural that once the juice is flowing the ideas start bursting from your creative rush. After all, you are human and your brain is constantly being stimulated but when you abandon a project to start one, you are not working twice faster, you are working 50% slower because you have to keep both projects alive. Remember mistake 2?.

Write the idea down instead, keep track of it and if you have spare time try to give more context to yout future projects so you don't have to think in that when you start it. Once you are complete wih a project then start the next one.

If you can handle 2 projects, try to not jump from one to another, do your punctual tasks, and move to the next projects, get the work done and get back to the previous.

Also, a project that gets interrupted half-development is more likely to end up abandoned.

4. Stopping because you can't figure out a single feature at the given moment


Sometimes it happens. You are in the middle of a code spree then you have to stop because you can't find out how to build a custom progress bar with a shape.

This mistake is very hard to avoid because it's impossible to know everything on the go. Most likely you have to stop so you can learn and ask for help. And after that you have to crash it a 100 times before you can be 100% sure that it won't crash again only to find out that it keeps crashinig. It's normal, you are learning.

But if a single feature keeps consuming your vital developing time try to workaround it. Find a solution, a temporary one that allows you to keep developing the the task, to get the job done and move on or better yet, ask yourself "Why is so important to develop this feature?". If you have a very good answer, then keep working on it but if you struggle to answer maybe you could skip that part.

5. Asking someone else to do it for you.


Stop it! If you can't pay a freelancer, a friend won't share time working for your projects. Saying "I gave you the idea" will not make you owner of the project neither the boss of whoever is helping you unless you pay for it.

Most of independent Android developers eat like any other person and it's very offensive to ask them to do them for free. Also nothing but morals and ethics stop them from stealing your ideas.

Grab a lap and "Just do it!".

Thank you for reading and share your toughts on those mistakes you have done.

6 Reasons to develop in Android Studio

It has come to my attention that a lot of people keep asking me if Android Studio is a "stable IDE for Android apps development". I mean it has "Android" on it, and it's a Studio so it's a win-win situation, right?

I think the concern has the root in the early versions of AS (Android Studio); It was very bad! It had a lot of bugs, it was not stable enough, it could crash any second and that red message in you upper-right corner blinking "IDE ERROR" was very frustrating. I started using it since it was released or at least on a very early version. I was aware that it was a beta product and was not ready to develop a proffesional app or at least not suitable to move entirely from Eclipse.

Saddly, many users like me felt a little bit disappointed when we found out that AS was not ready to become the next IDE and Eclipse would continue as the Android IDE for some time but not for too long.

Not too much ago, Android Studio 1.0 was released and lot of users like me saw the official IDE complete, mature enough, robust, capable and almost bug-free as we always wanted. We saw it grow, we saw it get stronger and bigger and by the release 0.8 it was prietty good already. By the time it was released I was "Eclipse-free" and all my projects, all my work and my collegue final proyect was already integrated in Android Studio.

It was a long, complicated, bumpy and hard road but here we are all with Android Studio 1.4 but the question remanins: ¿Why should I move to Android Studio? Well, here are my 6 reasons to move to develop in Android Studio.

1. Integrated Layout and Widget Editor with built-in pre-configurated screens

 
Android Studio layout editor. See https://developer.android.com/tools/studio/index.html



Android Studio has a fantastic built-in layout editor. Just as simple as drag and drop for begginers or for the pros that like to write the code all by themselves. The editor updates automatically as you write the syintax for an element and can help you with shortcuts to boost your productivity.

It has a function that allows you to preview the layout without starting the emulator so you can see the estimate on a 3.5' screen or in a 10.5' tablet. It can associate with your Java code so it grabs the context of the Activity and adjust the styles and parameters properly.

You can rotate the preview, select multiple previews, edit the properties right in the properties pallete of a selected element and change the local languaje (given that you have the translation) and it adjust by the specified theme in your styles resources folder. Yes, you can see your custom buttons.

 2. Pre-built templates to get started


Android Studio allows to create an Activity from a template to save time.

AS has a lot of templates and "pre-cooked" apps so you can start faster. You can skip all the templates and still AS will build up for you the manifest, the layout, the menu layout, some code to get started with the menu and will add some resources folders for you.

It can help you build a Google Maps Activity ready to use your API Key, a ready-to-navigate Activity with some fragments in it and some pre-cooked layouts so you won't spend too much time coding basic things like a "Settings Tab".

You can also edit the template so you can customize to use your own code.


3. Translations Editor


The Translations Editor allows you to skip writting XML markups to write your String resources. You can quickly navigate to a new languaje and set the translations from the original string resource folder without having to go line by line and writting values.

It also has a "Untranslatable" check button to make a String unstranslatable.

4. Ready for Android TV and Android Wear.


You can create an Android Wear App with templates

AS is not only suitable to develop Tablet and Smartphone apps. You can make your app compatible for Wear, TV, Android Auto and Google Glass.

AS will help you to render the layouts that you need given the selection of the compatible devices for your app.

5. The auto complete function


Whenever it comes to speeding things up, we already know that some IDE's provide some hot-keys and functions that make you feel more productive.

When you get familiar with the hot-keys in AS and the autocomplete function you will start to code faster and better. It is smart enough to suggest you valid arguments and how to get them. It helps you to build faster things that you already know. Period.

6. The Darcula theme.


Dark themes are more gentle with your eyes.

Yes, I love the IDE trending to make darker themes and the whole "I'm a super hacker" experience. It makes you look like a pro developer building SkyNet, it makes the code look like a complicated master piece even if its a "Hello World".

Actually the dark themes are so popular because it seems that they are more relaxing for longer coding hours. Let's face it, staring a computer and reading tiny words in it is not going to make you look more interesting but we really love it when it comes with a more siutable color for your already screwed eyes.

There are lots of new features in the earliest Android Studio features. All of them are fantastic and try-worthy, like the device monitor, that helps you to keep track of the memory usage in the real device or emulator. The debbugin now allows you to see the value of variables in the real code, you can keep track of memory allocation and much more.

So, if you still wonder if Android Studio is "stable enough" to try it I will roll my eyes again and say "Just try it, it will amaze you".

Thank you for reading.