Saturday, February 25, 2017

Quick connect to nearby connect

This was the day when we were collecting food money anything which can be donated to the flood victims for Chennai. By evening we got everything in the evening we already had enough money and food supplies to be sent to Chennai.. We wanted a Truck ! It was difficult to find one .. We put it on our whatsapp group but we were mostly software engineers and none of us had a truck owner's or truck driver's phone number . Few we had which were either booked or out of station. At that time I thought of this app where we can just post and search our requirement with nearby people and get help from. Who knows at the same time hundreds of truck may be going just crossing us towards Chennai. Anyway after two hours of wait and search finally we got one Truck and we could send stuff to Chennai.

Back home I started my research experimented on the available technologies, wrote few successful proof of concept app with redis, mongo and vertx-java. Then I came up with this idea of integrating nearby technology with a social network touch to make it very generic. It took me great deal of experiment to come up with a user friendly UX. Finally I am done and it's here as you see. It took me long and by the time lot of easier technology like firebase to build such servers have come up but i sticked to my design and technology as I feel it's more configurable.

Ok let me explain a little bit about this app and it's usage .

When we get any useful information of interest from someone unknown through any medium, We tend to ask WHO are you ? WHAT is this ? WHERE is this ? WHEN is this ? HOW much it cost ? etc etc . And if it's exciting and useful we try to help or visit or avail if it is NEARBY. Take few example say 1) A new Ice Cream shop which has opened just near your office and now that the owner wants to tell this to the nearby people, how would he tell all this in short and sweet manner ? 2) You went to a theater to watch a movie but unfortunately you had to leave it for some urgent work how would you sell ticket ? 3) You want to invite people nearby for free health camp . 4) Do carpool and let others know that you are giving free rides till your office. 5) You are going for a office party and you are in short of few people to avail a corporate discount. How will you find interested people from your office who may like to join and avail the offer ?

Take this another case where and how Quikc can help - NGO/College students want to drive the Nearby community for a weekend cleaning drive. They can create a post and publish it with Quikc with channel say #CleanSunday . Now the same message goes to every device who would be using this app and they can join and help. Also college students can use this app to invite unknown nearby interested students and do get-togethers for any such events.

Another case let's say you need an electrician so you would ask nearby people usually to get his contact and then you call him, but what if he is farther he may not be available in-time.. Instead of wandering you can post the same message with #Quikc with a channel name say #NeedElectrician and someone nearby you may be an electrician or know fixing things who would be of your help.

Quikc solves all these problems in a simple and user friendly way by an android app. Just post a message create a channel and push the message to nearby people and that's it you are done. Try this app from google play share your feedback, suggestions and feel free to write me back if you want to say hello.

Friday, April 8, 2016

How to Facebook or Google or G+ login in android and fetch user profile

While working on an idea of my new app I had this requirement of allowing users to use there Facebook or Google account. Facebook auth was easy and without any difficulty I could get the users profile info etc. But Google Auth + GPlus data fetching was a pain as they both involve different api strategy and I started working on it but I was stuck for days ! Unfortunately any example I found in internet for Google Auth + GPlus data fetching is either obsolete or doesnt work ! Even googles developer page is also not updated with correct functions.
It was quite impossible to get both data in one api call ! I then cracked it with the below minor changes to my existing code. Hope it helps to any android enthusiatic.

It was quite impossible to get both data in one api call ! I then cracked it with the below minor changes to my existing code. Hope it helps to any android enthusiatic.
Fetch G+ data with GoogleSignin
A slight modification to GoogleSignInClient can fetchus both Google account + GPlus data
Create the GoogleSignInOptions as below
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestScopes(new Scope(Scopes.PLUS_LOGIN))
                .build();
Create the GoogleApiClient as below
m_GoogleApiClient = new GoogleApiClient.Builder(m_activity)
                .enableAutoManage(m_activity, this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .addApi(Plus.API)
                .build();
public void fetchConnectedProfileInfo()
{
    Log.d(TAG, "fetchConnectedProfileInfo");
    if (m_GoogleApiClient.hasConnectedApi(Plus.API)) {
        Plus.PeopleApi.load(m_GoogleApiClient, "me").setResultCallback(this);
    }
}
Call fetchConnectedProfileInfo() from MainActivity.java onActivityResult()

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    getCallbackManager().onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        Log.d(TAG, "handleSignInResult:" + result.isSuccess());
        if (result.isSuccess()) {
            GoogleSignInAccount acct = result.getSignInAccount();
            Bundle googleData = m_gAuthProcessor.getGoogleAccData(acct);
           fetchConnectedProfileInfo();
        } else {
            notifyus("googleAuthFailed", null);
            // Signed out, show unauthentic
        }
    }
}
Code is available here https://github.com/sandipsahoo2k2/social-login

