Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f0bebe0

Browse files
committed
Design Changes
1 parent 3b921a2 commit f0bebe0

File tree

15 files changed

+173
-109
lines changed

15 files changed

+173
-109
lines changed

‎app/src/main/java/com/example/chatfull/ChatActivity.java‎

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import android.view.Menu;
2222
import android.view.MenuItem;
2323
import android.view.View;
24-
import android.widget.Button;
2524
import android.widget.EditText;
2625
import android.widget.ImageButton;
2726
import android.widget.ImageView;
@@ -52,6 +51,7 @@
5251
import java.io.InputStream;
5352
import java.util.ArrayList;
5453
import java.util.Calendar;
54+
import java.util.Collections;
5555
import java.util.Date;
5656
import java.util.List;
5757

@@ -82,14 +82,15 @@ public class ChatActivity extends AppCompatActivity
8282
MessagesListAdapter<Message> adapter;
8383
int cnt = 0; //Sets message counter id
8484

85-
Button btnSend;
85+
ImageButton btnSend;
8686
ImageButton btnAttachment, btnImage;
8787
EditText input;
8888

8989
RelativeLayout back_view;
9090
int[] colors;
9191

9292
List<Message> messageArrayList;
93+
boolean saved = false;
9394

9495
@Override
9596
protected void onCreate(Bundle savedInstanceState) {
@@ -104,6 +105,14 @@ protected void onCreate(Bundle savedInstanceState) {
104105
Toolbar toolbar = findViewById(R.id.toolbar);
105106
setSupportActionBar(toolbar);
106107
getSupportActionBar().setTitle(user.getName());
108+
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
109+
getSupportActionBar().setDisplayShowHomeEnabled(true);
110+
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
111+
@Override
112+
public void onClick(View v) {
113+
onBackPressed();
114+
}
115+
});
107116

108117
this.messagesList = findViewById(R.id.messagesList);
109118

@@ -150,7 +159,11 @@ public void loadImage(ImageView imageView, @Nullable String url, @Nullable Objec
150159
ta.recycle();
151160

152161
adapter.setOnMessageLongClickListener(this);
162+
}
153163

164+
@Override
165+
protected void onResume() {
166+
super.onResume();
154167
messageArrayList = new ArrayList<Message>();
155168
gson = new Gson();
156169

@@ -165,9 +178,11 @@ public void loadImage(ImageView imageView, @Nullable String url, @Nullable Objec
165178
for (Message msg : messageArray) {
166179
messageArrayList.add(msg);
167180
}
181+
Collections.sort(messageArrayList,Message.DateComparator);
168182
adapter.addToEnd(messageArrayList,false);
169183
Log.e("MESSAGE_SIZE", messageArrayList.size() + "");
170184
}
185+
saved = false;
171186
}
172187

173188
public boolean isStoragePermissionGranted() {
@@ -214,9 +229,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
214229
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
215230
int id = item.getItemId();
216231
switch (id) {
217-
case R.id.select_all:
218-
Toast.makeText(getApplicationContext(), "Select All Clicked", Toast.LENGTH_SHORT).show();
219-
break;
220232
case R.id.background_button:
221233
ColorPickerDialogBuilder
222234
.with(this)
@@ -454,16 +466,24 @@ protected void onDestroy() {
454466

455467
@Override
456468
protected void onPause() {
469+
if(saved == false) {
470+
String jsonDataString = gson.toJson(messageArrayList);
471+
editor.putString(SHARED_PREFERENCES_KEY_MESSAGE_LIST, jsonDataString);
472+
editor.commit();
473+
saved = true;
474+
}
457475
super.onPause();
458-
459-
String jsonDataString = gson.toJson(messageArrayList);
460-
editor.putString(SHARED_PREFERENCES_KEY_MESSAGE_LIST, jsonDataString);
461-
editor.commit();
462476
}
463477

464478
@Override
465479
public void onBackPressed() {
466480
Log.e("CHAT_ACTIVITY", "PAUSE");
481+
if(saved == false) {
482+
String jsonDataString = gson.toJson(messageArrayList);
483+
editor.putString(SHARED_PREFERENCES_KEY_MESSAGE_LIST, jsonDataString);
484+
editor.commit();
485+
saved = true;
486+
}
467487
Message message = new Message(Integer.toString(++cnt), MainActivity.me, null);
468488
message.setOffline(true);
469489
sender = new SendMessage(user.getIpAddress(), user.getPort(), message, this);
@@ -561,4 +581,15 @@ public void run() {
561581
}
562582
}, 500);
563583
}
584+
585+
public static <T> List<T> removeDuplicates(List<T> list)
586+
{
587+
List<T> newList = new ArrayList<T>();
588+
for (T element : list) {
589+
if (!newList.contains(element)) {
590+
newList.add(element);
591+
}
592+
}
593+
return newList;
594+
}
564595
}

