Compare commits
259
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5c80b230a | ||
|
|
87ee01bac9 | ||
|
|
126ad044f2 | ||
|
|
b636648457 | ||
|
|
bf3672a8c4 | ||
|
|
e6478d5161 | ||
|
|
ddea78aa4b | ||
|
|
b872fb17b8 | ||
|
|
4ec2c17df1 | ||
|
|
38a51f48d0 | ||
|
|
838897611c | ||
|
|
f42150063c | ||
|
|
d164d1219d | ||
|
|
fb71b4d781 | ||
|
|
f338738c1e | ||
|
|
fb704c7388 | ||
|
|
c99bca4200 | ||
|
|
92f43acb80 | ||
|
|
a7c85a24f2 | ||
|
|
fe5616b3f7 | ||
|
|
5c882c5ce2 | ||
|
|
61a4ed43b9 | ||
|
|
b242ad7ae4 | ||
|
|
1b02e806f8 | ||
|
|
eaf23a24ba | ||
|
|
ce64296c01 | ||
|
|
6e3716fe01 | ||
|
|
dcdd83243b | ||
|
|
986ec2987c | ||
|
|
c98609db5d | ||
|
|
0b4e3c6303 | ||
|
|
bc3e5a706d | ||
|
|
0b56d9dd23 | ||
|
|
62ccdf8eba | ||
|
|
72f4226419 | ||
|
|
f6a45beac5 | ||
|
|
a657ddef58 | ||
|
|
726e38ff2e | ||
|
|
191d3f760e | ||
|
|
2cd3b0f39c | ||
|
|
abd990eef7 | ||
|
|
cd875af7d7 | ||
|
|
b1e8f93371 | ||
|
|
64afd0222b | ||
|
|
32369f1f38 | ||
|
|
f00be506cc | ||
|
|
248fd1ce9c | ||
|
|
3e2d4bb665 | ||
|
|
92689941ca | ||
|
|
c46110cfea | ||
|
|
b5250e0b8d | ||
|
|
0e81397305 | ||
|
|
95d306eaed | ||
|
|
339a4fe01f | ||
|
|
48cdbc7681 | ||
|
|
5e85ba10f4 | ||
|
|
ea7dd7aba5 | ||
|
|
c60b766f37 | ||
|
|
da9ded2ae1 | ||
|
|
29eb517bb9 | ||
|
|
84a3f6caff | ||
|
|
b34821463a | ||
|
|
127abbaaeb | ||
|
|
d462d42775 | ||
|
|
5e80ad7e4e | ||
|
|
e1aadade5f | ||
|
|
77d6f5d977 | ||
|
|
c4ae2ec0a3 | ||
|
|
07ee9269b7 | ||
|
|
3ee43f1c50 | ||
|
|
dd65196af9 | ||
|
|
5547de006b | ||
|
|
0fbf571c60 | ||
|
|
f5f05697b6 | ||
|
|
5f179f6a26 | ||
|
|
37c6d29e84 | ||
|
|
0e81ba31cb | ||
|
|
1f24d32109 | ||
|
|
ff16f84c43 | ||
|
|
5b929bf515 | ||
|
|
bdcb3db238 | ||
|
|
f7960b1695 | ||
|
|
825d1b95da | ||
|
|
0e7abaf3f0 | ||
|
|
2731989ae8 | ||
|
|
5ad09e11df | ||
|
|
653d2eeeee | ||
|
|
756ad615ed | ||
|
|
dd6abafad5 | ||
|
|
0434f06bb5 | ||
|
|
50971098ad | ||
|
|
1787f10fca | ||
|
|
6d2684db70 | ||
|
|
f0f1b3a946 | ||
|
|
ae9b703726 | ||
|
|
10512fb74b | ||
|
|
ce9bdba30c | ||
|
|
188c98589c | ||
|
|
e5fa42ff14 | ||
|
|
f42aa95003 | ||
|
|
b16dc816b6 | ||
|
|
b86fe4d65d | ||
|
|
d7e17416f1 | ||
|
|
91355f1dd5 | ||
|
|
ae9e3ed07c | ||
|
|
f701993b0f | ||
|
|
c5bf617f65 | ||
|
|
f09cae1684 | ||
|
|
99d7f06981 | ||
|
|
eaaf7e2bbf | ||
|
|
897382de2b | ||
|
|
55d02a8412 | ||
|
|
7733582238 | ||
|
|
754c8339df | ||
|
|
ebf7baaa65 | ||
|
|
8b26b12813 | ||
|
|
5deb4186f9 | ||
|
|
d3d501f94a | ||
|
|
634f1213d4 | ||
|
|
6fa97ee435 | ||
|
|
05b3342763 | ||
|
|
d434f42d12 | ||
|
|
084f13eda4 | ||
|
|
ed59b54618 | ||
|
|
df282b95ad | ||
|
|
1b38533c83 | ||
|
|
8f4c370ab2 | ||
|
|
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 | ||
|
|
727201ece9 | ||
|
|
c711c3126e | ||
|
|
cdcf218160 | ||
|
|
ee652593c0 | ||
|
|
90773529e6 | ||
|
|
0134a7c82c | ||
|
|
fec3d40d7d | ||
|
|
bdf36f42d3 | ||
|
|
23967490e9 | ||
|
|
3bcd197618 | ||
|
|
ac3eba5654 | ||
|
|
9576856b0b | ||
|
|
f17975c92f | ||
|
|
07a24eab2f | ||
|
|
edc9276fac | ||
|
|
c7531eb652 | ||
|
|
5c1452ff57 | ||
|
|
e467044e41 | ||
|
|
5c5780f720 | ||
|
|
7119bab9c9 | ||
|
|
2eccc92510 | ||
|
|
b9e0fcdb04 | ||
|
|
5c15912b1b | ||
|
|
ac6525e49a | ||
|
|
3e67973a27 | ||
|
|
ed4e295e71 | ||
|
|
73b57399d5 | ||
|
|
9e0b67478d | ||
|
|
341eb37ff4 | ||
|
|
6d68a77e42 | ||
|
|
b50f56a5d4 | ||
|
|
e226438b09 | ||
|
|
a5db0793d6 | ||
|
|
07e1f1a1d3 | ||
|
|
de77e3484b | ||
|
|
24571ea22f | ||
|
|
515f90105c | ||
|
|
0d305dbc7e | ||
|
|
05bf888ba6 | ||
|
|
a2a53e8215 | ||
|
|
e6290b8aba | ||
|
|
aa5f6e7cbe | ||
|
|
054b447236 | ||
|
|
52db475469 | ||
|
|
6282800fdb | ||
|
|
20517fdf51 | ||
|
|
40400817c1 | ||
|
|
834e454eb2 |
@@ -0,0 +1,49 @@
|
||||
name: Build VTosters Lite
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
|
||||
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.maki.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 доступна прямая проверка версии коммита внутри приложения.
|
||||
|
||||

