dialog-300x249

Creating a nice looking List dialog with images and text

This tutorial, will demonstrate how you can create a great looking selectiondialog, containing both text and images.

alt text

This list can then be used either directly in an Activity, Fragment, or as an Activity looking like a dialog. In this example, I will go with the latter, and create an activity that looks like a selection dialog window, that, in this case will be used to choose a country.

Creating such a selection list is easy if it should contain text only, but a bit more complicated if you also want to include images.

Continue reading

lp-mini-review2

LastPass Mini Review

I have been trying out Lastpass as chrome extion, and mobile app for a few days, and heres a couple of things I have come across, as an avid Keepass user.

Feature requests

  • Tags – So I can group together items for different situations
  • Item duplicate – To avoid having to copy paste al lot of data
  • Ability to move a folder into another folder. Now I have to create a new folder where I want to move the items, move all the items, then delete the old foler.
  • Secure notes with a password and username field. Just like a “site”, except it does not have a url. Why does this not exist?…

Things I wonder about

  • Are all data encrypted? Also comment fields?
  • Why does the “view my deleted items” go to a lastpass.com website, instead of the chrome plugin?
  • How often does LastPass synchronize items, and does it do delta-sync? (and is that one item at a time?)
  • The security. Having my (encrypted) data stored at some companys server
  • Why does “secure notes” have a “copy username” and “copy password” context menu, when a regular secure note does not have these fields?

Problems importing data from Keepass

I have tried to import entries from Keepass, using the keepass xml export functionality. The basic import works, however there is quite a few quirks.

  • Import from Keepass is automatically turned into Lastpass “secure notes” if they are missing and url. I then have to create a new “site entry”, enter an url, and copy the data over there. Instead of being able to just add an url field afterwards, if it is missing.
  • Import from Keepass, sometimes triples, or quadruples all the text in the comment field!
  • Import from Keepass messes up special norwegian characters “æøå”

Bugs?

In addition to the bugs mentioned in the section above:

  • File attachments for secure notes in lastpass, loose their filenames. When saving such a file to disk from lastpass, the filname field is completely blank, but the file extension seems to be correct. This makes it impossible to know which file I am actually saving…
  • I cannot find the “History” tab for secure notes, to view a notes history, although it’s described here.

Things I miss from Keepass

  • Having the option in Keepass to use a password and a keyfile, for extra security.
  • Better control over the entries, with entry duplication, change history and more
  • Can use keyfile in addition to the password
  • Better overview of all folders and items
  • Being able to view attachment file sizes
  • Being able to see which entries that have attachments in the main list

Things I don’t like about Lastpass

  • The folder dropdown dialog when creating a new site or secure note. This list becomes quite ugly after adding a couple of folders

Things I like about LastPass

  • Browser integration
  • Syncing
  • Mobile app

Now, these things you may be able to do with Keepass and plugins, and by syncing the database over Dropbox, but that is a tad more cumbersome.

buttons-with-separators3

How to create simple view separators

This will show you three ways to create nice looking view separators, to use between a row of buttons for example.

The examples shows a LinearLayout with three buttons, that should get separators in between them.
The third example may be the easiest one to implement, while the other ones gives you better customizability.

buttons-with-separators3

 

 

Method one – Manually adding a view separator to the LinearLayout

We can create a simple View that represents the separator, and just add it in between our buttons.

As a separator, we can use a view like this:


<View

android:layout_height="fill_parent"
android:layout_width="1dp"
android:background="#90909090"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
/>

So the whole layout, as pictured, becomes:


 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:orientation="horizontal">

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="Yes"
        android:layout_weight="1"
        android:id="@+id/button1"
        android:textColor="#00b0e4" />

    <View android:layout_height="fill_parent"
        android:layout_width="1px"
        android:background="#90909090"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:id="@+id/separator1" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="No"
        android:layout_weight="1"
        android:id="@+id/button2"
        android:textColor="#00b0e4" />

    <View android:layout_height="fill_parent"
        android:layout_width="1px"
        android:background="#90909090"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        android:id="@+id/separator2" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="Neutral"
        android:layout_weight="1"
        android:id="@+id/button3"
        android:textColor="#00b0e4" />