‎app/src/main/java/com/example/chatfull/Message.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.stfalcon.chatkit.commons.models.MessageContentType;
1010

1111
import java.io.Serializable;
12+
import java.util.Comparator;
1213
import java.util.Date;
1314

1415
public class Message implements IMessage, Serializable, MessageContentType.Image, MessageContentType {
@@ -34,6 +35,13 @@ public Message(String id, User user, String text, Date createdAt) {
3435
this.isImage = false;
3536
}
3637

38+
public static Comparator<Message> DateComparator = new Comparator<Message>() {
39+
@Override
40+
public int compare(Message message, Message t1) {
41+
return t1.getCreatedAt().compareTo(message.getCreatedAt());
42+
}
43+
};
44+
3745
boolean offline;
3846

3947
public boolean isOffline() {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#344e5c"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#FF000000" android:pathData="M16.5,6v11.5c0,2.21 -1.79,4 -4,4s-4,-1.79 -4,-4V5c0,-1.38 1.12,-2.5 2.5,-2.5s2.5,1.12 2.5,2.5v10.5c0,0.55 -0.45,1 -1,1s-1,-0.45 -1,-1V6H10v9.5c0,1.38 1.12,2.5 2.5,2.5s2.5,-1.12 2.5,-2.5V5c0,-2.21 -1.79,-4 -4,-4S7,2.79 7,5v12.5c0,3.04 2.46,5.5 5.5,5.5s5.5,-2.46 5.5,-5.5V6h-1.5z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#344E5C"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#FF000000" android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
5+
</vector>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3-
<corners android:radius="8dp"/>
4-
<solid android:color="@android:color/white"/>
3+
<corners android:radius="20dp"/>
4+
<solid android:color="#E5E5EA"/>
55
</shape>

‎app/src/main/res/drawable/btn_grey.xml‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎app/src/main/res/drawable/ic_attachment.xml‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎app/src/main/res/drawable/ic_rgb.xml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<vector android:height="24dp" android:viewportHeight="512"
2+
android:viewportWidth="512" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<path android:fillAlpha="1" android:fillColor="#58C3E8"
4+
android:fillType="nonZero"
5+
android:pathData="M401.059,162.664C401.059,242.777 336.113,307.723 256,307.723C175.887,307.723 110.941,242.777 110.941,162.664C110.941,82.551 175.887,17.605 256,17.605C336.113,17.605 401.059,82.551 401.059,162.664ZM401.059,162.664" android:strokeColor="#00000000"/>
6+
<path android:fillAlpha="1" android:fillColor="#FFD061"
7+
android:fillType="nonZero"
8+
android:pathData="M504.395,349.855C504.395,429.969 439.449,494.914 359.336,494.914C279.223,494.914 214.277,429.969 214.277,349.855C214.277,269.742 279.223,204.797 359.336,204.797C439.449,204.797 504.395,269.742 504.395,349.855ZM504.395,349.855" android:strokeColor="#00000000"/>
9+
<path android:fillAlpha="1" android:fillColor="#49BD90"
10+
android:fillType="nonZero"
11+
android:pathData="M221.793,303.656C232.762,306.309 244.215,307.723 256,307.723C319.961,307.723 374.25,266.324 393.543,208.863C382.574,206.211 371.121,204.797 359.336,204.797C295.375,204.797 241.086,246.191 221.793,303.656ZM221.793,303.656" android:strokeColor="#00000000"/>
12+
<path android:fillAlpha="1" android:fillColor="#FA70B2"
13+
android:fillType="nonZero"
14+
android:pathData="M297.723,349.855C297.723,429.969 232.777,494.914 152.664,494.914C72.551,494.914 7.605,429.969 7.605,349.855C7.605,269.742 72.551,204.797 152.664,204.797C232.777,204.797 297.723,269.742 297.723,349.855ZM297.723,349.855" android:strokeColor="#00000000"/>
15+
<path android:fillAlpha="1" android:fillColor="#AF7BC6"
16+
android:fillType="nonZero"
17+
android:pathData="M118.457,208.863C137.75,266.324 192.039,307.723 256,307.723C267.785,307.723 279.238,306.309 290.207,303.656C270.914,246.191 216.625,204.793 152.664,204.793C140.879,204.797 129.426,206.211 118.457,208.863ZM118.457,208.863" android:strokeColor="#00000000"/>
18+
<path android:fillAlpha="1" android:fillColor="#EF6122"
19+
android:fillType="nonZero"
20+
android:pathData="M214.277,349.855C214.277,389.52 230.203,425.457 256,451.645C281.797,425.457 297.723,389.52 297.723,349.855C297.723,310.191 281.797,274.25 256,248.066C230.203,274.25 214.277,310.191 214.277,349.855ZM214.277,349.855" android:strokeColor="#00000000"/>
21+
<path android:fillAlpha="1" android:fillColor="#FFFFFF"
22+
android:fillType="nonZero"
23+
android:pathData="M290.207,303.664C279.238,306.313 267.781,307.723 256,307.723C244.219,307.723 232.762,306.313 221.793,303.664C228.891,282.535 240.711,263.59 256,248.066C271.289,263.59 283.109,282.535 290.207,303.664ZM290.207,303.664" android:strokeColor="#00000000"/>
24+
<path android:fillAlpha="1" android:fillColor="#000000"
25+
android:fillType="nonZero"
26+
android:pathData="M403.086,203.59C406.715,190.559 408.664,176.836 408.664,162.664C408.664,132.07 399.645,102.555 382.586,77.301C380.234,73.824 375.512,72.906 372.027,75.258C368.547,77.609 367.633,82.336 369.984,85.816C385.34,108.543 393.453,135.117 393.453,162.664C393.453,175.586 391.66,188.094 388.309,199.961C378.926,198.148 369.242,197.191 359.336,197.191C319.512,197.191 283.207,212.523 256,237.586C228.789,212.523 192.484,197.191 152.664,197.191C142.758,197.191 133.074,198.148 123.688,199.961C120.34,188.094 118.543,175.586 118.543,162.664C118.543,86.871 180.207,25.207 256,25.207C292.715,25.207 327.234,39.504 353.195,65.469C356.164,68.438 360.977,68.438 363.949,65.469C366.918,62.496 366.918,57.684 363.949,54.715C335.113,25.879 296.777,10 256,10C171.82,10 103.336,78.484 103.336,162.664C103.336,176.836 105.285,190.559 108.914,203.59C45.992,222.445 0,280.875 0,349.852C0,434.031 68.484,502.516 152.664,502.516C162.441,502.516 172.223,501.586 181.742,499.75C185.867,498.953 188.566,494.965 187.77,490.844C186.973,486.719 182.984,484.023 178.863,484.816C170.289,486.469 161.477,487.309 152.664,487.309C76.871,487.309 15.207,425.648 15.207,349.852C15.207,287.578 56.84,234.855 113.73,218.023C130.723,261.543 167.133,295.406 212.25,308.93C208.621,321.957 206.672,335.684 206.672,349.852C206.672,388.789 221.332,424.359 245.414,451.355C234.066,461.719 220.871,470.289 206.164,476.508C202.297,478.145 200.488,482.609 202.125,486.477C203.762,490.344 208.223,492.152 212.09,490.516C228.602,483.531 243.395,473.879 256.086,462.199C283.285,487.215 319.555,502.516 359.336,502.516C443.516,502.516 512,434.031 512,349.852C512,280.875 466.008,222.445 403.086,203.59ZM383.301,214.492C367.621,252.867 335.082,282.617 294.934,294.496C288.277,277.445 278.637,261.879 266.66,248.434C291.117,226.063 323.66,212.398 359.336,212.398C367.508,212.398 375.516,213.117 383.301,214.492ZM256,259.32C266,270.719 274.141,283.777 279.965,298.023C272.18,299.398 264.172,300.121 256,300.121C247.828,300.121 239.82,299.398 232.035,298.023C237.859,283.777 246,270.719 256,259.32ZM128.699,214.492C136.484,213.121 144.492,212.398 152.664,212.398C188.34,212.398 220.883,226.066 245.34,248.434C233.363,261.879 223.723,277.445 217.066,294.496C176.918,282.617 144.379,252.863 128.699,214.492ZM227.027,312.559C236.41,314.367 246.094,315.328 256,315.328C265.906,315.328 275.59,314.367 284.973,312.559C288.324,324.422 290.117,336.934 290.117,349.855C290.117,383.961 277.598,415.914 256.074,440.473C234.801,416.262 221.879,384.539 221.879,349.855C221.883,336.934 223.676,324.422 227.027,312.559ZM359.336,487.309C323.711,487.309 291.207,473.684 266.762,451.371C291.137,423.984 305.328,388.137 305.328,349.855C305.328,335.684 303.379,321.961 299.75,308.93C344.867,295.41 381.277,261.543 398.27,218.023C455.16,234.855 496.793,287.578 496.793,349.852C496.793,425.648 435.129,487.309 359.336,487.309ZM359.336,487.309" android:strokeColor="#00000000"/>
27+
</vector>

‎app/src/main/res/drawable/outline_image_24.xml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2-
android:width="24dp"
3-
android:height="24dp"
4-
android:viewportWidth="24.0"
5-
android:viewportHeight="24.0"
6-
android:tint="?attr/colorControlNormal">
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0"
6+
android:tint="#344e5c">
77
<path
88
android:fillColor="@android:color/white"
99
android:pathData="M19,5v14L5,19L5,5h14m0,-2L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14.14,13.86l-3,3.87L9,13.14 6,17h12l-3.86,-5.14z"/>

‎app/src/main/res/font/font.xml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<font
5+
android:fontStyle="normal"
6+
android:fontWeight="400"
7+
android:font="@font/sanfran" />
8+
</font-family>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /