Saturday, May 30, 2015

Sonar Qube Installation on Mac using Homebrew

Prerequisites: Installation of Homebrew would be ready
http://brew.sh/

For installation of SonarQube

  1. Java would be installed on your machine. Installation link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. On terminal window type "brew install sonar". After completion.
  3. On terminal window type "brew install sonar-runner". After completion
  4. On terminal window type "sonar console". This would start sonar server. For checking type http://localhost:9000/
  5. Once done for your Android Projects create the sonar-project.properties file. A dummy sonar-project.properties file is created at https://gist.github.com/jayshildave/7dbe249ebeb9b3599d93. The URL expects you are using a Android Studio project
  6. Now go to the project directory in terminal type the command "sonar-runner" to execute SonarQube for your project
  7. The output would be shown as below:



Wednesday, October 5, 2011

Android selector background issue for Layouts

How many times we have found that if you wish to have a background to your layout, similar to what we get in list items by using the tag its just not possible in Android.

In order to get this on a layout there is still a way.

Lets consider that we have a layout as below:

Relative Layout
Text View
Image View
Relative Layout

Now if you want to have the background of your layout from something like a drawable for both the states like pressed and default it simply doesn't take it even using the as the background.

In cases like this below technique can be used to just get the desired behaviour.

1. Create the layout file as
Relative Layout
View (Background of the layout, width and height should be same as the outer Layout)
Text View
Image View
Relative Layout

2. Go to the .java file.
Set the onTouchListener() to the RelativeLayout.
In that check for the following MotionEvents
a. MotionEvent.ACTION_DOWN
b. MotionEvent.ACTION_UP & MotionEvent.ACTION_CANCEL

3. In this if-else do the following:
a. From the View object use findViewById() and findViewById()
b. Set the background color and background resource on the view and textview.

4. "return false" from the onTouchListener() in case you want events in onClickListener().

That would give you the "" feel on a simple layout.

Note: when you are trying to set the color make sure its (0xffRRGGBB) i was trying (0xRRGGBB) and was not getting the correct color, wasted half an hour debugging this.

Signing off,
J

Saturday, February 26, 2011

Adjustresize issue on multiple editexts in a scroll view



OK i had a horrid time figuring out how to implement a scroll view in the above case. When the keyboard opened up it hardly space of about 2 fields to be viewed in an 320X480 (MDPI) device.
Also, whenever the user clicked on the views which arent in display, meaning which required to be scrolled. The scrollview never scrolled to that item. Try having the android:fillViewPort="true" for the scrollview it still dint work. I tried removing the title and it worked as a charm. But that was not the option to be used. Because the application i was building required the title to be present and be of exactly 160dip :( bad design but i guess i had to live with it. But i always wondered how did it work when it was full screen. My colleague Amit Chintawar gave a explanation that there isnt enuf space for the scrollview to scroll, which I dont completely agree, the scroll view has to scroll to that position by itself.

However finally i found a tweak and it made it possible.

Solution was to use the ever so charming "RelativeLayout" to draw the screen.
Have your title layout placed in the outer Relatvie Layout with a height of 160 dip.
Now place your scroll view also in the same outer layout as it is.

The first item in the Linear layout which is mandatory to have within the scrollView (by mandatory i mean a layout is mandatory to be kept) so coming back to the first item, have a android:layout_marginTop as 160dip. So eventually both the title layout and scroll view gets to start of from the top of the screen. Just that for the user it will appear after the title layout, and yes even within the small display it will scroll to even the last item in the screen.

Ok, before i forget one of the most important things. In the outer relative layout have the scrollView first and then the title relative layout, reason if your first item has some specific background then it will be drawn over the title layout causing the title never t be displayed ever.

So the layout file would look like below:

RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"
android:fillViewport="true"
LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
item 1 with margin of 160 dip
item 2
....
item 14
LinearLayout

ScrollView

RelativeLayout android:layout_width="fill_parent" android:layout_height="160dip"
Title
RelativeLayout

RelativeLayout

This will ensure that however long you items in the scroll view goes it will still get that item in display when it being tapped and the Keypad is opened.

I hope this would help some developer trying to build a scroll view with many text views in it and to get it scrolled on all the devices.

P.S. The problem occured in the emulator of Android 1.6 as well as the SonyEricsson device Xperia X8 at 1.6 maybe it doesnt happen on Android's latest version but still a problem on 1.6 for sure.

Signing Off,
J
(proud to be a Anddev)

Tuesday, August 31, 2010

Creating syncML.jar files using ANT from Funambol.

Compiling and building syncML.jar using ANT. (Funambol)

For this you would need the below mentioned tools.

1. WTK (Wireless too kit)

The same can be downloaded from the below link.
WIreless Tool Kit

2. Apache ant setup

The same can be downloaded from the below link.
Apache ant

3. Antenna.jar

The same can be downloaded from the below link.
Antenna.jar

4. JDK

This goes without saying.

The sdk for the same can be found from the below link.
Funambol sdk 8.7

Steps for the same:

1. Download the funambol sdk. (Generally, gets saved in the C:/Documents and settings/${user})

2. Download the latest WTK, Apache Ant and antenna.jar file.

3. Install the WTK tool. It gets added generally in c drive. i.e. C:/WTK 2.5.2_01

4. Copy the Apache ant 1.8 to your c drive.

5. Copy the antenna.jar file to the ant lib directory (this is very important for it to work)

6. Set environmental variables in your My Computer.

Set ${JAVA_HOME} and ${ANT_HOME}.
Also in your path variable set the part to ${JAVA_HOME}/bin and ${ANT_HOME}/bin

7. Open command prompt and try ant command. If it gives an internal error, the environmental variables are not set correctly.

8. Once that works, go to the build directory of Common project first in syncML folder. Build the syncML-Common-funambol.jar

9. Copy this in the lib of syncML project. Now go and build the syncML project. The synML-client-funambol.jar is created.

P.S. For creating the jar file you can use "ant build".

Note: In the syncML 1.8 in the build.properties file the WTK directory is C:/WTK 2.5.1, change it to your WTK directory otherwise it will give wtk.home directory doesnt exists.

I hope this helps someone who wants to use the syncML library.

J

Saturday, August 28, 2010

Life

Strange, I absolutely don't know what i am gonna write about, but lets give it a shot :)
P.S. There's always a option to delete it :)

Life is a phenomenal nature of the universe, which starts just to end. Or rather its a process where from absolutely nothing something very beautiful, very divine is made just to again go back to nothing. I feel life would be something which is worth its entire while when it was there.

Arghhh, nice lines but cant think of anything to continue on :(

Life is one of the most serene and most cherished moments of one's life. Ask that to a mother who has just delivered, or ask that to a person who has just had near death experience, or for that matter of sake ask a person who is trying to catch his breath.

Life is a gift of nature to the human beings which has to be cherished, loved, pampered, spoil t, and most importantly respected.

Live life, cherish all the moments as there wont be a tomorrow, stay happy and just keep smiling.