<commit_before>/*
 * 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.sdk.data.model;

import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.RequiresApi;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;

import com.qiscus.sdk.Qiscus;
import com.qiscus.sdk.R;
import com.qiscus.sdk.data.local.QiscusCacheManager;
import com.qiscus.sdk.data.remote.QiscusApi;
import com.qiscus.sdk.ui.QiscusChatActivity;
import com.qiscus.sdk.ui.QiscusGroupChatActivity;
import com.qiscus.sdk.util.QiscusAndroidUtil;
import com.qiscus.sdk.util.QiscusDateUtil;

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

/**
 * Created on : June 15, 2017
 * Author     : zetbaitsu
 * Name       : Zetra
 * GitHub     : https://github.com/zetbaitsu
 */
public class QiscusChatConfig {
    private int statusBarColor = R.color.qiscus_primary_dark;
    private int appBarColor = R.color.qiscus_primary;
    private int accentColor = R.color.qiscus_accent;
    private int inlineReplyColor = R.color.qiscus_primary;
    private int titleColor = R.color.qiscus_white;
    private int subtitleColor = R.color.qiscus_dark_white;
    private int rightBubbleColor = R.color.qiscus_primary_light;
    private int leftBubbleColor = R.color.qiscus_left_bubble;
    private int systemMessageBubbleColor = R.color.qiscus_accent_light;
    private int rightBubbleTextColor = R.color.qiscus_primary_text;
    private int leftBubbleTextColor = R.color.qiscus_primary_text;
    private int rightBubbleTimeColor = R.color.qiscus_secondary_text;
    private int leftBubbleTimeColor = R.color.qiscus_secondary_text;
    private int rightLinkTextColor = R.color.qiscus_primary_text;
    private int leftLinkTextColor = R.color.qiscus_primary_text;
    private int systemMessageTextColor = R.color.qiscus_primary_text;
    private int failedToSendMessageColor = R.color.qiscus_red;
    private int readIconColor = R.color.qiscus_primary;
    private int dateColor = R.color.qiscus_secondary_text;
    private int selectedBubbleBackgroundColor = R.color.qiscus_primary;

    private int rightProgressFinishedColor = R.color.qiscus_primary_light;
    private int leftProgressFinishedColor = R.color.qiscus_primary;

    private int accountLinkingTextColor = R.color.qiscus_primary;
    private int accountLinkingBackground = R.color.qiscus_account_linking_background;
    private String accountLinkingText = QiscusAndroidUtil.getString(R.string.qiscus_account_linking_text);

    private int buttonBubbleTextColor = R.color.qiscus_primary;
    private int buttonBubbleBackBackground = R.color.qiscus_account_linking_background;

    private DateFormatter dateFormat = QiscusDateUtil::toTodayOrDate;
    private DateFormatter timeFormat = QiscusDateUtil::toHour;

    private String emptyRoomTitle = QiscusAndroidUtil.getString(R.string.qiscus_welcome);
    private String emptyRoomSubtitle = QiscusAndroidUtil.getString(R.string.qiscus_desc_empty_chat);
    private int emptyRoomImageResource = R.drawable.ic_qiscus_chat_empty;
    private String messageFieldHint = QiscusAndroidUtil.getString(R.string.qiscus_hint_message);

    private int addPictureIcon = R.drawable.ic_qiscus_add_image;
    private int addPictureBackgroundColor = R.color.qiscus_gallery_background;
    private String addPictureText = QiscusAndroidUtil.getString(R.string.qiscus_gallery);
    private boolean enableAddPicture = true;

    private int takePictureIcon = R.drawable.ic_qiscus_pick_picture;
    private int takePictureBackgroundColor = R.color.qiscus_camera_background;
    private String takePictureText = QiscusAndroidUtil.getString(R.string.qiscus_camera);
    private boolean enableTakePicture = true;

    private int addFileIcon = R.drawable.ic_qiscus_add_file;
    private int addFileBackgroundColor = R.color.qiscus_file_background;
    private String addFileText = QiscusAndroidUtil.getString(R.string.qiscus_file);
    private boolean enableAddFile = true;

