Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
True RAW json printed
Browse files Browse the repository at this point in the history
  • Loading branch information
rus-ai committed Oct 17, 2020
1 parent 5fe6754 commit 643690f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "ru.wtw.moreliatalkclient"
minSdkVersion 14
targetSdkVersion 30
versionCode 9
versionName "0.1.3.6"
versionCode 10
versionName "0.1.3.7"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/ru/wtw/moreliatalkclient/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ public void onOpen(ServerHandshake handshakedata) {

@Override
public void onMessage(String message) {
if (showJSON) {
outChat("", "Received: " + message, "");
}
String cleanmessage = message.replaceAll("\\\\n", "").replaceAll("\\\\", "");
cleanmessage = cleanmessage.startsWith("\"") ? cleanmessage.substring(1) : cleanmessage;
cleanmessage = cleanmessage.endsWith("\"") ? cleanmessage.substring(0, cleanmessage.length() - 1) : cleanmessage;
if (showJSON) {
outChat("", "Received: " + cleanmessage, "");
}
Protocol protocol = new Gson().fromJson(cleanmessage, Protocol.class);
String reply = "";
if (protocol.getType().equals("register_user")) {
Expand All @@ -150,6 +150,13 @@ public void onMessage(String message) {
if (protocol.getErrors().getCode() == 409)
reply = activity.getResources().getString(R.string.auth_status_exist);
}
if (protocol.getType().equals("auth")) {
if (protocol.getErrors().getCode() == 200) {
uuid = protocol.getData().getUser()[0].getUuid();
auth_id = protocol.getData().getUser()[0].getAuth_id();
reply = activity.getResources().getString(R.string.auth_status_ok);
}
}
if (!showJSON) {
outChat("", reply, "");
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
<string name="safe_scrolling">Безопасная прокрутка</string>
<string name="safe_scroll_on">Прокручивать только из нижней позиции</string>
<string name="safe_scroll_off">Прокручивать всегда</string>
<string name="auth_status_ok">Auth success</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@

<!-- Design Preferences -->
<string name="themes_messages">Themes of messages ballons</string>
<string name="auth_status_ok">Auth success</string>
</resources>

0 comments on commit 643690f

Please sign in to comment.