Blog

  • How to fix touchpad scrolling in the Lenovo IdeaPad Z510 under Ubuntu 14.04 LTS

    How to fix touchpad scrolling in the Lenovo IdeaPad Z510 under Ubuntu 14.04 LTS

    When I’ve updated Ubuntu to 14.04 in Lenovo IdeaPad Z510 laptop then touchpad section disabled from “Mouse and Touchpad” settings (screen below)

    Screenshot from 2014-12-02 14:54:29

    To fix it you need install a lot of software. I try it but it not works for me.

    The most fast and simple solution is upgrade linux kernel to 3.14.1.

    The workflow is next:

    32-Bit Systems

    Download the .deb packages.

    $ wget kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-headers-3.14.1-031401_3.14.1-031401.201404141220_all.deb
    
    $ wget kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-headers-3.14.1-031401-generic_3.14.1-031401.201404141220_i386.deb
    
    $ wget kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-image-3.14.1-031401-generic_3.14.1-031401.201404141220_i386.deb

    Install packages.

    sudo dpkg -i linux-headers-3.14.1-*.deb linux-image-3.14.1-*.deb

    Reboot your system.

    sudo reboot

    64-Bit Systems

    Download the .deb packages.

    $ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-headers-3.14.1-031401_3.14.1-031401.201404141220_all.deb
    
    $ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-headers-3.14.1-031401-generic_3.14.1-031401.201404141220_amd64.deb
    
    $ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.14.1-trusty/linux-image-3.14.1-031401-generic_3.14.1-031401.201404141220_amd64.deb

    Install packages.

    sudo dpkg -i linux-headers-3.14.1-*.deb linux-image-3.14.1-*.deb

    Reboot your system.

    sudo reboot

    After reboot your “Mouse & Touchpad” settings will be the next:

    Screenshot from 2014-11-22 16:58:23

  • How to create custom style for fast scroll scrollbar in Android

    How to create custom style for fast scroll scrollbar in Android

    Here is sample for fastScroll ListView functionality.

    To apply this style you need add the following lines into your app’s style:

    <item name="android:fastScrollThumbDrawable">@drawable/fastscroll_drawable</item>
            <item name="android:fastScrollOverlayPosition">atThumb</item>
            <item name="android:fastScrollTrackDrawable">@drawable/track_fastscroll</item>

    Also if you need handle click action on your scrollbar you need create the next drawable:

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android" >
        <item android:state_pressed="true" android:drawable="@drawable/thumb_fastscroll_selected"/>
        <item android:drawable="@drawable/thumb_fastscroll"></item>
    </selector>

    Also you need apply this style in the AndroidManifest.xml or in another way.

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.hrupin.sample.custonui.fastscroll"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk android:minSdkVersion="11" />
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" 
            android:theme="@style/AppTheme">
            <activity
                android:name="com.hrupin.sample.custonui.fastscroll.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
    
    </manifest>

    Here is screenshots of app:

    2014-11-11 18.06.14

    2014-11-11 18.06.25

    Full source code you can get from github:

    Download it from github
  • How to use LoaderManager in Android. Sample.

    How to use LoaderManager in Android. Sample.

    Here is very simple example how to use LoaderManager from “android.support.v4.app” package.

    This sample will help you create nice application which can very nice communicate with your web server.

    The sample application looks like activity with ViewPager. Each Fragment in ViewPager adapter have implemented LoaderManager.LoaderCallbacks. Where “T” is returning type.
    It can be String or complex List, Map, ets. with objects.

    2014-10-23 13.53.45

    You can run the Loader and when data is loaded then show it.
    Below you can see how I use onLoadFinished method from LoaderManager.LoaderCallbacks interface for it.

    @Override
    	public Loader<String> onCreateLoader(int arg0, Bundle arg1) {
    		return new MyLoader(getActivity(), url);
    	}
    
    	@Override
    	public void onLoadFinished(Loader<String> arg0, String arg1) {
    		textView.setText(arg1);
    		hideProgress();
    	}
    Download it from github
  • How to use hexadecimal colours in iOS

    How to use hexadecimal colours in iOS

    I have develop the iOS application which based on design with hexadecimal colours (“#fff”, “#ff0000”, “#88ff0000”).

    To use the same in the iOS I’ve created special method witch can help me with it.

    iOS Simulator Screenshot
    iOS Simulator Screenshot

    Below you can see snippet of m-file.

    + (UIColor *) colorFromHexString:(NSString *)hexString {
        NSString *cleanString = [hexString stringByReplacingOccurrencesOfString:@"#" withString:@""];
        if([cleanString length] == 3) {
            NSString *red = [cleanString substringWithRange:NSMakeRange(0, 1)];
            NSString *green = [cleanString substringWithRange:NSMakeRange(1, 1)];
            NSString *blue = [cleanString substringWithRange:NSMakeRange(2, 1)];
            cleanString = [NSString stringWithFormat:@"ff%1$@%1$@%2$@%2$@%3$@%3$@", red, green, blue];
        }else if([cleanString length] == 6) {
            cleanString = [@"ff" stringByAppendingString:cleanString];
        }else{
            //do nothing
        }
        
        NSLog(@"%@", cleanString);
        
        unsigned int rgba;
        [[NSScanner scannerWithString:cleanString] scanHexInt:&rgba];
        
        CGFloat alpha = ((rgba & 0xFF000000) >> 24) / 255.0f;
        CGFloat red = ((rgba & 0x00FF0000) >> 16) / 255.0f;
        CGFloat green = ((rgba & 0x0000FF00) >> 8) / 255.0f;
        CGFloat blue = (rgba & 0x000000FF) / 255.0f;
        
        return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
    }
    Download it from github
  • How to fix “Conversion to Dalvik format failed with error 1” when you make Export Unsigned Application Package in Eclipse

    How to fix “Conversion to Dalvik format failed with error 1” when you make Export Unsigned Application Package in Eclipse

    Today I’ve got the “Conversion to Dalvik format failed with error 1” error when make “Android Tools–>Export Unsigned Application Package”

    I have ADT 23.0.2

    The problem was in the Proguard.

    To fix it you can disable Proguard in “project.properties” (Note that it is bad idea) or update Proguard.

    The Proguard updating is much better solution for it.

    To update it you need download the latest Proguard from here:

    http://sourceforge.net/projects/proguard/files/latest/download?source=files

    After that copy the “lib” and “bin” dirs from the zip to your sdk/tools/proguard/ to replace the default.

    This solution helps me.

    Let me know if you have better solution.

  • How to fix ViewPager stop between fragments in Android

    How to fix ViewPager stop between fragments in Android

    This issue I’ve got in one of my projects. I want to share it with you.

    There a lot of code. I try to describe the concept.

    1. I have Activity which have ViewPager
    2. ViewPager display Fragments each of them have Loader for data retrieving.
    3. I display data on fragment if onFinishLoader receive data. Rendering data in the Fragment I make in the onFinishLoader method.

    My case: I make page flipping very fast. The data loads in the fragment and start rendering while flipping animation in action. This action stop ViewPager between fragments. Below you can see my graphics.

    ltAGZm

    To remove this issue you need just remove all complex functionality from onFinishLoader and replace all View.GONE with View.INVISIBLE.

    Let me know if you have better solution.

  • Using .AAR (Android Archive Library) libraries with Eclipse

    Using .AAR (Android Archive Library) libraries with Eclipse

    As you know Android Studio able to use .AAR (Android Archive Library) libraries in the projects.

    To use it in Eclipse you need just UNZIP this AAR library and get all JARs and Resources from this lib.
    Also it isn’t beautiful solution but it works for Eclipse.

    Please let me know if you know better solution.

    Look forward to hearing better solution from you!!!

  • Centering source image (android:src) for ImageButton in Android

    Centering source image (android:src) for ImageButton in Android

    For centering android:src in the ImageButton I use the next solution.

    First I need create 9-patch src image using next rules. Please look at the screenshot from draw9patch utility from Android SDK.

    draw9patch utility
    draw9patch utility

    Next you need add the 9-patch image into ImageButton like this:

    <ImageButton
    android:layout_width="200dp"
    android:layout_height="match_parent"
    android:scaleType="fitXY"
    android:src="@drawable/src_image" />

    And finally you will get the next screen:

    Result screen
    Result screen
    Download it from github
  • Useful hotkeys in Android Studio under Mac OS X.

    Useful hotkeys in Android Studio under Mac OS X.

    CMD+F12 – Jump to method
    ALT+ENTER – Quick fix
    ALT+F7 – Find usage
    CTRL+SPACE – Code completion
    CTRL+ALT+L – Reformat code
    ALT+SHIFT+up/down – Move line up/down

    Please let me know your favourite hotkeys. I’m awaiting comments from you 😉

  • How to create custom background for InfoWindow on Google Maps V2 for Android

    How to create custom background for InfoWindow on Google Maps V2 for Android

    Here is short tutorial how to create custom background for InfoWindow (balloon) on Google Maps V2 for Android.

    As you can see the InfoWindowAdapter have two methods : getInfoWindow() and getInfoContents().

    To use default background for InfoWindows you need use getInfoContents().

    And if you want to use custom background for InfoWindows you need use getInfoWindow().

    Lets see screenshot below:

    The source code of InfoWindowAdapter is here:

    package com.hrupin.sample.googlemapsv2customballoons;
    
    import android.view.LayoutInflater;
    import android.view.View;
    import android.widget.TextView;
    
    import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
    import com.google.android.gms.maps.model.Marker;
    
    public class BalloonAdapter implements InfoWindowAdapter {
    	LayoutInflater inflater = null;
    	private TextView textViewTitle;
    
    	public BalloonAdapter(LayoutInflater inflater) {
    		this.inflater = inflater;
    	}
    
    	@Override
    	public View getInfoWindow(Marker marker) {
    		View v = inflater.inflate(R.layout.balloon, null);
    		if (marker != null) {
    			textViewTitle = (TextView) v.findViewById(R.id.textViewTitle);
    			textViewTitle.setText(marker.getTitle());
    		}
    		return (v);
    	}
    
    	@Override
    	public View getInfoContents(Marker marker) {
    		return (null);
    	}
    }
    Download it from github