Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 18 additions & 13 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:recyclerview-v7:24.2.1'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.android.support:design:24.2.1'
implementation 'com.android.support:support-v4:24.2.1'
implementation 'com.android.support:recyclerview-v7:24.2.1'
testImplementation 'junit:junit:4.12'
}
37 changes: 37 additions & 0 deletions app/src/main/java/com/zv/geochat/ChatActivityFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class ChatActivityFragment extends Fragment {
private static final String TAG = "ChatActivityFragment";
EditText edtMessage;
String userName = "user1";
public static final int x = 13;

public ChatActivityFragment() {
}

Expand Down Expand Up @@ -56,6 +58,17 @@ public void onClick(View view) {
}
});

Button btnsendConnectionError = (Button) v.findViewById(R.id.btnsendConnectionError);
btnsendConnectionError.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "CONNECT_ERROR_"+x, Snackbar.LENGTH_LONG)
.setAction("Action", null).show();

connectionOnError();
}
});

Button btnReceiveMessage = (Button) v.findViewById(R.id.btnReceiveMessage);
btnReceiveMessage.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -65,6 +78,13 @@ public void onClick(View view) {
simulateOnMessage();
}
});
Button btnsendRandomId = (Button) v.findViewById(R.id.btnsendRandomId);
btnsendRandomId.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sendRandomID();
}
});

edtMessage = (EditText) v.findViewById(R.id.edtMessage);

Expand Down Expand Up @@ -112,4 +132,21 @@ private void simulateOnMessage(){
getActivity().startService(intent);
}

private void connectionOnError(){
Bundle data = new Bundle();
data.putInt(ChatService.MSG_CMD, ChatService.Connect_Error);
Intent intent = new Intent(getContext(), ChatService.class);
intent.putExtras(data);
getActivity().startService(intent);
}

private void sendRandomID(){
Bundle data = new Bundle();
data.putInt(ChatService.MSG_CMD, ChatService.Random_UID);
data.putString("RANDOM_UID" , String.valueOf(System.currentTimeMillis()));
Intent intent = new Intent(getContext(), ChatService.class);
intent.putExtras(data);
getActivity().startService(intent);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@ public void displaySimpleNotification(String title, String contentText) {
try {


Notification noti = new Notification.Builder(context)
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setContentTitle(title)
.setContentText(contentText)
.setContentIntent(contentIntent)
.setAutoCancel(true)
.build();

noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationMgr.notify(0, noti);
} catch (IllegalArgumentException e) {
Log.e(TAG, e.getMessage());
}
}
public void displaySimpleNotification(String title, String contentText, String RANDOM_UID) {
Intent intent = new Intent(context, ChatActivity.class);
intent.putExtra("RANDOM_UID", RANDOM_UID);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);

// notification message
try {


Notification noti = new Notification.Builder(context)
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setContentTitle(title)
Expand Down
Loading