Sunday, March 27, 2016

creating a mobile site with users status | realtime apps

we would be using digital ocean for this

https://www.digitalocean.com/community/articles/initial-server-setup-with-ubuntu-12-04
https://www.digitalocean.com/community/articles/how-to-set-up-a-host-name-with-digitalocean
https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

https://www.digitalocean.com/community/articles/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps

install npm and nodejs in digital ocean
create a soft link for nodejs

ln -s  /usr/bin/nodejs  /usr/bin/node other wise you wont be able to install redis/hiredis with node module.
-I/usr/include/x86_64-linux-gnu if make fails for redis compilation

Great Tutorial
http://www.smartjava.org/content/create-simpe-restful-service-vertx-20-rxjava-and-mongodb
http://www.javaworld.com/article/2078838/mobile-java/open-source-java-projects-vert-x.html?null


android examples
-----------------
http://javapapers.com/android/android-chat-with-google-gcm-xmpp/
http://www.androidhive.info/2016/02/android-push-notifications-using-gcm-php-mysql-realtime-chat-app-part-3/
http://code.tutsplus.com/tutorials/quick-tip-add-facebook-login-to-your-android-app--cms-23837


Saturday, November 15, 2014

Why I couldn't do what an UXD proposed me to do in my android app

Don’t shoot a programmer, He draws as he can..

Things to keep in mind with UI Assets.. 

Scale and Size of Image and Icons. For every icon/image that we would use strictly follow android UI guidelines so we need 5 size for icons with 2:3:4:6:8 scaling ratio. This means the baseline (MDPI) asset is 48x48 px, and the high-density(HDPI) asset should be 1.5x the baseline at 72x72 px, and the x-high density (XHDPI) asset should be 2x the baseline at 96x96 px, and so on.


So we must create icons/image with above scalling. The easiest thing for a developer to use http://romannurik.github.io/AndroidAssetStudio/  link.
Howto’s : If we have the highest density and scaled image we can easily create assets with the above link for Luncher/Action bar/Notification/Generic Icons. This tool will create all necessary set of icons for all device size. Note : Create an  image/icon with highest density/scale with GIMP or adobe illustartor first then use them as the input for the above tools.
Some Take away :

Splash Screen  – I couldn’t implement it cause the screen-shot that the UXD gave me was not covering the phone width, it was little ugly when I tried to stretch and I didn’t have screen shot for the Icons that I had created with a replacement for the icons shared by him, for the helper views too. So skipped for this release (I liked the proposal, if not today some day I will incorporate with the app)

SearchWidget – I am using the default android search widget in which the search_icon comes in the left side I tried a lot, did some search but could not make it possible to keep it in right side. (I could have achieved with my customized search widget which would take me few days to build !, Why ? if I make my customized control again that should follow android UI specifications which would need me to create controls for every device size, everycolor, 9 patch image, icons- which would be cost me around a week of time, its lack of time that forced me to keep it still hidden and pops up from a menu click).

Location Icons – Customized location Icons again has to be for different device density. And the location icon given to me was eye catchy though I had to use the default map icons. Icons were left anchored but my requirement was for centered gravity.

Theme with the app color : It took me a few days to find out the best theme color that suit my app. I did a lot of experiement with themes. There are still some controls, for which its hard to create theme specific controls e.g android switch !  So I am still living with the default android theme controls.

Refer : The links that I refer while creating my icons for my app / webpages.

Geo-Pulse list icons – Again the asset that he shared was awesome but I couldn’t generate icons using http://romannurik.github.io/AndroidAssetStudio/icons-generic.html link. We must generate all icons with the android studio as it ensures that we have the right size and scaled icons. But remember any given icon by a designer should be with the highest size i.e  192px/192px (if not minm should be atlest 96px / 96px) so that you can create smaller and bigger icons wihtout loosing the quality. The most important thing is any icon given by a designer should be transparent in nature without which you cant create icon for different devices using the above links. So I had to create my own icons with cliparts that collected from web which are holo and tranparent and matched the UXD’s proposals.

Luncher Icon :Luncher icon should be created from a 512px / 512px Image without which you will loose the quality again  for different devices. Just a small note, all the assets name should be in small letters and underscores (no hiphens) .


This is just for book keeping of all that I did for ZPulse which might help for an enthusiastic android programmer and ease him for beautification for his/her app.

Saturday, October 4, 2014

How to set events on EditTextPreference dialog like longpress

Spent a lot on working on the preferences settings in android google also couldn't help me at last I could do some experiement and made it work.