    private int recordAudioIcon = R.drawable.ic_qiscus_add_audio;
    private int recordBackgroundColor = R.color.qiscus_record_background;
    private String recordText = QiscusAndroidUtil.getString(R.string.qiscus_record);
    private boolean enableRecordAudio = true;

    private int stopRecordIcon = R.drawable.ic_qiscus_send_on;
    private int cancelRecordIcon = R.drawable.ic_qiscus_cancel_record;

    private int sendButtonIcon = R.drawable.ic_qiscus_send;
    private int showAttachmentPanelIcon = R.drawable.ic_qiscus_attach;
    private int hideAttachmentPanelIcon = R.drawable.ic_qiscus_back_to_keyboard;
    private int hideAttachmentPanelBackgroundColor = R.color.qiscus_keyboard_background;

    private int replyBarColor = R.color.qiscus_primary;
    private int replySenderColor = R.color.qiscus_primary;
    private int replyMessageColor = R.color.qiscus_secondary_text;

    private int cardTitleColor = R.color.qiscus_primary_text;
    private int cardDescriptionColor = R.color.qiscus_secondary_text;
    private int cardButtonTextColor = R.color.qiscus_primary;
    private int cardButtonBackground = R.color.qiscus_white;

    private int playAudioIcon = R.drawable.ic_qiscus_play_audio;
    private int pauseAudioIcon = R.drawable.ic_qiscus_pause_audio;
    private int showEmojiIcon = R.drawable.ic_qiscus_emot;
    private int showKeyboardIcon = R.drawable.ic_qiscus_keyboard;

    private int[] swipeRefreshColorScheme = new int[]{R.color.qiscus_primary, R.color.qiscus_accent};

    private int notificationSmallIcon = R.drawable.ic_qiscus_notif_app;
    private int notificationBigIcon = R.drawable.ic_qiscus_notif_app;
    private boolean enableAvatarAsNotificationIcon = true;
    private boolean enableReplyNotification = false;
    private QiscusNotificationBuilderInterceptor notificationBuilderInterceptor;

    private QiscusImageCompressionConfig qiscusImageCompressionConfig = new QiscusImageCompressionConfig();

    private NotificationTitleHandler notificationTitleHandler = QiscusComment::getRoomName;

    private NotificationClickListener notificationClickListener =
            (context, qiscusComment) -> QiscusApi.getInstance()
                    .getChatRoom(qiscusComment.getRoomId())
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doOnNext(qiscusChatRoom -> {
                        if (!qiscusChatRoom.isGroup()) {
                            qiscusChatRoom.setName(qiscusComment.getSender());
                        }
                    })
                    .map(qiscusChatRoom -> {
                        if (qiscusChatRoom.isGroup()) {
                            return QiscusGroupChatActivity.generateIntent(context, qiscusChatRoom);
                        }
                        return QiscusChatActivity.generateIntent(context, qiscusChatRoom);
                    })
                    .subscribe(intent -> {
                        context.startActivity(intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_CLEAR_TASK));
                    }, throwable -> {
                        throwable.printStackTrace();
                        Toast.makeText(context, throwable.getMessage(), Toast.LENGTH_SHORT).show();
                    });

    private ReplyNotificationHandler replyNotificationHandler =
            (context, qiscusComment) -> QiscusApi.getInstance().postComment(qiscusComment)
                    .doOnSubscribe(() -> Qiscus.getDataStore().add(qiscusComment))<commit_msg>Update comment state after completed sent to server from notification reply.<commit_after>/*
 * 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.sdk.data.model;

import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.RequiresApi;
import android.support.v4.content.ContextCompat;
import android.widget.Toast;

import com.qiscus.sdk.Qiscus;
import com.qiscus.sdk.R;
import com.qiscus.sdk.data.local.QiscusCacheManager;
import com.qiscus.sdk.data.remote.QiscusApi;
import com.qiscus.sdk.ui.QiscusChatActivity;
import com.qiscus.sdk.ui.QiscusGroupChatActivity;
import com.qiscus.sdk.util.QiscusAndroidUtil;
import com.qiscus.sdk.util.QiscusDateUtil;

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

/**
 * Created on : June 15, 2017
 * Author     : zetbaitsu
 * Name       : Zetra
 * GitHub     : https://github.com/zetbaitsu
 */
