added proxied static and oauth + refactored by copilot

This commit is contained in:
gdlbo
2022-06-24 10:37:49 +03:00
parent 3167dfab09
commit 0bc2d2b896
34 changed files with 159 additions and 66 deletions
@@ -1,8 +1,8 @@
package ru.vtosters.lite.dnr;
import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
import static ru.vtosters.lite.utils.Globals.getUserToken;
import static ru.vtosters.lite.utils.Proxy.getApiCom;
import com.vk.core.util.ToastUtils;
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
@@ -51,7 +51,7 @@ public class DNRModule{
}
public static void hookRead(Dialog dialog){
makeRequest("https://" + getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.F1() + "&peer_id=" + dialog.getId() + "&v=5.91&access_token=" + getUserToken(), response -> {
makeRequest("https://" + getPrefsValue("proxyapi") + "/method/messages.markAsRead?start_message_id=" + dialog.F1() + "&peer_id=" + dialog.getId() + "&v=5.91&access_token=" + getUserToken(), response -> {
ToastUtils.a("Чат помечен как прочитанный!");
});
}
@@ -3,8 +3,8 @@ package ru.vtosters.lite.foaf;
import static android.widget.Toast.LENGTH_SHORT;
import static android.widget.Toast.makeText;
import static ru.vtosters.lite.utils.Globals.getIdentifier;
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
import static ru.vtosters.lite.utils.Globals.getString;
import static ru.vtosters.lite.utils.Proxy.getApiCom;
import static ru.vtosters.lite.utils.Proxy.proxy;
import android.app.ProgressDialog;
@@ -52,7 +52,7 @@ public class FoafBase{
StringBuilder sb;
if(proxy()){
sb = new StringBuilder();
str = "https://" + getApiCom() + "/_/vk.com/foaf.php?id=";
str = "https://" + getPrefsValue("proxyapi") + "/_/vk.com/foaf.php?id=";
} else {
sb = new StringBuilder();
str = "https://vk.com/foaf.php?id=";
@@ -5,69 +5,52 @@ import static java.lang.System.getProperties;
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import android.util.Log;
import java.util.Properties;
public class Proxy{
public static String getOauthComAuth(){
return getOauthComHttps() + "/authorize";
}
public static String linkReplacer(String link){
String vkapi = "api.vk.com";
String oauth = "oauth.vk.com";
String vkstatic = "static.vk.com";
public static String getOauthComAuthClient(){
return getOauthComAuth() + "?client_id=";
}
String proxiedvkapi = getPrefsValue("proxyapi");
String proxiedoauth = getPrefsValue("proxyoauth");
String proxedvkstatic = getPrefsValue("proxystatic");
public static String getOauthComBlank(){
return getOauthComHttps() + "/blank.html";
}
if(!proxy() || link.isEmpty()){
return link;
}
public static String getOauthComBlankRedirect(){
return "&redirect_uri=" + getOauthComBlank();
}
if(proxiedvkapi.isEmpty() || proxiedoauth.isEmpty() || proxedvkstatic.isEmpty()){
Log.d("VTLite", "Proxy is not set" + " " + proxiedvkapi + " " + proxiedoauth + " " + proxedvkstatic);
return link;
}
public static String getOauthComHttps(){
return "https://" + getOauthCom();
}
if(link.contains(vkapi)){
return link.replace(proxiedvkapi, vkapi);
}
public static String getStaticComSupport(){
return getStaticCom() + "/support";
}
if(link.contains(oauth)){
return link.replace(proxiedoauth, oauth);
}
public static String oauthFix(){
return "https://oauth.vk.com/blank.html";
}
if(link.contains(vkstatic)){
return link.replace(proxedvkstatic, vkstatic);
}
public static String getApiCom(){
String string = getPrefsValue("proxyapi");
if(!proxy() & string.isEmpty()) return "api.vk.com";
return string;
return link;
}
public static String getAwayPhpCom(){
String string = getPrefsValue("proxyapi");
if(!proxy() & string.isEmpty()) return "m.vk.com";
return string;
}
String proxyapi = getPrefsValue("proxyapi");
public static String getOauthCom(){
String string = getPrefsValue("proxyoauth");
if(!proxy() & string.isEmpty()) return "oauth.vk.com";
return string;
}
if(!proxy() & proxyapi.isEmpty()){
return "m.vk.com";
}
public static String getStaticCom(){
String string = getPrefsValue("proxystatic");
if(!proxy() & string.isEmpty()) return "static.vk.com";
return string;
}
public static String staticFix(String str){
String str2;
String string = getPrefsValue("proxystatic");
if(!proxy() & string.isEmpty()) return str;
str2 = string;
return str.replace(str2, "static.vk.com");
return proxyapi;
}
public static void setProxy(){