Customize Navigation Bar

When TapTalk.io framework is integrated to your app with the UI/combine implementation method, you can customize chat room's navigation bar layout to your preferences.

Customize Chat Room Navigation Bar

You can follow the steps below to customize chat rooms' navigation bar layout in your app.

1. Create your custom navigation bar XML layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize">

    <!--Customize and add more layouts here-->

</android.support.constraint.ConstraintLayout>

2. Create your custom navigation bar fragment

Create a new fragment file inside your project folder, and set it to extend TapBaseChatRoomCustomNavigationBarFragment.

Then override onCreateView() and return your custom layout.

import io.taptalk.TapTalk.View.Fragment.TapBaseChatRoomCustomNavigationBarFragment;

public class MeetTalkChatRoomNavigationBarFragment extends TapBaseChatRoomCustomNavigationBarFragment {
    
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        // Return your custom layout
        return inflater.inflate(R.layout.your_custom_navbar_layout, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        // Setup your views here
    }
}

3. Implement callbacks from base navigation fragment class to update UI

TapBaseChatRoomCustomNavigationBarFragment class is a helper fragment class that implements TapCoreChatRoomListener to listen to chat room related callbacks from PowerTalk SDK.

The class will then handle and redirect the callbacks to the following functions, which provide the required data that you can make use of for your own custom navbar class to display and update UI elements in the custom navigation bar.

You can override the callbacks functions from the TapBaseChatRoomCustomNavigationBarFragment class to your own custom navbar class:

4. Make use of base navigation bar manager properties

TapBaseChatRoomCustomNavigationBarFragment also provides some properties that you can make use of to display UI elements in your custom navbar class.

You can call any of these properties provided below to help displaying your custom navbar.

The values of the properties above will also be updated when any related callbacks from PowerTalk SDK is received.

5. Implement TapUIChatRoomCustomNavigationBarListener

After you finished setting up your custom-made navigation bar, you will need to implement a listener from TapUI that will be invoked when the user opens a chat room. You can then return your custom navigation bar fragment through the callback function.

To do this, call the addChatRoomCustomNavigationBarListener method from TapUI class after you have initialized TapTalk. You can check the example below:

setCustomChatRoomNavigationBar callback from TapUIChatRoomCustomNavigationBarListener returns a TapBaseChatRoomCustomNavigationBarFragment as a value. If you do not implement this callback or return a null, PowerTalk SDK will display the default chat room navigation bar.

Last updated

Was this helpful?