Android Drag-Drop Button - A custom component for android developers

See on Github

This is an open source android drag button custom component. You can use it on your project to show a drag-able icon and perform any action after user dragged to the edge of the component.

drag drop button screenshot
screenshot

Import aar file on releases directory to your android project to include drag-drop button. Or you can download entire project and open from Android studio and compile to match with your sdk version, then you can import generated aar file to your real project.

Example usage of the drag-drop-button

This is a sample code for drag button inserting into ui and handling events.

xml code to put drag-drop button on the activity
<com.mili.dragdropbutton.DragButton
    android:id="@+id/dragBtn"
    android:layout_width="200dp"
    android:layout_height="200dp"
    custom:imageBtnSizePercentage="0.25"
    custom:dragEndThresholdPercentage="0.10"
    custom:arrowCount="4"
    custom:arrowColor="#42f46e"
    custom:iconFileName="icon2.png">
</com.mili.dragdropbutton.DragButton>

Note:
Needs to define custom namespace on parent tag as
xmlns:custom="http://schemas.android.com/apk/res-auto"

See activity_main.xml on test project for complete source code.


Java code to handle events
DragButton dragButton = (DragButton) findViewById(R.id.dragBtn);
dragButton.setOnDraggedListener(new DragButton.OnDraggedListener() {
    @Override    public void onDragged(DragButton view, MotionEvent e) {
        Log.i("DragBtn", "Dragged");
    }
});
dragButton.setOnDragStartedListener(new DragButton.OnDragStartedListener() {
    @Override    public void onDragStarted(DragButton view, MotionEvent e) {        
        Log.i("DragBtn", "Drag started");
    }
});
dragButton.setOnDragEndedListener(new DragButton.OnDragEndedListener() {
    @Override    public void onDragEnded(DragButton view, MotionEvent e) {
        Log.i("DragBtn", "Drag ended");
    }
});
See MainActivity.java on test project for complete source code.


Custom Attributes on xml

imageBtnSizePercentage
Size of the center icon to draw related to the size of the button. Example- 1 will draw the center icon on entire button, 0.5 will draw half of the size of the button. Any value between 0-1.

dragEndThresholdPercentage
Indicate the percentage area of the threshold to fire the dragged event. Any value between 0-1.


arrowCount
Number of arrow to show the drag direction. Any positive integer value

arrowColor
Color of the arrows in hex format. Example- #42f46e

iconFileName
Path to the image file for center icon on assert folder. 512x512 is the recommended size. 
Example- icon2.png
 
Continue Reading...

Rendering Unicode characters on your Android device

This post is about a problem which I face and the solution for it...So the problem is How to render or enable Unicode characters on my android device. I got this problem when I browse a web site which include Sinhala Unicode characters.

I am using Opera mini browser to browse internet. So here is the way to render Unicode characters on Opera mini.

Step 1
Type config: or opera:config in address bar and tap on Go, then it will display a configuration page.

Step 2
Scroll down and find out the title of "Use bitmap fonts for complex scripts" and select Yes from the combo box. Now Save the configurations by tap on Save button.

Now close the config page and now you are welcome to Unicode pages...!

Continue Reading...

Use Android phone as a modem (Internet connection to PC through Android phone)

First of all I would like to say happy new year to all of you. So this is my first post in 2012.

This post is based on a problem that I faced after -->brought an Android phone. Oh I forgot to say you, I brought an Android phone it is Sony Ericsson Experia X10 mini pro. The problem that I faced is 'How to connect this phone and establish a internet connection in PC'. You know most of the normal phone that capable GPRS can connect to PC(USB or bluetooth) and establish the internet connection over phone. Earlier I used a Nokia phone(Nokia 3120 classic). It can be used as a modem to pc, therefore I could brows internet in PC through the phone.
But in this Android phone it is a little bit different. Because this is an Android phone *#%@.=+.

Simply here are steps to configure your Android phone as a modem.

First of all you have to download and install software needed in both sides, phone and PC. This task is just like a client-server application. So first, lets install on the phone.

The software is EasyTether. EasyTether allows you to shares your phone Internet connection with computer/laptop/notebook (Windows 7/Vista/XP 64-bit/32-bit, Mac OS X 10.4/10.5/10.6/10.7, Ubuntu 10.4+, Fedora 13+)

you can download Easy Tether from Android market and install it from your phone it self. But there is a thing to say you this is not a Free software. But Lite version of Easy Tether is available in Android market but the latest version of the EasyTether Lite has some restrictions since it is lite version. Such as blocking secure HTTP sites....... Therefore this is not a complete solution. But there is a way to Activate the EasyTether. Follow these steps to achieve the EasyTether.

The older version of the EasyTether has the Activation code for full version. Therefore you have to install an older version of Easy tether to get the code.

  • First download EasyTether 0.9.3 apk file from here or here.
  • Install the apk file manually to the phone.
  • Open the EasyTether from the phone ans just go to 'About' page and write down 5 digit code (under 'Registration code'). So this is the activation code for your phone.
  • Now uninstall EasyTether 0.9.3 from your phone to install latest version.
  • Install latest version of the EasyTether Lite version(free version)from the Android market.
  • Open it. In first start, EasyTether will show a dialog box about a setup wizard or some thing like that. Just cancel it(You can get it later from setup) and tap on 'Activate EasyTether' to activate the product.
  • Here you should type the 5 digit number which you written under 'Activation code'
  • Now you have the full version of the EasyTather with all capabilities.

Now tap on 'Setup/Settings' and tap on 'USB Tethering setup' to configure your computer for EasyTether. now a setup wizard for the configuration will open and you can easily follow the instruction. This setup wizard is more descriptive and easy. Therefore I think that is no need to explain these steps here. Additionally you have to download the EasyTether software for PC.(The setup wizard will inform you to download and install it to your PC).

Additionally make sure the network drivers installed on your PC. In Windows you can be found it in 'Device manager' under 'Network adapters' named 'Easy Tether Network Adapter'.

Finally you will be able to connect to internet through your Android phone.

To establish the connection just plug USB cable and click on 'Connect' by right click on the EasyTether icon from sys tray in Windows.


Continue Reading...