Android Studio / IntelliJ IDEA code regions

If you ever worked with Xcode then you must know the power of “#pragma mark” macro. You could just define regions of code using that and sometimes it helps when you have classes that can get a bit big or if you just want to have a nice structure of your class.

Well you can do that on Android Studio or IntelliJ IDEA or any of JetBrains’s IDE.

Using the steps below you can group your code and name the group however you like and also contract/expand the groups of code.

Code without grouping
Code without grouping feature

1. Open the IDE you are using

2. Select the code you want to group like in the image below

Group selection
Code selection

3. Press Ctrl + Alt + T and select the “region .. end region comments”

Group selection dialog
Group selection dialog

4. Now the code is surrounded with “//region” / “//endregion” lines, you can see that the region can be fold-able

Initial code region
Initial code region

5. You can now edit the description of your group

Collapsed Group with description
Collapsed Group with description

6. You can easily see the code within your group without having to expand the group, just hover the group description with the mouse pointer

Group code preview
Group code preview

As you can see from the first and last images, the class body is reduced dramatically and it can be better organised.

See more about this here.

Android Studio – TestFlight upload plugin

As you well know the new IDE for Android is Android Studio and it is using the power of Intellij IDEA IDE which is great.If you work with TestFlight to distribute your builds to your testing teams or customers, you will surely like my new plugin that helps you upload the builds more faster and notify people in distribution lists, it also lets you assign the app to the distribution lists.

The plugin works on Android Studio and IntellijIDEA and lets you store multiple teams and distribution lists for each team so you won’t need to browse to testflight website every time you want to upload a new android build. The plugin will also save the path to your apk file so basically after you make the first setup, next uploads you will just have to select the saved team and distribution lists and add the build changes text and your build is ready for testing :).

The plugin name is TF Uploader and you can install it either directly from jetbrains repository from the IDE settings -> plugins or you can download it from here and install it manually from IDE -> settings -> plugins.

If you like it, please vote it and also please let me some impressions here, it will help me do it better.

How to import an Intellij project in android after you reinstalled your Intellij

If it happened to reinstall your Intelij and you don’t remember how to import your android projects maybe this post will help you, even a little at least. So, lets begin.

Step 1: Press CTRL+SHIFT+ALT+S and the Project Structure window will open. On the left click on the project and then press the new button like in the picture.

Step 2:  After you pressed the “new” button you will see a list. Select the JSDK option and find your JDK1.5 or 1.6 (JDK is where you installed your Java). Then press the “new” button again and choose Android SDK this time, like in the pictures below and search for the path where your android folder is on your computer. After this you will have to select the version of jdk 1.5 or 1.6 and then the android plarform (I selected android 2.1)

Step 3: At this step you must have your settings like this:

Step 4:  That’s all with the project settings. Let’s move on the next part. On the left of the window just below the Project, click on Modules. Here there’s nothing for the moment but it will be. Now you have to click on the “+” button just like in the picture below:

Step 5: After you clicked the button this window will open and you will have to do what the picture says:

Step 6: After you pressed the “…” button a windows explorer will be opened and you will have to search for your project and select the “.iml” file like in the picture:

Step 7:  Now your project is imported. If you click on the name of your project you will see on the right some options. Click on the “Paths” and be sure to check the first option like in the picture.

Step 8: Now click to “Dependencies” and press the “new” button like in the picture and select the Android SDK and then the platform for Android (2.1 in our case).

Step 9: Now your settings must be like in the picture (of course, if you made the project on another platform you will must have your platform on the Module SDK. After this press ok and that’s it. Your project is ready.