refactored ssfs utils
This commit is contained in:
@@ -13,7 +13,7 @@ public class Handler {
|
||||
|
||||
public static JSONObject getBanner(int id) {
|
||||
Request request = new Request.a()
|
||||
.b("https://ssfs.vtosters.app/api/getChatBanner" + "?user_id=" + id)
|
||||
.b(Utils.getDomain() + "/api/getChatBanner" + "?user_id=" + id)
|
||||
.a();
|
||||
|
||||
try {
|
||||
@@ -26,7 +26,7 @@ public class Handler {
|
||||
|
||||
public static String getDescription(int id) {
|
||||
Request request = new Request.a()
|
||||
.b("https://ssfs.vtosters.app/api/getServiceDescription" + "?user_id=" + id)
|
||||
.b(Utils.getDomain() + "/api/getServiceDescription" + "?user_id=" + id)
|
||||
.a();
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.vtosters.lite.ssfs;
|
||||
|
||||
import android.util.Log;
|
||||
import com.vk.core.util.LangUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -13,6 +14,8 @@ import java.util.HashMap;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getStatic;
|
||||
|
||||
public class ProfileButtons {
|
||||
private static final String TAG = "ProfileButtons";
|
||||
|
||||
public static JSONObject profileButton(JSONObject orig) {
|
||||
try {
|
||||
int id = orig.getInt("id");
|
||||
@@ -55,7 +58,7 @@ public class ProfileButtons {
|
||||
|
||||
orig.put("buttons", newItem);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, e.getMessage());
|
||||
}
|
||||
|
||||
return orig;
|
||||
@@ -87,7 +90,7 @@ public class ProfileButtons {
|
||||
|
||||
return json;
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class UsersList {
|
||||
@@ -32,7 +33,7 @@ public class UsersList {
|
||||
}
|
||||
|
||||
Request request = new Request.a()
|
||||
.b("https://ssfs.vtosters.app/api/getUsersWithServiceDescriptionsAndBanners")
|
||||
.b(Utils.getDomain() + "/api/getUsersWithServiceDescriptionsAndBanners")
|
||||
.a();
|
||||
|
||||
VtOkHttpClient.getInstance().a(request).a(new Callback() {
|
||||
@@ -64,6 +65,11 @@ public class UsersList {
|
||||
var idsDescription = json.getJSONArray("with_service_descriptions");
|
||||
var idsBanner = json.getJSONArray("with_chat_banners");
|
||||
|
||||
if (dev()) {
|
||||
Log.d(TAG, idsDescription.toString());
|
||||
Log.d(TAG, idsBanner.toString());
|
||||
}
|
||||
|
||||
processIds(idsBanner, bannersList);
|
||||
processIds(idsDescription, descriptionsList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package ru.vtosters.lite.ssfs;
|
||||
|
||||
import com.vk.core.network.Network;
|
||||
import ru.vtosters.lite.hooks.DateHook;
|
||||
import ru.vtosters.lite.proxy.ProxyUtils;
|
||||
import ru.vtosters.lite.utils.*;
|
||||
|
||||
public class Utils {
|
||||
public static String getVKUILink() {
|
||||
return getDomain() +
|
||||
"?token=" + AccountManagerUtils.getUserToken() +
|
||||
"&vt_dark=" + (ThemesUtils.isDarkTheme() ? "1" : "0") +
|
||||
"&vt_amoled=" + (ThemesUtils.isAmoledTheme() && ThemesUtils.isDarkTheme() ? "1" : "0") +
|
||||
"&secret=" + AccountManagerUtils.getUserSecret() +
|
||||
"&proxy=" + (ProxyUtils.isAnyProxyEnabled() ? "1" : "0") +
|
||||
"&lang=" + DateHook.getLocale() +
|
||||
"&vt=1" +
|
||||
"&useragent=" + Base64Utils.encodeValue(Base64Utils.encode(Network.l.c().a())) +
|
||||
"&vt_debug=" + (Preferences.dev() ? "1" : "0");
|
||||
}
|
||||
|
||||
public static String getDomain() {
|
||||
String string = AndroidUtils.getPrefsValue("ssfscustom");
|
||||
|
||||
if (!string.isEmpty()) return string;
|
||||
|
||||
return "https://ssfs.vtosters.app";
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import com.vtosters.lite.general.fragments.SettingsGeneralFragment;
|
||||
import com.vtosters.lite.ui.MaterialSwitchPreference;
|
||||
import ru.vtosters.lite.concurrent.VTExecutors;
|
||||
import ru.vtosters.lite.hooks.ui.SystemThemeChangerHook;
|
||||
import ru.vtosters.lite.ssfs.Utils;
|
||||
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
|
||||
import ru.vtosters.lite.ui.components.DockBarEditorManager;
|
||||
import ru.vtosters.lite.ui.components.SuperAppEditorManager;
|
||||
@@ -183,7 +184,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment implements Tel
|
||||
getSSFSsumm(),
|
||||
R.drawable.ic_link_circle_outline_28,
|
||||
preference -> {
|
||||
VKUIwrapper.setLink(SSFSUtils.getSSFSLink());
|
||||
VKUIwrapper.setLink(Utils.getVKUILink());
|
||||
launchFragment(VKUIwrapper.class);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import com.vk.core.network.Network;
|
||||
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isAnyProxyEnabled;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
|
||||
|
||||
public class SSFSUtils {
|
||||
public static String getSSFSLink() {
|
||||
return SSFSDomain() +
|
||||
"?token=" + AccountManagerUtils.getUserToken() +
|
||||
"&vt_dark=" + getDarkVKUI() +
|
||||
"&vt_amoled=" + getAmoledVKUI() +
|
||||
"&secret=" + AccountManagerUtils.getUserSecret() +
|
||||
"&proxy=" + getUserProxy() +
|
||||
"&lang=" + getLocale() +
|
||||
"&vt=1" +
|
||||
"&useragent=" + Base64Utils.encodeValue(Base64Utils.encode(Network.l.c().a())) +
|
||||
"&vt_debug=" + isDEVModEnabled();
|
||||
}
|
||||
|
||||
public static String SSFSDomain() {
|
||||
String string = getPrefsValue("ssfscustom");
|
||||
|
||||
if (!string.isEmpty()) return string;
|
||||
|
||||
return "https://ssfs.vtosters.app";
|
||||
}
|
||||
|
||||
public static String getDarkVKUI() {
|
||||
return isDarkTheme() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getAmoledVKUI() {
|
||||
return ThemesUtils.isAmoledTheme() && isDarkTheme() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getUserProxy() {
|
||||
return isAnyProxyEnabled() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String isDEVModEnabled() {
|
||||
return dev() ? "1" : "0";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user