Compare commits
84
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9360ea4d85 | ||
|
|
c87d6581c8 | ||
|
|
7133fc6c03 | ||
|
|
46af5af250 | ||
|
|
5b9cc6778c | ||
|
|
5260ad8243 | ||
|
|
2996772020 | ||
|
|
d37534cb6b | ||
|
|
92eb48c21e | ||
|
|
d9e867cb6e | ||
|
|
f200c6e59a | ||
|
|
c668f3bf9a | ||
|
|
bd7afee09b | ||
|
|
ff09a4aec0 | ||
|
|
1e6c60f2ed | ||
|
|
beedb1538d | ||
|
|
8463f9e963 | ||
|
|
ce8f88b8d4 | ||
|
|
ff7d080b5a | ||
|
|
12ad83c607 | ||
|
|
cdf5d2c37c | ||
|
|
9af8e1729e | ||
|
|
d5219ed322 | ||
|
|
7af9a72e77 | ||
|
|
08817bde7e | ||
|
|
d1e9aadd71 | ||
|
|
b6307182cd | ||
|
|
cc70e55b53 | ||
|
|
ed08e97a50 | ||
|
|
44904786d9 | ||
|
|
12b67ce189 | ||
|
|
21b0edf092 | ||
|
|
2adb446d80 | ||
|
|
60738458bb | ||
|
|
a591026258 | ||
|
|
1bab7fa17c | ||
|
|
2713216728 | ||
|
|
f9a529275a | ||
|
|
e992203b7c | ||
|
|
0ed057d705 | ||
|
|
9b70ca6faf | ||
|
|
422c3e4a6c | ||
|
|
6dac880d61 | ||
|
|
c911b2d64e | ||
|
|
39f72f9058 | ||
|
|
2bff354ad0 | ||
|
|
cb55e9b96f | ||
|
|
33f551d464 | ||
|
|
282fa7bdda | ||
|
|
0abd97e8e1 | ||
|
|
5dd616685d | ||
|
|
aff99be92d | ||
|
|
c255f1e498 | ||
|
|
70342daf07 | ||
|
|
f95672e57d | ||
|
|
8f5da42df4 | ||
|
|
4022903069 | ||
|
|
4600c185e4 | ||
|
|
30e8ec0038 | ||
|
|
367b212ca3 | ||
|
|
6533feb62b | ||
|
|
95ef37f6a3 | ||
|
|
6216c66d95 | ||
|
|
02b6e4a728 | ||
|
|
00c1e926e6 | ||
|
|
ef8109e2e8 | ||
|
|
732ee76957 | ||
|
|
b97d2261de | ||
|
|
c362bfc8da | ||
|
|
cc445e4aea | ||
|
|
4ac83d59b5 | ||
|
|
5025a5fa94 | ||
|
|
b8cb19c8db | ||
|
|
593153de8f | ||
|
|
6c36b83d64 | ||
|
|
1381fdd3bb | ||
|
|
f680a37eb1 | ||
|
|
4531b7af52 | ||
|
|
0c4d1af2dc | ||
|
|
d6a18ecca6 | ||
|
|
dc768952c3 | ||
|
|
57cdcfcbd1 | ||
|
|
fb4837ce40 | ||
|
|
b85e1e6937 |
@@ -0,0 +1,46 @@
|
||||
name: Build VTosters Lite
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Download tools
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install default-jre
|
||||
sudo apt install python3
|
||||
chmod +x scripts/apktool.jar
|
||||
chmod +x scripts/apksigner.jar
|
||||
|
||||
- name: Build VTLite
|
||||
run: |
|
||||
git checkout master
|
||||
bash scripts/buildworkflow.sh
|
||||
|
||||
- name: Sign and verify the apk
|
||||
run: |
|
||||
java -jar scripts/apksigner.jar sign --ks scripts/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android smali/VTLite.apk
|
||||
java -jar scripts/apksigner.jar verify smali/VTLite.apk
|
||||
|
||||
- name: Upload apk to artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: VTLite.apk
|
||||
path: smali/VTLite.apk
|
||||
@@ -25,3 +25,4 @@ smali/assets/version.properties
|
||||
app/src/main/assets/version.properties
|
||||
smali/build/resources.zip
|
||||
*.idsig
|
||||
/smali/VTLite.apk.cache/
|
||||
|
||||
@@ -1,18 +1,82 @@
|
||||
# VTosters Lite
|
||||
|
||||
VTosters Lite - это модифицированный клиент ВКонтакте, основанный на версии 5.29
|
||||
VTosters Lite - это модифицированный клиент (декомпиляция) официального ВКонтакте основанный на версии 5.29
|
||||
|
||||
О найденных багах сообщать в [issues](https://github.com/vtosters/lite/issues), просьба не плодить дубликаты, воспользуйтесь поиском перед созданием нового issue
|
||||
|
||||
Скачивать самые актуальные версии можно с [Actions](https://github.com/vtosters/lite/actions)
|
||||
|
||||
Стабильные сборки находятся в [Releases](https://github.com/vtosters/lite/releases)
|
||||
|
||||
Зеркало на нашем [Git](https://git.devshelter.su/gdlbo/lite)
|
||||
|
||||
Зеркало на [Github](https://github.com/vtosters/lite)
|
||||
|
||||
## Отладка приложения
|
||||
|
||||
Для отладки с помощью Android Studio необходимо пройти в `/smali/AndroidManifest.xml`
|
||||
```
|
||||
android:debuggable="false" -> android:debuggable="true"
|
||||
```
|
||||
|
||||
Для дополнительной отладки ответов, доп логов и подмены данных для дебаг приложения необходимо включить **Режим разработчика**
|
||||
```
|
||||
Настройки -> Для разработчиков -> Режим разработчика
|
||||
```
|
||||
|
||||
Для просмотра трафика необходимо отключить функцию **SSL Pinning**
|
||||
|
||||
```
|
||||
Настройки -> Для разработчиков -> SSL Pinning
|
||||
```
|
||||
|
||||
Для логгирования внутренних запросов к API необходимо включить функции **Логгирование API**
|
||||
|
||||
(Работает только при использовании внутреннего логгера!)
|
||||
|
||||
```
|
||||
Настройки -> Для разработчиков -> Логгирование API
|
||||
```
|
||||
|
||||
Для использования внутреннего логгера необходимо включить функции **Запись логов в файл**
|
||||
```
|
||||
Настройки -> Для разработчиков -> Запись логов в файл
|
||||
```
|
||||
Сразу после нажатия на запись аппа начнет записывать **все действия** в файлы по пути
|
||||
```
|
||||
/VK/logs/com.vtosters.lite
|
||||
```
|
||||
При следующем открытии аппы она автоматически запакует эти файлы и отправит вам в **Документы** ВК
|
||||
|
||||
Позже архив можно будет скачать и работать с файлами логов которые находятся в нем
|
||||
|
||||
## Разработка
|
||||
Мы всегда готовы к новым предложениям в [Pull Requests](https://github.com/vtosters/lite/pulls)
|
||||
|
||||
Для понимания декомпилированного кода требуется использовать **Dex to Java** декомпилятор [jadx](https://github.com/skylot/jadx) или же сторонние варианты как [Fernflower](https://github.com/fesh0r/fernflower)
|
||||
|
||||
Рекомендуется установка **Android Debug Bridge** в систему ([Гайд как это сделать](https://technastic.com/system-wide-adb-fastboot-windows-10))
|
||||
|
||||
Для индексации декомпилированного кода в Studio используется [dex2jar](https://github.com/pxb1988/dex2jar)
|
||||
|
||||
Сгенерированные библиотеки из дексов находятся в `/app/libs`
|
||||
|
||||
При чистой перекомпиляции дексов в jar может сломаться некоторая индексация файлов, исправляйте ручками что попадется (К примеру какие-то функции в дексах изменены с **private** на **public**)
|
||||
|
||||
Для сборки декомпилированного кода и ресурсов используется [Apktool](https://github.com/iBotPeaches/Apktool)
|
||||
|
||||
А при нахождении решения каких-либо проблем ждем вас в [Pull Requests](https://github.com/vtosters/lite/pulls)
|
||||
|
||||
### Всё необходимое для сборки и компиляции
|
||||
|
||||
`Не меняйте packagename во избежание проблем с приложением`
|
||||
|
||||
`Некоторые функции связанные с музыкой не будут работать в пересобранном приложении`
|
||||
|
||||
## Компиляция
|
||||
Весь декомпилированный код клиента находится в `/smali`
|
||||
|
||||
Весь исходный код написанный на Java находится в `/app`
|
||||
Весь исходный код модификации находится в `/app`
|
||||
|
||||
Все необходимые скрипты для компиляции APK, его подписывании и не только находятся в `/scripts`
|
||||
Все необходимые скрипты/жарники для компиляции APK, его подписывании и не только находятся в `/scripts`
|
||||
|
||||
### Необходимые зависимости
|
||||
Требуется установленная **Java** >11 версии
|
||||
@@ -33,10 +97,3 @@ build.bat
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
## Проверка версии коммита
|
||||
|
||||
С версии 0.0.4 доступна прямая проверка версии коммита внутри приложения.
|
||||
|
||||

|
||||
@@ -86,6 +86,7 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
namespace 'ru.vtosters.lite'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="ru.vtosters.lite">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<application
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package bruhcollective.itaysonlab.libvkx.client;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.RemoteException;
|
||||
@@ -14,8 +15,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
|
||||
public class LibVKXClient {
|
||||
private static LibVKXClientImpl impl;
|
||||
@@ -29,7 +28,7 @@ public class LibVKXClient {
|
||||
|
||||
public static LibVKXClientImpl getInstance() {
|
||||
LibVKXClientImpl libVKXClientImpl = impl;
|
||||
return libVKXClientImpl == null ? getInstance(GetContext()) : libVKXClientImpl;
|
||||
return libVKXClientImpl == null ? getInstance(getContext()) : libVKXClientImpl;
|
||||
}
|
||||
|
||||
public static boolean isVkxInstalled() {
|
||||
@@ -37,7 +36,7 @@ public class LibVKXClient {
|
||||
}
|
||||
|
||||
public static boolean isIntegrationEnabled() {
|
||||
return Prefs.BooleanFalse("libvkx_integration") && isVkxInstalled();
|
||||
return getBoolValue("libvkx_integration", false) && isVkxInstalled();
|
||||
}
|
||||
|
||||
public static boolean play(MusicTrack musicTrack, List<MusicTrack> list, PlayerRefer playerRefer) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package bruhcollective.itaysonlab.libvkx.client;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserId;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -14,7 +14,6 @@ import android.os.RemoteException;
|
||||
import java.util.List;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class LibVKXClientImpl {
|
||||
private ILibVkxService serviceInstance;
|
||||
@@ -53,7 +52,7 @@ public class LibVKXClientImpl {
|
||||
public boolean runOnService(LibVKXAction action) {
|
||||
if (serviceInstance != null) {
|
||||
try {
|
||||
if (serviceInstance.getUserId() != GetUserId()) return false;
|
||||
if (serviceInstance.getUserId() != getUserId()) return false;
|
||||
action.run(serviceInstance);
|
||||
return true;
|
||||
} catch (RemoteException e) {
|
||||
@@ -77,7 +76,7 @@ public class LibVKXClientImpl {
|
||||
isBindFailed = true;
|
||||
} else {
|
||||
try {
|
||||
if (serviceInstance.getUserId() != GetUserId()) return;
|
||||
if (serviceInstance.getUserId() != getUserId()) return;
|
||||
runAfterBind.run(serviceInstance);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.aefyr.tsg.g2;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -20,7 +20,6 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
/**
|
||||
* Created by Aefyr on 19.05.2018.
|
||||
@@ -116,7 +115,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackAdded(TelegramStickersPack pack, int atIndex) {
|
||||
GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -126,7 +125,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackChanged(TelegramStickersPack pack, int atIndex) {
|
||||
GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -136,7 +135,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackRemoved(TelegramStickersPack pack, int atIndex) {
|
||||
GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -146,7 +145,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackDownloadError(TelegramStickersPack pack, Exception error) {
|
||||
GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -156,7 +155,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyActivePacksListChanged() {
|
||||
GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -166,7 +165,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyInactivePacksListChanged() {
|
||||
GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -27,11 +27,11 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import ru.f0x1d.net.NetCall;
|
||||
import ru.f0x1d.net.NetCallback;
|
||||
import ru.f0x1d.net.NetClient;
|
||||
import ru.f0x1d.net.NetRequest;
|
||||
import ru.f0x1d.net.NetResponse;
|
||||
import ru.vtosters.lite.net.NetCall;
|
||||
import ru.vtosters.lite.net.NetCallback;
|
||||
import ru.vtosters.lite.net.NetClient;
|
||||
import ru.vtosters.lite.net.NetRequest;
|
||||
import ru.vtosters.lite.net.NetResponse;
|
||||
|
||||
/**
|
||||
* Created by Aefyr on 11.05.2018.
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package ru.f0x1d.net;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
|
||||
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 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();
|
||||
}
|
||||
|
||||
public interface F0x1dRequestCallback {
|
||||
void onResponse(String str);
|
||||
}
|
||||
|
||||
private static class MakeRequestTask extends AsyncTask<Void, Void, String> {
|
||||
private final F0x1dRequestCallback callback;
|
||||
private boolean mIsPut;
|
||||
private boolean mIsVkToasterRequest;
|
||||
private final 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;
|
||||
}
|
||||
|
||||
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", 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package ru.vtosters.lite.audio.gcm;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.VKVersion;
|
||||
import static ru.vtosters.lite.utils.Preferences.VKVersionBuild;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Base64;
|
||||
|
||||
@@ -108,7 +111,7 @@ public class GCMFix {
|
||||
params.add("X-X-subscription=841415684880");
|
||||
}
|
||||
params.add("X-X-subtype=841415684880");
|
||||
params.add("X-app_ver=3439");
|
||||
params.add("X-app_ver=" + VKVersionBuild());
|
||||
params.add("X-kid=|ID|" + rid + "|");
|
||||
params.add("X-osv=30");
|
||||
params.add("X-sig=" + sig);
|
||||
@@ -129,12 +132,12 @@ public class GCMFix {
|
||||
if (!del) {
|
||||
params.add("X-gmp_app_id=1:841415684880:android:632f429381141121");
|
||||
}
|
||||
params.add("X-app_ver_name=5.29");
|
||||
params.add("X-app_ver_name=" + VKVersion());
|
||||
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("app_ver=" + VKVersionBuild());
|
||||
params.add("gcm_ver=11949470");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.badmanners;
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
public class Device {
|
||||
private String androidId;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.badmanners;
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
@@ -1,7 +1,10 @@
|
||||
package ru.vtosters.lite.dnr;
|
||||
|
||||
import static ru.vtosters.lite.dnr.DNRModule.*;
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.dnr.DNRModule.hookDNR;
|
||||
import static ru.vtosters.lite.dnr.DNRModule.hookDNT;
|
||||
import static ru.vtosters.lite.dnr.DNRModule.isDnrEnabledFor;
|
||||
import static ru.vtosters.lite.dnr.DNRModule.isDntEnabledFor;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
|
||||
import com.vk.im.engine.models.dialogs.Dialog;
|
||||
import com.vk.im.ui.components.common.DialogAction;
|
||||
@@ -9,8 +12,6 @@ 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();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ru.vtosters.lite.dnr;
|
||||
|
||||
import static ru.f0x1d.net.F0x1dRequest.*;
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Proxy.*;
|
||||
import static ru.vtosters.lite.net.Request.makeRequest;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserToken;
|
||||
import static ru.vtosters.lite.utils.Proxy.getApiCom;
|
||||
|
||||
import com.vk.core.util.ToastUtils;
|
||||
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
|
||||
@@ -10,11 +10,8 @@ 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();
|
||||
@@ -54,7 +51,7 @@ public class DNRModule {
|
||||
}
|
||||
|
||||
public static void hookRead(Dialog dialog) {
|
||||
makeRequest("https://" + getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.lastMsgVkId + "&peer_id=" + dialog.a() + "&v=5.91&access_token=" + GetUserToken(), response -> {
|
||||
makeRequest("https://" + getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.lastMsgVkId + "&peer_id=" + dialog.a() + "&v=5.91&access_token=" + getUserToken(), response -> {
|
||||
ToastUtils.a("Чат помечен как прочитанный!");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package ru.vtosters.lite.dnr;
|
||||
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class DNRPrefs {
|
||||
public static boolean getStoriesRead() {
|
||||
return Prefs.BooleanFalse("read_s");
|
||||
return getBoolValue("read_s", false);
|
||||
}
|
||||
|
||||
public static boolean getMarkAsReadWithoutExceptions(int peerId) {
|
||||
@@ -28,27 +28,27 @@ public class DNRPrefs {
|
||||
}
|
||||
|
||||
public static boolean readPM(int peer) {
|
||||
return (peer > 0 && peer < 2000000000) && Prefs.BooleanFalse("read_pm");
|
||||
return (peer > 0 && peer < 2000000000) && getBoolValue("read_pm", false);
|
||||
}
|
||||
|
||||
public static boolean readConversations(int peer) {
|
||||
return (peer > 2000000000) && Prefs.BooleanFalse("read_conversations");
|
||||
return (peer > 2000000000) && getBoolValue("read_conversations", false);
|
||||
}
|
||||
|
||||
public static boolean readBots(int peer) {
|
||||
return (peer < 0) && Prefs.BooleanFalse("read_bot");
|
||||
return (peer < 0) && getBoolValue("read_bot", false);
|
||||
}
|
||||
|
||||
public static boolean writePM(int peer) {
|
||||
return (peer > 0 && peer < 2000000000) && Prefs.BooleanFalse("write_pm");
|
||||
return (peer > 0 && peer < 2000000000) && getBoolValue("write_pm", false);
|
||||
}
|
||||
|
||||
public static boolean writeConversations(int peer) {
|
||||
return (peer > 2000000000) && Prefs.BooleanFalse("write_conversations");
|
||||
return (peer > 2000000000) && getBoolValue("write_conversations", false);
|
||||
}
|
||||
|
||||
public static boolean writeBots(int peer) {
|
||||
return (peer < 0) && Prefs.BooleanFalse("write_bot");
|
||||
return (peer < 0) && getBoolValue("write_bot", false);
|
||||
}
|
||||
|
||||
public static boolean getActivityWithoutExceptions(int peerId) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ru.vtosters.lite.dnr.helpers;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
@@ -11,11 +11,10 @@ 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(GetContext(), "dnr", null, 1);
|
||||
super(getContext(), "dnr", null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package ru.vtosters.lite.dnr.helpers;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
@@ -9,11 +11,10 @@ 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);
|
||||
super(getContext(), "dnt", null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package ru.vtosters.lite.encryption;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.vk.im.engine.models.messages.Msg;
|
||||
import com.vk.im.engine.models.messages.MsgFromUser;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
import ru.vtosters.lite.encryption.processors.BeeCryptProcessor;
|
||||
import ru.vtosters.lite.encryption.processors.DefaultCoffeeProcessor;
|
||||
import ru.vtosters.lite.encryption.processors.DonateCoffeeProcessor;
|
||||
import ru.vtosters.lite.encryption.processors.MP3InvisibleProcessor;
|
||||
import ru.vtosters.lite.encryption.processors.VTostersAESProcessor;
|
||||
import ru.vtosters.lite.encryption.processors.VTostersProcessor;
|
||||
|
||||
public class EncryptProvider {
|
||||
public static List<IMProcessor> processors = new ArrayList<>();
|
||||
|
||||
public static IMProcessor getProcessorFor(int peerId) {
|
||||
IMProcessor enabled = null;
|
||||
for (IMProcessor processor: EncryptProvider.processors) {
|
||||
if (processor.isUsedToEncrypt(peerId)) {
|
||||
enabled = processor;
|
||||
}
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public static String getBody(MsgFromUser msg) {
|
||||
return msg.E();
|
||||
}
|
||||
|
||||
public static int getPeerId(Msg msg) {
|
||||
return msg.b();
|
||||
}
|
||||
|
||||
// This will run through EVERY single processor available.
|
||||
public static String decryptMessage(MsgFromUser msg) {
|
||||
return decryptMessage(getBody(msg), getPeerId(msg));
|
||||
}
|
||||
|
||||
public static String decryptMessage(String msgBody, int peer) {
|
||||
try {
|
||||
for (IMProcessor processor : processors) {
|
||||
if ((processor.isUsed() || !processor.isPublic()) && processor.isEncrypted(msgBody) && (processor.isPublic() || getKeyForProcessor(processor, peer) != null))
|
||||
return "\uD83D\uDD12 " + processor.decode(msgBody, getKeyForProcessor(processor, peer));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return msgBody;
|
||||
}
|
||||
|
||||
private static byte[] getKeyForProcessor(IMProcessor processor, int peer) {
|
||||
if (processor.isPublic()) return null;
|
||||
String keyString = processor.getEncryptionKeyFor(peer);
|
||||
if (keyString == null) return null;
|
||||
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hash = digest.digest(keyString.getBytes());
|
||||
byte[] key = new byte[16];
|
||||
System.arraycopy(hash, 0, key, 0, key.length);
|
||||
return key;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return keyString.getBytes();
|
||||
}
|
||||
|
||||
// This will use only the processor which was chosen in chat menu [that's why ID is needed, bruh]
|
||||
public static String encryptMessage(MsgFromUser msg) {
|
||||
|
||||
String msgBody = getBody(msg);
|
||||
|
||||
Log.d("EncryptProvider", "encryptMessage: msg = " + msg.toString());
|
||||
Log.d("EncryptProvider", "encryptMessage: body = " + msgBody);
|
||||
Log.d("EncryptProvider", "encryptMessage: peerId = " + getPeerId(msg));
|
||||
|
||||
for (IMProcessor processor: processors) {
|
||||
int peer = getPeerId(msg);
|
||||
if (processor.isUsedToEncrypt(peer)) {
|
||||
return processor.encode(msgBody, getKeyForProcessor(processor, peer));
|
||||
}
|
||||
}
|
||||
|
||||
return msgBody;
|
||||
}
|
||||
|
||||
// For rendering UI
|
||||
public static List<Pair<String, String>> getUserVisibleEncoders() {
|
||||
List<Pair<String, String>> theList = new ArrayList<>();
|
||||
|
||||
for (IMProcessor processor: processors) {
|
||||
if (processor.isPublic()) theList.add(new Pair<>("VT_IMDecode_"+processor.getPrefKey(), processor.getUIName()));
|
||||
}
|
||||
|
||||
return theList;
|
||||
}
|
||||
|
||||
static {
|
||||
processors.add(new VTostersProcessor());
|
||||
processors.add(new VTostersAESProcessor());
|
||||
processors.add(new DefaultCoffeeProcessor());
|
||||
processors.add(new DonateCoffeeProcessor());
|
||||
processors.add(new BeeCryptProcessor());
|
||||
processors.add(new MP3InvisibleProcessor());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package ru.vtosters.lite.encryption.base;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public abstract class IMProcessor {
|
||||
// By default it checks start and end tag.
|
||||
public boolean isEncrypted(String source) {
|
||||
//Log.d("IMProcessor", "Checking if encrypted: "+source+" / "+getUIName());
|
||||
return source.startsWith(startTag()) && source.endsWith(endTag());
|
||||
}
|
||||
|
||||
// Key can be null - if it's a public processor
|
||||
@NonNull protected abstract String encodeInternal(@NonNull String source, @Nullable byte[] key);
|
||||
@NonNull protected abstract String decodeInternal(@NonNull String source, @Nullable byte[] key);
|
||||
|
||||
// Automatically removes tags. Magic!
|
||||
@NonNull
|
||||
public String encode(@NonNull String source, @Nullable byte[] key) {
|
||||
//Log.d("IMProcessor", "Encoding "+source);
|
||||
return startTag() + encodeInternal(source, key) + endTag();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String decode(@NonNull String source, @Nullable byte[] key) {
|
||||
//Log.d("IMProcessor", "Decoding");
|
||||
return decodeInternal(source.substring(startTag().length(), source.length() - endTag().length()), key);
|
||||
}
|
||||
|
||||
// Public - no key required.
|
||||
public boolean isPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// UI thing
|
||||
@NonNull abstract public String getUIName();
|
||||
@NonNull abstract public String getPrefKey();
|
||||
|
||||
@NonNull public String startTag() {
|
||||
return "";
|
||||
}
|
||||
@NonNull public String endTag() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean isUsed() {
|
||||
//Log.d("IMProcessor", "Checking if decoded with "+getUIName());
|
||||
return getBoolValue("VT_IMDecode_"+getPrefKey(), true);
|
||||
}
|
||||
|
||||
public boolean isUsedToEncrypt(int id) {
|
||||
//Log.d("IMProcessor", "Checking if "+id+" is ready to be encrypted with "+getUIName());
|
||||
return getBoolValue("VT_IMEncode_"+getPrefKey()+"_"+id, false);
|
||||
}
|
||||
|
||||
public void enableEncryptFor(int id) {
|
||||
Globals.getDefprefs().edit().putBoolean("VT_IMEncode_"+getPrefKey()+"_"+id, true).apply();
|
||||
}
|
||||
|
||||
public void disableEncryptFor(int id) {
|
||||
Globals.getDefprefs().edit().putBoolean("VT_IMEncode_"+getPrefKey()+"_"+id, false).apply();
|
||||
}
|
||||
|
||||
public void setEncryptionKeyFor(int id, @Nullable String key) {
|
||||
if (key == null || key.isEmpty()) key = "VTAesDefault";
|
||||
Globals.getDefprefs().edit().putString("VT_IMEncodeKey_"+getPrefKey()+"_"+id, key).apply();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getEncryptionKeyFor(int id) {
|
||||
return Globals.getDefprefs().getString("VT_IMEncodeKey_"+getPrefKey()+"_"+id, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package ru.vtosters.lite.encryption.processors;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
|
||||
public class BeeCryptProcessor extends IMProcessor {
|
||||
private static final String BC_CHARSET = "жъЖЪ";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String encodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
try {
|
||||
String a = Base64.encodeToString(source.getBytes(StandardCharsets.UTF_8), 2);
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (int i = 0; i < a.length(); i++) {
|
||||
StringBuilder bintxt = new StringBuilder();
|
||||
int c = a.charAt(i);
|
||||
for (int j = 0; j < 4; j++) {
|
||||
bintxt.insert(0, BC_CHARSET.charAt(c % 4));
|
||||
c /= 4;
|
||||
}
|
||||
res.append(bintxt);
|
||||
}
|
||||
return res.toString();
|
||||
} catch (java.lang.Exception e) {
|
||||
e.printStackTrace();
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEncrypted(String source) {
|
||||
return source.matches("[жъЖЪ]{16,}");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String decodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
StringBuilder b64 = new StringBuilder();
|
||||
int i = 0;
|
||||
while (i < source.length() - 3) {
|
||||
try {
|
||||
String bintxt = source.substring(i, i + 4);
|
||||
int c = 0;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
c = (c * 4) + Math.max(0, BC_CHARSET.indexOf(bintxt.charAt(j)));
|
||||
}
|
||||
b64.append((char) c);
|
||||
i += 4;
|
||||
} catch (java.lang.Exception e) {
|
||||
e.printStackTrace();
|
||||
return source;
|
||||
}
|
||||
}
|
||||
return new String(Base64.decode(b64.toString(), 2), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getUIName() {
|
||||
return "MP3 [beecrypt]";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "mp3_bc";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package ru.vtosters.lite.encryption.processors;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
|
||||
public class DefaultCoffeeProcessor extends IMProcessor {
|
||||
private final static String KEY = "stupidUsersMustD";
|
||||
private static Cipher dCipher, eCipher;
|
||||
|
||||
static {
|
||||
try {
|
||||
SecretKeySpec key = new SecretKeySpec(KEY.getBytes(), "AES");
|
||||
|
||||
dCipher = Cipher.getInstance("AES");
|
||||
dCipher.init(Cipher.DECRYPT_MODE, key);
|
||||
|
||||
eCipher = Cipher.getInstance("AES");
|
||||
eCipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String toHex(String text) {
|
||||
char[] chars = text.toCharArray();
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (char aChar : chars) {
|
||||
String s = Integer.toHexString(aChar);
|
||||
if (s.length() < 2) s = "0" + s;
|
||||
str.append(s.toUpperCase()).append(" ");
|
||||
}
|
||||
|
||||
String string = str.toString();
|
||||
return string.substring(0, string.length()-1);
|
||||
}
|
||||
|
||||
private String fromHex(String text) {
|
||||
text = text.replace(" ", "");
|
||||
char[] chars = text.toCharArray();
|
||||
char[] chars2 = new char[chars.length/2];
|
||||
for (int i = 0; i < chars.length; i+=2) {
|
||||
String c = String.valueOf(chars[i]) + chars[i + 1];
|
||||
chars2[i/2] = (char) Integer.parseInt(c, 16);
|
||||
}
|
||||
|
||||
return new String(chars2);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String encodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
try {
|
||||
return toHex(Base64.encodeToString(eCipher.doFinal(source.getBytes()), 0));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String decodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
try {
|
||||
return new String(dCipher.doFinal(Base64.decode(fromHex(source), 0)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String startTag() {
|
||||
return "VK CO FF EE ";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String endTag() {
|
||||
return " VK CO FF EE";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getUIName() {
|
||||
return "VK Coffee [default]";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "coffee_default";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package ru.vtosters.lite.encryption.processors;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class DonateCoffeeProcessor extends DefaultCoffeeProcessor {
|
||||
@Override
|
||||
@NonNull
|
||||
public String startTag() {
|
||||
return "II ";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String endTag() {
|
||||
return " II";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getUIName() {
|
||||
return "VK Coffee [hidden]";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "coffee_donate";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package ru.vtosters.lite.encryption.processors;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
|
||||
public class MP3InvisibleProcessor extends IMProcessor {
|
||||
@NonNull
|
||||
@Override
|
||||
protected String encodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
try {
|
||||
byte[] bytes = source.getBytes(StandardCharsets.UTF_8);
|
||||
java.lang.String[] plainText = new String[bytes.length];
|
||||
for (int i = 0; i < plainText.length; i++) {
|
||||
plainText[i] = toStr(bytes[i] & 255, " ");
|
||||
}
|
||||
return " " + TextUtils.join(" ", plainText);
|
||||
} catch (java.lang.Exception e) {
|
||||
e.printStackTrace();
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String decodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
try {
|
||||
java.lang.String[] t = source.replaceAll("^" + " ", "").split(" ");
|
||||
byte[] plainText = new byte[t.length];
|
||||
for (int i = 0; i < plainText.length; i++) {
|
||||
plainText[i] = (byte) toNum(t[i], " ");
|
||||
}
|
||||
return new String(plainText, StandardCharsets.UTF_8);
|
||||
} catch (java.lang.Exception e) {
|
||||
e.printStackTrace();
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
private static String toStr(int a, String cc) {
|
||||
StringBuilder s = new StringBuilder();
|
||||
while (a > 0) {
|
||||
s.insert(0, cc.charAt(a % cc.length()));
|
||||
a /= cc.length();
|
||||
}
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
private static int toNum(String a, String cc) {
|
||||
int n = 0;
|
||||
for (int i = 0; i < a.length(); i++) {
|
||||
int start = (a.length() - i) - 1;
|
||||
n = (int) (((double) n) + (((double) cc.indexOf(a.substring(start, start + 1))) * Math.pow(cc.length(), i)));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEncrypted(String source) {
|
||||
return source.matches("^" + " " + "([" + " " + "\\s]*)");
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getUIName() {
|
||||
return "MP3 [invisible]";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "mp3";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package ru.vtosters.lite.encryption.processors;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class VTostersAESProcessor extends IMProcessor {
|
||||
private final static String CIPHER_INSTANCE = "AES/CBC/PKCS7Padding";
|
||||
private final static String KEY_METHOD = "AES";
|
||||
|
||||
private HashMap<byte[], Cipher> decodeMap = new HashMap<>(), encodeMap = new HashMap<>();
|
||||
|
||||
public void free(byte[] key) {
|
||||
decodeMap.remove(key);
|
||||
encodeMap.remove(key);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Cipher wrapEncoder(byte[] key) throws InvalidAlgorithmParameterException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException {
|
||||
if (encodeMap.containsKey(key)) return encodeMap.get(key);
|
||||
|
||||
Triple<Cipher, SecretKeySpec, IvParameterSpec> encodeCipher = getBaseCipher(key);
|
||||
encodeCipher.first.init(Cipher.ENCRYPT_MODE, encodeCipher.second, encodeCipher.third);
|
||||
encodeMap.put(key, encodeCipher.first);
|
||||
|
||||
return encodeCipher.first;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Cipher wrapDecoder(byte[] key) throws InvalidAlgorithmParameterException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException {
|
||||
if (decodeMap.containsKey(key)) return decodeMap.get(key);
|
||||
|
||||
Triple<Cipher, SecretKeySpec, IvParameterSpec> decodeCipher = getBaseCipher(key);
|
||||
decodeCipher.first.init(Cipher.DECRYPT_MODE, decodeCipher.second, decodeCipher.third);
|
||||
decodeMap.put(key, decodeCipher.first);
|
||||
|
||||
return decodeCipher.first;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Triple<Cipher, SecretKeySpec, IvParameterSpec> getBaseCipher(byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException {
|
||||
byte[] off = new byte[16];
|
||||
System.arraycopy(key, 0, off, 0, off.length);
|
||||
return new Triple<>(Cipher.getInstance(CIPHER_INSTANCE), new SecretKeySpec(key, KEY_METHOD), new IvParameterSpec(off));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String encodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
try {
|
||||
return Base64.encodeToString(wrapEncoder(key).doFinal(source.getBytes(StandardCharsets.UTF_8)), Base64.DEFAULT);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String decodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
try {
|
||||
return new String(wrapDecoder(key).doFinal(Base64.decode(source, Base64.DEFAULT)), StandardCharsets.UTF_8);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPublic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String startTag() {
|
||||
return "VT0ST3RS [AES] ";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String endTag() {
|
||||
return " VT0ST3RS [AES]";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getUIName() {
|
||||
return "VTosters [AES]";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "vtaes";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getEncryptionKeyFor(int id) {
|
||||
return Globals.getDefprefs().getString("VT_IMEncodeKey_"+getPrefKey()+"_"+id, "VTAesDefault");
|
||||
}
|
||||
|
||||
public static class Triple<F, S, T> {
|
||||
public final F first;
|
||||
public final S second;
|
||||
public final T third;
|
||||
|
||||
public Triple(F first, S second, T third) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
this.third = third;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package ru.vtosters.lite.encryption.processors;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
|
||||
public class VTostersProcessor extends IMProcessor {
|
||||
@NonNull
|
||||
@Override
|
||||
protected String encodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
return Base64.encodeToString(source.getBytes(), Base64.DEFAULT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected String decodeInternal(@NonNull String source, @Nullable byte[] key) {
|
||||
return new String(Base64.decode(source, Base64.DEFAULT));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String startTag() {
|
||||
return "VT0ST3RS ";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String endTag() {
|
||||
return " VT0ST3RS";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getUIName() {
|
||||
return "VTosters Classique [Base64]";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPrefKey() {
|
||||
return "vt64";
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.f0x1d;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.About.getBuildNumber;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
@@ -18,9 +19,7 @@ import com.vtosters.lite.R;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import ru.vtosters.lite.badmanners.DeviceInfoCollector;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
import ru.vtosters.lite.deviceinfo.DeviceInfoCollector;
|
||||
|
||||
public class Crashreporter {
|
||||
protected static String logString;
|
||||
@@ -37,12 +36,12 @@ public class Crashreporter {
|
||||
}
|
||||
|
||||
static void start(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th, Activity activity) {
|
||||
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(GetContext()).toDeviceName() + "\n VTL Version: " + Prefs.VERSIONNAME + ", build: " + Prefs.getBuildNumber();
|
||||
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(getContext()).toDeviceName() + ", commit: " + getBuildNumber();
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
var notificationChannel = new NotificationChannel("crashes", "crash", NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationChannel.enableVibration(true);
|
||||
notificationChannel.enableLights(true);
|
||||
((NotificationManager) GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel);
|
||||
((NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel);
|
||||
}
|
||||
|
||||
var foxbinIntent = new Intent("com.f0x1d.dogbin.ACTION_UPLOAD_TO_FOXBIN");
|
||||
@@ -54,19 +53,19 @@ public class Crashreporter {
|
||||
foxbinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
|
||||
}
|
||||
|
||||
var saveLogIntent = new Intent(GetContext(), LogWriterService.class);
|
||||
var saveLogIntent = new Intent(getContext(), LogWriterService.class);
|
||||
saveLogIntent.putExtra("log", logString);
|
||||
saveLogIntent.putExtra("notificationId", 1);
|
||||
var psaveLogIntent = PendingIntent.getService(GetContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
var psaveLogIntent = PendingIntent.getService(getContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
var builder = new Notification.Builder(GetContext());
|
||||
var builder = new Notification.Builder(getContext());
|
||||
builder.setSmallIcon(R.drawable.ic_bug_24);
|
||||
builder.setContentTitle("VTL Крашнулся!");
|
||||
builder.setContentTitle("Произошла ошибка в работе VTLite!");
|
||||
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(GetContext(), (int) (Math.random() * 100.0d), foxbinIntent, PendingIntent.FLAG_CANCEL_CURRENT)));
|
||||
builder.addAction(new Notification.Action(0, "Загрузить логи", PendingIntent.getActivity(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));
|
||||
@@ -77,13 +76,13 @@ public class Crashreporter {
|
||||
}
|
||||
|
||||
|
||||
((NotificationManager) GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(-2147483548, builder.build());
|
||||
((NotificationManager) 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 = GetContext().getPackageManager();
|
||||
var pm = getContext().getPackageManager();
|
||||
try {
|
||||
pm.getPackageInfo("com.f0x1d.dogbin", 0);
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package ru.vtosters.lite.f0x1d;
|
||||
|
||||
import static android.widget.Toast.*;
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
@@ -10,7 +11,6 @@ import android.content.Intent;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -19,8 +19,6 @@ 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() {
|
||||
}
|
||||
@@ -41,12 +39,12 @@ public class LogWriterService extends Service {
|
||||
writeLog(intent, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
makeText(GetContext(), "Не удалось сохранить лог-файл", LENGTH_SHORT).show();
|
||||
makeText(getContext(), "Не удалось сохранить лог-файл", LENGTH_SHORT).show();
|
||||
}
|
||||
var notificationId = intent.getIntExtra("notificationId", 1);
|
||||
var manager = (NotificationManager) GetContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
var manager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(notificationId);
|
||||
makeText(GetContext(), "Лог-файл был сохранен", LENGTH_SHORT).show();
|
||||
makeText(getContext(), "Лог-файл был сохранен", LENGTH_SHORT).show();
|
||||
|
||||
stopSelf();
|
||||
return START_NOT_STICKY;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package ru.vtosters.lite.f0x1d;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Base64;
|
||||
@@ -24,7 +26,6 @@ import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
|
||||
public class VTVerifications {
|
||||
public static final HashMap<Integer, Boolean> sServiceAccountsMap = new HashMap<>();
|
||||
@@ -41,6 +42,7 @@ public class VTVerifications {
|
||||
|
||||
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);
|
||||
@@ -52,7 +54,7 @@ public class VTVerifications {
|
||||
}
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("https://gdlbo.net/vktoaster/getGalo4kiBatch")
|
||||
.url("https://vtosters.app/vktoaster/getGalo4kiBatch")
|
||||
.a(RequestBody.a(MediaType.b("application/json; charset=UTF-8"), "{\"types\":[0,228,404,1337]}"))
|
||||
.build();
|
||||
|
||||
@@ -101,9 +103,7 @@ public class VTVerifications {
|
||||
}
|
||||
|
||||
public static boolean hasPrometheus(int i) {
|
||||
|
||||
return sPrometheusMap.get(i) != null ? sPrometheusMap.get(i) : false;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isDeveloper(int i) {
|
||||
@@ -131,13 +131,20 @@ public class VTVerifications {
|
||||
return Base64.encodeToString(str.getBytes(), 1);
|
||||
}
|
||||
|
||||
|
||||
public static boolean vtverif() {
|
||||
return getBoolValue("VT_Verification", true);
|
||||
}
|
||||
|
||||
public static boolean isVerified(JSONObject jSONObject) {
|
||||
if (jSONObject.optInt("verified", 0) == 1) {
|
||||
return true;
|
||||
}
|
||||
if (!Prefs.BooleanTrue("VT_Verification")) {
|
||||
|
||||
if (!getBoolValue("VT_Verification", true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 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));
|
||||
}
|
||||
|
||||
@@ -145,16 +152,19 @@ public class VTVerifications {
|
||||
if (jSONObject.optInt("trending", 0) == 1) {
|
||||
return true;
|
||||
}
|
||||
if (!Prefs.BooleanTrue("VT_Fire")) {
|
||||
|
||||
if (!getBoolValue("VT_Fire", true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return 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));
|
||||
}
|
||||
|
||||
public static boolean hasDeveloper(JSONObject jSONObject) {
|
||||
if (!Prefs.BooleanTrue("VT_Dev")) {
|
||||
if (!getBoolValue("VT_Dev", true)) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package ru.vtosters.lite.foaf;
|
||||
|
||||
import static android.widget.Toast.*;
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Proxy.getApiCom;
|
||||
import static ru.vtosters.lite.utils.Proxy.proxy;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
|
||||
@@ -25,10 +25,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import ru.f0x1d.net.F0x1dRequest;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
import ru.vtosters.lite.net.Request;
|
||||
|
||||
public class FoafBase {
|
||||
private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>");
|
||||
@@ -37,7 +34,7 @@ public class FoafBase {
|
||||
private static final 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());
|
||||
Matcher matcher = FOAF_REGEX_LAST_SEEN.matcher(client.newCall(new okhttp3.Request.Builder().url(getLink(i)).build()).b().body().string());
|
||||
if (!matcher.find()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -51,7 +48,7 @@ public class FoafBase {
|
||||
private static String getLink(int i) {
|
||||
String str;
|
||||
StringBuilder sb;
|
||||
if (Prefs.proxy()) {
|
||||
if (proxy()) {
|
||||
sb = new StringBuilder();
|
||||
str = "https://" + getApiCom() + "/_/vk.com/foaf.php?id=";
|
||||
} else {
|
||||
@@ -69,8 +66,8 @@ public class FoafBase {
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.show();
|
||||
|
||||
F0x1dRequest.F0x1dRequestCallback callback = str -> FoafBase.lambdaLoadAndShow(progressDialog, context, i, str);
|
||||
F0x1dRequest.makeRequest(getLink(i), callback);
|
||||
Request.RequestCallback callback =str -> FoafBase.lambdaLoadAndShow(progressDialog, context, i, str);
|
||||
Request.makeRequest(getLink(i), callback);
|
||||
}
|
||||
|
||||
static void lambdaLoadAndShow(ProgressDialog progressDialog, Context context, int i, String str) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
@@ -0,0 +1,76 @@
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getUserToken;
|
||||
|
||||
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;
|
||||
|
||||
public class Request {
|
||||
public static void makeRequest(byte[] bArr, RequestCallback RequestCallback) {
|
||||
new MakeRequestTask(bArr, RequestCallback).execute();
|
||||
}
|
||||
|
||||
public static void makeRequest(String str, RequestCallback RequestCallback) {
|
||||
new MakeRequestTask(str.getBytes(), RequestCallback).execute();
|
||||
}
|
||||
|
||||
public interface RequestCallback {
|
||||
void onResponse(String str);
|
||||
}
|
||||
|
||||
private static class MakeRequestTask extends AsyncTask<Void, Void, String> {
|
||||
private final RequestCallback callback;
|
||||
private boolean mIsPut;
|
||||
private boolean mIsVTostersRequest;
|
||||
private final byte[] url;
|
||||
|
||||
public MakeRequestTask(byte[] bArr, RequestCallback RequestCallback) {
|
||||
mIsVTostersRequest = false;
|
||||
mIsPut = false;
|
||||
callback = RequestCallback;
|
||||
url = bArr;
|
||||
}
|
||||
|
||||
public String doInBackground(Void... voidArr) {
|
||||
try {
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(new String(url)).openConnection();
|
||||
httpURLConnection.setRequestMethod(mIsPut ? "PUT" : "GET");
|
||||
|
||||
if (mIsVTostersRequest) {
|
||||
httpURLConnection.setRequestProperty("Token", getUserToken());
|
||||
}
|
||||
if (!mIsVTostersRequest) {
|
||||
httpURLConnection.setRequestProperty("User-Agent", Network.a.a().a());
|
||||
}
|
||||
|
||||
httpURLConnection.setRequestProperty("Content-Type", mIsVTostersRequest ? "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);
|
||||
callback.onResponse(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package ru.vtosters.lite.tgs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class TGPref {
|
||||
private static final SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
|
||||
private static final SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
private static final String CNCT_METHOD = "VTGS:CM";
|
||||
private static final String TG_BOTKEY = "VTGS:BKey";
|
||||
@@ -57,8 +57,7 @@ public class TGPref {
|
||||
}
|
||||
|
||||
public static void setTGProxyUserPass(String user, String pass) {
|
||||
Prefs.edit().putString(TG_PROXYUSER, user).putString(TG_PROXYPASS, pass)
|
||||
.apply();
|
||||
Prefs.edit().putString(TG_PROXYUSER, user).putString(TG_PROXYPASS, pass).apply();
|
||||
}
|
||||
|
||||
public static boolean isTGProxyPassEnabled() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.tgs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
@@ -22,8 +23,6 @@ import org.json.JSONObject;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class TGRoot {
|
||||
public static final int N = 76820000;
|
||||
public static final int X = 976820000;
|
||||
@@ -49,7 +48,7 @@ public class TGRoot {
|
||||
int stickerId = (id - N) % 120;
|
||||
|
||||
TelegramStickersPack pack = null;
|
||||
for (TelegramStickersPack p : TelegramStickersService.getInstance(GetContext()).getActivePacksListReference()) {
|
||||
for (TelegramStickersPack p : TelegramStickersService.getInstance(getContext()).getActivePacksListReference()) {
|
||||
if (p.index == index) {
|
||||
pack = p;
|
||||
break;
|
||||
@@ -70,7 +69,7 @@ public class TGRoot {
|
||||
|
||||
public static void injectStickers(List<StickerStockItem> list) {
|
||||
try {
|
||||
List<TelegramStickersPack> packs = TelegramStickersService.getInstance(GetContext()).getActivePacksListReference();
|
||||
List<TelegramStickersPack> packs = TelegramStickersService.getInstance(getContext()).getActivePacksListReference();
|
||||
for (int i = packs.size() - 1; i >= 0; i--)
|
||||
list.add(0, toStickerPack(packs.get(i)));
|
||||
} catch (Exception e) {
|
||||
@@ -83,7 +82,7 @@ public class TGRoot {
|
||||
int index = (stickerId - N) / 120;
|
||||
|
||||
TelegramStickersPack p = null;
|
||||
for (TelegramStickersPack p_ : TelegramStickersService.getInstance(GetContext())
|
||||
for (TelegramStickersPack p_ : TelegramStickersService.getInstance(getContext())
|
||||
.getActivePacksListReference()) {
|
||||
if (p_.index == index) {
|
||||
p = p_;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
@@ -24,7 +25,6 @@ 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 {
|
||||
@@ -35,7 +35,7 @@ public class PreferencesUtil {
|
||||
}
|
||||
|
||||
public static void addListPreference(MaterialPreferenceToolbarFragment fragment, String key, String def, CharSequence title, CharSequence[] entries, CharSequence[] entriesValue) {
|
||||
ListPreference preference = new ListPreference(GetContext());
|
||||
ListPreference preference = new ListPreference(getContext());
|
||||
preference.a(entries);
|
||||
preference.b(entriesValue);
|
||||
preference.c(title); // setTitle
|
||||
@@ -46,7 +46,7 @@ public class PreferencesUtil {
|
||||
}
|
||||
|
||||
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment materialPreferenceToolbarFragment, String key, CharSequence title, CharSequence summary, boolean defValue) {
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(GetContext());
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getContext());
|
||||
materialSwitchPreference.c(title); // setTitle
|
||||
materialSwitchPreference.b(summary); // setSummary
|
||||
materialSwitchPreference.d(key); // setKey
|
||||
@@ -56,7 +56,7 @@ public class PreferencesUtil {
|
||||
}
|
||||
|
||||
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, int icon, boolean defValue, Preference.b listener) {
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(GetContext());
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getContext());
|
||||
materialSwitchPreference.c(title); // setTitle
|
||||
materialSwitchPreference.b(summary); // setSummary
|
||||
materialSwitchPreference.d(key); // setKey
|
||||
@@ -64,13 +64,13 @@ public class PreferencesUtil {
|
||||
materialSwitchPreference.a(listener); // setOnPreferenceClickListener
|
||||
|
||||
if (icon != 1)
|
||||
materialSwitchPreference.a(setTint(GetContext(), ContextCompat.getDrawable(GetContext(), icon))); // preference.setIcon
|
||||
materialSwitchPreference.a(setTint(getContext(), ContextCompat.getDrawable(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(GetContext());
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getContext());
|
||||
materialSwitchPreference.c(title); // setTitle
|
||||
materialSwitchPreference.b(summary); // setSummary
|
||||
materialSwitchPreference.d(key); // setKey
|
||||
@@ -78,14 +78,14 @@ public class PreferencesUtil {
|
||||
fragment.ay().d(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference)
|
||||
|
||||
if (icon != null)
|
||||
materialSwitchPreference.a(setTint(GetContext(), getDrawable(GetContext(), icon))); // preference.setIcon
|
||||
materialSwitchPreference.a(setTint(getContext(), getDrawable(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(GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
preference.b(summary); // setSummary
|
||||
preference.c(title); // setTitle
|
||||
preference.d(key); // setKey
|
||||
@@ -94,59 +94,59 @@ public class PreferencesUtil {
|
||||
}
|
||||
|
||||
public static void addPreference(MaterialPreferenceToolbarFragment fragment, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) {
|
||||
Preference preference = new Preference(GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
preference.b(summary); // setSummary
|
||||
preference.c(title); // setTitle
|
||||
|
||||
if (icon != null)
|
||||
preference.a(setTint(GetContext(), getDrawable(GetContext(), icon))); // preference.setIcon
|
||||
preference.a(setTint(getContext(), getDrawable(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(GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
preference.b(summary); // setSummary
|
||||
preference.c(title); // setTitle
|
||||
preference.d(key); // setKey
|
||||
|
||||
if (icon != null)
|
||||
preference.a(setTint(GetContext(), getDrawable(GetContext(), icon))); // preference.setIcon
|
||||
preference.a(setTint(getContext(), getDrawable(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(GetContext(), null);
|
||||
PreferenceCategory preference = new PreferenceCategory(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(GetContext(), null);
|
||||
PreferenceCategory preference = new PreferenceCategory(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(GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
|
||||
preference.c(title); // setTitle
|
||||
preference.d(key); // setKey
|
||||
preference.a(preference1 -> {
|
||||
LinearLayout linearLayout = new LinearLayout(GetContext());
|
||||
LinearLayout linearLayout = new LinearLayout(getContext());
|
||||
|
||||
final EditText editText = new EditText(GetContext());
|
||||
editText.setText(PreferenceManager.getDefaultSharedPreferences(GetContext()).getString(key, ""));
|
||||
final EditText editText = new EditText(getContext());
|
||||
editText.setText(PreferenceManager.getDefaultSharedPreferences(getContext()).getString(key, ""));
|
||||
editText.setHint(title);
|
||||
editText.setHintTextColor(PreferencesUtil.getSTextColor(GetContext()));
|
||||
editText.setHintTextColor(PreferencesUtil.getSTextColor(getContext()));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
} else {
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
}
|
||||
linearLayout.addView(editText);
|
||||
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
@@ -162,7 +162,7 @@ public class PreferencesUtil {
|
||||
if (!change)
|
||||
return;
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(GetContext())
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext())
|
||||
.edit()
|
||||
.putString(key, editText.getText().toString())
|
||||
.apply();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@@ -11,14 +13,12 @@ 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 = GetContext();
|
||||
if (OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && getBoolValue("showDoze", true)) {
|
||||
final Context context = getContext();
|
||||
if (!((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Выключите оптимизацию батареи!");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.isGmsInstalled;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@@ -11,12 +14,10 @@ import android.content.Intent;
|
||||
import com.vk.navigation.Navigator;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.InstallGMSFragment;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
|
||||
public class InstallGMS {
|
||||
public static void alert(final Activity activity) {
|
||||
if (!IsGmsInstalled()) {
|
||||
if (!isGmsInstalled()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Внимание!");
|
||||
builder.setMessage(Text());
|
||||
@@ -33,12 +34,12 @@ public class InstallGMS {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
edit().putBoolean("showAlertGms", false).apply();
|
||||
Context context = GetContext();
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(InstallGMSFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
}
|
||||
});
|
||||
if (Prefs.BooleanTrue("showAlertGms")) {
|
||||
if (getBoolValue("showAlertGms", true)) {
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@@ -9,9 +10,7 @@ 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) {
|
||||
@@ -37,7 +36,7 @@ public class Start {
|
||||
activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters")));
|
||||
}
|
||||
});
|
||||
if (Prefs.BooleanTrue("showAlert")) {
|
||||
if (getBoolValue("showAlert", true)) {
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
@@ -7,8 +9,6 @@ import com.vk.core.util.ToastUtils;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
public void b(Bundle bundle) {
|
||||
@@ -22,7 +22,7 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
|
||||
public boolean restart(Preference preference, Object obj) {
|
||||
ToastUtils.a(Helper.getString("restartapp"));
|
||||
ToastUtils.a(getString("restartapp"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static android.widget.Toast.*;
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserToken;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplication;
|
||||
import static ru.vtosters.lite.utils.SettBackup.backupSettings;
|
||||
import static ru.vtosters.lite.utils.SettBackup.deletePrefs;
|
||||
import static ru.vtosters.lite.utils.SettBackup.restoreBackup;
|
||||
@@ -12,7 +16,6 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
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;
|
||||
@@ -26,8 +29,6 @@ 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 {
|
||||
|
||||
@Override
|
||||
@@ -62,7 +63,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
copy(GetContext(), GetUserToken());
|
||||
copy(getContext(), getUserToken());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -73,6 +74,8 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
VKImageLoader.b();
|
||||
ImEngineProvider.a().h();
|
||||
AudioMessageUtils.j();
|
||||
@@ -99,7 +102,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
restarting();
|
||||
restartApplication();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -129,9 +132,9 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
SharedPreferences prefs = GetContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
restarting();
|
||||
restartApplication();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -143,7 +146,7 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
deletePrefs();
|
||||
restarting();
|
||||
restartApplication();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.componentSwitcher;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
@@ -7,9 +10,6 @@ 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 {
|
||||
|
||||
@Override
|
||||
@@ -21,11 +21,14 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
public boolean apply(Preference preference, Object obj) {
|
||||
if (((Boolean) obj).booleanValue()) {
|
||||
IconHelper.switchToVK();
|
||||
componentSwitcher("VTIconDefault", false);
|
||||
componentSwitcher("VTIconVK", true);
|
||||
} else {
|
||||
IconHelper.switchToDefault();
|
||||
componentSwitcher("VTIconDefault", true);
|
||||
componentSwitcher("VTIconVK", false);
|
||||
}
|
||||
ToastUtils.a(Helper.getString("iconapplying"));
|
||||
|
||||
ToastUtils.a(getString("iconapplying"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +41,7 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
public static class b implements Preference.b {
|
||||
@Override // android.support.v7.preference.Preference.b
|
||||
public boolean a(Preference preference, Object obj) {
|
||||
ToastUtils.a(Helper.getString("restartapp"));
|
||||
ToastUtils.a(getString("restartapp"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
@@ -14,7 +15,6 @@ import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public class DockBarAdapter extends RecyclerView.a
|
||||
@@ -42,7 +42,7 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
}
|
||||
|
||||
private View createTabItem() {
|
||||
LinearLayout container = new LinearLayout(GetContext());
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
container.setTag("tab_item_container");
|
||||
container.setGravity(Gravity.CENTER_VERTICAL);
|
||||
container.setOrientation(LinearLayout.HORIZONTAL);
|
||||
@@ -54,7 +54,7 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
);
|
||||
container.setLayoutParams(new LinearLayout.LayoutParams(-1, convertDpToPixel(48)));
|
||||
|
||||
ImageView icon = new ImageView(GetContext());
|
||||
ImageView icon = new ImageView(getContext());
|
||||
icon.setTag("icon");
|
||||
icon.setImageTintList(ColorStateList.valueOf(Themes.getAccentColor()));
|
||||
icon.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
@@ -62,7 +62,7 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
convertDpToPixel(24)));
|
||||
container.addView(icon);
|
||||
|
||||
TextView title = new TextView(GetContext());
|
||||
TextView title = new TextView(getContext());
|
||||
title.setTag("title");
|
||||
title.setTextSize(16.0f);
|
||||
title.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
@@ -76,10 +76,10 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
}
|
||||
|
||||
private View createGroupTitle() {
|
||||
LinearLayout layout = new LinearLayout(GetContext());
|
||||
LinearLayout layout = new LinearLayout(getContext());
|
||||
layout.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
|
||||
|
||||
TextView title = new TextView(GetContext());
|
||||
TextView title = new TextView(getContext());
|
||||
title.setTag("group_title");
|
||||
title.setTextSize(13.0f);
|
||||
title.setPadding(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplication;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@@ -14,7 +15,6 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import me.grishka.appkit.fragments.ToolbarFragment;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class DockBarFragment extends ToolbarFragment {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DockBarFragment extends ToolbarFragment {
|
||||
save.setText("Сохранить");
|
||||
save.setOnClickListener(v -> {
|
||||
DockBarManager.getInstance().save();
|
||||
restarting();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
LinearLayout.LayoutParams saveParams = new LinearLayout.LayoutParams(0, -2);
|
||||
@@ -57,7 +57,7 @@ public class DockBarFragment extends ToolbarFragment {
|
||||
reset.setText("Сбросить");
|
||||
reset.setOnClickListener(v -> {
|
||||
DockBarManager.getInstance().delete();
|
||||
restarting();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
LinearLayout.LayoutParams resetParams = new LinearLayout.LayoutParams(0, -2);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Themes.getAccentColor;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -26,8 +28,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class DockBarInjector {
|
||||
private static final DockBarManager sManager = DockBarManager.getInstance();
|
||||
|
||||
@@ -63,12 +63,18 @@ public class DockBarInjector {
|
||||
|
||||
for (DockBarTab tab : sManager.getSelectedTabs()) {
|
||||
MenuItem add = menu.add(0, tab.id, 0, tab.titleID);
|
||||
Drawable drawable = GetContext().getResources().getDrawable(tab.iconID);
|
||||
ColorStateList colorStateList = GetContext().getResources().getColorStateList(com.vtosters.lite.R.color.bottom_navigation_item);
|
||||
// if (isAndroidMonet()) {
|
||||
// colorStateList = ColorStateList.valueOf(Themes.getAccentColor());
|
||||
// }
|
||||
add.setIcon(new RecoloredDrawable(drawable, colorStateList));
|
||||
Drawable drawable = getContext().getResources().getDrawable(tab.iconID);
|
||||
ColorStateList dockcolors = new ColorStateList(
|
||||
new int[][]{
|
||||
new int[]{android.R.attr.state_checked},
|
||||
new int[]{-android.R.attr.state_checked}
|
||||
},
|
||||
new int[] {
|
||||
getAccentColor(),
|
||||
Color.parseColor("#ffaaaeb3")
|
||||
}
|
||||
);
|
||||
add.setIcon(new RecoloredDrawable(drawable, dockcolors));
|
||||
add.setShowAsAction(1);
|
||||
add.setCheckable(true);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.newfeed;
|
||||
import static ru.vtosters.lite.utils.Preferences.olddock;
|
||||
|
||||
import com.vk.apps.AppsFragment;
|
||||
import com.vk.discover.DiscoverFeedFragment;
|
||||
import com.vk.discover.DiscoverFragment;
|
||||
import com.vk.fave.fragments.FaveTabFragment;
|
||||
import com.vk.feedlikes.fragments.FeedLikesFragment;
|
||||
import com.vk.menu.MenuFragment;
|
||||
import com.vk.music.fragment.MusicFragment;
|
||||
import com.vk.newsfeed.Feed2049;
|
||||
import com.vk.newsfeed.HomeFragment;
|
||||
import com.vk.newsfeed.NewsfeedFragment;
|
||||
import com.vk.notifications.NotificationsContainerFragment;
|
||||
import com.vtosters.lite.R;
|
||||
@@ -40,9 +43,6 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
|
||||
public class DockBarManager {
|
||||
public static final int MIN_SELECTED_TABS_LIMIT = 3;
|
||||
public static final int MAX_SELECTED_TABS_LIMIT = 9;
|
||||
@@ -75,14 +75,14 @@ public class DockBarManager {
|
||||
}
|
||||
|
||||
private void load() {
|
||||
File dockbar = new File(Helper.GetContext().getFilesDir(), "dockbar.json");
|
||||
File dockbar = new File(getContext().getFilesDir(), "dockbar.json");
|
||||
|
||||
if (!dockbar.exists()) {
|
||||
mSelectedTabs.add(new DockBarTab("tab_news", Prefs.olddock() ? R.drawable.ic_newsfeed_28 : R.drawable.ic_menu_newsfeed_outline_28, R.string.newsfeed, R.id.tab_news, Prefs.isUseAlternativeFragments() ? Feed2049.b.c() : NewsfeedFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_discover", Prefs.olddock() ? R.drawable.ic_search_28 : R.drawable.ic_menu_search_outline_28, R.string.search, R.id.tab_discover, Prefs.isUseAlternativeFragments() ? DiscoverFragment.class : DiscoverFeedFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_messages", Prefs.olddock() ? R.drawable.ic_menu_messages_28 : R.drawable.ic_message_28_outline, R.string.messages, R.id.tab_messages, DialogsFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_feedback", Prefs.olddock() ? R.drawable.ic_menu_notifications_28 : R.drawable.ic_menu_notification_outline_28, R.string.feedback, R.id.tab_feedback, NotificationsContainerFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_menu", Prefs.olddock() ? R.drawable.ic_menu_more_28 : R.drawable.ic_menu_more_outline_28, R.string.menu, R.id.tab_menu, MenuFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_news", olddock() ? R.drawable.ic_newsfeed_28 : R.drawable.ic_menu_newsfeed_outline_28, R.string.newsfeed, R.id.tab_news, newfeed() ? HomeFragment.class : NewsfeedFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_discover", olddock() ? R.drawable.ic_search_28 : R.drawable.ic_menu_search_outline_28, R.string.search, R.id.tab_discover, DiscoverFragment.class ));
|
||||
mSelectedTabs.add(new DockBarTab("tab_messages", olddock() ? R.drawable.ic_menu_messages_28 : R.drawable.ic_message_28_outline, R.string.messages, R.id.tab_messages, DialogsFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_feedback", olddock() ? R.drawable.ic_menu_notifications_28 : R.drawable.ic_menu_notification_outline_28, R.string.feedback, R.id.tab_feedback, NotificationsContainerFragment.class));
|
||||
mSelectedTabs.add(new DockBarTab("tab_menu", olddock() ? R.drawable.ic_menu_more_28 : R.drawable.ic_menu_more_outline_28, R.string.menu, R.id.tab_menu, MenuFragment.class));
|
||||
|
||||
mDisabledTabs.add(new DockBarTab("tab_friends", R.drawable.ic_user_24, R.string.friends, R.id.menu_friends, FriendsFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_groups", R.drawable.ic_users_24, R.string.groups, R.id.menu_groups, GroupsFragment.class));
|
||||
@@ -114,17 +114,17 @@ public class DockBarManager {
|
||||
item.getInt("id"),
|
||||
Class.forName(item.getString("fragmentClass"))
|
||||
);
|
||||
if (Prefs.isUseAlternativeFragments()) {
|
||||
if (newfeed()) {
|
||||
if (tab.fragmentClass == NewsfeedFragment.class) {
|
||||
tab.fragmentClass = Feed2049.b.c();
|
||||
} else if (tab.fragmentClass == DiscoverFeedFragment.class) {
|
||||
tab.fragmentClass = HomeFragment.class;
|
||||
} else if (tab.fragmentClass == DiscoverFragment.class) {
|
||||
tab.fragmentClass = DiscoverFragment.class;
|
||||
}
|
||||
} else {
|
||||
if (tab.fragmentClass == Feed2049.b.c()) {
|
||||
if (tab.fragmentClass == HomeFragment.class) {
|
||||
tab.fragmentClass = NewsfeedFragment.class;
|
||||
} else if (tab.fragmentClass == DiscoverFragment.class) {
|
||||
tab.fragmentClass = DiscoverFeedFragment.class;
|
||||
tab.fragmentClass = DiscoverFragment.class;
|
||||
}
|
||||
}
|
||||
mSelectedTabs.add(tab);
|
||||
@@ -140,17 +140,17 @@ public class DockBarManager {
|
||||
item.getInt("id"),
|
||||
Class.forName(item.getString("fragmentClass"))
|
||||
);
|
||||
if (Prefs.isUseAlternativeFragments()) {
|
||||
if (newfeed()) {
|
||||
if (tab.fragmentClass == NewsfeedFragment.class) {
|
||||
tab.fragmentClass = Feed2049.b.c();
|
||||
} else if (tab.fragmentClass == DiscoverFeedFragment.class) {
|
||||
tab.fragmentClass = HomeFragment.class;
|
||||
} else if (tab.fragmentClass == DiscoverFragment.class) {
|
||||
tab.fragmentClass = DiscoverFragment.class;
|
||||
}
|
||||
} else {
|
||||
if (tab.fragmentClass == Feed2049.b.c()) {
|
||||
if (tab.fragmentClass == HomeFragment.class) {
|
||||
tab.fragmentClass = NewsfeedFragment.class;
|
||||
} else if (tab.fragmentClass == DiscoverFragment.class) {
|
||||
tab.fragmentClass = DiscoverFeedFragment.class;
|
||||
tab.fragmentClass = DiscoverFragment.class;
|
||||
}
|
||||
}
|
||||
mDisabledTabs.add(tab);
|
||||
@@ -163,13 +163,13 @@ public class DockBarManager {
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
File dockbar = new File(Helper.GetContext().getFilesDir(), "dockbar.json");
|
||||
File dockbar = new File(getContext().getFilesDir(), "dockbar.json");
|
||||
if (dockbar.exists()) dockbar.delete();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
File dockbar = new File(Helper.GetContext().getFilesDir(), "dockbar.json");
|
||||
File dockbar = new File(getContext().getFilesDir(), "dockbar.json");
|
||||
|
||||
JSONArray selected = new JSONArray();
|
||||
for (DockBarTab tab : mSelectedTabs) {
|
||||
|
||||
+18
-8
@@ -1,8 +1,15 @@
|
||||
package ru.vtosters.lite.ui.fragments.multiaccount;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Themes.*;
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getResources;
|
||||
import static ru.vtosters.lite.utils.Globals.isNetworkConnected;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplication;
|
||||
import static ru.vtosters.lite.utils.Themes.getTextAttr;
|
||||
import static ru.vtosters.lite.utils.Themes.recolorDrawable;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@@ -26,9 +33,6 @@ import com.vtosters.lite.im.ImEngineProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.MultiAccountViewHolder> {
|
||||
|
||||
private final List<MultiAccountItem> mAccounts = MultiAccountManager.buildList();
|
||||
@@ -126,7 +130,9 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
VKAccount b = VKAccountManager.b();
|
||||
PushSubscriber.a.a(b.b(), b.c());
|
||||
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
|
||||
restarting();
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
restartApplication();
|
||||
});
|
||||
Drawable drawable = recolorDrawable(getResources().getDrawable(R.drawable.ic_list_add));
|
||||
mAction.setImageDrawable(drawable);
|
||||
@@ -142,7 +148,9 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
VKAccount b = VKAccountManager.b();
|
||||
PushSubscriber.a.a(b.b(), b.c());
|
||||
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
|
||||
restarting();
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
restartApplication();
|
||||
|
||||
});
|
||||
|
||||
@@ -163,7 +171,9 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
VKAccount b = VKAccountManager.b();
|
||||
PushSubscriber.a.a(b.b(), b.c());
|
||||
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
|
||||
restarting();
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
restartApplication();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments.multiaccount;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@@ -9,7 +11,6 @@ import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import me.grishka.appkit.fragments.ToolbarFragment;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class MultiAccountFragment extends ToolbarFragment {
|
||||
|
||||
@@ -36,6 +37,6 @@ public class MultiAccountFragment extends ToolbarFragment {
|
||||
|
||||
super.a(arg0, arg1);
|
||||
|
||||
a(Helper.getString("accounts"));
|
||||
a(getString("accounts"));
|
||||
}
|
||||
}
|
||||
|
||||
+34
-18
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments.multiaccount;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Helper.GetContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPreferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -12,26 +12,34 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class MultiAccountManager {
|
||||
|
||||
public static void migrate() {
|
||||
SharedPreferences OldPrefs = GetContext().getSharedPreferences("pref_account_manager", Context.MODE_PRIVATE);
|
||||
SharedPreferences OldPrefs = getContext().getSharedPreferences("pref_account_manager", Context.MODE_PRIVATE);
|
||||
String OldPrefsValue = OldPrefs.getString("key_vk_account", "");
|
||||
SharedPreferences NewPrefs = GetContext().getSharedPreferences("pref_account_manager0", Context.MODE_PRIVATE);
|
||||
SharedPreferences NewPrefs = getContext().getSharedPreferences("pref_account_manager0", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = NewPrefs.edit();
|
||||
editor.putString("key_vk_account", OldPrefsValue);
|
||||
editor.apply();
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public static void migrationRestart() {
|
||||
SharedPreferences prefs = getPreferences();
|
||||
if (prefs.getBoolean("multiaccount_restart", true)) {
|
||||
prefs.edit().putBoolean("multiaccount_restart", false).commit();
|
||||
Globals.restartApplication();
|
||||
}
|
||||
}
|
||||
|
||||
public static SharedPreferences getCurrentAccount() {
|
||||
int account = GetPreferences().getInt("account", 0);
|
||||
return GetContext().getSharedPreferences("pref_account_manager" + (account != 0 ? account : ""), Context.MODE_PRIVATE);
|
||||
int account = getPreferences().getInt("account", 0);
|
||||
return getContext().getSharedPreferences("pref_account_manager" + (account != 0 ? account : ""), Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
private static int getAccountPrefsCount() {
|
||||
File[] prefs = new File(GetContext().getFilesDir().getParent(), "shared_prefs")
|
||||
File[] prefs = new File(getContext().getFilesDir().getParent(), "shared_prefs")
|
||||
.listFiles((dir, name) -> {
|
||||
return name.matches("pref_account_manager\\d+\\.xml");
|
||||
});
|
||||
@@ -50,7 +58,7 @@ public class MultiAccountManager {
|
||||
public static List<MultiAccountItem> buildList() {
|
||||
List<MultiAccountItem> list = new ArrayList<>();
|
||||
for (int i = 0; i <= getAccountPrefsCount(); i++) {
|
||||
SharedPreferences prefs = GetContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
|
||||
String keyVKAccount = prefs.getString("key_vk_account", "");
|
||||
if (!keyVKAccount.isEmpty()) {
|
||||
String name = withRegex(keyVKAccount, ".*\"name\":\\{.*?:\"(.*?)\"\\}.*", "");
|
||||
@@ -65,24 +73,32 @@ public class MultiAccountManager {
|
||||
}
|
||||
|
||||
public static boolean switchAccount(int i) {
|
||||
int account = GetPreferences().getInt("account", 0);
|
||||
int account = getPreferences().getInt("account", 0);
|
||||
if (account == i) return false;
|
||||
|
||||
GetPreferences().edit().putInt("account", i).commit();
|
||||
getPreferences().edit().putInt("account", i).commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void addAccount() {
|
||||
GetPreferences().edit().putInt("account", getAccountPrefsCount()).commit();
|
||||
getPreferences().edit().putInt("account", getAccountPrefsCount()).commit();
|
||||
}
|
||||
|
||||
public static void deleteAccount(int i) {
|
||||
int account = GetPreferences().getInt("account", 0);
|
||||
SharedPreferences prefs = GetContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
|
||||
int account = getPreferences().getInt("account", 0);
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
File file = new File(new File(GetContext().getFilesDir().getParent(), "shared_prefs"), "pref_account_manager" + i);
|
||||
File file = new File(new File(getContext().getFilesDir().getParent(), "shared_prefs"), "pref_account_manager" + i);
|
||||
if (file.exists()) file.delete();
|
||||
if (account == i && getAccountPrefsCount() > 0)
|
||||
switchAccount(buildList().get(0).index);
|
||||
if (account == i && getAccountPrefsCount() > 0) {
|
||||
List<MultiAccountItem> accounts = buildList();
|
||||
if (accounts.size() > 0)
|
||||
switchAccount(buildList().get(0).index);
|
||||
else {
|
||||
getContext().getSharedPreferences("pref_account_manager", Context.MODE_PRIVATE)
|
||||
.edit().clear().commit();
|
||||
Globals.getPreferences().edit().putBoolean("multiaccount_restart", true).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
package ru.vtosters.lite.ui.fragments.tgstickers;
|
||||
|
||||
import static android.widget.Toast.*;
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Themes.*;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getResources;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Themes.getAccentColor;
|
||||
import static ru.vtosters.lite.utils.Themes.getSTextAttr;
|
||||
import static ru.vtosters.lite.utils.Themes.getTabbarBackground;
|
||||
import static ru.vtosters.lite.utils.Themes.getTextAttr;
|
||||
import static ru.vtosters.lite.utils.Themes.recolorDrawable;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
@@ -28,7 +37,6 @@ 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;
|
||||
@@ -47,15 +55,12 @@ import java.io.File;
|
||||
import me.grishka.appkit.fragments.ToolbarFragment;
|
||||
import ru.vtosters.lite.tgs.TGPref;
|
||||
import ru.vtosters.lite.ui.PreferencesUtil;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
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 final static int TYPE_DIRECT = 0, TYPE_SOCKS = 2;
|
||||
private static final String TAG = "StickersFragment";
|
||||
public int from;
|
||||
public int to;
|
||||
@@ -92,7 +97,6 @@ public class StickersFragment extends ToolbarFragment {
|
||||
private void initGrabber() {
|
||||
int method = TGPref.getTGConnectMethod();
|
||||
switch (method) {
|
||||
case TYPE_TOASTER_SERVER:
|
||||
case TYPE_DIRECT:
|
||||
TelegramStickersGrabber.USE_PROXY = false;
|
||||
grabber.resetProxy();
|
||||
@@ -209,7 +213,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
@Override
|
||||
public View d(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
grabber = new TelegramStickersGrabber(TGPref.getTGBotKey());
|
||||
stickersService = TelegramStickersService.getInstance(GetContext());
|
||||
stickersService = TelegramStickersService.getInstance(getContext());
|
||||
|
||||
editPadding = convertDpToPixel(24f);
|
||||
|
||||
@@ -246,19 +250,18 @@ public class StickersFragment extends ToolbarFragment {
|
||||
openMenu(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(GetContext()));
|
||||
editText.setHintTextColor(PreferencesUtil.getSTextColor(getContext()));
|
||||
|
||||
// Костыль для китката
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
} else {
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
}
|
||||
linearLayout.addView(editText);
|
||||
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
@@ -272,7 +275,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
String pack = editText.getText().toString();
|
||||
pack = parsePack(pack);
|
||||
stickersService.requestPackDownload(pack, new File(GetContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
stickersService.requestPackDownload(pack, new File(getContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
}).setNeutralButton(android.R.string.cancel, null).create().show();
|
||||
};
|
||||
if (TGPref.getTGBotKey() == null) enterBotKey(() -> checkApiKey(work));
|
||||
@@ -291,7 +294,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
@Override
|
||||
public void b(@Nullable Bundle savedInstanceState) {
|
||||
super.b(savedInstanceState);
|
||||
GetContext().registerReceiver(receiver, new IntentFilter(ACTION_RELOAD));
|
||||
getContext().registerReceiver(receiver, new IntentFilter(ACTION_RELOAD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -306,7 +309,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
@Override
|
||||
public void A_() {
|
||||
super.A_();
|
||||
GetContext().unregisterReceiver(receiver);
|
||||
getContext().unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
private String parsePack(String pack) {
|
||||
@@ -353,7 +356,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
holder.updateButton.setImageDrawable(recolorDrawable(getResources().getDrawable(R.drawable.ic_camera_switch_48)));
|
||||
holder.updateButton.setOnClickListener(listener -> {
|
||||
stickersService.setBotKey(TGPref.getTGBotKey());
|
||||
stickersService.requestPackDownload(pack.id, new File(GetContext().getFilesDir(), new File("VT-Stickers", pack.id).getAbsolutePath()));
|
||||
stickersService.requestPackDownload(pack.id, new File(getContext().getFilesDir(), new File("VT-Stickers", pack.id).getAbsolutePath()));
|
||||
});
|
||||
|
||||
holder.deleteButton.setImageDrawable(recolorDrawable(getResources().getDrawable(R.drawable.vkim_ic_msg_delete)));
|
||||
@@ -367,7 +370,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
holder.switchCompat.setOnCheckedChangeListener((buttonView, isChecked) -> stickersService.setPackEnabled(pack, isChecked, false));
|
||||
holder.count.setText(pack.stickersCount + " " + getString("stickerscount"));
|
||||
|
||||
holder.layout.setBackgroundColor(Prefs.getNavbarColor());
|
||||
holder.layout.setBackgroundColor(getTabbarBackground());
|
||||
|
||||
// Color костыль
|
||||
int color = getTextAttr();
|
||||
|
||||
+4
-4
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments.tgstickers;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -11,7 +12,6 @@ import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
import ru.vtosters.lite.tgs.TGPref;
|
||||
import ru.vtosters.lite.tgs.TGRoot;
|
||||
import ru.vtosters.lite.ui.PreferencesUtil;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
|
||||
int vtosterXml = GetContext().getResources().getIdentifier("empty", "xml", GetContext().getPackageName());
|
||||
int vtosterXml = getContext().getResources().getIdentifier("empty", "xml", getContext().getPackageName());
|
||||
this.a(vtosterXml);
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("sprefsstickers"));
|
||||
@@ -85,7 +85,7 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
|
||||
|
||||
@Override
|
||||
public int aq() {
|
||||
return GetContext().getResources().getIdentifier("vtltgs", "string", GetContext().getPackageName());
|
||||
return getContext().getResources().getIdentifier("vtltgs", "string", getContext().getPackageName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getApplicationName;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.VERSIONNAME;
|
||||
import static ru.vtosters.lite.utils.Preferences.oldabout;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.vk.about.Items;
|
||||
import com.vk.about.Items1;
|
||||
import com.vk.about.Items2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class About {
|
||||
public static void injectAbout(List<Items2> list) {
|
||||
list.clear();
|
||||
list.add(new Items1());
|
||||
if (!oldabout()) {
|
||||
list.add(new Items(21, com.vtosters.lite.R.string.opencommit));
|
||||
list.add(new Items(8, com.vtosters.lite.R.string.tgchannel));
|
||||
list.add(new Items(9, com.vtosters.lite.R.string.tgchat));
|
||||
list.add(new Items(16, com.vtosters.lite.R.string.vtfaq));
|
||||
list.add(new Items(19, com.vtosters.lite.R.string.vtsite));
|
||||
list.add(new Items(20, com.vtosters.lite.R.string.donate));
|
||||
list.add(new Items(17, com.vtosters.lite.R.string.vkgroup));
|
||||
list.add(new Items(18, com.vtosters.lite.R.string.sett_debug));
|
||||
return;
|
||||
}
|
||||
list.add(new Items(0, com.vtosters.lite.R.string.about_app_feedback));
|
||||
list.add(new Items(1, com.vtosters.lite.R.string.about_app_estimate));
|
||||
list.add(new Items(2, com.vtosters.lite.R.string.about_app_privacy));
|
||||
list.add(new Items(5, com.vtosters.lite.R.string.about_app_cookie));
|
||||
list.add(new Items(3, com.vtosters.lite.R.string.about_app_terms_to_use));
|
||||
list.add(new Items(4, com.vtosters.lite.R.string.about_app_license));
|
||||
list.add(new Items(6, com.vtosters.lite.R.string.about_app_data_protect));
|
||||
list.add(new Items(8, com.vtosters.lite.R.string.sett_debug));
|
||||
}
|
||||
public static String getBuildNumber() {
|
||||
return getBuild(getContext(), "version.properties");
|
||||
}
|
||||
|
||||
public static String getCommitLink() {
|
||||
return "https://git.devshelter.su/gdlbo/lite/commit/" + getBuild(getContext(), "version.properties"); // https://github.com/vtosters/lite/commit/ github repo
|
||||
}
|
||||
|
||||
public static String getBuild(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=", "");
|
||||
return "0000000";
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "0000000";
|
||||
}
|
||||
|
||||
public static String getAppVersion() throws IOException {
|
||||
return getApplicationName() + " " + VERSIONNAME + " | " + getBuildNumber();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.vk.im.engine.events.OnMsgUpdateEvent;
|
||||
import com.vk.im.engine.internal.longpoll.a.MsgDeleteLpTask;
|
||||
import com.vk.im.engine.internal.storage.CacheEnvironment;
|
||||
import com.vk.im.engine.models.messages.Msg;
|
||||
import com.vk.im.engine.models.messages.MsgFromUser;
|
||||
import com.vk.im.engine.models.messages.NestedMsg;
|
||||
import com.vk.libsqliteext.CustomSqliteExtensions;
|
||||
|
||||
import org.sqlite.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
|
||||
public class DeletedMessagesHandler {
|
||||
private static List<Integer> sDeletedMessagesList = new ArrayList<>();
|
||||
|
||||
private static SQLiteDatabase sVKSQLiteDatabase;
|
||||
private static int sBodyIndex = -1;
|
||||
private static DeletedMessagesDBHelper sVTDatabase;
|
||||
|
||||
public static void reloadMessagesList() {
|
||||
if (sVTDatabase == null) {
|
||||
sVTDatabase = new DeletedMessagesDBHelper();
|
||||
}
|
||||
sDeletedMessagesList = new ArrayList<>(sVTDatabase.loadAllMessages());
|
||||
}
|
||||
|
||||
public static void grabVKDatabase(CacheEnvironment storageEnvironment) {
|
||||
sVKSQLiteDatabase = storageEnvironment.b();
|
||||
}
|
||||
|
||||
public static boolean hook() {
|
||||
return getBoolValue("undeletemsg", false);
|
||||
}
|
||||
|
||||
public static void setBodyDBParser(Msg msg) {
|
||||
if (!(msg instanceof MsgFromUser)) return;
|
||||
|
||||
for (Integer integer : sDeletedMessagesList) {
|
||||
MsgFromUser msgFromUser = (MsgFromUser) msg;
|
||||
checkForNestedMsg(msgFromUser.g);
|
||||
if (integer == msg.d) {
|
||||
editTextOfMsg((MsgFromUser) msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkForNestedMsg(List<NestedMsg> nestedMsgs) {
|
||||
for (NestedMsg nestedMsg : nestedMsgs) {
|
||||
if (!nestedMsg.i.isEmpty()) checkForNestedMsg(nestedMsg.i);
|
||||
|
||||
nestedMsg.b(EncryptProvider.decryptMessage(nestedMsg.E(), nestedMsg.h().c));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void editTextOfMsg(MsgFromUser msgFromUser) {
|
||||
if (!msgFromUser.e.startsWith(getPreifxUndelete())) {
|
||||
msgFromUser.e = getPreifxUndelete() + EncryptProvider.decryptMessage(msgFromUser);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPreifxUndelete() {
|
||||
return getPrefsValue("undeletemsg_prefix") + " ";
|
||||
}
|
||||
|
||||
public static void updateDialog(MsgDeleteLpTask msgDeleteLpTask) {
|
||||
Cursor c = getMessageFromDatabaseById(msgDeleteLpTask.c);
|
||||
if (c == null) return;
|
||||
|
||||
int localId = c.getInt(c.getColumnIndex("local_id"));
|
||||
|
||||
String str = DeletedMessagesHandler.class.getSimpleName();
|
||||
msgDeleteLpTask.a.a(str, new OnMsgUpdateEvent(str, msgDeleteLpTask.b, localId));
|
||||
}
|
||||
|
||||
public static void hookDeletedMessageId(MsgDeleteLpTask msgDeleteLpTask) {
|
||||
if (!hook()) return;
|
||||
|
||||
int messageId = msgDeleteLpTask.c;
|
||||
|
||||
Cursor c = getMessageFromDatabaseById(messageId);
|
||||
if (c == null) return;
|
||||
if (sBodyIndex == -1) sBodyIndex = c.getColumnIndex("body");
|
||||
if (TextUtils.isEmpty(c.getString(sBodyIndex))) {
|
||||
deleteMessageFromDB(messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
sDeletedMessagesList.add(messageId);
|
||||
sVTDatabase.saveDeletedMessage(messageId);
|
||||
}
|
||||
|
||||
public static Cursor getMessageFromDatabaseById(int messageId) {
|
||||
String query = "SELECT * FROM messages WHERE vk_id = " + messageId;
|
||||
Cursor c = CustomSqliteExtensions.a(sVKSQLiteDatabase, query);
|
||||
if (!c.moveToFirst()) return null;
|
||||
return c;
|
||||
}
|
||||
|
||||
public static void deleteMessageFromDB(int messageId) {
|
||||
sVKSQLiteDatabase.execSQL("DELETE FROM messages WHERE vk_id = " + messageId);
|
||||
}
|
||||
|
||||
public static class DeletedMessagesDBHelper extends SQLiteOpenHelper {
|
||||
public DeletedMessagesDBHelper() {
|
||||
super(getContext(), "deleted_msgs", null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(android.database.sqlite.SQLiteDatabase db) {
|
||||
db.execSQL("create table deleted_msgs (id integer primary key, msgId integer)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(android.database.sqlite.SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
|
||||
}
|
||||
|
||||
public void saveDeletedMessage(int msgId) {
|
||||
android.database.sqlite.SQLiteDatabase sqLiteDatabase = getWritableDatabase();
|
||||
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put("msgId", msgId);
|
||||
|
||||
sqLiteDatabase.insert("deleted_msgs", null, contentValues);
|
||||
sqLiteDatabase.close();
|
||||
}
|
||||
|
||||
public List<Integer> loadAllMessages() {
|
||||
List<Integer> msgIdsList = new ArrayList<>();
|
||||
|
||||
Cursor cursor = getReadableDatabase().query("deleted_msgs", null, null, null, null, null, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
int msgIdIndex = cursor.getColumnIndex("msgId");
|
||||
|
||||
do {
|
||||
msgIdsList.add(cursor.getInt(msgIdIndex));
|
||||
} while (cursor.moveToNext());
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
return msgIdsList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.isEmpty;
|
||||
import static ru.vtosters.lite.utils.Preferences.isEnableExternalOpening;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
@@ -39,7 +41,7 @@ public class ExternalLinkHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (!Prefs.isEnableExternalOpening()) return false;
|
||||
if (!isEnableExternalOpening()) return false;
|
||||
|
||||
if (checkVkVideo(file)) {
|
||||
if (qualities.size() == 1) {
|
||||
@@ -120,7 +122,7 @@ public class ExternalLinkHandler {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
GetContext().startActivity(intent);
|
||||
getContext().startActivity(intent);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -129,7 +131,7 @@ public class ExternalLinkHandler {
|
||||
}
|
||||
|
||||
private static String getMXPlayerPackageName() {
|
||||
for (ApplicationInfo info : GetContext().getPackageManager().getInstalledApplications(0)) {
|
||||
for (ApplicationInfo info : getContext().getPackageManager().getInstalledApplications(0)) {
|
||||
String packName = info.packageName;
|
||||
if (packName.equals("com.mxtech.videoplayer.ad") || packName.equals("com.mxtech.videoplayer.pro"))
|
||||
return packName;
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getLocale;
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.vtosters.lite.UserProfile;
|
||||
import com.vtosters.lite.VKActivity;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Globals {
|
||||
private static final List<Activity> activities = new ArrayList<>();
|
||||
|
||||
public static SharedPreferences getDefprefs() {
|
||||
if (preferences == null) preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
return preferences;
|
||||
}
|
||||
|
||||
public static void componentSwitcher(String component, Boolean enabled) {
|
||||
var packageManager = getContext().getPackageManager();
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(getPackageName(), getPackageName() + "." + component), enabled? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
} // Component switcher for changing app icon
|
||||
|
||||
public static String getPrefsValue(String pref) {
|
||||
return getPreferences().getString(pref, "");
|
||||
} // Get pref value as string
|
||||
|
||||
public static int getUserId() {
|
||||
return VKAccountManager.b().a();
|
||||
} // Current UserId
|
||||
|
||||
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();
|
||||
} // Edit SharedPreferences
|
||||
|
||||
public static void reloadMSG() {
|
||||
ImEngineProvider.a().h();
|
||||
} // Delete and reload msg cache
|
||||
|
||||
public static int getUserID(UserProfile userProfile) {
|
||||
return userProfile.n;
|
||||
} // UserId Profile via userProfile
|
||||
|
||||
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));
|
||||
} // UserId Profile via extendedUserProfile
|
||||
|
||||
public static UserProfile fromEup(ExtendedUserProfile extendedUserProfile) {
|
||||
return extendedUserProfile.a;
|
||||
}
|
||||
|
||||
public static void restartApplication() {
|
||||
Context ctx = getContext();
|
||||
PackageManager pm = ctx.getPackageManager();
|
||||
|
||||
Intent intent = pm.getLaunchIntentForPackage(ctx.getPackageName());
|
||||
Intent mainIntent = Intent.makeRestartActivityTask(intent.getComponent());
|
||||
ctx.startActivity(mainIntent);
|
||||
|
||||
Runtime.getRuntime().exit(0);
|
||||
} // Application restart (works on sdk 29+ too)
|
||||
|
||||
@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;
|
||||
} // Getting the global context through reflection to use context on application initialization
|
||||
|
||||
|
||||
public static boolean isGmsInstalled() {
|
||||
try {
|
||||
getContext().getPackageManager().getPackageInfo("com.google.android.gms", 0);
|
||||
return true;
|
||||
} catch (Exception unused) {
|
||||
return false;
|
||||
}
|
||||
} // Google Market Services check
|
||||
|
||||
public static Resources getResources() {
|
||||
return getContext().getResources();
|
||||
}
|
||||
|
||||
public static int getIdentifier(String name, String type) {
|
||||
return getResources().getIdentifier(name, type, getContext().getPackageName());
|
||||
} // Get res id
|
||||
|
||||
public static String getString(String resourcename) {
|
||||
return getContext().getString(Integer.parseInt(String.valueOf(getContext().getResources().getIdentifier(resourcename, "string", getContext().getPackageName()))));
|
||||
} // Get string via getIdentifier
|
||||
|
||||
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 SharedPreferences getPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
}
|
||||
|
||||
public static void sendToast(String text) {
|
||||
Toast.makeText(getContext(), text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isNetworkConnected() {
|
||||
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
|
||||
} // Network check
|
||||
|
||||
public static void fixGapps() {
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
boolean hasMusicChannel = false;
|
||||
|
||||
try {
|
||||
if (notificationManager.getNotificationChannel("audio_playback_channel") != null) {
|
||||
hasMusicChannel = true;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
if (!hasMusicChannel) {
|
||||
notificationManager.createNotificationChannel(new NotificationChannel("audio_playback_channel", getResources().getString(com.vtosters.lite.R.string.audio_message_play_error), NotificationManager.IMPORTANCE_LOW));
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} // Music channels fix
|
||||
|
||||
public static void registerActivities(Application application) {
|
||||
application.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
|
||||
@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) {
|
||||
activities.add(activity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
activities.remove(activity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Activity getCurrentActivity() {
|
||||
if (activities.size() == 0) return null;
|
||||
else return activities.get(0);
|
||||
}
|
||||
|
||||
public static String getApplicationName() {
|
||||
return getContext().getApplicationInfo().loadLabel(getContext().getPackageManager()).toString();
|
||||
}
|
||||
|
||||
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;
|
||||
} // Language changer and BaseContext injector
|
||||
|
||||
public static float[] getCenterScreenCoords() {
|
||||
int width = getResources().getDisplayMetrics().widthPixels;
|
||||
int height = getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
int centerWidth = width/2;
|
||||
int centerHeight = height/2;
|
||||
return new float[] {centerWidth, centerHeight};
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Proxy.*;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
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;
|
||||
|
||||
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 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() {
|
||||
Context ctx = GetContext();
|
||||
PackageManager pm = ctx.getPackageManager();
|
||||
Intent intent = pm.getLaunchIntentForPackage(ctx.getPackageName());
|
||||
Intent mainIntent = Intent.makeRestartActivityTask(intent.getComponent());
|
||||
ctx.startActivity(mainIntent);
|
||||
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 GetContext().getString(Integer.parseInt(String.valueOf(GetContext().getResources().getIdentifier(str, "string", 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();
|
||||
}
|
||||
|
||||
public static boolean isNetworkConnected() {
|
||||
ConnectivityManager cm = (ConnectivityManager) GetContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
public class IconHelper {
|
||||
public static void switchToVK() {
|
||||
var packageManager = GetContext().getPackageManager();
|
||||
var packageName = getPackageName();
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
public static void switchToDefault() {
|
||||
var packageManager = GetContext().getPackageManager();
|
||||
var packageName = getPackageName();
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static java.lang.Long.MAX_VALUE;
|
||||
import static ru.vtosters.lite.ui.fragments.dockbar.DockBarManager.getInstance;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.CommentsSort;
|
||||
import static ru.vtosters.lite.utils.Preferences.adsgroup;
|
||||
import static ru.vtosters.lite.utils.Preferences.adsstories;
|
||||
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.copyright_post;
|
||||
import static ru.vtosters.lite.utils.Preferences.friendsrecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.newfeed;
|
||||
import static ru.vtosters.lite.utils.Preferences.postsrecomm;
|
||||
|
||||
import com.vk.apps.AppsFragment;
|
||||
import com.vk.core.preference.Preference;
|
||||
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.HomeFragment;
|
||||
import com.vk.newsfeed.NewsfeedFragment;
|
||||
import com.vk.notifications.NotificationsContainerFragment;
|
||||
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;
|
||||
|
||||
public class Newsfeed {
|
||||
public static List<String> mFilters;
|
||||
|
||||
public static boolean isBlockedByFilter(String str) {
|
||||
for (String str2 : mFilters) {
|
||||
if (str.toLowerCase().contains(str2.toLowerCase())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void setupFilters() {
|
||||
mFilters = new ArrayList();
|
||||
|
||||
getFilter("refsfilter", "Referals.txt");
|
||||
getFilter("shortlinkfilter", "LinkShorter.txt");
|
||||
getFilter("default_ad_list", "StandartFilter.txt");
|
||||
getFilter("shitposting", "IDontWantToReadIt.txt");
|
||||
|
||||
String customfilters = getPrefsValue("spamfilters");
|
||||
|
||||
if (!customfilters.isEmpty()) {
|
||||
mFilters.addAll(Arrays.asList(customfilters.split(", ")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void getFilter(String boolname, String filename) {
|
||||
if (getBoolValue(boolname, true)) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getContext().getAssets().open(filename)));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine != null) {
|
||||
mFilters.add(readLine);
|
||||
} else {
|
||||
bufferedReader.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} // Get needed filter list from assets
|
||||
|
||||
public static boolean injectFilters(JSONObject jSONObject) {
|
||||
String optString = jSONObject.optString(NavigatorKeys.j, "");
|
||||
if (!ads(optString) && !checkCopyright(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, "")) || captions(jSONObject)) {
|
||||
return false;
|
||||
}
|
||||
return !AD(jSONObject);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} // json newsfeed/posts injector to detect and delete posts
|
||||
|
||||
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 (!Preferences.captions()) {
|
||||
return true;
|
||||
}
|
||||
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 ads(String str) {
|
||||
if ((str.equals("ads_easy_promote") || str.equals("promo_button") || str.equals("app_widget") || str.equals("ads")) && Preferences.ads()) {
|
||||
return true;
|
||||
}
|
||||
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(String str) {
|
||||
return str.equals("copyright") && copyright_post();
|
||||
}
|
||||
|
||||
public static String friendsads() {
|
||||
return postsrecomm() ? "user_rec" : "null";
|
||||
}
|
||||
|
||||
public static String getFriendRecomm() {
|
||||
return friendsrecomm() ? "friends_recommendations" : "null";
|
||||
}
|
||||
|
||||
public static String authorsads() {
|
||||
return authorsrecomm() ? "authors_rec" : "null";
|
||||
}
|
||||
|
||||
public static String widgetads() {
|
||||
return Preferences.ads() ? "null" : "app_widget";
|
||||
}
|
||||
|
||||
public static String promoads() {
|
||||
return Preferences.ads() ? "null" : "promo_button";
|
||||
}
|
||||
|
||||
public static String storyads() {
|
||||
return adsstories() ? "null" : "ads";
|
||||
}
|
||||
|
||||
public static String getCommentsSort(int value) {
|
||||
return !CommentsSort() && value == 2 || value == 1 ? "desc" : "asc";
|
||||
}
|
||||
|
||||
public static long getUpdateNewsfeed(boolean refresh_timeout) {
|
||||
switch (getPrefsValue("newsupdate")) {
|
||||
case "no_update":
|
||||
return MAX_VALUE;
|
||||
case "imd_update":
|
||||
return 10000L;
|
||||
default:
|
||||
return Preference.b().getLong(refresh_timeout ? "refresh_timeout_top" : "refresh_timeout_recent", 600000L);
|
||||
}
|
||||
}
|
||||
|
||||
public static Class getStartFragment() {
|
||||
switch (getPrefsValue("start_values")) {
|
||||
case "newsfeed":
|
||||
return newfeed() ? HomeFragment.class : NewsfeedFragment.class;
|
||||
case "messenger":
|
||||
return DialogsFragment.class;
|
||||
case "groups":
|
||||
return GroupsFragment.class;
|
||||
case "music":
|
||||
return MusicFragment.class;
|
||||
case "friends":
|
||||
return FriendsFragment.class;
|
||||
case "photos":
|
||||
return PhotosFragment.class;
|
||||
case "videos":
|
||||
return VideosFragment.class;
|
||||
case "settings":
|
||||
return SettingsListFragment.class;
|
||||
case "apps":
|
||||
return AppsFragment.class;
|
||||
case "discover":
|
||||
return DiscoverFragment.class;
|
||||
case "notifications":
|
||||
return NotificationsContainerFragment.class;
|
||||
case "money":
|
||||
return MoneyTransfersFragment.class;
|
||||
case "games":
|
||||
return GamesFragment.class;
|
||||
case "liked":
|
||||
return FaveTabFragment.class;
|
||||
case "menu":
|
||||
return MenuFragment.class;
|
||||
case "profile":
|
||||
return ProfileFragment.class;
|
||||
case "lives":
|
||||
return LivesTabsFragment.class;
|
||||
case "docs":
|
||||
return DocumentsViewFragment.class;
|
||||
case "brtd":
|
||||
return BirthdaysFragment.class;
|
||||
default:
|
||||
return getInstance().getSelectedTabs().get(0).fragmentClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,18 +37,15 @@ public class OEMDetector {
|
||||
|
||||
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;
|
||||
return bufferedReader.readLine();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.opusmodule;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.vk.medianative.MediaNative;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class OpusLoader {
|
||||
private static long timetracker;
|
||||
private static boolean inited;
|
||||
|
||||
public static void LoadLibrary(String libname){
|
||||
try {
|
||||
System.loadLibrary(libname);
|
||||
inited = true;
|
||||
} catch (UnsatisfiedLinkError unused2) {
|
||||
if(dev()) Log.d("VTLite", "Failed to load " + libname);
|
||||
inited = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLength() {
|
||||
if (isReadyToUse()) {
|
||||
long length = System.currentTimeMillis() - timetracker;
|
||||
timetracker = System.currentTimeMillis();
|
||||
return length;
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static int AudioStartRecordBridge(String str) {
|
||||
if (isReadyToUse()) {
|
||||
// Init custom AudioStartRecord
|
||||
timetracker = System.currentTimeMillis();
|
||||
return 1;
|
||||
}
|
||||
return MediaNative.nativeAudioStartRecord(str);
|
||||
}
|
||||
|
||||
public static int AudioWriteFrameBridge(ByteBuffer buffer, int length) {
|
||||
if (isReadyToUse()) {
|
||||
// Init custom AudioWriteFrame
|
||||
}
|
||||
return MediaNative.nativeAudioWriteFrame(buffer, length);
|
||||
}
|
||||
|
||||
public static void AudioStopRecordBridge() {
|
||||
if (isReadyToUse()) {
|
||||
// Init custom AudioStopRecord
|
||||
}
|
||||
MediaNative.nativeAudioStopRecord();
|
||||
}
|
||||
|
||||
private static boolean isReadyToUse() {
|
||||
return opusmodule() && inited;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager.migrate;
|
||||
import static ru.vtosters.lite.utils.DeletedMessagesHandler.reloadMessagesList;
|
||||
import static ru.vtosters.lite.utils.Globals.fixGapps;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Globals.registerActivities;
|
||||
import static ru.vtosters.lite.utils.Newsfeed.setupFilters;
|
||||
import static ru.vtosters.lite.utils.OpusLoader.LoadLibrary;
|
||||
import static ru.vtosters.lite.utils.Proxy.setProxy;
|
||||
import static ru.vtosters.lite.utils.Themes.systemThemeChanger;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.vk.core.util.Screen;
|
||||
import com.vtosters.lite.data.Users;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Preferences {
|
||||
public static SharedPreferences preferences = getContext().getSharedPreferences("com.vtosters.lite_preferences", Context.MODE_PRIVATE);
|
||||
|
||||
public static String VERSIONNAME = "Beta";
|
||||
|
||||
public static Integer VKBUILD = 12116; // 3439 orig
|
||||
public static String VKVER = "7.24"; // 5.29 orig
|
||||
|
||||
public static void init(Application application) {
|
||||
setupFilters();
|
||||
fixGapps();
|
||||
setProxy();
|
||||
migrate();
|
||||
reloadMessagesList();
|
||||
registerActivities(application);
|
||||
LoadLibrary("vkopustest");
|
||||
systemThemeChanger();
|
||||
} // VK Init
|
||||
|
||||
public static boolean getBoolValue(String key, Boolean value) {
|
||||
if (preferences == null) {
|
||||
preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
}
|
||||
return preferences.getBoolean(key, value);
|
||||
} // Set bool by default and get value
|
||||
|
||||
public static boolean opusmodule() {
|
||||
return getBoolValue("opusmodule", true);
|
||||
}
|
||||
|
||||
public static boolean systemtheme() {
|
||||
return getBoolValue("systemtheme", true);
|
||||
}
|
||||
|
||||
public static boolean authorsrecomm() {
|
||||
return getBoolValue("authorsrecomm", true);
|
||||
}
|
||||
|
||||
public static boolean captions() {
|
||||
return getBoolValue("captions", true);
|
||||
}
|
||||
|
||||
public static boolean copyright_post() {
|
||||
return getBoolValue("copyright_post", false);
|
||||
}
|
||||
|
||||
public static boolean default_ad_list() {
|
||||
return getBoolValue("default_ad_list", false);
|
||||
}
|
||||
|
||||
public static boolean shitposting() {
|
||||
return getBoolValue("shitposting", false);
|
||||
}
|
||||
|
||||
public static boolean friendsrecomm() {
|
||||
return getBoolValue("friendsrecomm", true);
|
||||
}
|
||||
|
||||
public static boolean isBGStickersEnabled() {
|
||||
return getBoolValue("isBGStickersEnabled", true);
|
||||
}
|
||||
|
||||
public static boolean ads() {
|
||||
return getBoolValue("__dbg_no_ads", false);
|
||||
}
|
||||
|
||||
public static boolean adsgroup() {
|
||||
return getBoolValue("adsgroup", false);
|
||||
}
|
||||
|
||||
public static boolean olddock() {
|
||||
return getBoolValue("olddock", false);
|
||||
}
|
||||
|
||||
public static boolean adsslider() {
|
||||
return getBoolValue("__dbg_no_slider_ads", false);
|
||||
}
|
||||
|
||||
public static boolean adsstories() {
|
||||
return getBoolValue("adsstories", false);
|
||||
}
|
||||
|
||||
public static boolean alteremoji(Context context) {
|
||||
return alteremojipref() ? alteremojipref() : Screen.a(context);
|
||||
}
|
||||
|
||||
public static boolean alteremojipref() {
|
||||
return getBoolValue("alteremoji", false);
|
||||
}
|
||||
|
||||
public static boolean awayphp() {
|
||||
return getBoolValue("awayphp", true);
|
||||
}
|
||||
|
||||
public static boolean VKUI_INJ() {
|
||||
return getBoolValue("VKUI_INJ", true);
|
||||
}
|
||||
|
||||
public static boolean benchmark() {
|
||||
return getBoolValue("benchmark", false);
|
||||
}
|
||||
|
||||
public static boolean calls() {
|
||||
return getBoolValue("calls", true);
|
||||
}
|
||||
|
||||
public static boolean convUsersOnline() {
|
||||
return getBoolValue("convUsersOnline", false);
|
||||
}
|
||||
|
||||
public static boolean darkmode() {
|
||||
return getBoolValue("darkmode", true);
|
||||
}
|
||||
|
||||
public static boolean dev() {
|
||||
return getBoolValue("dev", false);
|
||||
}
|
||||
|
||||
public static boolean devmenu() {
|
||||
return getBoolValue("devmenu", false);
|
||||
}
|
||||
|
||||
public static boolean dnr() {
|
||||
return getBoolValue("dnr", true);
|
||||
}
|
||||
|
||||
public static boolean dns() {
|
||||
return getBoolValue("dns", true);
|
||||
}
|
||||
|
||||
public static boolean libverify() {
|
||||
return getBoolValue("libverify", false);
|
||||
}
|
||||
|
||||
public static boolean dnt() {
|
||||
return getBoolValue("dnt", true);
|
||||
}
|
||||
|
||||
public static boolean dockcounter() {
|
||||
return getBoolValue("dockcounter", true);
|
||||
}
|
||||
|
||||
public static boolean feedcache() {
|
||||
return getBoolValue("feedcache", true);
|
||||
}
|
||||
|
||||
public static boolean CommentsSort() {
|
||||
return getBoolValue("commentssorting", false);
|
||||
}
|
||||
|
||||
public static void forceOffline() {
|
||||
if (setoffline()) {
|
||||
Users.b();
|
||||
}
|
||||
setupFilters();
|
||||
}
|
||||
|
||||
public static boolean fulltime() {
|
||||
return getBoolValue("fulltime", true);
|
||||
}
|
||||
|
||||
public static boolean gcmfix() {
|
||||
return getBoolValue("gcmfix", true);
|
||||
}
|
||||
|
||||
public static boolean hasMusicSubscription() {
|
||||
return getBoolValue("hasMusicSubscription", true);
|
||||
}
|
||||
|
||||
public static boolean isEnableExternalOpening() {
|
||||
return getBoolValue("isEnableExternalOpening", false);
|
||||
}
|
||||
|
||||
public static boolean iconvk() {
|
||||
return getBoolValue("iconvk", false);
|
||||
}
|
||||
|
||||
public static boolean iconvkru() {
|
||||
return getBoolValue("iconvkru", false);
|
||||
}
|
||||
|
||||
public static boolean isMusicRestricted() {
|
||||
return getBoolValue("isMusicRestricted", true);
|
||||
}
|
||||
|
||||
public static boolean msgflat() {
|
||||
return getBoolValue("msgflat", false);
|
||||
}
|
||||
|
||||
public static boolean msgtails() {
|
||||
return getBoolValue("msgtails", true);
|
||||
}
|
||||
|
||||
public static boolean navbar() {
|
||||
return getBoolValue("navbar", true);
|
||||
}
|
||||
|
||||
public static boolean newfeed() {
|
||||
return getBoolValue("newfeed", true);
|
||||
}
|
||||
|
||||
public static boolean offline() {
|
||||
return getBoolValue("offline", true);
|
||||
}
|
||||
|
||||
public static boolean oldabout() {
|
||||
return getBoolValue("oldabout", false);
|
||||
}
|
||||
|
||||
public static boolean postsrecomm() {
|
||||
return getBoolValue("postsrecomm", true);
|
||||
}
|
||||
|
||||
public static String readstatus() {
|
||||
return dnr() ? "messages.markAsRead" : "null";
|
||||
}
|
||||
|
||||
public static String copyrightfix() {
|
||||
return copyright_post() ? "copyright" : "ads_easy_promote";
|
||||
}
|
||||
|
||||
public static boolean refsfilter() {
|
||||
return getBoolValue("refsfilter", false);
|
||||
}
|
||||
|
||||
public static boolean setoffline() {
|
||||
return getBoolValue("setoffline", false);
|
||||
}
|
||||
|
||||
public static boolean shortinfo() {
|
||||
return getBoolValue("shortinfo", true);
|
||||
}
|
||||
|
||||
public static boolean shortlinkfilter() {
|
||||
return getBoolValue("shortlinkfilter", false);
|
||||
}
|
||||
|
||||
public static boolean shortpost() {
|
||||
return getBoolValue("shortpost", true);
|
||||
}
|
||||
|
||||
public static boolean showmenu() {
|
||||
return getBoolValue("showmenu", false);
|
||||
}
|
||||
|
||||
public static boolean ssl() {
|
||||
return getBoolValue("ssl", true);
|
||||
}
|
||||
|
||||
public static boolean stories() {
|
||||
return getBoolValue("stories", true);
|
||||
}
|
||||
|
||||
public static boolean swipe() {
|
||||
return getBoolValue("swipe", true);
|
||||
}
|
||||
|
||||
public static boolean systememoji() {
|
||||
return getBoolValue("systememoji", false);
|
||||
}
|
||||
|
||||
public static boolean unlockstats() {
|
||||
return getBoolValue("unlockstats", false);
|
||||
}
|
||||
|
||||
public static boolean usevkui() {
|
||||
return getBoolValue("usevkui", true);
|
||||
}
|
||||
|
||||
public static boolean vksans() {
|
||||
return getBoolValue("vksans", false);
|
||||
}
|
||||
|
||||
public static boolean voice() {
|
||||
return getBoolValue("voice", true);
|
||||
}
|
||||
|
||||
public static boolean newvideo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getMsgCount() {
|
||||
String customvalue = getPrefsValue("msgcount");
|
||||
return customvalue.isEmpty() ? 30 : Integer.parseInt(customvalue);
|
||||
}
|
||||
|
||||
public static String MediacontentFix() {
|
||||
return Build.VERSION.SDK_INT >= 29 ? "date_modified DESC" : "datetaken DESC";
|
||||
} // Fix photo picker for sdk 29+
|
||||
|
||||
public static String MediacontentFix2() {
|
||||
return Build.VERSION.SDK_INT >= 29 ? "date_modified" : "datetaken";
|
||||
} // Fix photo picker for sdk 29+
|
||||
|
||||
public static String MediacontentFix3() {
|
||||
return Build.VERSION.SDK_INT >= 29 ? ", date_modified=" : ", dateTaken=";
|
||||
} // Fix photo picker for sdk 29+
|
||||
|
||||
public static boolean color_grishka() {
|
||||
return getBoolValue("color_grishka", true);
|
||||
}
|
||||
|
||||
public static boolean vkme_msg() {
|
||||
return getBoolValue("vkme_msg", false);
|
||||
}
|
||||
|
||||
public static String VKVersion() {
|
||||
return VKVER;
|
||||
}
|
||||
|
||||
public static int VKVersionBuild() {
|
||||
return VKBUILD;
|
||||
}
|
||||
|
||||
public static long VKVersionBuildLong() {
|
||||
return VKVersionBuild();
|
||||
}
|
||||
|
||||
public static String getLocale() {
|
||||
String string = getPrefsValue("lang_value");
|
||||
if (string.equals("system")) {
|
||||
return Locale.getDefault().getLanguage();
|
||||
}
|
||||
return string.isEmpty() ? Locale.getDefault().getLanguage() : string;
|
||||
}
|
||||
}
|
||||
@@ -1,900 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
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.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.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 ru.vtosters.lite.ui.fragments.dockbar.DockBarManager;
|
||||
import ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager;
|
||||
|
||||
public class Prefs {
|
||||
private static final List<Activity> activities = new ArrayList<>();
|
||||
public static String VERSIONNAME = "2.0 Beta";
|
||||
private static List<String> mFilters;
|
||||
|
||||
public static boolean BooleanFalse(String key) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GetContext());
|
||||
return prefs.getBoolean(key, false);
|
||||
}
|
||||
|
||||
public static boolean BooleanTrue(String key) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(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 olddock() {
|
||||
return BooleanFalse("olddock");
|
||||
}
|
||||
|
||||
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 shitposting() {
|
||||
return BooleanFalse("shitposting");
|
||||
}
|
||||
|
||||
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 libverify() {
|
||||
return BooleanFalse("libverify");
|
||||
}
|
||||
|
||||
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.getBuild(GetContext(), "version.properties");
|
||||
}
|
||||
|
||||
public static String getCommitLink() {
|
||||
return "https://github.com/vtosters/lite/commit/" + Prefs.getBuild(GetContext(), "version.properties");
|
||||
}
|
||||
|
||||
public static String getBuild(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=", "");
|
||||
return "0000000";
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getBranch() {
|
||||
return GetPreferences().getString("ota_branches", "Stable");
|
||||
}
|
||||
|
||||
public static String getDarkVKUI() {
|
||||
return !VKThemeHelper.d() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getAmoledVKUI() {
|
||||
String string = GetPreferences().getString("darktheme", "");
|
||||
return string.equals("amoled") ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getCommentsSort(String def) {
|
||||
String string = GetPreferences().getString("commentssort", "");
|
||||
if (string.isEmpty()) {
|
||||
return def;
|
||||
}
|
||||
if (string.equals("new")) {
|
||||
return "desc";
|
||||
}
|
||||
if (string.equals("old")) {
|
||||
return "asc";
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static String getMeToken() {
|
||||
return GetPreferences().getString("me_token", "");
|
||||
}
|
||||
|
||||
public static void setMeToken(String str) {
|
||||
GetPreferences().edit().putString("me_token", str).apply();
|
||||
}
|
||||
|
||||
public static int getNavbarColor() {
|
||||
return VKThemeHelper.a(R.attr.tabbar_background);
|
||||
}
|
||||
|
||||
public static String getSSFSLink() {
|
||||
return SSFSDomain() + "?token=" + GetUserToken() + "&vt_dark=" + getDarkVKUI() + "&vt_amoled=" + getAmoledVKUI() + "&secret=" + 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(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 BooleanTrue("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 = GetPreferences().getString("proxyHostHTTP", "");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyHostHTTPS() {
|
||||
String string = GetPreferences().getString("proxyHostHTTPS", "");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyHostSocks() {
|
||||
String string = GetPreferences().getString("proxyHostSocks", "");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortHTTP() {
|
||||
String string = GetPreferences().getString("proxyPortHTTP", "");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortHTTPS() {
|
||||
String string = GetPreferences().getString("proxyPortHTTPS", "");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortSocks() {
|
||||
String string = 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 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 boolean newvideo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String widgetads() {
|
||||
return ads() ? "null" : "app_widget";
|
||||
}
|
||||
|
||||
public static int getMsgCount() {
|
||||
String customvalue = GetPreferences().getString("msgcount", "");
|
||||
return customvalue.isEmpty() ? 30 : Integer.parseInt(customvalue);
|
||||
}
|
||||
|
||||
public static void setNavbarColor(Window window, int i) {
|
||||
if (navbar() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
window.setNavigationBarColor(getNavbarColor());
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
IDontWantToReadIt();
|
||||
String string = 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(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(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(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 void IDontWantToReadIt() {
|
||||
if (BooleanTrue("shitposting")) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(GetContext().getAssets().open("IDontWantToReadIt.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 = GetPreferences().getString("ssfscustom", "");
|
||||
if (!string.isEmpty()) {
|
||||
return string;
|
||||
}
|
||||
return "https://vtsf.vknext.net";
|
||||
}
|
||||
|
||||
public static String VKVersion() {
|
||||
String string = 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(21, R.string.opencommit));
|
||||
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 = GetPreferences().getString("lang_value", "");
|
||||
if (string.equals("system")) {
|
||||
return Locale.getDefault().getLanguage();
|
||||
}
|
||||
return string.isEmpty() ? Locale.getDefault().getLanguage() : string;
|
||||
}
|
||||
|
||||
public static boolean proxy() {
|
||||
return GetPreferences().getString("proxy", "").equals("apiproxy");
|
||||
}
|
||||
|
||||
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();
|
||||
MultiAccountManager.migrate();
|
||||
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 boolean isUseAlternativeFragments() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Class getStartFragment() {
|
||||
String string = GetPreferences().getString("start_values", "");
|
||||
if (string.equals("default")) {
|
||||
return DockBarManager.getInstance().getSelectedTabs().get(0).fragmentClass;
|
||||
}
|
||||
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("photos")) {
|
||||
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 Feed2049.b.e();
|
||||
}
|
||||
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 : DockBarManager.getInstance().getSelectedTabs().get(0).fragmentClass;
|
||||
}
|
||||
|
||||
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) 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", getResources().getString(R.string.audio_message_play_error), NotificationManager.IMPORTANCE_LOW));
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,23 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
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 static java.lang.System.clearProperty;
|
||||
import static java.lang.System.getProperties;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class Proxy {
|
||||
public static String getOauthComAuth() {
|
||||
String oauthComHttps = getOauthComHttps();
|
||||
return oauthComHttps + "/authorize";
|
||||
return getOauthComHttps() + "/authorize";
|
||||
}
|
||||
|
||||
public static String getOauthComAuthClient() {
|
||||
String oauthComAuth = getOauthComAuth();
|
||||
return oauthComAuth + "?client_id=";
|
||||
return getOauthComAuth() + "?client_id=";
|
||||
}
|
||||
|
||||
public static String getOauthComBlank() {
|
||||
String oauthComHttps = getOauthComHttps();
|
||||
return oauthComHttps + "/blank.html";
|
||||
return getOauthComHttps() + "/blank.html";
|
||||
}
|
||||
|
||||
public static String getOauthComBlankRedirect() {
|
||||
@@ -35,8 +29,7 @@ public class Proxy {
|
||||
}
|
||||
|
||||
public static String getStaticComSupport() {
|
||||
String staticCom = getStaticCom();
|
||||
return staticCom + "/support";
|
||||
return getStaticCom() + "/support";
|
||||
}
|
||||
|
||||
public static String oauthFix() {
|
||||
@@ -44,32 +37,32 @@ public class Proxy {
|
||||
}
|
||||
|
||||
public static String getApiCom() {
|
||||
String string = GetPreferences().getString("proxyapi", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
String string = getPrefsValue("proxyapi");
|
||||
if (!proxy() & string.isEmpty()) {
|
||||
return "api.vk.com";
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String getAwayPhpCom() {
|
||||
String string = GetPreferences().getString("proxyapi", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
String string = getPrefsValue("proxyapi");
|
||||
if (!proxy() & string.isEmpty()) {
|
||||
return "m.vk.com";
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String getOauthCom() {
|
||||
String string = GetPreferences().getString("proxyoauth", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
String string = getPrefsValue("proxyoauth");
|
||||
if (!proxy() & string.isEmpty()) {
|
||||
return "oauth.vk.com";
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String getStaticCom() {
|
||||
String string = GetPreferences().getString("proxystatic", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
String string = getPrefsValue("proxystatic");
|
||||
if (!proxy() & string.isEmpty()) {
|
||||
return "static.vk.com";
|
||||
}
|
||||
return string;
|
||||
@@ -77,75 +70,145 @@ public class Proxy {
|
||||
|
||||
public static String staticFix(String str) {
|
||||
String str2;
|
||||
String string = GetPreferences().getString("proxystatic", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
String string = getPrefsValue("proxystatic");
|
||||
if (!proxy() & string.isEmpty()) {
|
||||
return str;
|
||||
}
|
||||
str2 = string;
|
||||
return str.replace(str2, "static.vk.com");
|
||||
}
|
||||
|
||||
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() {
|
||||
Properties properties = getProperties();
|
||||
switch (getPrefsValue("proxy")) {
|
||||
case "zaborona":
|
||||
properties.setProperty("socksProxyHost", "socks.zaboronahelp.pp.ua");
|
||||
properties.setProperty("socksProxyPort", "1488");
|
||||
resetProxySocks();
|
||||
break;
|
||||
case "socks":
|
||||
properties.setProperty("socksProxyHost", proxyHostSocks());
|
||||
properties.setProperty("socksProxyPort", proxyPortSocks());
|
||||
resetProxySocks();
|
||||
break;
|
||||
case "http":
|
||||
properties.setProperty("http.proxyHost", proxyHostHTTP());
|
||||
properties.setProperty("http.proxyPort", proxyPortHTTP());
|
||||
properties.setProperty("http.proxyUser", proxyUserHTTP());
|
||||
properties.setProperty("http.proxyPassword", proxyPassHTTP());
|
||||
resetProxyHttp();
|
||||
break;
|
||||
case "https":
|
||||
properties.setProperty("https.proxyHost", proxyHostHTTPS());
|
||||
properties.setProperty("https.proxyPort", proxyPortHTTPS());
|
||||
properties.setProperty("https.proxyUser", proxyUserHTTPS());
|
||||
properties.setProperty("https.proxyPassword", proxyPassHTTPS());
|
||||
resetProxyHttps();
|
||||
break;
|
||||
default:
|
||||
resetProxy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setProxy() {
|
||||
switch (GetPreferences().getString("proxy", "")) {
|
||||
case "zaborona":
|
||||
Properties properties = System.getProperties();
|
||||
properties.setProperty("socksProxyHost", "socks.zaboronahelp.pp.ua");
|
||||
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;
|
||||
}
|
||||
public static void resetProxy() {
|
||||
clearProperty("https.proxyHost");
|
||||
clearProperty("https.proxyPort");
|
||||
clearProperty("https.proxyUser");
|
||||
clearProperty("https.proxyPassword");
|
||||
clearProperty("http.proxyHost");
|
||||
clearProperty("http.proxyPort");
|
||||
clearProperty("http.proxyUser");
|
||||
clearProperty("http.proxyPassword");
|
||||
clearProperty("socksProxyHost");
|
||||
clearProperty("socksPortHost");
|
||||
} // Reset all proxies
|
||||
|
||||
public static void resetProxySocks() {
|
||||
clearProperty("https.proxyHost");
|
||||
clearProperty("https.proxyPort");
|
||||
clearProperty("https.proxyUser");
|
||||
clearProperty("https.proxyPassword");
|
||||
clearProperty("http.proxyHost");
|
||||
clearProperty("http.proxyPort");
|
||||
clearProperty("http.proxyUser");
|
||||
clearProperty("http.proxyPassword");
|
||||
} // Reset all except socks
|
||||
|
||||
public static void resetProxyHttp() {
|
||||
clearProperty("https.proxyHost");
|
||||
clearProperty("https.proxyPort");
|
||||
clearProperty("https.proxyUser");
|
||||
clearProperty("https.proxyPassword");
|
||||
clearProperty("socksProxyHost");
|
||||
clearProperty("socksPortHost");
|
||||
} // Reset all except http
|
||||
|
||||
public static void resetProxyHttps() {
|
||||
clearProperty("http.proxyHost");
|
||||
clearProperty("http.proxyPort");
|
||||
clearProperty("http.proxyUser");
|
||||
clearProperty("http.proxyPassword");
|
||||
clearProperty("socksProxyHost");
|
||||
clearProperty("socksPortHost");
|
||||
} // Reset all except https
|
||||
|
||||
public static String proxyHostHTTP() {
|
||||
String string = getPrefsValue("proxyHostHTTP");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyHostHTTPS() {
|
||||
String string = getPrefsValue("proxyHostHTTPS");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyHostSocks() {
|
||||
String string = getPrefsValue("proxyHostSocks");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortHTTP() {
|
||||
String string = getPrefsValue("proxyPortHTTP");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortHTTPS() {
|
||||
String string = getPrefsValue("proxyPortHTTPS");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortSocks() {
|
||||
String string = getPrefsValue("proxyPortSocks");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static String proxyUserHTTP() {
|
||||
String string = getPrefsValue("proxyUserHTTP");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
public static String proxyUserHTTPS() {
|
||||
String string = getPrefsValue("proxyUserHTTPS");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
public static String proxyPassHTTP() {
|
||||
String string = getPrefsValue("proxyPassHTTP");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
public static String proxyPassHTTPS() {
|
||||
String string = getPrefsValue("proxyPassHTTPS");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
public static boolean proxy() {
|
||||
return getPrefsValue("proxy").equals("apiproxy");
|
||||
}
|
||||
|
||||
|
||||
public static boolean proxyvk() {
|
||||
return getBoolValue("proxyvk", false);
|
||||
} // Official vk proxy enforcer
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.About.getBuildNumber;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserSecret;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserToken;
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.lite.utils.Preferences.getLocale;
|
||||
import static ru.vtosters.lite.utils.Preferences.vksans;
|
||||
import static ru.vtosters.lite.utils.Proxy.proxy;
|
||||
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
|
||||
public class SSFS {
|
||||
public static String getSSFSLink() {
|
||||
return SSFSDomain() + "?token=" + getUserToken() + "&vt_dark=" + getDarkVKUI() + "&vt_amoled=" + getAmoledVKUI() + "&secret=" + getUserSecret() + "&proxy=" + getUserProxy() + "&lang=" + getLocale() + "&vt=1&vtl=1&vksans=" + isVKSansEnabled() + "&vt_version=" + getBuildNumber() + "&vt_debug=" + isDEVModEnabled();
|
||||
}
|
||||
|
||||
public static String SSFSDomain() {
|
||||
String string = getPrefsValue("ssfscustom");
|
||||
if (!string.isEmpty()) {
|
||||
return string;
|
||||
}
|
||||
return "https://vtsf.vknext.net";
|
||||
}
|
||||
|
||||
public static String getDarkVKUI() {
|
||||
return !VKThemeHelper.d() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getAmoledVKUI() {
|
||||
return getPrefsValue("darktheme").equals("amoled") ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getUserProxy() {
|
||||
return proxy() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String isVKSansEnabled() {
|
||||
return vksans() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String isDEVModEnabled() {
|
||||
return dev() ? "1" : "0";
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,9 @@ import static android.os.Environment.getExternalStoragePublicDirectory;
|
||||
import static android.widget.Toast.LENGTH_LONG;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.Helper.GetContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Base64;
|
||||
|
||||
@@ -21,18 +20,18 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class SettBackup {
|
||||
static SharedPreferences prefs = GetContext().getSharedPreferences("com.vtosters.lite_preferences", Context.MODE_PRIVATE);
|
||||
static SharedPreferences prefs = getContext().getSharedPreferences("com.vtosters.lite_preferences", Context.MODE_PRIVATE);
|
||||
|
||||
public static void deletePrefs() {
|
||||
prefs.edit().clear().commit();
|
||||
File file = new File(new File(GetContext().getFilesDir().getParent(), "shared_prefs"), "com.vtosters.lite_preferences");
|
||||
File file = new File(new File(getContext().getFilesDir().getParent(), "shared_prefs"), "com.vtosters.lite_preferences");
|
||||
if (file.exists()) file.delete();
|
||||
}
|
||||
|
||||
public static void backupSettings() {
|
||||
SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault());
|
||||
String currentDateandTime = date.format(new Date());
|
||||
var directory = getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS) + "/VTLBackup_" + currentDateandTime + ".txt";
|
||||
var directory = getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS + "/VTLBackups/") + "/Backup_" + currentDateandTime + ".txt";
|
||||
var file = new File(directory);
|
||||
try {
|
||||
var exists = file.createNewFile();
|
||||
@@ -45,15 +44,15 @@ public class SettBackup {
|
||||
FileWriter out = new FileWriter(file);
|
||||
out.write(getAllPrefs());
|
||||
out.close();
|
||||
makeText(GetContext(), "Сохранено в файл " + directory, LENGTH_LONG).show();
|
||||
makeText(getContext(), "Сохранено в файл " + directory, LENGTH_LONG).show();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
makeText(GetContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
|
||||
makeText(getContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
makeText(GetContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
|
||||
makeText(getContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +62,7 @@ public class SettBackup {
|
||||
}
|
||||
|
||||
public static void restoreBackup() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType("text/plain");
|
||||
GetContext().startActivity(intent);
|
||||
File dir = new File(getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS + "/VTLBackups/").getPath());;
|
||||
// TODO Make restore backup from file list
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,114 +1,152 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.color_grishka;
|
||||
import static ru.vtosters.lite.utils.Preferences.isBGStickersEnabled;
|
||||
import static ru.vtosters.lite.utils.Preferences.navbar;
|
||||
import static ru.vtosters.lite.utils.Preferences.systemtheme;
|
||||
import static ru.vtosters.lite.utils.Preferences.vksans;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.vk.core.d.RecoloredDrawable;
|
||||
import com.vk.core.ui.themes.VKTheme;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vk.im.ui.themes.ImTheme;
|
||||
import com.vk.im.ui.themes.ImThemeHelper;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Themes {
|
||||
public static List<String> accentColors = Arrays.asList(
|
||||
"71AAEB", "3F8AE0", "528BCC", "4986CC", "5181B8", "74A2D6", "518BCC"
|
||||
);
|
||||
|
||||
public static void applyTheme(VKTheme theme, ImTheme imtheme) {
|
||||
VKThemeHelper.b.a(theme); // VKThemeHelper.b.a(VKTheme value) VK Theme apply
|
||||
ImThemeHelper.b.a(imtheme); // ImThemeHelper.b.a(ImTheme value) VK Theme Msg apply
|
||||
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
|
||||
|
||||
public static int getAccentColor() {
|
||||
return VKThemeHelper.a(R.attr.accent);
|
||||
}
|
||||
} // Color accent
|
||||
|
||||
public static int getTextAttr() {
|
||||
return VKThemeHelper.a(R.attr.text_primary);
|
||||
}
|
||||
} // Text Primary color
|
||||
|
||||
public static int getSTextAttr() {
|
||||
return VKThemeHelper.a(R.attr.text_secondary);
|
||||
}
|
||||
} // Text Secondary color
|
||||
|
||||
public static int getTabbarBackground() {
|
||||
return VKThemeHelper.a(R.attr.tabbar_background);
|
||||
}
|
||||
} // Tabbar/Navbar background
|
||||
|
||||
public static int getBackgroundContent() {
|
||||
return VKThemeHelper.a(R.attr.background_content);
|
||||
} // Background color in app
|
||||
|
||||
public static int getHeaderBackground() {
|
||||
return VKThemeHelper.a(R.attr.header_background);
|
||||
}
|
||||
|
||||
public static int getAmoledTheme() {
|
||||
return GetContext().getResources().getIdentifier("BaseAmoledStyle", "style", GetContext().getPackageName());
|
||||
}
|
||||
|
||||
public static int picFix() {
|
||||
return GetContext().getResources().getIdentifier("ActionBarThemeFix", "style", GetContext().getPackageName());
|
||||
}
|
||||
|
||||
public static int getAmoledImTheme() {
|
||||
return GetContext().getResources().getIdentifier("VkIm.Theme.VkApp.Amoled", "style", GetContext().getPackageName());
|
||||
}
|
||||
|
||||
public static VKTheme getDarkTheme() {
|
||||
String string = GetPreferences().getString("darktheme", "");
|
||||
if (string.isEmpty()) {
|
||||
return VKTheme.DARK;
|
||||
}
|
||||
if (string.equals("amoled")) {
|
||||
return VKTheme.AMOLED;
|
||||
}
|
||||
return VKTheme.DARK;
|
||||
}
|
||||
|
||||
public static ImTheme getImDarkTheme() {
|
||||
String string = GetPreferences().getString("darktheme", "");
|
||||
if (string.isEmpty()) {
|
||||
return ImTheme.VKAPP_DARK;
|
||||
}
|
||||
if (string.equals("amoled")) {
|
||||
return ImTheme.VKAPP_AMOLED;
|
||||
}
|
||||
return ImTheme.VKAPP_DARK;
|
||||
}
|
||||
|
||||
public static VKTheme getLightTheme() {
|
||||
String string = GetPreferences().getString("lighttheme", "");
|
||||
if (string.isEmpty()) {
|
||||
return VKTheme.DEFAULT_LIGHT;
|
||||
}
|
||||
return VKTheme.DEFAULT_LIGHT;
|
||||
}
|
||||
|
||||
public static ImTheme getImLightTheme() {
|
||||
String string = GetPreferences().getString("lighttheme", "");
|
||||
if (string.isEmpty()) {
|
||||
return ImTheme.VKAPP_LIGHT;
|
||||
}
|
||||
return ImTheme.VKAPP_LIGHT;
|
||||
}
|
||||
|
||||
public static int getColorFromAttr(int attr) {
|
||||
return VKThemeHelper.a(attr);
|
||||
}
|
||||
} // Toolbar/Header background
|
||||
|
||||
public static int getHeaderText() {
|
||||
return VKThemeHelper.a(R.attr.header_text);
|
||||
} // Header/Toolbar color text
|
||||
|
||||
public static int getAmoledTheme() {
|
||||
return getContext().getResources().getIdentifier("BaseAmoledStyle", "style", getContext().getPackageName());
|
||||
} // Get Amoled theme id
|
||||
|
||||
public static int picFix() {
|
||||
return getContext().getResources().getIdentifier("ActionBarThemeFix", "style", getContext().getPackageName());
|
||||
} // Fix tabbar color in photo viewer
|
||||
|
||||
public static int getAmoledImTheme() {
|
||||
return getContext().getResources().getIdentifier("VkIm.Theme.VkApp.Amoled", "style", getContext().getPackageName());
|
||||
} // Get Amoled theme id for messages
|
||||
|
||||
public static int getAttrId(String attr) {
|
||||
return getContext().getResources().getIdentifier(attr, "attr", getContext().getPackageName());
|
||||
}
|
||||
|
||||
public static void setBarTheme(View getview) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
getview.setSystemUiVisibility(getNeededColorNavbar() | getNeededColorStatusbar());
|
||||
}
|
||||
} // Set white/dark statusbar/navbar icons
|
||||
|
||||
public static int getNeededColorStatusbar() {
|
||||
return VKThemeHelper.d() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? 8192 : 0;
|
||||
}
|
||||
|
||||
public static int getNeededColorNavbar() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? VKThemeHelper.d() ? SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
|
||||
}
|
||||
|
||||
public static int getNeededColorStatusbarFix() {
|
||||
return VKThemeHelper.d() ? 8192 : 0;
|
||||
}
|
||||
|
||||
public static VKTheme getDarkTheme() {
|
||||
switch (getPrefsValue("darktheme")) {
|
||||
case "amoled":
|
||||
return VKTheme.AMOLED;
|
||||
default:
|
||||
return VKTheme.DARK;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static ImTheme getImDarkTheme() {
|
||||
switch (getPrefsValue("darktheme")) {
|
||||
case "amoled":
|
||||
return ImTheme.VKAPP_AMOLED;
|
||||
default:
|
||||
return ImTheme.VKAPP_DARK;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static VKTheme getLightTheme() {
|
||||
switch (getPrefsValue("lighttheme")) {
|
||||
default:
|
||||
return VKTheme.DEFAULT_LIGHT;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static ImTheme getImLightTheme() {
|
||||
switch (getPrefsValue("lighttheme")) {
|
||||
default:
|
||||
return ImTheme.VKAPP_LIGHT;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static int getColorFromAttr(int attr) {
|
||||
return VKThemeHelper.a(attr);
|
||||
} // Get needed attr color
|
||||
|
||||
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");
|
||||
return color_grishka() && Build.VERSION.SDK_INT >= 31;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
} // Accent colors
|
||||
|
||||
public static void themeMonetToolbar(ImageButton imageButton, Toolbar toolbar) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
@@ -117,37 +155,74 @@ public class Themes {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean vkim_msg() {
|
||||
return ru.vtosters.lite.utils.Prefs.BooleanFalse("vkim_msg");
|
||||
}
|
||||
|
||||
public static boolean amoled() {
|
||||
return ru.vtosters.lite.utils.Prefs.BooleanFalse("amoled");
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
} // Recolor drawable to accent color
|
||||
|
||||
public static Drawable recolorDrawableToolbar(Drawable drawable) {
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
return new RecoloredDrawable(drawable, getHeaderText());
|
||||
}
|
||||
} // Recolor toolbar drawable to accent color
|
||||
|
||||
public static ColorStateList recolorCSL(ColorStateList colorStateList) {
|
||||
if (colorStateList == null) {
|
||||
return null;
|
||||
}
|
||||
return ColorStateList.valueOf(getAccentColor());
|
||||
} // Recolor ColorStateList to accent color
|
||||
|
||||
public static ColorStateList themeCSL(ColorStateList csl) {
|
||||
int color = csl.getDefaultColor();
|
||||
try {
|
||||
int unsel = csl.getColorForState(new int[]{-android.R.attr.state_selected}, Color.BLACK);
|
||||
int sel = csl.getColorForState(new int[]{android.R.attr.state_selected}, Color.BLACK);
|
||||
|
||||
boolean isUnselAccent = isAccentedColor(unsel);
|
||||
boolean isSelAccent = isAccentedColor(sel);
|
||||
|
||||
if (isUnselAccent || isSelAccent) {
|
||||
|
||||
return new ColorStateList(new int[][] {
|
||||
new int[]{android.R.attr.state_selected}, new int[]{-android.R.attr.state_selected}
|
||||
}, new int[] {isSelAccent ? getAccentColor() : sel, isUnselAccent ? getAccentColor() : unsel});
|
||||
}
|
||||
return csl;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
} // Recolor ColorStateList
|
||||
|
||||
public static int darken(int color, float by) {
|
||||
float[] hsl = new float[3];
|
||||
ColorUtils.colorToHSL(color, hsl);
|
||||
hsl[2] -= by;
|
||||
hsl[2] = Math.max(0f, Math.min(hsl[2], 1f));
|
||||
return ColorUtils.HSLToColor(hsl);
|
||||
}
|
||||
|
||||
public static int lighten(int color, float factor) {
|
||||
int red = (int) ((Color.red(color) * (1 - factor) / 255 + factor) * 255);
|
||||
int green = (int) ((Color.green(color) * (1 - factor) / 255 + factor) * 255);
|
||||
int blue = (int) ((Color.blue(color) * (1 - factor) / 255 + factor) * 255);
|
||||
return Color.argb(Color.alpha(color), red, green, blue);
|
||||
}
|
||||
|
||||
public static int halfAlpha(int src) {
|
||||
return ColorUtils.setAlphaComponent(src, 169);
|
||||
}
|
||||
|
||||
public static boolean isAccentedColor(ColorStateList target) {
|
||||
return target != null && isAccentedColor(target.getDefaultColor());
|
||||
}
|
||||
|
||||
public static boolean isAccentedColor(int target) {
|
||||
return accentColors.contains(hex(target).toUpperCase());
|
||||
}
|
||||
|
||||
public static int getColor(Context context, int i) {
|
||||
@@ -158,16 +233,75 @@ public class Themes {
|
||||
return context.getColor(i);
|
||||
}
|
||||
return context.getResources().getColor(i);
|
||||
}
|
||||
} // Android Support color injector + accent color checker
|
||||
|
||||
public static int getColor2(int i) {
|
||||
if (isColorRefAccented(i) && isAndroidMonet()) {
|
||||
return getAccentColor();
|
||||
}
|
||||
return GetContext().getResources().getColor(i);
|
||||
return getContext().getResources().getColor(i);
|
||||
} // Android Support color injector + accent color checker
|
||||
|
||||
public static void setNavbarColor(Window window, int i) {
|
||||
if (navbar() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
window.setNavigationBarColor(getTabbarBackground());
|
||||
window.getDecorView().setSystemUiVisibility(getNeededColorNavbar());
|
||||
}
|
||||
}
|
||||
|
||||
public static String hex(int i) {
|
||||
return String.format("#%06X", Integer.valueOf(i & 16777215));
|
||||
} // Get color as hex string
|
||||
|
||||
public static int vk_sans_display_demibold() {
|
||||
return vksans() ? R.font.vk_sans_display_demibold : R.font.tt_commons_demi_bold;
|
||||
}
|
||||
|
||||
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 String getBackgroundStickers() {
|
||||
if (isBGStickersEnabled()) {
|
||||
return "images_with_background";
|
||||
}
|
||||
return "images";
|
||||
}
|
||||
|
||||
public static void systemThemeChanger() {
|
||||
if (!systemtheme())
|
||||
return;
|
||||
int currentNightMode = getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
switch (currentNightMode) {
|
||||
case Configuration.UI_MODE_NIGHT_UNDEFINED:
|
||||
applyTheme(getLightTheme(), getImLightTheme());
|
||||
break;
|
||||
case Configuration.UI_MODE_NIGHT_NO:
|
||||
applyTheme(getLightTheme(), getImLightTheme());
|
||||
break;
|
||||
case Configuration.UI_MODE_NIGHT_YES:
|
||||
applyTheme(getDarkTheme(), getImDarkTheme());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Helper.*;
|
||||
import static ru.vtosters.lite.utils.Themes.*;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Themes.getColorFromAttr;
|
||||
import static ru.vtosters.lite.utils.Themes.hex;
|
||||
|
||||
import android.util.Base64;
|
||||
import android.webkit.WebView;
|
||||
@@ -27,7 +30,7 @@ public class VKUIInjector {
|
||||
|
||||
private static String load(String str) {
|
||||
try {
|
||||
InputStream open = GetContext().getAssets().open(str);
|
||||
InputStream open = getContext().getAssets().open(str);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open, StandardCharsets.UTF_8));
|
||||
while (true) {
|
||||
@@ -64,8 +67,8 @@ public class VKUIInjector {
|
||||
}
|
||||
|
||||
public static void inject(WebView webView) {
|
||||
String string = GetPreferences().getString("darktheme", "");
|
||||
if (Prefs.BooleanTrue("VKUI_INJ")) {
|
||||
String string = getPrefsValue("darktheme");
|
||||
if (getBoolValue("VKUI_INJ", true)) {
|
||||
if (!isLoaded) {
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">Vtoasters Shit</string>
|
||||
<string name="app_name">VTosters Lite</string>
|
||||
</resources>
|
||||
+1
-1
@@ -5,7 +5,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.0-rc01'
|
||||
classpath 'com.android.tools.build:gradle:7.2.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
echo -e "${BOLD}${UNDERLINE}Сборка dex..${NC}\n"
|
||||
|
||||
gradle versionFile
|
||||
gradle assembleDebug
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Успех!${NC}\n"
|
||||
else
|
||||
echo -e "${RED}Провал.${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}${UNDERLINE}Экспорт dex..${NC}"
|
||||
gradle exportDex
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Успех!${NC}\n"
|
||||
else
|
||||
echo -e "${RED}Провал.${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}${UNDERLINE}Перенос dex6 в папку с исходным кодом..${NC}"
|
||||
mv app/classes6.dex smali/
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Успех!${NC}\n"
|
||||
else
|
||||
echo -e "${RED}Провал.${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}${UNDERLINE}Перенос dex8 в папку с исходным кодом..${NC}"
|
||||
mv app/classes8.dex smali/
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Успех!${NC}\n"
|
||||
else
|
||||
echo -e "${RED}Провал.${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}${UNDERLINE}Перенос version.properties в папку с исходным кодом..${NC}"
|
||||
mv app/version.properties smali/assets/
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Успех!${NC}\n"
|
||||
else
|
||||
echo -e "${RED}Провал.${NC}\n"
|
||||
fi
|
||||
|
||||
echo -e "${BOLD}${UNDERLINE}Сборка apk..${NC}"
|
||||
java -jar scripts/apktool.jar b smali -o smali/VTLite.apk --use-aapt2 -p scripts/framework/
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${GREEN}Успех!${NC}\n"
|
||||
else
|
||||
echo -e "${RED}Провал.${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple android:color="@color/picker_blue_pressed"
|
||||
<ripple android:color="?accent"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple android:color="@color/picker_blue_pressed"
|
||||
<ripple android:color="?accent"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<selector>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple android:color="@color/picker_blue_pressed"
|
||||
<ripple android:color="?accent"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<ripple android:color="@color/overlay">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="?header_text" />
|
||||
<solid android:color="?header_background" />
|
||||
<corners android:radius="@dimen/vkui_button_corner_big_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
@@ -12,7 +12,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="?header_text" />
|
||||
<solid android:color="?header_background" />
|
||||
<corners android:radius="@dimen/vkui_button_corner_big_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<gradient
|
||||
android:startColor="#fff8f8f8"
|
||||
android:endColor="#ffffffff"
|
||||
android:startColor="?background_content"
|
||||
android:endColor="?background_content"
|
||||
android:angle="90.0" />
|
||||
</shape>
|
||||
@@ -2,7 +2,7 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/picker_blue_pressed" />
|
||||
<solid android:color="?accent" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="@color/picker_blue_pressed" />
|
||||
<solid android:color="?accent" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="10000.0dip" />
|
||||
<solid android:color="@color/picker_blue_pressed" />
|
||||
<solid android:color="?accent" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
android:topRightRadius="12.0dip"
|
||||
android:bottomLeftRadius="12.0dip"
|
||||
android:bottomRightRadius="12.0dip" />
|
||||
<solid android:color="@color/blue_300" />
|
||||
<solid android:color="?accent" />
|
||||
</shape>
|
||||
@@ -7,7 +7,7 @@
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke
|
||||
android:width="0.5dip"
|
||||
android:color="@color/blue_300" />
|
||||
android:color="?accent" />
|
||||
<padding
|
||||
android:left="0.0dip"
|
||||
android:top="0.0dip"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/blue_200_muted" />
|
||||
<solid android:color="?accent" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_pressed="true">
|
||||
@@ -12,7 +12,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/blue_300" />
|
||||
<solid android:color="?accent" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
||||
@@ -14,7 +14,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="?header_text" />
|
||||
<solid android:color="?header_background" />
|
||||
<corners android:radius="@dimen/vkui_button_corner_big_radius" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
android:layout_height="48.0dip"
|
||||
app:tabBackground="@drawable/music_tab_bg"
|
||||
app:tabGravity="center"
|
||||
app:tabIndicatorColor="@color/white" />
|
||||
app:tabIndicatorColor="?header_tab_active_indicator" />
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<FrameLayout
|
||||
android:orientation="horizontal"
|
||||
android:id="@id/toolbar"
|
||||
android:background="?tabbar_background"
|
||||
android:background="?header_background"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?actionBarSize"
|
||||
@@ -18,7 +18,7 @@
|
||||
android:layout_height="48.0dip"
|
||||
android:layout_marginLeft="4.0dip"
|
||||
android:src="@drawable/ic_back_24"
|
||||
android:tint="?accent"
|
||||
android:tint="?header_text"
|
||||
android:contentDescription="@string/music_talkback_go_back"
|
||||
style="@style/ActionButton.White" />
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
android:layout_height="48.0dip"
|
||||
android:layout_marginRight="4.0dip"
|
||||
android:src="@drawable/ic_menu_search"
|
||||
android:tint="?accent"
|
||||
android:tint="?header_text"
|
||||
style="@style/ActionButton.White" />
|
||||
|
||||
<LinearLayout
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
<TextView
|
||||
android:textSize="16.0dip"
|
||||
android:textColor="?text_primary"
|
||||
android:textColor="?header_text"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@id/title"
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<TextView
|
||||
android:textSize="14.0dip"
|
||||
android:textColor="?text_secondary"
|
||||
android:textColor="?header_text_secondary"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@id/subtitle"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout android:background="#fffafbfc"
|
||||
<FrameLayout android:background="?tabbar_background"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<com.vk.im.ui.views.span.SpanPressableTextView
|
||||
android:textSize="14.0sp"
|
||||
android:textColor="#ff71757a"
|
||||
android:textColor="?text_primary"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
@@ -56,13 +56,13 @@
|
||||
android:layout_height="48.0dip"
|
||||
android:src="@drawable/ic_cancel_24"
|
||||
android:scaleType="centerInside"
|
||||
android:tint="@color/light_gray"
|
||||
android:tint="?text_primary"
|
||||
android:contentDescription="@null" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:textSize="14.0sp"
|
||||
android:textColor="#ff71757a"
|
||||
android:textColor="?text_primary"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="start|center"
|
||||
android:id="@id/loading"
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
<TextView
|
||||
android:textSize="14.0sp"
|
||||
android:textColor="#ff71757a"
|
||||
android:textColor="?text_primary"
|
||||
android:ellipsize="end"
|
||||
android:layout_gravity="start|center"
|
||||
android:id="@id/error"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/appkit_loader_content"
|
||||
android:background="#ffffffff"
|
||||
android:background="?background_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<com.vtosters.lite.ui.LinkedTextView
|
||||
android:textSize="16.0dip"
|
||||
android:textColor="#ff999999"
|
||||
android:textColor="?text_primary"
|
||||
android:gravity="center"
|
||||
android:id="@id/empty_text"
|
||||
android:layout_width="fill_parent"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
<LinearLayout
|
||||
android:gravity="center"
|
||||
android:background="?background_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:padding="16.0dip"
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:id="@id/load_more_error"
|
||||
android:padding="16.0dip"
|
||||
android:background="?background_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="76.0dip">
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="?background_content"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<ProgressBar
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<me.grishka.appkit.views.UsableRecyclerView
|
||||
android:id="@id/list"
|
||||
android:background="?background_content"
|
||||
android:scrollbars="vertical"
|
||||
android:clipToPadding="false"
|
||||
android:layout_width="fill_parent"
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
android:layout_width="16.0dip"
|
||||
android:layout_height="16.0dip"
|
||||
android:src="@drawable/ic_favorite_16"
|
||||
android:tint="@color/blue_200_muted"
|
||||
android:tint="?accent"
|
||||
android:layout_marginEnd="4.0dip"
|
||||
app:layout_constraintBottom_toBottomOf="@id/game_title"
|
||||
app:layout_constraintEnd_toStartOf="@id/game_menu"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
android:layout_height="238.0dip"
|
||||
app:contentScrim="?text_primary"
|
||||
app:layout_scrollFlags="exitUntilCollapsed|scroll"
|
||||
app:statusBarScrim="?tabbar_background"
|
||||
app:statusBarScrim="?header_background"
|
||||
app:titleEnabled="false">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -117,12 +117,12 @@
|
||||
android:layout_width="16.0dip"
|
||||
android:layout_height="16.0dip"
|
||||
android:src="@drawable/ic_longreads_black_16"
|
||||
android:tint="@color/black" />
|
||||
android:tint="?header_text" />
|
||||
|
||||
<TextView
|
||||
android:textSize="12.0sp"
|
||||
android:textStyle="normal"
|
||||
android:textColor="@color/black"
|
||||
android:textColor="?header_text"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -100,12 +100,12 @@
|
||||
android:layout_width="16.0dip"
|
||||
android:layout_height="16.0dip"
|
||||
android:src="@drawable/ic_longreads_black_16"
|
||||
android:tint="@color/black" />
|
||||
android:tint="?header_text" />
|
||||
|
||||
<TextView
|
||||
android:textSize="12.0sp"
|
||||
android:textStyle="normal"
|
||||
android:textColor="@color/black"
|
||||
android:textColor="?header_text"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/content_wrap"
|
||||
android:background="?tabbar_background"
|
||||
android:background="?background_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<me.grishka.appkit.views.UsableRecyclerView
|
||||
android:id="@id/list"
|
||||
android:background="?background_content"
|
||||
android:paddingTop="219.0dip"
|
||||
android:scrollbars="vertical"
|
||||
android:clipToPadding="false"
|
||||
|
||||
@@ -72,12 +72,12 @@
|
||||
android:layout_width="16.0dip"
|
||||
android:layout_height="16.0dip"
|
||||
android:src="@drawable/ic_longreads_black_16"
|
||||
android:tint="@color/black" />
|
||||
android:tint="?header_text" />
|
||||
|
||||
<TextView
|
||||
android:textSize="12.0sp"
|
||||
android:textStyle="normal"
|
||||
android:textColor="@color/black"
|
||||
android:textColor="?header_text"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user