diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e902854..5acc61d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -27,11 +27,20 @@
tools:targetApi="tiramisu"
android:requestLegacyExternalStorage="true"
android:localeConfig="@xml/locales">
-
-
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/app/src/main/java/uk/openvk/android/refresh/api/wrappers/DownloadManager.java b/app/src/main/java/uk/openvk/android/refresh/api/wrappers/DownloadManager.java
index 9a685bc..83ccb8b 100644
--- a/app/src/main/java/uk/openvk/android/refresh/api/wrappers/DownloadManager.java
+++ b/app/src/main/java/uk/openvk/android/refresh/api/wrappers/DownloadManager.java
@@ -488,6 +488,7 @@ private void sendMessage(final int message, String response) {
msg.what = message;
final Bundle bundle = new Bundle();
bundle.putString("response", response);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
handler.post(new Runnable() {
@Override
@@ -507,6 +508,7 @@ private void sendMessage(final int message, String response, int id) {
final Bundle bundle = new Bundle();
bundle.putString("response", response);
bundle.putInt("id", id);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
handler.post(new Runnable() {
@Override
diff --git a/app/src/main/java/uk/openvk/android/refresh/api/wrappers/OvkAPIWrapper.java b/app/src/main/java/uk/openvk/android/refresh/api/wrappers/OvkAPIWrapper.java
index 8ba5be2..01a46da 100644
--- a/app/src/main/java/uk/openvk/android/refresh/api/wrappers/OvkAPIWrapper.java
+++ b/app/src/main/java/uk/openvk/android/refresh/api/wrappers/OvkAPIWrapper.java
@@ -62,7 +62,7 @@ public class OvkAPIWrapper {
private OkHttpClient httpClient = null;
private boolean logging_enabled = true; // default for beta releases
- private String client_name = "openvk_legacy_android";
+ private String client_name = "openvk_refresh_android";
public Handler handler;
OvkAPIListeners apiListeners;
@@ -786,7 +786,7 @@ public void run() {
error.description = e.getMessage();
sendMessage(HandlerMessages.NO_INTERNET_CONNECTION, method, error.description);
} catch (SocketException e) {
- if(e.getMessage().contains("ETIMEDOUT")) {
+ if(Objects.requireNonNull(e.getMessage()).contains("ETIMEDOUT")) {
if(logging_enabled) Log.e(OvkApplication.API_TAG,
String.format("Connection error: %s", e.getMessage()));
error.description = e.getMessage();
@@ -863,8 +863,8 @@ private void sendMessage(final int message, String response) {
msg.what = message;
final Bundle bundle = new Bundle();
bundle.putString("response", response);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
-
handler.post(new Runnable() {
@Override
public void run() {
@@ -887,6 +887,7 @@ private void sendMessage(final int message, String method, String response) {
final Bundle bundle = new Bundle();
bundle.putString("response", response);
bundle.putString("method", method);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
handler.post(new Runnable() {
@Override
@@ -916,6 +917,7 @@ private void sendMessage(final int message, String method, String args, String r
bundle.putString("response", response);
bundle.putString("method", method);
bundle.putString("args", args);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
handler.post(new Runnable() {
@Override
@@ -941,6 +943,7 @@ private void sendMessage(final int message, String method, String args, String w
bundle.putString("method", method);
bundle.putString("args", args);
bundle.putString("where", where);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
handler.post(new Runnable() {
@Override
diff --git a/app/src/main/java/uk/openvk/android/refresh/api/wrappers/UploadManager.java b/app/src/main/java/uk/openvk/android/refresh/api/wrappers/UploadManager.java
index 37d1574..4941ec8 100644
--- a/app/src/main/java/uk/openvk/android/refresh/api/wrappers/UploadManager.java
+++ b/app/src/main/java/uk/openvk/android/refresh/api/wrappers/UploadManager.java
@@ -278,6 +278,7 @@ private void sendMessage(final int message, String filename, String response) {
final Bundle bundle = new Bundle();
bundle.putString("filename", filename);
bundle.putString("response", response);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
handler.post(new Runnable() {
@Override
@@ -300,6 +301,7 @@ public void updateLoadProgress(String filename, String url, final long position,
bundle.putString("url", url);
bundle.putLong("position", position);
bundle.putLong("length", length);
+ bundle.putString("address", apiListeners.from);
msg.setData(bundle);
handler.post(new Runnable() {
@Override
diff --git a/app/src/main/java/uk/openvk/android/refresh/receivers/OvkAPIReceiver.java b/app/src/main/java/uk/openvk/android/refresh/receivers/OvkAPIReceiver.java
index c60ceb8..8915b9f 100644
--- a/app/src/main/java/uk/openvk/android/refresh/receivers/OvkAPIReceiver.java
+++ b/app/src/main/java/uk/openvk/android/refresh/receivers/OvkAPIReceiver.java
@@ -46,16 +46,16 @@ public void onReceive(Context context, Intent intent) {
if(activity instanceof final NetworkActivity netActivity) {
OpenVKAPI ovk_api = netActivity.ovk_api;
final Bundle data = intent.getExtras();
- final Message msg = parseJSONData(ovk_api.wrapper, netActivity.handler, data);
- ovk_api.wrapper.handler.post(new Runnable() {
- @Override
- public void run() {
+ if(data.getString("address").equals(activity.getLocalClassName())) {
+ final Message msg = parseJSONData(ovk_api.wrapper, netActivity.handler, data);
+ ovk_api.wrapper.handler.post(() -> {
Log.d(OvkApplication.API_TAG,
- String.format("Handling message %s in %s", msg.what, activity.getLocalClassName())
+ String.format("Handling message %s in %s (%s)", msg.what, activity.getLocalClassName(),
+ data.getString("address"))
);
netActivity.receiveState(msg.what, data);
- }
- });
+ });
+ }
}
}
diff --git a/app/src/main/java/uk/openvk/android/refresh/ui/core/activities/base/NetworkActivity.java b/app/src/main/java/uk/openvk/android/refresh/ui/core/activities/base/NetworkActivity.java
index 2eff3a4..94e235b 100644
--- a/app/src/main/java/uk/openvk/android/refresh/ui/core/activities/base/NetworkActivity.java
+++ b/app/src/main/java/uk/openvk/android/refresh/ui/core/activities/base/NetworkActivity.java
@@ -47,65 +47,53 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
public void registerAPIDataReceiver() {
receiver = new OvkAPIReceiver(this);
LocalBroadcastManager.getInstance(this).registerReceiver(receiver, new IntentFilter(
- "uk.openvk.android.legacy.API_DATA_RECEIVE"));
+ "uk.openvk.android.refresh.API_DATA_RECEIVE"));
}
private void setAPIListeners(final OvkAPIListeners listeners) {
listeners.from = getLocalClassName();
- listeners.successListener = new OvkAPIListeners.OnAPISuccessListener() {
- @Override
- public void onAPISuccess(final Context ctx, int msg_code, final Bundle data) {
- if(!BuildConfig.BUILD_TYPE.equals("release"))
- Log.d(OvkApplication.APP_TAG,
- String.format(
- "Handling API message %s in %s",
- msg_code,
- getLocalClassName()
- )
- );
- if(msg_code == HandlerMessages.PARSE_JSON) {
- new Thread(new Runnable() {
- @Override
- public void run() {
- Intent intent = new Intent();
- intent.setAction("uk.openvk.android.legacy.API_DATA_RECEIVE");
- data.putString("address", listeners.from);
- intent.putExtras(data);
- LocalBroadcastManager.getInstance(ctx).sendBroadcast(intent);
- }
- }).start();
- } else {
- receiveState(msg_code, data);
- }
- }
- };
- listeners.failListener = new OvkAPIListeners.OnAPIFailListener() {
- @Override
- public void onAPIFailed(Context ctx, int msg_code, final Bundle data) {
- if(!BuildConfig.BUILD_TYPE.equals("release"))
- Log.d(OvkApplication.APP_TAG,
- String.format(
- "Handling API message %s in %s",
- msg_code,
- getLocalClassName()
- )
- );
+ listeners.successListener = (ctx, msg_code, data) -> {
+ if(!BuildConfig.BUILD_TYPE.equals("release"))
+ Log.d(OvkApplication.APP_TAG,
+ String.format(
+ "Handling API message %s in %s (%s)",
+ msg_code,
+ getLocalClassName(),
+ data.getString("address")
+ )
+ );
+ if(msg_code == HandlerMessages.PARSE_JSON) {
+ new Thread(() -> {
+ Intent intent = new Intent();
+ intent.setAction("uk.openvk.android.refresh.API_DATA_RECEIVE");
+ intent.putExtras(data);
+ LocalBroadcastManager.getInstance(ctx).sendBroadcast(intent);
+ }).start();
+ } else {
receiveState(msg_code, data);
}
};
- listeners.processListener = new OvkAPIListeners.OnAPIProcessListener() {
- @Override
- public void onAPIProcess(Context ctx, Bundle data, long value, long length) {
- if(!BuildConfig.BUILD_TYPE.equals("release"))
- Log.d(OvkApplication.APP_TAG,
- String.format(
- "Handling API message %s in %s",
- HandlerMessages.UPLOAD_PROGRESS,
- getLocalClassName()
- )
- );
- receiveState(HandlerMessages.UPLOAD_PROGRESS, data);
- }
+ listeners.failListener = (ctx, msg_code, data) -> {
+ if(!BuildConfig.BUILD_TYPE.equals("release"))
+ Log.d(OvkApplication.APP_TAG,
+ String.format(
+ "Handling API message %s in %s",
+ msg_code,
+ getLocalClassName()
+ )
+ );
+ receiveState(msg_code, data);
+ };
+ listeners.processListener = (ctx, data, value, length) -> {
+ if(!BuildConfig.BUILD_TYPE.equals("release"))
+ Log.d(OvkApplication.APP_TAG,
+ String.format(
+ "Handling API message %s in %s",
+ HandlerMessages.UPLOAD_PROGRESS,
+ getLocalClassName()
+ )
+ );
+ receiveState(HandlerMessages.UPLOAD_PROGRESS, data);
};
ovk_api.wrapper.setAPIListeners(listeners);
ovk_api.dlman.setAPIListeners(listeners);
diff --git a/app/src/main/java/uk/openvk/android/refresh/ui/list/adapters/MessagesAdapter.java b/app/src/main/java/uk/openvk/android/refresh/ui/list/adapters/MessagesAdapter.java
index 2d3f7cf..3860876 100644
--- a/app/src/main/java/uk/openvk/android/refresh/ui/list/adapters/MessagesAdapter.java
+++ b/app/src/main/java/uk/openvk/android/refresh/ui/list/adapters/MessagesAdapter.java
@@ -3,7 +3,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.text.method.LinkMovementMethod;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -24,7 +23,6 @@
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.RecyclerView;
import uk.openvk.android.refresh.Global;
-import uk.openvk.android.refresh.OvkApplication;
import uk.openvk.android.refresh.R;
import uk.openvk.android.refresh.api.entities.Message;
import uk.openvk.android.refresh.ui.util.glide.GlideApp;
@@ -68,7 +66,6 @@ public class Holder extends RecyclerView.ViewHolder {
private final TextView msg_text;
private final TextView msg_text_2;
private final TextView msg_timestamp;
- private final TextView msg_timestamp_2;
private final LinearLayout horizontal_layout;
private final LinearLayout vertical_layout;
@@ -80,7 +77,6 @@ public Holder(View view) {
this.msg_text = (TextView) view.findViewById(R.id.msg_text);
this.msg_timestamp = (TextView) view.findViewById(R.id.timestamp);
this.msg_text_2 = (TextView) view.findViewById(R.id.msg_text_2);
- this.msg_timestamp_2 = (TextView) view.findViewById(R.id.timestamp_vertical);
}
@SuppressLint({"SimpleDateFormat", "UseCompatLoadingForDrawables"})
@@ -177,13 +173,6 @@ private Message getItem(int position) {
if (position >= 0) {
return items.get(position);
} else {
- Log.e(OvkApplication.APP_TAG,
- String.format(
- "[NewsfeedAdapter] Invalid position %s of %s",
- position,
- items.size()
- )
- );
return null;
}
} catch (Exception ex) {