|
||||
+3
-2
@@ -86,12 +86,13 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
namespace 'ru.vtosters.lite'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
implementation 'com.google.android.material:material:1.5.0'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.3.3'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -3,11 +3,28 @@
|
||||
*/
|
||||
package bruhcollective.itaysonlab.libvkx;
|
||||
|
||||
// Works only with original signature of VT
|
||||
|
||||
public interface ILibVkxService extends android.os.IInterface {
|
||||
void play(java.util.List<String> audio_ids, int index, String playbackContext) throws android.os.RemoteException;
|
||||
|
||||
int getUserId() throws android.os.RemoteException;
|
||||
// Starts playback. playbackContext can be "other" if you don't sure what it is
|
||||
|
||||
void addTrackToCache(int track_id, int owner_id, String access_key) throws android.os.RemoteException;
|
||||
// A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE!
|
||||
|
||||
void deleteTrackFromCache(int track_id, int owner_id) throws android.os.RemoteException;
|
||||
// Cache add/remove
|
||||
|
||||
boolean isTrackCached(int track_id, int owner_id) throws android.os.RemoteException;
|
||||
|
||||
java.util.List<String> getCache() throws android.os.RemoteException;
|
||||
|
||||
/**
|
||||
* Default implementation for ILibVkxService.
|
||||
*/
|
||||
public static class Default implements ILibVkxService {
|
||||
class Default implements ILibVkxService {
|
||||
// Starts playback. playbackContext can be "other" if you don't sure what it is
|
||||
|
||||
@Override
|
||||
@@ -46,13 +63,20 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
|
||||
// Also, the items in the list are JSON ones.
|
||||
|
||||
/**
|
||||
* Local-side IPC implementation stub class.
|
||||
*/
|
||||
public static abstract class Stub extends android.os.Binder implements ILibVkxService {
|
||||
abstract class Stub extends android.os.Binder implements ILibVkxService {
|
||||
static final int TRANSACTION_play = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
|
||||
static final int TRANSACTION_getUserId = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
|
||||
static final int TRANSACTION_addTrackToCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
|
||||
static final int TRANSACTION_deleteTrackFromCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
|
||||
static final int TRANSACTION_isTrackCached = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
|
||||
static final int TRANSACTION_getCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
|
||||
private static final String DESCRIPTOR = "bruhcollective.itaysonlab.libvkx.ILibVkxService";
|
||||
|
||||
/**
|
||||
* Construct the stub at attach it to the interface.
|
||||
*/
|
||||
@@ -75,6 +99,18 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
return new Proxy(obj);
|
||||
}
|
||||
|
||||
public static boolean setDefaultImpl(ILibVkxService impl) {
|
||||
if (Proxy.sDefaultImpl == null && impl != null) {
|
||||
Proxy.sDefaultImpl = impl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ILibVkxService getDefaultImpl() {
|
||||
return Proxy.sDefaultImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public android.os.IBinder asBinder() {
|
||||
return this;
|
||||
@@ -154,7 +190,8 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
}
|
||||
|
||||
private static class Proxy implements ILibVkxService {
|
||||
private android.os.IBinder mRemote;
|
||||
public static ILibVkxService sDefaultImpl;
|
||||
private final android.os.IBinder mRemote;
|
||||
|
||||
Proxy(android.os.IBinder remote) {
|
||||
mRemote = remote;
|
||||
@@ -164,11 +201,12 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
public android.os.IBinder asBinder() {
|
||||
return mRemote;
|
||||
}
|
||||
// Starts playback. playbackContext can be "other" if you don't sure what it is
|
||||
|
||||
public String getInterfaceDescriptor() {
|
||||
return DESCRIPTOR;
|
||||
}
|
||||
// Starts playback. playbackContext can be "other" if you don't sure what it is
|
||||
// A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE!
|
||||
|
||||
@Override
|
||||
public void play(java.util.List<String> audio_ids, int index, String playbackContext) throws android.os.RemoteException {
|
||||
@@ -190,7 +228,7 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
_data.recycle();
|
||||
}
|
||||
}
|
||||
// A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE!
|
||||
// Cache add/remove
|
||||
|
||||
@Override
|
||||
public int getUserId() throws android.os.RemoteException {
|
||||
@@ -211,7 +249,6 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
// Cache add/remove
|
||||
|
||||
@Override
|
||||
public void addTrackToCache(int track_id, int owner_id, String access_key) throws android.os.RemoteException {
|
||||
@@ -253,6 +290,8 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
_data.recycle();
|
||||
}
|
||||
}
|
||||
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
|
||||
// Also, the items in the list are JSON ones.
|
||||
|
||||
@Override
|
||||
public boolean isTrackCached(int track_id, int owner_id) throws android.os.RemoteException {
|
||||
@@ -275,8 +314,6 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
|
||||
// Also, the items in the list are JSON ones.
|
||||
|
||||
@Override
|
||||
public java.util.List<String> getCache() throws android.os.RemoteException {
|
||||
@@ -297,44 +334,6 @@ public interface ILibVkxService extends android.os.IInterface {
|
||||
}
|
||||
return _result;
|
||||
}
|
||||
|
||||
public static ILibVkxService sDefaultImpl;
|
||||
}
|
||||
|
||||
static final int TRANSACTION_play = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
|
||||
static final int TRANSACTION_getUserId = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
|
||||
static final int TRANSACTION_addTrackToCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
|
||||
static final int TRANSACTION_deleteTrackFromCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
|
||||
static final int TRANSACTION_isTrackCached = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
|
||||
static final int TRANSACTION_getCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
|
||||
|
||||
public static boolean setDefaultImpl(ILibVkxService impl) {
|
||||
if (Proxy.sDefaultImpl == null && impl != null) {
|
||||
Proxy.sDefaultImpl = impl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ILibVkxService getDefaultImpl() {
|
||||
return Proxy.sDefaultImpl;
|
||||
}
|
||||
}
|
||||
// Starts playback. playbackContext can be "other" if you don't sure what it is
|
||||
|
||||
public void play(java.util.List<String> audio_ids, int index, String playbackContext) throws android.os.RemoteException;
|
||||
// A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE!
|
||||
|
||||
public int getUserId() throws android.os.RemoteException;
|
||||
// Cache add/remove
|
||||
|
||||
public void addTrackToCache(int track_id, int owner_id, String access_key) throws android.os.RemoteException;
|
||||
|
||||
public void deleteTrackFromCache(int track_id, int owner_id) throws android.os.RemoteException;
|
||||
|
||||
public boolean isTrackCached(int track_id, int owner_id) throws android.os.RemoteException;
|
||||
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
|
||||
// Also, the items in the list are JSON ones.
|
||||
|
||||
public java.util.List<String> getCache() throws android.os.RemoteException;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package bruhcollective.itaysonlab.libvkx.client;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
|
||||
|
||||
import com.vk.core.b.PackageManagerHelper;
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
import com.vk.music.PlayerRefer;
|
||||
@@ -13,12 +14,8 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
import bruhcollective.itaysonlab.libvkx.ILibVkxService;
|
||||
|
||||
/* loaded from: classes6.dex */
|
||||
public class LibVKXClient {
|
||||
private static LibVKXClientImpl impl;
|
||||
|
||||
@@ -31,7 +28,7 @@ public class LibVKXClient {
|
||||
|
||||
public static LibVKXClientImpl getInstance() {
|
||||
LibVKXClientImpl libVKXClientImpl = impl;
|
||||
return libVKXClientImpl == null ? getInstance(Helper.GetContext()) : libVKXClientImpl;
|
||||
return libVKXClientImpl == null ? getInstance(getContext()) : libVKXClientImpl;
|
||||
}
|
||||
|
||||
public static boolean isVkxInstalled() {
|
||||
@@ -39,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) {
|
||||
@@ -52,8 +49,7 @@ public class LibVKXClient {
|
||||
return getInstance().runOnService(action);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
public static /* synthetic */ void lambdaplay(List list, MusicTrack musicTrack, PlayerRefer playerRefer, ILibVkxService iLibVkxService) {
|
||||
public static void lambdaplay(List list, MusicTrack musicTrack, PlayerRefer playerRefer, ILibVkxService iLibVkxService) {
|
||||
int indexOf = list.indexOf(musicTrack);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator it = list.iterator();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package bruhcollective.itaysonlab.libvkx.client;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getUserId;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -12,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;
|
||||
@@ -51,7 +52,7 @@ public class LibVKXClientImpl {
|
||||
public boolean runOnService(LibVKXAction action) {
|
||||
if (serviceInstance != null) {
|
||||
try {
|
||||
if (serviceInstance.getUserId() != Helper.GetUserId()) return false;
|
||||
if (serviceInstance.getUserId() != getUserId()) return false;
|
||||
action.run(serviceInstance);
|
||||
return true;
|
||||
} catch (RemoteException e) {
|
||||
@@ -75,7 +76,7 @@ public class LibVKXClientImpl {
|
||||
isBindFailed = true;
|
||||
} else {
|
||||
try {
|
||||
if (serviceInstance.getUserId() != Helper.GetUserId()) return;
|
||||
if (serviceInstance.getUserId() != getUserId()) return;
|
||||
runAfterBind.run(serviceInstance);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
@@ -95,8 +96,7 @@ public class LibVKXClientImpl {
|
||||
|
||||
private boolean verifyBindActuality() {
|
||||
if (!checkIfAppExists()) return false; // no need
|
||||
if (isBindFailed) return false;
|
||||
return true;
|
||||
return !isBindFailed;
|
||||
}
|
||||
|
||||
private Intent getIntent() {
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.aefyr.tsg.g2;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
@@ -10,11 +7,13 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Aefyr on 20.05.2018.
|
||||
@@ -22,17 +21,13 @@ import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
|
||||
public class NotificationsHelper {
|
||||
private static final int NOTIFICATION_ID_BASE = 3921337;
|
||||
private static final String NOTIFICATION_CHANNEL_ID = "tgss_chan_v5";
|
||||
|
||||
private HashMap<TelegramStickersPack, Integer> downloadingPacksNotificationsIds;
|
||||
|
||||
private Context c;
|
||||
private NotificationManagerCompat manager;
|
||||
private int currentNotificationN = 0;
|
||||
|
||||
private static final int MAX_UPDATE_NOTIFICATIONS_PER_SECOND = 3;
|
||||
private static final int MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS = 1000 / MAX_UPDATE_NOTIFICATIONS_PER_SECOND;
|
||||
|
||||
private AtomicLong lastNotificationTime = new AtomicLong(0);
|
||||
private final HashMap<TelegramStickersPack, Integer> downloadingPacksNotificationsIds;
|
||||
private final Context c;
|
||||
private final NotificationManagerCompat manager;
|
||||
private int currentNotificationN = 0;
|
||||
private final AtomicLong lastNotificationTime = new AtomicLong(0);
|
||||
|
||||
public NotificationsHelper(Context c) {
|
||||
this.c = c;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.io.File;
|
||||
class PackDeletionTask extends AsyncTask<Void, Void, Boolean> {
|
||||
private static final String TAG = "TGSSAnnihilator";
|
||||
|
||||
private TelegramStickersPack pack;
|
||||
private final TelegramStickersPack pack;
|
||||
|
||||
PackDeletionTask(TelegramStickersPack pack) {
|
||||
this.pack = pack;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.aefyr.tsg.g2;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Created by Aefyr on 18.05.2018.
|
||||
*/
|
||||
@@ -101,7 +101,7 @@ public class TelegramStickersPack extends CustomStickersPack {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.toLowerCase().equals(id.toLowerCase());
|
||||
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equalsIgnoreCase(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
package com.aefyr.tsg.g2;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aefyr.tsg.g2.sql.TelegramStickersDbHelper;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersPackInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -7,17 +19,6 @@ import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import com.aefyr.tsg.g2.sql.TelegramStickersDbHelper;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersPackInfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
|
||||
|
||||
/**
|
||||
@@ -27,29 +28,25 @@ public class TelegramStickersService {
|
||||
private static final String TAG = "TGStickersService";
|
||||
private static TelegramStickersService instance;
|
||||
|
||||
private Context c;
|
||||
private final Context c;
|
||||
|
||||
private ArrayList<TelegramStickersPack> packs;
|
||||
private ArrayList<TelegramStickersPack> activePacks;
|
||||
private ArrayList<TelegramStickersPack> inactivePacks;
|
||||
private ArrayList<StickersEventsListener> listeners;
|
||||
private HashSet<String> currentlyDownloading;
|
||||
private final ArrayList<TelegramStickersPack> packs;
|
||||
private final ArrayList<TelegramStickersPack> activePacks;
|
||||
private final ArrayList<TelegramStickersPack> inactivePacks;
|
||||
private final ArrayList<StickersEventsListener> listeners;
|
||||
private final HashSet<String> currentlyDownloading;
|
||||
|
||||
private Handler uiThreadHandler;
|
||||
private final Handler uiThreadHandler;
|
||||
|
||||
private TelegramStickersGrabber grabber;
|
||||
private final TelegramStickersGrabber grabber;
|
||||
|
||||
private TelegramStickersDbHelper dbHelper;
|
||||
private final TelegramStickersDbHelper dbHelper;
|
||||
private boolean ready = false;
|
||||
private ArrayList<Runnable> queuedTasks;
|
||||
private final ArrayList<Runnable> queuedTasks;
|
||||
|
||||
private ThreadPoolExecutor executor;
|
||||
private final ThreadPoolExecutor executor;
|
||||
|
||||
private NotificationsHelper notificationsHelper;
|
||||
|
||||
public static TelegramStickersService getInstance(Context c) {
|
||||
return instance == null ? new TelegramStickersService(c) : instance;
|
||||
}
|
||||
private final NotificationsHelper notificationsHelper;
|
||||
|
||||
private TelegramStickersService(Context context) {
|
||||
instance = this;
|
||||
@@ -72,6 +69,10 @@ public class TelegramStickersService {
|
||||
updatePacks(true);
|
||||
}
|
||||
|
||||
public static TelegramStickersService getInstance(Context c) {
|
||||
return instance == null ? new TelegramStickersService(c) : instance;
|
||||
}
|
||||
|
||||
private void updatePacks(final boolean notify) {
|
||||
packs.clear();
|
||||
dbHelper.getAllPacks(new TelegramStickersDbHelper.PacksLoadingListener() {
|
||||
@@ -105,20 +106,6 @@ public class TelegramStickersService {
|
||||
});
|
||||
}
|
||||
|
||||
interface StickersEventsListener {
|
||||
void onPackAdded(TelegramStickersPack pack, int atIndex);
|
||||
|
||||
void onPackRemoved(TelegramStickersPack pack, int atIndex);
|
||||
|
||||
void onPackChanged(TelegramStickersPack pack, int atIndex);
|
||||
|
||||
void onPackDownloadError(TelegramStickersPack pack, Exception error);
|
||||
|
||||
void onActivePacksListChanged();
|
||||
|
||||
void onInactivePacksListChanged();
|
||||
}
|
||||
|
||||
public void addStickersEventsListener(StickersEventsListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
@@ -128,7 +115,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackAdded(TelegramStickersPack pack, int atIndex) {
|
||||
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -138,7 +125,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackChanged(TelegramStickersPack pack, int atIndex) {
|
||||
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -148,7 +135,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackRemoved(TelegramStickersPack pack, int atIndex) {
|
||||
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -158,7 +145,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyPackDownloadError(TelegramStickersPack pack, Exception error) {
|
||||
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -168,7 +155,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyActivePacksListChanged() {
|
||||
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -178,7 +165,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
|
||||
private void notifyInactivePacksListChanged() {
|
||||
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -398,5 +385,19 @@ public class TelegramStickersService {
|
||||
getPacksListReference().set(li1, p2);
|
||||
}
|
||||
|
||||
interface StickersEventsListener {
|
||||
void onPackAdded(TelegramStickersPack pack, int atIndex);
|
||||
|
||||
void onPackRemoved(TelegramStickersPack pack, int atIndex);
|
||||
|
||||
void onPackChanged(TelegramStickersPack pack, int atIndex);
|
||||
|
||||
void onPackDownloadError(TelegramStickersPack pack, Exception error);
|
||||
|
||||
void onActivePacksListChanged();
|
||||
|
||||
void onInactivePacksListChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ import android.provider.BaseColumns;
|
||||
*/
|
||||
public final class TelegramStickersContract {
|
||||
|
||||
public static final String SQL_CREATE_ENTRIES = String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s INTEGER AUTO_INCREMENT, %s TEXT, %s TEXT, %s TEXT, %s INTEGER, %s INTEGER, %s TEXT, %s TEXT)",
|
||||
StickersTableEntry.TABLE_NAME, StickersTableEntry._ID, StickersTableEntry.COLUMN_NAME_INDEX, StickersTableEntry.COLUMN_NAME_ID, StickersTableEntry.COLUMN_NAME_NAME,
|
||||
StickersTableEntry.COLUMN_NAME_FOLDER, StickersTableEntry.COLUMN_NAME_STICKERS_COUNT, StickersTableEntry.COLUMN_NAME_ENABLED, StickersTableEntry.COLUMN_NAME_VERSION, StickersTableEntry.COLUMN_NAME_EMOJIS);
|
||||
|
||||
private TelegramStickersContract() {
|
||||
}
|
||||
|
||||
@@ -23,9 +27,5 @@ public final class TelegramStickersContract {
|
||||
public static final String COLUMN_NAME_EMOJIS = "emojis";
|
||||
}
|
||||
|
||||
public static final String SQL_CREATE_ENTRIES = String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s INTEGER AUTO_INCREMENT, %s TEXT, %s TEXT, %s TEXT, %s INTEGER, %s INTEGER, %s TEXT, %s TEXT)",
|
||||
StickersTableEntry.TABLE_NAME, StickersTableEntry._ID, StickersTableEntry.COLUMN_NAME_INDEX, StickersTableEntry.COLUMN_NAME_ID, StickersTableEntry.COLUMN_NAME_NAME,
|
||||
StickersTableEntry.COLUMN_NAME_FOLDER, StickersTableEntry.COLUMN_NAME_STICKERS_COUNT, StickersTableEntry.COLUMN_NAME_ENABLED, StickersTableEntry.COLUMN_NAME_VERSION, StickersTableEntry.COLUMN_NAME_EMOJIS);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import android.util.Log;
|
||||
|
||||
import com.aefyr.tsg.g2.TelegramStickersPack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by Aefyr on 19.05.2018.
|
||||
*/
|
||||
@@ -27,12 +27,6 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper {
|
||||
private SQLiteDatabase writableDb;
|
||||
private SQLiteDatabase readableDb;
|
||||
|
||||
public interface PacksLoadingListener {
|
||||
void onPackLoaded(TelegramStickersPack pack);
|
||||
|
||||
void onAllPacksLoaded(ArrayList<TelegramStickersPack> packs);
|
||||
}
|
||||
|
||||
public TelegramStickersDbHelper(Context context) {
|
||||
super(context, DB_NAME, null, DB_VERSION);
|
||||
}
|
||||
@@ -105,6 +99,12 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper {
|
||||
new PacksLoadingTask(listener).execute();
|
||||
}
|
||||
|
||||
public interface PacksLoadingListener {
|
||||
void onPackLoaded(TelegramStickersPack pack);
|
||||
|
||||
void onAllPacksLoaded(ArrayList<TelegramStickersPack> packs);
|
||||
}
|
||||
|
||||
private class PacksLoadingTask extends AsyncTask<Void, Void, ArrayList<TelegramStickersPack>> {
|
||||
|
||||
PacksLoadingListener listener;
|
||||
|
||||
@@ -9,12 +9,6 @@ import android.util.Log;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.util.Flag;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.util.GoalCounter;
|
||||
|
||||
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 org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -33,17 +27,17 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
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.
|
||||
*/
|
||||
public class TelegramStickersGrabber {
|
||||
private static final String TAG = "TSG";
|
||||
|
||||
private static String BOT_API_BASE_URL;
|
||||
private static String GET_STICKER_SET_URL;
|
||||
private static String GET_FILE_URL;
|
||||
private static String BOT_API_BASE_FILE_URL;
|
||||
|
||||
public static String REAL_TG_IP = null;
|
||||
public static String PROXY_IP = null;
|
||||
public static int PROXY_PORT = -1;
|
||||
@@ -52,11 +46,32 @@ public class TelegramStickersGrabber {
|
||||
public static boolean PROXY_SOCKS = true;
|
||||
public static boolean HAS_PASS = false;
|
||||
public static boolean USE_PROXY = false;
|
||||
private static String BOT_API_BASE_URL;
|
||||
private static String GET_STICKER_SET_URL;
|
||||
private static String GET_FILE_URL;
|
||||
private static String BOT_API_BASE_FILE_URL;
|
||||
|
||||
static {
|
||||
updateURLs();
|
||||
}
|
||||
|
||||
private final MessageDigest sha256;
|
||||
private final Handler uiThreadHandler;
|
||||
private String botApiKey = "";
|
||||
private NetClient httpClient;
|
||||
public TelegramStickersGrabber(String botApiKey) {
|
||||
this.botApiKey = botApiKey;
|
||||
httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
|
||||
uiThreadHandler = new Handler(Looper.getMainLooper());
|
||||
try {
|
||||
sha256 = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.wtf(TAG, "No support for SHA-256");
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateURLs() {
|
||||
BOT_API_BASE_FILE_URL = "https://api.telegram.org/file/bot%s/%s";
|
||||
|
||||
@@ -66,11 +81,6 @@ public class TelegramStickersGrabber {
|
||||
GET_FILE_URL = BOT_API_BASE_URL + "getFile?file_id=%s";
|
||||
}
|
||||
|
||||
private String botApiKey = "";
|
||||
private NetClient httpClient;
|
||||
private final MessageDigest sha256;
|
||||
private final Handler uiThreadHandler;
|
||||
|
||||
public static boolean isTelegramBlocked() {
|
||||
NetClient client = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
|
||||
try {
|
||||
@@ -101,43 +111,6 @@ public class TelegramStickersGrabber {
|
||||
return false;
|
||||
}
|
||||
|
||||
public interface PackDownloadListener {
|
||||
void onPackDownloaded(TelegramStickersPackInfo pack, boolean newVersionFound);
|
||||
|
||||
void onPackDownloadError(Exception e);
|
||||
|
||||
void onGotPackInfo(TelegramStickersPackInfo packInfo);
|
||||
|
||||
void onStickerDownloaded(String pack, File sticker, String boundEmoji, int stickerIndex, int downloadedStickersCount, int totalStickerCount);
|
||||
}
|
||||
|
||||
public interface KeyCheckListener {
|
||||
void onKeyChecked(boolean ok);
|
||||
|
||||
void onNetError();
|
||||
}
|
||||
|
||||
public class TSGException extends Exception {
|
||||
private static final long serialVersionUID = 7866915509988422944L;
|
||||
|
||||
private TSGException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
public TelegramStickersGrabber(String botApiKey) {
|
||||
this.botApiKey = botApiKey;
|
||||
httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
|
||||
uiThreadHandler = new Handler(Looper.getMainLooper());
|
||||
try {
|
||||
sha256 = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.wtf(TAG, "No support for SHA-256");
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetProxy() {
|
||||
httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
|
||||
}
|
||||
@@ -201,40 +174,6 @@ public class TelegramStickersGrabber {
|
||||
});
|
||||
}
|
||||
|
||||
private class StickerSet {
|
||||
String id;
|
||||
String name;
|
||||
String version;
|
||||
ArrayList<Sticker> stickers;
|
||||
|
||||
StickerSet(String id, String name, String version, ArrayList<Sticker> stickers) {
|
||||
this.name = name;
|
||||
this.stickers = stickers;
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
private class Sticker {
|
||||
String emoji;
|
||||
String fileId;
|
||||
|
||||
Sticker(String fileId, String emoji) {
|
||||
this.fileId = fileId;
|
||||
this.emoji = emoji;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof Sticker && ((Sticker) obj).fileId.equals(fileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (17 * emoji.hashCode()) << 32 + fileId.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private void getPackInfo(final String packName, final File packFolder, final String installedVersion, final PackDownloadListener listener) {
|
||||
NetRequest packInfoRequest = new NetRequest.Builder().get().url(String.format(GET_STICKER_SET_URL, botApiKey, packName)).build();
|
||||
httpClient.newCall(packInfoRequest).enqueue(new NetCallback() {
|
||||
@@ -478,4 +417,62 @@ public class TelegramStickersGrabber {
|
||||
private void runOnUiThread(Runnable r) {
|
||||
uiThreadHandler.post(r);
|
||||
}
|
||||
|
||||
public interface PackDownloadListener {
|
||||
void onPackDownloaded(TelegramStickersPackInfo pack, boolean newVersionFound);
|
||||
|
||||
void onPackDownloadError(Exception e);
|
||||
|
||||
void onGotPackInfo(TelegramStickersPackInfo packInfo);
|
||||
|
||||
void onStickerDownloaded(String pack, File sticker, String boundEmoji, int stickerIndex, int downloadedStickersCount, int totalStickerCount);
|
||||
}
|
||||
|
||||
public interface KeyCheckListener {
|
||||
void onKeyChecked(boolean ok);
|
||||
|
||||
void onNetError();
|
||||
}
|
||||
|
||||
public class TSGException extends Exception {
|
||||
private static final long serialVersionUID = 7866915509988422944L;
|
||||
|
||||
private TSGException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
private class StickerSet {
|
||||
String id;
|
||||
String name;
|
||||
String version;
|
||||
ArrayList<Sticker> stickers;
|
||||
|
||||
StickerSet(String id, String name, String version, ArrayList<Sticker> stickers) {
|
||||
this.name = name;
|
||||
this.stickers = stickers;
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
|
||||
private class Sticker {
|
||||
String emoji;
|
||||
String fileId;
|
||||
|
||||
Sticker(String fileId, String emoji) {
|
||||
this.fileId = fileId;
|
||||
this.emoji = emoji;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof Sticker && ((Sticker) obj).fileId.equals(fileId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (17 * emoji.hashCode()) << 32 + fileId.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,9 @@ import android.util.Log;
|
||||
*/
|
||||
public class GoalCounter {
|
||||
|
||||
public interface OnGoalReachListener {
|
||||
void onGoalReached();
|
||||
}
|
||||
|
||||
private int goal;
|
||||
private final int goal;
|
||||
private int i = 0;
|
||||
|
||||
private OnGoalReachListener listener;
|
||||
private final OnGoalReachListener listener;
|
||||
|
||||
public GoalCounter(int goal, OnGoalReachListener listener) {
|
||||
this.goal = goal;
|
||||
@@ -36,4 +31,8 @@ public class GoalCounter {
|
||||
public synchronized int value() {
|
||||
return i;
|
||||
}
|
||||
|
||||
public interface OnGoalReachListener {
|
||||
void onGoalReached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.vk.core.ui.themes;
|
||||
|
||||
import com.vk.s.R;
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public enum VKTheme {
|
||||
DEFAULT_LIGHT(0, R.g.BaseStyle),
|
||||
DARK(1, R.g.BaseDarkStyle),
|
||||
AMOLED(2, Themes.getAmoledTheme());
|
||||
|
||||
private final long id;
|
||||
private final int themeResId;
|
||||
|
||||
VKTheme(long j, int i) {
|
||||
this.id = j;
|
||||
this.themeResId = i;
|
||||
}
|
||||
|
||||
public final long a() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public final int b() {
|
||||
return this.themeResId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.vk.im.ui.themes;
|
||||
|
||||
import static com.vk.im.ui.R.m.VkIm_Theme_VkApp_Dark;
|
||||
import static com.vk.im.ui.R.m.VkIm_Theme_VkApp_Light;
|
||||
import static com.vk.im.ui.R.m.VkIm_Theme_VkMe_Dark;
|
||||
import static com.vk.im.ui.R.m.VkIm_Theme_VkMe_Light;
|
||||
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public enum ImTheme {
|
||||
VKAPP_LIGHT(0, VkIm_Theme_VkApp_Light),
|
||||
VKAPP_DARK(3, VkIm_Theme_VkApp_Dark),
|
||||
VKME_LIGHT(1, VkIm_Theme_VkMe_Light),
|
||||
VKME_DARK(2, VkIm_Theme_VkMe_Dark),
|
||||
VKME_AMOLED(5, Themes.getAmoledMeTheme()),
|
||||
VKAPP_AMOLED(4, Themes.getAmoledImTheme());
|
||||
|
||||
private final int id;
|
||||
private final int themeResId;
|
||||
|
||||
ImTheme(int i, int i2) {
|
||||
this.id = i;
|
||||
this.themeResId = i2;
|
||||
}
|
||||
|
||||
public final int a() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public final int b() {
|
||||
return this.themeResId;
|
||||
}
|
||||
}
|
||||
@@ -164,6 +164,18 @@ public final class R {
|
||||
public static final int start_values = 0x7f03005c;
|
||||
public static final int proxy = 0x7f03005d;
|
||||
public static final int proxy_value = 0x7f03005e;
|
||||
public static final int commentssort = 0x7f03005f;
|
||||
public static final int commentssort_value = 0x7f030060;
|
||||
public static final int darktheme = 0x7f030061;
|
||||
public static final int darktheme_value = 0x7f030062;
|
||||
public static final int lighttheme = 0x7f030063;
|
||||
public static final int lighttheme_value = 0x7f030064;
|
||||
public static final int msgcount = 0x7f030065;
|
||||
public static final int msgcount_value = 0x7f030066;
|
||||
public static final int newsupdate = 0x7f030067;
|
||||
public static final int newsupdate_value = 0x7f030068;
|
||||
public static final int undel = 0x7f030069;
|
||||
public static final int undel_value = 0x7f03006a;
|
||||
}
|
||||
|
||||
public static final class attr {
|
||||
@@ -2395,6 +2407,7 @@ public final class R {
|
||||
public static final int window_bg_transparent = 0x7f06028b;
|
||||
public static final int yellow = 0x7f06028c;
|
||||
public static final int yellow_light = 0x7f06028d;
|
||||
public static final int iclauncher = 0x7f06028e;
|
||||
}
|
||||
|
||||
public static final class dimen {
|
||||
@@ -14464,8 +14477,8 @@ public final class R {
|
||||
public static final int copytokenbtn = 0x7f111029;
|
||||
public static final int killappbtn = 0x7f11102a;
|
||||
public static final int experts = 0x7f11102b;
|
||||
public static final int DNT_OFF = 0x7f11102c;
|
||||
public static final int DNT_ON = 0x7f11102d;
|
||||
public static final int DNT_OFF_res_0x7f11102c = 0x7f11102c;
|
||||
public static final int DNT_ON_res_0x7f11102d = 0x7f11102d;
|
||||
public static final int accounts = 0x7f11102e;
|
||||
public static final int act_bot = 0x7f11102f;
|
||||
public static final int act_cnv = 0x7f111030;
|
||||
@@ -14986,6 +14999,144 @@ public final class R {
|
||||
public static final int vtlota = 0x7f111233;
|
||||
public static final int DNR_ON = 0x7f111234;
|
||||
public static final int DNR_OFF = 0x7f111235;
|
||||
public static final int DNT_ON_res_0x7f111236 = 0x7f111236;
|
||||
public static final int DNT_OFF_res_0x7f111237 = 0x7f111237;
|
||||
public static final int other_clear_stickers_cache_summary = 0x7f111238;
|
||||
public static final int dockbar_editor = 0x7f111239;
|
||||
public static final int dockbar_reset = 0x7f11123a;
|
||||
public static final int dockbar_save = 0x7f11123b;
|
||||
public static final int dockbar_selected_items = 0x7f11123c;
|
||||
public static final int dockbar_unselected_items = 0x7f11123d;
|
||||
public static final int checkforupdates = 0x7f11123e;
|
||||
public static final int other_fix_dynamic_colors = 0x7f11123f;
|
||||
public static final int other_reset_settings = 0x7f111240;
|
||||
public static final int other_reset_settings_summary = 0x7f111241;
|
||||
public static final int other_fix_app = 0x7f111242;
|
||||
public static final int activity_dnr_summary = 0x7f111243;
|
||||
public static final int activity_dnr_visual = 0x7f111244;
|
||||
public static final int activity_dnr_warn = 0x7f111245;
|
||||
public static final int activity_dns_summary = 0x7f111246;
|
||||
public static final int activity_dnw_summary = 0x7f111247;
|
||||
public static final int activity_undel = 0x7f111248;
|
||||
public static final int activity_undel_attachments = 0x7f111249;
|
||||
public static final int activity_undel_dial = 0x7f11124a;
|
||||
public static final int activity_undel_enable = 0x7f11124b;
|
||||
public static final int activity_undel_tag = 0x7f11124c;
|
||||
public static final int activity_what_is_it = 0x7f11124d;
|
||||
public static final int appearance_other_color_navbar_summary = 0x7f11124e;
|
||||
public static final int appearance_other_color_webview_summary = 0x7f11124f;
|
||||
public static final int appearance_theme_dark_theme = 0x7f111250;
|
||||
public static final int appearance_theme_dialog_title = 0x7f111251;
|
||||
public static final int appearance_theme_info = 0x7f111252;
|
||||
public static final int appearance_theme_info_summary = 0x7f111253;
|
||||
public static final int appearance_theme_light_theme = 0x7f111254;
|
||||
public static final int appearance_theme_use_system = 0x7f111255;
|
||||
public static final int appearance_theme_use_system_summary = 0x7f111256;
|
||||
public static final int debug_cache = 0x7f111257;
|
||||
public static final int debug_cache_trusted_hash = 0x7f111258;
|
||||
public static final int debug_cache_video = 0x7f111259;
|
||||
public static final int debug_cache_webview = 0x7f11125a;
|
||||
public static final int debug_developer_dark_mode = 0x7f11125b;
|
||||
public static final int debug_developer_force_ssl = 0x7f11125c;
|
||||
public static final int debug_developer_force_ssl_summary = 0x7f11125d;
|
||||
public static final int debug_developer_functions = 0x7f11125e;
|
||||
public static final int debug_developer_has_music_subscription = 0x7f11125f;
|
||||
public static final int debug_developer_has_music_subscription_summary = 0x7f111260;
|
||||
public static final int debug_developer_is_music_restricted = 0x7f111261;
|
||||
public static final int debug_developer_is_music_restricted_summary = 0x7f111262;
|
||||
public static final int debug_developer_mode = 0x7f111263;
|
||||
public static final int debug_developer_mode_summary = 0x7f111264;
|
||||
public static final int debug_developer_old_about = 0x7f111265;
|
||||
public static final int debug_developer_ssfs_custom = 0x7f111266;
|
||||
public static final int debug_domains = 0x7f111267;
|
||||
public static final int debug_domains_api = 0x7f111268;
|
||||
public static final int debug_domains_awayphp = 0x7f111269;
|
||||
public static final int debug_domains_editing = 0x7f11126a;
|
||||
public static final int debug_domains_editing_summary = 0x7f11126b;
|
||||
public static final int debug_domains_oauth = 0x7f11126c;
|
||||
public static final int debug_domains_vkui_host = 0x7f11126d;
|
||||
public static final int debug_domains_vkui_spa = 0x7f11126e;
|
||||
public static final int debug_experimental = 0x7f11126f;
|
||||
public static final int debug_experimental_language = 0x7f111270;
|
||||
public static final int debug_experimental_language_summary = 0x7f111271;
|
||||
public static final int debug_experimental_libverify = 0x7f111272;
|
||||
public static final int debug_experimental_libverify_summary = 0x7f111273;
|
||||
public static final int debug_experimental_opusmodule = 0x7f111274;
|
||||
public static final int debug_experimental_page_stats = 0x7f111275;
|
||||
public static final int debug_experimental_page_stats_summary = 0x7f111276;
|
||||
public static final int debug_experimental_usevkui = 0x7f111277;
|
||||
public static final int debug_experimental_vk_me_mode = 0x7f111278;
|
||||
public static final int debug_experimental_vk_sans_font = 0x7f111279;
|
||||
public static final int debug_logging = 0x7f11127a;
|
||||
public static final int debug_logging_api = 0x7f11127b;
|
||||
public static final int debug_logging_api_errors = 0x7f11127c;
|
||||
public static final int debug_logging_api_errors_summary = 0x7f11127d;
|
||||
public static final int debug_logging_api_summary = 0x7f11127e;
|
||||
public static final int debug_logging_apply_spaces = 0x7f11127f;
|
||||
public static final int debug_logging_apply_spaces_summary = 0x7f111280;
|
||||
public static final int debug_logging_breakpoints = 0x7f111281;
|
||||
public static final int debug_logging_breakpoints_summary = 0x7f111282;
|
||||
public static final int debug_logging_file = 0x7f111283;
|
||||
public static final int debug_logging_file_summary = 0x7f111284;
|
||||
public static final int debug_logging_force_stats_sending = 0x7f111285;
|
||||
public static final int debug_logging_memleak = 0x7f111286;
|
||||
public static final int debug_logging_visualise_viewposttime = 0x7f111287;
|
||||
public static final int debug_logging_visualise_viewposttime_summary = 0x7f111288;
|
||||
public static final int debug_logging_webview = 0x7f111289;
|
||||
public static final int debug_other = 0x7f11128a;
|
||||
public static final int debug_proxy = 0x7f11128b;
|
||||
public static final int debug_proxy_enable = 0x7f11128c;
|
||||
public static final int debug_proxy_enable_summary = 0x7f11128d;
|
||||
public static final int debug_proxy_force = 0x7f11128e;
|
||||
public static final int debug_proxy_force_summary = 0x7f11128f;
|
||||
public static final int debug_show_settings_item = 0x7f111290;
|
||||
public static final int debug_system = 0x7f111291;
|
||||
public static final int debug_system_fcm = 0x7f111292;
|
||||
public static final int debug_system_fcm_copy_token = 0x7f111293;
|
||||
public static final int debug_system_google_now = 0x7f111294;
|
||||
public static final int debug_system_language = 0x7f111295;
|
||||
public static final int debug_system_terminate = 0x7f111296;
|
||||
public static final int debug_tests = 0x7f111297;
|
||||
public static final int debug_tests_ads = 0x7f111298;
|
||||
public static final int debug_tests_bd = 0x7f111299;
|
||||
public static final int debug_tests_captcha = 0x7f11129a;
|
||||
public static final int debug_tests_crash = 0x7f11129b;
|
||||
public static final int debug_tests_pretty_cards = 0x7f11129c;
|
||||
public static final int debug_tests_spa = 0x7f11129d;
|
||||
public static final int debug_tests_spa_uri = 0x7f11129e;
|
||||
public static final int debug_tests_validation = 0x7f11129f;
|
||||
public static final int debug_warning = 0x7f1112a0;
|
||||
public static final int debug_warning_summary = 0x7f1112a1;
|
||||
public static final int feed_ads_carousel_summary = 0x7f1112a2;
|
||||
public static final int feed_ads_regular_summary = 0x7f1112a3;
|
||||
public static final int feed_ads_sources = 0x7f1112a4;
|
||||
public static final int feed_ads_sources_summary = 0x7f1112a5;
|
||||
public static final int feed_ads_stories_summary = 0x7f1112a6;
|
||||
public static final int feed_other_cache_summary = 0x7f1112a7;
|
||||
public static final int feed_other_sort_comments = 0x7f1112a8;
|
||||
public static final int feed_other_sort_comments_summary = 0x7f1112a9;
|
||||
public static final int feed_other_update = 0x7f1112aa;
|
||||
public static final int feed_other_update_dialog_title = 0x7f1112ab;
|
||||
public static final int feed_recommendations_authors_summary = 0x7f1112ac;
|
||||
public static final int feed_recommendations_friends_reacted_summary = 0x7f1112ad;
|
||||
public static final int feed_recommendations_friends_summary = 0x7f1112ae;
|
||||
public static final int interface_global_old_icons = 0x7f1112af;
|
||||
public static final int interface_global_old_icons_summary = 0x7f1112b0;
|
||||
public static final int messages_interface_calls_summary = 0x7f1112b1;
|
||||
public static final int messages_interface_tails_summary = 0x7f1112b2;
|
||||
public static final int messages_other_choose_count = 0x7f1112b3;
|
||||
public static final int messages_other_download_first = 0x7f1112b4;
|
||||
public static final int proxy_if = 0x7f1112b5;
|
||||
public static final int proxy_login_title = 0x7f1112b6;
|
||||
public static final int proxy_password_title = 0x7f1112b7;
|
||||
public static final int vkx_download = 0x7f1112b8;
|
||||
public static final int vk_fix_music = 0x7f1112b9;
|
||||
public static final int vk_fix_music_summary = 0x7f1112ba;
|
||||
public static final int vkx_integration = 0x7f1112bb;
|
||||
public static final int vk_fix_music_other = 0x7f1112bc;
|
||||
public static final int vkx_title = 0x7f1112bd;
|
||||
public static final int vkx_why = 0x7f1112be;
|
||||
public static final int vkx_why_summary = 0x7f1112bf;
|
||||
}
|
||||
|
||||
public static final class style {
|
||||
@@ -15927,6 +16078,11 @@ public final class R {
|
||||
public static final int MD_Button_Borderless = 0x7f1203a7;
|
||||
public static final int MD_Button_Borderless_Dialog = 0x7f1203a8;
|
||||
public static final int MaterialDialogTheme_Dark = 0x7f1203a9;
|
||||
public static final int ActionBarThemeFix = 0x7f1203aa;
|
||||
public static final int BaseAmoledStyle = 0x7f1203ab;
|
||||
public static final int BaseAmoledTheme = 0x7f1203ac;
|
||||
public static final int Vk_Theme_client_amoled_generated = 0x7f1203ad;
|
||||
public static final int VkIm_Theme_VkApp_Amoled = 0x7f1203ae;
|
||||
}
|
||||
|
||||
public static final class xml {
|
||||
|
||||
@@ -7,20 +7,17 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.internal.Util;
|
||||
import okhttp3.internal.b.HttpMethod;
|
||||
import okhttp3.Request;
|
||||
|
||||
public final class Request {
|
||||
/* renamed from: a reason: collision with root package name */
|
||||
final HttpUrl a;
|
||||
final String b;
|
||||
final Headers c;
|
||||
final Map<Class<?>, Object> e;
|
||||
private volatile CacheControl f;
|
||||
@Nullable
|
||||
final RequestBody requestBody;
|
||||
private volatile CacheControl f;
|
||||
|
||||
Request(Builder builder) {
|
||||
this.a = builder.a;
|
||||
@@ -58,7 +55,7 @@ public final class Request {
|
||||
|
||||
@Nullable
|
||||
public <T> T a(Class<? extends T> cls) {
|
||||
return (T) cls.cast(this.e.get(cls));
|
||||
return cls.cast(this.e.get(cls));
|
||||
}
|
||||
|
||||
public Builder e() {
|
||||
@@ -85,7 +82,6 @@ public final class Request {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/* renamed from: a reason: collision with root package name */
|
||||
HttpUrl a;
|
||||
String b;
|
||||
Headers.a c;
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
package ru.f0x1d.net;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import com.vk.core.network.Network;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class F0x1dRequest {
|
||||
|
||||
public interface F0x1dRequestCallback {
|
||||
void onResponse(String str);
|
||||
}
|
||||
|
||||
public static void makeRequest(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) {
|
||||
new MakeRequestTask(bArr, f0x1dRequestCallback).execute();
|
||||
}
|
||||
|
||||
public static void makeRequest(String str, F0x1dRequestCallback f0x1dRequestCallback) {
|
||||
new MakeRequestTask(str.getBytes(), f0x1dRequestCallback).execute();
|
||||
}
|
||||
|
||||
public static void makeRequestToaster(String str, F0x1dRequestCallback f0x1dRequestCallback, boolean z) {
|
||||
new MakeRequestTask(str.getBytes(), f0x1dRequestCallback, true, !z).execute();
|
||||
}
|
||||
|
||||
private static class MakeRequestTask extends AsyncTask<Void, Void, String> {
|
||||
private F0x1dRequestCallback callback;
|
||||
private boolean mIsPut;
|
||||
private boolean mIsVkToasterRequest;
|
||||
private byte[] url;
|
||||
|
||||
public MakeRequestTask(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) {
|
||||
this.mIsVkToasterRequest = false;
|
||||
this.mIsPut = false;
|
||||
this.callback = f0x1dRequestCallback;
|
||||
this.url = bArr;
|
||||
}
|
||||
|
||||
public MakeRequestTask(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback, boolean z, boolean z2) {
|
||||
this.mIsVkToasterRequest = false;
|
||||
this.mIsPut = false;
|
||||
this.callback = f0x1dRequestCallback;
|
||||
this.url = bArr;
|
||||
this.mIsVkToasterRequest = z;
|
||||
this.mIsPut = z2;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
public String doInBackground(Void... voidArr) {
|
||||
try {
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(new String(this.url)).openConnection();
|
||||
httpURLConnection.setRequestMethod(this.mIsPut ? "PUT" : "GET");
|
||||
if (this.mIsVkToasterRequest) {
|
||||
httpURLConnection.setRequestProperty("Token", Helper.GetUserToken());
|
||||
}
|
||||
if (!this.mIsVkToasterRequest) {
|
||||
httpURLConnection.setRequestProperty("User-Agent", Network.a.a().a());
|
||||
}
|
||||
httpURLConnection.setRequestProperty("Content-Type", this.mIsVkToasterRequest ? "Content-Type" : "application/x-www-form-urlencoded");
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine != null) {
|
||||
stringBuffer.append(readLine);
|
||||
} else {
|
||||
bufferedReader.close();
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return e.getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPostExecute(String str) {
|
||||
super.onPostExecute(str);
|
||||
this.callback.onResponse(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
package ru.vtosters.lite.audio.gcm;
|
||||
|
||||
import static ru.vtosters.lite.audio.gcm.NewGcmFix.FixToken;
|
||||
import static ru.vtosters.lite.audio.gcm.NewGcmFix.FixToken2;
|
||||
import static ru.vtosters.lite.utils.Preferences.VKVersion;
|
||||
import static ru.vtosters.lite.utils.Preferences.VKVersionBuild;
|
||||
import static ru.vtosters.lite.utils.Preferences.musicFixNew;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Base64;
|
||||
|
||||
@@ -26,21 +32,23 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
public class GCMFix {
|
||||
private static String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL);
|
||||
public static ArrayList<String> langs = new ArrayList<>();
|
||||
private static final String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL);
|
||||
private static KeyPair pair;
|
||||
private static int rid = 0;
|
||||
|
||||
/* access modifiers changed from: private */
|
||||
public interface Callback {
|
||||
void doCallback(String str);
|
||||
}
|
||||
|
||||
static {
|
||||
genNewKey();
|
||||
}
|
||||
|
||||
public static String requestTokenV2(){
|
||||
return FixToken2();
|
||||
}
|
||||
|
||||
public static String requestToken() {
|
||||
if(musicFixNew()){
|
||||
return FixToken();
|
||||
}
|
||||
String xappide;
|
||||
try {
|
||||
String[] aidarr = {"3974055026275073921", "4418584909973341826", "4585634953328772978"};
|
||||
@@ -73,7 +81,7 @@ public class GCMFix {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
String token = sb.toString();
|
||||
if (token.equals("EGISTRATION_ERROR")) {
|
||||
if (token.equals("REGISTRATION_ERROR")) {
|
||||
return requestToken();
|
||||
}
|
||||
rid = 0;
|
||||
@@ -81,12 +89,7 @@ public class GCMFix {
|
||||
String sig2 = getSig(pub22);
|
||||
params.clear();
|
||||
fillParams(params, sig2, pub22, xappide, Long.parseLong(aid.split(" ")[1].split(":")[0]), true);
|
||||
doRequest("https://android.clients.google.com/c2dm/register3", "POST", params, aid, new Callback() {
|
||||
@Override
|
||||
public void doCallback(String str) {
|
||||
GCMFix.lambda$requestToken$1(str);
|
||||
}
|
||||
});
|
||||
doRequest("https://android.clients.google.com/c2dm/register3", "POST", params, aid, GCMFix::lambda$requestToken$1);
|
||||
return token;
|
||||
} catch (FileNotFoundException e2) {
|
||||
return requestToken();
|
||||
@@ -95,12 +98,12 @@ public class GCMFix {
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ void lambdaRequestToken(StringBuilder sb, AtomicBoolean wait, String s) {
|
||||
static void lambdaRequestToken(StringBuilder sb, AtomicBoolean wait, String s) {
|
||||
sb.append(s.substring(20));
|
||||
wait.set(true);
|
||||
}
|
||||
|
||||
static /* synthetic */ void lambda$requestToken$1(String str) {
|
||||
static void lambda$requestToken$1(String str) {
|
||||
}
|
||||
|
||||
private static void fillParams(List<String> params, String sig, String pub2, String xappid, long androidId, boolean del) {
|
||||
@@ -113,7 +116,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);
|
||||
@@ -134,12 +137,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");
|
||||
}
|
||||
|
||||
@@ -196,4 +199,8 @@ public class GCMFix {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
void doCallback(String str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package ru.vtosters.lite.audio.gcm;
|
||||
|
||||
public class NewGcmFix { // @Leyzymoy is not gay, thank you my friend, sir...
|
||||
private static final short[] DATA = {835, 841, 841, 842, 771, 853, 771, 842, 771, 842, 859, 855, 832, 783, 846, 791, 852, 844, 855, 843, 770, 841, 842, 861, 845, 846, 851, 852, 777, 863, 778, 775, 775, 939, 951, 900, 934, 940, 905, 941, 935, 897, 935, 911, 935, 940, 931, 1015, 955, 916, 925, 900, 1015, 992, 939, 951, 900, 955, 940, 1020, 1019, 932, 916, 925, 903, 1016, 903, 909, 900, 1022, 916, 918, 896, 1022, 926, 922, 1022, 935, 936, 927, 992};
|
||||
|
||||
public static String FixToken() {
|
||||
short[] sArr = DATA;
|
||||
int hashCode = "۠ۡۦ".hashCode();
|
||||
int hashCode2 = "ۤۢۨ".hashCode();
|
||||
int hashCode3 = "ۦ۠ۤ".hashCode();
|
||||
return convert(sArr, ((hashCode2 ^ (-1)) & 1751594) | ((-1751595) & hashCode2), ((hashCode3 ^ (-1)) & 1753419) | ((-1753420) & hashCode3), ((hashCode ^ (-1)) & 1747007) | ((-1747008) & hashCode));
|
||||
}
|
||||
|
||||
public static String FixToken2() {
|
||||
short[] sArr = DATA;
|
||||
int hashCode = "ۦۧۢ".hashCode();
|
||||
int hashCode2 = "ۥ۟ۡ".hashCode();
|
||||
int hashCode3 = "ۣۤ۟".hashCode();
|
||||
return convert(sArr, ((hashCode2 ^ (-1)) & 1752486) | ((-1752487) & hashCode2), ((hashCode3 ^ (-1)) & 1751664) | ((-1751665) & hashCode3), ((hashCode ^ (-1)) & 1753487) | ((-1753488) & hashCode));
|
||||
}
|
||||
|
||||
private static String convert(short[] sArr, int i, int i2, int i3) {
|
||||
char[] cArr = new char[i2];
|
||||
for (int i4 = 0; i4 < i2; i4 = 1 - (0 - i4)) {
|
||||
short s = sArr[0 - ((0 - i) - i4)];
|
||||
cArr[i4] = (char) (((s ^ (-1)) & i3) | ((i3 ^ (-1)) & s));
|
||||
}
|
||||
return new String(cArr);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.badmanners;
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
public class Device {
|
||||
private String androidId;
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.badmanners;
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
@@ -164,7 +164,7 @@ public class DeviceInfoCollector {
|
||||
declaredField.setAccessible(true);
|
||||
Object obj = declaredField.get(defaultAdapter);
|
||||
if (obj != null) {
|
||||
return (String) obj.getClass().getMethod("getAddress", new Class[0]).invoke(obj, new Object[0]);
|
||||
return (String) obj.getClass().getMethod("getAddress").invoke(obj, new Object[0]);
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
@@ -1,24 +1,28 @@
|
||||
package ru.vtosters.lite.dnr;
|
||||
|
||||
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;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class DNRInjector {
|
||||
public static void inject(Dialog dialog, List<DialogAction> list) {
|
||||
int peerId = dialog.a();
|
||||
|
||||
if (DNRModule.isDnrEnabledFor(peerId)) {
|
||||
if (isDnrEnabledFor(peerId)) {
|
||||
list.add(DialogAction.valueOf("DNR_OFF"));
|
||||
} else {
|
||||
list.add(DialogAction.valueOf("DNR_ON"));
|
||||
}
|
||||
|
||||
if (DNRModule.isDntEnabledFor(peerId)) {
|
||||
if (isDntEnabledFor(peerId)) {
|
||||
list.add(DialogAction.valueOf("DNT_OFF"));
|
||||
} else {
|
||||
list.add(DialogAction.valueOf("DNT_ON"));
|
||||
@@ -26,10 +30,10 @@ public class DNRInjector {
|
||||
}
|
||||
|
||||
public static LinkedHashMap<DialogAction, Integer> injectToHashMap(LinkedHashMap<DialogAction, Integer> hashMap) {
|
||||
hashMap.put(DialogAction.valueOf("DNR_ON"), Helper.getIdentifier("DNR_ON", "string"));
|
||||
hashMap.put(DialogAction.valueOf("DNR_OFF"), Helper.getIdentifier("DNR_OFF", "string"));
|
||||
hashMap.put(DialogAction.valueOf("DNT_ON"), Helper.getIdentifier("DNT_ON", "string"));
|
||||
hashMap.put(DialogAction.valueOf("DNT_OFF"), Helper.getIdentifier("DNT_OFF", "string"));
|
||||
hashMap.put(DialogAction.valueOf("DNR_ON"), getIdentifier("DNR_ON", "string"));
|
||||
hashMap.put(DialogAction.valueOf("DNR_OFF"), getIdentifier("DNR_OFF", "string"));
|
||||
hashMap.put(DialogAction.valueOf("DNT_ON"), getIdentifier("DNT_ON", "string"));
|
||||
hashMap.put(DialogAction.valueOf("DNT_OFF"), getIdentifier("DNT_OFF", "string"));
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
@@ -56,11 +60,11 @@ public class DNRInjector {
|
||||
}
|
||||
|
||||
public static void setDnr(Dialog dialog, boolean value) {
|
||||
DNRModule.hookDNR(dialog.a());
|
||||
hookDNR(dialog.a());
|
||||
}
|
||||
|
||||
public static void setDnt(Dialog dialog, boolean value) {
|
||||
DNRModule.hookDNT(dialog.a());
|
||||
hookDNT(dialog.a());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package ru.vtosters.lite.dnr;
|
||||
|
||||
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;
|
||||
import com.vk.im.engine.models.dialogs.Dialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import ru.f0x1d.net.F0x1dRequest;
|
||||
import ru.vtosters.lite.dnr.helpers.DoNotReadDBHelper;
|
||||
import ru.vtosters.lite.dnr.helpers.DoNotTypeDBHelper;
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Proxy;
|
||||
|
||||
public class DNRModule {
|
||||
public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper();
|
||||
public static DoNotTypeDBHelper mDoNotTypeDBHelper = new DoNotTypeDBHelper();
|
||||
public static Dialog mDialog;
|
||||
|
||||
public static boolean isDnrEnabledFor(int id) {
|
||||
var isEnabled = mDoNotReadDBHelper.isEnabledForPeerId(id);
|
||||
@@ -49,13 +51,11 @@ public class DNRModule {
|
||||
}
|
||||
|
||||
public static void hookRead(Dialog dialog) {
|
||||
F0x1dRequest.makeRequest("https://" + Proxy.getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.lastMsgVkId + "&peer_id=" + dialog.a() + "&v=5.91&access_token=" + Helper.GetUserToken(), response -> {
|
||||
makeRequest("https://" + getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.lastMsgVkId + "&peer_id=" + dialog.a() + "&v=5.91&access_token=" + getUserToken(), response -> {
|
||||
ToastUtils.a("Чат помечен как прочитанный!");
|
||||
});
|
||||
}
|
||||
|
||||
public static Dialog mDialog;
|
||||
|
||||
public static void hookDNR(int peerId) {
|
||||
mDoNotReadDBHelper.setEnabledForPeerId(peerId, !mDoNotReadDBHelper.isEnabledForPeerId(peerId));
|
||||
}
|
||||
|
||||
@@ -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,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 DoNotReadDBHelper extends SQLiteOpenHelper {
|
||||
public DoNotReadDBHelper() {
|
||||
super(Helper.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,71 @@
|
||||
package ru.vtosters.lite.downloaders;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.app.DownloadManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.vk.core.f.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import ru.vtosters.lite.ui.activities.APKInstallActivity;
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
|
||||
public class OTADownloader {
|
||||
|
||||
private static final BroadcastReceiver callback = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
var extras = intent.getExtras();
|
||||
if (extras == null
|
||||
|| !intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) return;
|
||||
|
||||
var query = new DownloadManager.Query();
|
||||
var id = extras.getLong(DownloadManager.EXTRA_DOWNLOAD_ID);
|
||||
query.setFilterById(id);
|
||||
var manager = (DownloadManager) Globals.getContext().getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
var cursor = manager.query(query);
|
||||
if (cursor.moveToFirst()) {
|
||||
var status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
|
||||
if (status == DownloadManager.STATUS_SUCCESSFUL) {
|
||||
var downloadDir = new File(Environment.getExternalStorageDirectory(), "Download");
|
||||
if (!downloadDir.exists()) return;
|
||||
var list = downloadDir.listFiles();
|
||||
if (list == null || list.length == 0) return;
|
||||
var maxIndex = -1;
|
||||
for (File file : list) {
|
||||
var name = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf("/") + 1);
|
||||
if (file.isFile()
|
||||
&& name.matches("VTLite-\\d+\\.apk"))
|
||||
maxIndex = Math.max(maxIndex, Integer.parseInt(name.replaceFirst(".+-(\\d+).+", "$1")));
|
||||
}
|
||||
File apk = maxIndex == -1 ? new File(downloadDir, "VTLite.apk") : new File(downloadDir, "VTLite-" + maxIndex + ".apk");
|
||||
APKInstallActivity.installOta(context, FileUtils.h(apk));
|
||||
} else if (status == DownloadManager.STATUS_FAILED) {
|
||||
Globals.sendToast(getString("downloaderr"));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void downloadBuild(String url) {
|
||||
var context = Globals.getContext();
|
||||
var uri = Uri.parse(url);
|
||||
|
||||
context.registerReceiver(callback, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
|
||||
|
||||
var request = new DownloadManager.Request(uri);
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
request.setTitle("VTLite.apk");
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "VTLite.apk");
|
||||
|
||||
var manager = (DownloadManager) Globals.getContext().getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
manager.enqueue(request);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package ru.vtosters.lite.downloaders;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.Context;
|
||||
@@ -48,7 +50,7 @@ public class VideoDownloader {
|
||||
}
|
||||
|
||||
if (list.isEmpty()) {
|
||||
ToastUtils.a("Данное видео невозможно скачать");
|
||||
ToastUtils.a(getString("videodownloaderr"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +66,7 @@ public class VideoDownloader {
|
||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
|
||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
request.setTitle(videoFile.toString());
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile.s + ".mp4");
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile + ".mp4");
|
||||
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
|
||||
}));
|
||||
builder.show();
|
||||
|
||||
@@ -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,5 +1,9 @@
|
||||
package ru.vtosters.lite.f0x1d;
|
||||
|
||||
import static ru.vtosters.lite.utils.About.getBuildNumber;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
@@ -16,9 +20,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;
|
||||
@@ -35,12 +37,12 @@ public class Crashreporter {
|
||||
}
|
||||
|
||||
static void start(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th, Activity activity) {
|
||||
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(Helper.GetContext()).toDeviceName() + "\n VTL Version: " + Prefs.VERSIONNAME + ", build: " + Prefs.getBuildNumber();
|
||||
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) Helper.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");
|
||||
@@ -52,20 +54,20 @@ public class Crashreporter {
|
||||
foxbinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
|
||||
}
|
||||
|
||||
var saveLogIntent = new Intent(Helper.GetContext(), LogWriterService.class);
|
||||
var saveLogIntent = new Intent(getContext(), LogWriterService.class);
|
||||
saveLogIntent.putExtra("log", logString);
|
||||
saveLogIntent.putExtra("notificationId", 1);
|
||||
var psaveLogIntent = PendingIntent.getService(Helper.GetContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
var psaveLogIntent = PendingIntent.getService(getContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
var builder = new Notification.Builder(Helper.GetContext());
|
||||
var builder = new Notification.Builder(getContext());
|
||||
builder.setSmallIcon(R.drawable.ic_bug_24);
|
||||
builder.setContentTitle("VTL Крашнулся!");
|
||||
builder.setContentTitle(getString("vtl_crashed"));
|
||||
builder.setContentText(logString);
|
||||
builder.setStyle(new Notification.BigTextStyle().bigText(logString));
|
||||
builder.setAutoCancel(true);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
||||
builder.addAction(new Notification.Action(0, "Загрузить логи", PendingIntent.getActivity(Helper.GetContext(), (int) (Math.random() * 100.0d), foxbinIntent, PendingIntent.FLAG_CANCEL_CURRENT)));
|
||||
builder.addAction(new Notification.Action(0, "Сохранить в файл", psaveLogIntent));
|
||||
builder.addAction(new Notification.Action(0, getString("vtl_crash_upload"), PendingIntent.getActivity(getContext(), (int) (Math.random() * 100.0d), foxbinIntent, PendingIntent.FLAG_CANCEL_CURRENT)));
|
||||
builder.addAction(new Notification.Action(0, getString("vtl_crash_save"), psaveLogIntent));
|
||||
} else {
|
||||
builder.setContentIntent(PendingIntent.getActivity(activity, 0, foxbinIntent, PendingIntent.FLAG_ONE_SHOT));
|
||||
}
|
||||
@@ -75,13 +77,13 @@ public class Crashreporter {
|
||||
}
|
||||
|
||||
|
||||
((NotificationManager) Helper.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 = Helper.GetContext().getPackageManager();
|
||||
var pm = getContext().getPackageManager();
|
||||
try {
|
||||
pm.getPackageInfo("com.f0x1d.dogbin", 0);
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package ru.vtosters.lite.f0x1d;
|
||||
|
||||
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;
|
||||
import android.content.Context;
|
||||
@@ -7,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;
|
||||
|
||||
@@ -16,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() {
|
||||
}
|
||||
@@ -38,12 +39,12 @@ public class LogWriterService extends Service {
|
||||
writeLog(intent, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(Helper.GetContext(), "Не удалось сохранить лог-файл", Toast.LENGTH_SHORT).show();
|
||||
makeText(getContext(), "Не удалось сохранить лог-файл", LENGTH_SHORT).show();
|
||||
}
|
||||
var notificationId = intent.getIntExtra("notificationId", 1);
|
||||
var manager = (NotificationManager) Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
var manager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.cancel(notificationId);
|
||||
Toast.makeText(Helper.GetContext(), "Лог-файл был сохранен", Toast.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,24 +26,23 @@ 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<>();
|
||||
private static final String TAG = "VTVerifications";
|
||||
private static final String DEVELOPERS_KEY = "VTNRS3";
|
||||
private static final String PROMETHEUS_KEY = "VTNRS1";
|
||||
private static final String SERVICE_ACCOUNTS_KEY = "VTNRS4";
|
||||
private static final String VERIFICATIONS_KEY = "VTNRS0";
|
||||
private static SharedPreferences mVerificationsCache;
|
||||
private static final HashMap<Integer, Boolean> sDevelopersMap = new HashMap<>();
|
||||
private static final HashMap<Integer, Boolean> sPrometheusMap = new HashMap<>();
|
||||
public static final HashMap<Integer, Boolean> sServiceAccountsMap = new HashMap<>();
|
||||
private static final HashMap<Integer, Boolean> sVerificationsMap = new HashMap<>();
|
||||
|
||||
private static OkHttpClient client = new OkHttpClient();
|
||||
private static SharedPreferences mVerificationsCache;
|
||||
private static final OkHttpClient client = new OkHttpClient();
|
||||
|
||||
public static void load(Context context) {
|
||||
mVerificationsCache = context.getSharedPreferences("vt_another_data", 0);
|
||||
|
||||
try {
|
||||
processArray(new JSONArray(getLoaded(VERIFICATIONS_KEY)), sVerificationsMap, null);
|
||||
processArray(new JSONArray(getLoaded(PROMETHEUS_KEY)), sPrometheusMap, null);
|
||||
@@ -53,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();
|
||||
|
||||
@@ -102,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) {
|
||||
@@ -132,36 +131,40 @@ 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;
|
||||
}
|
||||
if (isVerified((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
public static boolean hasPrometheus(JSONObject jSONObject) {
|
||||
if (jSONObject.optInt("trending", 0) == 1) {
|
||||
return true;
|
||||
}
|
||||
if (!Prefs.BooleanTrue("VT_Fire")) {
|
||||
|
||||
if (!getBoolValue("VT_Fire", true)) {
|
||||
return false;
|
||||
}
|
||||
if (hasPrometheus((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
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,12 +1,16 @@
|
||||
package ru.vtosters.lite.foaf;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.getDateFormat;
|
||||
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;
|
||||
|
||||
@@ -23,19 +27,16 @@ 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=\"(.+?)\"\\/>");
|
||||
private static final Pattern FOAF_REGEX_LAST_SEEN = Pattern.compile("<ya:lastLoggedIn dc:date=\"(.*)(((\\+|-)\\d\\d):(\\d\\d))\"\\/>");
|
||||
private static final Pattern FOAF_REGEX_LOGIN = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>");
|
||||
private static OkHttpClient client = new OkHttpClient();
|
||||
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;
|
||||
}
|
||||
@@ -49,7 +50,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 {
|
||||
@@ -63,15 +64,15 @@ public class FoafBase {
|
||||
|
||||
public static void loadAndShow(Context context, int i) {
|
||||
ProgressDialog progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setMessage("Загрузка...");
|
||||
progressDialog.setMessage(getString("com_facebook_loading"));
|
||||
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 /* synthetic */ void lambdaLoadAndShow(ProgressDialog progressDialog, Context context, int i, String str) {
|
||||
static void lambdaLoadAndShow(ProgressDialog progressDialog, Context context, int i, String str) {
|
||||
try {
|
||||
progressDialog.cancel();
|
||||
Matcher matcher = FOAF_REGEX.matcher(str);
|
||||
@@ -80,11 +81,11 @@ public class FoafBase {
|
||||
matcher2.find();
|
||||
String normalHumanDate = getNormalHumanDate(matcher.group(1));
|
||||
getNormalHumanDate(matcher2.group(1));
|
||||
AlertDialog.a a2 = new VkAlertDialog.a(context).a(R.string.addinf);
|
||||
a2.b(Helper.getString("foafid") + " " + i + Helper.getString("foafregdate") + " " + normalHumanDate + Helper.getString("foafdate") + " " + daysPassedFromFoafDate(normalHumanDate)).b(17039370, (DialogInterface.OnClickListener) null).b().show();
|
||||
AlertDialog.a a2 = new VkAlertDialog.a(context).a(getIdentifier("addinf", "string"));
|
||||
a2.b(getString("foafid") + " " + i + getString("foafregdate") + " " + normalHumanDate + getString("foafdate") + " " + daysPassedFromFoafDate(normalHumanDate)).b(17039370, null).b().show();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Toast.makeText(context, Helper.getString("foaferr"), Toast.LENGTH_SHORT).show();
|
||||
makeText(context, getString("foaferr"), LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-15
@@ -1,4 +1,6 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -13,17 +15,25 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import android.util.Base64;
|
||||
|
||||
public final class NetCall {
|
||||
private NetRequest req;
|
||||
private NetClient cl;
|
||||
private final NetRequest req;
|
||||
private final NetClient cl;
|
||||
|
||||
protected NetCall(NetClient cl, NetRequest req) {
|
||||
this.req = req;
|
||||
this.cl = cl;
|
||||
}
|
||||
|
||||
private static String constructArgs(Map<String, String> args) throws UnsupportedEncodingException {
|
||||
args = new TreeMap<>(args);
|
||||
String str = "";
|
||||
for (Map.Entry<String, String> en : args.entrySet()) {
|
||||
if (!str.isEmpty()) str += "&";
|
||||
str += URLEncoder.encode(en.getKey(), "UTF-8") + "=" + URLEncoder.encode(en.getValue(), "UTF-8");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public NetRequest request() {
|
||||
return req;
|
||||
}
|
||||
@@ -65,16 +75,6 @@ public final class NetCall {
|
||||
return r;
|
||||
}
|
||||
|
||||
private static String constructArgs(Map<String, String> args) throws UnsupportedEncodingException {
|
||||
args = new TreeMap<>(args);
|
||||
String str = "";
|
||||
for (Map.Entry<String, String> en : args.entrySet()) {
|
||||
if (!str.isEmpty()) str += "&";
|
||||
str += URLEncoder.encode(en.getKey(), "UTF-8") + "=" + URLEncoder.encode(en.getValue(), "UTF-8");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public void enqueue(NetCallback cb) {
|
||||
new Thread() {
|
||||
@Override
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
+34
-34
@@ -1,13 +1,43 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class NetClient {
|
||||
private long timeout;
|
||||
private Proxy proxy;
|
||||
private PasswordAuthentication authenticator;
|
||||
private final long timeout;
|
||||
private final Proxy proxy;
|
||||
private final PasswordAuthentication authenticator;
|
||||
|
||||
protected NetClient(Builder b) {
|
||||
timeout = b.timeout;
|
||||
proxy = b.proxy;
|
||||
authenticator = b.auth;
|
||||
}
|
||||
|
||||
public Builder newBuilder() {
|
||||
Builder b = new Builder();
|
||||
b.timeout = timeout;
|
||||
b.proxy = proxy;
|
||||
b.auth = authenticator;
|
||||
return b;
|
||||
}
|
||||
|
||||
public NetCall newCall(NetRequest req) {
|
||||
return new NetCall(this, req);
|
||||
}
|
||||
|
||||
public PasswordAuthentication getAuthenticator() {
|
||||
return authenticator;
|
||||
}
|
||||
|
||||
public Proxy getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private long timeout;
|
||||
@@ -54,34 +84,4 @@ public class NetClient {
|
||||
return new NetClient(this);
|
||||
}
|
||||
}
|
||||
|
||||
public Builder newBuilder() {
|
||||
Builder b = new Builder();
|
||||
b.timeout = timeout;
|
||||
b.proxy = proxy;
|
||||
b.auth = authenticator;
|
||||
return b;
|
||||
}
|
||||
|
||||
protected NetClient(Builder b) {
|
||||
timeout = b.timeout;
|
||||
proxy = b.proxy;
|
||||
authenticator = b.auth;
|
||||
}
|
||||
|
||||
public NetCall newCall(NetRequest req) {
|
||||
return new NetCall(this, req);
|
||||
}
|
||||
|
||||
public PasswordAuthentication getAuthenticator() {
|
||||
return authenticator;
|
||||
}
|
||||
|
||||
public Proxy getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
}
|
||||
+22
-22
@@ -1,12 +1,30 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class NetRequest {
|
||||
private String url;
|
||||
private String requestMethod;
|
||||
private Map<String, String> params;
|
||||
private final String url;
|
||||
private final String requestMethod;
|
||||
private final Map<String, String> params;
|
||||
|
||||
protected NetRequest(Builder b) {
|
||||
url = b.url;
|
||||
requestMethod = b.req;
|
||||
params = b.params;
|
||||
}
|
||||
|
||||
public Map<String, String> getRequestParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public String url() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getRequestMethod() {
|
||||
return requestMethod;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private String url;
|
||||
@@ -43,22 +61,4 @@ public class NetRequest {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected NetRequest(Builder b) {
|
||||
url = b.url;
|
||||
requestMethod = b.req;
|
||||
params = b.params;
|
||||
}
|
||||
|
||||
public Map<String, String> getRequestParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public String url() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public String getRequestMethod() {
|
||||
return requestMethod;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package ru.f0x1d.net;
|
||||
package ru.vtosters.lite.net;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public final class NetResponse {
|
||||
private byte[] data;
|
||||
private final byte[] data;
|
||||
private int code;
|
||||
|
||||
protected NetResponse(byte[] data) {
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,5 @@ package ru.vtosters.lite.provider;
|
||||
|
||||
import android.support.v4.content.FileProvider;
|
||||
|
||||
/* compiled from: VKFileProvider.kt */
|
||||
public final class VKFileProvider extends FileProvider {
|
||||
}
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
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 SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
|
||||
private static final SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
private static String
|
||||
CNCT_METHOD = "VTGS:CM",
|
||||
TG_BOTKEY = "VTGS:BKey",
|
||||
TG_PROXYIP = "VTGS:PIP",
|
||||
TG_PROXYPORT = "VTGS:PPT",
|
||||
TG_PROXYPASS = "VTGS:PPS",
|
||||
TG_PROXYUSER = "VTGS:PUS",
|
||||
TG_PROXYUSEPASS = "VTGS:PUsePassword";
|
||||
private static final String CNCT_METHOD = "VTGS:CM";
|
||||
private static final String TG_BOTKEY = "VTGS:BKey";
|
||||
private static final String TG_PROXYIP = "VTGS:PIP";
|
||||
private static final String TG_PROXYPORT = "VTGS:PPT";
|
||||
private static final String TG_PROXYPASS = "VTGS:PPS";
|
||||
private static final String TG_PROXYUSER = "VTGS:PUS";
|
||||
private static final String TG_PROXYUSEPASS = "VTGS:PUsePassword";
|
||||
|
||||
public static int getTGConnectMethod() {
|
||||
return Integer.parseInt(Prefs.getString(CNCT_METHOD, "0"));
|
||||
@@ -37,6 +36,10 @@ public class TGPref {
|
||||
return Prefs.getString(TG_PROXYIP, null);
|
||||
}
|
||||
|
||||
public static void setTGProxyIP(String ip) {
|
||||
Prefs.edit().putString(TG_PROXYIP, ip).apply();
|
||||
}
|
||||
|
||||
public static int getTGProxyPort() {
|
||||
return Prefs.getInt(TG_PROXYPORT, 0);
|
||||
}
|
||||
@@ -53,13 +56,8 @@ public class TGPref {
|
||||
return Prefs.getString(TG_PROXYUSER, "");
|
||||
}
|
||||
|
||||
public static void setTGProxyIP(String ip) {
|
||||
Prefs.edit().putString(TG_PROXYIP, ip).apply();
|
||||
}
|
||||
|
||||
public static void setTGProxyUserPass(String user, String pass) {
|
||||
Prefs.edit().putString(TG_PROXYUSER, user).putString(TG_PROXYPASS, pass)
|
||||
.apply();
|
||||
Prefs.edit().putString(TG_PROXYUSER, user).putString(TG_PROXYPASS, pass).apply();
|
||||
}
|
||||
|
||||
public static boolean isTGProxyPassEnabled() {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package ru.vtosters.lite.tgs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
@@ -20,24 +23,20 @@ import org.json.JSONObject;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class TGRoot {
|
||||
private final static Stack<Integer> pendingStickers = new Stack<>();
|
||||
|
||||
public static final int N = 76820000;
|
||||
public static final int X = 976820000;
|
||||
|
||||
private static String TAG = "TGRoot";
|
||||
private final static Stack<Integer> pendingStickers = new Stack<>();
|
||||
private static final String TAG = "TGRoot";
|
||||
|
||||
public static String getSummary() {
|
||||
switch (TGPref.getTGConnectMethod()) {
|
||||
case 0:
|
||||
return Helper.getString("ctypedirect");
|
||||
return getString("ctypedirect");
|
||||
case 2:
|
||||
return Helper.getString("ctypesocks");
|
||||
return getString("ctypesocks");
|
||||
default:
|
||||
return Helper.getString("ctypedisabled");
|
||||
return getString("ctypedisabled");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +48,7 @@ public class TGRoot {
|
||||
int stickerId = (id - N) % 120;
|
||||
|
||||
TelegramStickersPack pack = null;
|
||||
for (TelegramStickersPack p : TelegramStickersService.getInstance(Helper.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(Helper.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(Helper.GetContext())
|
||||
for (TelegramStickersPack p_ : TelegramStickersService.getInstance(getContext())
|
||||
.getActivePacksListReference()) {
|
||||
if (p_.index == index) {
|
||||
p = p_;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package ru.vtosters.lite.ui;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
@@ -22,22 +25,17 @@ import androidx.core.view.ViewCompat;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
import com.vtosters.lite.ui.MaterialSwitchPreference;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public class PreferencesUtil {
|
||||
|
||||
public interface EditTextPrefChangeListener {
|
||||
boolean onChanged(Preference preference, Object obj);
|
||||
}
|
||||
|
||||
public static Drawable setTint(Context ctx, Drawable d) {
|
||||
d.setColorFilter(Themes.getAccentColor(), PorterDuff.Mode.SRC_ATOP);
|
||||
return d;
|
||||
}
|
||||
|
||||
public static void addListPreference(MaterialPreferenceToolbarFragment fragment, String key, String def, CharSequence title, CharSequence[] entries, CharSequence[] entriesValue) {
|
||||
ListPreference preference = new ListPreference(Helper.GetContext());
|
||||
ListPreference preference = new ListPreference(getContext());
|
||||
preference.a(entries);
|
||||
preference.b(entriesValue);
|
||||
preference.c(title); // setTitle
|
||||
@@ -48,7 +46,7 @@ public class PreferencesUtil {
|
||||
}
|
||||
|
||||
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment materialPreferenceToolbarFragment, String key, CharSequence title, CharSequence summary, boolean defValue) {
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(Helper.GetContext());
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getContext());
|
||||
materialSwitchPreference.c(title); // setTitle
|
||||
materialSwitchPreference.b(summary); // setSummary
|
||||
materialSwitchPreference.d(key); // setKey
|
||||
@@ -58,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(Helper.GetContext());
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getContext());
|
||||
materialSwitchPreference.c(title); // setTitle
|
||||
materialSwitchPreference.b(summary); // setSummary
|
||||
materialSwitchPreference.d(key); // setKey
|
||||
@@ -66,13 +64,13 @@ public class PreferencesUtil {
|
||||
materialSwitchPreference.a(listener); // setOnPreferenceClickListener
|
||||
|
||||
if (icon != 1)
|
||||
materialSwitchPreference.a(setTint(Helper.GetContext(), ContextCompat.getDrawable(Helper.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(Helper.GetContext());
|
||||
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(getContext());
|
||||
materialSwitchPreference.c(title); // setTitle
|
||||
materialSwitchPreference.b(summary); // setSummary
|
||||
materialSwitchPreference.d(key); // setKey
|
||||
@@ -80,14 +78,14 @@ public class PreferencesUtil {
|
||||
fragment.ay().d(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference)
|
||||
|
||||
if (icon != null)
|
||||
materialSwitchPreference.a(setTint(Helper.GetContext(), getDrawable(Helper.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(Helper.GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
preference.b(summary); // setSummary
|
||||
preference.c(title); // setTitle
|
||||
preference.d(key); // setKey
|
||||
@@ -96,64 +94,77 @@ public class PreferencesUtil {
|
||||
}
|
||||
|
||||
public static void addPreference(MaterialPreferenceToolbarFragment fragment, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) {
|
||||
Preference preference = new Preference(Helper.GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
preference.b(summary); // setSummary
|
||||
preference.c(title); // setTitle
|
||||
|
||||
if (icon != null)
|
||||
preference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon
|
||||
preference.a(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(Helper.GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
preference.b(summary); // setSummary
|
||||
preference.c(title); // setTitle
|
||||
preference.d(key); // setKey
|
||||
|
||||
if (icon != null)
|
||||
preference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon
|
||||
preference.a(setTint(getContext(), getDrawable(getContext(), icon))); // preference.setIcon
|
||||
preference.a(listener); // preference.setOnPreferenceClickListener(listener)
|
||||
|
||||
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
|
||||
}
|
||||
|
||||
public static void addPreferenceDrawable(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, @Nullable Drawable icon, Preference.c listener) {
|
||||
Preference preference = new Preference(getContext());
|
||||
preference.b(summary); // setSummary
|
||||
preference.c(title); // setTitle
|
||||
preference.d(key); // setKey
|
||||
|
||||
if (icon != null)
|
||||
preference.a(icon); // preference.setIcon
|
||||
preference.a(listener); // preference.setOnPreferenceClickListener(listener)
|
||||
|
||||
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
|
||||
}
|
||||
|
||||
public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title) {
|
||||
PreferenceCategory preference = new PreferenceCategory(Helper.GetContext(), null);
|
||||
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(Helper.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(Helper.GetContext());
|
||||
Preference preference = new Preference(getContext());
|
||||
|
||||
preference.c(title); // setTitle
|
||||
preference.d(key); // setKey
|
||||
preference.a(preference1 -> {
|
||||
LinearLayout linearLayout = new LinearLayout(Helper.GetContext());
|
||||
LinearLayout linearLayout = new LinearLayout(getContext());
|
||||
|
||||
final EditText editText = new EditText(Helper.GetContext());
|
||||
editText.setText(PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()).getString(key, ""));
|
||||
final EditText editText = new EditText(getContext());
|
||||
editText.setText(PreferenceManager.getDefaultSharedPreferences(getContext()).getString(key, ""));
|
||||
editText.setHint(title);
|
||||
editText.setHintTextColor(PreferencesUtil.getSTextColor(Helper.GetContext()));
|
||||
editText.setHintTextColor(PreferencesUtil.getSTextColor(getContext()));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
} else {
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
}
|
||||
linearLayout.addView(editText);
|
||||
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
|
||||
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0);
|
||||
margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.p());
|
||||
@@ -164,7 +175,7 @@ public class PreferencesUtil {
|
||||
if (!change)
|
||||
return;
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(Helper.GetContext())
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext())
|
||||
.edit()
|
||||
.putString(key, editText.getText().toString())
|
||||
.apply();
|
||||
@@ -192,4 +203,8 @@ public class PreferencesUtil {
|
||||
var id = ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName());
|
||||
return ContextCompat.getDrawable(ctx, id);
|
||||
}
|
||||
|
||||
public interface EditTextPrefChangeListener {
|
||||
boolean onChanged(Preference preference, Object obj);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package ru.vtosters.lite.ui.activities;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class APKInstallActivity extends AppCompatActivity {
|
||||
public static final int REQUEST_INSTALL_PERMISSION = 1;
|
||||
|
||||
public static final String EXTRA_APK_URI = "apk_uri";
|
||||
|
||||
private Uri mApkUri;
|
||||
|
||||
public static void installOta(Context context, Uri apkUri) {
|
||||
Intent intent = new Intent(context, APKInstallActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.putExtra(EXTRA_APK_URI, apkUri);
|
||||
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
Toast.makeText(this, "No intent", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mApkUri = intent.getParcelableExtra(EXTRA_APK_URI);
|
||||
if (mApkUri == null) {
|
||||
Toast.makeText(this, "No apk uri", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
installApk();
|
||||
}
|
||||
|
||||
private void installApk() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
if (!getPackageManager().canRequestPackageInstalls()) {
|
||||
Intent permIntent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:" + getPackageName()));
|
||||
startActivityForResult(permIntent, REQUEST_INSTALL_PERMISSION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(mApkUri, "application/vnd.android.package-archive");
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Toast.makeText(this, "Ошибка установки обновления " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if (requestCode == REQUEST_INSTALL_PERMISSION)
|
||||
installApk();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
@@ -9,20 +14,18 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.OEMDetector;
|
||||
import ru.vtosters.lite.utils.Prefs;
|
||||
|
||||
public class DisableBattery {
|
||||
public static void alert(Activity activity) {
|
||||
if (OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && Prefs.BooleanTrue("showDoze")) {
|
||||
final Context context = Helper.GetContext();
|
||||
if (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("Выключите оптимизацию батареи!");
|
||||
builder.setMessage("Из-за того, что Вы используете оболочку из списка ниже - уведомления могут приходить с задержкой или не приходить вовсе. \n Для того, чтобы это исправить - нажмите на кнопку \"Отключить оптимизацию\". \n\nПрошивки на которых наблюдаются проблемы с пушами:\nFlyme, EMUI, MIUI, ColorOS, Samsung Experience или TouchWiz, Magic UI, ZenUI, Funtouch OS");
|
||||
builder.setTitle(getString("batteryissuetitle"));
|
||||
builder.setMessage(getString("batteryissuesumm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton("Отключить оптимизацию", new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(getString("batteryissuebtn1"), new DialogInterface.OnClickListener() {
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Intent intent = new Intent("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS");
|
||||
@@ -33,10 +36,10 @@ public class DisableBattery {
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("Игнорировать", new DialogInterface.OnClickListener() {
|
||||
builder.setNeutralButton(getString("batteryissuebtn2"), new DialogInterface.OnClickListener() {
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Helper.edit().putBoolean("showDoze", false).apply();
|
||||
edit().putBoolean("showDoze", false).apply();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Globals.isGmsInstalled;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
@@ -9,40 +15,34 @@ 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 (!Helper.IsGmsInstalled()) {
|
||||
if (!isGmsInstalled()) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Внимание!");
|
||||
builder.setMessage(Text());
|
||||
builder.setTitle(getString("debug_warning"));
|
||||
builder.setMessage(getString("gmsissuesumm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton("Продолжить без GMS", new DialogInterface.OnClickListener() {
|
||||
builder.setPositiveButton(getString("gmsissuebtn1"), new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Helper.edit().putBoolean("showAlertGms", false).apply();
|
||||
edit().putBoolean("showAlertGms", false).apply();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("Установить GMS", new DialogInterface.OnClickListener() {
|
||||
builder.setNeutralButton(getString("gmsissuebtn2"), new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Helper.edit().putBoolean("showAlertGms", false).apply();
|
||||
Context context = Helper.GetContext();
|
||||
edit().putBoolean("showAlertGms", false).apply();
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(InstallGMSFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
}
|
||||
});
|
||||
if (Prefs.BooleanTrue("showAlertGms")) {
|
||||
if (getBoolValue("showAlertGms", true)) {
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String Text() {
|
||||
return "На вашем устройстве отсутствует компонент Google Play Services (GMS), который необходим для корректной работы VTosters Lite";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import ru.vtosters.lite.downloaders.OTADownloader;
|
||||
import ru.vtosters.lite.ui.vkui.ModalBottomSheetWrapper;
|
||||
import ru.vtosters.lite.utils.OTAHelper;
|
||||
|
||||
public class OTADialog implements OTAHelper.OTAListener {
|
||||
|
||||
private Activity mActivity;
|
||||
|
||||
private OTAHelper mHelper;
|
||||
|
||||
public static OTADialog checkUpdates(Activity activity) {
|
||||
return new OTADialog(activity);
|
||||
}
|
||||
|
||||
public OTADialog(Activity activity) {
|
||||
mActivity = activity;
|
||||
|
||||
mHelper = new OTAHelper(this);
|
||||
mHelper.loadData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateApplied() {
|
||||
mActivity.runOnUiThread(() -> {
|
||||
// Toast.makeText(mActivity, "Обновления найдены", Toast.LENGTH_SHORT).show();
|
||||
new ModalBottomSheetWrapper(mActivity)
|
||||
.setUpdateInfoView(mHelper.getNewVersionName(), mHelper.getUpdateDescription())
|
||||
.setPositiveButton(getString("updateanddownload"), () -> {
|
||||
OTADownloader.downloadBuild(mHelper.getDownloadUrl());
|
||||
})
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateCanceled() {
|
||||
mActivity.runOnUiThread(() -> {
|
||||
// Toast.makeText(mActivity, "Обновлений не найдено", Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
@@ -7,9 +11,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) {
|
||||
@@ -17,35 +19,36 @@ public class Start {
|
||||
activity.requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228);
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle("Внимание!");
|
||||
builder.setTitle(getString("debug_warning"));
|
||||
builder.setMessage(getWelcome());
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton("Продолжить", new DialogInterface.OnClickListener() {
|
||||
/* class ru.vtosters.lite.utils.lite.dialog.Start.AnonymousClass1 */
|
||||
builder.setPositiveButton(getString("startbtn2"), new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Helper.edit().putBoolean("showAlert", false).apply();
|
||||
edit().putBoolean("showAlert", false).apply();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton("Новости", new DialogInterface.OnClickListener() {
|
||||
/* class ru.vtosters.lite.utils.lite.dialog.Start.AnonymousClass2 */
|
||||
builder.setNeutralButton(getString("startbtn1"), new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Helper.edit().putBoolean("showAlert", false).apply();
|
||||
edit().putBoolean("showAlert", false).apply();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getWelcome() {
|
||||
if (!OEMDetector.isOEM()) {
|
||||
return "Модификация VTosters Lite не имеет никакого отношения к VK Group!\nРаспространяется полностью бесплатно!";
|
||||
String Default = getString("startsumm1");
|
||||
|
||||
if (OEMDetector.isOEM()){
|
||||
return Default + getString("startsumm2");
|
||||
}
|
||||
return "Модификация VTosters Lite не имеет никакого отношения к VK Group!\nРаспространяется полностью бесплатно!\n\nПриложение может некорректно работать в связи с тем, что вы, скорее всего, используете оболочку из списка ниже. Все проблемы с отображением и работой приложения связаны только с вашей прошивкой и только с ней. Все багрепорты, присланные из-за проблем на этой прошивке, не рассматриваются разработчиками и не будут исправлены.\n\nНажимая на кнопку \"Продолжить\", вы соглашаетесь с тем, что возможные баги приложения могут произойти из-за специфики вашей прошивки. Рекомендуем использовать прошивки на базе AOSP для получения максимальной стабильности.\n\nПрошивки на которых наблюдаются проблемы с приложениями:\nFlyme, EMUI, MIUI, ColorOS, Samsung Experience или TouchWiz, Magic UI, ZenUI, Funtouch OS";
|
||||
|
||||
return Default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vk.webapp.VKConnect;
|
||||
|
||||
public class VKIDProtection {
|
||||
public static void alert(final Activity activity) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(getString("debug_warning"));
|
||||
builder.setMessage(getString("vkidsumm"));
|
||||
builder.setCancelable(false);
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setPositiveButton(getString("startbtn2"), (dialogInterface, i) -> edit().putBoolean("showAlertVkId", false).apply());
|
||||
// android.content.DialogInterface.OnClickListener
|
||||
builder.setNeutralButton(getString("vkiddisable"), (dialogInterface, i) -> {
|
||||
edit().putBoolean("showAlertVkId", false).apply();
|
||||
Intent a2 = new Navigator(VKConnect.class).a(activity);
|
||||
activity.startActivity(a2);
|
||||
});
|
||||
if (getBoolValue("showAlertVkId", true)) {
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
public class ActivityFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_activity);
|
||||
|
||||
@@ -1,15 +1,39 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vk.newsfeed.NewsfeedSettingsFragment;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
public class FeedFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_feed);
|
||||
prefs();
|
||||
}
|
||||
|
||||
private void prefs() {
|
||||
a("officialnewssett").a(new openofficialsett());
|
||||
}
|
||||
|
||||
public static class openofficialsett implements Preference.c {
|
||||
openofficialsett() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(NewsfeedSettingsFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
public class InstallGMSFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_gms);
|
||||
|
||||
@@ -1,42 +1,41 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplicationWithTimer;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.vk.core.util.ToastUtils;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
/* renamed from: ru.vtosters.lite.utils.lite.ui.activities.interface reason: invalid class name */
|
||||
public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_interface);
|
||||
prefs();
|
||||
}
|
||||
|
||||
/* access modifiers changed from: package-private */
|
||||
/* renamed from: ru.vtosters.lite.utils.lite.ui.activities.interface$a */
|
||||
public class a implements Preference.b {
|
||||
private void prefs() {
|
||||
a("newfeed").a(new restart());
|
||||
a("dateformat").a(new restart());
|
||||
a("stories").a(new restart());
|
||||
a("swipe").a(new restart());
|
||||
a("dockcounter").a(new restart());
|
||||
}
|
||||
|
||||
public boolean restart(Preference preference, Object obj) {
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
}
|
||||
|
||||
public class restart implements Preference.b {
|
||||
restart() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.b
|
||||
public boolean a(Preference preference, Object obj) {
|
||||
return InterfaceFragment.this.restart(preference, obj);
|
||||
}
|
||||
|
||||
a() {
|
||||
}
|
||||
}
|
||||
|
||||
private void prefs() {
|
||||
a("newfeed").a((Preference.b) new a());
|
||||
}
|
||||
|
||||
public /* synthetic */ boolean restart(Preference preference, Object obj) {
|
||||
ToastUtils.a(Helper.getString("restartapp"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,65 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.deleteCache;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplicationWithTimer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_messages);
|
||||
prefs();
|
||||
}
|
||||
|
||||
private void prefs() {
|
||||
a("vkme").a(new MessagesFragment.restart());
|
||||
a("vkme_notifs").a(new MessagesFragment.restart());
|
||||
a("isBGStickersEnabled").a(new MessagesFragment.clearCache());
|
||||
a("roundedmsgs").a(new MessagesFragment.restart());
|
||||
a("systememoji").a(new MessagesFragment.restart());
|
||||
}
|
||||
|
||||
public boolean restart(Preference preference, Object obj) {
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
}
|
||||
|
||||
public class restart implements Preference.b {
|
||||
restart() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.b
|
||||
public boolean a(Preference preference, Object obj) {
|
||||
return MessagesFragment.this.restart(preference, obj);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean clearCache(Preference preference, Object obj) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
prefs2.edit().clear().commit();
|
||||
deleteCache();
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
}
|
||||
|
||||
public class clearCache implements Preference.b {
|
||||
clearCache() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.b
|
||||
public boolean a(Preference preference, Object obj) {
|
||||
return MessagesFragment.this.restart(preference, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vk.webapp.VKConnect;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
@@ -10,5 +17,23 @@ public class MusicFragment extends MaterialPreferenceToolbarFragment {
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_music);
|
||||
prefs();
|
||||
}
|
||||
|
||||
private void prefs() {
|
||||
a("vkid_warn").a(new MusicFragment.openvkid());
|
||||
}
|
||||
|
||||
public static class openvkid implements Preference.c {
|
||||
openvkid() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(VKConnect.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static android.widget.Toast.makeText;
|
||||
import static ru.vtosters.lite.utils.Globals.deleteCache;
|
||||
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;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
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;
|
||||
@@ -19,54 +30,66 @@ import com.vtosters.lite.auth.VKAccountManager;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
import com.vtosters.lite.im.ImEngineProvider;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
|
||||
public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
/* access modifiers changed from: package-private */
|
||||
static class c implements Preference.c {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
copy(Helper.GetContext(), Helper.GetUserToken());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void copy(Context context, String str) {
|
||||
((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", str));
|
||||
Toast.makeText(context, Helper.getString("copybtn"), Toast.LENGTH_SHORT).show();
|
||||
ToastUtils.a(Helper.getString("tokenwarning"));
|
||||
}
|
||||
|
||||
c() {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_other);
|
||||
prefs();
|
||||
}
|
||||
|
||||
/* access modifiers changed from: package-private */
|
||||
public class e implements Preference.c {
|
||||
private void prefs() {
|
||||
a("firebasefix").a(new a());
|
||||
a("applicationstop").a(new b());
|
||||
a("tokencopy").a(new c());
|
||||
a("applicationrestart").a(new d());
|
||||
a("clearcache").a(new e());
|
||||
a("stickfix").a(new f());
|
||||
a("deleteprefs").a(new deleteprefs());
|
||||
|
||||
// a("saveprefs").a((Preference.c) new saveprefs());
|
||||
// a("restoreprefs").a((Preference.c) new restoreprefs());
|
||||
}
|
||||
|
||||
static class c implements Preference.c {
|
||||
c() {
|
||||
}
|
||||
|
||||
public static void copy(Context context, String str) {
|
||||
((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", str));
|
||||
makeText(context, getString("copybtn"), LENGTH_SHORT).show();
|
||||
ToastUtils.a(getString("tokenwarning"));
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
copy(getContext(), getUserToken());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class e implements Preference.c {
|
||||
e() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
prefs2.edit().clear().commit();
|
||||
VKImageLoader.b();
|
||||
ImEngineProvider.a().h();
|
||||
AudioMessageUtils.j();
|
||||
FileUtils.l();
|
||||
ToastUtils.a(Helper.getString("cachecleaned"));
|
||||
deleteCache();
|
||||
ToastUtils.a(getString("cachecleaned"));
|
||||
return true;
|
||||
}
|
||||
|
||||
e() {
|
||||
}
|
||||
}
|
||||
|
||||
/* access modifiers changed from: package-private */
|
||||
public class b implements Preference.c {
|
||||
public static class b implements Preference.c {
|
||||
b() {
|
||||
}
|
||||
|
||||
@@ -77,19 +100,17 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
}
|
||||
|
||||
/* access modifiers changed from: package-private */
|
||||
public class d implements Preference.c {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
Helper.restarting();
|
||||
return true;
|
||||
public static class d implements Preference.c {
|
||||
d() {
|
||||
}
|
||||
|
||||
d() {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
restartApplication();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* access modifiers changed from: package-private */
|
||||
public class a implements Preference.c {
|
||||
a() {
|
||||
}
|
||||
@@ -98,22 +119,64 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
public boolean a(Preference preference) {
|
||||
VKAccount b = VKAccountManager.b();
|
||||
PushSubscriber.a.a(b.b(), b.c());
|
||||
ToastUtils.a(Helper.getString("fcmtokenrem"));
|
||||
ToastUtils.a(getString("fcmtokenrem"));
|
||||
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
|
||||
OtherFragment.this.aB().postDelayed(() -> {
|
||||
PushSubscriber.a.a(true);
|
||||
ToastUtils.a(Helper.getString("fcmtokenget"));
|
||||
ToastUtils.a(Helper.getString("fcmtokenfixed"));
|
||||
ToastUtils.a(getString("fcmtokenget"));
|
||||
ToastUtils.a(getString("fcmtokenfixed"));
|
||||
}, 1000);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void prefs() {
|
||||
a("firebasefix").a((Preference.c) new a());
|
||||
a("applicationstop").a((Preference.c) new b());
|
||||
a("tokencopy").a((Preference.c) new c());
|
||||
a("applicationrestart").a((Preference.c) new d());
|
||||
a("clearcache").a((Preference.c) new e());
|
||||
public static class f implements Preference.c {
|
||||
f() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
prefs2.edit().clear().commit();
|
||||
deleteCache();
|
||||
ToastUtils.a(getString("cachecleaned"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class deleteprefs implements Preference.c {
|
||||
deleteprefs() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
deletePrefs();
|
||||
restartApplication();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class saveprefs implements Preference.c {
|
||||
saveprefs() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
backupSettings();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class restoreprefs implements Preference.c {
|
||||
restoreprefs() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean a(Preference preference) {
|
||||
restoreBackup();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
public class ProxySettingsFragment extends MaterialPreferenceToolbarFragment {
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_proxy);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.componentSwitcher;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplicationWithTimer;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
@@ -7,41 +11,47 @@ import com.vk.core.util.ToastUtils;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import ru.vtosters.lite.utils.Helper;
|
||||
import ru.vtosters.lite.utils.IconHelper;
|
||||
|
||||
public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
/* access modifiers changed from: package-private */
|
||||
public class a implements Preference.b {
|
||||
public /* synthetic */ a() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.b
|
||||
public boolean a(Preference preference, Object obj) {
|
||||
return ThemesFragment.this.apply(preference, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// com.vtosters.lite.fragments.MaterialPreferenceFragment, android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
a(R.xml.preferences_themes);
|
||||
prefs();
|
||||
}
|
||||
|
||||
public /* synthetic */ boolean apply(Preference preference, Object obj) {
|
||||
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;
|
||||
}
|
||||
|
||||
private void prefs() {
|
||||
a("iconvk").a((Preference.b) new a());
|
||||
a("iconvk").a(new a());
|
||||
a("darktheme").a(new restart());
|
||||
a("lighttheme").a(new restart());
|
||||
a("navbar").a(new restart());
|
||||
}
|
||||
|
||||
public static class restart implements Preference.b {
|
||||
@Override // android.support.v7.preference.Preference.b
|
||||
public boolean a(Preference preference, Object obj) {
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class a implements Preference.b {
|
||||
@Override // android.support.v7.preference.Preference.b
|
||||
public boolean a(Preference preference, Object obj) {
|
||||
return ThemesFragment.this.apply(preference, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isIntegrationEnabled;
|
||||
import static ru.vtosters.lite.f0x1d.VTVerifications.vtverif;
|
||||
import static ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager.getAccountPrefsCount;
|
||||
import static ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager.getCurrentAccount;
|
||||
import static ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager.withRegex;
|
||||
import static ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager.workingAccounts;
|
||||
import static ru.vtosters.lite.utils.About.getBuildNumber;
|
||||
import static ru.vtosters.lite.utils.About.getCommitLink;
|
||||
import static ru.vtosters.lite.utils.Globals.drawableFromUrl;
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserId;
|
||||
import static ru.vtosters.lite.utils.Globals.isGmsInstalled;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplicationWithTimer;
|
||||
import static ru.vtosters.lite.utils.Preferences.ads;
|
||||
import static ru.vtosters.lite.utils.Preferences.devmenu;
|
||||
import static ru.vtosters.lite.utils.Preferences.disableSettingsSumms;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasSpecialVerif;
|
||||
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
|
||||
import static ru.vtosters.lite.utils.Preferences.navbar;
|
||||
import static ru.vtosters.lite.utils.Preferences.offline;
|
||||
import static ru.vtosters.lite.utils.Preferences.shortinfo;
|
||||
import static ru.vtosters.lite.utils.Preferences.vkme;
|
||||
import static ru.vtosters.lite.utils.Themes.applyTheme;
|
||||
import static ru.vtosters.lite.utils.Themes.getDarkTheme;
|
||||
import static ru.vtosters.lite.utils.Themes.getImDarkTheme;
|
||||
import static ru.vtosters.lite.utils.Themes.getImLightTheme;
|
||||
import static ru.vtosters.lite.utils.Themes.getLightTheme;
|
||||
import static ru.vtosters.lite.utils.Themes.setTheme;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
import com.vk.about.AboutAppFragment;
|
||||
import com.vk.identity.fragments.IdentityListFragment;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vk.notifications.settings.NotificationsSettingsFragment;
|
||||
import com.vk.webapp.Bugs;
|
||||
import com.vk.webapp.PrivacyFragment;
|
||||
import com.vk.webapp.SSFS;
|
||||
import com.vk.webapp.VKConnect;
|
||||
import com.vtosters.lite.auth.VKAccountManager;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
import com.vtosters.lite.fragments.SettingsAccountFragment;
|
||||
import com.vtosters.lite.fragments.SettingsDebugFragment;
|
||||
import com.vtosters.lite.fragments.SettingsGeneralFragment;
|
||||
import com.vtosters.lite.fragments.k.BlacklistFragment;
|
||||
import com.vtosters.lite.fragments.money.music.control.subscription.MusicSubscriptionControlFragment;
|
||||
|
||||
import ru.vtosters.lite.ui.PreferencesUtil;
|
||||
import ru.vtosters.lite.ui.dialogs.OTADialog;
|
||||
import ru.vtosters.lite.ui.fragments.dockbar.DockBarFragment;
|
||||
import ru.vtosters.lite.ui.fragments.dockbar.DockBarManager;
|
||||
import ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountFragment;
|
||||
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
|
||||
|
||||
public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
@Override
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
|
||||
String keyVKAccount = getCurrentAccount().getString("key_vk_account", "");
|
||||
String avatarUrl = withRegex(keyVKAccount, ".*\"photo\":\\{.*?:\"(.*?)\"\\}.*", "https://vk.com/images/camera_200.png").replace("\\/", "/");
|
||||
String name = withRegex(keyVKAccount, ".*\"name\":\\{.*?:\"(.*?)\"\\}.*", "");
|
||||
String id = "@id" + getUserId();
|
||||
|
||||
String feedsumm = getValAsString("vtlfeedsumm", ads());
|
||||
String docksumm = getDocksumm();
|
||||
String musicsumm = getValAsString("vtlmusicsumm", isIntegrationEnabled());
|
||||
String msgsumm = getValAsString("vtlmsgsumm", vkme());
|
||||
String activitysumm = getValAsString("vtlactivitysumm", !offline());
|
||||
String themessumm = getValAsString("vtlthemessumm", navbar());
|
||||
String tgssumm = getTGSsumm();
|
||||
String interfacesumm = getValAsString("vtlinterfacesumm", shortinfo());
|
||||
String proxysumm = getValAsString("vtlproxysumm", !getPrefsValue("proxy").equals("noproxy"));
|
||||
String othersumm = getValAsString("vtlothersumm", vtverif());
|
||||
String multiaccsumm = getMultiAccsumm();
|
||||
String ssfs = getSSFSsumm();
|
||||
String about = "Commit: " + getBuildNumber();
|
||||
|
||||
int vtosterXml = getIdentifier("empty", "xml");
|
||||
this.a(vtosterXml);
|
||||
|
||||
if (vkme()) {
|
||||
PreferencesUtil.addPreferenceDrawable(this, "", name, id, drawableFromUrl(avatarUrl), preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(MultiAccountFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
PreferencesUtil.addPreference(this, "", getString("accounts"), multiaccsumm, "ic_user_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(MultiAccountFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("vtsettdarktheme"));
|
||||
}
|
||||
|
||||
PreferencesUtil.addMaterialSwitchPreference(this, "isdark", getString("vtsettdarktheme"), "", "ic_palette_24", false, (preference, o) -> {
|
||||
boolean value = (boolean) o;
|
||||
|
||||
if(value){
|
||||
applyTheme(getLightTheme(), getImLightTheme());
|
||||
} else {
|
||||
applyTheme(getDarkTheme(), getImDarkTheme());
|
||||
}
|
||||
|
||||
edit().putBoolean("isdark", value).commit();
|
||||
|
||||
setTheme(this.p());
|
||||
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
PreferencesUtil.addMaterialSwitchPreference(this, "systemtheme", getString("appearance_theme_use_system"), getString("appearance_theme_use_system_summary"), "ic_recent_24", true, (preference, o) -> {
|
||||
boolean value = (boolean) o;
|
||||
|
||||
edit().putBoolean("systemtheme", value).commit();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (!isGmsInstalled()) {
|
||||
PreferencesUtil.addPreference(this, "", getString("installgms"), "", "ic_alert", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(InstallGMSFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
if(devmenu()){
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("sett_debug"));
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("sett_debug"), "", "ic_bug_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(SettingsDebugFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addMaterialSwitchPreference(this, "ssl", getString("debug_developer_force_ssl"), getString("debug_developer_force_ssl_summary"), "ic_globe_24", true, (preference, o) -> {
|
||||
boolean value = (boolean) o;
|
||||
edit().putBoolean("ssl", value).commit();
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("vtsettaccount"));
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vkconnect"), "", "ic_tags_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(VKConnect.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("privacy_settings"), "", "ic_privacy_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(PrivacyFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("sett_account"), "", "ic_user_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(SettingsAccountFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("bugs"), "", "ic_bug_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(Bugs.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtssfs"), ssfs, "ic_link_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(SSFS.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("notification_settings"));
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("sett_general"), "", "ic_settings_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(SettingsGeneralFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("blacklist"), "", "ic_users_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(BlacklistFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("sett_notifications"), "", "ic_notification_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(NotificationsSettingsFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
if (VKAccountManager.b().isRealMusicSubs()) {
|
||||
PreferencesUtil.addPreference(this, "", getString("subscription_music"), "", "ic_music_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(MusicSubscriptionControlFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
if (VKAccountManager.b().ar()) {
|
||||
PreferencesUtil.addPreference(this, "", getString("identity_title"), "", "ic_services_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(IdentityListFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("vtsettmod"));
|
||||
|
||||
if (!vkme()) {
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlfeed"), feedsumm, "ic_newsfeed_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(FeedFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("dockbar_editor"), docksumm, "ic_list_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(DockBarFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
if (isValidSignature())
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlmusic"), musicsumm, "ic_music_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(MusicFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlmessages"), msgsumm, "ic_message_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(MessagesFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlactivity"), activitysumm, "ic_write_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(ActivityFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlthemes"), themessumm, "ic_palette_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(ThemesFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtltgs"), tgssumm, "ic_telegram", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(StickersFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlinterface"), interfacesumm, "ic_interface", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(InterfaceFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlproxy"), proxysumm, "ic_globe_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(ProxySettingsFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtlother"), othersumm, "ic_more_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(OtherFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("vtsettaboutmod"));
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("menu_about"), about, "ic_about_24", preference -> {
|
||||
Context context = getContext();
|
||||
Intent a2 = new Navigator(AboutAppFragment.class).a(context);
|
||||
context.startActivity(a2);
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("opencommit"), "", "ic_link_24", preference -> {
|
||||
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(getCommitLink())));
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("vtfaq"), getString("vtfaqsumm"), "ic_help_24", preference -> {
|
||||
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/s/vtosters_faq")));
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("reportbug"), getString("reportbugsumm"), "ic_bug_24", preference -> {
|
||||
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/issues")));
|
||||
return false;
|
||||
});
|
||||
|
||||
if (isValidSignature()) {
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("updates"));
|
||||
|
||||
PreferencesUtil.addPreference(this, "", getString("checkforupdates"), "", "ic_download_24", preference -> {
|
||||
OTADialog.checkUpdates(p());
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addMaterialSwitchPreference(this, "checkupdates", getString("checkupdates"), "", "ic_recent_24", true, (preference, o) -> {
|
||||
boolean value = (boolean) o;
|
||||
|
||||
edit().putBoolean("checkupdates", value).commit();
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static String getValAsString(String stringid, Boolean value) {
|
||||
if(disableSettingsSumms()) return "";
|
||||
|
||||
if (value){
|
||||
return getString(stringid) + ": " + getString("vtlsettenabled");
|
||||
}
|
||||
|
||||
return getString(stringid) + ": " + getString("vtlsettdisabled");
|
||||
}
|
||||
|
||||
public static String getSSFSsumm() {
|
||||
if(disableSettingsSumms()) return "";
|
||||
|
||||
if(hasSpecialVerif()) return getString("vtlssfssumm") + ": " + getString("vtlsettverifyes");
|
||||
|
||||
return getString("vtlssfssumm") + ": " + getString("vtlsettverifno");
|
||||
}
|
||||
|
||||
public static String getDocksumm() {
|
||||
if(disableSettingsSumms()) return "";
|
||||
|
||||
return getString("vtldocksumm") + ": " + DockBarManager.getInstance().getTabCount();
|
||||
}
|
||||
|
||||
public static String getTGSsumm() {
|
||||
if(disableSettingsSumms()) return "";
|
||||
|
||||
return getString("vtltgssumm") + ": " + TelegramStickersService.getInstance(getContext()).getPacksListReference().size();
|
||||
}
|
||||
|
||||
public static String getMultiAccsumm() {
|
||||
if(disableSettingsSumms() || getAccountPrefsCount() <= 1) return "";
|
||||
|
||||
return getString("vtlmultiaccsumm") + ": " + workingAccounts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int aq() {
|
||||
return getIdentifier("notification_settings", "string");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
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;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@@ -12,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
|
||||
@@ -22,7 +24,7 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
public static final int DISABLED_TAB_TYPE = 2;
|
||||
public static final int GROUP_TITLE_TYPE = 3;
|
||||
|
||||
|
||||
|
||||
private final DockBarManager mDockBarManager = DockBarManager.getInstance();
|
||||
|
||||
@Override
|
||||
@@ -40,51 +42,51 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
}
|
||||
|
||||
private View createTabItem() {
|
||||
LinearLayout container = new LinearLayout(Helper.GetContext());
|
||||
LinearLayout container = new LinearLayout(getContext());
|
||||
container.setTag("tab_item_container");
|
||||
container.setGravity(Gravity.CENTER_VERTICAL);
|
||||
container.setOrientation(LinearLayout.HORIZONTAL);
|
||||
container.setPadding(
|
||||
Helper.convertDpToPixel(12),
|
||||
Helper.convertDpToPixel(12),
|
||||
Helper.convertDpToPixel(12),
|
||||
Helper.convertDpToPixel(12)
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(12)
|
||||
);
|
||||
container.setLayoutParams(new LinearLayout.LayoutParams(-1, Helper.convertDpToPixel(48)));
|
||||
container.setLayoutParams(new LinearLayout.LayoutParams(-1, convertDpToPixel(48)));
|
||||
|
||||
ImageView icon = new ImageView(Helper.GetContext());
|
||||
ImageView icon = new ImageView(getContext());
|
||||
icon.setTag("icon");
|
||||
icon.setImageTintList(ColorStateList.valueOf(Themes.getAccentColor()));
|
||||
icon.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
Helper.convertDpToPixel(24),
|
||||
Helper.convertDpToPixel(24)));
|
||||
convertDpToPixel(24),
|
||||
convertDpToPixel(24)));
|
||||
container.addView(icon);
|
||||
|
||||
TextView title = new TextView(Helper.GetContext());
|
||||
TextView title = new TextView(getContext());
|
||||
title.setTag("title");
|
||||
title.setTextSize(16.0f);
|
||||
title.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
title.setTextColor(Themes.getTextAttr());
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
|
||||
params.weight = 1;
|
||||
params.leftMargin = Helper.convertDpToPixel(16);
|
||||
params.leftMargin = convertDpToPixel(16);
|
||||
container.addView(title, params);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private View createGroupTitle() {
|
||||
LinearLayout layout = new LinearLayout(Helper.GetContext());
|
||||
LinearLayout layout = new LinearLayout(getContext());
|
||||
layout.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
|
||||
|
||||
TextView title = new TextView(Helper.GetContext());
|
||||
TextView title = new TextView(getContext());
|
||||
title.setTag("group_title");
|
||||
title.setTextSize(13.0f);
|
||||
title.setPadding(
|
||||
Helper.convertDpToPixel(16),
|
||||
Helper.convertDpToPixel(13),
|
||||
Helper.convertDpToPixel(16),
|
||||
Helper.convertDpToPixel(13)
|
||||
convertDpToPixel(16),
|
||||
convertDpToPixel(13),
|
||||
convertDpToPixel(16),
|
||||
convertDpToPixel(13)
|
||||
);
|
||||
title.setAllCaps(true);
|
||||
title.setTextColor(Themes.getTextAttr());
|
||||
@@ -155,8 +157,8 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
|
||||
static class DockBarEditViewHolder extends RecyclerView.x {
|
||||
|
||||
private ImageView mIcon;
|
||||
private TextView mTitle;
|
||||
private final ImageView mIcon;
|
||||
private final TextView mTitle;
|
||||
|
||||
public DockBarEditViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@@ -173,7 +175,7 @@ public class DockBarAdapter extends RecyclerView.a
|
||||
|
||||
static class GroupViewHolder extends RecyclerView.x {
|
||||
|
||||
private TextView mGroupTitle;
|
||||
private final TextView mGroupTitle;
|
||||
|
||||
public GroupViewHolder(View view) {
|
||||
super(view);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.convertDpToPixel;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Globals.restartApplication;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@@ -12,7 +16,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 {
|
||||
|
||||
@@ -30,18 +33,18 @@ public class DockBarFragment extends ToolbarFragment {
|
||||
|
||||
LinearLayout buttonsContainer = new LinearLayout(n());
|
||||
buttonsContainer.setPadding(
|
||||
Helper.convertDpToPixel(13),
|
||||
Helper.convertDpToPixel(10),
|
||||
Helper.convertDpToPixel(13),
|
||||
Helper.convertDpToPixel(10)
|
||||
convertDpToPixel(13),
|
||||
convertDpToPixel(10),
|
||||
convertDpToPixel(13),
|
||||
convertDpToPixel(10)
|
||||
);
|
||||
container.addView(buttonsContainer, new LinearLayout.LayoutParams(-1, -2));
|
||||
|
||||
|
||||
Button save = new Button(n());
|
||||
save.setText("Сохранить");
|
||||
save.setText(getString("dockbar_save"));
|
||||
save.setOnClickListener(v -> {
|
||||
DockBarManager.getInstance().save();
|
||||
Helper.restarting();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
LinearLayout.LayoutParams saveParams = new LinearLayout.LayoutParams(0, -2);
|
||||
@@ -49,13 +52,13 @@ public class DockBarFragment extends ToolbarFragment {
|
||||
buttonsContainer.addView(save, saveParams);
|
||||
|
||||
View divider = new View(n());
|
||||
buttonsContainer.addView(divider, new LinearLayout.LayoutParams(Helper.convertDpToPixel(10), 0));
|
||||
buttonsContainer.addView(divider, new LinearLayout.LayoutParams(convertDpToPixel(10), 0));
|
||||
|
||||
Button reset = new Button(n());
|
||||
reset.setText("Сбросить");
|
||||
reset.setText(getString("dockbar_reset"));
|
||||
reset.setOnClickListener(v -> {
|
||||
DockBarManager.getInstance().delete();
|
||||
Helper.restarting();
|
||||
restartApplication();
|
||||
});
|
||||
|
||||
LinearLayout.LayoutParams resetParams = new LinearLayout.LayoutParams(0, -2);
|
||||
@@ -81,6 +84,6 @@ public class DockBarFragment extends ToolbarFragment {
|
||||
|
||||
super.a(arg0, arg1);
|
||||
|
||||
a("Редактор докбара");
|
||||
a(getString("dockbar_editor"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getResources;
|
||||
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;
|
||||
@@ -24,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();
|
||||
|
||||
@@ -61,12 +63,18 @@ public class DockBarInjector {
|
||||
|
||||
for (DockBarTab tab : sManager.getSelectedTabs()) {
|
||||
MenuItem add = menu.add(0, tab.id, 0, tab.titleID);
|
||||
Drawable drawable = Helper.GetContext().getResources().getDrawable(tab.iconID);
|
||||
ColorStateList colorStateList = Helper.GetContext().getResources().getColorStateList(com.vtosters.lite.R.color.bottom_navigation_item);
|
||||
// if (isAndroidMonet()) {
|
||||
// colorStateList = ColorStateList.valueOf(Themes.getAccentColor());
|
||||
// }
|
||||
add.setIcon((Drawable) new RecoloredDrawable(drawable, colorStateList));
|
||||
Drawable drawable = 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,19 +1,26 @@
|
||||
package ru.vtosters.lite.ui.fragments.dockbar;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getContext;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.newfeed;
|
||||
import static ru.vtosters.lite.utils.Preferences.oldicons;
|
||||
import static ru.vtosters.lite.utils.Preferences.useNewSettings;
|
||||
import static ru.vtosters.lite.utils.Preferences.vkme;
|
||||
import static ru.vtosters.lite.utils.Preferences.vkme_notifs;
|
||||
|
||||
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;
|
||||
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;
|
||||
@@ -39,14 +46,20 @@ 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 = 8;
|
||||
public static final int MAX_SELECTED_TABS_LIMIT = 9;
|
||||
|
||||
private static DockBarManager sInstance = new DockBarManager();
|
||||
private final List<DockBarTab> mSelectedTabs = new ArrayList<>();
|
||||
private final List<DockBarTab> mDisabledTabs = new ArrayList<>();
|
||||
private final List<String> mGroups = Arrays.asList(
|
||||
getString("dockbar_selected_items"),
|
||||
getString("dockbar_unselected_items")
|
||||
);
|
||||
public DockBarManager() {
|
||||
load();
|
||||
}
|
||||
|
||||
public static DockBarManager getInstance() {
|
||||
if (sInstance == null)
|
||||
@@ -54,26 +67,33 @@ public class DockBarManager {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private List<DockBarTab> mSelectedTabs = new ArrayList<>();
|
||||
private List<DockBarTab> mDisabledTabs = new ArrayList<>();
|
||||
private List<String> mGroups = Arrays.asList(
|
||||
"Выбранные элементы докбара",
|
||||
"Невыбранные элементы"
|
||||
);
|
||||
|
||||
public DockBarManager() {
|
||||
load();
|
||||
private static String readFully(InputStream is) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[2048];
|
||||
int len;
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
bos.write(buffer, 0, len);
|
||||
}
|
||||
return bos.toString();
|
||||
}
|
||||
|
||||
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));
|
||||
if(vkme()) {
|
||||
mSelectedTabs.add(new DockBarTab("tab_settings", R.drawable.ic_settings_24, R.string.menu_settings, R.id.menu_settings, useNewSettings()));
|
||||
if(vkme_notifs()) mSelectedTabs.add(new DockBarTab("tab_feedback", oldicons() ? 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_messages", oldicons() ? 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_profile", R.drawable.libverify_ic_account_circle_white, R.string.profile, R.id.profile, ProfileFragment.class));
|
||||
return;
|
||||
}
|
||||
|
||||
mSelectedTabs.add(new DockBarTab("tab_news", oldicons() ? 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", oldicons() ? 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", oldicons() ? 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", oldicons() ? 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", oldicons() ? 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));
|
||||
@@ -82,12 +102,13 @@ public class DockBarManager {
|
||||
mDisabledTabs.add(new DockBarTab("tab_videos", R.drawable.ic_video_24, R.string.videos, R.id.menu_videos, VideosFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_lives", R.drawable.ic_live_filter_24dp, R.string.sett_live, R.id.menu_lives, LivesPostListFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_games", R.drawable.ic_games_24, R.string.games, R.id.menu_games, GamesFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_liked", R.drawable.ic_menu_like_24, R.string.sett_likes, R.id.menu_feed_likes, FeedLikesFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_fave", R.drawable.ic_favorite_24, R.string.exo_track_selection_title_video_res_0x7f11031e, R.id.menu_fave, FaveTabFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_documents", R.drawable.ic_document_24, R.string.docs, R.id.menu_documents, DocumentsViewFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_payments", R.drawable.ic_money_transfer_24, R.string.money_transfer_money_transfers, R.id.menu_payments, MoneyTransfersFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_vk_apps", R.drawable.ic_services_24, R.string.menu_apps, R.id.menu_vk_apps, AppsFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_profile", R.drawable.libverify_ic_account_circle_white, R.string.profile, R.id.profile, ProfileFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_settings", R.drawable.ic_settings_24, R.string.menu_settings, R.id.menu_settings, SettingsListFragment.class));
|
||||
mDisabledTabs.add(new DockBarTab("tab_settings", R.drawable.ic_settings_24, R.string.menu_settings, R.id.menu_settings, useNewSettings()));
|
||||
mDisabledTabs.add(new DockBarTab("tab_brtd", R.drawable.ic_menu_birthdays, R.string.birthdays_title, R.id.menu_birthdays, BirthdaysFragment.class));
|
||||
|
||||
} else {
|
||||
@@ -104,17 +125,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);
|
||||
@@ -130,17 +151,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);
|
||||
@@ -152,24 +173,14 @@ public class DockBarManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static String readFully(InputStream is) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[2048];
|
||||
int len;
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
bos.write(buffer, 0, len);
|
||||
}
|
||||
return bos.toString();
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -224,7 +235,11 @@ public class DockBarManager {
|
||||
int target = adapter.getIndexByViewType(toPosition, adapter.getItemType(toPosition));
|
||||
if (fromPosition < toPosition) {
|
||||
|
||||
if (mSelectedTabs.size() <= MIN_SELECTED_TABS_LIMIT || mSelectedTabs.get(curr).tag.equals("tab_menu")) return;
|
||||
if(!vkme()){
|
||||
if (mSelectedTabs.size() <= MIN_SELECTED_TABS_LIMIT || mSelectedTabs.get(curr).tag.equals("tab_menu")){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DockBarTab tab = mSelectedTabs.get(curr);
|
||||
mSelectedTabs.remove(tab);
|
||||
@@ -237,7 +252,7 @@ public class DockBarManager {
|
||||
for (int i = 0; i < target; i++) {
|
||||
Collections.swap(mDisabledTabs, i, i + 1);
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
|
||||
if (mSelectedTabs.size() >= MAX_SELECTED_TABS_LIMIT) return;
|
||||
|
||||
@@ -294,6 +309,10 @@ public class DockBarManager {
|
||||
return mSelectedTabs.get(getIndexByViewType(pos, 1));
|
||||
}
|
||||
|
||||
public int getTabCount() {
|
||||
return mSelectedTabs.size();
|
||||
}
|
||||
|
||||
public DockBarTab getDisabledTab(int pos) {
|
||||
return mDisabledTabs.get(getIndexByViewType(pos, 2));
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import android.support.v7.widget.a.ItemTouchHelper;
|
||||
|
||||
public class ItemTouchHelperCallback extends ItemTouchHelper.a {
|
||||
|
||||
private DockBarAdapter mAdapter;
|
||||
private final DockBarAdapter mAdapter;
|
||||
|
||||
public ItemTouchHelperCallback(DockBarAdapter mAdapter) {
|
||||
this.mAdapter = mAdapter;
|
||||
|
||||
+39
-25
@@ -1,5 +1,16 @@
|
||||
package ru.vtosters.lite.ui.fragments.multiaccount;
|
||||
|
||||
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.getString;
|
||||
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;
|
||||
@@ -23,9 +34,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();
|
||||
@@ -34,17 +42,17 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
public MultiAccountViewHolder b(ViewGroup parent, int viewType) {
|
||||
RelativeLayout layout = new RelativeLayout(parent.getContext());
|
||||
layout.setPadding(
|
||||
Helper.convertDpToPixel(12),
|
||||
Helper.convertDpToPixel(6),
|
||||
Helper.convertDpToPixel(6),
|
||||
Helper.convertDpToPixel(6)
|
||||
convertDpToPixel(12),
|
||||
convertDpToPixel(6),
|
||||
convertDpToPixel(6),
|
||||
convertDpToPixel(6)
|
||||
);
|
||||
|
||||
VKCircleImageView avatar = new VKCircleImageView(parent.getContext());
|
||||
avatar.setId(1);
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
Helper.convertDpToPixel(48),
|
||||
Helper.convertDpToPixel(48)
|
||||
convertDpToPixel(48),
|
||||
convertDpToPixel(48)
|
||||
);
|
||||
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
|
||||
params.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
@@ -53,7 +61,7 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
TextView nickname = new TextView(parent.getContext());
|
||||
nickname.setId(2);
|
||||
nickname.setPaddingRelative(
|
||||
Helper.convertDpToPixel(12),
|
||||
convertDpToPixel(12),
|
||||
0,
|
||||
0,
|
||||
0
|
||||
@@ -61,7 +69,7 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
nickname.setEllipsize(TextUtils.TruncateAt.END);
|
||||
nickname.setSingleLine(true);
|
||||
nickname.setTextSize(15.0f);
|
||||
nickname.setTextColor(Themes.getTextAttr());
|
||||
nickname.setTextColor(getTextAttr());
|
||||
nickname.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
|
||||
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(-2, -2);
|
||||
params1.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
@@ -71,11 +79,11 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
ImageButton action = new ImageButton(parent.getContext());
|
||||
action.setId(3);
|
||||
action.setBackgroundResource(com.vtosters.lite.R.drawable.rounded_list_selector);
|
||||
Drawable drawable = Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.ic_list_remove));
|
||||
Drawable drawable = recolorDrawable(getResources().getDrawable(R.drawable.ic_list_remove));
|
||||
action.setImageDrawable(drawable);
|
||||
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(
|
||||
Helper.convertDpToPixel(48),
|
||||
Helper.convertDpToPixel(48)
|
||||
convertDpToPixel(48),
|
||||
convertDpToPixel(48)
|
||||
);
|
||||
params2.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
@@ -83,10 +91,10 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
|
||||
return new MultiAccountViewHolder(layout);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void a(MultiAccountViewHolder holder, int pos) {
|
||||
holder.bind(pos == 0 ? null : mAccounts.get(pos-1), pos);
|
||||
holder.bind(pos == 0 ? null : mAccounts.get(pos - 1), pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,14 +113,14 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
|
||||
super(view);
|
||||
|
||||
mContainer = (RelativeLayout) view;
|
||||
mAvatar = (VKCircleImageView) view.findViewById(1);
|
||||
mNickname = (TextView) view.findViewById(2);
|
||||
mAction = (ImageButton) view.findViewById(3);
|
||||
mAvatar = view.findViewById(1);
|
||||
mNickname = view.findViewById(2);
|
||||
mAction = view.findViewById(3);
|
||||
}
|
||||
|
||||
public void bind(MultiAccountItem item, int pos) {
|
||||
if (pos == 0) {
|
||||
mNickname.setText("Добавить новый аккаунт");
|
||||
mNickname.setText(getString("add_another_account"));
|
||||
mContainer.setOnClickListener(v -> {
|
||||
MultiAccountManager.addAccount();
|
||||
|
||||
@@ -123,9 +131,11 @@ 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();
|
||||
Helper.restarting();
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
restartApplication();
|
||||
});
|
||||
Drawable drawable = Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.ic_list_add));
|
||||
Drawable drawable = recolorDrawable(getResources().getDrawable(R.drawable.ic_list_add));
|
||||
mAction.setImageDrawable(drawable);
|
||||
mAction.setClickable(false);
|
||||
} else {
|
||||
@@ -139,11 +149,13 @@ 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();
|
||||
Helper.restarting();
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
|
||||
prefs.edit().clear().commit();
|
||||
restartApplication();
|
||||
|
||||
});
|
||||
|
||||
if (Helper.isNetworkConnected())
|
||||
if (isNetworkConnected())
|
||||
mAvatar.a(item.imageUrl);
|
||||
else
|
||||
mAvatar.a(R.drawable.vkim_ic_placeholder_user_square_64dp);
|
||||
@@ -160,7 +172,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();
|
||||
Helper.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"));
|
||||
}
|
||||
}
|
||||
|
||||
+49
-20
@@ -1,6 +1,7 @@
|
||||
package ru.vtosters.lite.ui.fragments.multiaccount;
|
||||
|
||||
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;
|
||||
@@ -11,33 +12,41 @@ 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 = Helper.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 = Helper.GetPreferences().getInt("account", 0);
|
||||
return Helper.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(Helper.GetContext().getFilesDir().getParent(), "shared_prefs")
|
||||
public static int getAccountPrefsCount() {
|
||||
File[] prefs = new File(getContext().getFilesDir().getParent(), "shared_prefs")
|
||||
.listFiles((dir, name) -> {
|
||||
return name.matches("pref_account_manager\\d+\\.xml");
|
||||
});
|
||||
return prefs != null ? prefs.length : 0;
|
||||
}
|
||||
|
||||
private static String withRegex(String base, String regex, String def) {
|
||||
public static String withRegex(String base, String regex, String def) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(base);
|
||||
if (matcher.find()) {
|
||||
@@ -48,8 +57,8 @@ public class MultiAccountManager {
|
||||
|
||||
public static List<MultiAccountItem> buildList() {
|
||||
List<MultiAccountItem> list = new ArrayList<>();
|
||||
for (int i = 0; i <= getAccountPrefsCount(); i++) {
|
||||
SharedPreferences prefs = Helper.GetContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
|
||||
for (int i = 0; i <= workingAccounts(); i++) {
|
||||
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\":\\{.*?:\"(.*?)\"\\}.*", "");
|
||||
@@ -63,25 +72,45 @@ public class MultiAccountManager {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static int workingAccounts() {
|
||||
int count = 0;
|
||||
for (int i = 0; i <= getAccountPrefsCount(); i++) {
|
||||
SharedPreferences prefs = getContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
|
||||
String keyVKAccount = prefs.getString("key_vk_account", "");
|
||||
if (!keyVKAccount.isEmpty()) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static boolean switchAccount(int i) {
|
||||
int account = Helper.GetPreferences().getInt("account", 0);
|
||||
int account = getPreferences().getInt("account", 0);
|
||||
if (account == i) return false;
|
||||
|
||||
Helper.GetPreferences().edit().putInt("account", i).commit();
|
||||
getPreferences().edit().putInt("account", i).commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void addAccount() {
|
||||
Helper.GetPreferences().edit().putInt("account", getAccountPrefsCount()).commit();
|
||||
getPreferences().edit().putInt("account", workingAccounts()).commit();
|
||||
}
|
||||
|
||||
public static void deleteAccount(int i) {
|
||||
int account = Helper.GetPreferences().getInt("account", 0);
|
||||
SharedPreferences prefs = Helper.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(Helper.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 && workingAccounts() > 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,5 +1,18 @@
|
||||
package ru.vtosters.lite.ui.fragments.tgstickers;
|
||||
|
||||
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;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -24,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;
|
||||
@@ -43,32 +55,21 @@ 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;
|
||||
private TelegramStickersGrabber grabber;
|
||||
private TelegramStickersService stickersService;
|
||||
private FloatingActionButton fab;
|
||||
|
||||
private static final String TAG = "StickersFragment";
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private RecyclerView.Adapter adapter;
|
||||
|
||||
private boolean movePending = false;
|
||||
public int from;
|
||||
public int to;
|
||||
|
||||
private int editPadding;
|
||||
private RecyclerView recycler;
|
||||
|
||||
private final BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -90,11 +91,12 @@ public class StickersFragment extends ToolbarFragment {
|
||||
}
|
||||
}
|
||||
};
|
||||
private int editPadding;
|
||||
private RecyclerView recycler;
|
||||
|
||||
private void initGrabber() {
|
||||
int method = TGPref.getTGConnectMethod();
|
||||
switch (method) {
|
||||
case TYPE_TOASTER_SERVER:
|
||||
case TYPE_DIRECT:
|
||||
TelegramStickersGrabber.USE_PROXY = false;
|
||||
grabber.resetProxy();
|
||||
@@ -118,7 +120,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
|
||||
private void openMenu(String toast) {
|
||||
if (toast != null) {
|
||||
Toast.makeText(super.n(), toast, Toast.LENGTH_SHORT).show();
|
||||
makeText(super.n(), toast, LENGTH_SHORT).show();
|
||||
}
|
||||
var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).a(super.n());
|
||||
super.n().startActivity(intent);
|
||||
@@ -130,7 +132,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
super.a(menu, menuInflater);
|
||||
MenuItem add = menu.add(0, 0, 0, "");
|
||||
add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
add.setIcon(Helper.getResources().getDrawable(com.vtosters.lite.R.drawable.ic_settings_24));
|
||||
add.setIcon(getResources().getDrawable(com.vtosters.lite.R.drawable.ic_settings_24));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,21 +157,21 @@ public class StickersFragment extends ToolbarFragment {
|
||||
linearLayout.addView(editText);
|
||||
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
|
||||
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0);
|
||||
margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
new AlertDialog.Builder(super.n())
|
||||
.setTitle(Helper.getString("stickersapi5"))
|
||||
.setMessage(Helper.getString("stickersapi6"))
|
||||
.setTitle(getString("stickersapi5"))
|
||||
.setMessage(getString("stickersapi6"))
|
||||
.setView(linearLayout)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
TGPref.setTGBotKey(editText.getText().toString());
|
||||
if (r != null) r.run();
|
||||
}).setNegativeButton(android.R.string.cancel, null).setNeutralButton(Helper.getString("stickersapi7"), (dialog, which) -> new AlertDialog.Builder(super.n())
|
||||
.setTitle(Helper.getString("stickersapi8"))
|
||||
.setMessage(Helper.getString("stickersapi9") +
|
||||
Helper.getString("stickersapi10")).setPositiveButton(android.R.string.ok, null)
|
||||
.create().show()).create().show();
|
||||
}).setNegativeButton(android.R.string.cancel, null).setNeutralButton(getString("stickersapi7"), (dialog, which) -> new AlertDialog.Builder(super.n())
|
||||
.setTitle(getString("stickersapi8"))
|
||||
.setMessage(getString("stickersapi9") +
|
||||
getString("stickersapi10")).setPositiveButton(android.R.string.ok, null)
|
||||
.create().show()).create().show();
|
||||
}
|
||||
|
||||
private void checkApiKey(final Runnable r) {
|
||||
@@ -179,7 +181,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
|
||||
final ProgressDialog progressDialog = new ProgressDialog(context);
|
||||
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
|
||||
progressDialog.setMessage(Helper.getString("stickersapi1"));
|
||||
progressDialog.setMessage(getString("stickersapi1"));
|
||||
progressDialog.show();
|
||||
|
||||
grabber.checkKey(new TelegramStickersGrabber.KeyCheckListener() {
|
||||
@@ -187,7 +189,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
public void onKeyChecked(boolean ok) {
|
||||
progressDialog.dismiss();
|
||||
if (!ok) {
|
||||
Toast.makeText(context, Helper.getString("stickersapi2"), Toast.LENGTH_SHORT).show();
|
||||
makeText(context, getString("stickersapi2"), LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
stickersService.setBotKey(TGPref.getTGBotKey());
|
||||
@@ -199,9 +201,9 @@ public class StickersFragment extends ToolbarFragment {
|
||||
public void onNetError() {
|
||||
progressDialog.dismiss();
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage(Helper.getString("stickersapi3"))
|
||||
.setMessage(getString("stickersapi3"))
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(Helper.getString("stickersapi4"), (arg0, arg1) -> checkApiKey(r)).create().show();
|
||||
.setPositiveButton(getString("stickersapi4"), (arg0, arg1) -> checkApiKey(r)).create().show();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -211,9 +213,9 @@ 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(Helper.GetContext());
|
||||
stickersService = TelegramStickersService.getInstance(getContext());
|
||||
|
||||
editPadding = Helper.convertDpToPixel(24f);
|
||||
editPadding = convertDpToPixel(24f);
|
||||
|
||||
FrameLayout v = new FrameLayout(container.getContext());
|
||||
|
||||
@@ -222,11 +224,11 @@ public class StickersFragment extends ToolbarFragment {
|
||||
|
||||
fab = new FloatingActionButton(container.getContext());
|
||||
fab.setImageResource(R.drawable.ic_add_24);
|
||||
fab.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor()));
|
||||
fab.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
|
||||
fab.setOnClickListener(v2 -> fabClick());
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
||||
params.setMargins(0, 0, 0, Helper.convertDpToPixel(12f));
|
||||
params.setMargins(0, 0, 0, convertDpToPixel(12f));
|
||||
fab.setLayoutParams(params);
|
||||
|
||||
v.addView(recycler);
|
||||
@@ -245,36 +247,35 @@ public class StickersFragment extends ToolbarFragment {
|
||||
switch (method) {
|
||||
case TYPE_SOCKS:
|
||||
if (TGPref.getTGProxyIP() == null) {
|
||||
openMenu(Helper.getString("stickersproxy1"));
|
||||
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(Helper.GetContext()));
|
||||
editText.setHintTextColor(PreferencesUtil.getSTextColor(getContext()));
|
||||
|
||||
// Костыль для китката
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
|
||||
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
} else {
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext())));
|
||||
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext())));
|
||||
}
|
||||
linearLayout.addView(editText);
|
||||
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
|
||||
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0);
|
||||
margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0);
|
||||
editText.setLayoutParams(margin);
|
||||
|
||||
new AlertDialog.Builder(super.n()).setTitle(Helper.getString("stickershelp1"))
|
||||
.setMessage(Helper.getString("stickershelp2"))
|
||||
new AlertDialog.Builder(super.n()).setTitle(getString("stickershelp1"))
|
||||
.setMessage(getString("stickershelp2"))
|
||||
.setView(linearLayout)
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
String pack = editText.getText().toString();
|
||||
pack = parsePack(pack);
|
||||
stickersService.requestPackDownload(pack, new File(Helper.GetContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
|
||||
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));
|
||||
@@ -284,7 +285,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
};
|
||||
|
||||
if (method == -1) {
|
||||
openMenu(Helper.getString("stickersconnection"));
|
||||
openMenu(getString("stickersconnection"));
|
||||
} else {
|
||||
r.run();
|
||||
}
|
||||
@@ -293,7 +294,7 @@ public class StickersFragment extends ToolbarFragment {
|
||||
@Override
|
||||
public void b(@Nullable Bundle savedInstanceState) {
|
||||
super.b(savedInstanceState);
|
||||
Helper.GetContext().registerReceiver(receiver, new IntentFilter(ACTION_RELOAD));
|
||||
getContext().registerReceiver(receiver, new IntentFilter(ACTION_RELOAD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,13 +303,13 @@ public class StickersFragment extends ToolbarFragment {
|
||||
|
||||
super.a(arg0, arg1);
|
||||
|
||||
a(Helper.getString("vtltgs"));
|
||||
a(getString("vtltgs"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void A_() {
|
||||
super.A_();
|
||||
Helper.GetContext().unregisterReceiver(receiver);
|
||||
getContext().unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
private String parsePack(String pack) {
|
||||
@@ -321,31 +322,12 @@ public class StickersFragment extends ToolbarFragment {
|
||||
}
|
||||
|
||||
public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.StickerPackViewHolder> {
|
||||
private String TAG = "StickerPackAdapter";
|
||||
|
||||
public class StickerPackViewHolder extends RecyclerView.ViewHolder {
|
||||
private SwitchCompat switchCompat;
|
||||
private ImageView stickerImage, updateButton, deleteButton;
|
||||
private TextView name, count;
|
||||
private LinearLayout layout;
|
||||
|
||||
StickerPackViewHolder(@NonNull View view) {
|
||||
super(view);
|
||||
|
||||
switchCompat = (SwitchCompat) view.findViewById(R.id.choose_btn);
|
||||
stickerImage = (ImageView) view.findViewById(R.id.photo);
|
||||
updateButton = (ImageView) view.findViewById(R.id.button_update);
|
||||
deleteButton = (ImageView) view.findViewById(R.id.action_delete);
|
||||
name = (TextView) view.findViewById(R.id.vkim_cancel);
|
||||
count = (TextView) view.findViewById(R.id.vkim_cancel_label_text);
|
||||
layout = (LinearLayout) view.findViewById(R.id.linearLayout5);
|
||||
}
|
||||
}
|
||||
private final String TAG = "StickerPackAdapter";
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public StickerPackViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
var view = LayoutInflater.from(parent.getContext()).inflate(Helper.getIdentifier("tgs_entry", "layout"), parent, false);
|
||||
var view = LayoutInflater.from(parent.getContext()).inflate(getIdentifier("tgs_entry", "layout"), parent, false);
|
||||
return new StickerPackViewHolder(view);
|
||||
}
|
||||
|
||||
@@ -365,19 +347,19 @@ public class StickersFragment extends ToolbarFragment {
|
||||
if (f.exists()) {
|
||||
holder.stickerImage.setImageURI(Uri.parse("file://" + f.getAbsolutePath()));
|
||||
} else {
|
||||
holder.stickerImage.setImageDrawable(Helper.getResources().getDrawable(R.drawable.icon_vk_104));
|
||||
holder.stickerImage.setImageDrawable(getResources().getDrawable(R.drawable.icon_vk_104));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
holder.updateButton.setImageDrawable(Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.ic_camera_switch_48)));
|
||||
holder.updateButton.setImageDrawable(recolorDrawable(getResources().getDrawable(R.drawable.ic_camera_switch_48)));
|
||||
holder.updateButton.setOnClickListener(listener -> {
|
||||
stickersService.setBotKey(TGPref.getTGBotKey());
|
||||
stickersService.requestPackDownload(pack.id, new File(Helper.GetContext().getFilesDir(), new File("VT-Stickers", pack.id).getAbsolutePath()));
|
||||
stickersService.requestPackDownload(pack.id, new File(getContext().getFilesDir(), new File("VT-Stickers", pack.id).getAbsolutePath()));
|
||||
});
|
||||
|
||||
holder.deleteButton.setImageDrawable(Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.vkim_ic_msg_delete)));
|
||||
holder.deleteButton.setImageDrawable(recolorDrawable(getResources().getDrawable(R.drawable.vkim_ic_msg_delete)));
|
||||
holder.deleteButton.setOnClickListener(listener -> {
|
||||
stickersService.deletePack(pack);
|
||||
notifyItemRemoved(position);
|
||||
@@ -386,13 +368,13 @@ public class StickersFragment extends ToolbarFragment {
|
||||
holder.name.setText(pack.title);
|
||||
holder.switchCompat.setChecked(pack.enabled);
|
||||
holder.switchCompat.setOnCheckedChangeListener((buttonView, isChecked) -> stickersService.setPackEnabled(pack, isChecked, false));
|
||||
holder.count.setText(pack.stickersCount + " " + Helper.getString("stickerscount"));
|
||||
holder.count.setText(pack.stickersCount + " " + getString("stickerscount"));
|
||||
|
||||
holder.layout.setBackgroundColor(Prefs.getNavbarColor());
|
||||
holder.layout.setBackgroundColor(getTabbarBackground());
|
||||
|
||||
// Color костыль
|
||||
int color = Themes.getTextAttr();
|
||||
int secondary = Themes.getSTextAttr();
|
||||
int color = getTextAttr();
|
||||
int secondary = getSTextAttr();
|
||||
|
||||
holder.name.setTextColor(color);
|
||||
holder.count.setTextColor(secondary);
|
||||
@@ -402,6 +384,28 @@ public class StickersFragment extends ToolbarFragment {
|
||||
public int getItemCount() {
|
||||
return stickersService.getPacksListReference().size();
|
||||
}
|
||||
|
||||
public class StickerPackViewHolder extends RecyclerView.ViewHolder {
|
||||
private final SwitchCompat switchCompat;
|
||||
private final ImageView stickerImage;
|
||||
private final ImageView updateButton;
|
||||
private final ImageView deleteButton;
|
||||
private final TextView name;
|
||||
private final TextView count;
|
||||
private final LinearLayout layout;
|
||||
|
||||
StickerPackViewHolder(@NonNull View view) {
|
||||
super(view);
|
||||
|
||||
switchCompat = view.findViewById(R.id.choose_btn);
|
||||
stickerImage = view.findViewById(R.id.photo);
|
||||
updateButton = view.findViewById(R.id.button_update);
|
||||
deleteButton = view.findViewById(R.id.action_delete);
|
||||
name = view.findViewById(R.id.vkim_cancel);
|
||||
count = view.findViewById(R.id.vkim_cancel_label_text);
|
||||
layout = view.findViewById(R.id.linearLayout5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-16
@@ -1,5 +1,8 @@
|
||||
package ru.vtosters.lite.ui.fragments.tgstickers;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
|
||||
@@ -9,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 {
|
||||
|
||||
@@ -17,19 +19,19 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
|
||||
public void b(Bundle bundle) {
|
||||
super.b(bundle);
|
||||
|
||||
int vtosterXml = Helper.GetContext().getResources().getIdentifier("empty", "xml", Helper.GetContext().getPackageName());
|
||||
int vtosterXml = getIdentifier("empty", "xml");
|
||||
this.a(vtosterXml);
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, Helper.getString("sprefsstickers"));
|
||||
PreferencesUtil.addPreference(this, "", Helper.getString("sprefsdelkey"), "", null, preference -> {
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("sprefsstickers"));
|
||||
PreferencesUtil.addPreference(this, "", getString("sprefsdelkey"), "", null, preference -> {
|
||||
TGPref.setTGBotKey(null);
|
||||
ToastUtils.a(Helper.getString("sprefsdelkey2"));
|
||||
ToastUtils.a(getString("sprefsdelkey2"));
|
||||
return false;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, Helper.getString("sprefsnetwork"));
|
||||
PreferencesUtil.addListPreference(this, "VTGS:CM", "0", Helper.getString("sprefsctype"), new CharSequence[]{
|
||||
Helper.getString("ctypedirect"), Helper.getString("ctypesocks")
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("sprefsnetwork"));
|
||||
PreferencesUtil.addListPreference(this, "VTGS:CM", "0", getString("sprefsctype"), new CharSequence[]{
|
||||
getString("ctypedirect"), getString("ctypesocks")
|
||||
}, new String[]{
|
||||
"0", "2"
|
||||
});
|
||||
@@ -44,22 +46,22 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
|
||||
return true;
|
||||
});
|
||||
|
||||
PreferencesUtil.addPreferenceCategory(this, Helper.getString("ssocks"));
|
||||
PreferencesUtil.addPreferenceCategory(this, getString("ssocks"));
|
||||
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_host", Helper.getString("ssockshost"), (preference, o) -> {
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_host", getString("ssockshost"), (preference, o) -> {
|
||||
TGPref.setTGProxyIP((String) o);
|
||||
return true;
|
||||
});
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_port", Helper.getString("ssocksport"), (preference, o) -> {
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_port", getString("ssocksport"), (preference, o) -> {
|
||||
try {
|
||||
TGPref.setTGProxyPort(Integer.parseInt((String) o));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
ToastUtils.a(Helper.getString("ssockswport"));
|
||||
ToastUtils.a(getString("ssockswport"));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
PreferencesUtil.addMaterialSwitchPreference(this, "tg_proxy_auth", Helper.getString("ssocksauth"), "", null, false, (preference, o) -> {
|
||||
PreferencesUtil.addMaterialSwitchPreference(this, "tg_proxy_auth", getString("ssocksauth"), "", null, false, (preference, o) -> {
|
||||
boolean value = (boolean) o;
|
||||
|
||||
a("tg_proxy_login").a(value); // findPreference("tg_proxy_login").setEnabled(value);
|
||||
@@ -68,11 +70,11 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
|
||||
TGPref.setTGProxyPassEnabled(value);
|
||||
return true;
|
||||
});
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_login", Helper.getString("ssockslogin"), (preference, o) -> {
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_login", getString("ssockslogin"), (preference, o) -> {
|
||||
TGPref.setTGProxyUserPass((String) o, TGPref.getTGProxyPass());
|
||||
return true;
|
||||
});
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_pass", Helper.getString("ssockspass"), (preference, o) -> {
|
||||
PreferencesUtil.addEditTextPreference(this, "tg_proxy_pass", getString("ssockspass"), (preference, o) -> {
|
||||
TGPref.setTGProxyUserPass(TGPref.getTGProxyUser(), (String) o);
|
||||
return true;
|
||||
});
|
||||
@@ -83,7 +85,7 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
|
||||
|
||||
@Override
|
||||
public int aq() {
|
||||
return Helper.GetContext().getResources().getIdentifier("vtltgs", "string", Helper.GetContext().getPackageName());
|
||||
return getIdentifier("vtltgs", "string");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package ru.vtosters.lite.ui.vkui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
|
||||
import com.vk.core.dialogs.bottomsheet.ModalBottomSheet;
|
||||
|
||||
public class ModalBottomSheetProxy {
|
||||
public final ModalBottomSheet.a builder;
|
||||
|
||||
public ModalBottomSheetProxy(Activity activity) {
|
||||
builder = new ModalBottomSheet.a(activity);
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
builder.b(title);
|
||||
}
|
||||
|
||||
|
||||
public void setClickableMessage(String text) {
|
||||
builder.a(text, kostil -> {
|
||||
});
|
||||
}
|
||||
|
||||
public void setClickableMessage(String text, Runnable runnable) {
|
||||
builder.a(text, listener -> runnable.run());
|
||||
}
|
||||
|
||||
public void setPositiveButton(String text, Runnable runnable) {
|
||||
builder.b(text, kostil -> runnable.run());
|
||||
}
|
||||
|
||||
public void setSubtitle(String text) {
|
||||
builder.b((CharSequence) text);
|
||||
}
|
||||
|
||||
public void setView(View view) {
|
||||
builder.a(view);
|
||||
}
|
||||
|
||||
public ModalBottomSheet show() {
|
||||
return builder.c(null);
|
||||
}
|
||||
|
||||
public ModalBottomSheet show(boolean isCancellable) {
|
||||
var sheet = builder.c(null);
|
||||
sheet.b(isCancellable);
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package ru.vtosters.lite.ui.vkui;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.vk.core.dialogs.bottomsheet.ModalBottomSheet;
|
||||
|
||||
import ru.vtosters.lite.utils.Globals;
|
||||
import ru.vtosters.lite.utils.Themes;
|
||||
|
||||
public class ModalBottomSheetWrapper {
|
||||
public final ModalBottomSheet.a builder;
|
||||
|
||||
public ModalBottomSheetWrapper(Activity activity) {
|
||||
builder = new ModalBottomSheet.a(activity);
|
||||
}
|
||||
|
||||
public ModalBottomSheetWrapper setTitle(String title) {
|
||||
builder.b(title);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModalBottomSheetWrapper setUpdateInfoView(String version, String changelog) {
|
||||
var context = Globals.getContext();
|
||||
var container = new LinearLayout(context);
|
||||
var title = new TextView(context);
|
||||
var changelogView = new TextView(context);
|
||||
|
||||
container.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
title.setText(getString("newversion") + " " + version);
|
||||
title.setTypeface(title.getTypeface(), Typeface.BOLD);
|
||||
title.setSingleLine(true);
|
||||
title.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
|
||||
title.setTextColor(Themes.getTextAttr());
|
||||
title.setTextSize(24.0f);
|
||||
container.addView(title, new LinearLayout.LayoutParams(-1, -2));
|
||||
|
||||
changelogView.setPadding(0, Globals.convertDpToPixel(8), 0, 0);
|
||||
changelogView.setText(getString("changelog") + ": \n" + changelog);
|
||||
changelogView.setTextColor(Themes.getTextAttr());
|
||||
container.addView(changelogView, new LinearLayout.LayoutParams(-1, -2));
|
||||
|
||||
builder.a(container);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// try to call a true function and you will understand my pain
|
||||
public ModalBottomSheetWrapper setMessage(
|
||||
String text
|
||||
) {
|
||||
builder.a(text, listener -> {});
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModalBottomSheetWrapper setClickableMessage(
|
||||
String text,
|
||||
Runnable callback
|
||||
) {
|
||||
builder.a(text, listener -> callback.run());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModalBottomSheetWrapper setPositiveButton(
|
||||
String text,
|
||||
Runnable callback
|
||||
) {
|
||||
builder.b(text, kostil -> callback.run());
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModalBottomSheetWrapper setSubtitle(String text) {
|
||||
builder.b((CharSequence) text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModalBottomSheetWrapper setView(View view) {
|
||||
builder.a(view);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ModalBottomSheet show() {
|
||||
return builder.c(null);
|
||||
}
|
||||
|
||||
public ModalBottomSheet show(boolean isCancellable) {
|
||||
var sheet = builder.c(null);
|
||||
sheet.b(isCancellable);
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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.Globals.getIdentifier;
|
||||
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, getIdentifier("opencommit", "string")));
|
||||
list.add(new Items(8, getIdentifier("tgchannel", "string")));
|
||||
list.add(new Items(9, getIdentifier("tgchat", "string")));
|
||||
list.add(new Items(16, getIdentifier("vtfaq", "string")));
|
||||
list.add(new Items(19, getIdentifier("vtsite", "string")));
|
||||
list.add(new Items(20, getIdentifier("donate", "string")));
|
||||
list.add(new Items(17, getIdentifier("vkgroup", "string")));
|
||||
list.add(new Items(18, getIdentifier("sett_debug", "string")));
|
||||
return;
|
||||
}
|
||||
|
||||
list.add(new Items(0, getIdentifier("about_app_feedback", "string")));
|
||||
list.add(new Items(1, getIdentifier("about_app_estimate", "string")));
|
||||
list.add(new Items(2, getIdentifier("about_app_privacy", "string")));
|
||||
list.add(new Items(5, getIdentifier("about_app_cookie", "string")));
|
||||
list.add(new Items(3, getIdentifier("about_app_terms_to_use", "string")));
|
||||
list.add(new Items(4, getIdentifier("about_app_license", "string")));
|
||||
list.add(new Items(6, getIdentifier("about_app_data_protect", "string")));
|
||||
list.add(new Items(8, getIdentifier("sett_debug", "string")));
|
||||
}
|
||||
public static String getBuildNumber() {
|
||||
return getBuild(getContext(), "version.properties");
|
||||
}
|
||||
|
||||
public static String getCommitLink() {
|
||||
return "https://git.maki.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", true);
|
||||
}
|
||||
|
||||
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_value") + " ";
|
||||
}
|
||||
|
||||
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,5 +1,9 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
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;
|
||||
import android.content.Intent;
|
||||
@@ -37,7 +41,7 @@ public class ExternalLinkHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (!Prefs.isEnableExternalOpening()) return false;
|
||||
if (!isEnableExternalOpening()) return false;
|
||||
|
||||
if (checkVkVideo(file)) {
|
||||
if (qualities.size() == 1) {
|
||||
@@ -55,7 +59,7 @@ public class ExternalLinkHandler {
|
||||
}
|
||||
|
||||
private static boolean checkYoutubeLink(VideoFile file) {
|
||||
if (!Helper.isEmpty(file.n)) {
|
||||
if (!isEmpty(file.n)) {
|
||||
for (String filter : filters) {
|
||||
if (file.n.contains(filter))
|
||||
return true;
|
||||
@@ -74,25 +78,25 @@ public class ExternalLinkHandler {
|
||||
* this.k = var3.optString("mp4_2160");
|
||||
*/
|
||||
public static boolean checkVkVideo(VideoFile videoFile) {
|
||||
if (!Helper.isEmpty(videoFile.e)) {
|
||||
if (!isEmpty(videoFile.e)) {
|
||||
qualities.put("240", videoFile.e);
|
||||
}
|
||||
if (!Helper.isEmpty(videoFile.f)) {
|
||||
if (!isEmpty(videoFile.f)) {
|
||||
qualities.put("360", videoFile.f);
|
||||
}
|
||||
if (!Helper.isEmpty(videoFile.g)) {
|
||||
if (!isEmpty(videoFile.g)) {
|
||||
qualities.put("480", videoFile.g);
|
||||
}
|
||||
if (!Helper.isEmpty(videoFile.h)) {
|
||||
if (!isEmpty(videoFile.h)) {
|
||||
qualities.put("720", videoFile.h);
|
||||
}
|
||||
if (!Helper.isEmpty(videoFile.i)) {
|
||||
if (!isEmpty(videoFile.i)) {
|
||||
qualities.put("1080", videoFile.i);
|
||||
}
|
||||
if (!Helper.isEmpty(videoFile.j)) {
|
||||
if (!isEmpty(videoFile.j)) {
|
||||
qualities.put("1440", videoFile.j);
|
||||
}
|
||||
if (!Helper.isEmpty(videoFile.k)) {
|
||||
if (!isEmpty(videoFile.k)) {
|
||||
qualities.put("2160", videoFile.k);
|
||||
}
|
||||
|
||||
@@ -107,7 +111,7 @@ public class ExternalLinkHandler {
|
||||
Intent intent = new Intent();
|
||||
|
||||
String packageName = getMXPlayerPackageName();
|
||||
if (!Helper.isEmpty(packageName)) {
|
||||
if (!isEmpty(packageName)) {
|
||||
intent.setPackage(packageName);
|
||||
intent.setDataAndType(uri, "application/mp4");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -118,7 +122,7 @@ public class ExternalLinkHandler {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
Helper.GetContext().startActivity(intent);
|
||||
getContext().startActivity(intent);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -127,7 +131,7 @@ public class ExternalLinkHandler {
|
||||
}
|
||||
|
||||
private static String getMXPlayerPackageName() {
|
||||
for (ApplicationInfo info : Helper.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,71 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
|
||||
public class FragAnimationKit {
|
||||
// Q
|
||||
private static final int actOpenEnter = getIdentifier("q_enter", "anim");
|
||||
private static final int actCloseExit = getIdentifier("q_pop_exit", "anim");
|
||||
// Slide
|
||||
private static final int SactOpenEnter = getIdentifier("legacy_enter", "anim");
|
||||
private static final int SactCloseExit = getIdentifier("legacy_pop_exit", "anim");
|
||||
// Fade
|
||||
private static final int FadeOpenEnter = getIdentifier("vkme_enter_slide_up", "anim");
|
||||
private static final int FadeCloseExit = getIdentifier("vkme_enter_slide_down", "anim");
|
||||
// System
|
||||
private static final Resources resources = Resources.getSystem();
|
||||
private static final int SSactOpenEnter = resources.getIdentifier("activity_open_enter", "anim","android");
|
||||
private static final int SSactCloseExit = resources.getIdentifier("activity_close_exit", "anim", "android");
|
||||
// System [task]
|
||||
private static final int SSTactOpenEnter = resources.getIdentifier("task_open_enter", "anim","android");
|
||||
private static final int SSTactCloseExit = resources.getIdentifier("task_close_exit", "anim", "android");
|
||||
|
||||
public static void animateOpen(FragmentTransaction transaction) {
|
||||
setAnimations(transaction);
|
||||
}
|
||||
|
||||
public static void animateClose(FragmentTransaction transaction) {
|
||||
setAnimations(transaction);
|
||||
}
|
||||
|
||||
public static void setAnimations(FragmentTransaction transaction) {
|
||||
if (transaction != null && !getPrefsValue("anim_rtrn_type").equals("noanim")) {
|
||||
switch (getPrefsValue("anim_rtrn_type")) {
|
||||
case "q":
|
||||
transaction.a(
|
||||
actOpenEnter,
|
||||
actCloseExit
|
||||
);
|
||||
break;
|
||||
case "fade":
|
||||
transaction.a(
|
||||
FadeOpenEnter,
|
||||
FadeCloseExit
|
||||
);
|
||||
break;
|
||||
case "slide":
|
||||
transaction.a(
|
||||
SactOpenEnter,
|
||||
SactCloseExit
|
||||
);
|
||||
break;
|
||||
case "system":
|
||||
transaction.a(
|
||||
SSactOpenEnter,
|
||||
SSactCloseExit
|
||||
);
|
||||
break;
|
||||
case "system_task":
|
||||
transaction.a(
|
||||
SSTactOpenEnter,
|
||||
SSTactCloseExit
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static androidx.core.content.ContextCompat.getDrawable;
|
||||
import static ru.vtosters.lite.utils.Preferences.checkupdates;
|
||||
import static ru.vtosters.lite.utils.Preferences.getLocale;
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
import static ru.vtosters.lite.utils.Themes.isDarkTheme;
|
||||
|
||||
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.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.StrictMode;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import com.vk.navigation.Navigator;
|
||||
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.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import ru.vtosters.lite.ui.dialogs.DisableBattery;
|
||||
import ru.vtosters.lite.ui.dialogs.InstallGMS;
|
||||
import ru.vtosters.lite.ui.dialogs.OTADialog;
|
||||
import ru.vtosters.lite.ui.dialogs.Start;
|
||||
|
||||
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 MainActivityInit(Activity activity){
|
||||
if(checkupdates())
|
||||
OTADialog.checkUpdates(activity);
|
||||
Start.alert(activity);
|
||||
InstallGMS.alert(activity);
|
||||
DisableBattery.alert(activity);
|
||||
// VKIDProtection.alert(activity);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Drawable drawableFromUrl(String url) {
|
||||
try {
|
||||
URL aryURI = new URL(url);
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
|
||||
URLConnection conn = aryURI.openConnection();
|
||||
InputStream is = conn.getInputStream();
|
||||
Bitmap bmp = BitmapFactory.decodeStream(is);
|
||||
|
||||
return new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(getBitmapClippedCircle(bmp), convertDpToPixel(48), convertDpToPixel(48), true));
|
||||
} catch (Exception e) {
|
||||
return getDrawable(getContext(), com.vtosters.lite.R.drawable.libverify_ic_account_circle_white);
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getBitmapClippedCircle(Bitmap bitmap) {
|
||||
final int width = bitmap.getWidth();
|
||||
final int height = bitmap.getHeight();
|
||||
final Bitmap outputBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
|
||||
final Path path = new Path();
|
||||
path.addCircle(
|
||||
(float)(width / 2)
|
||||
, (float)(height / 2)
|
||||
, (float) Math.min(width, (height / 2))
|
||||
, Path.Direction.CCW);
|
||||
|
||||
final Canvas canvas = new Canvas(outputBitmap);
|
||||
canvas.clipPath(path);
|
||||
canvas.drawBitmap(bitmap, 0, 0, null);
|
||||
return outputBitmap;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
public static void restartApplicationWithTimer() {
|
||||
Handler handler = new Handler();
|
||||
handler.postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
restartApplication();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
public static void restartApplicationInto(Class Class) {
|
||||
Context ctx = getContext();
|
||||
PackageManager pm = ctx.getPackageManager();
|
||||
|
||||
Intent intent = new Navigator(Class).a(ctx);
|
||||
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;
|
||||
} // Getting the global context through reflection to use context on application initialization
|
||||
|
||||
public static void deleteCache() {
|
||||
try {
|
||||
File dir = getContext().getCacheDir();
|
||||
deleteDir(dir);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean deleteDir(File dir) {
|
||||
if (dir != null && dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
for (int i=0; i < Objects.requireNonNull(children).length; i++) {
|
||||
boolean success = deleteDir(new File(dir, children[i]));
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return dir.delete();
|
||||
} else if(dir!= null && dir.isFile()) {
|
||||
return dir.delete();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
try {
|
||||
return getResources().getIdentifier(name, type, getContext().getPackageName());
|
||||
} catch (Exception e) {
|
||||
Log.d("VTLite", "Not found " + name + "as type " + type);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
} // Get res id
|
||||
|
||||
public static String getString(String resourcename) {
|
||||
return getContext().getString(getIdentifier(resourcename, "string"));
|
||||
} // Get string via getIdentifier
|
||||
|
||||
public static String getStringDate(@StringRes int i, Object... objArr) {
|
||||
return getContext().getString(i, objArr);
|
||||
}
|
||||
|
||||
public static String getPackageName() {
|
||||
return getContext().getPackageName();
|
||||
}
|
||||
|
||||
public static int convertDpToPixel(float f) {
|
||||
return (int) (f * ((float) 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(getIdentifier("audio_message_play_error", "string")), 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());
|
||||
|
||||
edit().putBoolean("isdark", isDarkTheme()).commit();
|
||||
|
||||
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,146 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
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 Proxy.GetConnector(str);
|
||||
}
|
||||
|
||||
public static void reloadMSG() {
|
||||
ImEngineProvider.a().h();
|
||||
}
|
||||
|
||||
public static int getUserID(UserProfile userProfile) {
|
||||
return userProfile.n;
|
||||
}
|
||||
|
||||
public static String getUserFirstName(UserProfile userProfile) {
|
||||
return userProfile.p;
|
||||
}
|
||||
|
||||
public static String getUserLastName(UserProfile userProfile) {
|
||||
return userProfile.o;
|
||||
}
|
||||
|
||||
public static int getUserID(ExtendedUserProfile extendedUserProfile) {
|
||||
return getUserID(fromEup(extendedUserProfile));
|
||||
}
|
||||
|
||||
public static UserProfile fromEup(ExtendedUserProfile extendedUserProfile) {
|
||||
return extendedUserProfile.a;
|
||||
}
|
||||
|
||||
public static void restarting(){
|
||||
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 Helper.GetContext().getString(Integer.parseInt(String.valueOf(Helper.GetContext().getResources().getIdentifier(str, "string", Helper.GetContext().getPackageName()))));
|
||||
}
|
||||
|
||||
public static String getPackageName() {
|
||||
return GetContext().getPackageName();
|
||||
}
|
||||
|
||||
public static int convertDpToPixel(float f) {
|
||||
return (int) (f * (((float) GetContext().getResources().getDisplayMetrics().densityDpi) / 160.0f));
|
||||
}
|
||||
|
||||
public static String GetString(@StringRes int res, Object... args) {
|
||||
return GetContext().getString(res, args);
|
||||
}
|
||||
|
||||
public static SharedPreferences GetPrefs() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(GetContext());
|
||||
}
|
||||
|
||||
public static SharedPreferences GetPreferences() {
|
||||
return PreferenceManager.getDefaultSharedPreferences(GetContext());
|
||||
}
|
||||
|
||||
public static void SendToast(String text) {
|
||||
ToastUtils.a(text);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String str) {
|
||||
return str == null || str.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isNetworkConnected() {
|
||||
ConnectivityManager cm = (ConnectivityManager) GetContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return activeNetwork != null ? activeNetwork.isConnectedOrConnecting() :false;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
public class IconHelper {
|
||||
public static void switchToVK() {
|
||||
var packageManager = Helper.GetContext().getPackageManager();
|
||||
var packageName = Helper.getPackageName();
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
public static void switchToDefault() {
|
||||
var packageManager = Helper.GetContext().getPackageManager();
|
||||
var packageName = Helper.getPackageName();
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
|
||||
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.donaterecomm;
|
||||
import static ru.vtosters.lite.utils.Preferences.hasVerification;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class JsonInjectors {
|
||||
public static JSONObject profileButton() throws JSONException {
|
||||
String pic = "https:\\/\\/sun1-18.userapi.com\\/NLd_rNpGuSaBnPV6O-j5mqCGZk8BK8drAMd2LQ\\/5R-DEF37PFs.png";
|
||||
String title = "Помоги проекту донатом и получи бонус!";
|
||||
String link = "https:\\/\\/vk.com\\/vtosters_official";
|
||||
String text_color = "2D81E0";
|
||||
|
||||
JSONObject jsonObj = new JSONObject("{\"action\":{\"target\":\"internal\",\"type\":\"open_url\",\"url\":\"" + link + "\"},\"title\":\"" + title + "\",\"icons\":[{\"url\":\"" + pic + "\",\"width\":20,\"height\":20},{\"url\":\"" + pic + "\",\"width\":40,\"height\":40},{\"url\":\"" + pic + "\",\"width\":60,\"height\":60},{\"url\":\"" + pic + "\",\"width\":80,\"height\":80}],\"text_color\":\"" + text_color + "\"}");
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
public static JSONObject discoverBanner() throws JSONException {
|
||||
String smallimg = "https:\\/\\/sun1-25.userapi.com\\/3D4YtNHjgwoyxav3FksnYRINp_FhWULuDKYdcA\\/zfCUgKMS0O4.png";
|
||||
String background = "https:\\/\\/images.wsj.net\\/im-501403";
|
||||
String title = "Задонать";
|
||||
String desc = "Помоги проекту донатом и получи приятные бонусы на аккаунт";
|
||||
String text_color = "ffffff";
|
||||
|
||||
JSONObject jsonObj = new JSONObject("{\"title\":\"" + title + "\",\"description\":\"" + desc + "\",\"text_color\":\"#" + text_color + "\",\"image\":[{\"url\":\"" + smallimg + "\",\"width\":72,\"height\":72},{\"url\":\"" + smallimg + "\",\"width\":108,\"height\":108},{\"url\":\"" + smallimg + "\",\"width\":144,\"height\":144},{\"url\":\"" + smallimg + "\",\"width\":216,\"height\":216},{\"url\":\"" + smallimg + "\",\"width\":288,\"height\":288}],\"background\":[{\"url\":\"" + background + "\",\"width\":344,\"height\":215},{\"url\":\"" + background + "\",\"width\":516,\"height\":323},{\"url\":\"" + background + "\",\"width\":680,\"height\":426},{\"url\":\"" + background + "\",\"width\":1032,\"height\":645},{\"url\":\"" + background + "\",\"width\":1376,\"height\":860}]}");
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
public static JSONObject discoverBannerButton() throws JSONException {
|
||||
String link = "vk.com\\/vtosters_official";
|
||||
|
||||
JSONObject jsonObj = new JSONObject("{\"type\":\"open_url\",\"url\":\"" + link + "\",\"target\":\"internal\"}");
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
public static String haveDonateBanner() {
|
||||
Random random = new Random();
|
||||
int randomshower = random.nextInt(8);
|
||||
|
||||
return hasVerification() || donaterecomm() || randomshower != 1 ? "null" : "info";
|
||||
}
|
||||
|
||||
public static String haveDonateButton() {
|
||||
Random random = new Random();
|
||||
int randomshower = random.nextInt(10);
|
||||
|
||||
return hasVerification() || donaterecomm() || randomshower != 1 ? "null" : "buttons";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
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 static ru.vtosters.lite.utils.Preferences.useNewSettings;
|
||||
import static ru.vtosters.lite.utils.Preferences.vkme;
|
||||
|
||||
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.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() ? "null" : "user_rec";
|
||||
}
|
||||
|
||||
public static String getFriendRecomm() {
|
||||
return friendsrecomm() ? "null" : "friends_recommendations";
|
||||
}
|
||||
|
||||
public static String authorsads() {
|
||||
return authorsrecomm() ? "null" : "authors_rec";
|
||||
}
|
||||
|
||||
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) {
|
||||
if (vkme()) {
|
||||
return MAX_VALUE;
|
||||
}
|
||||
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() {
|
||||
if (vkme()) {
|
||||
return DialogsFragment.class;
|
||||
}
|
||||
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 useNewSettings();
|
||||
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,126 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class OTAHelper {
|
||||
|
||||
private static final String LATEST_RELEASE_URL = "https://api.github.com/repositories/473685743/releases/latest";
|
||||
private static final String LATEST_RELEASE_COMMIT_URL = "https://api.github.com/repositories/473685743/git/ref/tags/%s";
|
||||
|
||||
private OTAListener mListener;
|
||||
|
||||
private final OkHttpClient mClient = new OkHttpClient();
|
||||
|
||||
private JSONObject mReleaseJson;
|
||||
private JSONObject mCommitJson;
|
||||
|
||||
public OTAHelper(OTAListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
Request release = new Request.Builder()
|
||||
.url(LATEST_RELEASE_URL)
|
||||
.build();
|
||||
mClient.newCall(release).a(new Callback() {
|
||||
@Override
|
||||
public void a(Call call, IOException e) {
|
||||
Log.d("OTAHelper", "Error while getting latest release info: " + e);
|
||||
mListener.onUpdateCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Call call, Response response) throws IOException {
|
||||
try {
|
||||
setData(response);
|
||||
} catch (JSONException | NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setData(Response response) throws IOException, JSONException {
|
||||
mReleaseJson = new JSONObject(response.body().string());
|
||||
|
||||
String tag = mReleaseJson.getString("tag_name");
|
||||
Request commit = new Request.Builder()
|
||||
.url(String.format(LATEST_RELEASE_COMMIT_URL, tag))
|
||||
.build();
|
||||
mClient.newCall(commit).a(new Callback() {
|
||||
@Override
|
||||
public void a(Call call, IOException e) {
|
||||
Log.d("OTAHelper", "Error while getting latest commit info: " + e);
|
||||
mListener.onUpdateCanceled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Call call, Response response) throws IOException {
|
||||
try {
|
||||
mCommitJson = new JSONObject(response.body().string());
|
||||
if (isNewVersion())
|
||||
mListener.onUpdateApplied();
|
||||
else mListener.onUpdateCanceled();
|
||||
} catch (NullPointerException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
mListener.onUpdateCanceled();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isNewVersion() {
|
||||
try {
|
||||
String commitSHA = mCommitJson.getJSONObject("object").getString("sha");
|
||||
return !commitSHA.startsWith(About.getBuildNumber());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getNewVersionName() {
|
||||
try {
|
||||
return mReleaseJson.getString("name");
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getUpdateDescription() {
|
||||
try {
|
||||
return mReleaseJson.getString("body");
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDownloadUrl() {
|
||||
try {
|
||||
return mReleaseJson.getJSONArray("assets")
|
||||
.getJSONObject(0)
|
||||
.getString("browser_download_url");
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface OTAListener {
|
||||
|
||||
void onUpdateApplied();
|
||||
|
||||
void onUpdateCanceled();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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,467 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static android.os.Build.VERSION;
|
||||
import static ru.vtosters.lite.f0x1d.VTVerifications.hasPrometheus;
|
||||
import static ru.vtosters.lite.f0x1d.VTVerifications.isVerified;
|
||||
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.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Globals.getString;
|
||||
import static ru.vtosters.lite.utils.Globals.getStringDate;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserId;
|
||||
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.SignatureChecker.validateAppSignature;
|
||||
import static ru.vtosters.lite.utils.Themes.systemThemeChanger;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.vk.core.util.Screen;
|
||||
import com.vk.im.engine.models.users.UserSex;
|
||||
import com.vtosters.lite.data.Users;
|
||||
import com.vtosters.lite.fragments.SettingsListFragment;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import ru.vtosters.lite.ui.fragments.VTSettings;
|
||||
|
||||
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);
|
||||
if(dev()){
|
||||
LoadLibrary("vkopustest");
|
||||
}
|
||||
systemThemeChanger();
|
||||
} // VK Init
|
||||
|
||||
public static void forceOffline() {
|
||||
if (setoffline() && !offline()) {
|
||||
Users.b();
|
||||
}
|
||||
setupFilters();
|
||||
}
|
||||
|
||||
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 SharedPreferences getPrefsFromFile(String filename) {
|
||||
return getContext().getSharedPreferences(filename, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static boolean opusmodule() {
|
||||
return getBoolValue("opusmodule", true);
|
||||
}
|
||||
|
||||
public static boolean systemtheme() {
|
||||
return getBoolValue("systemtheme", true) && VERSION.SDK_INT >= 28;
|
||||
}
|
||||
|
||||
public static boolean authorsrecomm() {
|
||||
return getBoolValue("authorsrecomm", false);
|
||||
}
|
||||
|
||||
public static boolean captions() {
|
||||
return getBoolValue("captions", false);
|
||||
}
|
||||
|
||||
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", false);
|
||||
}
|
||||
|
||||
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 oldicons() {
|
||||
return getBoolValue("oldicons", false);
|
||||
}
|
||||
|
||||
public static boolean vkme() {
|
||||
return getBoolValue("vkme", 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 musicFixNew() {
|
||||
return getBoolValue("musicFixNew", true);
|
||||
}
|
||||
|
||||
public static Class useNewSettings() {
|
||||
boolean bool = getBoolValue("useNewSettings", true);
|
||||
return bool? VTSettings.class : SettingsListFragment.class;
|
||||
}
|
||||
|
||||
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", false);
|
||||
}
|
||||
|
||||
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 boolean gcmfix() {
|
||||
return getBoolValue("gcmfix", true) && isValidSignature();
|
||||
}
|
||||
|
||||
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", false);
|
||||
}
|
||||
|
||||
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", true);
|
||||
}
|
||||
|
||||
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 VERSION.SDK_INT >= 29 ? "date_modified DESC" : "datetaken DESC";
|
||||
} // Fix photo picker for sdk 29+
|
||||
|
||||
public static String MediacontentFix2() {
|
||||
return VERSION.SDK_INT >= 29 ? "date_modified" : "datetaken";
|
||||
} // Fix photo picker for sdk 29+
|
||||
|
||||
public static String MediacontentFix3() {
|
||||
return 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 boolean vkme_notifs() {
|
||||
return getBoolValue("vkme_notifs", false);
|
||||
}
|
||||
|
||||
public static boolean roundedmsgs() {
|
||||
return getBoolValue("roundedmsgs", false);
|
||||
}
|
||||
|
||||
public static boolean checkupdates() {
|
||||
return getBoolValue("checkupdates", true) && isValidSignature();
|
||||
}
|
||||
|
||||
public static boolean disableanimstickers() {
|
||||
return getBoolValue("disableanimstickers", true);
|
||||
}
|
||||
|
||||
public static boolean isValidSignature() {
|
||||
try {
|
||||
return validateAppSignature();
|
||||
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean disableSettingsSumms() {
|
||||
return getBoolValue("disableSettingsSumms", false);
|
||||
}
|
||||
|
||||
public static boolean donaterecomm() {
|
||||
return getBoolValue("donaterecomm", false);
|
||||
}
|
||||
|
||||
public static String VKVersion() {
|
||||
return VKVER;
|
||||
}
|
||||
|
||||
public static int VKVersionBuild() {
|
||||
return VKBUILD;
|
||||
}
|
||||
|
||||
public static long VKVersionBuildLong() {
|
||||
return VKVersionBuild();
|
||||
}
|
||||
|
||||
public static boolean hasVerification() {
|
||||
return isVerified(getUserId());
|
||||
}
|
||||
|
||||
public static boolean hasSpecialVerif() {
|
||||
return hasPrometheus(getUserId());
|
||||
}
|
||||
|
||||
public static String getLocale() {
|
||||
String string = getPrefsValue("lang_value");
|
||||
|
||||
if (string.equals("system")) {
|
||||
return Locale.getDefault().getLanguage();
|
||||
}
|
||||
|
||||
return string.isEmpty() ? Locale.getDefault().getLanguage() : string;
|
||||
}
|
||||
|
||||
public static boolean fulltime() {
|
||||
return getPrefsValue("dateformat").equals("noyear") || getPrefsValue("dateformat").equals("full") || getPrefsValue("dateformat").equals("noseconds");
|
||||
}
|
||||
|
||||
public static String getDateFormat() {
|
||||
switch (getPrefsValue("dateformat")) {
|
||||
case "noyear":
|
||||
return getString("fulltime2");
|
||||
case "full":
|
||||
return getString("fulltime");
|
||||
default:
|
||||
return getString("fulltime3");
|
||||
}
|
||||
}
|
||||
|
||||
public static String nullOnline() {
|
||||
return getString("onlineNull");
|
||||
}
|
||||
|
||||
public static boolean isOnlineNull(int status) {
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
public static SimpleDateFormat setDateFormat() {
|
||||
return new SimpleDateFormat(getDateFormat());
|
||||
}
|
||||
|
||||
public static String getFormattedDate(UserSex type, long time){
|
||||
SimpleDateFormat date = new SimpleDateFormat(getDateFormat(), Locale.getDefault());
|
||||
|
||||
if(!fulltime()) return null;
|
||||
|
||||
try {
|
||||
return getStringDate(type == UserSex.FEMALE ? getIdentifier("last_seen_profile_f", "string") : getIdentifier("last_seen_profile_m", "string"), date.format(new Date(time)));
|
||||
} catch (Throwable th) {
|
||||
Log.d("VTLite", "Format data error, type " + type + " , time " + time);
|
||||
th.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,877 +0,0 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
|
||||
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 {
|
||||
public static String VERSIONNAME = "2.0 Beta";
|
||||
private static List<String> mFilters;
|
||||
private static List<Activity> activities = new ArrayList<>();
|
||||
|
||||
public static boolean BooleanFalse(String key) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
|
||||
return prefs.getBoolean(key, false);
|
||||
}
|
||||
|
||||
public static boolean BooleanTrue(String key) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
|
||||
return prefs.getBoolean(key, true);
|
||||
}
|
||||
|
||||
public static void ClearCache() {
|
||||
}
|
||||
|
||||
public static String GetBackgroundStickers() {
|
||||
if (isBGStickersEnabled()) {
|
||||
return "images_with_background";
|
||||
}
|
||||
return "images";
|
||||
}
|
||||
|
||||
public static boolean isBGStickersEnabled() {
|
||||
return BooleanTrue("isBGStickersEnabled");
|
||||
}
|
||||
|
||||
public static String GetCopyright() {
|
||||
return copyright_post() ? "null" : "copyright";
|
||||
}
|
||||
|
||||
public static String GetFriendRecomm() {
|
||||
return friendsrecomm() ? "friends_recommendations" : "null";
|
||||
}
|
||||
|
||||
public static String GetStories() {
|
||||
return stories() ? "stories" : "null";
|
||||
}
|
||||
|
||||
public static boolean ads() {
|
||||
return BooleanFalse("__dbg_no_ads");
|
||||
}
|
||||
|
||||
public static boolean adsgroup() {
|
||||
return BooleanFalse("adsgroup");
|
||||
}
|
||||
|
||||
public static boolean 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(Helper.GetContext(), "version.properties");
|
||||
}
|
||||
|
||||
public static String getCommitLink() {
|
||||
return "https://github.com/vtosters/lite/commit/" + Prefs.getBuild(Helper.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 Helper.GetPreferences().getString("ota_branches", "Stable");
|
||||
}
|
||||
|
||||
public static String getDarkVKUI() {
|
||||
return !VKThemeHelper.d() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getMeToken() {
|
||||
return Helper.GetPreferences().getString("me_token", "");
|
||||
}
|
||||
|
||||
public static int getNavbarColor() {
|
||||
return VKThemeHelper.a((int) R.attr.tabbar_background);
|
||||
}
|
||||
|
||||
public static String getSSFSLink() {
|
||||
return SSFSDomain() + "?token=" + ru.vtosters.lite.utils.Helper.GetUserToken() + "&vt_dark=" + getDarkVKUI() + "&secret=" + ru.vtosters.lite.utils.Helper.GetUserSecret() + "&proxy=" + getUserProxy() + "&lang=" + getLocale() + "&vt=1&vtl=1&vksans=" + isVKSansEnabled() + "&vt_version=" + getBuildNumber() + "&vt_debug=" + isDEVModEnabled();
|
||||
}
|
||||
|
||||
public static String getString(String key, String defValue) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
|
||||
return prefs.getString(key, defValue);
|
||||
}
|
||||
|
||||
public static String getUserProxy() {
|
||||
return proxy() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static boolean hasMusicSubscription() {
|
||||
return BooleanTrue("hasMusicSubscription");
|
||||
}
|
||||
|
||||
public static boolean isEnableExternalOpening() {
|
||||
return BooleanFalse("isEnableExternalOpening");
|
||||
}
|
||||
|
||||
public static boolean iconvk() {
|
||||
return BooleanFalse("iconvk");
|
||||
}
|
||||
|
||||
public static boolean iconvkru() {
|
||||
return BooleanFalse("iconvkru");
|
||||
}
|
||||
|
||||
public static String isDEVModEnabled() {
|
||||
return dev() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static boolean isOtaEnabled() {
|
||||
return BooleanTrue("ota_enabled");
|
||||
}
|
||||
|
||||
public static boolean isMusicRestricted() {
|
||||
return BooleanTrue("isMusicRestricted");
|
||||
}
|
||||
|
||||
public static String isVKSansEnabled() {
|
||||
return vksans() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static boolean msgflat() {
|
||||
return BooleanFalse("msgflat");
|
||||
}
|
||||
|
||||
public static boolean msgtails() {
|
||||
return BooleanTrue("msgtails");
|
||||
}
|
||||
|
||||
public static boolean navbar() {
|
||||
return BooleanTrue("navbar");
|
||||
}
|
||||
|
||||
public static boolean newfeed() {
|
||||
return 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 = Helper.GetPreferences().getString("proxyHostHTTP", "");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyHostHTTPS() {
|
||||
String string = Helper.GetPreferences().getString("proxyHostHTTPS", "");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyHostSocks() {
|
||||
String string = Helper.GetPreferences().getString("proxyHostSocks", "");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortHTTP() {
|
||||
String string = Helper.GetPreferences().getString("proxyPortHTTP", "");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortHTTPS() {
|
||||
String string = ru.vtosters.lite.utils.Helper.GetPreferences().getString("proxyPortHTTPS", "");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static String proxyPortSocks() {
|
||||
String string = Helper.GetPreferences().getString("proxyPortSocks", "");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
public static boolean proxyvk() {
|
||||
return BooleanFalse("proxyvk");
|
||||
}
|
||||
|
||||
public static String readstatus() {
|
||||
return dnr() ? "messages.markAsRead" : "null";
|
||||
}
|
||||
|
||||
public static boolean refsfilter() {
|
||||
return BooleanFalse("refsfilter");
|
||||
}
|
||||
|
||||
public static boolean rightLikes() {
|
||||
return BooleanFalse("rightLikes");
|
||||
}
|
||||
|
||||
public static void setMeToken(String str) {
|
||||
ru.vtosters.lite.utils.Helper.GetPreferences().edit().putString("me_token", str).apply();
|
||||
}
|
||||
|
||||
public static boolean setoffline() {
|
||||
return BooleanFalse("setoffline");
|
||||
}
|
||||
|
||||
public static boolean shortinfo() {
|
||||
return BooleanTrue("shortinfo");
|
||||
}
|
||||
|
||||
public static boolean shortlinkfilter() {
|
||||
return BooleanFalse("shortlinkfilter");
|
||||
}
|
||||
|
||||
public static boolean shortpost() {
|
||||
return BooleanTrue("shortpost");
|
||||
}
|
||||
|
||||
public static boolean showmenu() {
|
||||
return BooleanFalse("showmenu");
|
||||
}
|
||||
|
||||
public static boolean ssl() {
|
||||
return BooleanTrue("ssl");
|
||||
}
|
||||
|
||||
public static boolean stories() {
|
||||
return BooleanTrue("stories");
|
||||
}
|
||||
|
||||
public static String storyads() {
|
||||
return adsstories() ? "null" : "ads";
|
||||
}
|
||||
|
||||
public static boolean swipe() {
|
||||
return BooleanTrue("swipe");
|
||||
}
|
||||
|
||||
public static boolean systememoji() {
|
||||
return BooleanFalse("systememoji");
|
||||
}
|
||||
|
||||
public static boolean unlockstats() {
|
||||
return BooleanFalse("unlockstats");
|
||||
}
|
||||
|
||||
public static boolean usevkui() {
|
||||
return BooleanTrue("usevkui");
|
||||
}
|
||||
|
||||
public static boolean vksans() {
|
||||
return BooleanFalse("vksans");
|
||||
}
|
||||
|
||||
public static boolean voice() {
|
||||
return BooleanTrue("voice");
|
||||
}
|
||||
|
||||
public static boolean newvideo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String widgetads() {
|
||||
return ads() ? "null" : "app_widget";
|
||||
}
|
||||
|
||||
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 = Helper.GetPreferences().getString("spamfilters", "");
|
||||
if (!string.isEmpty()) {
|
||||
mFilters.addAll(Arrays.asList(string.split(", ")));
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReferalsPut() {
|
||||
if (BooleanTrue("refsfilter")) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("Referals.txt")));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine != null) {
|
||||
mFilters.add(readLine);
|
||||
} else {
|
||||
bufferedReader.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShortLinkPut() {
|
||||
if (BooleanTrue("shortlinkfilter")) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("LinkShorter.txt")));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine != null) {
|
||||
mFilters.add(readLine);
|
||||
} else {
|
||||
bufferedReader.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void StandardFilterPut() {
|
||||
if (BooleanTrue("default_ad_list")) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("StandartFilter.txt")));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine != null) {
|
||||
mFilters.add(readLine);
|
||||
} else {
|
||||
bufferedReader.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void IDontWantToReadIt() {
|
||||
if (BooleanTrue("shitposting")) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.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 = Helper.GetPreferences().getString("ssfscustom", "");
|
||||
if (!string.isEmpty()) {
|
||||
return string;
|
||||
}
|
||||
return "https://vtsf.vknext.net";
|
||||
}
|
||||
|
||||
public static String VKVersion() {
|
||||
String string = Helper.GetPreferences().getString("vkversion", "");
|
||||
if (!string.isEmpty()) {
|
||||
return string;
|
||||
}
|
||||
return "5.29";
|
||||
}
|
||||
|
||||
public static boolean isBlockedByFilter(String str) {
|
||||
for (String str2 : mFilters) {
|
||||
if (str.toLowerCase().contains(str2.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void injectAbout(List<Items2> list) {
|
||||
list.clear();
|
||||
list.add(new Items1());
|
||||
if (!oldabout()) {
|
||||
list.add(new Items(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 = Helper.GetPreferences().getString("lang_value", "");
|
||||
if (string.equals("system")) {
|
||||
return Locale.getDefault().getLanguage();
|
||||
}
|
||||
return string.isEmpty() ? Locale.getDefault().getLanguage() : string;
|
||||
}
|
||||
|
||||
public static boolean proxy() {
|
||||
return ru.vtosters.lite.utils.Helper.GetPreferences().getString("proxy", "").equals("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 = ru.vtosters.lite.utils.Helper.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) ru.vtosters.lite.utils.Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
boolean z = false;
|
||||
try {
|
||||
if (notificationManager.getNotificationChannel("audio_playback_channel") != null) {
|
||||
z = true;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (!z) {
|
||||
notificationManager.createNotificationChannel(new NotificationChannel("audio_playback_channel", ru.vtosters.lite.utils.Helper.getResources().getString(R.string.audio_message_play_error), NotificationManager.IMPORTANCE_LOW));
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@ package ru.vtosters.lite.utils;
|
||||
public class ProfileHide {
|
||||
// private static final OkHttpClient client = new OkHttpClient();
|
||||
//
|
||||
// /* JADX WARN: Type inference failed for: r1v1, types: [boolean] */
|
||||
// /* JADX WARNING: Unknown variable types count: 1 */
|
||||
// public static void injectMap(HashMap<Integer, AdministratorProfileFragment.a.a> hashMap) {
|
||||
// for (int i = 0; VTVerifications.sServiceAccountsMap.valueOf(i) < 0; i++) {
|
||||
// boolean valueOf = VTVerifications.sServiceAccountsMap.valueOf(Helper.getId());
|
||||
|
||||
@@ -1,28 +1,23 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Prefs.proxyHostHTTP;
|
||||
import static ru.vtosters.lite.utils.Prefs.proxyHostHTTPS;
|
||||
import static ru.vtosters.lite.utils.Prefs.proxyHostSocks;
|
||||
import static ru.vtosters.lite.utils.Prefs.proxyPortHTTP;
|
||||
import static ru.vtosters.lite.utils.Prefs.proxyPortHTTPS;
|
||||
import static ru.vtosters.lite.utils.Prefs.proxyPortSocks;
|
||||
import 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() {
|
||||
@@ -34,8 +29,7 @@ public class Proxy {
|
||||
}
|
||||
|
||||
public static String getStaticComSupport() {
|
||||
String staticCom = getStaticCom();
|
||||
return staticCom + "/support";
|
||||
return getStaticCom() + "/support";
|
||||
}
|
||||
|
||||
public static String oauthFix() {
|
||||
@@ -43,108 +37,170 @@ public class Proxy {
|
||||
}
|
||||
|
||||
public static String getApiCom() {
|
||||
String string = Helper.GetPreferences().getString("proxyapi", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
return "api.vk.com";
|
||||
}
|
||||
String string = getPrefsValue("proxyapi");
|
||||
if (!proxy() & string.isEmpty()) return "api.vk.com";
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String getAwayPhpCom() {
|
||||
String string = Helper.GetPreferences().getString("proxyapi", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
return "m.vk.com";
|
||||
}
|
||||
String string = getPrefsValue("proxyapi");
|
||||
if (!proxy() & string.isEmpty()) return "m.vk.com";
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String getOauthCom() {
|
||||
String string = Helper.GetPreferences().getString("proxyoauth", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
return "oauth.vk.com";
|
||||
}
|
||||
String string = getPrefsValue("proxyoauth");
|
||||
if (!proxy() & string.isEmpty()) return "oauth.vk.com";
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String getStaticCom() {
|
||||
String string = Helper.GetPreferences().getString("proxystatic", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
return "static.vk.com";
|
||||
}
|
||||
String string = getPrefsValue("proxystatic");
|
||||
if (!proxy() & string.isEmpty()) return "static.vk.com";
|
||||
return string;
|
||||
}
|
||||
|
||||
public static String staticFix(String str) {
|
||||
String str2;
|
||||
String string = Helper.GetPreferences().getString("proxystatic", "");
|
||||
if (!Prefs.proxy() & string.isEmpty()) {
|
||||
return str;
|
||||
}
|
||||
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 (Helper.GetPreferences().getString("proxy", "")) {
|
||||
case "zaborona":
|
||||
Properties properties = System.getProperties();
|
||||
properties.setProperty("socksProxyHost", "socks.zaborona.help");
|
||||
properties.setProperty("socksProxyPort", "1488");
|
||||
System.clearProperty("https.proxyHost");
|
||||
System.clearProperty("https.proxyPort");
|
||||
System.clearProperty("http.proxyHost");
|
||||
System.clearProperty("http.proxyPort");
|
||||
break;
|
||||
case "socks":
|
||||
Properties properties2 = System.getProperties();
|
||||
properties2.setProperty("socksProxyHost", proxyHostSocks());
|
||||
properties2.setProperty("socksProxyPort", proxyPortSocks());
|
||||
System.clearProperty("https.proxyHost");
|
||||
System.clearProperty("https.proxyPort");
|
||||
System.clearProperty("http.proxyHost");
|
||||
System.clearProperty("http.proxyPort");
|
||||
break;
|
||||
case "http":
|
||||
Properties properties3 = System.getProperties();
|
||||
properties3.setProperty("http.proxyHost", proxyHostHTTP());
|
||||
properties3.setProperty("http.proxyPort", proxyPortHTTP());
|
||||
System.clearProperty("socksProxyHost");
|
||||
System.clearProperty("socksPortHost");
|
||||
System.clearProperty("https.proxyHost");
|
||||
System.clearProperty("https.proxyPort");
|
||||
break;
|
||||
case "https":
|
||||
Properties properties4 = System.getProperties();
|
||||
properties4.setProperty("https.proxyHost", proxyHostHTTPS());
|
||||
properties4.setProperty("https.proxyPort", proxyPortHTTPS());
|
||||
System.clearProperty("socksProxyHost");
|
||||
System.clearProperty("socksPortHost");
|
||||
System.clearProperty("http.proxyHost");
|
||||
System.clearProperty("http.proxyPort");
|
||||
break;
|
||||
default:
|
||||
System.clearProperty("socksProxyHost");
|
||||
System.clearProperty("socksPortHost");
|
||||
System.clearProperty("https.proxyHost");
|
||||
System.clearProperty("https.proxyPort");
|
||||
System.clearProperty("http.proxyHost");
|
||||
System.clearProperty("http.proxyPort");
|
||||
break;
|
||||
}
|
||||
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,45 @@
|
||||
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 static ru.vtosters.lite.utils.Themes.isDarkTheme;
|
||||
|
||||
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 isDarkTheme() ? "1" : "0";
|
||||
}
|
||||
|
||||
public static String getAmoledVKUI() {
|
||||
return getPrefsValue("darktheme").equals("amoled") && isDarkTheme() ? "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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static android.os.Environment.DIRECTORY_DOWNLOADS;
|
||||
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.Globals.getContext;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Base64;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class SettBackup {
|
||||
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");
|
||||
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 + "/VTLBackups/") + "/Backup_" + currentDateandTime + ".txt";
|
||||
var file = new File(directory);
|
||||
try {
|
||||
var exists = file.createNewFile();
|
||||
|
||||
if (!exists) {
|
||||
file.delete();
|
||||
file.createNewFile();
|
||||
}
|
||||
try {
|
||||
FileWriter out = new FileWriter(file);
|
||||
out.write(getAllPrefs());
|
||||
out.close();
|
||||
makeText(getContext(), "Сохранено в файл " + directory, LENGTH_LONG).show();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
makeText(getContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
makeText(getContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAllPrefs() {
|
||||
Map<String, ?> allPrefs = prefs.getAll();
|
||||
return Base64.encodeToString(allPrefs.toString().getBytes(), 1);
|
||||
}
|
||||
|
||||
public static void restoreBackup() {
|
||||
File dir = new File(getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS + "/VTLBackups/").getPath());;
|
||||
// TODO Make restore backup from file list
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user