Goal : Open the Contacts and fill the phone number in one of the inputs for Preferences.

e.g You want to set the Number only Edit text

public class SettingsFragment extends PreferenceFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences_activity);
        
        Preference preference = findPreference("EMERGENCY_PH_NO") ;
        EditTextPreference editTextPreference = (EditTextPreference) preference;
    }
}

now its easy just grab the handle and set the longpress event

All the code is given below

public class SettingsFragment extends PreferenceFragment {

EditText m_emergency_number = null;
final int EMERGENCY_CONTACT_PICK = 1337;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences_activity);
        
        Preference preference = findPreference("EMERGENCY_PH_NO") ;
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        //TextView TextView = (TextView) editTextPreference.getEditText();
        m_emergency_number = (EditText) editTextPreference.getEditText();    
        m_emergency_number.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
openContact(EMERGENCY_CONTACT_PICK);
return true;
}
});
    }    
    
    void openContact(int who)
{
Intent intent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
intent.setType(Phone.CONTENT_TYPE); // Show user only contacts w/ phone numbers
        startActivityForResult(intent, who);
}
    
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent aData) {
    // TODO Auto-generated method stub
    if (resultCode == Activity.RESULT_OK) 
    {
       Uri contactUri = aData.getData();
       //Intent intent = new Intent(Intent.ACTION_GET_CONTENT,contactData);
           //startActivityForResult(intent, 1336);
       String[] projection = {Phone.NUMBER};
       
       Cursor cursor = getActivity().getContentResolver().query(contactUri, projection, null, null, null);
            cursor.moveToFirst();

               // Retrieve the phone number from the NUMBER column
               int column = cursor.getColumnIndex(Phone.NUMBER);
               String number = cursor.getString(column);
               if(EMERGENCY_CONTACT_PICK == requestCode)
               {
                m_emergency_number.setText(number);
               }
    }
    }
}

Wednesday, September 24, 2014

android layout tricks

Merging a image with map

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"/>

          <RelativeLayout
    android:id="@+id/rl"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <ImageButton
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="20dp"
        android:
        android:src="@drawable/star" />

</RelativeLayout>
</merge>

Actionbar theming
-------------------------
http://jgilfelt.github.io/android-actionbarstylegenerator/#name=example&compat=sherlock&theme=light&actionbarstyle=transparent&texture=0&hairline=0&neutralPressed=1&backColor=E4E4E4%2C100&secondaryColor=D6D6D6%2C100&tabColor=9c0%2C100&tertiaryColor=690%2C100&accentColor=6ad869%2C100&cabBackColor=FFFFFF%2C100&cabHighlightColor=33B5E5%2C100

Sunday, September 21, 2014

All about signing the apk and its effect in google play

  1. Generate a private key using keytool. For example:
    $ keytool -genkey -v -keystore my-release-key.keystore-alias alias_name -keyalg RSA -keysize 2048 -validity 10000
    This example prompts you for passwords for the keystore and key, and to provide the Distinguished Name fields for your key. It then generates the keystore as a file called my-release-key.keystore. The keystore contains a single key, valid for 10000 days. The alias is a name that you will use later when signing your app.
  2. Compile your app in release mode to obtain an unsigned APK.
  3. Stand on google_play_services first then run below commands
    android update lib-project --path .
    ant clean
    ant release

    stand on your project root folder
    android update lib-project --path .
    ant clean
    ant release

    make sure your project file is updated with
    android.library.reference.2=../../Android/sdk/extras/google/google_play_services/libproject/google-play-services_lib
  4. Sign your app with your private key using jarsigner:
  5. $ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1-keystore my-release-key.keystore my_application.apk alias_name
    This example prompts you for passwords for the keystore and key. It then modifies the APK in-place to sign it. Note that you can sign an APK multiple times with different keys.
  6. Verify that your APK is signed. For example:
    $ jarsigner -verify -verbose -certs my_application.apk
  7. Align the final APK package using zipalign.
    $ zipalign -v 4 your_project_name-unaligned.apk your_project_name.apk
    zipalign ensures that all uncompressed data starts with a particular byte alignment relative to the start of the file, which reduces the amount of RAM consumed by an app
  8. How to check your details in the keystore 
  9. keytool -list -keystore .keystore
  10. keytool -list -keystore .keystore -alias foo
    1. List all info ::
    keytool -list -v -keystore android-release-key.keystore
How to find that debug SHA1 ley to be used by Android MAP key

keytool -list -v -keystore C:\Users\<username>\.android\debug.keystore
password : android

keytool -exportcert -alias androiddebugkey -keystore C:\Users\ssaho3\.android\debug.keystore -list -v