Skip to content

Commit 212054e

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # src/main/java/com/nbs/ui/panels/ContactsPanel.java
2 parents f8c8fcd + f2abeb7 commit 212054e

File tree

915 files changed

+3368
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

915 files changed

+3368
-11
lines changed

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@
6363
<artifactId>commons-codec</artifactId>
6464
<version>1.11</version>
6565
</dependency>
66+
<!-- https://mvnrepository.com/artifact/com.melloware/jintellitype -->
67+
<dependency>
68+
<groupId>com.melloware</groupId>
69+
<artifactId>jintellitype</artifactId>
70+
<version>1.3.9</version>
71+
</dependency>
72+
<!-- https://mvnrepository.com/artifact/com.vdurmont/emoji-java -->
73+
<dependency>
74+
<groupId>com.vdurmont</groupId>
75+
<artifactId>emoji-java</artifactId>
76+
<version>4.0.0</version>
77+
</dependency>
6678

6779

6880
</dependencies>

profile/.merkle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#add nbs1.0.rar
2-
#Tue Jun 26 14:17:32 CST 2018
3-
QmQD445aW3Ge6bgD6Lv9RJG48WfveAMgXket15GYsuysYb=nbs.rp
2+
#Tue Jun 26 18:13:02 CST 2018
43
QmdNQYHjg2d6PKsXu5DSRWJHPUgSMVqWttAAp3bqaHq2Z8=Girls-Gee-\u300Aoh\u300B.mp3
5-
QmWuoJzhZkMjEe9ybfFeaSn6jDzTgvPd6UkC6RLZUbZVyf=NBS.jpg
6-
QmNgp7Lt1JYRiWYVpzV7s8nUxeHgScudkSbn36p8HmySAY=nbs1.0.rar
74
Qmc5QhR1WeUhGW12tT3WND3qxfLRmnci1PYjogjGy56X3n=Monica.mp3
5+
QmWuoJzhZkMjEe9ybfFeaSn6jDzTgvPd6UkC6RLZUbZVyf=NBS.jpg
86
QmfK5QwVKDod3Bwjdmcgyf1qGxEzmGayfSSFTcv4BxxRXR=nbs.rp
9-
QmW4dKs2KXqCWc9TQXzSc41HTNBPtFJJf7crwSbLGkQmVa=nbs64.png
7+
QmQD445aW3Ge6bgD6Lv9RJG48WfveAMgXket15GYsuysYb=nbs.rp
108
QmeLUM8e8WRKBLsRp3Pme39yiTz4nTMGURm7unUQbrWhCn=\u5FAE\u4FE1\u56FE\u7247_20180608230516.jpg
9+
QmNgp7Lt1JYRiWYVpzV7s8nUxeHgScudkSbn36p8HmySAY=nbs1.0.rar
10+
QmW4dKs2KXqCWc9TQXzSc41HTNBPtFJJf7crwSbLGkQmVa=nbs64.png
11+
QmfFhhc1Woo4hE5d14jBPdotng7j9vx6UA4My8Xk597Di8=nbs1.0.rar

src/main/java/UI/AppMainWindow.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.nbs.tools.ConfigHelper;
1616

