Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zetbaitsu committed Mar 7, 2017
2 parents daab98f + afa848c commit af8f8cf
Show file tree
Hide file tree
Showing 76 changed files with 882 additions and 168 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ allprojects {
Then add to your app module build.gradle
```groovy
dependencies {
compile 'com.qiscus.sdk:chat:1.11.0'
compile 'com.qiscus.sdk:chat:1.12.0'
}
```
# Let's make cools chatting apps!
Expand Down
47 changes: 47 additions & 0 deletions app/src/main/java/com/qiscus/dragonfly/CustomChatFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -27,6 +28,7 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.qiscus.sdk.Qiscus;
import com.qiscus.sdk.data.model.QiscusChatRoom;
import com.qiscus.sdk.ui.adapter.QiscusChatAdapter;
import com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment;
Expand Down Expand Up @@ -74,6 +76,27 @@ protected void onLoadView(View view) {
});
}

@Override
protected void onApplyChatConfig() {
super.onApplyChatConfig();
if (addImageButton != null) {
addImageButton.setBackground(ContextCompat.getDrawable(Qiscus.getApps(),
R.drawable.bt_qiscus_selector_grey));
}
if (takeImageButton != null) {
takeImageButton.setBackground(ContextCompat.getDrawable(Qiscus.getApps(),
R.drawable.bt_qiscus_selector_grey));
}
if (addFileButton != null) {
addFileButton.setBackground(ContextCompat.getDrawable(Qiscus.getApps(),
R.drawable.bt_qiscus_selector_grey));
}
if (recordAudioButton != null) {
recordAudioButton.setBackground(ContextCompat.getDrawable(Qiscus.getApps(),
R.drawable.bt_qiscus_selector_grey));
}
}

