Tag: android

  • Scrolling div on Android in webview

    Problem

    Simple thing as scrolling a div with overflow:auto is currently not possible on the Android platform.
    Due to my application requirement I really needed this functionality so here is what I come up with

    Challenges

    Currently when we call node.offsetHeight we will not get the full height of the div only the content visible
    to fix that I change the positioning to absolute and height 100% to get the true height of the div.

    Android project with scrollable div can be download here

    Code

    Code consist of three parts

    • CSS
    • JavaScript
    • HTML markup
     /**
    		 * WebKit Div Scroller class
    		 * @author:Greg Bugaj
    		 * Initial release
    		 */
    		 //Namespace
    		var GB=GB || {};
    		GB.Scroller=
    		{
    			SCROLL_INREMENT:5,//Amount to scroll per update
    			SCROLL_TIME:75,//Time between update Intervals in  MS	
    			
    			getElementsByClassName:function(classname, node)  {
    				if (!node) {
    					node = document.getElementsByTagName('BODY')[0];
    				}
    				var a = [];
    				var re = new RegExp('\\b' + classname + '\\b');
    				var els = node.getElementsByTagName("*");
    				for(var i=0,j=els.length; i=  contentHeight)){
    							cancelTimer=true;
    						}
    						if(cancelTimer){
    							clearInterval(iTimer);
    							return;
    						}						
    						t+=GB.Scroller.SCROLL_INREMENT*direction;
    						scroller.style.top=t+"px";				
    					};
    					
    					
    					//Attach events to navigation 
    					var tapUP = GB.Scroller.getElementsByClassName("scroll_up", scroller_container);
    					if(tapUP==null){
    						alert("There is no DIV with class 'scroll_up'");
    					}
    					tapUP=tapUP[0];//There should be only 1 element in the array
    					
    					var tapDOWN = GB.Scroller.getElementsByClassName("scroll_down", scroller_container);
    					if(tapDOWN==null){
    						alert("There is no DIV with class 'scroll_down'");
    					}
    					tapDOWN=tapDOWN[0];//There should be only 1 element in the array
    					
    						
    					tapUP.addEventListener('touchstart', function(e){
    						iTimer=setInterval(function(){ scrollContent(e, -1);}, GB.Scroller.SCROLL_TIME);
    					}, false);
    					
    					tapUP.addEventListener('touchend', function(e){
    						clearInterval(iTimer);
    					}, false);
    					
    					tapDOWN.addEventListener('touchstart', function(e){
    							iTimer=setInterval(function(){scrollContent(e, 1);}, GB.Scroller.SCROLL_TIME);
    					}, false);
    					
    					tapDOWN.addEventListener('touchend', function(e){
    						clearInterval(iTimer);
    					}, false);
    					
    				}//for
    			}//function
    		};
    		
    		//Initialize all the scrollable components on the page
    		window.addEventListener('load', function(){ GB.Scroller.init(); }, true);
    
       
    Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec dapibus ipsum in nulla rhoncus a blandit enim lobortis. Mauris scelerisque justo eu purus molestie ut sodales diam laoreet. Integer id volutpat urna. Sed lacinia risus id magna pharetra scelerisque. Proin venenatis blandit sapien vitae pulvinar. Nulla et urna in erat venenatis posuere eu id ipsum. Proin magna mi, congue ultrices malesuada id, sollicitudin a urna. Praesent id lorem leo. Phasellus vestibulum dapibus mattis. Fusce et faucibus risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec dapibus ipsum in nulla rhoncus a blandit enim lobortis. Mauris scelerisque justo eu purus molestie ut sodales diam laoreet. Integer id volutpat urna. Sed lacinia risus id magna pharetra scelerisque. Proin venenatis blandit sapien vitae pulvinar. Nulla et urna in erat venenatis posuere eu id ipsum. Proin magna mi, congue ultrices malesuada id, sollicitudin a urna. Praesent id lorem leo. Phasellus vestibulum dapibus mattis. Fusce et faucibus risus.

    Feature request/updates

    I will add features as I need them or upon request.

  • Android ImpulseShopper released

    About

    ImpulseShopper(pre-beta) is application that lets you monitor your favorite daily deals websites like woot.com, 1saleaday.com, dailysteals.com etc…
    Includes both widget and full blown application.

    • Engine based
    • Filters
    • Product thumbnails
    • Share via SMS, Email, Twitter
    • Notifications
    • Deployed on Google AppEngine

    Screenshots

    [nggallery id=7]

  • Android Daily Deals Agent – ImpulseShopper

    Update : Beta released

    First beta have been unlished on the Android Marketplace. So far so good, some one reported that the program crashes(unknown cause)

    Overview

    This is idea for my Daily deals agent that will monitor certain sites for daily deals.

    Current sites to consider

    • Woot.com – woot | shirt | wine | sellout
    • 1saleaday.com – wireless, watches

    Simple yet powerful enough to help me keep tabs on sweet deals.

    Screenshots

    [nggallery id=7]

  • TabWidget demo project

    Sorry it took little longer than expected, run in some issues with cupcake (SDK 1.5)
    I have attached a Demo project for all interested with  some screenshots and modified .project for TabWidget Project(fixes cupcake problem ref http://groups.google.com/group/android-developers/browse_thread/thread/5537ae10e4143240) if you use eclipse.

    1. My env:
    Eclipse Version: 3.4.2
    Android SDK 1.5
    Windows

    2.After you import the TabWidgedDemo project you will probably need to fix your buildpath.
    Make sure to add TabWidet as a reference to TabWidgedDemo.

    3.In TabWidged project you will need to update the .project file otherwise you will get Verify error when deploying to the device.

    If you have any questions let me know, I hope you enjoy the project, more improvements to come

    Download tabwidgetdemo for eclipse

  • Detecting Network Speed and Type on Android (Edge,3G)

    For better experience for users of my app I wanted to show them different UI based on their network speed, problem here is that there is no way to know what network we are currently on.

    My first instinct was to use android.net.ConnectivityManager getActiveNetworkInfo() which gives us current network information, but the only thing we can find out from this is the connection type TYPE_MOBILE or TYPE_WIFI which is not very useful for my purpose.

    So here is a quick tool that will try to determine network type by testing the download speed, I use threshold of 176 kbits/sec as EDGE cut of value.

    Downloads

    Screenshots

  • Carme GPS Tracker for Android

    My frist Android app, this is simple GPS tracker program that let us record our tracks, store  and share them.

    This project uses my custom TabWidget for Android.

    Main features

    • Record
    • Playback
    • Share via Email (Google Earth)
    • Share via Twitter  (in progress)
    • Exporting to SD Card
    • Tagging (in progress)

    I use icon from http://www.dryicons.com , love their methodology give the little guys an edge by providing free high quality designs.

    Screenshots

    [nggallery id=2]

    To Come

    Here are some other features that I will implement soon

    • Altitude profiler
    • Photos
    • Profiles

    Download Carme source code

  • Custom Android Tabs

    Due to limitation of Android Tab component I created a custom TabWidget that I am using in couple different projects already. The widget allows us to  add custom background and use custom icons, tabs   can be Top/Bottom aligned.

    Currently tabs can launch new Activity and  Dialog , when starting new Activity we can use  “startActivityForResult” so our tab will get a notification when other activity have finished.

    (more…)