Customising Nikola driver android source code

M
Muthurengan 6 years ago - Created

This guide helps you successfully white-label nikola driver android source code to your brand.


Prerequisites

This guide assumes who already have Android studio installed with the latest SDK version. For this guide, we need an SDK version of 26.

This source code works only with Android studio. We do not support Eclipse.

1. Unzip the source code zip file

After you unzip the zip file the contents of the folder will look like this:


2. Import the project into Android studio

Launch Android studio and select Open an existing Android Studio project.

Select the folder we just unzipped before and press Open.

The gradle will start to build and sync all dependencies.

Make sure you have an active internet connection while importing project into Android Studio. 

3. Update the const.java file

Navigate to the const.java file with the following path:

app>java>com>nikola>driver>utils>const.java


In this file we need to update 4 variables:

  • PLACES_AUTOCOMPLETE_API_KEY
  • GOOGLE_API_KEY
  • SOCKET_URL
  • HOST_URL

Host URL

Change the HOST_URL to your domain URL you have pointed to the server.

public static final String HOST_URL = "http://yourcompany.com/";

Socket URL

Similarly, change the SOCKET_URL to the 3000 port of your domain URL you have pointed to the server.

public static final String SOCKET_URL = "http://yourcompany.com:3000/";

Google API key

Update the GOOGLE_API_KEY, by substituting your_google_api_key with the API Key of your google console project.

public static final String GOOGLE_API_KEY = "your_google_api_key";

Google Places Autocomplete API key

Update the PLACES_AUTOCOMPLETE_API_KEY, by substituting your_google_api_key with the API Key of your google console project.

public static final String PLACES_AUTOCOMPLETE_API_KEY = "your_google_api_key";
To know how to create a API key in google console visit How to generate an API key in google console.

4. Update the strings.xml file

Navigate to the strings.xml file with the following path:

app>res>values>strings.xml 


In this file we will update 5 variables:

  • app_name
  • facebook_api_id
  • sender_id
  • google_app_id
  • map_key

App name

Change the app_name value to your driver app name.

Facebook App ID

Substitute  your_facebook_api_id with your Facebook app ID to enable Facebook login. If you don't know how to get a facebook app ID, visit How to generate a Facebook app ID guide.

Sender ID

Substitute sender_id with your Sender ID to receive push notifications in your app. If you don't know how to get a Sender ID, visit How to generate a Sender ID guide.


Google ID

Substitute google_app_id with your Sender ID. If you don't know how to get a Sender ID, visit How to generate a Sender ID guide.


Map Key

Substitute map_key value also to your Google API Key. If you don't know how to get a Sender ID, visit How to generate an API key in Google console guide.


5. Update activity_welcome.xml file

Copy and paste your splash screen image into the drawable folder.


Navigate to activity_welcome.xml file in the following path.

app>res>layout>activity_welcome.xml

Substitute splash_screen with the name of your splash screen.

android:background="@drawable/splash_screen"

6. Update ProfileActivity.java file

Navigate to ProfileActivity.java file in the following path.

app>java>com>nikola>driver>activity>ProfileActivity.java

Go to line no: 110. You'll find this code:

/* Glide.with(this).load(userprofile.getProfileurl())
         .error(R.drawable.defult_user)
         .centerCrop() 
         .crossFade() 
         .placeholder(R.drawable.defult_user).into(profile_image);*/

This code is commented for demo purpose. Uncomment it by removing the "/*" and "*/". After you uncomment it will look like this:

Glide.with(this).load(userprofile.getProfileurl())
        .error(R.drawable.defult_user)          
        .centerCrop()          
        .crossFade()           
        .placeholder(R.drawable.defult_user).into(profile_image);

Now go to line no: 123. Uncomment the below code by removing the "/*" and "*/":

