various android ui things

20130817_120219

I just finished a small android project this morning. Yesterday evening I came across the code of someone on GitHub who had built a small duel game about Harry Potter. This was java application and you can play this in the console. So I then forked the repo and created the android application for it. You can find my project here: https://github.com/mrwonderman/Harry-Potter-Duel

The application is completely playable but I won’t publish the application to the play store as the game code isn’t from myself. But feel free to check the code out and try it yourself.

Now I learned some nice small things while writing the application. For example, you can append text to a TextView with the following command. So you don’t need to get and set the text manually.

textView.append("yay !");

Another thing is, how to make a TextView scrollable. I added the following lines to the xml layout of the TextView:

android:scrollbars="vertical"

android:singleLine="false"

and in the java code you need to use the following line:

textView.setMovementMethod(ScrollingMovementMethod.getInstance());

To display a Progressbar from right to left is very easy. Just use the following code:

progressBar.setRotation(180);

This then can look like that:

progressbarRTL

android-square-progressbar v.1.2.0

IMG_20130811_112751

After the summer holidays I ‘m publishing the next major version of the android-square-progressbar library. This isn’t actually a really big major version to the library itself, but the example application has changed very much. I’m now using the Navigation Drawer (https://developer.android.com/design/patterns/navigation-drawer.html) and a new Holo-Theme.

Navigation Drawer

Screenshot_2013-08-11-11-35-33With the navigation drawer I was able to move all the customisation things to another layer which is still easy to access. In the Navigation Drawer you can now choose the colour, activate the new opacity style, choose another image or visit the github page right from the app.

The Navigation Drawer is really easy to use and I created a small repository on Github where I’m hosting a basic version of an application which already contains a full configured Navigation Drawer. It still needs some fine tuning, so maybe check it out here later this month: BaseNavigationDrawer (GitHub). I will use this in future projects with Navigation Drawer’s.

The only thing I miss is the possibility to set a Style (like android.R.style.Theme_Holo_Light) to it. I haven’t found a possibility to do this. But I think this is supposed to be so, as you shouldn’t but any form widgets in there like CheckBoxes or Buttons.

This is now the second application where I am using the Navigation Drawer as the main navigation possibility and I can only recommend it. The other one was the “Current and Voltage” application here.

Opacity

Back to the new things the library can do now. As you see in the next image you can now activate the opacity. This will let the image disappear if the progress is 0, but I will appear more and more when the progress gets higher. When it reaches 100% then the images is shown normally. This can be a nice way to display the progress even more.

Screenshot_2013-08-11-11-35-42Screenshot_2013-08-11-11-35-55

 

You can set the opacity to the squareProgressBar with the following command:

squareProgressBar.setOpacity(true);

The road ahead

This is now the 4th update of the library and I want to bring a next one to you in september. I want to focus on these things:

  • OpenGL
  • Handling of bigger images
  • Some progressbar features

If you have any ideas of how I can improve the library, just comment or message me.

You can find the application and the source here:

Play Store : https://play.google.com/store/apps/details?id=net.yscs.android.square_progressbar_example

Github : https://github.com/mrwonderman/android-square-progressbar/

tree on mac os x ft. dart

Long time ago I wrote a small dart script which prints a light nice tree in the console. You can find it on github here: https://github.com/mrwonderman/dart-tree

Simply check it out and then use the following steps to integrate it. After that you can use it for example, the terminal of mac os x, which hasn’t got a native tree command.

1. edit your .profile file in your home directory

Screen Shot 2013-07-04 at 21.51.17

2. add a new line, which contains something like that:

Screen Shot 2013-07-04 at 21.53.09

vi can be a bit tricky. You need to press ‘i’ first to switch to the insert view. Then write the new line, press the ESC-key and write ‘:w’ and press enter. This saves the document. Type ‘:q’ to close the document. Use the location where you checked out the tree.dart script. Maybe you need to add dart to your PATH var, if you haven’t already:

Screen Shot 2013-07-04 at 21.55.49

3. Restart the terminal and run tree in a folder of your choice:

Screen Shot 2013-07-04 at 21.58.52

If you have any questions or feature-request, do let me know on github.

android-square-progressbar v.1.1.0

IMG_20130628_185136

Finally the new version of the android-square-progressbar is now available.  This version has some major features like:

  • custom width of the progressbar
  • easy methods to set the colours (holo-colours, hexcoloursand RGB)
  • better algorithm
  • new example app

In the new example app I made some bigger changes. First of all the pictures are now completely different, because I don’t want to run into any copyright problems. Another big change are the new 2 elements where you can set the width of the progressbar and the colour.

You now can simply set the colour of the bar with the following code:

squareProgressBar.setColor("#C9C9C9");

or

squareProgressBar.setHoloColor(color.holo_blue_dark);

This is really helpful and a better way to set the colour as in the first version. In the app you can choose the colour like that:

newcolour

 Actually the new major feature is the possibility to set the width of the progressbar. I recommend to set it between 3 and 20 dp.

 squareProgressBar.setWidth(8);

Here are some examples:

newscreen1newscreen2

Another big improvement is the new algorithm. It is now working properly and it handles the width quite well.

Play Store : https://play.google.com/store/apps/details?id=net.yscs.android.square_progressbar_example

Github : https://github.com/mrwonderman/android-square-progressbar/

20 Searches [through Glass]

“Strom und Spannung” version 1.1.0 release

I’m finally releasing a new version of the “Strom und Spannung”‘s app this evening. Finally I managed to make a complete translation of the app. I had to guess a lot of the tecnical words, but I think it’s alright. If you find something, please tell me :).

