This commit is contained in:
aliveoutside
2022-03-24 19:37:43 +03:00
commit aa972fa5b3
37643 changed files with 6680801 additions and 0 deletions
@@ -0,0 +1,87 @@
package ru.f0x1d.net;
import android.os.AsyncTask;
import com.vk.core.network.Network;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import ru.vtosters.lite.utils.Helper;
public class F0x1dRequest {
public interface F0x1dRequestCallback {
void onResponse(String str);
}
public static void makeRequest(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) {
new MakeRequestTask(bArr, f0x1dRequestCallback).execute();
}
public static void makeRequest(String str, F0x1dRequestCallback f0x1dRequestCallback) {
new MakeRequestTask(str.getBytes(), f0x1dRequestCallback).execute();
}
public static void makeRequestToaster(String str, F0x1dRequestCallback f0x1dRequestCallback, boolean z) {
new MakeRequestTask(str.getBytes(), f0x1dRequestCallback, true, !z).execute();
}
private static class MakeRequestTask extends AsyncTask<Void, Void, String> {
private F0x1dRequestCallback callback;
private boolean mIsPut;
private boolean mIsVkToasterRequest;
private byte[] url;
public MakeRequestTask(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) {
this.mIsVkToasterRequest = false;
this.mIsPut = false;
this.callback = f0x1dRequestCallback;
this.url = bArr;
}
public MakeRequestTask(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback, boolean z, boolean z2) {
this.mIsVkToasterRequest = false;
this.mIsPut = false;
this.callback = f0x1dRequestCallback;
this.url = bArr;
this.mIsVkToasterRequest = z;
this.mIsPut = z2;
}
/* JADX INFO: Access modifiers changed from: protected */
public String doInBackground(Void... voidArr) {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(new String(this.url)).openConnection();
httpURLConnection.setRequestMethod(this.mIsPut ? "PUT" : "GET");
if (this.mIsVkToasterRequest) {
httpURLConnection.setRequestProperty("Token", Helper.GetUserToken());
}
if (!this.mIsVkToasterRequest) {
httpURLConnection.setRequestProperty("User-Agent", Network.a.a().a());
}
httpURLConnection.setRequestProperty("Content-Type", this.mIsVkToasterRequest ? "Content-Type" : "application/x-www-form-urlencoded");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
StringBuffer stringBuffer = new StringBuffer();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
stringBuffer.append(readLine);
} else {
bufferedReader.close();
return stringBuffer.toString();
}
}
} catch (Exception e) {
return e.getLocalizedMessage();
}
}
public void onPostExecute(String str) {
super.onPostExecute(str);
this.callback.onResponse(str);
}
}
}
@@ -0,0 +1,96 @@
package ru.f0x1d.net;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.TreeMap;
import android.util.Base64;
public final class NetCall {
private NetRequest req;
private NetClient cl;
protected NetCall(NetClient cl, NetRequest req) {
this.req = req;
this.cl = cl;
}
public NetRequest request() {
return req;
}
public NetResponse execute() throws IOException {
Proxy proxy = cl.getProxy();
PasswordAuthentication auth = cl.getAuthenticator();
HttpURLConnection con = (HttpURLConnection) new URL(req.url()).openConnection(proxy != null ? proxy : Proxy.NO_PROXY);
if (proxy != null && auth != null) {
String authStr = "Basic " + Base64.encodeToString((auth.getUserName() + new String(auth.getPassword())).getBytes(), Base64.NO_WRAP);
con.setRequestProperty("Proxy-Connection", "Keep-Alive");
con.setRequestProperty("Proxy-Authorization", authStr);
}
con.setConnectTimeout((int) cl.getTimeout());
con.setRequestMethod(req.getRequestMethod());
if (req.getRequestMethod().equals("POST")) {
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
}
Map<String, String> params = req.getRequestParams();
if (params != null) {
String strArgs = constructArgs(params);
con.setRequestProperty("Content-Length", String.valueOf(strArgs.getBytes(StandardCharsets.UTF_8).length));
con.setDoOutput(true);
con.getOutputStream().write(strArgs.getBytes(StandardCharsets.UTF_8));
con.getOutputStream().close();
}
con.connect();
InputStream in;
if (con.getResponseCode() == 200) in = con.getInputStream();
else in = con.getErrorStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024 * 1024];
int c;
while ((c = in.read(buffer)) != -1) bos.write(buffer, 0, c);
in.close();
bos.close();
NetResponse r = new NetResponse(bos.toByteArray());
r.setCode(con.getResponseCode());
return r;
}
private static String constructArgs(Map<String, String> args) throws UnsupportedEncodingException {
args = new TreeMap<>(args);
String str = "";
for (Map.Entry<String, String> en : args.entrySet()) {
if (!str.isEmpty()) str += "&";
str += URLEncoder.encode(en.getKey(), "UTF-8") + "=" + URLEncoder.encode(en.getValue(), "UTF-8");
}
return str;
}
public void enqueue(NetCallback cb) {
new Thread() {
@Override
public void run() {
try {
NetResponse resp = execute();
cb.onResponse(NetCall.this, resp);
} catch (IOException e) {
cb.onFailure(NetCall.this, e);
}
try {
interrupt();
join();
} catch (Exception e) {
}
}
}.start();
}
}
@@ -0,0 +1,9 @@
package ru.f0x1d.net;
import java.io.IOException;
public interface NetCallback {
void onFailure(NetCall netCall, IOException iOException);
void onResponse(NetCall netCall, NetResponse netResponse) throws IOException;
}
@@ -0,0 +1,87 @@
package ru.f0x1d.net;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.util.concurrent.TimeUnit;
public class NetClient {
private long timeout;
private Proxy proxy;
private PasswordAuthentication authenticator;
public static final class Builder {
private long timeout;
private Proxy proxy;
private PasswordAuthentication auth;
public Builder connectTimeout(long l, TimeUnit unit) {
int m;
switch (unit) {
case SECONDS:
m = 1000;
break;
case MILLISECONDS:
m = 1;
break;
case HOURS:
m = 1000 * 60 * 60;
break;
case DAYS:
m = 1000 * 60 * 60 * 24;
break;
case MINUTES:
m = 1000 * 60;
break;
default:
m = 1;
break;
}
timeout = l * m;
return this;
}
public Builder proxyAuthenticator(PasswordAuthentication auth) {
this.auth = auth;
return this;
}
public Builder proxy(Proxy proxy) {
this.proxy = proxy;
return this;
}
public NetClient build() {
return new NetClient(this);
}
}
public Builder newBuilder() {
Builder b = new Builder();
b.timeout = timeout;
b.proxy = proxy;
b.auth = authenticator;
return b;
}
protected NetClient(Builder b) {
timeout = b.timeout;
proxy = b.proxy;
authenticator = b.auth;
}
public NetCall newCall(NetRequest req) {
return new NetCall(this, req);
}
public PasswordAuthentication getAuthenticator() {
return authenticator;
}
public Proxy getProxy() {
return proxy;
}
public long getTimeout() {
return timeout;
}
}
+64
View File
@@ -0,0 +1,64 @@
package ru.f0x1d.net;
import java.util.Map;
import java.util.TreeMap;
public class NetRequest {
private String url;
private String requestMethod;
private Map<String, String> params;
public static final class Builder {
private String url;
private String req = "GET";
private Map<String, String> params;
public NetRequest build() {
return new NetRequest(this);
}
public Builder url(String url) {
this.url = url;
return this;
}
public Builder get() {
req = "GET";
return this;
}
public Builder post() {
req = "POST";
return this;
}
public Builder params(Map<String, String> params) {
this.params = params;
return this;
}
public Builder param(String param, String value) {
if (params == null) params = new TreeMap<>();
params.put(param, value);
return this;
}
}
protected NetRequest(Builder b) {
url = b.url;
requestMethod = b.req;
params = b.params;
}
public Map<String, String> getRequestParams() {
return params;
}
public String url() {
return url;
}
public String getRequestMethod() {
return requestMethod;
}
}
+38
View File
@@ -0,0 +1,38 @@
package ru.f0x1d.net;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
public final class NetResponse {
private byte[] data;
private int code;
protected NetResponse(byte[] data) {
this.data = data;
}
protected void setCode(int code) {
this.code = code;
}
public boolean isSuccessful() {
return code() == 200;
}
public int code() {
return code;
}
public byte[] getData() {
return data;
}
public InputStream getDataStream() {
return new ByteArrayInputStream(data);
}
public String getDataString() {
return new String(data, StandardCharsets.UTF_8);
}
}
@@ -0,0 +1,199 @@
package ru.vtosters.lite.audio.gcm;
import android.os.Build;
import android.util.Base64;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.interfaces.RSAPrivateKey;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.HttpsURLConnection;
public class GCMFix {
private static String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL);
public static ArrayList<String> langs = new ArrayList<>();
private static KeyPair pair;
private static int rid = 0;
/* access modifiers changed from: private */
public interface Callback {
void doCallback(String str);
}
static {
genNewKey();
}
public static String requestToken() {
String xappide;
try {
String[] aidarr = {"3974055026275073921", "4418584909973341826", "4585634953328772978"};
int r = new Random().nextInt(aidarr.length - 1);
String aid = "AidLogin " + aidarr[r] + ":" + new String[]{"1932960345884890854", "6594645578425092292", "1792344590975444730"}[r];
String pub2 = genNewKey();
String sig = getSig(pub2);
String xappide2 = null;
byte[] bytes = pair.getPublic().getEncoded();
try {
bytes = MessageDigest.getInstance("SHA1").digest(bytes);
} catch (NoSuchAlgorithmException e) {
xappide2 = "";
}
if (xappide2 == null) {
bytes[0] = (byte) (((bytes[0] & 15) + 112) & 255);
xappide = Base64.encodeToString(bytes, 2).substring(0, 11);
} else {
xappide = xappide2;
}
AtomicBoolean wait = new AtomicBoolean(false);
StringBuilder sb = new StringBuilder();
List<String> params = new ArrayList<>();
fillParams(params, sig, pub2, xappide, Long.parseLong(aid.split(" ")[1].split(":")[0]), false);
Callback callback = str -> GCMFix.lambdaRequestToken(sb, wait, str);
doRequest("https://android.clients.google.com/c2dm/register3", "POST", params, aid, callback);
while (!wait.get()) {
Thread.sleep(100);
}
String token = sb.toString();
if (token.equals("EGISTRATION_ERROR")) {
return requestToken();
}
rid = 0;
String pub22 = genNewKey();
String sig2 = getSig(pub22);
params.clear();
fillParams(params, sig2, pub22, xappide, Long.parseLong(aid.split(" ")[1].split(":")[0]), true);
doRequest("https://android.clients.google.com/c2dm/register3", "POST", params, aid, new Callback() {
@Override
public void doCallback(String str) {
GCMFix.lambda$requestToken$1(str);
}
});
return token;
} catch (FileNotFoundException e2) {
return requestToken();
} catch (Exception e3) {
return null;
}
}
static /* synthetic */ void lambdaRequestToken(StringBuilder sb, AtomicBoolean wait, String s) {
sb.append(s.substring(20));
wait.set(true);
}
static /* synthetic */ void lambda$requestToken$1(String str) {
}
private static void fillParams(List<String> params, String sig, String pub2, String xappid, long androidId, boolean del) {
rid++;
params.add("X-subtype=841415684880");
if (del) {
params.add("X-delete=1");
params.add("X-X-delete=1");
} else {
params.add("X-X-subscription=841415684880");
}
params.add("X-X-subtype=841415684880");
params.add("X-app_ver=3439");
params.add("X-kid=|ID|" + rid + "|");
params.add("X-osv=30");
params.add("X-sig=" + sig);
params.add("X-cliv=fiid-9877000");
params.add("X-gmsv=11949480");
params.add("X-pub2=" + pub2);
params.add("X-X-kid=|ID|" + rid + "|");
StringBuilder sb = new StringBuilder();
sb.append("X-appid=");
sb.append(xappid);
params.add(sb.toString());
if (del) {
params.add("X-scope=GCM");
} else {
params.add("X-scope=*");
}
params.add("X-subscription=841415684880");
if (!del) {
params.add("X-gmp_app_id=1:841415684880:android:632f429381141121");
}
params.add("X-app_ver_name=5.29");
params.add("app=com.vkontakte.android");
params.add("sender=841415684880");
params.add("device=" + androidId);
params.add("cert=48761eef50ee53afc4cc9c5f10e6bde7f8f5b82f");
params.add("app_ver=3439");
params.add("gcm_ver=11949470");
}
private static String join(String chr, Iterable<String> arr) {
String str = "";
for (String s : arr) {
str = str.isEmpty() ? s : str + chr + s;
}
return str;
}
private static String join(String chr, String[] arr) {
return join(chr, Arrays.asList(arr));
}
private static void doRequest(String url, String method, List<String> params, String aidlogin, Callback callback) throws IOException {
HttpsURLConnection con = (HttpsURLConnection) new URL(url).openConnection();
con.setRequestMethod(method);
con.setRequestProperty("Authorization", aidlogin);
con.setRequestProperty("app", "com.vkontakte.android");
con.setRequestProperty("Gcm-ver", "11947470");
con.setRequestProperty("Gcm-cert", "48761eef50ee53afc4cc9c5f10e6bde7f8f5b82f");
con.setRequestProperty("User-Agent", agent);
String uparams = join("&", params);
con.setDoOutput(true);
DataOutputStream out = new DataOutputStream(con.getOutputStream());
out.writeBytes(uparams);
out.flush();
out.close();
callback.doCallback(new BufferedReader(new InputStreamReader(con.getInputStream())).readLine());
con.getInputStream().close();
}
private static String genNewKey() {
try {
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
gen.initialize(2048);
pair = gen.generateKeyPair();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return Base64.encodeToString(pair.getPublic().getEncoded(), 0);
}
private static String getSig(String pub2) {
try {
PrivateKey key = pair.getPrivate();
Signature sign = Signature.getInstance(key instanceof RSAPrivateKey ? "SHA256withRSA" : "SHA256withECDSA");
sign.initSign(key);
sign.update(join("\n", new String[]{"com.vkontakte.android", pub2}).getBytes(StandardCharsets.UTF_8));
return Base64.encodeToString(sign.sign(), 0);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
@@ -0,0 +1,96 @@
package ru.vtosters.lite.badmanners;
public class Device {
private String androidId;
private String bluetoothMac;
private String boardName;
private String brandName;
private String cpuAbi;
private String deviceName;
private String firmwareDisplay;
private String firmwareId;
private String manufacturerName;
private String modelName;
private String productName;
private int sdkVersion;
private String serialId;
private String wifiMac;
public Device withSerialId(String str) {
this.serialId = str;
return this;
}
public Device withAndroidId(String str) {
this.androidId = str;
return this;
}
public Device withWifiMac(String str) {
this.wifiMac = str;
return this;
}
public Device withBluetoothMac(String str) {
this.bluetoothMac = str;
return this;
}
public Device withSdkVersion(int i) {
this.sdkVersion = i;
return this;
}
public Device withFirmwareId(String str) {
this.firmwareId = str;
return this;
}
public Device withFirmwareDisplay(String str) {
this.firmwareDisplay = str;
return this;
}
public Device withProductName(String str) {
this.productName = str;
return this;
}
public Device withDeviceName(String str) {
this.deviceName = str;
return this;
}
public Device withBoardName(String str) {
this.boardName = str;
return this;
}
public Device withCpuAbi(String str) {
this.cpuAbi = str;
return this;
}
public Device withManufacturerName(String str) {
this.manufacturerName = str;
return this;
}
public Device withBrandName(String str) {
this.brandName = str;
return this;
}
public Device withModelName(String str) {
this.modelName = str;
return this;
}
public String toString() {
return "Device{serialId='" + this.serialId + "', androidId='" + this.androidId + "', wifiMac='" + this.wifiMac + "', bluetoothMac='" + this.bluetoothMac + "'}";
}
public String toDeviceName() {
return "Device{sdkVersion=" + this.sdkVersion + ", productName='" + this.productName + "', deviceName='" + this.deviceName + "', boardName='" + this.boardName + "', cpuAbi='" + this.cpuAbi + "', manufacturerName='" + this.manufacturerName + "', brandName='" + this.brandName + "', modelName='" + this.modelName + "'}";
}
}
@@ -0,0 +1,192 @@
package ru.vtosters.lite.badmanners;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.os.EnvironmentCompat;
import java.io.BufferedReader;
import java.io.FileReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.NetworkInterface;
import java.util.Collections;
public class DeviceInfoCollector {
private static final String TAG = "DeviceInfoCollector";
public Device collect(Context context) {
return new Device().withSerialId(serialId()).withAndroidId(androidId(context)).withWifiMac(wifiMac(context)).withBluetoothMac(bluetoothMac(context)).withSdkVersion(Build.VERSION.SDK_INT).withFirmwareId(Build.ID).withFirmwareDisplay(Build.DISPLAY).withProductName(Build.PRODUCT).withDeviceName(Build.DEVICE).withBoardName(Build.BOARD).withCpuAbi(Build.CPU_ABI).withManufacturerName(Build.MANUFACTURER).withBrandName(Build.BRAND).withModelName(Build.MODEL);
}
private String serialId() {
String str;
try {
Class<?> cls = Class.forName("android.os.SystemProperties");
Method method = cls.getMethod("get", String.class);
str = (String) method.invoke(cls, "gsm.sn1");
if (isInvalidSerial(str)) {
str = (String) method.invoke(cls, "ril.serialnumber");
}
if (isInvalidSerial(str)) {
str = (String) method.invoke(cls, "ro.serialno");
}
if (isInvalidSerial(str)) {
str = (String) method.invoke(cls, "sys.serialnumber");
}
if (isInvalidSerial(str)) {
str = Build.SERIAL;
}
} catch (Exception e) {
Log.d(TAG, "Serial ID obtaining failed: ", e);
}
str = null;
if (str != null) {
return str.toLowerCase();
}
return null;
}
private String androidId(Context context) {
return Settings.Secure.getString(context.getContentResolver(), "android_id").toLowerCase();
}
private String wifiMac(Context context) {
String wifiMacFromManager = wifiMacFromManager(context);
if (isInvalidMac(wifiMacFromManager)) {
wifiMacFromManager = wifiMacFromNetworkInterfaces();
}
if (isInvalidMac(wifiMacFromManager)) {
wifiMacFromManager = wifiMacFromFileSystem();
}
if (isInvalidMac(wifiMacFromManager)) {
wifiMacFromManager = null;
}
if (wifiMacFromManager != null) {
return wifiMacFromManager.toLowerCase();
}
return null;
}
private String wifiMacFromManager(Context context) {
WifiInfo connectionInfo;
try {
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager == null || (connectionInfo = wifiManager.getConnectionInfo()) == null) {
return null;
}
return null;
} catch (Exception e) {
Log.d(TAG, "WiFi MAC obtaining from manager failed: ", e);
return null;
}
}
private String wifiMacFromNetworkInterfaces() {
try {
for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
if ("wlan0".equalsIgnoreCase(networkInterface.getName())) {
byte[] hardwareAddress = networkInterface.getHardwareAddress();
if (hardwareAddress == null) {
return null;
}
StringBuilder sb = new StringBuilder();
int length = hardwareAddress.length;
for (int i = 0; i < length; i++) {
sb.append(String.format("%02X:", Byte.valueOf(hardwareAddress[i])));
}
if (sb.length() > 0) {
sb.deleteCharAt(sb.length() - 1);
}
return sb.toString();
}
}
return null;
} catch (Exception e) {
Log.d(TAG, "WiFi MAC obtaining from network interfaces failed: ", e);
return null;
}
}
private String wifiMacFromFileSystem() {
try {
FileReader fileReader = new FileReader("/sys/class/net/wlan0/address");
try {
BufferedReader bufferedReader = new BufferedReader(fileReader);
try {
String readLine = bufferedReader.readLine();
bufferedReader.close();
fileReader.close();
return readLine;
} catch (Throwable th) {
th.addSuppressed(th);
}
} catch (Throwable th2) {
throw th2;
}
} catch (Exception e) {
Log.d(TAG, "WiFi MAC obtaining from file system failed: ", e);
return null;
}
return null;
}
private String bluetoothMac(Context context) {
String bluetoothMacFromAdapter = bluetoothMacFromAdapter();
if (isInvalidMac(bluetoothMacFromAdapter)) {
bluetoothMacFromAdapter = bluetoothMacFromContentResolver(context);
}
if (isInvalidMac(bluetoothMacFromAdapter)) {
bluetoothMacFromAdapter = null;
}
if (bluetoothMacFromAdapter != null) {
return bluetoothMacFromAdapter.toLowerCase();
}
return null;
}
private String bluetoothMacFromAdapter() {
try {
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
if (defaultAdapter == null) {
return null;
}
if (Build.VERSION.SDK_INT < 23) {
return null;
}
Field declaredField = defaultAdapter.getClass().getDeclaredField("mService");
declaredField.setAccessible(true);
Object obj = declaredField.get(defaultAdapter);
if (obj != null) {
return (String) obj.getClass().getMethod("getAddress", new Class[0]).invoke(obj, new Object[0]);
}
return null;
} catch (Exception e) {
Log.d(TAG, "BT MAC obtaining from adapter failed: ", e);
return null;
}
}
private String bluetoothMacFromContentResolver(Context context) {
try {
return Settings.Secure.getString(context.getContentResolver(), "bluetooth_address");
} catch (Exception e) {
Log.d(TAG, "BT MAC obtaining from content resolver failed: ", e);
return null;
}
}
private boolean isInvalidSerial(String str) {
return TextUtils.isEmpty(str) || EnvironmentCompat.MEDIA_UNKNOWN.equalsIgnoreCase(str);
}
private boolean isInvalidMac(String str) {
return TextUtils.isEmpty(str) || "02:00:00:00:00:00".equalsIgnoreCase(str) || "00:00:00:00:00:00".equalsIgnoreCase(str);
}
}
@@ -0,0 +1,68 @@
package ru.vtosters.lite.dnr;
import android.util.Log;
import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.ui.components.common.DialogAction;
import java.util.LinkedHashMap;
import java.util.List;
import ru.vtosters.lite.utils.Helper;
public class DNRInjector {
public static void inject(Dialog dialog, List<DialogAction> list) {
int peerId = dialog.a();
if (DNRModule.isDnrEnabledFor(peerId)) {
list.add(DialogAction.valueOf("DNR_OFF"));
} else {
list.add(DialogAction.valueOf("DNR_ON"));
}
if (DNRModule.isDntEnabledFor(peerId)) {
list.add(DialogAction.valueOf("DNT_OFF"));
} else {
list.add(DialogAction.valueOf("DNT_ON"));
}
}
public static LinkedHashMap<DialogAction, Integer> injectToHashMap(LinkedHashMap<DialogAction, Integer> hashMap) {
hashMap.put(DialogAction.valueOf("DNR_ON"), Helper.getIdentifier("DNR_ON", "string"));
hashMap.put(DialogAction.valueOf("DNR_OFF"), Helper.getIdentifier("DNR_OFF", "string"));
hashMap.put(DialogAction.valueOf("DNT_ON"), Helper.getIdentifier("DNT_ON", "string"));
hashMap.put(DialogAction.valueOf("DNT_OFF"), Helper.getIdentifier("DNT_OFF", "string"));
return hashMap;
}
public static boolean onClick(Dialog dialog, DialogAction action) {
var id = dialog.a();
if (action == DialogAction.valueOf("DNR_ON")) {
setDnr(dialog, true);
return true;
} else if (action == DialogAction.valueOf("DNR_OFF")) {
setDnr(dialog, false);
return true;
}
if (action == DialogAction.valueOf("DNT_ON")) {
setDnt(dialog, true);
return true;
} else if (action == DialogAction.valueOf("DNT_OFF")) {
setDnt(dialog, false);
return true;
}
return false;
}
public static void setDnr(Dialog dialog, boolean value) {
DNRModule.hookDNR(dialog.a());
}
public static void setDnt(Dialog dialog, boolean value) {
DNRModule.hookDNT(dialog.a());
}
}
@@ -0,0 +1,68 @@
package ru.vtosters.lite.dnr;
import android.util.Log;
import com.vk.core.util.ToastUtils;
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
import com.vk.im.engine.models.dialogs.Dialog;
import java.util.List;
import ru.f0x1d.net.F0x1dRequest;
import ru.vtosters.lite.dnr.helpers.DoNotReadDBHelper;
import ru.vtosters.lite.dnr.helpers.DoNotTypeDBHelper;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.utils.Proxy;
public class DNRModule {
public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper();
public static DoNotTypeDBHelper mDoNotTypeDBHelper = new DoNotTypeDBHelper();
public static boolean isDnrEnabledFor(int id) {
var isEnabled = mDoNotReadDBHelper.isEnabledForPeerId(id);
return isEnabled;
}
public static List<Integer> getDnrEnabled() {
return mDoNotReadDBHelper.get();
}
public static List<Integer> getDntEnabled() {
return mDoNotTypeDBHelper.get();
}
public static boolean isDntEnabledFor(int id) {
var isEnabled = mDoNotTypeDBHelper.isEnabledForPeerId(id);
return isEnabled;
}
public static boolean isDntEnabledFor(SetUserActivityCmd cmd) {
return isDntEnabledFor(cmd.b);
}
public static boolean isDnrEnabledFor(Dialog dialog) {
if (dialog == null) return false;
return isDnrEnabledFor(dialog.a());
}
public static boolean isDntEnabledFor(Dialog dialog) {
if (dialog == null) return false;
return isDntEnabledFor(dialog.a());
}
public static void hookRead(Dialog dialog) {
F0x1dRequest.makeRequest("https://" + Proxy.getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.lastMsgVkId + "&peer_id=" + dialog.a() + "&v=5.91&access_token=" + Helper.GetUserToken(), response -> {
ToastUtils.a("Чат помечен как прочитанный!");
});
}
public static Dialog mDialog;
public static void hookDNR(int peerId) {
mDoNotReadDBHelper.setEnabledForPeerId(peerId, !mDoNotReadDBHelper.isEnabledForPeerId(peerId));
}
public static void hookDNT(int peerId) {
mDoNotTypeDBHelper.setEnabledForPeerId(peerId, !mDoNotTypeDBHelper.isEnabledForPeerId(peerId));
}
}
@@ -0,0 +1,66 @@
package ru.vtosters.lite.dnr;
import ru.vtosters.lite.utils.Prefs;
// Настройки Донецкой Народной Республики
public class DNRPrefs {
public static boolean getStoriesRead() {
return Prefs.BooleanFalse("read_s");
}
public static boolean getMarkAsReadWithoutExceptions(int peerId) {
if (readPM(peerId))
return true;
if (readConversations(peerId))
return true;
return readBots(peerId);
}
public static boolean getMarkAsRead(int peerId) {
return isInDNRExceptions(peerId);
}
public static boolean isInDNRExceptions(int peerId) {
return DNRModule.mDoNotReadDBHelper.isEnabledForPeerId(peerId);
}
public static boolean isInDNTExceptions(int peerId) {
return DNRModule.mDoNotTypeDBHelper.isEnabledForPeerId(peerId);
}
public static boolean readPM(int peer) {
return (peer > 0 && peer < 2000000000) && Prefs.BooleanFalse("read_pm");
}
public static boolean readConversations(int peer) {
return (peer > 2000000000) && Prefs.BooleanFalse("read_conversations");
}
public static boolean readBots(int peer) {
return (peer < 0) && Prefs.BooleanFalse("read_bot");
}
public static boolean writePM(int peer) {
return (peer > 0 && peer < 2000000000) && Prefs.BooleanFalse("write_pm");
}
public static boolean writeConversations(int peer) {
return (peer > 2000000000) && Prefs.BooleanFalse("write_conversations");
}
public static boolean writeBots(int peer) {
return (peer < 0) && Prefs.BooleanFalse("write_bot");
}
public static boolean getActivityWithoutExceptions(int peerId) {
if (writePM(peerId))
return true;
if (writeConversations(peerId))
return true;
return writeBots(peerId);
}
public static boolean getActivity(int peerId) {
return isInDNTExceptions(peerId);
}
}
@@ -0,0 +1,78 @@
package ru.vtosters.lite.dnr.helpers;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
import java.util.List;
import ru.vtosters.lite.dnr.DNRPrefs;
import ru.vtosters.lite.utils.Helper;
public class DoNotReadDBHelper extends SQLiteOpenHelper {
public DoNotReadDBHelper() {
super(Helper.GetContext(), "dnr", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table dnr (peerId integer primary key, enabled integer)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public boolean isEnabledForPeerId(int peerId) {
try (Cursor c = getReadableDatabase().query("dnr", null, null, null, null, null, null)) {
if (c.moveToFirst()) {
int peerIdIndex = c.getColumnIndex("peerId");
int enabledIndex = c.getColumnIndex("enabled");
do {
if (c.getInt(peerIdIndex) == peerId)
return c.getInt(enabledIndex) == 1;
} while (c.moveToNext());
}
} catch (Exception e) {
e.printStackTrace();
}
return DNRPrefs.getMarkAsReadWithoutExceptions(peerId);
}
public List<Integer> get() {
ArrayList<Integer> rs = new ArrayList<>();
try (Cursor c = getReadableDatabase().query("dnr", null, null, null, null, null, null)) {
if (c.moveToFirst()) {
int peerIdIndex = c.getColumnIndex("peerId");
int enabledIndex = c.getColumnIndex("enabled");
do {
if (c.getInt(enabledIndex) == 1) {
rs.add(c.getInt(peerIdIndex));
}
} while (c.moveToNext());
}
} catch (Exception e) {
e.printStackTrace();
}
return rs;
}
public void setEnabledForPeerId(int peerId, boolean enabled) {
ContentValues cv = new ContentValues();
cv.put("enabled", enabled ? 1 : 0);
int i = getWritableDatabase().update("dnr", cv, "peerId = " + peerId, null);
if (i == 0) {
cv.put("peerId", peerId);
getWritableDatabase().insert("dnr", null, cv);
}
}
}
@@ -0,0 +1,78 @@
package ru.vtosters.lite.dnr.helpers;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.ArrayList;
import java.util.List;
import ru.vtosters.lite.dnr.DNRPrefs;
import ru.vtosters.lite.utils.Helper;
public class DoNotTypeDBHelper extends SQLiteOpenHelper {
public DoNotTypeDBHelper() {
super(Helper.GetContext(), "dnt", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table dnt (peerId integer primary key, enabled integer)");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
public List<Integer> get() {
ArrayList<Integer> rs = new ArrayList<>();
try (Cursor c = getReadableDatabase().query("dnt", null, null, null, null, null, null)) {
if (c.moveToFirst()) {
int peerIdIndex = c.getColumnIndex("peerId");
int enabledIndex = c.getColumnIndex("enabled");
do {
if (c.getInt(enabledIndex) == 1) {
rs.add(c.getInt(peerIdIndex));
}
} while (c.moveToNext());
}
} catch (Exception e) {
e.printStackTrace();
}
return rs;
}
public boolean isEnabledForPeerId(int peerId) {
try (Cursor c = getReadableDatabase().query("dnt", null, null, null, null, null, null)) {
if (c.moveToFirst()) {
int peerIdIndex = c.getColumnIndex("peerId");
int enabledIndex = c.getColumnIndex("enabled");
do {
if (c.getInt(peerIdIndex) == peerId)
return c.getInt(enabledIndex) == 1;
} while (c.moveToNext());
}
} catch (Exception e) {
e.printStackTrace();
}
return DNRPrefs.getActivityWithoutExceptions(peerId);
}
public void setEnabledForPeerId(int peerId, boolean enabled) {
ContentValues cv = new ContentValues();
cv.put("enabled", enabled ? 1 : 0);
int i = getWritableDatabase().update("dnt", cv, "peerId = " + peerId, null);
if (i == 0) {
cv.put("peerId", peerId);
getWritableDatabase().insert("dnt", null, cv);
}
}
}
@@ -0,0 +1,74 @@
package ru.vtosters.lite.downloaders;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import com.vk.core.util.ToastUtils;
import com.vk.dto.common.VideoFile;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import ru.vtosters.lite.R;
public class VideoDownloader {
public static void downloadVideo(VideoFile videoFile, Context context) {
final List<String> list = new ArrayList<>();
final List<String> urls = new ArrayList<>();
if (!Objects.equals(videoFile.e, "")) {
list.add("240p");
urls.add(videoFile.e);
}
if (!Objects.equals(videoFile.f, "")) {
list.add("360p");
urls.add(videoFile.f);
}
if (!Objects.equals(videoFile.g, "")) {
list.add("480p");
urls.add(videoFile.g);
}
if (!Objects.equals(videoFile.h, "")) {
list.add("720p");
urls.add(videoFile.h);
}
if (!Objects.equals(videoFile.i, "")) {
list.add("1080p");
urls.add(videoFile.i);
}
if (!Objects.equals(videoFile.j, "")) {
list.add("1440p");
urls.add(videoFile.j);
}
if (!Objects.equals(videoFile.k, "")) {
list.add("2160p");
urls.add(videoFile.k);
}
if (list.isEmpty()) {
ToastUtils.a("Данное видео невозможно скачать");
return;
}
var max = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
max[i] = list.get(i);
}
var builder = new AlertDialog.Builder(context);
builder.setItems(max, ((dialog, which) -> {
var url = urls.get(which);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle(videoFile.toString());
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile.s + ".mp4");
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
}));
builder.show();
}
}
@@ -0,0 +1,95 @@
package ru.vtosters.lite.f0x1d;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
import com.vtosters.lite.R;
import java.io.PrintWriter;
import java.io.StringWriter;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.badmanners.DeviceInfoCollector;
import ru.vtosters.lite.utils.Prefs;
public class Crashreporter {
protected static String logString;
public static String getStackTrace(Throwable th) {
StringWriter stringWriter = new StringWriter();
th.printStackTrace(new PrintWriter(stringWriter));
return stringWriter.toString();
}
public static void init(Activity activity) {
final var defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler((thread, th) -> Crashreporter.start(defaultUncaughtExceptionHandler, thread, th, activity));
}
static void start(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th, Activity activity) {
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(Helper.GetContext()).toDeviceName() + "\n VTL Version: " + Prefs.VERSIONNAME + ", build: " + Prefs.getBuildNumber();
if (Build.VERSION.SDK_INT >= 26) {
var notificationChannel = new NotificationChannel("crashes", "crash", NotificationManager.IMPORTANCE_DEFAULT);
notificationChannel.enableVibration(true);
notificationChannel.enableLights(true);
((NotificationManager) Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel);
}
var foxbinIntent = new Intent("com.f0x1d.dogbin.ACTION_UPLOAD_TO_FOXBIN");
foxbinIntent.putExtra("android.intent.extra.TEXT", logString);
foxbinIntent.setType("text/plain");
if (!isFoxbinInstalled()) {
foxbinIntent = new Intent("android.intent.action.VIEW");
foxbinIntent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.f0x1d.dogbin"));
foxbinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
}
var saveLogIntent = new Intent(Helper.GetContext(), LogWriterService.class);
saveLogIntent.putExtra("log", logString);
saveLogIntent.putExtra("notificationId", 1);
var psaveLogIntent = PendingIntent.getService(Helper.GetContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT);
var builder = new Notification.Builder(Helper.GetContext());
builder.setSmallIcon(R.drawable.ic_bug_24);
builder.setContentTitle("VTL Крашнулся!");
builder.setContentText(logString);
builder.setStyle(new Notification.BigTextStyle().bigText(logString));
builder.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
builder.addAction(new Notification.Action(0, "Загрузить логи", PendingIntent.getActivity(Helper.GetContext(), (int) (Math.random() * 100.0d), foxbinIntent, PendingIntent.FLAG_CANCEL_CURRENT)));
builder.addAction(new Notification.Action(0, "Сохранить в файл", psaveLogIntent));
} else {
builder.setContentIntent(PendingIntent.getActivity(activity, 0, foxbinIntent, PendingIntent.FLAG_ONE_SHOT));
}
if (Build.VERSION.SDK_INT >= 26) {
builder.setChannelId("crashes");
}
((NotificationManager) Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(-2147483548, builder.build());
Log.e("VTosters Lite", "crashed: " + th.getLocalizedMessage());
uncaughtExceptionHandler.uncaughtException(thread, th);
}
private static boolean isFoxbinInstalled() {
var pm = Helper.GetContext().getPackageManager();
try {
pm.getPackageInfo("com.f0x1d.dogbin", 0);
return true;
} catch (Exception e) {
return false;
}
}
}
@@ -0,0 +1,65 @@
package ru.vtosters.lite.f0x1d;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.Nullable;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import ru.vtosters.lite.utils.Helper;
public class LogWriterService extends Service {
public LogWriterService() {
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
Log.d("LogWriterService", "The service has been started");
var file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/VTL_log.txt");
try {
var exists = file.createNewFile();
if (!exists) {
file.delete();
file.createNewFile();
}
writeLog(intent, file);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(Helper.GetContext(), "Не удалось сохранить лог-файл", Toast.LENGTH_SHORT).show();
}
var notificationId = intent.getIntExtra("notificationId", 1);
var manager = (NotificationManager) Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(notificationId);
Toast.makeText(Helper.GetContext(), "Лог-файл был сохранен", Toast.LENGTH_SHORT).show();
stopSelf();
return START_NOT_STICKY;
}
private void writeLog(Intent intent, File file) throws IOException {
FileOutputStream stream;
stream = new FileOutputStream(file);
stream.write(intent.getStringExtra("log").getBytes(StandardCharsets.UTF_8));
stream.flush();
stream.close();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
@@ -0,0 +1,171 @@
package ru.vtosters.lite.f0x1d;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Base64;
import android.util.Log;
import android.widget.Toast;
import com.vk.dto.common.VerifyInfo;
import com.vk.navigation.NavigatorKeys;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import ru.vtosters.lite.utils.Prefs;
public class VTVerifications {
private static final String TAG = "VTVerifications";
private static final String DEVELOPERS_KEY = "VTNRS3";
private static final String PROMETHEUS_KEY = "VTNRS1";
private static final String SERVICE_ACCOUNTS_KEY = "VTNRS4";
private static final String VERIFICATIONS_KEY = "VTNRS0";
private static SharedPreferences mVerificationsCache;
private static final HashMap<Integer, Boolean> sDevelopersMap = new HashMap<>();
private static final HashMap<Integer, Boolean> sPrometheusMap = new HashMap<>();
public static final HashMap<Integer, Boolean> sServiceAccountsMap = new HashMap<>();
private static final HashMap<Integer, Boolean> sVerificationsMap = new HashMap<>();
private static OkHttpClient client = new OkHttpClient();
public static void load(Context context) {
mVerificationsCache = context.getSharedPreferences("vt_another_data", 0);
try {
processArray(new JSONArray(getLoaded(VERIFICATIONS_KEY)), sVerificationsMap, null);
processArray(new JSONArray(getLoaded(PROMETHEUS_KEY)), sPrometheusMap, null);
processArray(new JSONArray(getLoaded(DEVELOPERS_KEY)), sDevelopersMap, null);
processArray(new JSONArray(getLoaded(SERVICE_ACCOUNTS_KEY)), sServiceAccountsMap, null);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
Request request = new Request.Builder()
.url("https://gdlbo.net/vktoaster/getGalo4kiBatch")
.a(RequestBody.a(MediaType.b("application/json; charset=UTF-8"), "{\"types\":[0,228,404,1337]}"))
.build();
client.newCall(request).a(new Callback() {
@Override
public void a(Call call, IOException e) {
Log.d(TAG, "" + e);
}
@Override
public void a(Call call, Response response) throws IOException {
try {
getVerifications(response.body().string());
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
private static void getVerifications(String body) throws Exception {
JSONObject jSONObject = new JSONObject(body);
processArray(jSONObject.optJSONArray("0"), sVerificationsMap, VERIFICATIONS_KEY);
processArray(jSONObject.optJSONArray("228"), sPrometheusMap, PROMETHEUS_KEY);
processArray(jSONObject.optJSONArray("404"), sDevelopersMap, DEVELOPERS_KEY);
processArray(jSONObject.optJSONArray("1337"), sServiceAccountsMap, SERVICE_ACCOUNTS_KEY);
}
private static void processArray(JSONArray jSONArray, Map<Integer, Boolean> map, String str) {
if (jSONArray != null) {
for (int i = 0; i < jSONArray.length(); i++) {
map.put(Integer.valueOf(jSONArray.optInt(i)), true);
}
if (str != null) {
setLoaded(str, jSONArray.toString());
}
}
}
public static boolean isVerified(int i) {
return sVerificationsMap.get(i) != null ? sVerificationsMap.get(i) : false;
}
public static boolean isVerifiedMSG(int i) {
return sVerificationsMap.get(i) != null ? sVerificationsMap.get(i) : false;
}
public static boolean hasPrometheus(int i) {
return sPrometheusMap.get(i) != null ? sPrometheusMap.get(i) : false;
}
public static boolean isDeveloper(int i) {
return sDevelopersMap.get(i) != null ? sDevelopersMap.get(i) : false;
}
public static boolean isServiceAccount(int i) {
return sServiceAccountsMap.get(i) != null ? sServiceAccountsMap.get(i) : false;
}
private static String getLoaded(String str) {
return decode(mVerificationsCache.getString(str, encode("[]")));
}
public static void setLoaded(String str, String str2) {
mVerificationsCache.edit().putString(str, encode(str2)).apply();
}
public static String decode(String str) {
return new String(Base64.decode(str, 1), StandardCharsets.UTF_8);
}
public static String encode(String str) {
return Base64.encodeToString(str.getBytes(), 1);
}
public static boolean isVerified(JSONObject jSONObject) {
if (jSONObject.optInt("verified", 0) == 1) {
return true;
}
if (!Prefs.BooleanTrue("VT_Verification")) {
return false;
}
if (isVerified((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0))) {
return true;
}
return false;
}
public static boolean hasPrometheus(JSONObject jSONObject) {
if (jSONObject.optInt("trending", 0) == 1) {
return true;
}
if (!Prefs.BooleanTrue("VT_Fire")) {
return false;
}
if (hasPrometheus((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0))) {
return true;
}
return false;
}
public static boolean hasDeveloper(JSONObject jSONObject) {
if (!Prefs.BooleanTrue("VT_Dev")) {
return false;
}
return isDeveloper((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0));
}
public static VerifyInfo VerifyInfo(JSONObject jSONObject) {
return new VerifyInfo(isVerified(jSONObject), hasPrometheus(jSONObject));
}
}
@@ -0,0 +1,105 @@
package ru.vtosters.lite.foaf;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.widget.Toast;
import androidx.exifinterface.media.ExifInterface;
import com.vk.core.dialogs.alert.VkAlertDialog;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import ru.f0x1d.net.F0x1dRequest;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.utils.Prefs;
public class FoafBase {
private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>");
private static final Pattern FOAF_REGEX_LAST_SEEN = Pattern.compile("<ya:lastLoggedIn dc:date=\"(.*)(((\\+|-)\\d\\d):(\\d\\d))\"\\/>");
private static final Pattern FOAF_REGEX_LOGIN = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>");
private static OkHttpClient client = new OkHttpClient();
public static int GetLastSeenInt(int i) throws ParseException, IOException {
Matcher matcher = FOAF_REGEX_LAST_SEEN.matcher(client.newCall(new Request.Builder().url(getLink(i)).build()).b().body().string());
if (!matcher.find()) {
return 0;
}
return (int) (new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:ss", Locale.getDefault()).parse(matcher.group(1)).getTime() / 1000);
}
public static long GetLastSeenLong(int i) throws ParseException, IOException {
return GetLastSeenInt(i);
}
private static String getLink(int i) {
String str;
StringBuilder sb;
if (Prefs.proxy()) {
sb = new StringBuilder();
str = "https://vk-api-proxy.xtrafrancyz.net/_/vk.com/foaf.php?id=";
} else {
sb = new StringBuilder();
str = "https://vk.com/foaf.php?id=";
}
sb.append(str);
sb.append(i);
return sb.toString();
}
public static void loadAndShow(Context context, int i) {
ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setMessage("Загрузка...");
progressDialog.setCancelable(false);
progressDialog.show();
F0x1dRequest.F0x1dRequestCallback callback = str -> FoafBase.lambdaLoadAndShow(progressDialog, context, i, str);
F0x1dRequest.makeRequest(getLink(i), callback);
}
static /* synthetic */ void lambdaLoadAndShow(ProgressDialog progressDialog, Context context, int i, String str) {
try {
progressDialog.cancel();
Matcher matcher = FOAF_REGEX.matcher(str);
Matcher matcher2 = FOAF_REGEX_LOGIN.matcher(str);
matcher.find();
matcher2.find();
String normalHumanDate = getNormalHumanDate(matcher.group(1));
getNormalHumanDate(matcher2.group(1));
AlertDialog.a a2 = new VkAlertDialog.a(context).a(R.string.addinf);
a2.b(Helper.getString("foafid") + " " + i + Helper.getString("foafregdate") + " " + normalHumanDate + Helper.getString("foafdate") + " " + daysPassedFromFoafDate(normalHumanDate)).b(17039370, (DialogInterface.OnClickListener) null).b().show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(context, Helper.getString("foaferr"), Toast.LENGTH_SHORT).show();
}
}
private static long daysPassedFromFoafDate(String str) {
try {
Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(str.split(" ")[1]);
return TimeUnit.DAYS.convert(new Date().getTime() - parse.getTime(), TimeUnit.MILLISECONDS);
} catch (ParseException e) {
e.printStackTrace();
return -1;
}
}
private static String getNormalHumanDate(String str) {
String[] split = str.split(ExifInterface.GPS_DIRECTION_TRUE);
return split[1].split("\\+")[0] + " " + split[0];
}
}
@@ -0,0 +1,7 @@
package ru.vtosters.lite.provider;
import android.support.v4.content.FileProvider;
/* compiled from: VKFileProvider.kt */
public final class VKFileProvider extends FileProvider {
}
@@ -0,0 +1,72 @@
package ru.vtosters.lite.tgs;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import ru.vtosters.lite.utils.Helper;
public class TGPref {
private static SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
private static String
CNCT_METHOD = "VTGS:CM",
TG_BOTKEY = "VTGS:BKey",
TG_PROXYIP = "VTGS:PIP",
TG_PROXYPORT = "VTGS:PPT",
TG_PROXYPASS = "VTGS:PPS",
TG_PROXYUSER = "VTGS:PUS",
TG_PROXYUSEPASS = "VTGS:PUsePassword";
public static int getTGConnectMethod() {
return Integer.parseInt(Prefs.getString(CNCT_METHOD, "0"));
}
public static void setTGConnectMethod(int method) {
Prefs.edit().putString(CNCT_METHOD, String.valueOf(method)).apply();
}
public static String getTGBotKey() {
return Prefs.getString(TG_BOTKEY, null);
}
public static void setTGBotKey(String key) {
Prefs.edit().putString(TG_BOTKEY, key).apply();
}
public static String getTGProxyIP() {
return Prefs.getString(TG_PROXYIP, null);
}
public static int getTGProxyPort() {
return Prefs.getInt(TG_PROXYPORT, 0);
}
public static void setTGProxyPort(int port) {
Prefs.edit().putInt(TG_PROXYPORT, port).apply();
}
public static String getTGProxyPass() {
return Prefs.getString(TG_PROXYPASS, "");
}
public static String getTGProxyUser() {
return Prefs.getString(TG_PROXYUSER, "");
}
public static void setTGProxyIP(String ip) {
Prefs.edit().putString(TG_PROXYIP, ip).apply();
}
public static void setTGProxyUserPass(String user, String pass) {
Prefs.edit().putString(TG_PROXYUSER, user).putString(TG_PROXYPASS, pass)
.apply();
}
public static boolean isTGProxyPassEnabled() {
return Prefs.getBoolean(TG_PROXYUSEPASS, false);
}
public static void setTGProxyPassEnabled(boolean en) {
Prefs.edit().putBoolean(TG_PROXYUSEPASS, en).apply();
}
}
@@ -0,0 +1,155 @@
package ru.vtosters.lite.tgs;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import com.aefyr.tsg.g2.TelegramStickersPack;
import com.aefyr.tsg.g2.TelegramStickersService;
import com.vk.dto.common.Attachment;
import com.vk.dto.stickers.StickerItem;
import com.vk.dto.stickers.StickerStockItem;
import com.vk.im.engine.models.attaches.Attach;
import com.vtosters.lite.attachments.PendingGraffitiAttachment;
import com.vtosters.lite.im.AppAttachToImAttachConverter;
import com.vtosters.lite.upload.Upload;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
import java.util.Stack;
import ru.vtosters.lite.utils.Helper;
public class TGRoot {
private final static Stack<Integer> pendingStickers = new Stack<>();
public static final int N = 76820000;
public static final int X = 976820000;
private static String TAG = "TGRoot";
public static String getSummary() {
switch (TGPref.getTGConnectMethod()) {
case 0:
return Helper.getString("ctypedirect");
case 2:
return Helper.getString("ctypesocks");
default:
return Helper.getString("ctypedisabled");
}
}
public static Attachment processSticker(StickerItem item) {
int id = item.b();
if (id < N) return null;
int index = (id - N) / 120;
int stickerId = (id - N) % 120;
TelegramStickersPack pack = null;
for (TelegramStickersPack p : TelegramStickersService.getInstance(Helper.GetContext()).getActivePacksListReference()) {
if (p.index == index) {
pack = p;
break;
}
}
String image = pack.getStickerFile(stickerId).getAbsolutePath();
Bitmap bm = BitmapFactory.decodeFile(image);
int upid = Upload.a();
pendingStickers.push(upid);
Attachment att = new PendingGraffitiAttachment(upid, 0, image, bm.getWidth(), bm.getHeight(), null);
bm.recycle();
return att;
}
public static void injectStickers(List<StickerStockItem> list) {
try {
List<TelegramStickersPack> packs = TelegramStickersService.getInstance(Helper.GetContext()).getActivePacksListReference();
for (int i = packs.size() - 1; i >= 0; i--)
list.add(0, toStickerPack(packs.get(i)));
} catch (Exception e) {
e.printStackTrace();
}
}
public static StickerStockItem getPackBySticker(int stickerId) {
if (stickerId < N) return null;
int index = (stickerId - N) / 120;
TelegramStickersPack p = null;
for (TelegramStickersPack p_ : TelegramStickersService.getInstance(Helper.GetContext())
.getActivePacksListReference()) {
if (p_.index == index) {
p = p_;
break;
}
}
if (p == null) return null;
try {
return toStickerPack(p);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private static StickerStockItem toStickerPack(TelegramStickersPack p) throws JSONException {
JSONArray arr = new JSONArray();
for (int j = 0; j < p.stickersCount; j++)
arr.put(new JSONObject().put("sticker_id", N + p.index * 120 + j)
.put("images", new JSONArray()
.put(new JSONObject()
.put("width", 512)
.put("height", 512)
.put("url", "file://" + p.getStickerFile(j).getAbsolutePath())))
.put("images_with_background", new JSONArray()
.put(new JSONObject()
.put("width", 512)
.put("height", 512)
.put("url", "file://" + p.getStickerFile(j).getAbsolutePath())))
);
String photo = "file://" + p.getStickerFile(0).getAbsolutePath();
return StickerStockItem.a(new JSONObject()
.put("product", new JSONObject()
.put("id", X + p.index)
.put("type", "stickers")
.put("title", p.title)
.put("purchased", 1)
.put("active", 1)
.put("promoted", 0)
.put("previews", new JSONArray()
.put(new JSONObject()
.put("url", photo)
.put("width", 102)
.put("height", 102)
))
.put("stickers", arr))
.put("free", 1)
.put("can_purchase", 1)
.put("new", 1)
.put("photo_35", photo)
.put("photo_70", photo)
.put("photo_140", photo)
.put("photo_296", photo)
.put("photo_592", photo), X + p.index);
}
public static Attach modifyStickerIM(int i, StickerItem stickerItem, String str) {
if (stickerItem.b() < 76820000) {
return AppAttachToImAttachConverter.a.a(i, stickerItem, str);
}
return AppAttachToImAttachConverter.a.a(processSticker(stickerItem));
}
}
@@ -0,0 +1,195 @@
package ru.vtosters.lite.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.preference.PreferenceManager;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
import com.vtosters.lite.ui.MaterialSwitchPreference;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.utils.Themes;
public class PreferencesUtil {
public interface EditTextPrefChangeListener {
boolean onChanged(Preference preference, Object obj);
}
public static Drawable setTint(Context ctx, Drawable d) {
d.setColorFilter(Themes.getAccentColor(), PorterDuff.Mode.SRC_ATOP);
return d;
}
public static void addListPreference(MaterialPreferenceToolbarFragment fragment, String key, String def, CharSequence title, CharSequence[] entries, CharSequence[] entriesValue) {
ListPreference preference = new ListPreference(Helper.GetContext());
preference.a(entries);
preference.b(entriesValue);
preference.c(title); // setTitle
preference.a(title); // setDialogTitle
preference.d(key); // setKey
preference.b(def); // setDefaultValue
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment materialPreferenceToolbarFragment, String key, CharSequence title, CharSequence summary, boolean defValue) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(Helper.GetContext());
materialSwitchPreference.c(title); // setTitle
materialSwitchPreference.b(summary); // setSummary
materialSwitchPreference.d(key); // setKey
materialSwitchPreference.b(Boolean.valueOf(defValue)); // setDefaultValue
materialPreferenceToolbarFragment.ay().d(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference)
}
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, int icon, boolean defValue, Preference.b listener) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(Helper.GetContext());
materialSwitchPreference.c(title); // setTitle
materialSwitchPreference.b(summary); // setSummary
materialSwitchPreference.d(key); // setKey
materialSwitchPreference.b(Boolean.valueOf(defValue)); // setDefaultValue
materialSwitchPreference.a(listener); // setOnPreferenceClickListener
if (icon != 1)
materialSwitchPreference.a(setTint(Helper.GetContext(), ContextCompat.getDrawable(Helper.GetContext(), icon))); // preference.setIcon
fragment.ay().d(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, String icon, boolean defValue, Preference.b listener) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(Helper.GetContext());
materialSwitchPreference.c(title); // setTitle
materialSwitchPreference.b(summary); // setSummary
materialSwitchPreference.d(key); // setKey
materialSwitchPreference.b(Boolean.valueOf(defValue)); // setDefaultValue
fragment.ay().d(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference)
if (icon != null)
materialSwitchPreference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon
materialSwitchPreference.a(listener); // setOnPreferenceClickListener(listener)
fragment.ay().d(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary) {
Preference preference = new Preference(Helper.GetContext());
preference.b(summary); // setSummary
preference.c(title); // setTitle
preference.d(key); // setKey
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreference(MaterialPreferenceToolbarFragment fragment, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) {
Preference preference = new Preference(Helper.GetContext());
preference.b(summary); // setSummary
preference.c(title); // setTitle
if (icon != null)
preference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon
preference.a(listener); // preference.setOnPreferenceClickListener(listener)
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) {
Preference preference = new Preference(Helper.GetContext());
preference.b(summary); // setSummary
preference.c(title); // setTitle
preference.d(key); // setKey
if (icon != null)
preference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon
preference.a(listener); // preference.setOnPreferenceClickListener(listener)
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title) {
PreferenceCategory preference = new PreferenceCategory(Helper.GetContext(), null);
preference.c(title); // setTitle
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title, int collapsedSize) {
PreferenceCategory preference = new PreferenceCategory(Helper.GetContext(), null);
preference.c(title); // setTitle
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static void addEditTextPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, EditTextPrefChangeListener editTextPrefChangeListener) {
Preference preference = new Preference(Helper.GetContext());
preference.c(title); // setTitle
preference.d(key); // setKey
preference.a(preference1 -> {
LinearLayout linearLayout = new LinearLayout(Helper.GetContext());
final EditText editText = new EditText(Helper.GetContext());
editText.setText(PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()).getString(key, ""));
editText.setHint(title);
editText.setHintTextColor(PreferencesUtil.getSTextColor(Helper.GetContext()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
} else {
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
}
linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0);
editText.setLayoutParams(margin);
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.p());
builder.setTitle(title);
builder.setView(linearLayout);
builder.setPositiveButton("OK", (dialog, which) -> {
boolean change = editTextPrefChangeListener.onChanged(preference, editText.getText().toString());
if (!change)
return;
PreferenceManager.getDefaultSharedPreferences(Helper.GetContext())
.edit()
.putString(key, editText.getText().toString())
.apply();
});
builder.show();
return false;
}); // preference.setOnPreferenceClickListener(listener)
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
}
public static int getTextColor(Context ctx) {
TypedValue typedValue = new TypedValue();
ctx.getTheme().resolveAttribute(Themes.getTextAttr(), typedValue, true);
return typedValue.data;
}
public static int getSTextColor(Context ctx) {
TypedValue typedValue = new TypedValue();
ctx.getTheme().resolveAttribute(Themes.getSTextAttr(), typedValue, true);
return typedValue.data;
}
private static Drawable getDrawable(Context ctx, String name) {
var id = ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName());
return ContextCompat.getDrawable(ctx, id);
}
}
@@ -0,0 +1,46 @@
package ru.vtosters.lite.ui.dialogs;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.utils.OEMDetector;
import ru.vtosters.lite.utils.Prefs;
public class DisableBattery {
public static void alert(Activity activity) {
if (OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && Prefs.BooleanTrue("showDoze")) {
final Context context = Helper.GetContext();
if (!((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Выключите оптимизацию батареи!");
builder.setMessage("Из-за того, что Вы используете оболочку из списка ниже - уведомления могут приходить с задержкой или не приходить вовсе. \n Для того, чтобы это исправить - нажмите на кнопку \"Отключить оптимизацию\". \n\nПрошивки на которых наблюдаются проблемы с пушами:\nFlyme, EMUI, MIUI, ColorOS, Samsung Experience или TouchWiz, Magic UI, ZenUI, Funtouch OS");
builder.setCancelable(false);
builder.setPositiveButton("Отключить оптимизацию", new DialogInterface.OnClickListener() {
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS");
StringBuilder sb = new StringBuilder();
sb.append("package:");
sb.append(context.getPackageName());
intent.setData(Uri.parse(sb.toString()));
context.startActivity(intent);
}
});
builder.setNeutralButton("Игнорировать", new DialogInterface.OnClickListener() {
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showDoze", false).apply();
}
});
builder.show();
}
}
}
}
@@ -0,0 +1,48 @@
package ru.vtosters.lite.ui.dialogs;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import com.vk.navigation.Navigator;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.utils.Prefs;
import ru.vtosters.lite.ui.fragments.InstallGMSFragment;
public class InstallGMS {
public static void alert(final Activity activity) {
if (!Helper.IsGmsInstalled()) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Внимание!");
builder.setMessage(Text());
builder.setCancelable(false);
builder.setPositiveButton("Продолжить без GMS", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlertGms", false).apply();
}
});
builder.setNeutralButton("Установить GMS", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlertGms", false).apply();
Context context = Helper.GetContext();
Intent a2 = new Navigator(InstallGMSFragment.class).a(context);
context.startActivity(a2);
}
});
if (Prefs.BooleanTrue("showAlertGms")) {
builder.show();
}
}
}
private static String Text() {
return "На вашем устройстве отсутствует компонент Google Play Services (GMS), который необходим для корректной работы VTosters Lite";
}
}
@@ -0,0 +1,51 @@
package ru.vtosters.lite.ui.dialogs;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.utils.OEMDetector;
import ru.vtosters.lite.utils.Prefs;
public class Start {
public static void alert(final Activity activity) {
if (Build.VERSION.SDK_INT >= 23) {
activity.requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228);
}
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Внимание!");
builder.setMessage(getWelcome());
builder.setCancelable(false);
builder.setPositiveButton("Продолжить", new DialogInterface.OnClickListener() {
/* class ru.vtosters.lite.utils.lite.dialog.Start.AnonymousClass1 */
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlert", false).apply();
}
});
builder.setNeutralButton("Новости", new DialogInterface.OnClickListener() {
/* class ru.vtosters.lite.utils.lite.dialog.Start.AnonymousClass2 */
@Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlert", false).apply();
activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters")));
}
});
if (Prefs.BooleanTrue("showAlert")) {
builder.show();
}
}
private static String getWelcome() {
if (!OEMDetector.isOEM()) {
return "Модификация VTosters Lite не имеет никакого отношения к VK Group!\nРаспространяется полностью бесплатно!";
}
return "Модификация VTosters Lite не имеет никакого отношения к VK Group!\nРаспространяется полностью бесплатно!\n\nПриложение может некорректно работать в связи с тем, что вы, скорее всего, используете оболочку из списка ниже. Все проблемы с отображением и работой приложения связаны только с вашей прошивкой и только с ней. Все багрепорты, присланные из-за проблем на этой прошивке, не рассматриваются разработчиками и не будут исправлены.\n\nНажимая на кнопку \"Продолжить\", вы соглашаетесь с тем, что возможные баги приложения могут произойти из-за специфики вашей прошивки. Рекомендуем использовать прошивки на базе AOSP для получения максимальной стабильности.\n\nПрошивки на которых наблюдаются проблемы с приложениями:\nFlyme, EMUI, MIUI, ColorOS, Samsung Experience или TouchWiz, Magic UI, ZenUI, Funtouch OS";
}
}
@@ -0,0 +1,16 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
import com.vtosters.lite.R;
public class ActivityFragment extends MaterialPreferenceToolbarFragment {
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_activity);
}
}
@@ -0,0 +1,15 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import com.vtosters.lite.R;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
public class FeedFragment extends MaterialPreferenceToolbarFragment {
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_feed);
}
}
@@ -0,0 +1,15 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import com.vtosters.lite.R;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
public class InstallGMSFragment extends MaterialPreferenceToolbarFragment {
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_gms);
}
}
@@ -0,0 +1,40 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import com.vk.core.util.ToastUtils;
import com.vtosters.lite.R;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
/* renamed from: ru.vtosters.lite.utils.lite.ui.activities.interface reason: invalid class name */
public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_interface);
prefs();
}
/* access modifiers changed from: package-private */
/* renamed from: ru.vtosters.lite.utils.lite.ui.activities.interface$a */
public class a implements Preference.b {
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
return InterfaceFragment.this.restart(preference, obj);
}
a() {
}
}
private void prefs() {
a("newfeed").a((Preference.b) new a());
}
public /* synthetic */ boolean restart(Preference preference, Object obj) {
ToastUtils.a("Пожалуйста перезапустите приложение");
return true;
}
}
@@ -0,0 +1,15 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import com.vtosters.lite.R;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
public class MessagesFragment extends MaterialPreferenceToolbarFragment {
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_messages);
}
}
@@ -0,0 +1,14 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import com.vtosters.lite.R;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
public class MusicFragment extends MaterialPreferenceToolbarFragment {
@Override
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_music);
}
}
@@ -0,0 +1,119 @@
package ru.vtosters.lite.ui.fragments;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.widget.Toast;
import com.vk.audio.AudioMessageUtils;
import com.vk.auth.api.VKAccount;
import com.vk.core.f.FileUtils;
import com.vk.core.util.AppContextHolder;
import com.vk.core.util.ToastUtils;
import com.vk.imageloader.VKImageLoader;
import com.vk.pushes.PushSubscriber;
import com.vtosters.lite.R;
import com.vtosters.lite.auth.VKAccountManager;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
import com.vtosters.lite.im.ImEngineProvider;
import ru.vtosters.lite.utils.Helper;
public class OtherFragment extends MaterialPreferenceToolbarFragment {
/* access modifiers changed from: package-private */
static class c implements Preference.c {
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
copy(Helper.GetContext(), Helper.GetUserToken());
return true;
}
public static void copy(Context context, String str) {
((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", str));
Toast.makeText(context, Helper.getString("copybtn"), Toast.LENGTH_SHORT).show();
ToastUtils.a(Helper.getString("tokenwarning"));
}
c() {
}
}
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_other);
prefs();
}
/* access modifiers changed from: package-private */
public class e implements Preference.c {
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
VKImageLoader.b();
ImEngineProvider.a().h();
AudioMessageUtils.j();
FileUtils.l();
ToastUtils.a(Helper.getString("cachecleaned"));
return true;
}
e() {
}
}
/* access modifiers changed from: package-private */
public class b implements Preference.c {
b() {
}
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
System.exit(0);
return true;
}
}
/* access modifiers changed from: package-private */
public class d implements Preference.c {
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
Helper.restarting();
return true;
}
d() {
}
}
/* access modifiers changed from: package-private */
public class a implements Preference.c {
a() {
}
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
VKAccount b = VKAccountManager.b();
PushSubscriber.a.a(b.b(), b.c());
ToastUtils.a(Helper.getString("fcmtokenrem"));
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
OtherFragment.this.aB().postDelayed(() -> {
PushSubscriber.a.a(true);
ToastUtils.a(Helper.getString("fcmtokenget"));
ToastUtils.a(Helper.getString("fcmtokenfixed"));
}, 1000);
return true;
}
}
private void prefs() {
a("firebasefix").a((Preference.c) new a());
a("applicationstop").a((Preference.c) new b());
a("tokencopy").a((Preference.c) new c());
a("applicationrestart").a((Preference.c) new d());
a("clearcache").a((Preference.c) new e());
}
}
@@ -0,0 +1,15 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import com.vtosters.lite.R;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
public class ProxySettingsFragment extends MaterialPreferenceToolbarFragment {
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_proxy);
}
}
@@ -0,0 +1,47 @@
package ru.vtosters.lite.ui.fragments;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import com.vk.core.util.ToastUtils;
import com.vtosters.lite.R;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.utils.IconHelper;
public class ThemesFragment extends MaterialPreferenceToolbarFragment {
/* access modifiers changed from: package-private */
public class a implements Preference.b {
public /* synthetic */ a() {
}
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
return ThemesFragment.this.apply(preference, obj);
}
}
@Override
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
public void b(Bundle bundle) {
super.b(bundle);
a(R.xml.preferences_themes);
prefs();
}
public /* synthetic */ boolean apply(Preference preference, Object obj) {
if (((Boolean) obj).booleanValue()) {
IconHelper.switchToVK();
} else {
IconHelper.switchToDefault();
}
ToastUtils.a(Helper.getString("iconapplying"));
return true;
}
private void prefs() {
a("iconvk").a((Preference.b) new a());
}
}
@@ -0,0 +1,407 @@
package ru.vtosters.lite.ui.fragments.tgstickers;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.ColorStateList;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.SwitchCompat;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.aefyr.tsg.g2.TelegramStickersPack;
import com.aefyr.tsg.g2.TelegramStickersService;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.vk.navigation.Navigator;
import com.vtosters.lite.R;
import java.io.File;
import me.grishka.appkit.fragments.ToolbarFragment;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.ui.PreferencesUtil;
import ru.vtosters.lite.utils.Prefs;
import ru.vtosters.lite.utils.Themes;
public class StickersFragment extends ToolbarFragment {
public final static String ACTION_RELOAD = "com.vtosters.lite.action.RELOAD_TGS_LIST";
private final static int TYPE_DIRECT = 0, TYPE_SOCKS = 2, TYPE_TOASTER_SERVER = 3;
private TelegramStickersGrabber grabber;
private TelegramStickersService stickersService;
private FloatingActionButton fab;
private static final String TAG = "StickersFragment";
@SuppressWarnings("rawtypes")
private RecyclerView.Adapter adapter;
private boolean movePending = false;
public int from;
public int to;
private int editPadding;
private RecyclerView recycler;
private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (ACTION_RELOAD.equals(intent.getAction())) {
if (adapter != null) {
try {
if (movePending) {
movePending = false;
adapter.notifyItemMoved(from, to);
from = -1;
to = -1;
} else {
adapter.notifyDataSetChanged();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
};
private void initGrabber() {
int method = TGPref.getTGConnectMethod();
switch (method) {
case TYPE_TOASTER_SERVER:
case TYPE_DIRECT:
TelegramStickersGrabber.USE_PROXY = false;
grabber.resetProxy();
break;
case TYPE_SOCKS:
if (TGPref.getTGProxyIP() != null) {
TelegramStickersGrabber.USE_PROXY = true;
TelegramStickersGrabber.PROXY_IP = TGPref.getTGProxyIP();
TelegramStickersGrabber.PROXY_PORT = TGPref.getTGProxyPort();
if (TGPref.isTGProxyPassEnabled()) {
TelegramStickersGrabber.HAS_PASS = true;
TelegramStickersGrabber.PROXY_USER = TGPref.getTGProxyUser();
TelegramStickersGrabber.PROXY_PASS = TGPref.getTGProxyPass();
}
grabber.enableProxy();
}
break;
}
TelegramStickersGrabber.updateURLs();
}
private void openMenu(String toast) {
if (toast != null) {
Toast.makeText(super.n(), toast, Toast.LENGTH_SHORT).show();
}
var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).a(super.n());
super.n().startActivity(intent);
}
@Override
public void a(Menu menu, MenuInflater menuInflater) {
super.a(menu, menuInflater);
MenuItem add = menu.add(0, 0, 0, "");
add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
add.setIcon(Helper.getResources().getDrawable(com.vtosters.lite.R.drawable.ic_settings_24));
}
@Override
public boolean a_(MenuItem arg0) {
openMenu(null);
return true;
}
private void enterBotKey(Runnable r) {
LinearLayout linearLayout = new LinearLayout(super.n());
final EditText editText = new EditText(super.n());
editText.setHintTextColor(PreferencesUtil.getSTextColor(super.n()));
// Костыль для китката
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(super.n())));
} else {
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(super.n())));
}
linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0);
editText.setLayoutParams(margin);
new AlertDialog.Builder(super.n())
.setTitle(Helper.getString("stickersapi5"))
.setMessage(Helper.getString("stickersapi6"))
.setView(linearLayout)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
TGPref.setTGBotKey(editText.getText().toString());
if (r != null) r.run();
}).setNegativeButton(android.R.string.cancel, null).setNeutralButton(Helper.getString("stickersapi7"), (dialog, which) -> new AlertDialog.Builder(super.n())
.setTitle(Helper.getString("stickersapi8"))
.setMessage(Helper.getString("stickersapi9") +
Helper.getString("stickersapi10")).setPositiveButton(android.R.string.ok, null)
.create().show()).create().show();
}
private void checkApiKey(final Runnable r) {
grabber.setBotApiKey(TGPref.getTGBotKey());
var context = super.n();
final ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage(Helper.getString("stickersapi1"));
progressDialog.show();
grabber.checkKey(new TelegramStickersGrabber.KeyCheckListener() {
@Override
public void onKeyChecked(boolean ok) {
progressDialog.dismiss();
if (!ok) {
Toast.makeText(context, Helper.getString("stickersapi2"), Toast.LENGTH_SHORT).show();
return;
}
stickersService.setBotKey(TGPref.getTGBotKey());
if (r != null) r.run();
}
@Override
public void onNetError() {
progressDialog.dismiss();
new AlertDialog.Builder(context)
.setMessage(Helper.getString("stickersapi3"))
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(Helper.getString("stickersapi4"), (arg0, arg1) -> checkApiKey(r)).create().show();
}
});
}
@SuppressWarnings("rawtypes")
@NonNull
@Override
public View d(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
grabber = new TelegramStickersGrabber(TGPref.getTGBotKey());
stickersService = TelegramStickersService.getInstance(Helper.GetContext());
editPadding = Helper.convertDpToPixel(24f);
FrameLayout v = new FrameLayout(container.getContext());
recycler = new RecyclerView(container.getContext());
recycler.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
fab = new FloatingActionButton(container.getContext());
fab.setImageResource(R.drawable.ic_add_24);
fab.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor()));
fab.setOnClickListener(v2 -> fabClick());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
params.setMargins(0, 0, 0, Helper.convertDpToPixel(12f));
fab.setLayoutParams(params);
v.addView(recycler);
v.addView(fab);
recycler.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
recycler.setAdapter(new StickerPackAdapter());
return v;
}
private void fabClick() {
int method = TGPref.getTGConnectMethod();
Runnable r = () -> {
initGrabber();
switch (method) {
case TYPE_SOCKS:
if (TGPref.getTGProxyIP() == null) {
openMenu(Helper.getString("stickersproxy1"));
return;
}
case TYPE_TOASTER_SERVER:
case TYPE_DIRECT:
final Runnable work = () -> {
LinearLayout linearLayout = new LinearLayout(super.n());
final EditText editText = new EditText(super.n());
editText.setHintTextColor(PreferencesUtil.getSTextColor(Helper.GetContext()));
// Костыль для китката
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
} else {
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
}
linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0);
editText.setLayoutParams(margin);
new AlertDialog.Builder(super.n()).setTitle(Helper.getString("stickershelp1"))
.setMessage(Helper.getString("stickershelp2"))
.setView(linearLayout)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
String pack = editText.getText().toString();
pack = parsePack(pack);
stickersService.requestPackDownload(pack, new File(Helper.GetContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
}).setNeutralButton(android.R.string.cancel, null).create().show();
};
if (TGPref.getTGBotKey() == null) enterBotKey(() -> checkApiKey(work));
else checkApiKey(work);
break;
}
};
if (method == -1) {
openMenu(Helper.getString("stickersconnection"));
} else {
r.run();
}
}
@Override
public void b(@Nullable Bundle savedInstanceState) {
super.b(savedInstanceState);
Helper.GetContext().registerReceiver(receiver, new IntentFilter(ACTION_RELOAD));
}
@Override
public void a(View arg0, Bundle arg1) {
o_(true);
super.a(arg0, arg1);
a(Helper.getString("vtltgs"));
}
@Override
public void A_() {
super.A_();
Helper.GetContext().unregisterReceiver(receiver);
}
private String parsePack(String pack) {
if (pack.startsWith("https://t.me/addstickers/")) {
pack = pack.substring(25);
} else if (pack.startsWith("https://telegram.me/addstickers/")) {
pack = pack.substring(32);
}
return pack;
}
public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.StickerPackViewHolder> {
private String TAG = "StickerPackAdapter";
public class StickerPackViewHolder extends RecyclerView.ViewHolder {
private SwitchCompat switchCompat;
private ImageView stickerImage, updateButton, deleteButton;
private TextView name, count;
private LinearLayout layout;
StickerPackViewHolder(@NonNull View view) {
super(view);
switchCompat = (SwitchCompat) view.findViewById(R.id.choose_btn);
stickerImage = (ImageView) view.findViewById(R.id.photo);
updateButton = (ImageView) view.findViewById(R.id.button_update);
deleteButton = (ImageView) view.findViewById(R.id.action_delete);
name = (TextView) view.findViewById(R.id.vkim_cancel);
count = (TextView) view.findViewById(R.id.vkim_cancel_label_text);
layout = (LinearLayout) view.findViewById(R.id.linearLayout5);
}
}
@NonNull
@Override
public StickerPackViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
var view = LayoutInflater.from(parent.getContext()).inflate(Helper.getIdentifier("tgs_entry", "layout"), parent, false);
return new StickerPackViewHolder(view);
}
@Override
public int getItemViewType(int position) {
final TelegramStickersPack pack = stickersService.getPacksListReference().get(position);
return pack.state == TelegramStickersPack.DOWNLOADED ? 0 : 1;
}
@Override
public void onBindViewHolder(@NonNull final StickerPackViewHolder holder, int position) {
final TelegramStickersPack pack = stickersService.getPacksListReference().get(position);
if (pack.state != TelegramStickersPack.DOWNLOADED) return;
File f = new File(pack.folder, "001.png");
try {
if (f.exists()) {
holder.stickerImage.setImageURI(Uri.parse("file://" + f.getAbsolutePath()));
} else {
holder.stickerImage.setImageDrawable(Helper.getResources().getDrawable(R.drawable.icon_vk_104));
}
} catch (Exception e) {
e.printStackTrace();
}
holder.updateButton.setImageDrawable(Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.ic_camera_switch_48)));
holder.updateButton.setOnClickListener(listener -> {
stickersService.setBotKey(TGPref.getTGBotKey());
stickersService.requestPackDownload(pack.id, new File(Helper.GetContext().getFilesDir(), new File("VT-Stickers", pack.id).getAbsolutePath()));
});
holder.deleteButton.setImageDrawable(Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.vkim_ic_msg_delete)));
holder.deleteButton.setOnClickListener(listener -> {
stickersService.deletePack(pack);
notifyItemRemoved(position);
notifyItemRangeChanged(position, getItemCount());
});
holder.name.setText(pack.title);
holder.switchCompat.setChecked(pack.enabled);
holder.switchCompat.setOnCheckedChangeListener((buttonView, isChecked) -> stickersService.setPackEnabled(pack, isChecked, false));
holder.count.setText(pack.stickersCount + " " + Helper.getString("stickerscount"));
holder.layout.setBackgroundColor(Prefs.getNavbarColor());
// Color костыль
int color = Themes.getTextAttr();
int secondary = Themes.getSTextAttr();
holder.name.setTextColor(color);
holder.count.setTextColor(secondary);
}
@Override
public int getItemCount() {
return stickersService.getPacksListReference().size();
}
}
}
@@ -0,0 +1,89 @@
package ru.vtosters.lite.ui.fragments.tgstickers;
import android.os.Bundle;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
import com.vk.core.util.ToastUtils;
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.tgs.TGPref;
import ru.vtosters.lite.tgs.TGRoot;
import ru.vtosters.lite.utils.Helper;
import ru.vtosters.lite.ui.PreferencesUtil;
public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragment {
@Override
public void b(Bundle bundle) {
super.b(bundle);
int vtosterXml = Helper.GetContext().getResources().getIdentifier("empty", "xml", Helper.GetContext().getPackageName());
this.a(vtosterXml);
PreferencesUtil.addPreferenceCategory(this, Helper.getString("sprefsstickers"));
PreferencesUtil.addPreference(this, "", Helper.getString("sprefsdelkey"), "", null, preference -> {
TGPref.setTGBotKey(null);
ToastUtils.a(Helper.getString("sprefsdelkey2"));
return false;
});
PreferencesUtil.addPreferenceCategory(this, Helper.getString("sprefsnetwork"));
PreferencesUtil.addListPreference(this, "VTGS:CM", "0", Helper.getString("sprefsctype"), new CharSequence[]{
Helper.getString("ctypedirect"), Helper.getString("ctypesocks")
}, new String[]{
"0", "2"
});
a("VTGS:CM").b(TGRoot.getSummary());
a("VTGS:CM").a((preference, o) -> {
String newData = (String) o;
TGPref.setTGConnectMethod(Integer.parseInt(newData));
TelegramStickersGrabber.updateURLs();
preference.b(TGRoot.getSummary()); // setTitle
return true;
});
PreferencesUtil.addPreferenceCategory(this, Helper.getString("ssocks"));
PreferencesUtil.addEditTextPreference(this, "tg_proxy_host", Helper.getString("ssockshost"), (preference, o) -> {
TGPref.setTGProxyIP((String) o);
return true;
});
PreferencesUtil.addEditTextPreference(this, "tg_proxy_port", Helper.getString("ssocksport"), (preference, o) -> {
try {
TGPref.setTGProxyPort(Integer.parseInt((String) o));
return true;
} catch (Exception e) {
ToastUtils.a(Helper.getString("ssockswport"));
return false;
}
});
PreferencesUtil.addMaterialSwitchPreference(this, "tg_proxy_auth", Helper.getString("ssocksauth"), "", null, false, (preference, o) -> {
boolean value = (boolean) o;
a("tg_proxy_login").a(value); // findPreference("tg_proxy_login").setEnabled(value);
a("tg_proxy_pass").a(value); // findPreference("tg_proxy_pass").setEnabled(booleanValue);
TGPref.setTGProxyPassEnabled(value);
return true;
});
PreferencesUtil.addEditTextPreference(this, "tg_proxy_login", Helper.getString("ssockslogin"), (preference, o) -> {
TGPref.setTGProxyUserPass((String) o, TGPref.getTGProxyPass());
return true;
});
PreferencesUtil.addEditTextPreference(this, "tg_proxy_pass", Helper.getString("ssockspass"), (preference, o) -> {
TGPref.setTGProxyUserPass(TGPref.getTGProxyUser(), (String) o);
return true;
});
a("tg_proxy_login").a(TGPref.isTGProxyPassEnabled());
a("tg_proxy_pass").a(TGPref.isTGProxyPassEnabled());
}
@Override
public int aq() {
return Helper.GetContext().getResources().getIdentifier("vtltgs", "string", Helper.GetContext().getPackageName());
}
}
@@ -0,0 +1,55 @@
package ru.vtosters.lite.ui.vkui;
import android.app.Activity;
import android.content.DialogInterface;
import android.view.View;
import com.vk.core.dialogs.bottomsheet.ModalBottomSheet;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.Helper;
public class ModalBottomSheetProxy {
public final ModalBottomSheet.a builder;
public ModalBottomSheetProxy(Activity activity) {
builder = new ModalBottomSheet.a(activity);
}
public void setTitle(String title) {
builder.b(title);
}
public void setClickableMessage(String text) {
builder.a(text, kostil -> {
});
}
public void setClickableMessage(String text, Runnable runnable) {
builder.a(text, listener -> runnable.run());
}
public void setPositiveButton(String text, Runnable runnable) {
builder.b(text, kostil -> runnable.run());
}
public void setSubtitle(String text) {
builder.b((CharSequence) text);
}
public void setView(View view) {
builder.a(view);
}
public ModalBottomSheet show() {
return builder.c(null);
}
public ModalBottomSheet show(boolean isCancellable) {
var sheet = builder.c(null);
sheet.b(isCancellable);
return sheet;
}
}
@@ -0,0 +1,155 @@
package ru.vtosters.lite.utils;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.net.Uri;
import android.os.Build;
import android.util.Log;
import com.vk.dto.common.VideoFile;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ExternalLinkHandler {
private static final String TAG = "ExternalLinkHandler";
private static final List<String> filters = Arrays.asList(
"youtube.com",
"www.youtube.com",
"youtu.be",
"m.youtube.com"
);
private static final Map<String, String> qualities = new HashMap<>();
public static boolean parseVideoFile(VideoFile file, Context context) {
if (!Prefs.isEnableExternalOpening()) return false;
if (checkYoutubeLink(file)) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(file.n));
context.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
} else if (checkVkVideo(file)) {
if (qualities.size() == 1) {
startExternalVideo((String) qualities.values().toArray()[0]);
} else {
String[] titles = qualities.keySet().toArray(new String[0]);
new AlertDialog.Builder(context)
.setItems(titles, ((dialog, which) -> {
startExternalVideo(qualities.get(titles[which]));
}))
.show();
}
}
return true;
}
private static boolean checkYoutubeLink(VideoFile file) {
if (!Helper.isEmpty(file.n)) {
for (String filter : filters) {
if (file.n.contains(filter))
return true;
}
}
return false;
}
/**
* this.e = var3.optString("mp4_240", var3.optString("src"));
* this.f = var3.optString("mp4_360");
* this.g = var3.optString("mp4_480");
* this.h = var3.optString("mp4_720");
* this.i = var3.optString("mp4_1080");
* this.j = var3.optString("mp4_1440");
* this.k = var3.optString("mp4_2160");
*/
public static boolean checkVkVideo(VideoFile videoFile) {
if (!Helper.isEmpty(videoFile.e)) {
qualities.put("240", videoFile.e);
}
if (!Helper.isEmpty(videoFile.f)) {
qualities.put("360", videoFile.f);
}
if (!Helper.isEmpty(videoFile.g)) {
qualities.put("480", videoFile.g);
}
if (!Helper.isEmpty(videoFile.h)) {
qualities.put("720", videoFile.h);
}
if (!Helper.isEmpty(videoFile.i)) {
qualities.put("1080", videoFile.i);
}
if (!Helper.isEmpty(videoFile.j)) {
qualities.put("1440", videoFile.j);
}
if (!Helper.isEmpty(videoFile.k)) {
qualities.put("2160", videoFile.k);
}
return qualities.size() > 0;
}
public static boolean startExternalVideo(String url) {
try {
qualities.clear();
Uri uri = Uri.parse(url);
Intent intent = new Intent();
String packageName = getMXPlayerPackageName();
if (!Helper.isEmpty(packageName)) {
intent.setPackage(packageName);
intent.setDataAndType(uri, "application/mp4");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
} else {
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "video/mp4");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
Helper.GetContext().startActivity(intent);
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
private static String getMXPlayerPackageName() {
for (ApplicationInfo info : Helper.GetContext().getPackageManager().getInstalledApplications(0)) {
String packName = info.packageName;
if (packName.equals("com.mxtech.videoplayer.ad") || packName.equals("com.mxtech.videoplayer.pro"))
return packName;
}
return null;
}
}
@@ -0,0 +1,140 @@
package ru.vtosters.lite.utils;
import static android.content.Context.ACTIVITY_SERVICE;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import com.vk.core.util.ToastUtils;
import com.vtosters.lite.UserProfile;
import com.vtosters.lite.api.ExtendedUserProfile;
import com.vtosters.lite.auth.VKAccountManager;
import com.vtosters.lite.im.ImEngineProvider;
import java.lang.reflect.Method;
import java.util.List;
public class Helper {
public static int GetUserId() {
return VKAccountManager.b().a();
}
public static String GetUserSecret() {
return VKAccountManager.b().c();
}
public static String GetUserToken() {
return VKAccountManager.b().b();
}
public static SharedPreferences.Editor edit() {
return PreferenceManager.getDefaultSharedPreferences(GetContext()).edit();
}
public static String getConnectorDomain(String str) {
return Proxy.GetConnector(str);
}
public static void reloadMSG() {
ImEngineProvider.a().h();
}
public static int getUserID(UserProfile userProfile) {
return userProfile.n;
}
public static String getUserFirstName(UserProfile userProfile) {
return userProfile.p;
}
public static String getUserLastName(UserProfile userProfile) {
return userProfile.o;
}
public static int getUserID(ExtendedUserProfile extendedUserProfile) {
return getUserID(fromEup(extendedUserProfile));
}
public static UserProfile fromEup(ExtendedUserProfile extendedUserProfile) {
return extendedUserProfile.a;
}
public static void restarting() {
GetContext().startActivity(Intent.makeRestartActivityTask(GetContext().getPackageManager().getLaunchIntentForPackage(GetContext().getPackageName()).getComponent()));
Runtime.getRuntime().exit(0);
}
@NonNull
public static Context GetContext() {
try {
Class<?> appGlobalsClazz = Class.forName("android.app.AppGlobals");
Method getInitialApplication = appGlobalsClazz.getDeclaredMethod("getInitialApplication");
getInitialApplication.setAccessible(true);
return (Context) getInitialApplication.invoke(null);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static boolean IsGmsInstalled() {
try {
GetContext().getPackageManager().getPackageInfo("com.google.android.gms", 0);
return true;
} catch (Exception unused) {
return false;
}
}
public static Resources getResources() {
return GetContext().getResources();
}
public static int getIdentifier(String str, String str2) {
return getResources().getIdentifier(str, str2, GetContext().getPackageName());
}
public static String getString(String str) {
return Helper.GetContext().getString(Integer.parseInt(String.valueOf(Helper.GetContext().getResources().getIdentifier(str, "string", Helper.GetContext().getPackageName()))));
}
public static String getPackageName() {
return GetContext().getPackageName();
}
public static int convertDpToPixel(float f) {
return (int) (f * (((float) GetContext().getResources().getDisplayMetrics().densityDpi) / 160.0f));
}
public static String GetString(@StringRes int res, Object... args) {
return GetContext().getString(res, args);
}
public static SharedPreferences GetPrefs() {
return PreferenceManager.getDefaultSharedPreferences(GetContext());
}
public static SharedPreferences GetPreferences() {
return PreferenceManager.getDefaultSharedPreferences(GetContext());
}
public static void SendToast(String text) {
ToastUtils.a(text);
}
public static boolean isEmpty(String str) {
return str == null || str.isEmpty();
}
}
@@ -0,0 +1,20 @@
package ru.vtosters.lite.utils;
import android.content.ComponentName;
import android.content.pm.PackageManager;
public class IconHelper {
public static void switchToVK() {
var packageManager = Helper.GetContext().getPackageManager();
var packageName = Helper.getPackageName();
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
public static void switchToDefault() {
var packageManager = Helper.GetContext().getPackageManager();
var packageName = Helper.getPackageName();
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
}
@@ -0,0 +1,58 @@
package ru.vtosters.lite.utils;
import android.text.TextUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class OEMDetector {
public static boolean isOEM() {
return isMIUI() || isEMUI() || isFlyme() || isZenUI() || isSamsung() || isVivo();
}
private static boolean isMIUI() {
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
}
private static boolean isEMUI() {
return !TextUtils.isEmpty(getSystemProperty("ro.build.hw_emui_api_level"));
}
private static boolean isZenUI() {
return !TextUtils.isEmpty(getSystemProperty("ro.asus.ui"));
}
private static boolean isVivo() {
return !TextUtils.isEmpty(getSystemProperty("ro.vivo.os.version")) || !TextUtils.isEmpty(getSystemProperty("ro.vivo.rom")) || !TextUtils.isEmpty(getSystemProperty("ro.vivo.rom.version")) || !TextUtils.isEmpty(getSystemProperty("ro.vivo.build.version.sdk"));
}
private static boolean isSamsung() {
return !TextUtils.isEmpty(getSystemProperty("ro.config.knox"));
}
private static boolean isFlyme() {
return !TextUtils.isEmpty(getSystemProperty("ro.build.ro.meizu.rom.config")) || !TextUtils.isEmpty(getSystemProperty("persist.sys.static_blur_mode")) || !TextUtils.isEmpty(getSystemProperty("persist.sys.use.flyme.icon"));
}
private static String getSystemProperty(String str) {
BufferedReader bufferedReader;
Throwable th;
BufferedReader bufferedReader2 = null;
try {
bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec("getprop " + str).getInputStream()), 1024);
try {
String readLine = bufferedReader.readLine();
try {
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
}
return readLine;
} catch (IOException ignored) {
}
} catch (Throwable ignored) {
}
return null;
}
}
@@ -0,0 +1,834 @@
package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Proxy.setProxy;
import android.app.Activity;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.Window;
import com.vk.about.Items;
import com.vk.about.Items1;
import com.vk.about.Items2;
import com.vk.apps.AppsFragment;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.core.util.Screen;
import com.vk.discover.DiscoverFragment;
import com.vk.fave.fragments.FaveTabFragment;
import com.vk.menu.MenuFragment;
import com.vk.music.fragment.MusicFragment;
import com.vk.navigation.NavigatorKeys;
import com.vk.newsfeed.Feed2049;
import com.vk.notifications.NotificationsContainerFragment;
import com.vtosters.lite.R;
import com.vtosters.lite.VKActivity;
import com.vtosters.lite.data.Users;
import com.vtosters.lite.fragments.GamesFragment;
import com.vtosters.lite.fragments.PhotosFragment;
import com.vtosters.lite.fragments.ProfileFragment;
import com.vtosters.lite.fragments.SettingsListFragment;
import com.vtosters.lite.fragments.d.DocumentsViewFragment;
import com.vtosters.lite.fragments.f.FriendsFragment;
import com.vtosters.lite.fragments.g.BirthdaysFragment;
import com.vtosters.lite.fragments.h.GroupsFragment;
import com.vtosters.lite.fragments.lives.LivesTabsFragment;
import com.vtosters.lite.fragments.m.VideosFragment;
import com.vtosters.lite.fragments.messages.dialogs.DialogsFragment;
import com.vtosters.lite.fragments.money.MoneyTransfersFragment;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
import kotlin.jvm.internal.Intrinsics;
public class Prefs {
public static String VERSIONNAME = "2.0 DEV";
private static List<String> mFilters;
private static List<Activity> activities = new ArrayList<>();
public static boolean BooleanFalse(String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
return prefs.getBoolean(key, false);
}
public static boolean BooleanTrue(String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
return prefs.getBoolean(key, true);
}
public static void ClearCache() {
}
public static String GetBackgroundStickers() {
if (isBGStickersEnabled()) {
return "images_with_background";
}
return "images";
}
public static boolean isBGStickersEnabled() {
return BooleanTrue("isBGStickersEnabled");
}
public static String GetCopyright() {
return copyright_post() ? "null" : "copyright";
}
public static String GetFriendRecomm() {
return friendsrecomm() ? "friends_recommendations" : "null";
}
public static String GetStories() {
return stories() ? "stories" : "null";
}
public static boolean ads() {
return BooleanFalse("__dbg_no_ads");
}
public static boolean adsgroup() {
return BooleanFalse("adsgroup");
}
public static boolean adsslider() {
return BooleanFalse("__dbg_no_slider_ads");
}
public static boolean adsstories() {
return BooleanFalse("adsstories");
}
public static boolean alteremoji(Context context) {
return alteremojipref() ? alteremojipref() : Screen.a(context);
}
public static boolean alteremojipref() {
return BooleanFalse("alteremoji");
}
public static String authorsads() {
return authorsrecomm() ? "authors_rec" : "null";
}
public static boolean authorsrecomm() {
return BooleanTrue("authorsrecomm");
}
public static boolean awayphp() {
return BooleanTrue("awayphp");
}
public static boolean VKUI_INJ() {
return BooleanTrue("VKUI_INJ");
}
public static boolean benchmark() {
return BooleanFalse("benchmark");
}
public static boolean calls() {
return BooleanTrue("calls");
}
public static boolean captions() {
return BooleanTrue("captions");
}
public static boolean convUsersOnline() {
return BooleanFalse("convUsersOnline");
}
public static boolean copyright_post() {
return BooleanTrue("copyright_post");
}
public static boolean darkmode() {
return BooleanTrue("darkmode");
}
public static boolean default_ad_list() {
return BooleanFalse("default_ad_list");
}
public static boolean dev() {
return BooleanFalse("dev");
}
public static boolean devmenu() {
return BooleanFalse("devmenu");
}
public static boolean dnr() {
return BooleanTrue("dnr");
}
public static boolean dns() {
return BooleanTrue("dns");
}
public static boolean dnt() {
return BooleanTrue("dnt");
}
public static boolean dockcounter() {
return BooleanTrue("dockcounter");
}
public static boolean feedautoupdate() {
return BooleanTrue("feedautoupdate");
}
public static boolean feedcache() {
return BooleanTrue("feedcache");
}
public static void forceOffline() {
if (setoffline()) {
Users.b();
}
setupFilters();
}
public static boolean forcenogms() {
return BooleanTrue("forcenogms");
}
public static String friendsads() {
return postsrecomm() ? "user_rec" : "null";
}
public static boolean friendsrecomm() {
return BooleanTrue("friendsrecomm");
}
public static boolean fulltime() {
return BooleanTrue("fulltime");
}
public static boolean gcmfix() {
return BooleanTrue("gcmfix");
}
public static String getAppVersion() throws IOException {
return "VTLite | " + VERSIONNAME + " | " + getBuildNumber();
}
public static String getBuildNumber() {
return Prefs.loadAssetTextAsString(Helper.GetContext(), "version.properties");
}
public static String loadAssetTextAsString(Context context, String name) {
try {
Scanner scanner = new Scanner(context.getAssets().open(name));
while (scanner.hasNextLine()) {
String line = scanner.findInLine("VERSION_BUILD=.+");
if (line != null)
return line.replace("VERSION_BUILD=", "");
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static String getBranch() {
return Helper.GetPreferences().getString("ota_branches", "Stable");
}
public static String getDarkVKUI() {
return !VKThemeHelper.d() ? "1" : "0";
}
public static String getMeToken() {
return Helper.GetPreferences().getString("me_token", "");
}
public static int getNavbarColor() {
return VKThemeHelper.a((int) R.attr.tabbar_background);
}
public static String getSSFSLink() {
return SSFSDomain() + "?token=" + ru.vtosters.lite.utils.Helper.GetUserToken() + "&vt_dark=" + getDarkVKUI() + "&secret=" + ru.vtosters.lite.utils.Helper.GetUserSecret() + "&proxy=" + getUserProxy() + "&lang=" + getLocale() + "&vt=1&vtl=1&vksans=" + isVKSansEnabled() + "&vt_version=" + getBuildNumber() + "&vt_debug=" + isDEVModEnabled();
}
public static String getString(String key, String defValue) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
return prefs.getString(key, defValue);
}
public static String getUserProxy() {
return proxy() ? "1" : "0";
}
public static boolean hasMusicSubscription() {
return BooleanTrue("hasMusicSubscription");
}
public static boolean isEnableExternalOpening() {
return BooleanFalse("isEnableExternalOpening");
}
public static boolean iconvk() {
return BooleanFalse("iconvk");
}
public static boolean iconvkru() {
return BooleanFalse("iconvkru");
}
public static String isDEVModEnabled() {
return dev() ? "1" : "0";
}
public static boolean isOtaEnabled() {
return BooleanTrue("ota_enabled");
}
public static boolean isMusicRestricted() {
return BooleanTrue("isMusicRestricted");
}
public static String isVKSansEnabled() {
return vksans() ? "1" : "0";
}
public static boolean msgflat() {
return BooleanFalse("msgflat");
}
public static boolean msgtails() {
return BooleanTrue("msgtails");
}
public static boolean navbar() {
return BooleanTrue("navbar");
}
public static boolean newfeed() {
return BooleanFalse("newfeed");
}
public static boolean offline() {
return BooleanTrue("offline");
}
public static boolean oldabout() {
return BooleanFalse("oldabout");
}
public static boolean postsrecomm() {
return BooleanTrue("postsrecomm");
}
public static String promoads() {
return ads() ? "null" : "promo_button";
}
public static String proxyHostHTTP() {
String string = Helper.GetPreferences().getString("proxyHostHTTP", "");
return string.isEmpty() ? "192.168.0.1" : string;
}
public static String proxyHostHTTPS() {
String string = Helper.GetPreferences().getString("proxyHostHTTPS", "");
return string.isEmpty() ? "192.168.0.1" : string;
}
public static String proxyHostSocks() {
String string = Helper.GetPreferences().getString("proxyHostSocks", "");
return string.isEmpty() ? "192.168.0.1" : string;
}
public static String proxyPortHTTP() {
String string = Helper.GetPreferences().getString("proxyPortHTTP", "");
return string.isEmpty() ? "8888" : string;
}
public static String proxyPortHTTPS() {
String string = ru.vtosters.lite.utils.Helper.GetPreferences().getString("proxyPortHTTPS", "");
return string.isEmpty() ? "8888" : string;
}
public static String proxyPortSocks() {
String string = Helper.GetPreferences().getString("proxyPortSocks", "");
return string.isEmpty() ? "8888" : string;
}
public static boolean proxyvk() {
return BooleanFalse("proxyvk");
}
public static String readstatus() {
return dnr() ? "messages.markAsRead" : "null";
}
public static boolean refsfilter() {
return BooleanFalse("refsfilter");
}
public static boolean rightLikes() {
return BooleanFalse("rightLikes");
}
public static void setMeToken(String str) {
ru.vtosters.lite.utils.Helper.GetPreferences().edit().putString("me_token", str).apply();
}
public static boolean setoffline() {
return BooleanFalse("setoffline");
}
public static boolean shortinfo() {
return BooleanTrue("shortinfo");
}
public static boolean shortlinkfilter() {
return BooleanFalse("shortlinkfilter");
}
public static boolean shortpost() {
return BooleanTrue("shortpost");
}
public static boolean showmenu() {
return BooleanFalse("showmenu");
}
public static boolean ssl() {
return BooleanTrue("ssl");
}
public static boolean stories() {
return BooleanTrue("stories");
}
public static String storyads() {
return adsstories() ? "null" : "ads";
}
public static boolean swipe() {
return BooleanTrue("swipe");
}
public static boolean systememoji() {
return BooleanFalse("systememoji");
}
public static boolean unlockstats() {
return BooleanFalse("unlockstats");
}
public static boolean usevkui() {
return BooleanTrue("usevkui");
}
public static boolean vksans() {
return BooleanFalse("vksans");
}
public static boolean voice() {
return BooleanTrue("voice");
}
public static String widgetads() {
return ads() ? "null" : "app_widget";
}
public static void setNavbarColor(Window window, int i) {
if (navbar()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setNavigationBarColor(getNavbarColor());
}
}
if (Build.VERSION.SDK_INT >= 31 && VKThemeHelper.d()) {
View decorView = window.getDecorView();
Intrinsics.a((Object) decorView, "view");
decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | 8192);
}
}
public static String MediacontentFix() {
return Build.VERSION.SDK_INT >= 29 ? "date_modified DESC" : "datetaken DESC";
}
public static String MediacontentFix2() {
return Build.VERSION.SDK_INT >= 29 ? "date_modified" : "datetaken";
}
public static String MediacontentFix3() {
return Build.VERSION.SDK_INT >= 29 ? ", date_modified=" : ", dateTaken=";
}
public static boolean inject(JSONObject jSONObject) {
String optString = jSONObject.optString(NavigatorKeys.j, "");
if (!ads(optString) && !authors_rec(optString) && !recomm(optString) && !friendrecomm(optString)) {
String optString2 = jSONObject.optString("post_type", "");
if (!ads(optString2) && !authors_rec(optString2) && !recomm(optString2) && !friendrecomm(optString2)) {
String optString3 = jSONObject.optString("filters", "");
if (ads(optString3) || authors_rec(optString3) || recomm(optString3) || friendrecomm(optString3) || isBlockedByFilter(jSONObject.optString(NavigatorKeys.x, "")) || checkCopyright(jSONObject) || captions(jSONObject)) {
return false;
}
return !AD(jSONObject);
}
}
return false;
}
public static void setupFilters() {
mFilters = new ArrayList();
ReferalsPut();
StandardFilterPut();
ShortLinkPut();
String string = Helper.GetPreferences().getString("spamfilters", "");
if (!string.isEmpty()) {
mFilters.addAll(Arrays.asList(string.split(", ")));
}
}
public static void ReferalsPut() {
if (BooleanTrue("refsfilter")) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("Referals.txt")));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
mFilters.add(readLine);
} else {
bufferedReader.close();
return;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void ShortLinkPut() {
if (BooleanTrue("shortlinkfilter")) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("LinkShorter.txt")));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
mFilters.add(readLine);
} else {
bufferedReader.close();
return;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void StandardFilterPut() {
if (BooleanTrue("default_ad_list")) {
try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("StandartFilter.txt")));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
mFilters.add(readLine);
} else {
bufferedReader.close();
return;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static String SSFSDomain() {
String string = Helper.GetPreferences().getString("ssfscustom", "");
if (!string.isEmpty()) {
return string;
}
return "https://sf.vknext.ru";
}
public static String VKVersion() {
String string = Helper.GetPreferences().getString("vkversion", "");
if (!string.isEmpty()) {
return string;
}
return "5.29";
}
public static boolean isBlockedByFilter(String str) {
for (String str2 : mFilters) {
if (str.toLowerCase().contains(str2.toLowerCase())) {
return true;
}
}
return false;
}
public static void injectAbout(List<Items2> list) {
list.clear();
list.add(new Items1());
if (!oldabout()) {
list.add(new Items(8, R.string.tgchannel));
list.add(new Items(9, R.string.tgchat));
list.add(new Items(16, R.string.vtfaq));
list.add(new Items(19, R.string.vtsite));
list.add(new Items(20, R.string.donate));
list.add(new Items(17, R.string.vkgroup));
list.add(new Items(18, R.string.sett_debug));
return;
}
list.add(new Items(0, R.string.about_app_feedback));
list.add(new Items(1, R.string.about_app_estimate));
list.add(new Items(2, R.string.about_app_privacy));
list.add(new Items(5, R.string.about_app_cookie));
list.add(new Items(3, R.string.about_app_terms_to_use));
list.add(new Items(4, R.string.about_app_license));
list.add(new Items(6, R.string.about_app_data_protect));
list.add(new Items(8, R.string.sett_debug));
}
public static boolean ads(String str) {
if ((str.equals("ads_easy_promote") || str.equals("promo_button") || str.equals("app_widget") || str.equals("ads")) && ads()) {
return false;
}
return false;
}
public static String getLocale() {
String string = Helper.GetPreferences().getString("lang_value", "");
if (string.equals("system")) {
return Locale.getDefault().getLanguage();
}
return string.isEmpty() ? Locale.getDefault().getLanguage() : string;
}
public static boolean proxy() {
return ru.vtosters.lite.utils.Helper.GetPreferences().getString("proxy", "").equals("xtrafrancyz");
}
public static boolean authors_rec(String str) {
return str.equals("authors_rec") && !authorsrecomm();
}
public static boolean captions(JSONObject jSONObject) {
try {
JSONObject jSONObject2 = jSONObject.getJSONObject("caption");
if (!captions()) {
return true;
}
boolean postsrecomm = postsrecomm();
return (jSONObject2.getString(NavigatorKeys.j).equals("explorebait") && !postsrecomm) || ((jSONObject2.getString(NavigatorKeys.j).equals("shared") && postsrecomm) || ((jSONObject.getString(NavigatorKeys.j).equals("digest") && postsrecomm) || ((jSONObject2.getString(NavigatorKeys.j).equals("commented") && postsrecomm) || (jSONObject2.getString(NavigatorKeys.j).equals("voted") && postsrecomm))));
} catch (JSONException unused) {
return false;
}
}
public static boolean recomm(String str) {
return (str.equals("user_rec") || str.equals("live_recommended") || str.equals("inline_user_rec")) && !postsrecomm();
}
public static boolean friendrecomm(String str) {
return str.equals("friends_recommendations") && !friendsrecomm();
}
public static boolean AD(JSONObject jSONObject) {
return jSONObject.optInt("marked_as_ads", 0) == 1 && adsgroup();
}
public static boolean checkCopyright(JSONObject jSONObject) {
return jSONObject.optInt("copyright", 0) == 1 && copyright_post();
}
public static Activity getCurrentActivity() {
if (activities.size() == 0) {
return null;
}
return activities.get(0);
}
public static void init(Application application) {
setupFilters();
fixGapps();
setProxy();
registerActivities(application);
}
private static void registerActivities(Application application) {
application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() { // from class: ru.vtoster2.VTCore.1
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityResumed(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStarted(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStopped(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityCreated(Activity activity, Bundle bundle) {
if (activity instanceof VKActivity) {
Prefs.activities.add(activity);
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
Prefs.activities.remove(activity);
}
});
}
public static Class getStartFragment() {
String string = ru.vtosters.lite.utils.Helper.GetPreferences().getString("start_value", "");
if (string.equals("newsfeed")) {
return Feed2049.b.c();
}
if (string.equals("messenger")) {
return DialogsFragment.class;
}
if (string.equals("groups")) {
return GroupsFragment.class;
}
if (string.equals("music")) {
return MusicFragment.class;
}
if (string.equals("friends")) {
return FriendsFragment.class;
}
if (string.equals(NavigatorKeys.v)) {
return PhotosFragment.class;
}
if (string.equals("videos")) {
return VideosFragment.class;
}
if (string.equals("settings")) {
return SettingsListFragment.class;
}
if (string.equals("apps")) {
return AppsFragment.class;
}
if (string.equals("discover")) {
return DiscoverFragment.class;
}
if (string.equals("notifications")) {
return NotificationsContainerFragment.class;
}
if (string.equals("money")) {
return MoneyTransfersFragment.class;
}
if (string.equals("games")) {
return GamesFragment.class;
}
if (string.equals("liked")) {
return FaveTabFragment.class;
}
if (string.equals("menu")) {
return MenuFragment.class;
}
if (string.equals("profile")) {
return ProfileFragment.class;
}
if (string.equals("lives")) {
return LivesTabsFragment.class;
}
if (string.equals("docs")) {
return DocumentsViewFragment.class;
}
return string.equals("brtd") ? BirthdaysFragment.class : Feed2049.b.c();
}
public static Context BaseContextLocale(Context context) {
Locale locale = new Locale(getLocale());
Locale.setDefault(locale);
var resources = context.getResources();
var configuration = resources.getConfiguration();
if (Build.VERSION.SDK_INT >= 24) {
configuration.setLocale(locale);
configuration.setLayoutDirection(locale);
return context.createConfigurationContext(configuration);
}
configuration.locale = locale;
configuration.setLayoutDirection(locale);
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
return context;
}
public static int vk_sans_display_demibold() {
return vksans() ? R.font.tt_commons_demi_bold : R.font.vk_sans_display_demibold;
}
public static int vk_sans_text_black() {
return vksans() ? R.font.vk_sans_display_bold : R.font.roboto_black;
}
public static int vk_sans_text_bold() {
return vksans() ? R.font.vk_sans_text_bold : R.font.roboto_bold;
}
public static int vk_sans_text_demibold() {
return vksans() ? R.font.vk_sans_text_demibold : R.font.roboto_bold_italic;
}
public static int vk_sans_text_light() {
return vksans() ? R.font.vk_sans_text_light : R.font.roboto_light;
}
public static int vk_sans_text_medium() {
return vksans() ? R.font.vk_sans_text_medium : R.font.roboto_medium;
}
public static int vk_sans_text_regular() {
return vksans() ? R.font.vk_sans_text_regular : R.font.roboto_regular;
}
public static void fixGapps() {
try {
if (Build.VERSION.SDK_INT >= 26) {
NotificationManager notificationManager = (NotificationManager) ru.vtosters.lite.utils.Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE);
boolean z = false;
try {
if (notificationManager.getNotificationChannel("audio_playback_channel") != null) {
z = true;
}
} catch (Exception ignored) {
}
if (!z) {
notificationManager.createNotificationChannel(new NotificationChannel("audio_playback_channel", ru.vtosters.lite.utils.Helper.getResources().getString(R.string.audio_message_play_error), NotificationManager.IMPORTANCE_LOW));
}
}
} catch (Exception ignored) {
}
}
}
@@ -0,0 +1,46 @@
package ru.vtosters.lite.utils;
public class ProfileHide {
// private static final OkHttpClient client = new OkHttpClient();
//
// /* JADX WARN: Type inference failed for: r1v1, types: [boolean] */
// /* JADX WARNING: Unknown variable types count: 1 */
// public static void injectMap(HashMap<Integer, AdministratorProfileFragment.a.a> hashMap) {
// for (int i = 0; VTVerifications.sServiceAccountsMap.valueOf(i) < 0; i++) {
// boolean valueOf = VTVerifications.sServiceAccountsMap.valueOf(Helper.getId());
// if (valueOf) {
// hashMap.put(1, new AdministratorProfileFragment.a.C0211a(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 = Helper.getUserID(extendedUserProfile.f11298a);
// if (VTVerifications.sServiceAccountsMap.valueOf(userID)) {
// Request.Builder builder = new Request.Builder();
// try {
// String string = new JSONObject(client.newCall(builder.o(HttpUrl.l("https://sf.vknext.ru/block_text?user_id=" + userID)).build()).b().a().p()).getJSONObject(MsgSendVc.e).getString("response");
// if (!string.equals("")) {
// ExtendedUserProfile.class.getDeclaredField("z2").set(extendedUserProfile, string);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }
//
// public static String getInfo(ExtendedUserProfile extendedUserProfile) {
// int userID = Helper.getUserID(extendedUserProfile);
// if (VTVerifications.sServiceAccountsMap.valueOf(userID)) {
// try {
// String str = (String) ExtendedUserProfile.class.getDeclaredField("z2").get(extendedUserProfile);
// if (!TextUtils.equals(str, "") && str != null) {
// return str;
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// return Helper.getContext().getString(UserPresenter.i0.a(userID).intValue());
// }
}
@@ -0,0 +1,169 @@
package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Prefs.proxyHostHTTP;
import static ru.vtosters.lite.utils.Prefs.proxyHostHTTPS;
import static ru.vtosters.lite.utils.Prefs.proxyHostSocks;
import static ru.vtosters.lite.utils.Prefs.proxyPortHTTP;
import static ru.vtosters.lite.utils.Prefs.proxyPortHTTPS;
import static ru.vtosters.lite.utils.Prefs.proxyPortSocks;
import java.util.Properties;
public class Proxy {
public static String getOauthComAuth() {
String oauthComHttps = getOauthComHttps();
return oauthComHttps + "/authorize";
}
public static String getOauthComAuthClient() {
String oauthComAuth = getOauthComAuth();
return oauthComAuth + "?client_id=";
}
public static String getOauthComBlank() {
String oauthComHttps = getOauthComHttps();
return oauthComHttps + "/blank.html";
}
public static String getOauthComBlankRedirect() {
return "&redirect_uri=" + getOauthComBlank();
}
public static String getOauthComHttps() {
return "https://" + getOauthCom();
}
public static String getStaticComSupport() {
String staticCom = getStaticCom();
return staticCom + "/support";
}
public static String oauthFix() {
return "https://oauth.vk.com/blank.html";
}
public static String getApiCom() {
if (!Prefs.proxy()) {
return "api.vk.com";
}
String string = Helper.GetPreferences().getString("proxyapi", "");
if (!string.isEmpty()) {
return string;
}
return "vk-api-proxy.xtrafrancyz.net";
}
public static String getAwayPhpCom() {
if (!Prefs.proxy()) {
return "m.vk.com";
}
String string = Helper.GetPreferences().getString("proxyapi", "");
if (!string.isEmpty()) {
return string;
}
return "vk-api-proxy.xtrafrancyz.net";
}
public static String getOauthCom() {
if (!Prefs.proxy()) {
return "oauth.vk.com";
}
String string = Helper.GetPreferences().getString("proxyoauth", "");
if (!string.isEmpty()) {
return string;
}
return "vk-oauth-proxy.xtrafrancyz.net";
}
public static String getStaticCom() {
if (!ru.vtosters.lite.utils.Prefs.proxy()) {
return "static.vk.com";
}
String string = Helper.GetPreferences().getString("proxystatic", "");
if (!string.isEmpty()) {
return string;
}
return "vk-static-proxy.xtrafrancyz.net";
}
public static String staticFix(String str) {
String str2;
String str3;
if (!Prefs.proxy()) {
return str;
}
String string = Helper.GetPreferences().getString("proxystatic", "");
if (string.isEmpty()) {
str3 = "static.vk.com";
str2 = "vk-static-proxy.xtrafrancyz.net";
} else {
str3 = "static.vk.com";
str2 = string;
}
return str.replace(str2, str3);
}
public static String GetConnector(String str) {
if (!Prefs.proxy()) {
return str;
}
if (str.startsWith("https://")) {
String replace = str.replace("https://", "");
return "https://" + getApiCom() + "/_/" + replace;
} else if (str.startsWith("http://")) {
String replace2 = str.replace("http://", "");
return "http://" + getApiCom() + "/_/" + replace2;
} else {
return getApiCom() + "/_/" + str;
}
}
public static void setProxy() {
switch (Helper.GetPreferences().getString("proxy", "")) {
case "zaborona":
Properties properties = System.getProperties();
properties.setProperty("socksProxyHost", "socks.zaborona.help");
properties.setProperty("socksProxyPort", "1488");
System.clearProperty("https.proxyHost");
System.clearProperty("https.proxyPort");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
break;
case "socks":
Properties properties2 = System.getProperties();
properties2.setProperty("socksProxyHost", proxyHostSocks());
properties2.setProperty("socksProxyPort", proxyPortSocks());
System.clearProperty("https.proxyHost");
System.clearProperty("https.proxyPort");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
break;
case "http":
Properties properties3 = System.getProperties();
properties3.setProperty("http.proxyHost", proxyHostHTTP());
properties3.setProperty("http.proxyPort", proxyPortHTTP());
System.clearProperty("socksProxyHost");
System.clearProperty("socksPortHost");
System.clearProperty("https.proxyHost");
System.clearProperty("https.proxyPort");
break;
case "https":
Properties properties4 = System.getProperties();
properties4.setProperty("https.proxyHost", proxyHostHTTPS());
properties4.setProperty("https.proxyPort", proxyPortHTTPS());
System.clearProperty("socksProxyHost");
System.clearProperty("socksPortHost");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
break;
default:
System.clearProperty("socksProxyHost");
System.clearProperty("socksPortHost");
System.clearProperty("https.proxyHost");
System.clearProperty("https.proxyPort");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
break;
}
}
}
@@ -0,0 +1,107 @@
package ru.vtosters.lite.utils;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v7.widget.Toolbar;
import android.widget.ImageButton;
import com.vk.core.d.RecoloredDrawable;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vtosters.lite.R;
import com.vtosters.lite.auth.VKAccountManager;
import ru.vtosters.lite.f0x1d.VTVerifications;
public class Themes {
public static int getAccentColor() {
return VKThemeHelper.a((int) R.attr.accent);
}
public static int getTextAttr() {
return VKThemeHelper.a((int) R.attr.text_primary);
}
public static int getSTextAttr() {
return VKThemeHelper.a((int) R.attr.text_secondary);
}
public static int getTabbarBackground() {
return VKThemeHelper.a((int) R.attr.tabbar_background);
}
public static int getColorFromAttr(int attr) {
return VKThemeHelper.a(attr);
}
public static int getHeaderText() {
return VKThemeHelper.a((int) R.attr.header_text);
}
public static boolean isAndroidMonet() {
if (color_grishka()) {
return Build.VERSION.SDK_INT >= 31;
} else {
return false;
}
}
public static boolean color_grishka() {
return ru.vtosters.lite.utils.Prefs.BooleanTrue("color_grishka");
}
public static boolean isColorRefAccented(int i) {
return i == R.color.cornflower_blue || i == R.color.cornflower_blue_two || i == R.color.dot_unread || i == R.color.fave_promo_btn_pressed || i == R.color.im_back_to_vk_gradient_start || i == R.color.live_emoji_butt_hide || i == R.color.picker_tab_bg_selected || i == R.color.sky_300 || i == R.color.text_blue || i == R.color.tw__blue_default || i == R.color.tw__blue_pressed || i == R.color.white_blue32 || i == R.color.name || i == R.color.picker_blue || i == R.color.picker_blue_pressed || i == R.color.picker_tab_text_selected || i == R.color.sharing_blue_btn_pressed || i == R.color.sharing_blue_btn_normal || i == R.color.tip_background || i == R.color.vkim_msg_sending_ic || i == R.color.vkim_playing_drawable_rect || i == R.color.accent_blue || i == R.color.light_blue_gray || i == R.color.light_blue || i == R.color.blue_200 || i == R.color.header_blue || i == R.color.blue_200_muted || i == R.color.im_old_accent || i == R.color.im_old_accent_muted || i == R.color.im_dark_accent || i == R.color.im_dark_accent_muted || i == R.color.azure_A400 || i == R.color.blue || i == R.color.blue_400 || i == R.color.blue_300 || i == R.color.cool_blue;
}
public static void themeMonetToolbar(ImageButton imageButton, Toolbar toolbar) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageButton.setImageTintList(ColorStateList.valueOf(getHeaderText()));
toolbar.setElevation(0.0f);
}
}
public static boolean vkim_msg() {
return ru.vtosters.lite.utils.Prefs.BooleanFalse("vkim_msg");
}
public static boolean vkme_msg() {
return ru.vtosters.lite.utils.Prefs.BooleanFalse("vkme_msg");
}
public static Drawable recolorDrawable(Drawable drawable) {
if (drawable == null) {
return null;
}
return new RecoloredDrawable(drawable, getAccentColor());
}
public static ColorStateList recolorCSL(ColorStateList colorStateList) {
if (colorStateList == null) {
return null;
}
return ColorStateList.valueOf(getAccentColor());
}
public static int getColor(Context context, int i) {
if (isColorRefAccented(i) && isAndroidMonet()) {
return getAccentColor();
}
if (Build.VERSION.SDK_INT >= 23) {
return context.getColor(i);
}
return context.getResources().getColor(i);
}
public static int getColor2(int i) {
if (isColorRefAccented(i) && isAndroidMonet()) {
return getAccentColor();
}
return Helper.GetContext().getResources().getColor(i);
}
public static String hex(int i) {
return String.format("#%06X", new Object[]{Integer.valueOf(i & 16777215)});
}
}
@@ -0,0 +1,76 @@
package ru.vtosters.lite.utils;
import android.util.Base64;
import android.util.Log;
import android.webkit.WebView;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import com.vtosters.lite.R;
public class VKUIInjector {
private static boolean isLoaded = false;
private static String loadedCSS = "";
private static String loadedCSSAmoled = "";
static {
}
public VKUIInjector() {
}
private static String load(String str) {
try {
InputStream open = Helper.GetContext().getAssets().open(str);
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open, StandardCharsets.UTF_8));
while (true) {
String readLine = bufferedReader.readLine();
if (readLine != null) {
sb.append(readLine);
} else {
bufferedReader.close();
return sb.toString();
}
}
} catch (IOException e) {
e.printStackTrace();
return "";
}
}
public static void load() {
loadedCSS = load("vt_ui_accent.css")
.replace("%accent%", Themes.hex(Themes.getAccentColor()))
.replace("%background_page%", Themes.hex(Themes.getColorFromAttr(R.attr.background_page)))
.replace("%background_content%", Themes.hex(Themes.getColorFromAttr(R.attr.background_content)))
.replace("%text_primary%", Themes.hex(Themes.getColorFromAttr(R.attr.text_primary)));
// loadedCSSAmoled = load("vt_ui_oled.css");
isLoaded = true;
}
private static void inject(WebView webView, String str) {
webView.loadUrl("javascript:(function() {var parent = document.getElementsByTagName('head').item(0);var style = document.createElement('style');style.type = 'text/css';style.innerHTML = window.atob('" + str + "');parent.appendChild(style)})()");
}
public static void inject(WebView webView) {
if (Prefs.BooleanTrue("VKUI_INJ")) {
if (!isLoaded) {
load();
}
StringBuilder sb = new StringBuilder();
if (true/*Themes.isAccentedCache()*/) {
Log.d("VKUI", "Injecting Accent");
sb.append("\n\n");
sb.append(loadedCSS);
}
Log.d("VKUI", "Final CSS: " + sb.toString());
inject(webView, Base64.encodeToString(sb.toString().getBytes(), 2));
}
}
}