/* new AQuery(this).id(R.id.profile_image).image(userprofile.getProfileurl(), true, true,                             200, 0, new BitmapAjaxCallback() {                          
        
        @Override                                 
        public void callback(String url, ImageView iv, Bitmap bm,                                                                           AjaxStatus status) {
           if (url != null && !url.equals("")) {
               filePath = aQuery.getCachedFile(url).getPath();
           }                          
        }
    });*/

After you uncomment it will look like this:

new AQuery(this).id(R.id.profile_image).image(userprofile.getProfileurl(), true, true,                                  200, 0, new BitmapAjaxCallback() {
                                            
        @Override
        public void callback(String url, ImageView iv, Bitmap bm,                                                                                                        AjaxStatus status) {            
            if (url != null && !url.equals("")) {                
                filePath = aQuery.getCachedFile(url).getPath();            
            }                                   
        }     
});

Next, go to the method showPictureDialog() in line no: 216.

Replace the code inside this method with the below code. Once you do, it will look like this:

private void showPictureDialog() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);             dialog.setTitle(getResources().getString(R.string.txt_slct_option));
    String[] items = {getResources().getString(R.string.txt_gellery),     getResources().getString(R.string.txt_cameray)};          
    dialog.setItems(items, new DialogInterface.OnClickListener() {              

        @Override             
        public void onClick(DialogInterface dialog, int which) {                 
            // TODO Auto-generated method stub                 
            switch (which) {                     
                case 0:                         
                    choosePhotoFromGallary();                         
                    break;                     
                case 1:                         
                    takePhotoFromCamera();                         
                    break;                  
             }             
        }         
    });         
    dialog.show();
}

7. Update UploadAdapter.java file

Navigate to UploadAdapter.java with the following path:

app>java>com>nikola>driver>adapter>UploadAdapter.java

Go to Line no: 84 and delete the code from line 84 - 101 and replace it with the below code:

Glide.with().load(upload_itme.getUpload_img()).into(holder.iv_upload);

Then, go to the method showPictureDialog() in line no: 211.

Replace the code inside this method with the below code. Once you do, it will look like this:

private void showPictureDialog() {     
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);                 dialog.setTitle(getResources().getString(R.string.txt_slct_option));     
    String[] items = {getResources().getString(R.string.txt_gellery),         getResources().getString(R.string.txt_cameray)};               
    dialog.setItems(items, new DialogInterface.OnClickListener() {
                        
        @Override                      
        public void onClick(DialogInterface dialog, int which) {                              
            // TODO Auto-generated method stub                              
            switch (which) {                                      
                case 0:                                              
                    choosePhotoFromGallary();                                              
                    break;                                      
                case 1:                                              
                    takePhotoFromCamera();                                              
                    break;                                
            }                      
        }              
    });              
    dialog.show(); 
}

8. Update the activity_main.xml file

Navigate to activity_main.xml file in the following path.

app>res>layout>activity_main.xml

Open the file and go to line no: 29 and substitute logo_header with your header logo name.

android:src="@drawable/logo_header"


8. Update the helpview.xml file

Navigate to helpview.xml file in the following path.

app>res>layout>helpview.xml

Open the file and go to line no: 35 and substitute logo_header with your header logo name.

android:src="@drawable/logo_header"

9. Update your app logo

Convert your logo into 5 different resolutions. You can use this website to do that.

For good quality convert a logo with minimum resolution of 1024 x 1024.

After you download the converted files. You'll have these folders in the android directory.

Copy the images inside the above folders and paste it to the respective folder inside app>res>mipmap.


You can ignore the image inside mipmap-ldpi.


10. Update build.gradle (Module: app) file

Open the app level build.gradle file.

Update the applicationId parameter with your package name.

applicationId 'com.yourcompany.driver'

and press Sync Now.


You can check the app by running it on an emulator or a device by pressing Run from the toolbar.


Next, visit How to upload apk to play store to learn how to export a build and publish it in the play store.


Was this article helpful?

2 out of 2 found this helpful

Articles in this section