Some other new features are:

  • Much better unified UI
  • Calculation of the resistance when the temperature changes
  • Many user enhancements

You can get the newest version here: https://play.google.com/store/apps/details?id=net.yscs.android.stromundspannung

Recording to my awkward roadmap, there will be a small update in a week or so for bugfixes. But the new major update won’t hit the play store until mid august. I’ve got some big topics I want to include into the app and make it available to tablets. But let’s see :).

At this point I really want to recommend the lint markers. You can right click on your android project and choose the following sub menu:Screen Shot 2013-06-10 at 21.16.08
This will show you parts of your code that you can improve. This really helps to keep your code clean and avoid some UI-Bugs.

“Strom und Spannung v1.0” release today

ic_launcher-web

This morning I finally released my calculation application about current and voltage. I know there are a lot of other applications that can do this too, but I wanted to publish the application. I think the application is very basic but okay. Another thing is, that I developed the whole application in German.

A lot of things changed since I last published an application, and the tutorial got even longer: http://developer.android.com/tools/publishing/app-signing.html

The main reason I developed the app was that I wanted to work with the new Navigation Drawer. Take a look at it in the following screen:

device-2013-05-26-100047This Navigation Drawer replaces my former tab-layout perfectly. And it’s really easy to implement. Take a look at the following sites:

http://developer.android.com/design/patterns/navigation-drawer.html

http://developer.android.com/training/implementing-navigation/nav-drawer.html

But a least there is one good thing, the code of my app  is opensource, so you can check it out yourself and feel free to download the app in the play store.

https://github.com/mrwonderman/stromspannung

https://play.google.com/store/apps/details?id=net.yscs.android.stromundspannung

android-square-progressbar

I finally finished my first android library this night. The idea behind the android-square-progressbar library is that you can display a ProgressBar which surrounds a picture. This could be helpful if you don’t have  space for a normal ProgressBar or so.

You can find my github project here, this includes the actual library and an example app: https://github.com/mrwonderman/android-square-progressbar

You can download the library here: http://pub.signer.pro/android-square-progressbar-1.0.1.jar

And the example app here: http://pub.signer.pro/android-square-progressbar-example-1.0.1.apk

At the moment it has the possibility to set different colors. But in the future I see more features like thickness of the ProgressBar and some design things to. The library supports more or less all different shapes of images, as demonstrated in the example app.

Here are some examples how it could look like.

one two

To add this to a project, simply add the following part to your XML-Layout:

<net.yscs.android.square_progressbar.SquareProgressBar
android:id="@+id/subi1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true" />

You then can access it from the java code like that:

SquareProgressBar subi = (SquareProgressBar) findViewById(R.id.subi1);
subi.setImage(R.drawable.house);
subi.setProgress(25);

Configure JNDI/JDBC(MySQL) connection in JBoss

Small snippet that shows how you configure a JNDI connection in JBoss. This connection is a MySQL/JDBC connection. Just name it mysql-ds.xml and but it in the deploy folder on your JBoss-Server.

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/translations</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/translationsdb</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password></password>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

Dart: Calculate all occurrences of a substring

I recently wanted to calculate all occurrences of a substring in a string with Dart. The code I used is nearly the same as you would use in Java to do this. So here’s my snippet for Dart:

int countOccurences(mainString, search) {
 int lInx = 0;
 int count =0;
 while(lInx != -1){
 lInx = mainString.indexOf(search,lInx);
 if( lInx != -1){
 count++;
 lInx+=search.length;
 }
 }
 return count;
}

You can now simply call it like that:

int countAll = countOccurences(sameRandomString, "smile");