16
Sep

Android Studio Tutorial: Adding versionName to Generated APK file

This is more feature what i love to develop android apps using Android Studio and Gradle. Adding a versionName after your generated APK filename will be much easier. Gradle will auto generate your APK filename ending with your version name.
i.e. Usually you will get this file name when generating a release APK: myapkfiles-release.apk and then by using this parameter you will get: myapkfiles-release-1.1.apk (1.1 is your versionName in your build.gradle).

Here is the code you need to add to your build.gradle in your buildtypes block:

applicationVariants.all { variant ->
                def file = variant.outputFile
                variant.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
            }

The complete buildtypes block that i have:

buildTypes {
        release {
            runProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                def file = variant.outputFile
                variant.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
            }
        }
        debug {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
16
Sep

A Fullscreen Holo Theme with Action Bar

I need to customize my android app to have a Fullscreen Holo Theme (no title screen) but still with Action Bar. Unfortunately, the Holo Theme from SDK doesnot have what i need. The default Holo Theme with Fullscreen has no title bar and also action bar.

Theme.Holo.Light.NoActionBar has a title bar but no action bar.
Theme.Holo.Light.NoActionBar.Fullscreen has neither the action bar nor the title bar.

Now i was thinking about making a hack to Holo Theme. Hmm this is what i did to solve my problem.

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

This old good method solved the problem fantastically. This trick or hack will have a regular “Holo Theme” result in your UI with Action Bar but no Title Bar / Notification Bar.

16
Sep

iOS 8 Release Date: Sept 17 will be the biggest iOS release ever

Duo iPhone 6 will be the first handset that will be equipped with iOS 8. And what about with the other iPhone version?

Apple will release iOS ensuring 8 adjacent to the initial sale of the iPhone 6, which is released on September 17th, 2014.

While in addition to the iPhone 6, Apple also ensures that the IOS 8 will also be deployed to older iPhones and iPad.

But not all versions, which only gets a Phone 4S, iPhone 5, iPhone 5S, 5C iPhone, iPad 2, iPad 3 (New iPad), the iPad 4, iPad Air, iPad Mini, Mini Retina Display iPad and a fifth-generation iPod Touch.

Apple CEO, Tim Cook,  previously called the IOS 8 as ‘a huge release’ ever. It also confirms that the emergence of IOS 8 is not just a minor update as successor to IOS 7 However, there is a significant improvement in it.

From the point of users, improvisation offered 8 comes from the iOS notification center, email inbox, keyboard, and a series of other features that are more interactive.

As for developers, Apple announced a new programming language, Dubbed Swift, to make it easier to develop applications that run on iOS.

New applications that appear in the IOS HealthKit 8 is the latest one. This application is able to monitor the heart rate, sleep, weight and blood pressure of the user.

8 In iOS, Apple also introduced HomeKit, a new platform that allows users to keep an eye on everything in the house only through their iPad or iPhone.

This feature as well as providing access to the user to control the lights, camera, house keys, and everything that is connected to the device.

In terms of notification, the user can also respond IOS 8 text message or notification on Facebook directly from the notification center, although the state of the lock screen.

For the first time, iOS also brings widgets to the notification center. This widget can provide access to the user to see a variety of information, such as sports scores to weather.

And one more thing the important thing for the parents, a feature named as family sharing that allows parents to track the location of the children and give consent through their iPhone or iPad when the child wants to buy apps in their handphone/smartphone.

16
Sep

How to rewrite sitemap.xml in NGINX server

I use Google XML Sitemaps by Arne Brahhold. It is one of the best WordPress plugin. It has great support and documentation.
But i have a problem when i installed it. I can’t access my sitemap. So as googlebot will not crawl your site properly. As you know, i use NGINX as my server. There is no htaccess to rewrite rules. As in documentation i need to add rewrite rules to my nginx server.
So here is what i do to solve this problem. I added the rewrite rules to my server block in nginx server configuration.

You need to add this rules:

rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;
server {
                listen 80;
                server_name blog.waysquare.com *.blog.waysquare.com;

                access_log /var/log/nginx/blog.waysquare.com.access_log;
                error_log /var/log/nginx/blog.waysquare.com.error_log;

                root /home/way/www/blog.waysquare.com;
                index index.php index.htm index.html;

		rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/index.php?xml_sitemap=params=$2" last;
		rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/index.php?xml_sitemap=params=$2;zip=true" last;
		rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/index.php?xml_sitemap=params=$2;html=true" last;
		rewrite ^/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/index.php?xml_sitemap=params=$2;html=true;zip=true" last;

                location ~ .php$ {
                  fastcgi_pass   127.0.0.1:9000;
                  fastcgi_index  index.php;
                  fastcgi_read_timeout 150;
                  fastcgi_param  SCRIPT_FILENAME /home/way/www/blog.waysquare.com;
                  include fastcgi_params;
        }
       location ~ /$ {
     			index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
     			try_files $uri $uri/ /index.php$is_args$args;
		}

       }

Happy coding!

16
Sep

How to Set Transparent Background for ImageButton

This tutorial will help you to set transparent background for ImageButton. If you set ImageButton in your layout XML as usual, you will get a result as shown below. Image Button will appear but with a grey background underlying it.

 

 

imagebutton transparent background before How to Set Transparent Background for ImageButton

 

So, how to remove the grey background as shown the result as below. It shows the button nice and clean.

imagebutton transparent background How to Set Transparent Background for ImageButton

 

You need to add this property code to your ImageButton layout:

android:background="@null"

My complete ImageButton layout:

<ImageButton
            android:id="@+id/play_pause"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:padding="5dp"
            android:scaleType="fitCenter"
            android:adjustViewBounds="true"
            android:src="@drawable/stop_button"
            android:background="@null"
            android:visibility="invisible"/>

Happy coding!

14
Sep

Sony Xperia Z3 Compact: price cut before launch

Sony Xperia Z3 Compact can be pre-ordered already. Officially, calling from the phone the manufacturer from a retail price of 499 euros, in some shops but not yet been effective. However, unfortunately this price cut effective only in the UK currently.

Xperia Z3 Compact: price cut before release
If you want to pre-order the Xperia Z3 Compact in Germany, currently you do pay almost 500 euros for it. The offers on the price comparison based on Sony’s recommendation of 499 euros.

In the UK, things are different: Sony will officially publish the price for 430 pounds have (540 Euros) for the Xperia Z3 Compact – the online shop Clove UK and Handtec but it is already much cheaper for 350 pounds (440 euros) including taxes. The shops also deliver to Germany and other country. Import costs are not due. The first devices to go out in late September.

Who can wait a bit longer, In circumstances, if you want it but probably not a problem by importing from UK. It is assumed that if you buy from the first shop and will reduce the cost of the phone. And still be happy with very good price than predecessor Xperia Z1, and can save you money: The mobile phone is available in our price comparison for 330 euros.

14
Sep

WhatsApp resets privacy settings secretly

WhatsApp users should take a look at their privacy settings. The available since Tuesday update brings not only new features, but also an automatic reset privacy settings.

Actually the update is used to the camera give the user a quick access and also to edit videos before sending. However, the new update brings not only new capabilities but also a repealed privacy status with it.

Under the option “last online” you have the possibility to choose how you want to be visible to other WhatsApp users. Resetting the privacy settings causes in many cases, regardless of iOS or Android, that is visible to all WhatsApp users.

Privacy concerns

The messaging service WhatsApp is always in the critique, not careful enough to deal with the data of its users. Has aggravated the problem since its acquisition by Facebook. The protection of privacy is described by experts as full of holes and inconsistent. The now existing problem, this shows once again very clearly. Only since April this year it is even possible to change the online status and so to regulate its visibility.

Despite the constant criticism WhatsApp recorded continuously growing number of users. Only in August announced by Jan Koum via Twitter that the service is already used by over 600 million people.

13
Sep

How to change ListView item color when clicked

How to change listview item color when clicked? I have listview using expandable listview. What i want is when i clicked listitem the colors will change.

I created a selector xml as below:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@color/blue_light" /> <!-- focused -->
    <item android:state_focused="true" android:state_pressed="true" android:drawable="@color/blue_light" /> <!-- focused and pressed-->
    <item android:state_pressed="true" android:drawable="@color/blue_light" /> <!-- pressed -->
    <item android:drawable="@color/list_bg" />
</selector>

Then i add this code to my listview item row inside LinearLayout tag:

android:background="@drawable/list_item_selector"

The complete code as shown below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/row_layout"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:background="@drawable/list_item_selector" >

    <LinearLayout
        android:layout_width="50dp"
        android:layout_height="fill_parent"
        android:gravity="center_horizontal"
        android:layout_marginRight="5dp">

        <ImageView
            android:id="@+id/row_logo"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_gravity="center_vertical"
            android:src="@drawable/ic_launcher"
            android:padding="5dp"
            android:contentDescription="@string/app_name"/>
    </LinearLayout>

    <TextView
        android:id="@+id/row_label"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:paddingLeft="5dp"
        android:gravity="center_vertical"
        android:textSize="15sp"
        android:textStyle="bold"
        android:textColor="@color/text"/>


</LinearLayout>

I was using Expandable ListView, it is the same concept if you use general ListView.

Menu Title