/*
 * Copyright (c) 2016 Qiscus.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.qiscus.dragonfly;

import android.app.ProgressDialog;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.qiscus.sdk.Qiscus;
import com.qiscus.sdk.util.QiscusDateUtil;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created on : September 28, 2016
 * Author     : zetbaitsu
 * Name       : Zetra
 * Email      : zetra@mail.ugm.ac.id
 * GitHub     : https://github.com/zetbaitsu
 * LinkedIn   : https://id.linkedin.com/in/zetbaitsu
 */
public class CustomChatActivity extends AppCompatActivity {
    private ProgressDialog progressDialog;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(ContextCompat.getColor(this, R.color.qiscus_primary_light));
        }

        setContentView(R.layout.activity_custom_chat);

        customizeChatUI();

        showLoading();
        Qiscus.buildChatRoomWith("rya.meyvriska1@gmail.com")
                .build()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .map(CustomChatFragment::newInstance)
                .subscribe(qiscusChatFragment -> {
                    getSupportFragmentManager().beginTransaction()
                            .replace(R.id.fragment_container, qiscusChatFragment)
                            .commit();
                    dismissLoading();
                }, throwable -> {
                    throwable.printStackTrace();
                    showError(throwable.getMessage());
                    dismissLoading();
                });
    }

    private void customizeChatUI() {
        Qiscus.getChatConfig()
                .setLeftBubbleColor(R.color.qiscus_primary)
                .setRightBubbleColor(R.color.qiscus_primary_light)
                .setRightBubbleTextColor(R.color.qiscus_primary_text)
                .setRightBubbleTimeColor(R.color.qiscus_secondary_text)
                .setTimeFormat(QiscusDateUtil::toHour);
    }

    public void showError(String errorMessage) {
        Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show();
    }

    public void showLoading() {
        if (progressDialog == null) {
            progressDialog = new ProgressDialog(this);
            progressDialog.setMessage("Please wait...");
        }
        progressDialog.setCancelable(false);
        progressDialog.show();
    }

    public void dismissLoading() {
        progressDialog.dismiss();
    }
}

@@ -973,51 +973,8 @@
 cus;
-%0Aimport com.qiscus.sdk.util.QiscusDateUtil;
 %0A%0Aim
@@ -1878,36 +1878,8 @@
 );%0A%0A
-        customizeChatUI();%0A%0A
     
@@ -2587,32 +2587,32 @@
 smissLoading();%0A
+
                 
@@ -2626,408 +2626,8 @@
  %7D%0A%0A
-    private void customizeChatUI() %7B%0A        Qiscus.getChatConfig()%0A                .setLeftBubbleColor(R.color.qiscus_primary)%0A                .setRightBubbleColor(R.color.qiscus_primary_light)%0A                .setRightBubbleTextColor(R.color.qiscus_primary_text)%0A                .setRightBubbleTimeColor(R.color.qiscus_secondary_text)%0A                .setTimeFormat(QiscusDateUtil::toHour);%0A    %7D%0A%0A
     

Remove styling chat