ssfs update
added profile hide
This commit is contained in:
@@ -11,6 +11,7 @@ import android.os.Build;
|
||||
|
||||
import ru.vtosters.lite.concurrent.VTExecutors;
|
||||
import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
|
||||
import ru.vtosters.lite.ssfs.UsersList;
|
||||
import ru.vtosters.lite.ui.dialogs.DisableBattery;
|
||||
import ru.vtosters.lite.ui.dialogs.InstallGMS;
|
||||
import ru.vtosters.lite.ui.dialogs.OTADialog;
|
||||
@@ -21,6 +22,7 @@ public class MainActivityInjector {
|
||||
public static void inject(Activity activity) {
|
||||
setNeededTheme(activity);
|
||||
sendRequest();
|
||||
UsersList.getUsersList();
|
||||
if (checkupdates()) OTADialog.checkUpdates(activity);
|
||||
VTExecutors.getIoScheduler().a(DeletedMessagesHandler::reloadMessagesList); // ioScheduler
|
||||
Start.alert(activity);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package ru.vtosters.lite.ssfs;
|
||||
|
||||
import okhttp3.Request;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Handler {
|
||||
public static String getBanner(int id) {
|
||||
Request request = new Request.a()
|
||||
.b("https://ssfs.vtosters.app/api/getChatBanner" + "?user_id=" + id)
|
||||
.a();
|
||||
|
||||
try {
|
||||
return new JSONObject(VtOkHttpClient.getInstance().a(request).execute().a().g()).getJSONObject("response").getString("text");
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDescription(int id) {
|
||||
Request request = new Request.a()
|
||||
.b("https://ssfs.vtosters.app/api/getServiceDescription" + "?user_id=" + id)
|
||||
.a();
|
||||
|
||||
try {
|
||||
return new JSONObject(VtOkHttpClient.getInstance().a(request).execute().a().g()).getString("response");
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package ru.vtosters.lite.ssfs;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.vk.profile.presenter.UserPresenter;
|
||||
import com.vtosters.lite.api.ExtendedUserProfile;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserID;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class ProfileHider {
|
||||
public static boolean isService(Integer id) {
|
||||
return UsersList.hasDescription(id) || id == 100 || id == 101 || id == 333;
|
||||
}
|
||||
|
||||
public static void fetchInfo(ExtendedUserProfile extendedUserProfile, JSONObject jsonObject) {
|
||||
int userID = getUserID(extendedUserProfile);
|
||||
|
||||
if (UsersList.hasDescription(userID)) {
|
||||
try {
|
||||
extendedUserProfile.z2 = Handler.getDescription(userID);
|
||||
} catch (NullPointerException e) {
|
||||
Log.e("ProfileHide", "null \"profiles\" node\n" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getInfo(ExtendedUserProfile extendedUserProfile) {
|
||||
int userID = getUserID(extendedUserProfile);
|
||||
if (UsersList.hasDescription(userID) && !TextUtils.isEmpty(extendedUserProfile.z2))
|
||||
return extendedUserProfile.z2;
|
||||
return getGlobalContext().getString(UserPresenter.q0.a(userID));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package ru.vtosters.lite.ssfs;
|
||||
|
||||
import android.util.Log;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.NetworkUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class UsersList {
|
||||
private static final String TAG = "UsersList";
|
||||
private static final List<Integer> descriptionsList = new ArrayList<>();
|
||||
private static final List<Integer> bannersList = new ArrayList<>();
|
||||
|
||||
public static void getUsersList() {
|
||||
var prefs = AndroidUtils.getGlobalContext().getSharedPreferences("vt_another_data", 0);
|
||||
|
||||
if ((!NetworkUtils.isNetworkConnected() || getBoolValue("isRoamingState", false)) && prefs.contains("ids")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Request request = new Request.a()
|
||||
.b("https://ssfs.vtosters.app/api/getUsersWithServiceDescriptionsAndBanners")
|
||||
.a();
|
||||
|
||||
VtOkHttpClient.getInstance().a(request).a(new Callback() {
|
||||
@Override
|
||||
public void a(Call call, IOException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Call call, Response response) {
|
||||
try {
|
||||
parseJson(new JSONObject(response.a().g()).getJSONObject("response"));
|
||||
} catch (JSONException | IOException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean hasDescription(int id) {
|
||||
return descriptionsList.contains(id);
|
||||
}
|
||||
|
||||
public static boolean hasBanner(int id) {
|
||||
return bannersList.contains(id);
|
||||
}
|
||||
|
||||
static void parseJson(JSONObject json) throws JSONException {
|
||||
var idsDescription = json.getJSONArray("with_service_descriptions");
|
||||
var idsBanner = json.getJSONArray("with_chat_banners");
|
||||
|
||||
Log.d("ProfileHider", idsDescription.toString());
|
||||
|
||||
processIds(idsBanner, bannersList);
|
||||
processIds(idsDescription, descriptionsList);
|
||||
}
|
||||
|
||||
static void processIds(JSONArray jsonIds, List<Integer> member) {
|
||||
for (int i = 0; i < jsonIds.length(); i++)
|
||||
member.add(jsonIds.optInt(i));
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.vk.profile.presenter.UserPresenter;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.api.ExtendedUserProfile;
|
||||
import com.vtosters.lite.fragments.messages.chat.vc.MsgSendVc;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserID;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class ProfileHider {
|
||||
private static final OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
public static void injectMap(HashMap<Integer, UserPresenter.a.a> hashMap) {
|
||||
if (VTVerifications.isServiceAccount(getUserId())) {
|
||||
hashMap.put(100, new UserPresenter.a.a(R.string.service_account_admin_100_info, R.color.service_account_admin_100, R.drawable.ic_custom_avatar_id100));
|
||||
hashMap.put(101, new UserPresenter.a.a(R.string.service_account_admin_101_info, R.color.service_account_admin_101, R.drawable.ic_custom_avatar_id101));
|
||||
hashMap.put(333, new UserPresenter.a.a(R.string.service_account_mobile_info, R.color.service_account_admin_333, R.drawable.ic_custom_avatar_id333)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static void fetchInfo(ExtendedUserProfile extendedUserProfile) {
|
||||
int userID = getUserID(extendedUserProfile.a);
|
||||
if (VTVerifications.isServiceAccount(userID)) {
|
||||
Request request = new Request.a()
|
||||
.b("https://sf.vknext.net/block_text?user_id=" + userID)
|
||||
.a();
|
||||
try {
|
||||
JSONObject payload = new JSONObject(client.a(request)
|
||||
.execute()
|
||||
.c()
|
||||
.a()
|
||||
.g());
|
||||
String response = payload.optJSONObject(MsgSendVc.d0).optString("response");
|
||||
if (!TextUtils.isEmpty(response))
|
||||
extendedUserProfile.z2 = response;
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NullPointerException e) {
|
||||
Log.e("ProfileHide", "null \"profiles\" node\n" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getInfo(ExtendedUserProfile extendedUserProfile) {
|
||||
int userID = getUserID(extendedUserProfile);
|
||||
if (VTVerifications.isServiceAccount(userID) && !TextUtils.isEmpty(extendedUserProfile.z2))
|
||||
return extendedUserProfile.z2;
|
||||
return getGlobalContext().getString(UserPresenter.q0.a(userID));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
.method public constructor <init>(Landroid/content/Context;Lcom/vtosters/lite/api/ExtendedUserProfile;Z)V
|
||||
.locals 2
|
||||
|
||||
invoke-static {p2}, Lru/vtosters/lite/utils/ProfileHider;->getInfo(Lcom/vtosters/lite/api/ExtendedUserProfile;)Ljava/lang/String;
|
||||
invoke-static {p2}, Lru/vtosters/lite/ssfs/ProfileHider;->getInfo(Lcom/vtosters/lite/api/ExtendedUserProfile;)Ljava/lang/String;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
|
||||
move-result-object p1
|
||||
|
||||
const-string p2, "LinkParser.parseWiki(Lin\u2026account_admin_100_info)))"
|
||||
|
||||
invoke-static {p1, p2}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
|
||||
|
||||
const/4 p2, 0x0
|
||||
|
||||
const/4 v0, 0x2
|
||||
|
||||
@@ -101,16 +101,11 @@
|
||||
.method public final b(I)Z
|
||||
.locals 1
|
||||
|
||||
.line 1
|
||||
invoke-virtual {p0}, Lcom/vk/profile/presenter/UserPresenter$a;->a()Ljava/util/HashMap;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
invoke-interface {v0, p1}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z
|
||||
invoke-static {p1}, Lru/vtosters/lite/ssfs/ProfileHider;->isService(Ljava/lang/Integer;)Z
|
||||
|
||||
move-result p1
|
||||
|
||||
|
||||
@@ -143,8 +143,6 @@
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/utils/ProfileHider;->injectMap(Ljava/util/HashMap;)V
|
||||
|
||||
sput-object v0, Lcom/vk/profile/presenter/UserPresenter;->p0:Ljava/util/HashMap;
|
||||
|
||||
return-void
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
|
||||
iput v4, v2, Lcom/vk/dto/user/UserProfile;->b:I
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/utils/ProfileHider;->fetchInfo(Lcom/vtosters/lite/api/ExtendedUserProfile;)V
|
||||
invoke-static {v0, v1}, Lru/vtosters/lite/ssfs/ProfileHider;->fetchInfo(Lcom/vtosters/lite/api/ExtendedUserProfile;Lorg/json/JSONObject;)V
|
||||
|
||||
.line 3
|
||||
iget-object v2, v0, Lcom/vtosters/lite/api/ExtendedUserProfile;->a:Lcom/vk/dto/user/UserProfile;
|
||||
|
||||
Reference in New Issue
Block a user