</LinearLayout>

Method two – Specifying a divider for the LinearLayout

As pointed out by Paul Burke in the comments, you can specify a view divider on the linearlayout. This is obviously a better solution (and the solution I was searching for), that also works when you are dealing with an unknown number of items.

This methods only works for API level 11 and higher.

Create a new file called separator.xml in the drawable folder:


<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
 <size android:width="1dp" />
 <solid android:color="#90909090" />
</shape>

We can then use this separator in our LinearLayout like this:


 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:divider="@drawable/separator"
    android:showDividers="middle"
    android:orientation="horizontal">

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="Yes"
        android:layout_weight="1"
        android:id="@+id/button1"
        android:textColor="#00b0e4" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="No"
        android:layout_weight="1"
        android:id="@+id/button2"
        android:textColor="#00b0e4" />

    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        style="?android:attr/buttonBarButtonStyle"
        android:text="Neutral"
        android:layout_weight="1"
        android:id="@+id/button3"
        android:textColor="#00b0e4" />

</LinearLayout>

The important part here is on the LinearLayout:

android:divider="@drawable/separator"
android:showDividers="middle"

 

Method three – ButtonBarStyle (the easiest way for default separators)

As danialgoodwin mentioned in the comments, adding the buttonBarStyle to the LinearLayout will show default separators.  This is also for api level 11 or higher only.

The important part here, is adding this line to the LinearLayout:


style="?android:buttonBarStyle"

And the whole code will look like this:


    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        style="?android:buttonBarStyle"
        android:dividerPadding="15dp"
        >

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Button"
            android:id="@+id/button1"
            android:layout_gravity="center_vertical" />

        <!-- more buttons/views -->
        
    </LinearLayout>

You can also adjust the paddings of the view separators with the “dividerPadding” setting.

 

The buttons will also use an equal amount of horizontal space, so they all get the same size.

You could also create gradient drawable shapes for separators.

The history of Android

Ron Amadeo of the tech news site Ars Technica, recently posted a rather lengthy article on Android history, from version 0.5 to todays 4.4. Its worth reading.

The history of Android

I now notice that android has come a looong way, since my first android device, the white HTC Magic with cupcake 1.5, to the Nexus 5 with android 4.4.3.

I don’t think I could ever go back to the magic, today.
(I shiver when I see one of my friends still using it.)

How to fix ArrayIndexOutOfBoundsException in your custom ListAdapter

If you are creating your own ListAdapter, perhaps you want to show different list items, or list item headings in your list by overriding the getItemViewType and the getViewTypeCount in the implemented Adapter class, then you may have come across the ArrayIndexOutOfBoundsException, as the example below:


ERROR/AndroidRuntime(400): FATAL EXCEPTION: main
ERROR/AndroidRuntime(400): java.lang.ArrayIndexOutOfBoundsException
ERROR/AndroidRuntime(400): at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:4540)
ERROR/AndroidRuntime(400): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:3370)
ERROR/AndroidRuntime(400): at android.widget.AbsListView.onTouchEvent(AbsListView.java:2233)
ERROR/AndroidRuntime(400): at android.widget.ListView.onTouchEvent(ListView.java:3446)

Continue reading

Screen Shot 2014-06-08 at 22.00.13

Google Play just got a nicer permissions layout

Google Play just got updated to version 4.8.20, with a much nicer ui for app permissions.

Review App Permissions.

Here you can see a list of all the permissions app may ask for.

Simplified permissions on Google Play

To help make it easier to understand what an app will have access to, the Play Store has recently made improvements to how permissions are displayed. Permissions are organized into permissions groups, easily identified by icons (example: Location Location) to help clarify the most important information and capabilities an app can access on your device. This information can help you make an informed decision more easily on whether you would like to install the app.

Screenshot_2014-06-05-16-29-42 Screenshot_2014-06-05-16-29-55 Screenshot_2014-06-05-16-30-17 Screenshot_2014-06-05-16-31-46