public class QiscusChatConfig {
    private int statusBarColor = R.color.qiscus_primary_dark;
    private int appBarColor = R.color.qiscus_primary;
    private int accentColor = R.color.qiscus_accent;
    private int inlineReplyColor = R.color.qiscus_primary;
    private int titleColor = R.color.qiscus_white;
    private int subtitleColor = R.color.qiscus_dark_white;
    private int rightBubbleColor = R.color.qiscus_primary_light;
    private int leftBubbleColor = R.color.qiscus_left_bubble;
    private int systemMessageBubbleColor = R.color.qiscus_accent_light;
    private int rightBubbleTextColor = R.color.qiscus_primary_text;
    private int leftBubbleTextColor = R.color.qiscus_primary_text;
    private int rightBubbleTimeColor = R.color.qiscus_secondary_text;
    private int leftBubbleTimeColor = R.color.qiscus_secondary_text;
    private int rightLinkTextColor = R.color.qiscus_primary_text;
    private int leftLinkTextColor = R.color.qiscus_primary_text;
    private int systemMessageTextColor = R.color.qiscus_primary_text;
    private int failedToSendMessageColor = R.color.qiscus_red;
    private int readIconColor = R.color.qiscus_primary;
    private int dateColor = R.color.qiscus_secondary_text;
    private int selectedBubbleBackgroundColor = R.color.qiscus_primary;

    private int rightProgressFinishedColor = R.color.qiscus_primary_light;
    private int leftProgressFinishedColor = R.color.qiscus_primary;

    private int accountLinkingTextColor = R.color.qiscus_primary;
    private int accountLinkingBackground = R.color.qiscus_account_linking_background;
    private String accountLinkingText = QiscusAndroidUtil.getString(R.string.qiscus_account_linking_text);

    private int buttonBubbleTextColor = R.color.qiscus_primary;
    private int buttonBubbleBackBackground = R.color.qiscus_account_linking_background;

    private DateFormatter dateFormat = QiscusDateUtil::toTodayOrDate;
    private DateFormatter timeFormat = QiscusDateUtil::toHour;

    private String emptyRoomTitle = QiscusAndroidUtil.getString(R.string.qiscus_welcome);
    private String emptyRoomSubtitle = QiscusAndroidUtil.getString(R.string.qiscus_desc_empty_chat);
    private int emptyRoomImageResource = R.drawable.ic_qiscus_chat_empty;
    private String messageFieldHint = QiscusAndroidUtil.getString(R.string.qiscus_hint_message);

    private int addPictureIcon = R.drawable.ic_qiscus_add_image;
    private int addPictureBackgroundColor = R.color.qiscus_gallery_background;
    private String addPictureText = QiscusAndroidUtil.getString(R.string.qiscus_gallery);
    private boolean enableAddPicture = true;

    private int takePictureIcon = R.drawable.ic_qiscus_pick_picture;
    private int takePictureBackgroundColor = R.color.qiscus_camera_background;
    private String takePictureText = QiscusAndroidUtil.getString(R.string.qiscus_camera);
    private boolean enableTakePicture = true;

    private int addFileIcon = R.drawable.ic_qiscus_add_file;
    private int addFileBackgroundColor = R.color.qiscus_file_background;
    private String addFileText = QiscusAndroidUtil.getString(R.string.qiscus_file);
    private boolean enableAddFile = true;

    private int recordAudioIcon = R.drawable.ic_qiscus_add_audio;
    private int recordBackgroundColor = R.color.qiscus_record_background;
    private String recordText = QiscusAndroidUtil.getString(R.string.qiscus_record);
    private boolean enableRecordAudio = true;

