Customising Nikola user android source code

M
Muthurengan 1 year 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>user>utils>const.java

In this file we need to update 4 variables:

  • PLACES_AUTOCOMPLETE_API_KEY
  • GOOGLE_API_KEY
  • SOCKET_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/";

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/";

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";

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

Substitute Your app name with your 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

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


2. Now, 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>user>ProfileActivity.java

Go to line no: 106. 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: 119. 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: 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();
}

7. Update activity_addpayment.xml file

Navigate to activity_addpayment.xml with the following path:

app>res>layout>activity_addpayment.xml

Go to Line no: 80 and delete the code from line 80 - 101.


8. Update NavigationDrawableFragment.java

Navigate to NavigationDrawableFragment.java with the following path:

app>java>com>nikola>user>Fragment>NavigationDrawableFragment.java

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

/*if (!pictureUrl.equals("")) {            
    //Glide.with(activity).load(pictureUrl).into(userIcon);         
}*/

Uncomment this by removing "/*", "*/" and "//". You will get this:

if (!pictureUrl.equals("")) {                     Glide.with(activity).load(pictureUrl).into(userIcon);
}

Now, go to line no: 88 and delete the following line:

userSettingsList.add(new UserSettings(R.drawable.flash, getString(R.string.ask_bot)));

Go, to line no: 116 and delete the line 116 - 118. Renumber the Switch cases. Finally your Switch block will look like this:

switch (position) {             
    case 0:                  
        break;             
    case 1:                 
        startActivity(new Intent(activity, AskBotActivity.class));
        break;
    case 2:
        startActivity(new Intent(activity,AddPaymentActivity.class)); 
        break;             
    case 3:                 
        startActivity(new Intent(activity, NikolaWalletActivity.class));
        break;             
    case 4:                
        showrefferal();                 
        break;                       
    case 5:                 
        startActivity(new Intent(activity,HistoryActivity.class));
        break;             
    case 6:                 
        startActivity(new Intent(activity,LaterRequestsActivity.class));
        break;             
    case 7:                 
        HourlyBookngFragment hourlyfragment = new HourlyBookngFragment();                 
        Bundle nbundle = new Bundle();
        nbundle.putString("pickup_address", Home_Map_Fragment.pickup_add);                         hourlyfragment.setArguments(nbundle);
        activity.addFragment(hourlyfragment, false, Const.HOURLY_FRAGMENT, true);
        break;
    case 8:
        activity.addFragment(new AirportBookingFragment(), false, Const.AIRPORT_FRAGMENT, true);
        break; 
    case 9: 
        startActivity(new Intent(activity,HelpwebActivity.class)); 
        break;
    case 10:
        showlogoutdailog();
        break;           
}

8. Update otp_verifier.xml

Navigate to otp_verifier.xml file in the following path.

app>res>layout>otp_verifier.xml

Delete the code from line 92 - 101.


9. 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: 28 and substitute logo_header with your header logo name.

android:src="@drawable/logo_header"


10. 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: 36 and substitute logo_header with your header logo name.

android:src="@drawable/logo_header"

11. 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.


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

Open the app level build.gradle file.

Update the applicationId parameter with your package name.

applicationId 'com.yourcompany.user'

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?

1 out of 1 found this helpful

Articles in this section