1717
import com.nbs.tools.DateHelper;
18+
import com.nbs.ui.frames.MainFrame;
1819
import com.nbs.utils.Base64CodecUtil;
1920
import com.nbs.utils.RadomCharactersHelper;
2021
import io.ipfs.api.IPFS;
@@ -59,7 +60,7 @@ public class AppMainWindow {
5960

6061
private static boolean boradcastSuccess = false;
6162

62-
public static JFrame frame;
63+
public static MainFrame frame;
6364
/**
6465
* 主窗口
6566
*/
@@ -210,7 +211,7 @@ private void initialize(){
210211
e.printStackTrace();
211212
}
212213

213-
frame = new JFrame();
214+
frame = new MainFrame();
214215
//set window Size
215216
frame.setBounds(ConstantsUI.MAIN_WINDOW_X,ConstantsUI.MAIN_WINDOW_Y
216217
,ConstantsUI.MAIN_WINDOW_WIDTH,ConstantsUI.MAIN_WINDOW_HEIGHT);

src/main/java/UI/ConstantsUI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public class ConstantsUI {
5656
/**
5757
* 图标路径
5858
*/
59-
private static final String BUTTON_ICON_ROOT = "/icon/"+PropertyUtil.getProperty("nbs.button.dir","")+"/";
59+
public static final String BUTTON_ICON_ROOT = "/icon"+File.separator
60+
+PropertyUtil.getProperty("nbs.button.dir","")+ File.separator;
6061

6162
/**
6263
* 主图标

src/main/java/UI/button/NBSIconButton.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ private void initialize(){
7474
this.setMargin(new Insets(0,0,0,0));
7575
}
7676

77+
78+
7779
/**
7880
* 设置按钮样式:
7981
*/

src/main/java/UI/panel/im/IMPanel.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.nbs.ipfs.entity.IpfsMessage;
1414
import com.nbs.tools.DateHelper;
1515
import com.nbs.ui.components.ColorCnst;
16+
import com.nbs.ui.panels.ChatPanel;
1617
import com.nbs.utils.Base64CodecUtil;
1718
import io.ipfs.api.IPFS;
1819

@@ -45,13 +46,17 @@ public class IMPanel extends NBSAbstractPanel {
4546
* 左侧IM peers
4647
*/
4748
private ImLeftPanel leftPanel;
49+
/**
50+
* 右侧聊天面板
51+
*/
52+
private ChatPanel chatPanel;
4853

4954

5055
private static JTextArea imMSGShow = new JTextArea();
5156
/**
5257
* 顶部显示
5358
*/
54-
private static ToolbarStatsPanel toolbarStatsPanel = new ToolbarStatsPanel(PKUI_PANEL_IM_LABEL);;
59+
private static ToolbarStatsPanel toolbarStatsPanel = new ToolbarStatsPanel(PKUI_PANEL_IM_LABEL);
5560

5661
private static JTextArea inputArea = new JTextArea();
5762

@@ -86,7 +91,7 @@ protected void init() {
8691

8792
@Override
8893
protected void addComponent() {
89-
this.add(toolbarStatsPanel,BorderLayout.NORTH);
94+
// this.add(toolbarStatsPanel,BorderLayout.NORTH);
9095
/**
9196
*
9297
*/
@@ -121,7 +126,9 @@ private JPanel getCenterPanel(){
121126
/**
122127
* 聊天主窗口
123128
*/
124-
centerPanel.add(buildMessMainPanel(),BorderLayout.CENTER);
129+
//centerPanel.add(buildMessMainPanel(),BorderLayout.CENTER);
130+
chatPanel = new ChatPanel(this);
131+
centerPanel.add(chatPanel,BorderLayout.CENTER);
125132
return centerPanel;
126133
}
127134

@@ -130,6 +137,9 @@ public void load() {
130137

131138
}
132139

140+
/**
141+
*
142+
*/
133143
@Override
134144
protected void addListener() {
135145
sendButton.addActionListener(new AbstractAction() {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package UI.panel.im;
2+
3+
import javax.swing.*;
4+
5+
/**
6+
* @Package : UI.panel.im
7+
* @Description : <p></p>
8+
* @Author : lambor.c
9+
* @Date : 2018/6/26-20:55
10+
* Copyright (c) 2018, NBS , lambor.c<[email protected]>.
11+
* All rights reserved.
12+
*/
13+
public class RightPanel extends JPanel {
14+
private static RightPanel context;
15+
16+
17+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package com.nbs.entity;
2+
3+
import com.nbs.ipfs.entity.IpfsMessage;
4+
5+
/**
6+
* @Package : com.nbs.entity
7+
* @Description : <p></p>
8+
* @Author : lambor.c
9+
* @Date : 2018/6/26-23:34
10+
* Copyright (c) 2018, NBS , lambor.c<[email protected]>.
11+
* All rights reserved.
12+
*/
13+
public class MessageItem implements Comparable<MessageItem> {
14+
public static final int SYSTEM_MESSAGE = 0;
15+
public static final int LEFT_TEXT = 1;
16+
public static final int LEFT_IMAGE = 2;
17+
public static final int LEFT_ATTACHMENT = 3;
18+
19+
public static final int RIGHT_TEXT = -1;
20+
public static final int RIGHT_IMAGE = -2;
21+
public static final int RIGHT_ATTACHMENT = -3;
22+
23+
/**
24+
*
25+
*/
26+
private String seqno;
27+
/**
28+
* 群聊
29+
*/
30+
private String roomId;
31+
/**
32+
* 消息内容
33+
*/
34+
private String messageContent;
35+
private long timestamp;
36+
/**
37+
* nickname
38+
*/
39+
private String senderUsername;
40+
/**
41+
* peerID
42+
*/
43+
private String senderId;
44+
/**
45+
*
46+
*/
47+
private String from;
48+
private boolean needToResend;
49+
50+
public MessageItem() {
51+
}
52+
53+
public MessageItem(long timestamp) {
54+
this.timestamp = timestamp;
55+
}
56+
57+
public MessageItem(String seqno, String messageContent, String senderId) {
58+
this.seqno = seqno;
59+
this.messageContent = messageContent;
60+
this.senderId = senderId;
61+
}
62+
63+
/**
64+
* TODO
65+
* @param item
66+
* @param message
67+
*/
68+
public MessageItem(ContactsItem item,IpfsMessage message) {
69+
this.senderUsername = senderUsername;
70+
}
71+
72+
@Override
73+
public int compareTo(MessageItem o) {
74+
return (int) (this.getTimestamp() - o.getTimestamp());
75+
}
76+
77+
public String getSeqno() {
78+
return seqno;
79+
}
80+
81+
public void setSeqno(String seqno) {
82+
this.seqno = seqno;
83+
}
84+
85+
public String getRoomId() {
86+
return roomId;
87+
}
88+
89+
public void setRoomId(String roomId) {
90+
this.roomId = roomId;
91+
}
92+
93+
public String getMessageContent() {
94+
return messageContent;
95+
}
96+
97+
public void setMessageContent(String messageContent) {
98+
this.messageContent = messageContent;
99+
}
100+
101+
public long getTimestamp() {
102+
return timestamp;
103+
}
104+
105+
public void setTimestamp(long timestamp) {
106+
this.timestamp = timestamp;
107+
}
108+
109+
public String getSenderUsername() {
110+
return senderUsername;
111+
}
112+
113+
public void setSenderUsername(String senderUsername) {
114+
this.senderUsername = senderUsername;
115+
}
116+
117+
public String getSenderId() {
118+
return senderId;
119+
}
120+
121+
public void setSenderId(String senderId) {
122+
this.senderId = senderId;
123+
}
124+
125+
public boolean isNeedToResend() {
126+
return needToResend;
127+
}
128+
129+
public void setNeedToResend(boolean needToResend) {
130+
this.needToResend = needToResend;
131+
}
132+
133+
public String getFrom() {
134+
return from;
135+
}
136+
137+
public void setFrom(String from) {
138+
this.from = from;
139+
}
140+
}

src/main/java/com/nbs/tools/ConfigHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public class ConfigHelper {
3232
public static final String PROFILE_ROOT = CURRENT_DIR + File.separator+"profile" + File.separator;
3333
public static final String NBS_FILES_ROOT_PATH = CURRENT_DIR + File.separator +"nbs" + File.separator;
3434
public static final String NBS_FILES_IPFS_ROOT = NBS_FILES_ROOT_PATH + "ipfs"+ File.separator;
35+
/**
36+
* 临时文件
37+
*/
38+
public static final String NBS_TEMP_ROOT = NBS_FILES_ROOT_PATH + "_temp" + File.separator;
3539
public static final String NBS_CACHE_AVATAR_ROOT_PATH = NBS_FILES_ROOT_PATH +"cache"+ File.separator+ "avatar" + File.separator;
3640
private static final String CONF_FILE = "nbs-conf.properties";
3741

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.nbs.tools;
2+
3+
import com.nbs.ui.holder.MessageLeftTextViewHolder;
4+
import com.nbs.ui.holder.MessageRightTextViewHolder;
5+
import com.nbs.ui.holder.MessageSystemMessageViewHolder;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
/**
11+
* @Package : com.nbs.tools
12+
* @Description :
13+
* <p>
14+
* 提供消息ViewHolder缓存,
15+
* 对消息的ViewHolder进入缓存能大大加速消息列表的加载速度,在刚进入房间时,默认先加载10条消息,
16+
* </p>
17+
* @Author : lambor.c
18+
* @Date : 2018/6/26-23:46
19+
* Copyright (c) 2018, NBS , lambor.c<[email protected]>.
20+
* All rights reserved.
21+
*/
22+
public class MessageViewHolderCacheHelper {
23+
private final int CACHE_CAPACITY = 20;
24+
private List<MessageRightTextViewHolder> rightTextViewHolders = new ArrayList<>();
25+
26+
private List<MessageLeftTextViewHolder> leftTextViewHolders = new ArrayList<>();
27+
28+
private List<MessageSystemMessageViewHolder> systemMessageViewHolders = new ArrayList<>();
29+
30+
private int rightTextPosition = 0;
31+
private int rightImagePosition = 0;
32+
private int rightAttachmentPosition = 0;
33+
private int leftTextPosition = 0;
34+
private int leftImagePosition = 0;
35+
private int leftAttachmentPosition = 0;
36+
private int systemMessagePosition = 0;
37+
38+
public MessageViewHolderCacheHelper() {
39+
initHolders();
40+
}
41+
42+
private void initHolders(){
43+
new Thread(()->{
44+
long startTime = System.currentTimeMillis();
45+
initLeftTextViewHolder();
46+
initRightTextViewHolder();
47+
}).start();
48+
}
49+
50+
private void initRightTextViewHolder(){
51+
for(int i=0;i<CACHE_CAPACITY;i++){
52+
rightTextViewHolders.add(new MessageRightTextViewHolder());
53+
}
54+
}
55+
56+
private void initLeftTextViewHolder(){
57+
for(int i=0;i<CACHE_CAPACITY;i++){
58+
leftTextViewHolders.add(new MessageLeftTextViewHolder());
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)