ok
This commit is contained in:
@@ -12,23 +12,38 @@ import org.json.JSONException;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import ru.vtosters.hooks.other.Preferences;
|
import ru.vtosters.hooks.other.Preferences;
|
||||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||||
|
import ru.vtosters.lite.utils.AndroidUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class VKProxy {
|
public class VKProxy {
|
||||||
private static final OkHttpClient sClient = VtOkHttpClient.getInstance();
|
private static final OkHttpClient sClient = VtOkHttpClient.getInstance();
|
||||||
|
private static String nwProxy = Preferences.getPreferences().getString("configNetworkProxy", "");
|
||||||
|
private static String nwProxyCerts = Preferences.getPreferences().getString("configNetworkProxyCerts", "");
|
||||||
|
|
||||||
public static boolean isProxyEnabled() {
|
public static boolean isProxyEnabled() {
|
||||||
return Preferences.getBoolValue("isVKProxyEnabled", false);
|
return Preferences.getBoolValue("useProxyServer", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setProxyStatus(boolean status) {
|
public static void setProxyStatus(boolean status) {
|
||||||
Preferences.getPreferences().edit().putBoolean("isVKProxyEnabled", status).apply();
|
Preferences.getPreferences().edit().putBoolean("useProxyServer", status).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getConfigNetworkProxy() {
|
||||||
|
if (nwProxyCerts.isEmpty()) {
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
return nwProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getConfigNetworkProxyCerts() {
|
||||||
|
if (nwProxyCerts.isEmpty()) {
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
return nwProxyCerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
if (!isProxyEnabled()) return;
|
|
||||||
|
|
||||||
Request request = new Request.a()
|
Request request = new Request.a()
|
||||||
.b("https://firebaseremoteconfig.googleapis.com/v1/projects/api-project-841415684880/namespaces/firebase:fetch")
|
.b("https://firebaseremoteconfig.googleapis.com/v1/projects/api-project-841415684880/namespaces/firebase:fetch")
|
||||||
.a(RequestBody.a(MediaType.b("application/json; charset=UTF-8"), "{\"appId\":\"1:841415684880:android:632f429381141121\",\"appInstanceId\":\"RB855168585SG\"}\n"))
|
.a(RequestBody.a(MediaType.b("application/json; charset=UTF-8"), "{\"appId\":\"1:841415684880:android:632f429381141121\",\"appInstanceId\":\"RB855168585SG\"}\n"))
|
||||||
@@ -51,7 +66,6 @@ public class VKProxy {
|
|||||||
@Override
|
@Override
|
||||||
public void a(Call call, Response response) throws IOException {
|
public void a(Call call, Response response) throws IOException {
|
||||||
String payload = response.a().g();
|
String payload = response.a().g();
|
||||||
Log.d("VKProxy", payload);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(payload).getJSONObject("entries");
|
JSONObject jsonObject = new JSONObject(payload).getJSONObject("entries");
|
||||||
@@ -64,11 +78,12 @@ public class VKProxy {
|
|||||||
new ProxySettings().c(configNetworkProxy);
|
new ProxySettings().c(configNetworkProxy);
|
||||||
new ProxySettings().b(configNetworkProxyCerts);
|
new ProxySettings().b(configNetworkProxyCerts);
|
||||||
|
|
||||||
Preference.b("NetworkProxy", "proxy_enabled_cookie", true);
|
Preferences.getPreferences().edit().putString("configNetworkProxy", configNetworkProxy).putString("configNetworkProxyCerts", configNetworkProxyCerts).apply();
|
||||||
Preference.b("NetworkProxy", "proxy_user_state", true);
|
|
||||||
Network.l.b().a(true);
|
nwProxy = configNetworkProxy;
|
||||||
new ProxyHost().a(true);
|
nwProxyCerts = configNetworkProxyCerts;
|
||||||
new NetworkProxyPreferences().a(NetworkProxy.Reason.PROXY_ENABLED_SERVER);
|
|
||||||
|
AndroidUtils.sendToast("Инициализированы прокси");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ import android.widget.Toast;
|
|||||||
import androidx.appcompat.view.ContextThemeWrapper;
|
import androidx.appcompat.view.ContextThemeWrapper;
|
||||||
import b.h.g.m.FileUtils;
|
import b.h.g.m.FileUtils;
|
||||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||||
import com.vk.core.network.Network;
|
|
||||||
import com.vk.core.network.proxy.NetworkProxy;
|
|
||||||
import com.vk.core.network.proxy.ProxyHost;
|
|
||||||
import com.vk.core.preference.Preference;
|
|
||||||
import com.vk.im.engine.ImEngine1;
|
import com.vk.im.engine.ImEngine1;
|
||||||
import com.vk.im.engine.ImEngineExt;
|
import com.vk.im.engine.ImEngineExt;
|
||||||
import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider;
|
import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider;
|
||||||
@@ -26,10 +22,8 @@ import com.vk.imageloader.VKImageLoader;
|
|||||||
import com.vk.media.player.cache.AutoPlayCacheHolder;
|
import com.vk.media.player.cache.AutoPlayCacheHolder;
|
||||||
import com.vk.mediastore.MediaStorage;
|
import com.vk.mediastore.MediaStorage;
|
||||||
import com.vk.stickers.Stickers;
|
import com.vk.stickers.Stickers;
|
||||||
import com.vtosters.lite.NetworkProxyPreferences;
|
|
||||||
import com.vtosters.lite.im.ImEngineProvider;
|
import com.vtosters.lite.im.ImEngineProvider;
|
||||||
import ru.vtosters.hooks.SwitchHook;
|
import ru.vtosters.hooks.SwitchHook;
|
||||||
import ru.vtosters.hooks.VKProxy;
|
|
||||||
import ru.vtosters.hooks.other.Preferences;
|
import ru.vtosters.hooks.other.Preferences;
|
||||||
import ru.vtosters.hooks.other.ThemesUtils;
|
import ru.vtosters.hooks.other.ThemesUtils;
|
||||||
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
|
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
|
||||||
@@ -282,32 +276,6 @@ public class DataSettingsFragment extends TrackedMaterialPreferenceToolbarFragme
|
|||||||
|
|
||||||
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), AndroidUtils.getString("sett_other"));
|
PreferenceFragmentUtils.addPreferenceCategory(getPreferenceScreen(), AndroidUtils.getString("sett_other"));
|
||||||
|
|
||||||
PreferenceFragmentUtils.addMaterialSwitchPreference(
|
|
||||||
getPreferenceScreen(),
|
|
||||||
"",
|
|
||||||
"Use Proxy Server",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
VKProxy.isProxyEnabled(),
|
|
||||||
(preference, o) -> {
|
|
||||||
VKProxy.setProxyStatus((Boolean) o);
|
|
||||||
VKProxy.load();
|
|
||||||
|
|
||||||
if ((Boolean) o) {
|
|
||||||
Preference.b("NetworkProxy", "proxy_enabled_cookie", true);
|
|
||||||
Preference.b("NetworkProxy", "proxy_user_state", true);
|
|
||||||
Network.l.b().a(true);
|
|
||||||
new ProxyHost().a(true);
|
|
||||||
} else {
|
|
||||||
Preference.b("NetworkProxy", "proxy_enabled_cookie", false);
|
|
||||||
Preference.b("NetworkProxy", "proxy_user_state", false);
|
|
||||||
Network.l.b().a(false);
|
|
||||||
new ProxyHost().a(false);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
PreferenceFragmentUtils.addMaterialSwitchPreference(
|
PreferenceFragmentUtils.addMaterialSwitchPreference(
|
||||||
getPreferenceScreen(),
|
getPreferenceScreen(),
|
||||||
"disableForceTrafficSaver",
|
"disableForceTrafficSaver",
|
||||||
|
|||||||
@@ -1,25 +1,34 @@
|
|||||||
package ru.vtosters.lite.ui.fragments;
|
package ru.vtosters.lite.ui.fragments;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import com.vk.core.preference.Preference;
|
||||||
import com.vtosters.lite.R;
|
import com.vtosters.lite.R;
|
||||||
|
import ru.vtosters.hooks.VKProxy;
|
||||||
|
import ru.vtosters.lite.ui.PreferenceFragmentUtils;
|
||||||
|
|
||||||
public class ProxySettingsFragment extends TrackedMaterialPreferenceToolbarFragment {
|
public class ProxySettingsFragment extends TrackedMaterialPreferenceToolbarFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
addPreferencesFromResource(R.xml.preferences_proxy);
|
addPreferencesFromResource(R.xml.preferences_proxy);
|
||||||
// findPreference("random_proxy").setOnPreferenceClickListener(preference -> {
|
|
||||||
// try {
|
PreferenceFragmentUtils.addMaterialSwitchPreference(
|
||||||
// setupNewProxy();
|
getPreferenceScreen(),
|
||||||
// } catch (IOException e) {
|
"",
|
||||||
// sendToast(requireContext().getString(R.string.get_proxy_error));
|
"Use VK Proxy Server",
|
||||||
// }
|
null,
|
||||||
// return true;
|
null,
|
||||||
// });
|
VKProxy.isProxyEnabled(),
|
||||||
|
(preference, o) -> {
|
||||||
|
VKProxy.setProxyStatus((Boolean) o);
|
||||||
|
VKProxy.load();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int T4() {
|
public int T4() {
|
||||||
return R.string.vtlproxy;
|
return R.string.vtlproxy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,11 @@
|
|||||||
android:key="trackInstalledApps"
|
android:key="trackInstalledApps"
|
||||||
android:summary="@string/sett_mytracker_location_crap_summary"
|
android:summary="@string/sett_mytracker_location_crap_summary"
|
||||||
android:title="@string/sett_mytracker_apps"/>
|
android:title="@string/sett_mytracker_apps"/>
|
||||||
|
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="useProxyServer"
|
||||||
|
android:title="@string/sett_use_proxy"
|
||||||
|
android:visibility="gone" />
|
||||||
<com.vtosters.lite.ui.MaterialSwitchPreference
|
<com.vtosters.lite.ui.MaterialSwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="isRoamingState"
|
android:key="isRoamingState"
|
||||||
|
|||||||
@@ -52,6 +52,11 @@
|
|||||||
}
|
}
|
||||||
.end annotation
|
.end annotation
|
||||||
|
|
||||||
|
.line 1
|
||||||
|
iget-object v0, p0, Lcom/vk/core/network/proxy/ProxyHost$a;->a:Lcom/vk/core/network/proxy/ProxyHost;
|
||||||
|
|
||||||
|
invoke-virtual {v0}, Lcom/vk/core/network/proxy/ProxyHost;->i()V
|
||||||
|
|
||||||
return-void
|
return-void
|
||||||
.end method
|
.end method
|
||||||
|
|
||||||
|
|||||||
@@ -382,6 +382,8 @@
|
|||||||
|
|
||||||
if-eqz p1, :cond_0
|
if-eqz p1, :cond_0
|
||||||
|
|
||||||
|
const/4 v3, 0x1
|
||||||
|
|
||||||
goto :goto_0
|
goto :goto_0
|
||||||
|
|
||||||
:cond_0
|
:cond_0
|
||||||
@@ -598,7 +600,9 @@
|
|||||||
.locals 1
|
.locals 1
|
||||||
|
|
||||||
.line 1
|
.line 1
|
||||||
invoke-static {}, Lru/vtosters/hooks/VKProxy;->isProxyEnabled()Z
|
iget-object v0, p0, Lcom/vk/core/network/proxy/ProxyHost;->e:Ljava/util/concurrent/atomic/AtomicBoolean;
|
||||||
|
|
||||||
|
invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicBoolean;->get()Z
|
||||||
|
|
||||||
move-result v0
|
move-result v0
|
||||||
|
|
||||||
@@ -685,9 +689,13 @@
|
|||||||
.method public i()V
|
.method public i()V
|
||||||
.locals 3
|
.locals 3
|
||||||
|
|
||||||
const-string v1, ""
|
invoke-static {}, Lru/vtosters/hooks/VKProxy;->getConfigNetworkProxy()Z
|
||||||
|
|
||||||
const-string v0, ""
|
move-result-object v1
|
||||||
|
|
||||||
|
invoke-static {}, Lru/vtosters/hooks/VKProxy;->getConfigNetworkProxyCerts()Z
|
||||||
|
|
||||||
|
move-result-object v0
|
||||||
|
|
||||||
.line 3
|
.line 3
|
||||||
iget-object v2, p0, Lcom/vk/core/network/proxy/ProxyHost;->d:Lcom/vk/core/network/proxy/ProxySettings;
|
iget-object v2, p0, Lcom/vk/core/network/proxy/ProxyHost;->d:Lcom/vk/core/network/proxy/ProxySettings;
|
||||||
|
|||||||
@@ -31,7 +31,17 @@
|
|||||||
.locals 3
|
.locals 3
|
||||||
|
|
||||||
.line 1
|
.line 1
|
||||||
invoke-static {}, Lru/vtosters/hooks/VKProxy;->isProxyEnabled()Z
|
sget-object v0, Lcom/vk/core/util/AppContextHolder;->a:Landroid/content/Context;
|
||||||
|
|
||||||
|
invoke-static {v0}, Landroid/preference/PreferenceManager;->getDefaultSharedPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;
|
||||||
|
|
||||||
|
move-result-object v0
|
||||||
|
|
||||||
|
const-string v1, "__dbg_proxy_enable"
|
||||||
|
|
||||||
|
const/4 v2, 0x0
|
||||||
|
|
||||||
|
invoke-interface {v0, v1, v2}, Landroid/content/SharedPreferences;->getBoolean(Ljava/lang/String;Z)Z
|
||||||
|
|
||||||
move-result v0
|
move-result v0
|
||||||
|
|
||||||
|
|||||||
+30
@@ -989,6 +989,36 @@
|
|||||||
|
|
||||||
invoke-virtual {v0, p1}, Landroidx/preference/PreferenceGroup;->removePreference(Landroidx/preference/Preference;)Z
|
invoke-virtual {v0, p1}, Landroidx/preference/PreferenceGroup;->removePreference(Landroidx/preference/Preference;)Z
|
||||||
|
|
||||||
|
const-string p1, "useProxyServer"
|
||||||
|
|
||||||
|
.line 9
|
||||||
|
invoke-virtual {p0, p1}, Lcom/vtosters/lite/fragments/u2/PreferenceFragmentCompat;->findPreference(Ljava/lang/CharSequence;)Landroidx/preference/Preference;
|
||||||
|
|
||||||
|
move-result-object p1
|
||||||
|
|
||||||
|
check-cast p1, Landroidx/preference/SwitchPreference;
|
||||||
|
|
||||||
|
.line 10
|
||||||
|
sget-object v0, Lcom/vk/core/network/Network;->l:Lcom/vk/core/network/Network;
|
||||||
|
|
||||||
|
invoke-virtual {v0}, Lcom/vk/core/network/Network;->b()Lcom/vk/core/network/proxy/NetworkProxy;
|
||||||
|
|
||||||
|
move-result-object v0
|
||||||
|
|
||||||
|
.line 11
|
||||||
|
invoke-virtual {v0}, Lcom/vk/core/network/proxy/NetworkProxy;->d()Z
|
||||||
|
|
||||||
|
move-result v2
|
||||||
|
|
||||||
|
invoke-virtual {p1, v2}, Landroidx/preference/TwoStatePreference;->setChecked(Z)V
|
||||||
|
|
||||||
|
.line 12
|
||||||
|
new-instance v2, Lcom/vtosters/lite/general/fragments/SettingsGeneralFragment$b;
|
||||||
|
|
||||||
|
invoke-direct {v2, p0, v0, p1}, Lcom/vtosters/lite/general/fragments/SettingsGeneralFragment$b;-><init>(Lcom/vtosters/lite/general/fragments/SettingsGeneralFragment;Lcom/vk/core/network/proxy/NetworkProxy;Landroidx/preference/SwitchPreference;)V
|
||||||
|
|
||||||
|
invoke-virtual {p1, v2}, Landroidx/preference/Preference;->setOnPreferenceChangeListener(Landroidx/preference/Preference$OnPreferenceChangeListener;)V
|
||||||
|
|
||||||
const-string p1, "isRoamingState"
|
const-string p1, "isRoamingState"
|
||||||
|
|
||||||
.line 13
|
.line 13
|
||||||
|
|||||||
Reference in New Issue
Block a user