@NonNull
@Override
protected ViewGroup getRootView(View view) {
Expand Down Expand Up @@ -104,6 +127,12 @@ protected ViewGroup getMessageInputPanel(View view) {
return (ViewGroup) view.findViewById(R.id.input_panel);
}

@Nullable
@Override
protected ViewGroup getMessageEditTextContainer(View view) {
return null;
}

@NonNull
@Override
protected EditText getMessageEditText(View view) {
Expand Down Expand Up @@ -146,6 +175,12 @@ protected TextView getEmptyChatDescView(View view) {
return (TextView) view.findViewById(R.id.empty_chat_desc);
}

@Nullable
@Override
protected ViewGroup getAttachmentPanel(View view) {
return null;
}

@Nullable
@Override
protected ImageView getAddImageButton(View view) {
Expand All @@ -170,6 +205,18 @@ protected ImageView getRecordAudioButton(View view) {
return (ImageView) view.findViewById(R.id.button_add_audio);
}

@Nullable
@Override
public ImageView getHideAttachmentButton(View view) {
return null;
}

@Nullable
@Override
protected ImageView getToggleEmojiButton(View view) {
return (ImageView) view.findViewById(R.id.button_emoji);
}

@Nullable
@Override
protected QiscusAudioRecorderView getRecordAudioPanel(View view) {
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/qiscus/dragonfly/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void openChat(View view) {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(intent -> {
revertCustomChatConfig();
startActivity(intent);
dismissLoading();
}, throwable -> {
Expand All @@ -91,6 +92,7 @@ public void openChatFragment(View view) {
.observeOn(AndroidSchedulers.mainThread())
.map(qiscusChatRoom -> ChatActivity.generateIntent(this, qiscusChatRoom, false))
.subscribe(intent -> {
revertCustomChatConfig();
startActivity(intent);
dismissLoading();
}, throwable -> {
Expand All @@ -109,6 +111,7 @@ public void openSimpleCustomChat(View view) {
.observeOn(AndroidSchedulers.mainThread())
.map(qiscusChatRoom -> ChatActivity.generateIntent(this, qiscusChatRoom, true))
.subscribe(intent -> {
revertCustomChatConfig();
startActivity(intent);
dismissLoading();
}, throwable -> {
Expand All @@ -127,6 +130,7 @@ public void openAdvanceCustomChat(View view) {
.observeOn(AndroidSchedulers.mainThread())
.map(qiscusChatRoom -> CustomChatActivity.generateIntent(this, qiscusChatRoom))
.subscribe(intent -> {
setupCustomChatConfig();
startActivity(intent);
dismissLoading();
}, throwable -> {
Expand Down Expand Up @@ -167,4 +171,16 @@ public void showLoading() {
public void dismissLoading() {
mProgressDialog.dismiss();
}

private void revertCustomChatConfig() {
Qiscus.getChatConfig()
.setSendButtonIcon(R.drawable.ic_qiscus_send)
.setShowAttachmentPanelIcon(R.drawable.ic_qiscus_attach);
}

private void setupCustomChatConfig() {
Qiscus.getChatConfig()
.setSendButtonIcon(R.drawable.ic_qiscus_send_on)
.setShowAttachmentPanelIcon(R.drawable.ic_qiscus_send_off);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ protected void onCreateChatComponents(Bundle savedInstanceState) {
}

@Override
protected void sendMessage() {
if (chatT.isEmpty()) {
public void sendMessage(String message) {
if (chatAdapter.isEmpty()) {
Toast.makeText(getActivity(), "First message sent!", Toast.LENGTH_SHORT).show();
}
super.sendMessage();
super.sendMessage(message);
}

private void lockChatAfter(int duration) {
Expand Down
33 changes: 25 additions & 8 deletions app/src/main/res/layout/fragment_custom_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -123,7 +124,8 @@
android:paddingRight="2dp"
android:paddingStart="2dp"
android:paddingTop="2dp"
android:src="@drawable/ic_qiscus_add_image"/>
android:src="@drawable/ic_qiscus_add_image"
android:tint="@color/qiscus_secondary_text"/>

<ImageView
android:id="@+id/button_pick_picture"
Expand All @@ -137,7 +139,8 @@
android:paddingRight="1dp"
android:paddingStart="1dp"
android:paddingTop="2dp"
android:src="@drawable/ic_qiscus_pick_picture"/>
android:src="@drawable/ic_qiscus_pick_picture"
android:tint="@color/qiscus_secondary_text"/>

<ImageView
android:id="@+id/button_add_file"
Expand All @@ -151,7 +154,8 @@
android:paddingRight="1dp"
android:paddingStart="1dp"
android:paddingTop="2dp"
android:src="@drawable/ic_qiscus_add_file"/>
android:src="@drawable/ic_qiscus_add_file"
android:tint="@color/qiscus_secondary_text"/>

<ImageView
android:id="@+id/button_add_audio"
Expand All @@ -165,7 +169,8 @@
android:paddingRight="1dp"
android:paddingStart="1dp"
android:paddingTop="2dp"
android:src="@drawable/ic_qiscus_add_audio"/>
android:src="@drawable/ic_qiscus_add_audio"
android:tint="@color/qiscus_secondary_text"/>

</LinearLayout>

Expand All @@ -190,20 +195,32 @@
android:padding="4dp"
android:src="@drawable/ic_action_add"/>

<EditText
<com.vanniktech.emoji.EmojiEditText
android:id="@+id/field_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="@android:color/transparent"
android:hint="@string/hint_message"
android:imeOptions="actionSend"
android:inputType="textLongMessage|textMultiLine|textCapSentences"
android:imeOptions="actionSend|flagNoEnterAction"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:maxLines="4"
android:padding="8dp"
android:textColor="@color/qiscus_primary_text"
android:textSize="16sp"/>
android:textSize="16sp"
app:emojiSize="22sp"/>

<ImageView
android:id="@+id/button_emoji"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:background="@drawable/bt_qiscus_selector_grey"
android:padding="2dp"
android:src="@drawable/ic_qiscus_emot"/>

<ImageView
android:id="@+id/button_send"
Expand Down
4 changes: 3 additions & 1 deletion chat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ext {
siteUrl = 'https://github.com/qiscus/qiscus-sdk-android'
gitUrl = 'https://github.com/qiscus/qiscus-sdk-android.git'

libraryVersion = '1.11.0'
libraryVersion = '1.12.0'

developerId = 'qiscustech'
developerName = 'Qiscus Tech'
Expand Down Expand Up @@ -125,4 +125,6 @@ dependencies {

compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'

compile 'com.vanniktech:emoji-one:0.4.0'
}
4 changes: 4 additions & 0 deletions chat/src/main/java/com/qiscus/sdk/Qiscus.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import com.qiscus.sdk.service.QiscusPusherService;
import com.qiscus.sdk.ui.QiscusChatActivity;
import com.qiscus.sdk.ui.fragment.QiscusChatFragment;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.one.EmojiOneProvider;

import org.greenrobot.eventbus.EventBus;

Expand Down Expand Up @@ -122,6 +124,8 @@ public static void initWithCustomServer(Application application, String serverBa
QiscusCacheManager.getInstance().setLastChatActivity(false, 0);

configureFcmToken();

EmojiManager.install(new EmojiOneProvider());
}

public static void startPusherService() {
Expand Down
Loading

0 comments on commit af8f8cf

Please sign in to comment.