    private int stopRecordIcon = R.drawable.ic_qiscus_send_on;
    private int cancelRecordIcon = R.drawable.ic_qiscus_cancel_record;

    private int sendButtonIcon = R.drawable.ic_qiscus_send;
    private int showAttachmentPanelIcon = R.drawable.ic_qiscus_attach;
    private int hideAttachmentPanelIcon = R.drawable.ic_qiscus_back_to_keyboard;
    private int hideAttachmentPanelBackgroundColor = R.color.qiscus_keyboard_background;

    private int replyBarColor = R.color.qiscus_primary;
    private int replySenderColor = R.color.qiscus_primary;
    private int replyMessageColor = R.color.qiscus_secondary_text;

    private int cardTitleColor = R.color.qiscus_primary_text;
    private int cardDescriptionColor = R.color.qiscus_secondary_text;
    private int cardButtonTextColor = R.color.qiscus_primary;
    private int cardButtonBackground = R.color.qiscus_white;

    private int playAudioIcon = R.drawable.ic_qiscus_play_audio;
    private int pauseAudioIcon = R.drawable.ic_qiscus_pause_audio;
    private int showEmojiIcon = R.drawable.ic_qiscus_emot;
    private int showKeyboardIcon = R.drawable.ic_qiscus_keyboard;

    private int[] swipeRefreshColorScheme = new int[]{R.color.qiscus_primary, R.color.qiscus_accent};

    private int notificationSmallIcon = R.drawable.ic_qiscus_notif_app;
    private int notificationBigIcon = R.drawable.ic_qiscus_notif_app;
    private boolean enableAvatarAsNotificationIcon = true;
    private boolean enableReplyNotification = false;
    private QiscusNotificationBuilderInterceptor notificationBuilderInterceptor;

    private QiscusImageCompressionConfig qiscusImageCompressionConfig = new QiscusImageCompressionConfig();

    private NotificationTitleHandler notificationTitleHandler = QiscusComment::getRoomName;

    private NotificationClickListener notificationClickListener =
            (context, qiscusComment) -> QiscusApi.getInstance()
                    .getChatRoom(qiscusComment.getRoomId())
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .doOnNext(qiscusChatRoom -> {
                        if (!qiscusChatRoom.isGroup()) {
                            qiscusChatRoom.setName(qiscusComment.getSender());
                        }
                    })
                    .map(qiscusChatRoom -> {
                        if (qiscusChatRoom.isGroup()) {
                            return QiscusGroupChatActivity.generateIntent(context, qiscusChatRoom);
                        }
                        return QiscusChatActivity.generateIntent(context, qiscusChatRoom);
                    })
                    .subscribe(intent -> {
                        context.startActivity(intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_CLEAR_TASK));
                    }, throwable -> {
                        throwable.printStackTrace();
                        Toast.makeText(context, throwable.getMessage(), Toast.LENGTH_SHORT).show();
                    });

    private ReplyNotificationHandler replyNotificationHandler =
            (context, qiscusComment) -> QiscusApi.getInstance().postComment(qiscusComment)
                    .doOnSubscribe(() -> Qiscus.getDataStore().add(qiscusComment))
                    .doOnNext(comment -> {
                        comment.setState(QiscusComment.STATE_ON_QISCUS);
                        QiscusComment savedQiscusComment = Qiscus.getDataStore().getComment(comment.getId(), comment.getUniqueId());
                        if (savedQiscusComment != null && savedQiscusComment.getState() > comment.getState()) {
                            comment.setState(savedQiscusComment.getState());
                        }
                        Qiscus.getDataStore().addOrUpdate(comment);
                    })
{'fraction_non_alphanumeric': 0.07332175925925925, 'fraction_numerical': 0.001736111111111111, 'mean_word_length': 3.6479289940828403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '678621', 'n_tokens_mistral': 5075, 'n_tokens_neox': 4667, 'n_words': 968}