ssfs update
added support for im banners
This commit is contained in:
@@ -152,61 +152,6 @@ public class JsonInjectors {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject convBar(JSONObject orig) {
|
||||
var peerid = Objects.requireNonNull(orig.optJSONObject("peer")).optInt("id");
|
||||
|
||||
var pic = "https://image.pngaaa.com/641/326641-middle.png"; // can be null
|
||||
var text = AndroidUtils.getString(R.string.no_data_error);
|
||||
var link = "https://vtosters.app"; // can be null
|
||||
var linktitle = "Test button"; // can be null
|
||||
|
||||
var hasIcon = !pic.isEmpty();
|
||||
var hasButton = !link.isEmpty();
|
||||
|
||||
var isPicture = pic.endsWith(".png") || pic.endsWith(".jpg") || pic.endsWith(".jpeg") || pic.endsWith(".webp");
|
||||
|
||||
if (isVerified(peerid))
|
||||
text = AndroidUtils.getString(R.string.i_bought) + " VTosters Premium";
|
||||
if (isPrometheus(peerid))
|
||||
text = AndroidUtils.getString(R.string.i_bought) + " VTosters Premium Gold Prime Pro Plus";
|
||||
if (isDeveloper(peerid)) text = AndroidUtils.getString(R.string.i_created_poop);
|
||||
|
||||
if (!isVerified(peerid) || text.equals("") || peerid == AccountManagerUtils.getUserId() || peerid == 0) {
|
||||
if (getBoolValue("convBarRecomm", false)) {
|
||||
return null;
|
||||
} else {
|
||||
return orig.optJSONObject("conversation_bar");
|
||||
}
|
||||
}
|
||||
|
||||
if (!dev()) return orig.optJSONObject("conversation_bar"); // for devs only
|
||||
|
||||
try {
|
||||
var json = new JSONObject();
|
||||
|
||||
var buttonsJson = new JSONObject();
|
||||
buttonsJson.put("layout", "tertiary");
|
||||
buttonsJson.put("text", linktitle);
|
||||
buttonsJson.put("type", "link");
|
||||
buttonsJson.put("link", link);
|
||||
|
||||
var buttonsjson = new JSONArray(); // max 3 buttons in array
|
||||
if (hasButton) buttonsjson.put(buttonsJson);
|
||||
|
||||
json.put("name", "group_admin_welcome");
|
||||
json.put("text", text);
|
||||
json.put("buttons", buttonsjson);
|
||||
if (hasIcon && isPicture) {
|
||||
json.put("icon", pic);
|
||||
}
|
||||
return json;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static JSONObject menu(JSONObject orig) throws JSONException {
|
||||
var Special = orig.optJSONArray("special");
|
||||
var Main = orig.getJSONArray("main");
|
||||
|
||||
@@ -8,13 +8,13 @@ import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Handler {
|
||||
public static String getBanner(int id) {
|
||||
public static JSONObject 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");
|
||||
return new JSONObject(VtOkHttpClient.getInstance().a(request).execute().a().g()).getJSONObject("response");
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package ru.vtosters.lite.ssfs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.*;
|
||||
import static ru.vtosters.lite.utils.VTVerifications.isVerified;
|
||||
|
||||
public class ImBanner {
|
||||
public static JSONObject convBar(JSONObject orig) {
|
||||
var peerid = Objects.requireNonNull(orig.optJSONObject("peer")).optInt("id");
|
||||
|
||||
if (!UsersList.hasBanner(peerid) || peerid == 0) {
|
||||
if (getBoolValue("convBarRecomm", false)) {
|
||||
return null;
|
||||
} else {
|
||||
return orig.optJSONObject("conversation_bar");
|
||||
}
|
||||
}
|
||||
|
||||
// var pic = "https://image.pngaaa.com/641/326641-middle.png"; // can be null
|
||||
// var text = AndroidUtils.getString(com.vtosters.lite.R.string.no_data_error);
|
||||
// var link = "https://vtosters.app"; // can be null
|
||||
// var linktitle = "Test button"; // can be null
|
||||
//
|
||||
// var hasIcon = !pic.isEmpty();
|
||||
// var hasButton = !link.isEmpty();
|
||||
// var isPicture = pic.endsWith(".png") || pic.endsWith(".jpg") || pic.endsWith(".jpeg") || pic.endsWith(".webp");
|
||||
//
|
||||
// if (isVerified(peerid))
|
||||
// text = AndroidUtils.getString(com.vtosters.lite.R.string.i_bought) + " VTosters Premium";
|
||||
// if (isPrometheus(peerid))
|
||||
// text = AndroidUtils.getString(com.vtosters.lite.R.string.i_bought) + " VTosters Premium Gold Prime Pro Plus";
|
||||
// if (isDeveloper(peerid)) text = AndroidUtils.getString(com.vtosters.lite.R.string.i_created_poop);
|
||||
//
|
||||
// if (!isVerified(peerid) || text.equals("") || peerid == AccountManagerUtils.getUserId() || peerid == 0) {
|
||||
// if (getBoolValue("convBarRecomm", false)) {
|
||||
// return null;
|
||||
// } else {
|
||||
// return orig.optJSONObject("conversation_bar");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!dev()) return orig.optJSONObject("conversation_bar"); // for devs only
|
||||
|
||||
try {
|
||||
var jsonBanner = Handler.getBanner(peerid);
|
||||
var pic = jsonBanner.optString("picture");
|
||||
var text = jsonBanner.optString("text");
|
||||
var link = jsonBanner.optString("link");
|
||||
var linktitle = jsonBanner.optString("link_text");
|
||||
|
||||
var hasIcon = !pic.isEmpty();
|
||||
var hasButton = !link.isEmpty();
|
||||
|
||||
var isPicture = pic.endsWith(".png") || pic.endsWith(".jpg") || pic.endsWith(".jpeg") || pic.endsWith(".webp");
|
||||
|
||||
var json = new JSONObject();
|
||||
|
||||
var buttonsJson = new JSONObject();
|
||||
buttonsJson.put("layout", "tertiary");
|
||||
buttonsJson.put("text", linktitle);
|
||||
buttonsJson.put("type", "link");
|
||||
buttonsJson.put("link", link);
|
||||
|
||||
var buttonsjson = new JSONArray(); // max 3 buttons in array
|
||||
if (hasButton) buttonsjson.put(buttonsJson);
|
||||
|
||||
json.put("name", "group_admin_welcome");
|
||||
json.put("text", text);
|
||||
json.put("buttons", buttonsjson);
|
||||
if (hasIcon && isPicture) {
|
||||
json.put("icon", pic);
|
||||
}
|
||||
return json;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean showAlert() {
|
||||
var context = LifecycleUtils.getCurrentActivity();
|
||||
var bool = Preferences.getBoolValue("linkalert", false);
|
||||
|
||||
if (!bool) {
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle("Внимание!")
|
||||
.setMessage("Разработчики клиента не несут никакой ответственности за пользовательские ссылки. Будьте внимательны!")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("Продолжить", (dialogInterface, i) -> {
|
||||
Preferences.preferences.edit().putBoolean("linkalert", true).commit();
|
||||
})
|
||||
.setNeutralButton("Отмена", (dialogInterface, i) -> {
|
||||
dialogInterface.cancel();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
return bool;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.NetworkUtils;
|
||||
|
||||
@@ -52,11 +53,11 @@ public class UsersList {
|
||||
}
|
||||
|
||||
public static boolean hasDescription(int id) {
|
||||
return descriptionsList.contains(id);
|
||||
return descriptionsList.contains(id) && id != AccountManagerUtils.getUserId();
|
||||
}
|
||||
|
||||
public static boolean hasBanner(int id) {
|
||||
return bannersList.contains(id);
|
||||
return bannersList.contains(id) && id != AccountManagerUtils.getUserId();
|
||||
}
|
||||
|
||||
static void parseJson(JSONObject json) throws JSONException {
|
||||
|
||||
+1
-1
@@ -622,7 +622,7 @@
|
||||
|
||||
move-result-object v4
|
||||
|
||||
invoke-static {v1}, Lru/vtosters/lite/hooks/JsonInjectors;->convBar(Lorg/json/JSONObject;)Lorg/json/JSONObject;
|
||||
invoke-static {v1}, Lru/vtosters/lite/ssfs/ImBanner;->convBar(Lorg/json/JSONObject;)Lorg/json/JSONObject;
|
||||
|
||||
move-result-object v6
|
||||
|
||||
|
||||
+10
-1
@@ -16,8 +16,17 @@
|
||||
|
||||
# direct methods
|
||||
.method public static synthetic a(Lcom/vk/im/ui/components/viewcontrollers/dialog_bar/DialogBarVcCallback;Ljava/lang/String;Lcom/vk/im/engine/models/dialogs/ConversationBar$ButtonType;ILjava/lang/Object;)V
|
||||
.locals 0
|
||||
.locals 1
|
||||
|
||||
invoke-static {}, Lru/vtosters/lite/ssfs/ImBanner;->showAlert()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_228
|
||||
|
||||
return-void
|
||||
|
||||
:cond_228
|
||||
if-nez p4, :cond_1
|
||||
|
||||
and-int/lit8 p3, p3, 0x2
|
||||
|
||||
Reference in New Issue
Block a user