Compare commits
132
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45f7cc4484 | ||
|
|
886ddd60c1 | ||
|
|
adc06426ac | ||
|
|
62aa568599 | ||
|
|
f2ac845797 | ||
|
|
a85e55a594 | ||
|
|
e2775db4e5 | ||
|
|
589e8928a0 | ||
|
|
cd189b1dda | ||
|
|
14c111a3e6 | ||
|
|
b506c56346 | ||
|
|
bbbc94e510 | ||
|
|
8cb2c380e7 | ||
|
|
b9879f9ed7 | ||
|
|
cf05e051e8 | ||
|
|
963c4d81ba | ||
|
|
099c699702 | ||
|
|
1117fc19d4 | ||
|
|
78dca26063 | ||
|
|
f5180f61d5 | ||
|
|
540fffdcc9 | ||
|
|
5357c60eaa | ||
|
|
c59f29121f | ||
|
|
bd38cab377 | ||
|
|
0058431590 | ||
|
|
bf4cf2be53 | ||
|
|
aac86a9952 | ||
|
|
ae00e72bac | ||
|
|
fea984f6fd | ||
|
|
d870c2f984 | ||
|
|
f7f43928cf | ||
|
|
1accb45f12 | ||
|
|
d9f53920e5 | ||
|
|
76d91332d7 | ||
|
|
728cbde683 | ||
|
|
60c98cd998 | ||
|
|
f1d106e0f0 | ||
|
|
c92194e90b | ||
|
|
91683af807 | ||
|
|
c5c898aa4e | ||
|
|
25634b2469 | ||
|
|
b8e764d09d | ||
|
|
17ed32857a | ||
|
|
d631d07e0f | ||
|
|
2ec4c69832 | ||
|
|
6426c965c6 | ||
|
|
4f6d410185 | ||
|
|
18a899f439 | ||
|
|
7e5b3fe233 | ||
|
|
4abd0eec6c | ||
|
|
cf17ed64c7 | ||
|
|
a2dd7c1e06 | ||
|
|
021fe66bec | ||
|
|
1b3896f4ca | ||
|
|
fc9ccf66d1 | ||
|
|
d205f2894b | ||
|
|
7afc04b2b2 | ||
|
|
584ee96ee0 | ||
|
|
66f7ea1b79 | ||
|
|
7b0a83458b | ||
|
|
cdaf7909d4 | ||
|
|
c70ab388c1 | ||
|
|
50c66c2703 | ||
|
|
357e520bb0 | ||
|
|
6379ce5741 | ||
|
|
02807739a1 | ||
|
|
40635ab75a | ||
|
|
32e1bfe6fd | ||
|
|
281a0e8499 | ||
|
|
220c61afe1 | ||
|
|
7a632d5224 | ||
|
|
3218c1a46b | ||
|
|
b2028d86ba | ||
|
|
45ed5879e6 | ||
|
|
48479dd064 | ||
|
|
3b556b81a1 | ||
|
|
526c9a607a | ||
|
|
81752895ab | ||
|
|
ad970d097a | ||
|
|
bc2010b49d | ||
|
|
ff4a4094ff | ||
|
|
3629e71098 | ||
|
|
b955ac355f | ||
|
|
409279eca0 | ||
|
|
ea0a0f1d93 | ||
|
|
3cc81dfddc | ||
|
|
86041e6031 | ||
|
|
e140ce2661 | ||
|
|
f6f15132a2 | ||
|
|
e73751ecf3 | ||
|
|
3c0516b4cd | ||
|
|
38d9f4a818 | ||
|
|
207fa4f2e7 | ||
|
|
f9f778b8f4 | ||
|
|
962dcdec67 | ||
|
|
486026b8aa | ||
|
|
e78d08fb94 | ||
|
|
a5e81dbd87 | ||
|
|
49051dae9a | ||
|
|
94236c87e3 | ||
|
|
449ba8c768 | ||
|
|
0da81c01e9 | ||
|
|
b4a0b7e1ea | ||
|
|
f2209eca49 | ||
|
|
4a004971c6 | ||
|
|
e400b8761c | ||
|
|
ff8e7b7f41 | ||
|
|
2c501606be | ||
|
|
73420fe1c4 | ||
|
|
337f81346c | ||
|
|
06f9a4545b | ||
|
|
fa99df93c4 | ||
|
|
adcd2472d5 | ||
|
|
7527b9a07e | ||
|
|
800c223baa | ||
|
|
d1123d3ccf | ||
|
|
f61fc99d9c | ||
|
|
60653cc739 | ||
|
|
d25bba10b0 | ||
|
|
3b67ecaa5e | ||
|
|
6600f32392 | ||
|
|
64303b1709 | ||
|
|
5c7e50d61e | ||
|
|
f68ad105a6 | ||
|
|
164479da1d | ||
|
|
d93bf41d28 | ||
|
|
38a2b3f2b2 | ||
|
|
342534676c | ||
|
|
56a6a6de03 | ||
|
|
d1445c2801 | ||
|
|
6d3ddede38 | ||
|
|
08dae9b342 |
@@ -21,10 +21,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Set up JDK 14
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '14'
|
||||
java-version: '17'
|
||||
distribution: 'adopt'
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
* Стабильные сборки находятся в [Releases](https://github.com/vtosters/lite/releases)
|
||||
|
||||
Зеркало на нашем [<img src="https://gitea.com/assets/img/logo.svg" align="center" width="20" height="20"/> Git](https://git.maki.su/gdlbo/lite)
|
||||
Зеркало на нашем [<img src="https://gitea.com/assets/img/logo.svg" align="center" width="20" height="20"/> Git](https://git.maki.su/vtosters/lite)
|
||||
|
||||
### Быстрая навигация
|
||||
|
||||
|
||||
+62
-73
@@ -1,8 +1,6 @@
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
@@ -21,6 +19,10 @@ cargo {
|
||||
|
||||
def smaliFolder = projectDir.toPath().resolve("../smali").normalize()
|
||||
def scriptsFolder = projectDir.toPath().resolve("../scripts").normalize()
|
||||
//you can add own folders with decompiled smali code
|
||||
def dexes=smaliFolder.toFile()
|
||||
.listFiles( { f -> f.isDirectory() && f.name.startsWith("smali") } as FileFilter)
|
||||
.size()
|
||||
|
||||
versionFile {
|
||||
file = projectDir.toPath().resolve("src/main/assets/version.properties").toFile()
|
||||
@@ -50,19 +52,24 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
buildConfigField 'String', 'APPCENTER_KEY', '""'
|
||||
proguardFile 'proguard-rules.pro'
|
||||
}
|
||||
rc {
|
||||
minifyEnabled true
|
||||
buildConfigField 'String', 'APPCENTER_KEY', '""'
|
||||
proguardFile 'proguard-rules.pro'
|
||||
}
|
||||
dev {
|
||||
initWith release
|
||||
minifyEnabled false
|
||||
buildConfigField 'String', 'APPCENTER_KEY', '""'
|
||||
}
|
||||
beta {
|
||||
initWith release
|
||||
minifyEnabled false
|
||||
buildConfigField 'String', 'APPCENTER_KEY', '""'
|
||||
}
|
||||
release {
|
||||
buildConfigField 'String', 'APPCENTER_KEY', '""'
|
||||
minifyEnabled true
|
||||
proguardFile 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -72,77 +79,60 @@ android {
|
||||
}
|
||||
namespace 'ru.vtosters.lite'
|
||||
ndkVersion '25.2.9519653'
|
||||
buildFeatures {
|
||||
aidl true
|
||||
}
|
||||
}
|
||||
|
||||
task testClasses {
|
||||
doLast {
|
||||
println 'This is a dummy testClasses task'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.microsoft.appcenter:appcenter-analytics:5.0.1'
|
||||
implementation 'com.microsoft.appcenter:appcenter-crashes:5.0.1'
|
||||
implementation 'com.microsoft.appcenter:appcenter-analytics:5.0.2'
|
||||
implementation 'com.microsoft.appcenter:appcenter-crashes:5.0.2'
|
||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
|
||||
implementation 'net.sourceforge.streamsupport:streamsupport-minifuture:1.7.4'
|
||||
implementation 'com.google.guava:guava:23.3-android'
|
||||
|
||||
implementation fileTree(dir: 'libs', include: ['*.aar'])
|
||||
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.google.guava:guava:23.3-android'
|
||||
}
|
||||
|
||||
task generateBuildTasks() {
|
||||
android.applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def buildType = output.name.toString().capitalize()
|
||||
def lowerBuildType = buildType.toLowerCase()
|
||||
if(buildType=="Base")return
|
||||
task "exportDex$buildType"() {
|
||||
dependsOn('assemble' + buildType)
|
||||
doLast {
|
||||
try {
|
||||
var z = ""
|
||||
if (lowerBuildType != "debug") {
|
||||
z = "-unsigned"
|
||||
}
|
||||
|
||||
File moduleDir = projectDir
|
||||
ZipInputStream inputStream = new ZipInputStream(new FileInputStream(moduleDir.getAbsolutePath() + "/build/outputs/apk/$lowerBuildType/app-$lowerBuildType${z}.apk"))
|
||||
ZipFile file = new ZipFile(moduleDir.getAbsolutePath() + "/build/outputs/apk/$lowerBuildType/app-$lowerBuildType${z}.apk");
|
||||
ZipEntry entry
|
||||
while ((entry = inputStream.nextEntry) != null) {
|
||||
if (entry.getName().equals("classes.dex")) {
|
||||
print('classes.dex found!')
|
||||
|
||||
FileOutputStream outputStream = new FileOutputStream(new File(moduleDir.getAbsoluteFile(), "classes6.dex"))
|
||||
|
||||
byte[] buffer = new byte[1024]
|
||||
int len = 0
|
||||
while ((len = inputStream.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, len)
|
||||
}
|
||||
outputStream.close()
|
||||
}
|
||||
if (entry.getName().equals("classes2.dex")) {
|
||||
print('\nclasses2.dex found!')
|
||||
|
||||
FileOutputStream outputStream = new FileOutputStream(new File(moduleDir.getAbsoluteFile(), "classes7.dex"))
|
||||
|
||||
byte[] buffer = new byte[1024]
|
||||
int len = 0
|
||||
while ((len = inputStream.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, len)
|
||||
}
|
||||
outputStream.close()
|
||||
}
|
||||
}
|
||||
|
||||
for (ZipEntry e : Collections.list(file.entries())) {
|
||||
if (e.getName().endsWith("assets/version.properties")) {
|
||||
var is = file.getInputStream(e)
|
||||
FileOutputStream outputStream = new FileOutputStream(new File(moduleDir.getAbsoluteFile(), "version.properties"))
|
||||
|
||||
byte[] buffer = new byte[1024]
|
||||
int len = 0
|
||||
while ((len = is.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, len)
|
||||
}
|
||||
outputStream.close()
|
||||
|
||||
print('\nversion.properties found!')
|
||||
}
|
||||
def suffix=buildType.toLowerCase()
|
||||
String apkPath=projectDir.getAbsolutePath()+"/build/outputs/apk/$suffix/app-$suffix"
|
||||
def apk=new File(apkPath+"-unsigned.apk")
|
||||
if(!apk.exists())apk=new File(apkPath+".apk")
|
||||
def zip=new ZipFile(apk)
|
||||
def entries=zip.entries()
|
||||
def dexCounter=dexes
|
||||
while(entries.hasMoreElements())
|
||||
{
|
||||
def entry=entries.nextElement()
|
||||
String filename
|
||||
if(entry.name.matches("^classes(?:(?=\\d)2|)\\.dex\$"))filename="classes${++dexCounter}.dex"
|
||||
else if(entry.name=="assets/version.properties")filename="version.properties"
|
||||
else continue
|
||||
println("Exporting "+entry.name)
|
||||
def tmpFile=new File(projectDir,filename)
|
||||
def is=zip.getInputStream(entry)
|
||||
def fos=new FileOutputStream(tmpFile)
|
||||
def buff=new byte[0x800]
|
||||
int len
|
||||
while((len=is.read(buff))>0)fos.write(buff,0,len)
|
||||
is.close()
|
||||
fos.close()
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace()
|
||||
@@ -152,17 +142,16 @@ task generateBuildTasks() {
|
||||
task "prepareDexForMerge$buildType"(type: Copy) {
|
||||
dependsOn('exportDex' + buildType)
|
||||
// Remove comment for native lib build
|
||||
dependsOn('cargoBuild')
|
||||
//dependsOn('cargoBuild')
|
||||
into smaliFolder.toString()
|
||||
from(projectDir) {
|
||||
include 'classes6.dex'
|
||||
include 'classes7.dex'
|
||||
into '../smali'
|
||||
include "classes*.dex"
|
||||
}
|
||||
from(projectDir) {
|
||||
include 'version.properties'
|
||||
into 'assets'
|
||||
}
|
||||
// Remove comment for native lib build
|
||||
from('../native-effects/target/aarch64-linux-android/release'){
|
||||
include 'libnative_effects.so'
|
||||
into 'lib/arm64-v8a'
|
||||
@@ -171,15 +160,16 @@ task generateBuildTasks() {
|
||||
include 'libnative_effects.so'
|
||||
into 'lib/armeabi-v7a'
|
||||
}
|
||||
doLast {
|
||||
new File(projectDir, "classes6.dex").delete()
|
||||
new File(projectDir, "classes7.dex").delete()
|
||||
new File(projectDir, "version.properties").delete()
|
||||
}
|
||||
}
|
||||
task "cleanTemporaryFiles$buildType"(type:Delete)
|
||||
{
|
||||
delete fileTree(dir:projectDir,include:["*.dex","version.properties"])
|
||||
delete fileTree(dir:smaliFolder,include:['*.dex',"assets/version.properties"])
|
||||
}
|
||||
task "buildVTL$buildType"(type: Exec) {
|
||||
dependsOn('prepareDexForMerge' + buildType)
|
||||
workingDir(projectDir.parentFile)
|
||||
finalizedBy "cleanTemporaryFiles$buildType"
|
||||
if (Os.isFamily("unix") || Os.isFamily("mac")) {
|
||||
commandLine 'bash', '-c', './scripts/build.sh'
|
||||
} else {
|
||||
@@ -207,7 +197,6 @@ task generateBuildTasks() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
task generateRjava(type: Exec) {
|
||||
workingDir(projectDir.parentFile)
|
||||
if (Os.isFamily("unix") || Os.isFamily("mac"))
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Vendored
+3
-1
@@ -32,13 +32,15 @@
|
||||
-repackageclasses
|
||||
-allowaccessmodification
|
||||
-optimizations
|
||||
-optimizationpasses 5
|
||||
-keepattributes SourceFile, LineNumberTable
|
||||
|
||||
-keep,allowoptimization class ru.vtosters.lite.** {
|
||||
-keep,allowoptimization class ru.vtosters.hooks.**, ru.vtosters.lite.utils.AndroidUtils, ru.vtosters.lite.utils.NetworkUtils, ru.vtosters.lite.utils.CrashReporter, ru.vtosters.lite.ui.activities.**, ru.vtosters.lite.services.**, ru.vtosters.lite.ui.fragments.**, ru.vtosters.lite.themes.**, ru.vtosters.lite.music.hook.**, ru.vtosters.lite.music.cache.injectors.**, ru.vtosters.lite.ui.wallpapers.NativeEffects, com.aefyr.tsg.g2.TelegramStickersService {
|
||||
public <fields>;
|
||||
public <methods>;
|
||||
public <init>(...);
|
||||
}
|
||||
|
||||
-keep class com.vtosters.lite.** { *; }
|
||||
-keep class com.vk.** { *; }
|
||||
-keep class bruhcollective.itaysonlab.libvkx.client.** { *; }
|
||||
@@ -10,9 +10,9 @@ import com.vk.music.common.MusicPlaybackLaunchContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
import static ru.vtosters.hooks.other.Preferences.isValidSignature;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
|
||||
|
||||
public class LibVKXClient {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@@ -80,11 +80,6 @@ public class LibVKXClient {
|
||||
lambdaplay(list, musicTrack, iLibVkxService, null);
|
||||
}
|
||||
|
||||
public static String asId(MusicTrack musicTrack) {
|
||||
String id = musicTrack.e + "_" + musicTrack.d;
|
||||
if (musicTrack.O != null && !musicTrack.O.equals("")) {
|
||||
id += "_" + musicTrack.O;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
public static String asId(MusicTrack musicTrack)
|
||||
{ return musicTrack.y1(); }
|
||||
}
|
||||
@@ -36,10 +36,8 @@ public class TelegramStickersPack extends CustomStickersPack {
|
||||
public HashMap<String, List<Integer>> emojis = new HashMap<>();
|
||||
|
||||
public TelegramStickersPack(String id) {
|
||||
final var idLowerCase = id.toLowerCase();
|
||||
this.id = idLowerCase;
|
||||
this.hash = idLowerCase.hashCode();
|
||||
title = id;
|
||||
this.id = this.title = id;
|
||||
this.hash = id.hashCode();
|
||||
}
|
||||
|
||||
public JSONObject encodeEmojis() throws JSONException {
|
||||
@@ -103,7 +101,7 @@ public class TelegramStickersPack extends CustomStickersPack {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equalsIgnoreCase(id);
|
||||
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equals(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ 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 ru.vtosters.lite.ui.fragments.VTSettings;
|
||||
import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment;
|
||||
|
||||
import java.io.File;
|
||||
@@ -25,19 +26,13 @@ import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
public class TelegramStickersService {
|
||||
private static final String TAG = "TGStickersService";
|
||||
private static TelegramStickersService instance;
|
||||
|
||||
private final Context c;
|
||||
|
||||
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 final Handler uiThreadHandler;
|
||||
|
||||
private final TelegramStickersGrabber grabber;
|
||||
|
||||
private final TelegramStickersDbHelper dbHelper;
|
||||
private final ArrayList<Runnable> queuedTasks;
|
||||
private final ThreadPoolExecutor executor;
|
||||
@@ -47,16 +42,14 @@ public class TelegramStickersService {
|
||||
private TelegramStickersService(Context context) {
|
||||
instance = this;
|
||||
|
||||
this.c = context.getApplicationContext();
|
||||
|
||||
listeners = new ArrayList<>();
|
||||
currentlyDownloading = new HashSet<>();
|
||||
uiThreadHandler = new Handler(Looper.getMainLooper());
|
||||
grabber = new TelegramStickersGrabber(null);
|
||||
dbHelper = new TelegramStickersDbHelper(c);
|
||||
dbHelper = new TelegramStickersDbHelper(context);
|
||||
queuedTasks = new ArrayList<>();
|
||||
executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(2);
|
||||
notificationsHelper = new NotificationsHelper(c);
|
||||
notificationsHelper = new NotificationsHelper(context);
|
||||
|
||||
packs = new ArrayList<>();
|
||||
activePacks = new ArrayList<>();
|
||||
@@ -69,11 +62,11 @@ public class TelegramStickersService {
|
||||
return instance == null ? new TelegramStickersService(c) : instance;
|
||||
}
|
||||
|
||||
private void updatePacks(final boolean notify) {
|
||||
private void updatePacks(boolean notify) {
|
||||
packs.clear();
|
||||
dbHelper.getAllPacks(new TelegramStickersDbHelper.PacksLoadingListener() {
|
||||
@Override
|
||||
public void onPackLoaded(final TelegramStickersPack pack) {
|
||||
public void onPackLoaded(TelegramStickersPack pack) {
|
||||
runOnUiThread(() -> {
|
||||
packs.add(pack);
|
||||
|
||||
@@ -102,14 +95,6 @@ public class TelegramStickersService {
|
||||
});
|
||||
}
|
||||
|
||||
public void addStickersEventsListener(StickersEventsListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeStickersEventsListener(StickersEventsListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
private void notifyPackAdded(TelegramStickersPack pack, int atIndex) {
|
||||
getGlobalContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
if (listeners.isEmpty())
|
||||
@@ -152,6 +137,7 @@ public class TelegramStickersService {
|
||||
|
||||
private void notifyActivePacksListChanged() {
|
||||
getGlobalContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
|
||||
getGlobalContext().sendBroadcast(new Intent(VTSettings.ACTION_INVALIDATE_TGS_COUNT));
|
||||
if (listeners.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -186,20 +172,16 @@ public class TelegramStickersService {
|
||||
return inactivePacks;
|
||||
}
|
||||
|
||||
public boolean isDoneLoading() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
public boolean requestPackDownload(final String id, File packFolder) {
|
||||
public void requestPackDownload(String id, File packFolder) {
|
||||
if (currentlyDownloading.contains(id)) {
|
||||
Log.e(TAG, String.format("Got request to download pack %s which is already downloading", id));
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
final File folder = packFolder;
|
||||
File folder = packFolder;
|
||||
queuedTasks.add(() -> requestPackDownload(id, folder));
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
TelegramStickersPack pack = new TelegramStickersPack(id);
|
||||
@@ -219,85 +201,86 @@ public class TelegramStickersService {
|
||||
notifyPackAdded(pack, packs.size() - 1);
|
||||
}
|
||||
|
||||
final TelegramStickersPack newPack = pack;
|
||||
final boolean isUpdate = update;
|
||||
TelegramStickersPack newPack = pack;
|
||||
boolean isUpdate = update;
|
||||
|
||||
currentlyDownloading.add(id.toLowerCase());
|
||||
currentlyDownloading.add(id);
|
||||
notificationsHelper.packStartedDownloading(newPack);
|
||||
|
||||
|
||||
grabber.enableProxy();
|
||||
grabber.grabPack(id, packFolder, pack.version, new TelegramStickersGrabber.PackDownloadListener() {
|
||||
@Override
|
||||
public void onPackDownloaded(TelegramStickersPackInfo packInfo, boolean newVersionFound) {
|
||||
|
||||
runOnUiThread(() -> {
|
||||
newPack.state = TelegramStickersPack.DOWNLOADED;
|
||||
notifyPackChanged(newPack, packs.indexOf(newPack));
|
||||
currentlyDownloading.remove(newPack.id);
|
||||
syncPack(newPack);
|
||||
|
||||
if (isUpdate) {
|
||||
if (newPack.enabled)
|
||||
notifyActivePacksListChanged();
|
||||
} else {
|
||||
activePacks.add(newPack);
|
||||
notifyActivePacksListChanged();
|
||||
}
|
||||
});
|
||||
notificationsHelper.packDoneDownloading(newPack, true, isUpdate, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPackDownloadError(final Exception e) {
|
||||
runOnUiThread(() -> {
|
||||
Log.e(TAG, "Error while downloading pack " + newPack.id);
|
||||
e.printStackTrace();
|
||||
|
||||
if (!isUpdate) {
|
||||
int index = packs.indexOf(newPack);
|
||||
packs.remove(index);
|
||||
notifyPackRemoved(newPack, index);
|
||||
} else {
|
||||
// try-catch block to handle possible timeout exception
|
||||
try {
|
||||
grabber.grabPack(id, packFolder, pack.version, new TelegramStickersGrabber.PackDownloadListener() {
|
||||
@Override
|
||||
public void onPackDownloaded(TelegramStickersPackInfo packInfo, boolean newVersionFound) {
|
||||
runOnUiThread(() -> {
|
||||
newPack.state = TelegramStickersPack.DOWNLOADED;
|
||||
notifyPackChanged(newPack, packs.indexOf(newPack));
|
||||
}
|
||||
currentlyDownloading.remove(newPack.id);
|
||||
syncPack(newPack);
|
||||
|
||||
notifyPackDownloadError(newPack, e);
|
||||
currentlyDownloading.remove(newPack.id);
|
||||
});
|
||||
notificationsHelper.packDoneDownloading(newPack, false, isUpdate, e);
|
||||
}
|
||||
if (isUpdate) {
|
||||
if (newPack.enabled)
|
||||
notifyActivePacksListChanged();
|
||||
} else {
|
||||
activePacks.add(newPack);
|
||||
notifyActivePacksListChanged();
|
||||
}
|
||||
});
|
||||
notificationsHelper.packDoneDownloading(newPack, true, isUpdate, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGotPackInfo(final TelegramStickersPackInfo packInfo) {
|
||||
runOnUiThread(() -> {
|
||||
newPack.title = packInfo.title;
|
||||
newPack.stickersCount = packInfo.stickersCount;
|
||||
newPack.version = packInfo.version;
|
||||
notifyPackChanged(newPack, packs.indexOf(newPack));
|
||||
});
|
||||
@Override
|
||||
public void onPackDownloadError(Exception e) {
|
||||
runOnUiThread(() -> {
|
||||
Log.e(TAG, "Error while downloading pack " + newPack.id);
|
||||
e.printStackTrace();
|
||||
|
||||
notificationsHelper.packDownloadUpdated(newPack, 0);
|
||||
}
|
||||
if (!isUpdate) {
|
||||
int index = packs.indexOf(newPack);
|
||||
packs.remove(index);
|
||||
notifyPackRemoved(newPack, index);
|
||||
} else {
|
||||
newPack.state = TelegramStickersPack.DOWNLOADED;
|
||||
notifyPackChanged(newPack, packs.indexOf(newPack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStickerDownloaded(String pack, File sticker, String boundEmoji, int stickerIndex, int downloadedStickersCount, int totalStickersCount) {
|
||||
stickerIndex--;
|
||||
notifyPackDownloadError(newPack, e);
|
||||
currentlyDownloading.remove(newPack.id);
|
||||
});
|
||||
notificationsHelper.packDoneDownloading(newPack, false, isUpdate, e);
|
||||
}
|
||||
|
||||
List<Integer> list = newPack.emojis.get(boundEmoji);
|
||||
if (list == null) list = new ArrayList<>();
|
||||
list.add(stickerIndex);
|
||||
newPack.emojis.put(boundEmoji, list);
|
||||
@Override
|
||||
public void onGotPackInfo(TelegramStickersPackInfo packInfo) {
|
||||
runOnUiThread(() -> {
|
||||
newPack.title = packInfo.title;
|
||||
newPack.stickersCount = packInfo.stickersCount;
|
||||
newPack.version = packInfo.version;
|
||||
notifyPackChanged(newPack, packs.indexOf(newPack));
|
||||
});
|
||||
|
||||
notificationsHelper.packDownloadUpdated(newPack, downloadedStickersCount);
|
||||
}
|
||||
});
|
||||
notificationsHelper.packDownloadUpdated(newPack, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
@Override
|
||||
public void onStickerDownloaded(String pack, File sticker, String boundEmoji, int stickerIndex, int downloadedStickersCount, int totalStickersCount) {
|
||||
stickerIndex--;
|
||||
|
||||
List<Integer> list = newPack.emojis.get(boundEmoji);
|
||||
if (list == null) list = new ArrayList<>();
|
||||
list.add(stickerIndex);
|
||||
newPack.emojis.put(boundEmoji, list);
|
||||
|
||||
notificationsHelper.packDownloadUpdated(newPack, downloadedStickersCount);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
// handle other possible exceptions
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPackEnabled(final TelegramStickersPack pack, final boolean enabled, final boolean notify) {
|
||||
public void setPackEnabled(TelegramStickersPack pack, boolean enabled, boolean notify) {
|
||||
if (!ready) {
|
||||
queuedTasks.add(() -> setPackEnabled(pack, enabled, notify));
|
||||
return;
|
||||
@@ -323,7 +306,7 @@ public class TelegramStickersService {
|
||||
}
|
||||
}
|
||||
|
||||
public void deletePack(final TelegramStickersPack pack) {
|
||||
public void deletePack(TelegramStickersPack pack) {
|
||||
if (!ready) {
|
||||
queuedTasks.add(() -> deletePack(pack));
|
||||
return;
|
||||
@@ -332,7 +315,6 @@ public class TelegramStickersService {
|
||||
boolean d = dbHelper.deletePack(pack);
|
||||
Log.d(TAG, "Delete from DB=" + d);
|
||||
|
||||
|
||||
int index = packs.indexOf(pack);
|
||||
packs.remove(index);
|
||||
notifyPackRemoved(pack, index);
|
||||
@@ -353,7 +335,7 @@ public class TelegramStickersService {
|
||||
uiThreadHandler.post(r);
|
||||
}
|
||||
|
||||
private void syncPack(final TelegramStickersPack pack) {
|
||||
private void syncPack(TelegramStickersPack pack) {
|
||||
if (!ready) {
|
||||
queuedTasks.add(() -> syncPack(pack));
|
||||
return;
|
||||
@@ -395,6 +377,4 @@ public class TelegramStickersService {
|
||||
|
||||
void onInactivePacksListChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,23 +7,20 @@ import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.util.Flag;
|
||||
import com.aefyr.tsg.g2.stickersgrabber.util.GoalCounter;
|
||||
import okhttp3.*;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.net.*;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@@ -31,14 +28,19 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
*/
|
||||
public class TelegramStickersGrabber {
|
||||
private static final String TAG = "TSG";
|
||||
public static String REAL_TG_IP = null;
|
||||
public static String PROXY_IP = null;
|
||||
public static int PROXY_PORT = -1;
|
||||
public static String PROXY_USER = null;
|
||||
public static String PROXY_PASS = null;
|
||||
public static boolean PROXY_SOCKS = true;
|
||||
public static boolean HAS_PASS = false;
|
||||
public static boolean USE_PROXY = false;
|
||||
private static final OkHttpClient sClient = VtOkHttpClient.getInstance();
|
||||
private static final int MAX_RETRIES = 2;
|
||||
private static final AtomicInteger retryCount = new AtomicInteger();
|
||||
private static final int STICKER_QUALITY = 100;
|
||||
private static final String STICKER_FILE_NAME_FORMAT = "%03d.png";
|
||||
private static final String STICKERS_KEY = "stickers";
|
||||
private static final String FILE_ID_KEY = "file_id";
|
||||
private static final String EMOJI_KEY = "emoji";
|
||||
private static final String IS_ANIMATED_KEY = "is_animated";
|
||||
private static final String IS_VIDEO_KEY = "is_video";
|
||||
private static final String THUMB_KEY = "thumb";
|
||||
private static final String NAME_KEY = "name";
|
||||
private static final String TITLE_KEY = "title";
|
||||
private static String BOT_API_BASE_URL;
|
||||
private static String GET_STICKER_SET_URL;
|
||||
private static String GET_FILE_URL;
|
||||
@@ -50,12 +52,10 @@ public class TelegramStickersGrabber {
|
||||
|
||||
private final MessageDigest sha256;
|
||||
private final Handler uiThreadHandler;
|
||||
private String botApiKey = "";
|
||||
private NetClient httpClient;
|
||||
private String botApiKey;
|
||||
|
||||
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");
|
||||
@@ -69,81 +69,12 @@ public class TelegramStickersGrabber {
|
||||
public static void updateURLs() {
|
||||
BOT_API_BASE_FILE_URL = "https://api.telegram.org/file/bot%s/%s";
|
||||
|
||||
|
||||
BOT_API_BASE_URL = REAL_TG_IP != null ? "https://" + REAL_TG_IP + "/bot%s/" : "https://api.telegram.org/bot%s/";
|
||||
BOT_API_BASE_URL = "https://api.telegram.org/bot%s/";
|
||||
GET_STICKER_SET_URL = BOT_API_BASE_URL + "getStickerSet?name=%s";
|
||||
GET_FILE_URL = BOT_API_BASE_URL + "getFile?file_id=%s";
|
||||
}
|
||||
|
||||
public static boolean isTelegramBlocked() {
|
||||
NetClient client = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
|
||||
try {
|
||||
if (PROXY_IP != null) {
|
||||
Socket socket = new Socket(PROXY_IP, PROXY_PORT);
|
||||
Proxy proxy = new Proxy(Proxy.Type.SOCKS, socket.getRemoteSocketAddress());
|
||||
NetClient.Builder b = new NetClient.Builder().proxy(proxy);
|
||||
if (PROXY_USER != null) {
|
||||
b = b.proxyAuthenticator(new PasswordAuthentication(PROXY_USER, PROXY_PASS.toCharArray()));
|
||||
}
|
||||
client = b.build();
|
||||
socket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
NetRequest req = new NetRequest.Builder().url(REAL_TG_IP != null ? "https://" + REAL_TG_IP + "/test/" : "https://api.telegram.org/test/").build();
|
||||
try {
|
||||
NetResponse res = client.newCall(req).execute();
|
||||
String s = res.getDataString();
|
||||
|
||||
if (!s.equals("{\"ok\":false,\"error_code\":404,\"description\":\"Not Found\"}"))
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetProxy() {
|
||||
httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
|
||||
}
|
||||
|
||||
public void enableProxy() {
|
||||
Thread kostil = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (PROXY_IP != null) {
|
||||
Socket socket = new Socket(PROXY_IP, PROXY_PORT);
|
||||
Proxy proxy = new Proxy(Proxy.Type.SOCKS, socket.getRemoteSocketAddress());
|
||||
NetClient.Builder b = httpClient.newBuilder().proxy(proxy);
|
||||
|
||||
if (PROXY_USER != null) {
|
||||
httpClient = b.proxyAuthenticator(new PasswordAuthentication(PROXY_USER, PROXY_PASS.toCharArray())).build();
|
||||
}
|
||||
|
||||
httpClient = b.build();
|
||||
socket.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
kostil.start();
|
||||
try {
|
||||
kostil.join();
|
||||
Log.d(TAG, "Proxy set");
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "Unable to set proxy:");
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void grabPack(String id, File packFolder, String installedVersion, final PackDownloadListener listener) {
|
||||
public void grabPack(String id, File packFolder, String installedVersion, PackDownloadListener listener) {
|
||||
getPackInfo(id, packFolder, installedVersion, listener);
|
||||
}
|
||||
|
||||
@@ -151,264 +82,247 @@ public class TelegramStickersGrabber {
|
||||
botApiKey = key;
|
||||
}
|
||||
|
||||
public void checkKey(final KeyCheckListener listener) {
|
||||
public void checkKey(KeyCheckListener listener) {
|
||||
Log.d(TAG, "Checking key: " + botApiKey);
|
||||
NetRequest request = new NetRequest.Builder().get().url(String.format(BOT_API_BASE_URL + "getMe", botApiKey)).build();
|
||||
httpClient.newCall(request).enqueue(new NetCallback() {
|
||||
// Create a request object with the URL and bot API key
|
||||
Request request = new Request.a()
|
||||
.b(String.format(BOT_API_BASE_URL + "getMe", botApiKey))
|
||||
.a();
|
||||
// Create a new call object and enqueue it to run asynchronously
|
||||
sClient.a(request).a(new Callback() {
|
||||
@Override
|
||||
public void onFailure(NetCall call, IOException e) {
|
||||
e.printStackTrace();
|
||||
public void a(Call call, IOException e) {
|
||||
// Handle the failure case
|
||||
Log.d(TAG, e.getMessage());
|
||||
runOnUiThread(listener::onNetError);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(NetCall call, final NetResponse response) throws IOException {
|
||||
runOnUiThread(() -> listener.onKeyChecked(response.code() == 200));
|
||||
public void a(Call call, Response response) {
|
||||
Log.d(TAG, response.toString());
|
||||
runOnUiThread(() -> listener.onKeyChecked(response.h()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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() {
|
||||
private void getPack(StickerSet set, File packFolder, TelegramStickersPackInfo packInfo, PackDownloadListener listener) {
|
||||
GoalCounter downloadedStickers = new GoalCounter(set.stickers.size(), () -> {
|
||||
Log.d(TAG, String.format("Pack %s has been downloaded to %s", set.id, packFolder.getAbsolutePath()));
|
||||
listener.onPackDownloaded(packInfo, true);
|
||||
});
|
||||
|
||||
Flag deathFlag = new Flag();
|
||||
|
||||
for (int i = 0; i < set.stickers.size(); i++) {
|
||||
Sticker sticker = set.stickers.get(i);
|
||||
String getFileUrl = String.format(GET_FILE_URL, botApiKey, sticker.fileId);
|
||||
Request fileInfoRequest = new Request.a()
|
||||
.b(getFileUrl)
|
||||
.a();
|
||||
|
||||
int stickerIndex = i + 1;
|
||||
|
||||
sClient.a(fileInfoRequest).a(new Callback() {
|
||||
@Override
|
||||
public void a(Call call, IOException e) {
|
||||
handleFailure(deathFlag, listener, e, downloadedStickers, call, fileInfoRequest, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Call call, Response response) {
|
||||
if (deathFlag.up())
|
||||
return;
|
||||
|
||||
if (!response.h()) {
|
||||
retryRequest(call, fileInfoRequest, this);
|
||||
return;
|
||||
}
|
||||
|
||||
try (ResponseBody responseBody = response.a()) {
|
||||
JSONObject fileInfoResponse = new JSONObject(responseBody.g()).getJSONObject("result");
|
||||
String filePath = fileInfoResponse.getString("file_path");
|
||||
|
||||
if (botApiKey == null) botApiKey = "";
|
||||
|
||||
String fileDownloadUrl = String.format(BOT_API_BASE_FILE_URL, botApiKey, filePath);
|
||||
Request fileDownloadRequest = new Request.a()
|
||||
.b(fileDownloadUrl)
|
||||
.a();
|
||||
|
||||
sClient.a(fileDownloadRequest).a(new Callback() {
|
||||
@Override
|
||||
public void a(Call call, IOException e) {
|
||||
handleFailure(deathFlag, listener, e, downloadedStickers, call, fileDownloadRequest, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Call call, Response response) {
|
||||
if (deathFlag.up())
|
||||
return;
|
||||
|
||||
if (!response.h()) {
|
||||
retryRequest(call, fileDownloadRequest, this);
|
||||
return;
|
||||
}
|
||||
|
||||
try (ResponseBody responseBody = response.a()) {
|
||||
if (responseBody == null) {
|
||||
handleFailure(deathFlag, listener, new TSGException("Response body for a sticker is null :/"), downloadedStickers, call, fileDownloadRequest, this);
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream stickerInputStream = responseBody.a();
|
||||
Bitmap stickerImage = BitmapFactory.decodeStream(stickerInputStream);
|
||||
|
||||
if (stickerImage == null) {
|
||||
handleFailure(deathFlag, listener, new TSGException("Unable to decode sticker image"), downloadedStickers, call, fileDownloadRequest, this);
|
||||
return;
|
||||
}
|
||||
|
||||
File stickerFile = new File(packFolder, String.format(STICKER_FILE_NAME_FORMAT, stickerIndex));
|
||||
|
||||
try {
|
||||
saveStickerImage(stickerImage, stickerFile);
|
||||
} catch (TSGException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
listener.onStickerDownloaded(set.name, stickerFile, sticker.emoji, stickerIndex,
|
||||
downloadedStickers.value() + 1, set.stickers.size());
|
||||
downloadedStickers.increase();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
handleFailure(deathFlag, listener, e, downloadedStickers, call, fileInfoRequest, this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFailure(Flag deathFlag, PackDownloadListener listener, Exception e, GoalCounter downloadedStickers, Call call, Request request, Callback callback) {
|
||||
if ((e instanceof IOException || e instanceof TSGException) && retryCount.get() > MAX_RETRIES) {
|
||||
Log.e(TAG, "Unable to download sticker: " + e.getMessage());
|
||||
downloadedStickers.increase();
|
||||
return;
|
||||
} else if (retryCount.get() < MAX_RETRIES) {
|
||||
retryRequest(call, request, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
if (deathFlag.up()) {
|
||||
return;
|
||||
}
|
||||
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(e);
|
||||
}
|
||||
|
||||
private void retryRequest(Call call, Request request, Callback callback) {
|
||||
retryCount.incrementAndGet();
|
||||
|
||||
if (retryCount.get() > MAX_RETRIES) {
|
||||
Log.e(TAG, "retryRequest: max retries");
|
||||
callback.a(call, new IOException());
|
||||
} else {
|
||||
Log.e(TAG, "retryRequest");
|
||||
sClient.a(request).a(callback);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveStickerImage(Bitmap image, File file) throws TSGException {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
image.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
||||
} catch (IOException e) {
|
||||
throw new TSGException("Unable to save sticker image");
|
||||
}
|
||||
}
|
||||
|
||||
private void getPackInfo(String packName, File packFolder, String installedVersion, PackDownloadListener listener) {
|
||||
String getStickerSetUrl = String.format(GET_STICKER_SET_URL, botApiKey, packName);
|
||||
Request packInfoRequest = new Request.a()
|
||||
.b(getStickerSetUrl)
|
||||
.a();
|
||||
sClient.a(packInfoRequest).a(new Callback() {
|
||||
@Override
|
||||
public void onFailure(NetCall call, IOException e) {
|
||||
public void a(Call call, IOException e) {
|
||||
Log.d(TAG, e.getMessage());
|
||||
listener.onPackDownloadError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(NetCall call, NetResponse response) {
|
||||
if (!response.isSuccessful()) {
|
||||
if (response.getData() != null)
|
||||
listener.onPackDownloadError(new TSGException(response.getDataString() + "\nURL: " + call.request().url()));
|
||||
else
|
||||
listener.onPackDownloadError(new TSGException("Unknown Exception, no response body"));
|
||||
public void a(Call call, Response response) throws IOException {
|
||||
Log.d(TAG, response.toString());
|
||||
|
||||
if (!response.h()) {
|
||||
String errorMessage = response.a() != null ? response.a().g() + "\nURL: " + call.m0().g() : "Unknown Exception, no response body";
|
||||
listener.onPackDownloadError(new TSGException(errorMessage));
|
||||
return;
|
||||
}
|
||||
|
||||
StickerSet set;
|
||||
try {
|
||||
JSONObject jPackInfo = new JSONObject(response.getDataString()).getJSONObject("result");
|
||||
String packVersion = new String(sha256.digest(jPackInfo.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
try (ResponseBody responseBody = response.a()) {
|
||||
JSONObject packInfoResponse = new JSONObject(responseBody.g()).getJSONObject("result");
|
||||
String packVersion = new String(sha256.digest(packInfoResponse.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
|
||||
if (packVersion.equals(installedVersion)) {
|
||||
listener.onPackDownloaded(null, false);
|
||||
return;
|
||||
}
|
||||
|
||||
JSONArray jStickers = jPackInfo.getJSONArray("stickers");
|
||||
JSONArray stickersArray = packInfoResponse.getJSONArray(STICKERS_KEY);
|
||||
|
||||
if (jStickers.length() == 0) {
|
||||
if (stickersArray.length() == 0) {
|
||||
listener.onPackDownloadError(new TSGException("No stickers in pack"));
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Sticker> stickers = new ArrayList<>(jStickers.length());
|
||||
ArrayList<Sticker> stickers = parseStickers(stickersArray);
|
||||
|
||||
Log.d(TAG, String.format("Parsing stickers in pack %s", packName));
|
||||
StickerSet set = new StickerSet(packInfoResponse.getString(NAME_KEY), packInfoResponse.getString(TITLE_KEY), packVersion, stickers);
|
||||
|
||||
for (int i = 0; i < jStickers.length(); i++) {
|
||||
JSONObject jSticker = jStickers.getJSONObject(i);
|
||||
if (jSticker.optBoolean("is_animated") || jSticker.optBoolean("is_video")) {
|
||||
if (jSticker.has("thumb")) {
|
||||
stickers.add(new Sticker(jSticker.getJSONObject("thumb").getString("file_id"), jSticker.getString("emoji")));
|
||||
} else {
|
||||
listener.onPackDownloadError(new TSGException("Animated and video stickerpacks without thumbs are not supported!"));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
stickers.add(new Sticker(jSticker.getString("file_id"), jSticker.getString("emoji")));
|
||||
}
|
||||
if (!packFolder.exists() && !packFolder.mkdirs()) {
|
||||
// Handle the folder creation failure case
|
||||
listener.onPackDownloadError(new IOException("Can't create folder for the pack!"));
|
||||
return;
|
||||
}
|
||||
|
||||
set = new StickerSet(jPackInfo.getString("name"), jPackInfo.getString("title"), packVersion, stickers);
|
||||
Log.d(TAG, String.format("Got info for pack %s, now downloading stickers to %s", packName, packFolder.getAbsolutePath()));
|
||||
|
||||
TelegramStickersPackInfo packInfo = new TelegramStickersPackInfo(packName, set.name, set.stickers.size(), set.version);
|
||||
|
||||
listener.onGotPackInfo(packInfo);
|
||||
|
||||
getPack(set, packFolder, packInfo, listener);
|
||||
} catch (Exception e) {
|
||||
listener.onPackDownloadError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!packFolder.exists() && !packFolder.mkdirs()) {
|
||||
listener.onPackDownloadError(new IOException("Can't create folder for the pack!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, String.format("Got info for pack %s, now downloading stickers to %s", packName, packFolder.getAbsolutePath()));
|
||||
|
||||
TelegramStickersPackInfo packInfo = new TelegramStickersPackInfo(packName, set.name, set.stickers.size(), set.version);
|
||||
listener.onGotPackInfo(packInfo);
|
||||
getPack(set, packFolder, packInfo, listener);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getPack(final StickerSet set, final File packFolder, final TelegramStickersPackInfo packInfo, final PackDownloadListener listener) {
|
||||
final GoalCounter downloadedStickers = new GoalCounter(set.stickers.size(), () -> {
|
||||
Log.d(TAG, String.format("Pack %s has been downloaded to %s", set.id, packFolder.getAbsolutePath()));
|
||||
private ArrayList<Sticker> parseStickers(JSONArray stickersArray) throws JSONException, TSGException {
|
||||
ArrayList<Sticker> stickers = new ArrayList<>(stickersArray.length());
|
||||
|
||||
listener.onPackDownloaded(packInfo, true);
|
||||
});
|
||||
final Flag deathFlag = new Flag();
|
||||
for (int i = 0; i < stickersArray.length(); i++) {
|
||||
JSONObject stickerObject = stickersArray.getJSONObject(i);
|
||||
boolean isAnimated = stickerObject.optBoolean(IS_ANIMATED_KEY);
|
||||
boolean isVideo = stickerObject.optBoolean(IS_VIDEO_KEY);
|
||||
String fileId = stickerObject.getString(FILE_ID_KEY);
|
||||
String emoji = stickerObject.getString(EMOJI_KEY);
|
||||
|
||||
AtomicInteger retryed = new AtomicInteger();
|
||||
for (int i = 0; i < set.stickers.size(); i++) {
|
||||
final Sticker sticker = set.stickers.get(i);
|
||||
NetRequest fileInfoRequest = new NetRequest.Builder().get().url(String.format(GET_FILE_URL, botApiKey, sticker.fileId)).build();
|
||||
|
||||
final int stickerIndex = i + 1;
|
||||
|
||||
AtomicBoolean sync = new AtomicBoolean();
|
||||
httpClient.newCall(fileInfoRequest).enqueue(new NetCallback() {
|
||||
@Override
|
||||
public void onFailure(NetCall call, IOException e) {
|
||||
if (deathFlag.up())
|
||||
return;
|
||||
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(e);
|
||||
|
||||
sync.set(true);
|
||||
if (isAnimated || isVideo) {
|
||||
if (stickerObject.has(THUMB_KEY)) {
|
||||
fileId = stickerObject.getJSONObject(THUMB_KEY).getString(FILE_ID_KEY);
|
||||
} else {
|
||||
throw new TSGException("Animated and video stickerpacks without thumbs are not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(NetCall call, NetResponse response) throws IOException {
|
||||
if (deathFlag.up())
|
||||
return;
|
||||
|
||||
if (response.code() != 200) {
|
||||
retryed.incrementAndGet();
|
||||
|
||||
if (retryed.get() > 5)
|
||||
onFailure(call, new IOException());
|
||||
else httpClient.newCall(fileInfoRequest)
|
||||
.enqueue(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String filePath;
|
||||
try {
|
||||
JSONObject jFileInfo = new JSONObject(response.getDataString()).getJSONObject("result");
|
||||
filePath = jFileInfo.getString("file_path");
|
||||
} catch (Exception e) {
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(e);
|
||||
sync.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (botApiKey == null) botApiKey = "";
|
||||
|
||||
NetRequest fileDownloadRequest = new NetRequest.Builder().get().url(String.format(BOT_API_BASE_FILE_URL, botApiKey, filePath)).build();
|
||||
|
||||
httpClient.newCall(fileDownloadRequest).enqueue(new NetCallback() {
|
||||
@Override
|
||||
public void onFailure(NetCall call, IOException e) {
|
||||
if (deathFlag.up())
|
||||
return;
|
||||
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(e);
|
||||
|
||||
sync.set(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(NetCall call, NetResponse response) throws IOException {
|
||||
if (deathFlag.up())
|
||||
return;
|
||||
|
||||
if (response.code() != 200) {
|
||||
retryed.incrementAndGet();
|
||||
|
||||
if (retryed.get() > 5)
|
||||
onFailure(call, new IOException());
|
||||
else httpClient.newCall(fileDownloadRequest)
|
||||
.enqueue(this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.getData() == null) {
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(new TSGException("Response body for a sticker is null :/"));
|
||||
sync.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
InputStream stickerInputStream = response.getDataStream();
|
||||
|
||||
Bitmap stickerImage = BitmapFactory.decodeStream(stickerInputStream);
|
||||
|
||||
try {
|
||||
stickerInputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(e);
|
||||
sync.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (stickerImage == null) {
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(new TSGException("Unable to decode sticker image"));
|
||||
sync.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
File stickerFile = new File(packFolder, String.format("%03d.png", stickerIndex));
|
||||
|
||||
FileOutputStream fileOutputStream;
|
||||
try {
|
||||
fileOutputStream = new FileOutputStream(stickerFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(e);
|
||||
sync.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!stickerImage.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream)) {
|
||||
stickerImage.recycle();
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(new TSGException("Unable to compress sticker to a png file at path: " + stickerFile.getAbsolutePath()));
|
||||
sync.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
stickerImage.recycle();
|
||||
|
||||
try {
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
deathFlag.raise();
|
||||
listener.onPackDownloadError(e);
|
||||
sync.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
listener.onStickerDownloaded(set.name, stickerFile, sticker.emoji, stickerIndex, downloadedStickers.value() + 1, set.stickers.size());
|
||||
downloadedStickers.increase();
|
||||
|
||||
sync.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
while (!sync.get())
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e1) {
|
||||
}
|
||||
stickers.add(new Sticker(fileId, emoji));
|
||||
}
|
||||
|
||||
return stickers;
|
||||
}
|
||||
|
||||
private void runOnUiThread(Runnable r) {
|
||||
@@ -431,15 +345,13 @@ public class TelegramStickersGrabber {
|
||||
void onNetError();
|
||||
}
|
||||
|
||||
public class TSGException extends Exception {
|
||||
private static final long serialVersionUID = 7866915509988422944L;
|
||||
|
||||
public static class TSGException extends Exception {
|
||||
private TSGException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
private class StickerSet {
|
||||
private static class StickerSet {
|
||||
String id;
|
||||
String name;
|
||||
String version;
|
||||
@@ -453,7 +365,7 @@ public class TelegramStickersGrabber {
|
||||
}
|
||||
}
|
||||
|
||||
private class Sticker {
|
||||
private static class Sticker {
|
||||
String emoji;
|
||||
String fileId;
|
||||
|
||||
|
||||
@@ -130,9 +130,9 @@ public class BinaryResourceValue implements SerializableResource {
|
||||
*/
|
||||
public static final int SIZE = 8;
|
||||
|
||||
private final int size;
|
||||
private final Type type;
|
||||
private final int data;
|
||||
public int size;
|
||||
public Type type;
|
||||
public int data;
|
||||
|
||||
public static BinaryResourceValue create(ByteBuffer buffer) {
|
||||
int size = (buffer.getShort() & 0xFFFF);
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.vk.api.base.ApiRequest;
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
import com.vk.log.L;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.music.Genius;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import b.h.v.InitialValueObservable;
|
||||
import b.h.v.TextViewTextChangeEvent;
|
||||
import b.h.v.TextViewTextChangeEventObservable;
|
||||
import com.vk.core.util.ContextExtKt;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
|
||||
public final class TextViewExt {
|
||||
public static void a(TextView textView, Drawable drawable) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vk.dto.common.VerifyInfo;
|
||||
import com.vk.extensions.ViewExtKt;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
|
||||
|
||||
public final class VerifyInfoHelper {
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.vk.im.engine.models.dialogs.Dialog;
|
||||
import com.vk.im.engine.models.groups.Group;
|
||||
import com.vk.im.engine.utils.DialogPermissionHelper;
|
||||
import com.vk.im.ui.p.ImBridge7;
|
||||
import ru.vtosters.lite.dialogs.DialogMenuInjectors;
|
||||
import ru.vtosters.hooks.DialogMenuInjectors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.vk.im.ui.views.msg.MsgPartIconTwoRowView;
|
||||
import com.vtosters.lite.R;
|
||||
import kotlin.TypeCastException;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
import ru.vtosters.lite.hooks.CallsHook;
|
||||
import ru.vtosters.hooks.CallsHook;
|
||||
|
||||
public final class MsgPartCallHolder extends MsgPartHolderBase<AttachCall> {
|
||||
public static final a I = new a();
|
||||
|
||||
@@ -39,7 +39,7 @@ import com.vk.im.ui.views.avatars.AvatarView;
|
||||
import com.vk.im.ui.views.avatars.StoryBorderView;
|
||||
|
||||
import static com.vk.im.ui.d.vkim_administration_title;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
import static ru.vtosters.hooks.other.ThemesUtils.getAccentColor;
|
||||
|
||||
public class DialogItemView extends ViewGroup {
|
||||
private final int B;
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.CompressFormat;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@@ -0,0 +1,502 @@
|
||||
package com.vk.medianative;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.os.Process;
|
||||
import android.os.*;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Scanner;
|
||||
|
||||
public final class MediaNative {
|
||||
private static final String a = NativeMediaEncoder.class.getSimpleName();
|
||||
private static final Object f17443d = new Object();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Keep
|
||||
public static volatile Context context;
|
||||
private static boolean isMediaLoaded = false;
|
||||
private static boolean isMediaMasksLoaded = false;
|
||||
|
||||
public static int HSLToIntRGB(float f2, float f3, float f4) {
|
||||
int[] iArr = new int[3];
|
||||
waitForContext();
|
||||
nativeHSLToRGB(f2, f3, f4, iArr);
|
||||
return Color.argb(255, iArr[0], iArr[1], iArr[2]);
|
||||
}
|
||||
|
||||
public static void HSLToRGB(float f2, float f3, float f4, int[] iArr) {
|
||||
waitForContext();
|
||||
nativeHSLToRGB(f2, f3, f4, iArr);
|
||||
}
|
||||
|
||||
public static int HSVToIntRGB(float f2, float f3, float f4) {
|
||||
int[] iArr = new int[3];
|
||||
waitForContext();
|
||||
nativeHSVToRGB(f2, f3, f4, iArr);
|
||||
return Color.argb(255, iArr[0], iArr[1], iArr[2]);
|
||||
}
|
||||
|
||||
public static void HSVToRGB(float f2, float f3, float f4, int[] iArr) {
|
||||
waitForContext();
|
||||
nativeHSVToRGB(f2, f3, f4, iArr);
|
||||
}
|
||||
|
||||
public static int LabToIntRGB(float f2, float f3, float f4) {
|
||||
int[] iArr = new int[3];
|
||||
waitForContext();
|
||||
nativeLabToRGB(f2, f3, f4, iArr);
|
||||
return Color.argb(255, iArr[0], iArr[1], iArr[2]);
|
||||
}
|
||||
|
||||
public static void LabToRGB(float f2, float f3, float f4, int[] iArr) {
|
||||
waitForContext();
|
||||
nativeLabToRGB(f2, f3, f4, iArr);
|
||||
}
|
||||
|
||||
public static void RGBToHSL(int i, int i2, int i3, float[] fArr) {
|
||||
waitForContext();
|
||||
nativeRGBToHSL(i, i2, i3, fArr);
|
||||
}
|
||||
|
||||
public static void RGBToHSV(int i, int i2, int i3, float[] fArr) {
|
||||
waitForContext();
|
||||
nativeRGBToHSV(i, i2, i3, fArr);
|
||||
}
|
||||
|
||||
public static void RGBToLab(int i, int i2, int i3, float[] fArr) {
|
||||
waitForContext();
|
||||
nativeRGBToLab(i, i2, i3, fArr);
|
||||
}
|
||||
|
||||
public static long animationPlayerCreate(String str, int i, int i2, boolean z) {
|
||||
waitForContext();
|
||||
return nativeAnimationPlayerCreate(str, i, i2, z);
|
||||
}
|
||||
|
||||
public static int animationPlayerDecode(long j, Bitmap bitmap) {
|
||||
waitForContext();
|
||||
return nativeAnimationPlayerDecode(j, bitmap);
|
||||
}
|
||||
|
||||
public static int animationPlayerGetSize(long j) {
|
||||
waitForContext();
|
||||
return nativeAnimationPlayerGetSize(j);
|
||||
}
|
||||
|
||||
public static void animationPlayerRelease(long j) {
|
||||
waitForContext();
|
||||
nativeAnimationPlayerRelease(j);
|
||||
}
|
||||
|
||||
public static boolean animationPlayerSeek(long j, int i) {
|
||||
waitForContext();
|
||||
return nativeAnimationPlayerSeek(j, i);
|
||||
}
|
||||
|
||||
public static void applyCurveAndSaturationBitmap(Bitmap bitmap, int[] iArr, float f2) {
|
||||
waitForContext();
|
||||
nativeCurveSaturation(bitmap, iArr, f2, Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public static long audioGetTotalPcmDuration() {
|
||||
waitForContext();
|
||||
return nativeAudioGetTotalPcmDuration();
|
||||
}
|
||||
|
||||
public static byte[] audioGetWaveform(short[] sArr, int i) {
|
||||
waitForContext();
|
||||
return nativeAudioGetWaveform(sArr, i);
|
||||
}
|
||||
|
||||
public static int audioIsOpusFile(String str) {
|
||||
waitForContext();
|
||||
return nativeAudioIsOpusFile(str);
|
||||
}
|
||||
|
||||
public static void audioReadOpusFile(ByteBuffer byteBuffer, int i, int[] iArr) {
|
||||
waitForContext();
|
||||
nativeAudioReadOpusFile(byteBuffer, i, iArr);
|
||||
}
|
||||
|
||||
public static int audioSeekOpusFile(float f2) {
|
||||
waitForContext();
|
||||
return nativeAudioSeekOpusFile(f2);
|
||||
}
|
||||
|
||||
public static int audioStartRecord(String str) { // need to hack
|
||||
waitForContext();
|
||||
return nativeAudioStartRecord(str);
|
||||
}
|
||||
|
||||
public static void audioStopRecord() { // need to hack
|
||||
waitForContext();
|
||||
nativeAudioStopRecord();
|
||||
}
|
||||
|
||||
public static int audioWriteFrame(ByteBuffer byteBuffer, int i) { // need to hack
|
||||
waitForContext();
|
||||
return nativeAudioWriteFrame(byteBuffer, i);
|
||||
}
|
||||
|
||||
private static void waitForContext() {
|
||||
synchronized (f17443d) {
|
||||
if (context == null) {
|
||||
try {
|
||||
f17443d.wait();
|
||||
} catch (InterruptedException e2) {
|
||||
Log.e(a, "Interrupted while waiting for context", e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void blurBitmap(Bitmap bitmap, int i) {
|
||||
waitForContext();
|
||||
nativeBlur(bitmap, i);
|
||||
}
|
||||
|
||||
private static String c() {
|
||||
return getProcMaps(String.valueOf(Process.myPid()));
|
||||
}
|
||||
|
||||
public static void cameraProcessorCreate() {
|
||||
waitForContext();
|
||||
nativeProcessorCreate();
|
||||
}
|
||||
|
||||
public static boolean cameraProcessorDo(byte[] bArr, long[] jArr) {
|
||||
waitForContext();
|
||||
return nativeProcessorDo(bArr, jArr);
|
||||
}
|
||||
|
||||
public static int cameraProcessorGetVersion() {
|
||||
waitForContext();
|
||||
return nativeProcessorGetVersion();
|
||||
}
|
||||
|
||||
public static boolean cameraProcessorInit(String str, int i, int i2) {
|
||||
waitForContext();
|
||||
return nativeProcessorInit(str, i, i2);
|
||||
}
|
||||
|
||||
public static boolean cameraProcessorLoad(String str, boolean z) {
|
||||
waitForContext();
|
||||
return nativeProcessorLoad(str, z);
|
||||
}
|
||||
|
||||
public static void cameraProcessorMouseTap(int i, float f2, float f3) {
|
||||
waitForContext();
|
||||
nativeProcessorMouseTap(i, f2, f3);
|
||||
}
|
||||
|
||||
public static void cameraProcessorRelease() {
|
||||
waitForContext();
|
||||
nativeProcessorRelease();
|
||||
}
|
||||
|
||||
public static void colorCorrectionBitmap(Bitmap bitmap, Bitmap bitmap2, float[] fArr) {
|
||||
waitForContext();
|
||||
nativeColorCorrection(bitmap, bitmap2, fArr, fArr.length, Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public static byte[] compressBitmapJpeg(Bitmap bitmap, int i) {
|
||||
waitForContext();
|
||||
return nativeJpegTurboCompress(bitmap, i);
|
||||
}
|
||||
|
||||
public static String createAllInOneShader() {
|
||||
waitForContext();
|
||||
return nativeAllInOneShader();
|
||||
}
|
||||
|
||||
public static void createCurve(int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4, int[] iArr5, float f2, float f3, float f4, float f5, float f6) {
|
||||
waitForContext();
|
||||
nativeCreateCurve(iArr, iArr2, iArr3, iArr4, iArr5, f2, f3, f4, f5, f6);
|
||||
}
|
||||
|
||||
public static String createOneInAllShader() {
|
||||
waitForContext();
|
||||
return nativeOneInAllShader();
|
||||
}
|
||||
|
||||
private static String d() {
|
||||
return getProcMaps("self");
|
||||
}
|
||||
|
||||
public static String dump() {
|
||||
return "LD_LIBRARY_PATH:\n" + SoLoader.makeLdLibraryPath() + "\nSELF_MAPS:\n" + d() + "\nPID_MAPS:\n" + c() + "\n";
|
||||
}
|
||||
|
||||
private static void e() {
|
||||
isMediaMasksLoaded = NativeLibLoader.loadLibrary("vkmediamasks");
|
||||
}
|
||||
|
||||
public static void enhanceBitmap(Bitmap bitmap, float f2) {
|
||||
waitForContext();
|
||||
nativeEnhance(bitmap, f2, Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
private static void loadVKMediaLibs() {
|
||||
if (isMediaLoaded) {
|
||||
return;
|
||||
}
|
||||
NativeLibLoader.loadLibrary("ffmpeg");
|
||||
isMediaLoaded = NativeLibLoader.loadLibrary("vkmedia");
|
||||
isMediaLoaded = NativeLibLoader.loadLibrary("vkmediaencoder");
|
||||
}
|
||||
|
||||
public static void flipHorizontallyBitmap(Bitmap bitmap) {
|
||||
waitForContext();
|
||||
nativeFlipHorizontally(bitmap);
|
||||
}
|
||||
|
||||
public static void flipVerticallyBitmap(Bitmap bitmap) {
|
||||
waitForContext();
|
||||
nativeFlipVertically(bitmap);
|
||||
}
|
||||
|
||||
public static void generateHistogram(Bitmap bitmap, int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4) {
|
||||
waitForContext();
|
||||
nativeHistogram(bitmap, iArr, iArr2, iArr3, iArr4);
|
||||
}
|
||||
|
||||
public static void init(Context context2) {
|
||||
synchronized (f17443d) {
|
||||
context = context2;
|
||||
SoLoader.init(context2, false);
|
||||
NativeLibLoader.loadLibrary("gnustl_shared");
|
||||
NativeLibLoader.loadLibrary("vkchronicle");
|
||||
loadVKMediaLibs();
|
||||
f17443d.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public static void intRGBToHSL(int i, float[] fArr) {
|
||||
waitForContext();
|
||||
nativeRGBToHSL(Color.red(i), Color.green(i), Color.blue(i), fArr);
|
||||
}
|
||||
|
||||
public static void intRGBToHSV(int i, float[] fArr) {
|
||||
waitForContext();
|
||||
nativeRGBToHSV(Color.red(i), Color.green(i), Color.blue(i), fArr);
|
||||
}
|
||||
|
||||
public static void intRGBToLab(int i, float[] fArr) {
|
||||
waitForContext();
|
||||
nativeRGBToLab(Color.red(i), Color.green(i), Color.blue(i), fArr);
|
||||
}
|
||||
|
||||
public static boolean isAsus() {
|
||||
return "asus".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
}
|
||||
|
||||
public static boolean isMediaSupported() {
|
||||
if (!isMediaMasksLoaded) {
|
||||
e();
|
||||
}
|
||||
return isMediaMasksLoaded;
|
||||
}
|
||||
|
||||
public static boolean isX86() {
|
||||
try {
|
||||
String str = Build.SUPPORTED_ABIS[0];
|
||||
if (str != null) {
|
||||
return str.startsWith("x86");
|
||||
}
|
||||
return false;
|
||||
} catch (Throwable unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void lookupBitmap(Bitmap bitmap, Bitmap bitmap2) {
|
||||
waitForContext();
|
||||
nativeLookup(bitmap, bitmap2, Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public static long mediaEncoderCreate(MediaEncoderSettings mediaEncoderSettings) {
|
||||
waitForContext();
|
||||
return nativeCreateEncoder(mediaEncoderSettings);
|
||||
}
|
||||
|
||||
public static int mediaEncoderDoEncode(long j) {
|
||||
waitForContext();
|
||||
return nativeDoEncode(j);
|
||||
}
|
||||
|
||||
public static void mediaEncoderDoRelease(long j) {
|
||||
waitForContext();
|
||||
nativeReleaseEncoder(j);
|
||||
}
|
||||
|
||||
private static native String nativeAllInOneShader();
|
||||
|
||||
private static native long nativeAnimationPlayerCreate(String str, int i, int i2, boolean z);
|
||||
|
||||
private static native int nativeAnimationPlayerDecode(long j, Bitmap bitmap);
|
||||
|
||||
private static native int nativeAnimationPlayerGetSize(long j);
|
||||
|
||||
private static native void nativeAnimationPlayerRelease(long j);
|
||||
|
||||
private static native boolean nativeAnimationPlayerSeek(long j, int i);
|
||||
|
||||
private static native long nativeAudioGetTotalPcmDuration();
|
||||
|
||||
private static native byte[] nativeAudioGetWaveform(short[] sArr, int i);
|
||||
|
||||
private static native int nativeAudioIsOpusFile(String str);
|
||||
|
||||
private static native int nativeAudioOpenOpusFile(String str);
|
||||
|
||||
private static native void nativeAudioReadOpusFile(ByteBuffer byteBuffer, int i, int[] iArr);
|
||||
|
||||
private static native int nativeAudioSeekOpusFile(float f2);
|
||||
|
||||
private static native int nativeAudioStartRecord(String str);
|
||||
|
||||
private static native void nativeAudioStopRecord();
|
||||
|
||||
private static native int nativeAudioWriteFrame(ByteBuffer byteBuffer, int i);
|
||||
|
||||
private static native void nativeBlur(Bitmap bitmap, int i);
|
||||
|
||||
private static native void nativeColorCorrection(Bitmap bitmap, Bitmap bitmap2, float[] fArr, int i, int i2);
|
||||
|
||||
private static native String nativeCreateColorCorrectionShader(float[] fArr, int i, int i2);
|
||||
|
||||
private static native void nativeCreateCurve(int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4, int[] iArr5, float f2, float f3, float f4, float f5, float f6);
|
||||
|
||||
private static native long nativeCreateEncoder(MediaEncoderSettings mediaEncoderSettings);
|
||||
|
||||
private static native void nativeCurveSaturation(Bitmap bitmap, int[] iArr, double d2, int i);
|
||||
|
||||
private static native int nativeDoEncode(long j);
|
||||
|
||||
private static native void nativeEnhance(Bitmap bitmap, double d2, int i);
|
||||
|
||||
private static native void nativeFlipHorizontally(Bitmap bitmap);
|
||||
|
||||
private static native void nativeFlipVertically(Bitmap bitmap);
|
||||
|
||||
private static native void nativeHSLToRGB(float f2, float f3, float f4, int[] iArr);
|
||||
|
||||
private static native void nativeHSVToRGB(float f2, float f3, float f4, int[] iArr);
|
||||
|
||||
private static native void nativeHistogram(Bitmap bitmap, int[] iArr, int[] iArr2, int[] iArr3, int[] iArr4);
|
||||
|
||||
private static native byte[] nativeJpegTurboCompress(Bitmap bitmap, int i);
|
||||
|
||||
private static native void nativeLabToRGB(float f2, float f3, float f4, int[] iArr);
|
||||
|
||||
private static native void nativeLookup(Bitmap bitmap, Bitmap bitmap2, int i);
|
||||
|
||||
private static native String nativeOneInAllShader();
|
||||
|
||||
private static native void nativePinBitmap(Bitmap bitmap);
|
||||
|
||||
private static native void nativeProcessorCreate();
|
||||
|
||||
private static native boolean nativeProcessorDo(byte[] bArr, long[] jArr);
|
||||
|
||||
private static native int nativeProcessorGetVersion();
|
||||
|
||||
private static native boolean nativeProcessorInit(String str, int i, int i2);
|
||||
|
||||
private static native boolean nativeProcessorLoad(String str, boolean z);
|
||||
|
||||
private static native void nativeProcessorMouseTap(int i, float f2, float f3);
|
||||
|
||||
private static native void nativeProcessorRelease();
|
||||
|
||||
private static native void nativeRGBToHSL(int i, int i2, int i3, float[] fArr);
|
||||
|
||||
private static native void nativeRGBToHSV(int i, int i2, int i3, float[] fArr);
|
||||
|
||||
private static native void nativeRGBToLab(int i, int i2, int i3, float[] fArr);
|
||||
|
||||
private static native void nativeReleaseEncoder(long j);
|
||||
|
||||
private static native void nativeResize(Bitmap bitmap, Bitmap bitmap2, int i);
|
||||
|
||||
public static int openOpusFile(String str) {
|
||||
waitForContext();
|
||||
return nativeAudioOpenOpusFile(str);
|
||||
}
|
||||
|
||||
public static void pinBitmap(Bitmap bitmap) {
|
||||
waitForContext();
|
||||
nativePinBitmap(bitmap);
|
||||
}
|
||||
|
||||
public static void resizeBitmap(Bitmap bitmap, Bitmap bitmap2) {
|
||||
waitForContext();
|
||||
nativeResize(bitmap, bitmap2, Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
private static String getProcMaps(String str) {
|
||||
try (InputStream inputStream = Runtime.getRuntime().exec("cat /proc/" + str + "/maps").getInputStream()) {
|
||||
return new Scanner(inputStream).useDelimiter("\\A").next();
|
||||
} catch (Exception e) {
|
||||
return "empty";
|
||||
}
|
||||
}
|
||||
|
||||
public static class EncoderHandler extends Handler {
|
||||
private Callback a;
|
||||
|
||||
public EncoderHandler(Looper looper) {
|
||||
super(looper);
|
||||
}
|
||||
|
||||
@Keep
|
||||
public static Object postEventFromNative(Object obj, int i, int i2, int i3) {
|
||||
EncoderHandler encoderHandler;
|
||||
if (obj != null && (encoderHandler = (EncoderHandler) ((WeakReference<?>) obj).get()) != null) {
|
||||
if (i == 2) {
|
||||
return encoderHandler.a.getLayerBitmap(i2, i3);
|
||||
}
|
||||
encoderHandler.sendMessage(encoderHandler.obtainMessage(i, i2, i3, null));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
Callback callback = this.a;
|
||||
if (callback == null) {
|
||||
return;
|
||||
}
|
||||
int i = message.what;
|
||||
if (i == 0) {
|
||||
callback.onBytes(message.arg1);
|
||||
} else if (i != 1) {
|
||||
String str = MediaNative.a;
|
||||
Log.e(str, "Unknown message type " + message.what);
|
||||
} else {
|
||||
callback.onProgress(message.arg1);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
this.a = callback;
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
@Nullable
|
||||
Bitmap getLayerBitmap(int i, int i2);
|
||||
|
||||
void onBytes(int i);
|
||||
|
||||
void onProgress(int i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@ import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.ViewUtils;
|
||||
import com.vtosters.lite.ui.MusicErrorViewHelper;
|
||||
import com.vtosters.lite.ui.holder.RecyclerHolder;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.music.Genius;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -18,12 +18,12 @@ import com.vk.imageloader.view.VKMultiImageView;
|
||||
import com.vk.navigation.NavigatorKeys;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.a0;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static b.h.z.f.roboto_medium;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
import static ru.vtosters.hooks.other.ThemesUtils.getAccentColor;
|
||||
|
||||
@UiThread
|
||||
public class TargetImageView extends VKMultiImageView {
|
||||
|
||||
@@ -4976,30 +4976,29 @@ public final class R {
|
||||
public static final int ic_deepl_logo_icon = 0x7f080bcb; // 2131233739
|
||||
public static final int ic_google_translate_logo = 0x7f080bcc; // 2131233740
|
||||
public static final int ic_yandex_translate_icon = 0x7f080bd1; // 2131233745
|
||||
public static final int microsoft = 0x7f080bd2; // 2131233746
|
||||
public static final int $splash__0 = 0x7f080bd2; // 2131233746
|
||||
public static final int roundmsg = 0x7f080bd3; // 2131233747
|
||||
public static final int tgs_entry_background = 0x7f080bd4; // 2131233748
|
||||
public static final int yandex = 0x7f080bd7; // 2131233751
|
||||
public static final int $splash__0 = 0x7f080bd8; // 2131233752
|
||||
public static final int $splash__1 = 0x7f080bd9; // 2131233753
|
||||
public static final int $splash__10 = 0x7f080bda; // 2131233754
|
||||
public static final int $splash__11 = 0x7f080bdb; // 2131233755
|
||||
public static final int $splash__12 = 0x7f080bdc; // 2131233756
|
||||
public static final int $splash__13 = 0x7f080bdd; // 2131233757
|
||||
public static final int $splash__14 = 0x7f080bde; // 2131233758
|
||||
public static final int $splash__15 = 0x7f080bdf; // 2131233759
|
||||
public static final int $splash__2 = 0x7f080be0; // 2131233760
|
||||
public static final int $splash__3 = 0x7f080be1; // 2131233761
|
||||
public static final int $splash__4 = 0x7f080be2; // 2131233762
|
||||
public static final int $splash__5 = 0x7f080be3; // 2131233763
|
||||
public static final int $splash__6 = 0x7f080be4; // 2131233764
|
||||
public static final int $splash__7 = 0x7f080be5; // 2131233765
|
||||
public static final int $splash__8 = 0x7f080be6; // 2131233766
|
||||
public static final int $splash__9 = 0x7f080be7; // 2131233767
|
||||
public static final int $splash__1 = 0x7f080bd8; // 2131233752
|
||||
public static final int $splash__10 = 0x7f080bd9; // 2131233753
|
||||
public static final int $splash__11 = 0x7f080bda; // 2131233754
|
||||
public static final int $splash__12 = 0x7f080bdb; // 2131233755
|
||||
public static final int $splash__13 = 0x7f080bdc; // 2131233756
|
||||
public static final int $splash__14 = 0x7f080bdd; // 2131233757
|
||||
public static final int $splash__15 = 0x7f080bde; // 2131233758
|
||||
public static final int $splash__2 = 0x7f080bdf; // 2131233759
|
||||
public static final int $splash__3 = 0x7f080be0; // 2131233760
|
||||
public static final int $splash__4 = 0x7f080be1; // 2131233761
|
||||
public static final int $splash__5 = 0x7f080be2; // 2131233762
|
||||
public static final int $splash__6 = 0x7f080be3; // 2131233763
|
||||
public static final int $splash__7 = 0x7f080be4; // 2131233764
|
||||
public static final int $splash__8 = 0x7f080be5; // 2131233765
|
||||
public static final int $splash__9 = 0x7f080be6; // 2131233766
|
||||
public static final int checker_background = 0x7f080be8; // 2131233768
|
||||
public static final int custom_thumb_selector = 0x7f080be9; // 2131233769
|
||||
public static final int custom_track_selector = 0x7f080bea; // 2131233770
|
||||
public static final int splash = 0x7f080beb; // 2131233771
|
||||
public static final int splash = 0x7f080bec; // 2131233772
|
||||
public static final int abc_control_background_material = 0x7f080032; // 2131230770
|
||||
public static final int ic_action_close = 0x7f080322; // 2131231522
|
||||
public static final int ic_camera_outline_28_new = 0x7f0803a0; // 2131231648
|
||||
@@ -6797,6 +6796,9 @@ public final class R {
|
||||
public static final int ic_telegram_24 = 0x7f080bcf; // 2131233743
|
||||
public static final int ic_telegram_outline_28 = 0x7f080bd0; // 2131233744
|
||||
public static final int vtlogo = 0x7f080bd6; // 2131233750
|
||||
public static final int bing = 0x7f080be7; // 2131233767
|
||||
public static final int sauceNAO = 0x7f080beb; // 2131233771
|
||||
public static final int tracemoe = 0x7f080bed; // 2131233773
|
||||
public static final int bg_music_play_button_white = 0x7f08015e; // 2131231070
|
||||
public static final int bg_poll_bg_thumb = 0x7f080181; // 2131231105
|
||||
public static final int bg_stickers_suggestions_left = 0x7f0801ad; // 2131231149
|
||||
@@ -19592,67 +19594,76 @@ public final class R {
|
||||
public static final int calls_not_available = 0x7f12184a; // 2131892298
|
||||
public static final int cannot_write = 0x7f12184b; // 2131892299
|
||||
public static final int change_accent_color = 0x7f12184c; // 2131892300
|
||||
public static final int copydebuginfo_summ = 0x7f12184d; // 2131892301
|
||||
public static final int copydebuginfo_title = 0x7f12184e; // 2131892302
|
||||
public static final int copyownlink_summ = 0x7f12184f; // 2131892303
|
||||
public static final int copyownlink_title = 0x7f121850; // 2131892304
|
||||
public static final int crash_service_name = 0x7f121851; // 2131892305
|
||||
public static final int currentLanguage = 0x7f121852; // 2131892306
|
||||
public static final int current_theme = 0x7f121853; // 2131892307
|
||||
public static final int custom_links_warning = 0x7f121854; // 2131892308
|
||||
public static final int data = 0x7f121855; // 2131892309
|
||||
public static final int data_updated = 0x7f121856; // 2131892310
|
||||
public static final int datasettings_title = 0x7f121857; // 2131892311
|
||||
public static final int device_info = 0x7f121858; // 2131892312
|
||||
public static final int device_info_copied = 0x7f121859; // 2131892313
|
||||
public static final int dialogstats = 0x7f12185a; // 2131892314
|
||||
public static final int disable_analytics = 0x7f12185b; // 2131892315
|
||||
public static final int disable_analytics_summ = 0x7f12185c; // 2131892316
|
||||
public static final int downloading_update = 0x7f12185d; // 2131892317
|
||||
public static final int error_applying_accent = 0x7f12185e; // 2131892318
|
||||
public static final int error_no_text = 0x7f12185f; // 2131892319
|
||||
public static final int error_saving_file = 0x7f121860; // 2131892320
|
||||
public static final int failed_to_get_text = 0x7f121861; // 2131892321
|
||||
public static final int invalid_pack_link = 0x7f121862; // 2131892322
|
||||
public static final int invalidate_theme_cache_title = 0x7f121863; // 2131892323
|
||||
public static final int logColors_title = 0x7f121864; // 2131892324
|
||||
public static final int maxquality_summ = 0x7f121865; // 2131892325
|
||||
public static final int maxquality_title = 0x7f121866; // 2131892326
|
||||
public static final int monettheme_summ = 0x7f121867; // 2131892327
|
||||
public static final int monettheme_title = 0x7f121868; // 2131892328
|
||||
public static final int newsfeed_notif_summ = 0x7f121869; // 2131892329
|
||||
public static final int newsfeed_notif_title = 0x7f12186a; // 2131892330
|
||||
public static final int open_bot = 0x7f12186b; // 2131892331
|
||||
public static final int promotedstickers_title = 0x7f12186c; // 2131892332
|
||||
public static final int remove_encryption_key = 0x7f12186d; // 2131892333
|
||||
public static final int remove_from_ads_stories_whitelist = 0x7f12186e; // 2131892334
|
||||
public static final int reset_accounts = 0x7f12186f; // 2131892335
|
||||
public static final int reset_all_settings = 0x7f121870; // 2131892336
|
||||
public static final int restore_accounts = 0x7f121871; // 2131892337
|
||||
public static final int restore_settings = 0x7f121872; // 2131892338
|
||||
public static final int save_accounts = 0x7f121873; // 2131892339
|
||||
public static final int save_online_data = 0x7f121874; // 2131892340
|
||||
public static final int select_color = 0x7f121875; // 2131892341
|
||||
public static final int select_palette = 0x7f121876; // 2131892342
|
||||
public static final int sources = 0x7f121877; // 2131892343
|
||||
public static final int storiesGroupsAdBlock = 0x7f121878; // 2131892344
|
||||
public static final int storiesGroupsAdBlocksummary = 0x7f121879; // 2131892345
|
||||
public static final int systemtheme = 0x7f12187a; // 2131892346
|
||||
public static final int systemtheme_enabled = 0x7f12187b; // 2131892347
|
||||
public static final int systemtheme_summ = 0x7f12187c; // 2131892348
|
||||
public static final int updateverifdata_summ = 0x7f12187d; // 2131892349
|
||||
public static final int updateverifdata_title = 0x7f12187e; // 2131892350
|
||||
public static final int useCustomPrefsStyle_summ = 0x7f12187f; // 2131892351
|
||||
public static final int useCustomPrefsStyle_title = 0x7f121880; // 2131892352
|
||||
public static final int useGenius_summ = 0x7f121881; // 2131892353
|
||||
public static final int useGenius_title = 0x7f121882; // 2131892354
|
||||
public static final int useNewColorEngine_summ = 0x7f121883; // 2131892355
|
||||
public static final int useNewColorEngine_title = 0x7f121884; // 2131892356
|
||||
public static final int useOldAppVer_summ = 0x7f121885; // 2131892357
|
||||
public static final int useOldAppVer_title = 0x7f121886; // 2131892358
|
||||
public static final int vkx_integration_enabled_info = 0x7f121887; // 2131892359
|
||||
public static final int whitelisted_ad_groups_stories_title = 0x7f121888; // 2131892360
|
||||
public static final int writebar_ios_title = 0x7f121889; // 2131892361
|
||||
public static final int compression_types = 0x7f12184d; // 2131892301
|
||||
public static final int compression_types_selection = 0x7f12184e; // 2131892302
|
||||
public static final int copydebuginfo_summ = 0x7f12184f; // 2131892303
|
||||
public static final int copydebuginfo_title = 0x7f121850; // 2131892304
|
||||
public static final int copyownlink_summ = 0x7f121851; // 2131892305
|
||||
public static final int copyownlink_title = 0x7f121852; // 2131892306
|
||||
public static final int crash_service_name = 0x7f121853; // 2131892307
|
||||
public static final int currentLanguage = 0x7f121854; // 2131892308
|
||||
public static final int current_theme = 0x7f121855; // 2131892309
|
||||
public static final int custom_links_warning = 0x7f121856; // 2131892310
|
||||
public static final int data = 0x7f121857; // 2131892311
|
||||
public static final int data_updated = 0x7f121858; // 2131892312
|
||||
public static final int datasettings_title = 0x7f121859; // 2131892313
|
||||
public static final int device_info = 0x7f12185a; // 2131892314
|
||||
public static final int device_info_copied = 0x7f12185b; // 2131892315
|
||||
public static final int dialogstats = 0x7f12185c; // 2131892316
|
||||
public static final int disable_analytics = 0x7f12185d; // 2131892317
|
||||
public static final int disable_analytics_summ = 0x7f12185e; // 2131892318
|
||||
public static final int downloading_update = 0x7f12185f; // 2131892319
|
||||
public static final int error_applying_accent = 0x7f121860; // 2131892320
|
||||
public static final int error_no_text = 0x7f121861; // 2131892321
|
||||
public static final int error_saving_file = 0x7f121862; // 2131892322
|
||||
public static final int failed_to_get_text = 0x7f121863; // 2131892323
|
||||
public static final int invalid_pack_link = 0x7f121864; // 2131892324
|
||||
public static final int invalidate_theme_cache_title = 0x7f121865; // 2131892325
|
||||
public static final int logColors_title = 0x7f121866; // 2131892326
|
||||
public static final int maxquality_summ = 0x7f121867; // 2131892327
|
||||
public static final int maxquality_title = 0x7f121868; // 2131892328
|
||||
public static final int microgsett = 0x7f121869; // 2131892329
|
||||
public static final int monettheme_summ = 0x7f12186a; // 2131892330
|
||||
public static final int monettheme_title = 0x7f12186b; // 2131892331
|
||||
public static final int newsfeed_notif_summ = 0x7f12186c; // 2131892332
|
||||
public static final int newsfeed_notif_title = 0x7f12186d; // 2131892333
|
||||
public static final int open_bot = 0x7f12186e; // 2131892334
|
||||
public static final int promotedstickers_title = 0x7f12186f; // 2131892335
|
||||
public static final int remove_encryption_key = 0x7f121870; // 2131892336
|
||||
public static final int remove_from_ads_stories_whitelist = 0x7f121871; // 2131892337
|
||||
public static final int reset_accounts = 0x7f121872; // 2131892338
|
||||
public static final int reset_all_settings = 0x7f121873; // 2131892339
|
||||
public static final int restore_accounts = 0x7f121874; // 2131892340
|
||||
public static final int restore_settings = 0x7f121875; // 2131892341
|
||||
public static final int save_accounts = 0x7f121876; // 2131892342
|
||||
public static final int save_online_data = 0x7f121877; // 2131892343
|
||||
public static final int select_color = 0x7f121878; // 2131892344
|
||||
public static final int select_palette = 0x7f121879; // 2131892345
|
||||
public static final int sources = 0x7f12187a; // 2131892346
|
||||
public static final int storiesGroupsAdBlock = 0x7f12187b; // 2131892347
|
||||
public static final int storiesGroupsAdBlocksummary = 0x7f12187c; // 2131892348
|
||||
public static final int systemtheme = 0x7f12187d; // 2131892349
|
||||
public static final int systemtheme_enabled = 0x7f12187e; // 2131892350
|
||||
public static final int systemtheme_summ = 0x7f12187f; // 2131892351
|
||||
public static final int updateverifdata_summ = 0x7f121880; // 2131892352
|
||||
public static final int updateverifdata_title = 0x7f121881; // 2131892353
|
||||
public static final int useCustomPrefsStyle_summ = 0x7f121882; // 2131892354
|
||||
public static final int useCustomPrefsStyle_title = 0x7f121883; // 2131892355
|
||||
public static final int useGenius_summ = 0x7f121884; // 2131892356
|
||||
public static final int useGenius_title = 0x7f121885; // 2131892357
|
||||
public static final int useNewColorEngine_summ = 0x7f121886; // 2131892358
|
||||
public static final int useNewColorEngine_title = 0x7f121887; // 2131892359
|
||||
public static final int useOldAppVer_summ = 0x7f121888; // 2131892360
|
||||
public static final int useOldAppVer_title = 0x7f121889; // 2131892361
|
||||
public static final int vkx_integration_enabled_info = 0x7f12188a; // 2131892362
|
||||
public static final int whitelisted_ad_groups_stories_title = 0x7f12188b; // 2131892363
|
||||
public static final int writebar_ios_title = 0x7f12188c; // 2131892364
|
||||
public static final int cache_size = 0x7f12188d; // 2131892365
|
||||
public static final int cache_size_summ = 0x7f12188e; // 2131892366
|
||||
public static final int clear_all_cache = 0x7f12188f; // 2131892367
|
||||
public static final int invalidate_theme_cache_each_update_title = 0x7f121890; // 2131892368
|
||||
public static final int invertFilters = 0x7f121891; // 2131892369
|
||||
public static final int invertFilters_summ = 0x7f121892; // 2131892370
|
||||
}
|
||||
|
||||
public static final class style {
|
||||
|
||||
@@ -0,0 +1,505 @@
|
||||
package com.vtosters.lite.api.execute;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.RectF;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import com.vk.api.base.utils.ApiUtils;
|
||||
import com.vk.core.network.Network;
|
||||
import com.vk.core.util.AppContextHolder;
|
||||
import com.vk.core.util.Screen;
|
||||
import com.vk.dto.common.data.VKList;
|
||||
import com.vk.dto.gift.GiftItem;
|
||||
import com.vk.dto.group.Group;
|
||||
import com.vk.dto.newsfeed.entries.ProfilesRecommendations;
|
||||
import com.vk.dto.photo.Photo;
|
||||
import com.vk.dto.user.UserProfile;
|
||||
import com.vk.dto.user.deactivation.UserDeactivation;
|
||||
import com.vtosters.lite.api.ExtendedUserProfile;
|
||||
import com.vtosters.lite.auth.VKAccountManager;
|
||||
import com.vtosters.lite.utils.Utils;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.hooks.OnlineFormatterHook;
|
||||
import ru.vtosters.hooks.RenameHook;
|
||||
import ru.vtosters.hooks.ssfs.ProfileHook;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.proxy.ProxyUtils;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GetFullUserProfile extends GetFullProfile<ExtendedUserProfile> {
|
||||
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
|
||||
|
||||
public GetFullUserProfile(int i, String str, String str2) {
|
||||
super(i, "execute.getFullProfileNewNew");
|
||||
i = i == 0 ? VKAccountManager.d().D0() : i;
|
||||
b("user_id", i);
|
||||
b("func_v", 23); // 11
|
||||
this.F = i;
|
||||
if (!TextUtils.isEmpty(str2)) {
|
||||
c("source", str2);
|
||||
}
|
||||
b("photo_sizes", 1);
|
||||
b("skip_hidden", 1);
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return;
|
||||
}
|
||||
c("access_keys", str);
|
||||
}
|
||||
|
||||
public JSONArray getCitiesNames(String ids) {
|
||||
var request = new Request.a()
|
||||
.b("https://" + ProxyUtils.getApi() + "/method/" + "database.getCitiesById"
|
||||
+ "?v=5.119"
|
||||
+ "&city_ids="
|
||||
+ ids
|
||||
+ "&access_token="
|
||||
+ AccountManagerUtils.getUserToken())
|
||||
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a();
|
||||
|
||||
try {
|
||||
return new JSONObject(mClient.a(request).execute().a().g()).getJSONArray("response");
|
||||
} catch (JSONException | IOException e) {
|
||||
Log.d(this.getClass().getSimpleName(), e.toString());
|
||||
}
|
||||
|
||||
return new JSONArray();
|
||||
}
|
||||
|
||||
public JSONArray getCountriesNames(String ids) {
|
||||
var request = new Request.a()
|
||||
.b("https://" + ProxyUtils.getApi() + "/method/" + "database.getCountriesById"
|
||||
+ "?v=5.119"
|
||||
+ "&country_ids="
|
||||
+ ids
|
||||
+ "&access_token="
|
||||
+ AccountManagerUtils.getUserToken())
|
||||
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a();
|
||||
|
||||
try {
|
||||
return new JSONObject(mClient.a(request).execute().a().g()).getJSONArray("response");
|
||||
} catch (JSONException | IOException e) {
|
||||
Log.d(this.getClass().getSimpleName(), e.toString());
|
||||
}
|
||||
|
||||
return new JSONArray();
|
||||
}
|
||||
|
||||
|
||||
protected ExtendedUserProfile o() {
|
||||
return new ExtendedUserProfile();
|
||||
}
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
public void a(ExtendedUserProfile extendedUserProfile, JSONObject jSONObject) throws JSONException {
|
||||
char c;
|
||||
RenameHook.injectIntoJson(jSONObject);
|
||||
JSONObject onlineHook = OnlineFormatterHook.onlineHook(jSONObject);
|
||||
UserProfile userProfile = extendedUserProfile.a;
|
||||
int i = onlineHook.getInt("id");
|
||||
this.F = i;
|
||||
userProfile.b = i;
|
||||
ProfileHook.fetchInfo(extendedUserProfile, onlineHook);
|
||||
|
||||
extendedUserProfile.a.c = onlineHook.getString("first_name");
|
||||
extendedUserProfile.a.e = onlineHook.getString("last_name");
|
||||
extendedUserProfile.a.d = extendedUserProfile.a.c + " " + extendedUserProfile.a.e;
|
||||
extendedUserProfile.a.f = onlineHook.getString(Screen.a() > 1.0f ? "photo_medium_rec" : "photo_rec");
|
||||
extendedUserProfile.a.h = onlineHook.getInt("friend_status") == 3;
|
||||
extendedUserProfile.j = onlineHook.optString("photo_max", onlineHook.getString("photo_medium_rec"));
|
||||
extendedUserProfile.m = onlineHook.optString("activity", "");
|
||||
extendedUserProfile.a.g = onlineHook.getInt("sex") == 1;
|
||||
extendedUserProfile.a.E = UserProfile.d(jSONObject);
|
||||
|
||||
if (onlineHook.has("crop_photo")) {
|
||||
extendedUserProfile.k = new Photo(onlineHook.getJSONObject("crop_photo").getJSONObject("photo"));
|
||||
JSONObject jSONObject2 = onlineHook.getJSONObject("crop_photo").getJSONObject("rect");
|
||||
JSONObject jSONObject3 = onlineHook.getJSONObject("crop_photo").getJSONObject("crop");
|
||||
double d = jSONObject3.getDouble("x");
|
||||
double d2 = jSONObject3.getDouble("x2");
|
||||
double d3 = jSONObject3.getDouble("y");
|
||||
double d4 = jSONObject3.getDouble("y2");
|
||||
double d5 = jSONObject2.getDouble("x");
|
||||
double d6 = jSONObject2.getDouble("x2");
|
||||
double d7 = jSONObject2.getDouble("y");
|
||||
double d8 = (d2 - d) / 100.0d;
|
||||
double d9 = (d4 - d3) / 100.0d;
|
||||
double d10 = (d / 100.0d) + ((d5 / 100.0d) * d8);
|
||||
double d11 = (d3 / 100.0d) + ((d7 / 100.0d) * d9);
|
||||
extendedUserProfile.l = new RectF((float) d10, (float) d11, (float) (d10 + (((d6 - d5) / 100.0d) * d8)), (float) (d11 + (((jSONObject2.getDouble("y2") - d7) / 100.0d) * d9)));
|
||||
}
|
||||
|
||||
SparseArray<String> sparseArray = new SparseArray<>();
|
||||
SparseArray<String> sparseArray2 = new SparseArray<>();
|
||||
|
||||
if (onlineHook.has("cities") && onlineHook.getJSONArray("cities").length() > 0) {
|
||||
List<String> cityNames = new ArrayList<>();
|
||||
|
||||
JSONArray cities = onlineHook.getJSONArray("cities");
|
||||
|
||||
for (int i21 = 0; i21 < cities.length(); i21++) {
|
||||
cityNames.add(cities.getString(i21));
|
||||
}
|
||||
|
||||
JSONArray citiesNamesJSONArray = getCitiesNames(String.join(", ", cityNames));
|
||||
|
||||
Log.d(this.getClass().getSimpleName(), citiesNamesJSONArray.toString());
|
||||
|
||||
for (int i22 = 0; i22 < citiesNamesJSONArray.length(); i22++) {
|
||||
JSONObject cityJSONObject = citiesNamesJSONArray.getJSONObject(i22);
|
||||
int cityid = cityJSONObject.getInt("id");
|
||||
String cityTitle = cityJSONObject.getString("title");
|
||||
sparseArray.put(cityid, cityTitle);
|
||||
}
|
||||
|
||||
extendedUserProfile.i0 = sparseArray.get(cities.getInt(0));
|
||||
}
|
||||
|
||||
if (onlineHook.has("countries") && onlineHook.getJSONArray("countries").length() > 0) {
|
||||
JSONArray countries = onlineHook.getJSONArray("countries");
|
||||
List<String> countryList = new ArrayList<>();
|
||||
|
||||
for (int i23 = 0; i23 < countries.length(); i23++) {
|
||||
countryList.add(countries.getString(i23));
|
||||
}
|
||||
|
||||
JSONArray countryInfo = getCountriesNames(String.join(", ", countryList));
|
||||
|
||||
Log.d(this.getClass().getSimpleName(), countryInfo.toString());
|
||||
|
||||
for (int i24 = 0; i24 < countryInfo.length(); i24++) {
|
||||
JSONObject country = countryInfo.getJSONObject(i24);
|
||||
int countryid = country.getInt("id");
|
||||
String countryTitle = country.getString("title");
|
||||
sparseArray2.put(countryid, countryTitle);
|
||||
}
|
||||
|
||||
extendedUserProfile.j0 = sparseArray2.get(countries.getInt(0));
|
||||
}
|
||||
|
||||
extendedUserProfile.U = onlineHook.getInt("can_write_private_message") == 1;
|
||||
extendedUserProfile.X = onlineHook.getInt("can_post") == 1;
|
||||
extendedUserProfile.Y = onlineHook.optInt("can_suggest") == 1;
|
||||
extendedUserProfile.V = onlineHook.optInt("can_see_all_posts") == 1;
|
||||
extendedUserProfile.f0 = onlineHook.optInt("can_see_archived_posts") == 1;
|
||||
extendedUserProfile.a0 = "all".equals(onlineHook.optString("wall_default"));
|
||||
extendedUserProfile.W = onlineHook.optBoolean("can_call", false);
|
||||
extendedUserProfile.Z = onlineHook.optInt("blacklisted_by_me") == 1;
|
||||
|
||||
if (onlineHook.optInt("blacklisted") == 1) {
|
||||
extendedUserProfile.Y0 = new ExtendedUserProfile.c();
|
||||
}
|
||||
|
||||
extendedUserProfile.u = onlineHook.optInt("relation");
|
||||
if (onlineHook.has("relation_partner")) {
|
||||
extendedUserProfile.v = onlineHook.getJSONObject("relation_partner").getInt("id");
|
||||
extendedUserProfile.w = onlineHook.getJSONObject("relation_partner").getString("first_name") + " " + onlineHook.getJSONObject("relation_partner").getString("last_name");
|
||||
}
|
||||
|
||||
if (onlineHook.has("bdate")) {
|
||||
String string = onlineHook.getString("bdate");
|
||||
extendedUserProfile.a.I = string;
|
||||
String[] split = string.split("\\.");
|
||||
extendedUserProfile.s = Integer.parseInt(split[0]);
|
||||
extendedUserProfile.t = Integer.parseInt(split[1]);
|
||||
if (split.length > 2) {
|
||||
extendedUserProfile.r = Integer.parseInt(split[2]);
|
||||
}
|
||||
}
|
||||
|
||||
extendedUserProfile.d = onlineHook.optString("first_name_dat", extendedUserProfile.a.c);
|
||||
extendedUserProfile.b = onlineHook.optString("first_name_gen", extendedUserProfile.a.c);
|
||||
extendedUserProfile.c = onlineHook.optString("first_name_ins", extendedUserProfile.a.c);
|
||||
extendedUserProfile.h = onlineHook.optString("first_name_acc", extendedUserProfile.a.c);
|
||||
extendedUserProfile.g = onlineHook.optString("last_name_dat", extendedUserProfile.a.e);
|
||||
extendedUserProfile.e = onlineHook.optString("last_name_gen", extendedUserProfile.a.e);
|
||||
extendedUserProfile.f = onlineHook.optString("last_name_ins", extendedUserProfile.a.e);
|
||||
|
||||
String optString = onlineHook.optString("last_name_acc", extendedUserProfile.a.e);
|
||||
extendedUserProfile.i = optString;
|
||||
|
||||
if (onlineHook.has("mobile_phone") && !onlineHook.getString("mobile_phone").isEmpty()) {
|
||||
extendedUserProfile.l0 = onlineHook.getString("mobile_phone");
|
||||
}
|
||||
|
||||
if (onlineHook.has("home_phone") && !onlineHook.getString("home_phone").isEmpty()) {
|
||||
extendedUserProfile.m0 = onlineHook.getString("home_phone");
|
||||
}
|
||||
|
||||
if (onlineHook.has("skype")) {
|
||||
extendedUserProfile.n0 = onlineHook.getString("skype");
|
||||
}
|
||||
|
||||
if (onlineHook.has("twitter")) {
|
||||
extendedUserProfile.o0 = onlineHook.getString("twitter");
|
||||
}
|
||||
|
||||
if (onlineHook.has("livejournal")) {
|
||||
extendedUserProfile.r0 = onlineHook.getString("livejournal");
|
||||
}
|
||||
|
||||
if (onlineHook.has("facebook") && onlineHook.optLong("facebook", -1L) != -1) {
|
||||
extendedUserProfile.q0 = onlineHook.getLong("facebook");
|
||||
extendedUserProfile.p0 = onlineHook.getString("facebook_name");
|
||||
}
|
||||
|
||||
if (onlineHook.has("instagram")) {
|
||||
extendedUserProfile.u0 = onlineHook.getString("instagram");
|
||||
}
|
||||
|
||||
extendedUserProfile.R0 = onlineHook.getInt("friend_status");
|
||||
JSONArray optJSONArray = onlineHook.optJSONArray("schools");
|
||||
extendedUserProfile.v0 = new ArrayList<>();
|
||||
|
||||
ArrayList arrayList = null;
|
||||
if (optJSONArray != null) {
|
||||
for (int i4 = 0; i4 < optJSONArray.length(); i4++) {
|
||||
ExtendedUserProfile.f fVar = new ExtendedUserProfile.f();
|
||||
JSONObject jSONObject6 = optJSONArray.getJSONObject(i4);
|
||||
fVar.c = sparseArray.get(jSONObject6.optInt(optString));
|
||||
fVar.a = jSONObject6.optString("name", "???");
|
||||
fVar.g = jSONObject6.optInt("year_from");
|
||||
fVar.f = jSONObject6.optInt("year_to");
|
||||
fVar.h = jSONObject6.optInt("year_graduated");
|
||||
fVar.b = jSONObject6.optString("class", null);
|
||||
fVar.d = jSONObject6.optString("speciality", null);
|
||||
fVar.e = jSONObject6.optString("type_str", AppContextHolder.a.getResources().getString(2131889117));
|
||||
extendedUserProfile.v0.add(fVar);
|
||||
}
|
||||
}
|
||||
extendedUserProfile.w0 = new ArrayList<>();
|
||||
|
||||
JSONArray optJSONArray2 = onlineHook.optJSONArray("universities");
|
||||
if (optJSONArray2 != null) {
|
||||
for (int i5 = 0; i5 < optJSONArray2.length(); i5++) {
|
||||
ExtendedUserProfile.g gVar = new ExtendedUserProfile.g();
|
||||
JSONObject jSONObject7 = optJSONArray2.getJSONObject(i5);
|
||||
gVar.a = jSONObject7.getString("name").trim();
|
||||
if (jSONObject7.has("faculty_name")) {
|
||||
gVar.b = jSONObject7.getString("faculty_name").trim();
|
||||
}
|
||||
if (jSONObject7.has("chair_name")) {
|
||||
gVar.c = jSONObject7.getString("chair_name").trim();
|
||||
}
|
||||
gVar.d = jSONObject7.optInt("graduation");
|
||||
extendedUserProfile.w0.add(gVar);
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineHook.has("interests") && onlineHook.getString("interests").length() > 0) {
|
||||
extendedUserProfile.y0 = onlineHook.getString("interests");
|
||||
}
|
||||
|
||||
if (onlineHook.has("movies") && onlineHook.getString("movies").length() > 0) {
|
||||
extendedUserProfile.A0 = onlineHook.getString("movies");
|
||||
}
|
||||
|
||||
if (onlineHook.has("music") && onlineHook.getString("music").length() > 0) {
|
||||
extendedUserProfile.z0 = onlineHook.getString("music");
|
||||
}
|
||||
|
||||
if (onlineHook.has("tv") && onlineHook.getString("tv").length() > 0) {
|
||||
extendedUserProfile.B0 = onlineHook.getString("tv");
|
||||
}
|
||||
|
||||
if (onlineHook.has("books") && onlineHook.getString("books").length() > 0) {
|
||||
extendedUserProfile.C0 = onlineHook.getString("books");
|
||||
}
|
||||
|
||||
if (onlineHook.has("games") && onlineHook.getString("games").length() > 0) {
|
||||
extendedUserProfile.D0 = onlineHook.getString("games");
|
||||
}
|
||||
|
||||
if (onlineHook.has("about") && onlineHook.getString("about").length() > 0) {
|
||||
extendedUserProfile.F0 = onlineHook.getString("about");
|
||||
}
|
||||
|
||||
if (onlineHook.has("quotes") && onlineHook.getString("quotes").length() > 0) {
|
||||
extendedUserProfile.E0 = onlineHook.getString("quotes");
|
||||
}
|
||||
|
||||
if (onlineHook.has("activities") && onlineHook.getString("activities").length() > 0) {
|
||||
extendedUserProfile.x0 = onlineHook.getString("activities");
|
||||
}
|
||||
|
||||
if (onlineHook.has("home_town") && onlineHook.getString("home_town").length() > 0) {
|
||||
extendedUserProfile.g0 = onlineHook.getString("home_town");
|
||||
}
|
||||
|
||||
if (onlineHook.has("site") && onlineHook.getString("site").length() > 0) {
|
||||
extendedUserProfile.M = onlineHook.getString("site");
|
||||
}
|
||||
|
||||
extendedUserProfile.a.Q.b(onlineHook);
|
||||
|
||||
JSONObject optJSONObject = onlineHook.optJSONObject("personal");
|
||||
if (optJSONObject != null) {
|
||||
JSONArray optJSONArray3 = optJSONObject.optJSONArray("langs");
|
||||
|
||||
if (optJSONArray3 != null) {
|
||||
ArrayList arrayList2 = new ArrayList<>();
|
||||
for (int i6 = 0; i6 < optJSONArray3.length(); i6++) {
|
||||
arrayList2.add(optJSONArray3.getString(i6));
|
||||
}
|
||||
extendedUserProfile.G0 = TextUtils.join(", ", arrayList2);
|
||||
}
|
||||
|
||||
extendedUserProfile.J0 = optJSONObject.optInt("political");
|
||||
extendedUserProfile.H0 = optJSONObject.optString("religion");
|
||||
extendedUserProfile.K0 = optJSONObject.optInt("life_main");
|
||||
extendedUserProfile.L0 = optJSONObject.optInt("people_main");
|
||||
extendedUserProfile.I0 = optJSONObject.optString("inspired_by");
|
||||
extendedUserProfile.M0 = optJSONObject.optInt("smoking");
|
||||
extendedUserProfile.N0 = optJSONObject.optInt("alcohol");
|
||||
}
|
||||
|
||||
SparseArray sparseArray3 = new SparseArray();
|
||||
JSONArray optJSONArray4 = onlineHook.optJSONArray("relatives_profiles");
|
||||
if (optJSONArray4 != null) {
|
||||
for (int i7 = 0; i7 < optJSONArray4.length(); i7++) {
|
||||
UserProfile userProfile2 = new UserProfile(optJSONArray4.getJSONObject(i7));
|
||||
sparseArray3.put(userProfile2.b, userProfile2);
|
||||
}
|
||||
}
|
||||
|
||||
JSONArray optJSONArray5 = onlineHook.optJSONArray("relatives");
|
||||
if (optJSONArray5 != null) {
|
||||
ArrayList arrayList3 = null;
|
||||
ArrayList arrayList4 = null;
|
||||
ArrayList arrayList5 = null;
|
||||
ArrayList arrayList6 = null;
|
||||
for (int i8 = 0; i8 < optJSONArray5.length(); i8++) {
|
||||
JSONObject jSONObject8 = optJSONArray5.getJSONObject(i8);
|
||||
int i9 = jSONObject8.getInt("id");
|
||||
if (ApiUtils.a(sparseArray3, i9)) {
|
||||
String valueOf = jSONObject8.getString("type");
|
||||
switch (valueOf.hashCode()) {
|
||||
case -995424086 -> {
|
||||
if (valueOf.equals("parent")) {
|
||||
c = 4;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
}
|
||||
case -268316490 -> {
|
||||
if (valueOf.equals("grandparent")) {
|
||||
c = 1;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
}
|
||||
case 94631196 -> {
|
||||
if (valueOf.equals("child")) {
|
||||
c = 2;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
}
|
||||
case 395180944 -> {
|
||||
if (valueOf.equals("grandchild")) {
|
||||
c = 0;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
}
|
||||
case 2083595970 -> {
|
||||
if (valueOf.equals("sibling")) {
|
||||
c = 3;
|
||||
break;
|
||||
}
|
||||
c = 65535;
|
||||
}
|
||||
default -> c = 65535;
|
||||
}
|
||||
switch (c) {
|
||||
case 0 -> arrayList6 = Utils.a(arrayList6, sparseArray3.get(i9));
|
||||
case 1 -> arrayList5 = Utils.a(arrayList5, sparseArray3.get(i9));
|
||||
case 2 -> arrayList4 = Utils.a(arrayList4, sparseArray3.get(i9));
|
||||
case 3 -> arrayList3 = Utils.a(arrayList3, sparseArray3.get(i9));
|
||||
case 4 -> arrayList = Utils.a(arrayList, sparseArray3.get(i9));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extendedUserProfile.A = Utils.a((ArrayList<UserProfile>) arrayList, UserProfile.CREATOR);
|
||||
extendedUserProfile.B = Utils.a((ArrayList<UserProfile>) arrayList3, UserProfile.CREATOR);
|
||||
extendedUserProfile.C = Utils.a((ArrayList<UserProfile>) arrayList4, UserProfile.CREATOR);
|
||||
extendedUserProfile.D = Utils.a((ArrayList<UserProfile>) arrayList5, UserProfile.CREATOR);
|
||||
extendedUserProfile.E = Utils.a((ArrayList<UserProfile>) arrayList6, UserProfile.CREATOR);
|
||||
}
|
||||
|
||||
JSONObject optJSONObject2 = onlineHook.optJSONObject("owner_state");
|
||||
if (optJSONObject2 != null) {
|
||||
extendedUserProfile.q = UserDeactivation.CREATOR.a(optJSONObject2);
|
||||
}
|
||||
|
||||
JSONObject optJSONObject3 = onlineHook.optJSONObject("gifts");
|
||||
if (optJSONObject3 != null) {
|
||||
extendedUserProfile.y1 = new VKList<>(optJSONObject3, GiftItem.C);
|
||||
}
|
||||
|
||||
JSONArray optJSONArray6 = onlineHook.optJSONArray("friends");
|
||||
if (optJSONArray6 != null) {
|
||||
extendedUserProfile.H = new ArrayList<>();
|
||||
for (int i10 = 0; i10 < optJSONArray6.length(); i10++) {
|
||||
extendedUserProfile.H.add(new UserProfile(optJSONArray6.getJSONObject(i10)));
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineHook.has("career")) {
|
||||
extendedUserProfile.I = new ArrayList<>();
|
||||
JSONArray jSONArray3 = onlineHook.getJSONArray("career");
|
||||
for (int i11 = 0; i11 < jSONArray3.length(); i11++) {
|
||||
JSONObject jSONObject9 = jSONArray3.getJSONObject(i11);
|
||||
ExtendedUserProfile.e eVar = new ExtendedUserProfile.e();
|
||||
if (jSONObject9.has("group")) {
|
||||
eVar.a = new Group(jSONObject9.getJSONObject("group"));
|
||||
} else {
|
||||
eVar.c = jSONObject9.getString("company");
|
||||
}
|
||||
eVar.e = jSONObject9.optInt("from");
|
||||
eVar.f = jSONObject9.optInt("until");
|
||||
eVar.d = jSONObject9.optString("position");
|
||||
extendedUserProfile.I.add(eVar);
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineHook.has("display_fields")) {
|
||||
JSONArray jSONArray4 = onlineHook.getJSONArray("display_fields");
|
||||
extendedUserProfile.j1 = new ArrayList<>();
|
||||
for (int i12 = 0; i12 < jSONArray4.length(); i12++) {
|
||||
extendedUserProfile.j1.add(jSONArray4.getString(i12));
|
||||
}
|
||||
}
|
||||
|
||||
extendedUserProfile.u1 = onlineHook.getBoolean("all_photos_are_hidden");
|
||||
JSONObject optJSONObject4 = onlineHook.optJSONObject("friends_recommendations");
|
||||
if (optJSONObject4 != null) {
|
||||
extendedUserProfile.J = getFriendsRecomms(optJSONObject4);
|
||||
}
|
||||
}
|
||||
|
||||
public ProfilesRecommendations getFriendsRecomms(JSONObject json) {
|
||||
try {
|
||||
Method method = ProfilesRecommendations.class.getDeclaredMethod("b", JSONObject.class);
|
||||
return (ProfilesRecommendations) method.invoke(null, json);
|
||||
} catch (Exception e) {
|
||||
Log.d(this.getClass().getSimpleName(), e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public GetFullProfile.a a(JSONObject jSONObject) {
|
||||
return super.a(jSONObject);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -26,8 +26,8 @@ import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vtosters.lite.R;
|
||||
import me.grishka.appkit.utils.V;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.vkme;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getCSTDock;
|
||||
import static ru.vtosters.hooks.other.Preferences.vkme;
|
||||
import static ru.vtosters.hooks.other.ThemesUtils.getCSTDock;
|
||||
|
||||
public class BottomNavigationItemView extends FrameLayout implements MenuView.ItemView {
|
||||
private final TextView mSmallLabel;
|
||||
|
||||
+7
-4
@@ -1,14 +1,17 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.view.View;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.VersionReader;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.devmenu;
|
||||
import static ru.vtosters.hooks.other.Preferences.getBuildName;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getApplicationName;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.devmenu;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBuildName;
|
||||
|
||||
public class About {
|
||||
public class AboutHook {
|
||||
public static void inject(View view) {
|
||||
view.setOnLongClickListener(v -> {
|
||||
if (devmenu()) {
|
||||
@@ -0,0 +1,21 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
|
||||
|
||||
public class AdBlockHook {
|
||||
public static JSONObject discoverInject(JSONObject json) throws JSONException {
|
||||
return NewsFeedFiltersUtils.discoverInject(json);
|
||||
}
|
||||
|
||||
public static JSONArray feedInject(JSONArray items) {
|
||||
return NewsFeedFiltersUtils.feedInject(items);
|
||||
|
||||
}
|
||||
|
||||
public static JSONObject storiesads(JSONObject json, boolean isDeleteFix) throws JSONException {
|
||||
return NewsFeedFiltersUtils.storiesads(json, isDeleteFix);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import b.h.g.g.BuildInfo;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class AppVerHook {
|
||||
public static int appBuild() {
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class BusinessNotifHook {
|
||||
public static boolean hook(boolean i) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -0,0 +1,27 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.hooks.music.injectors.CatalogJsonInjector;
|
||||
|
||||
public class CatalogsHook {
|
||||
public static JSONObject injectCatalogGetAudio(JSONObject json) {
|
||||
try {
|
||||
return CatalogJsonInjector.music(json);
|
||||
} catch (JSONException e) {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject injectCatalogGetAudioArtist(JSONObject json) {
|
||||
try {
|
||||
return CatalogJsonInjector.fixArtists(json);
|
||||
} catch (JSONException e) {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject injectCatalogGetSection(JSONObject json) {
|
||||
return CatalogJsonInjector.injectIntoCatalogs(json);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@@ -17,11 +17,11 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static ru.vtosters.lite.dialogs.DialogHeaderInjector.forceInvalidateDialogActions;
|
||||
import static ru.vtosters.hooks.DialogHeaderInjector.forceInvalidateDialogActions;
|
||||
import static ru.vtosters.hooks.other.ThemesUtils.getSTextAttr;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.getCurrentActivity;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
|
||||
public class CryptImHook {
|
||||
public static boolean isPrivateProcessor(int peerID) {
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import com.vtosters.lite.R;
|
||||
@@ -8,8 +8,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getStringDate;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
public class DateHook {
|
||||
public static boolean fulltime() {
|
||||
+7
-9
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentValues;
|
||||
@@ -12,18 +12,16 @@ import com.vk.im.engine.models.messages.NestedMsg;
|
||||
import com.vk.libsqliteext.CustomSqliteExtensionsKt;
|
||||
import io.requery.android.database.sqlite.SQLiteDatabase;
|
||||
import io.requery.android.database.sqlite.SQLiteOpenHelper;
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
import static ru.vtosters.hooks.other.Preferences.getString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
public class DeletedMessagesHandler {
|
||||
public class DeletedMessagesHook {
|
||||
private static List<Integer> sDeletedMessagesList = new ArrayList<>();
|
||||
|
||||
private static SQLiteDatabase sVKSQLiteDatabase;
|
||||
private static int sBodyIndex = -1;
|
||||
private static DeletedMessagesDBHelper sVTDatabase;
|
||||
@@ -60,13 +58,13 @@ public class DeletedMessagesHandler {
|
||||
for (NestedMsg nestedMsg : nestedMsgs) {
|
||||
if (!nestedMsg.w0().isEmpty()) checkForNestedMsg(nestedMsg.w0());
|
||||
|
||||
nestedMsg.d(EncryptProvider.decryptMessage(nestedMsg.f(), nestedMsg.getFrom().getId()));
|
||||
nestedMsg.d(EncryptionMessagesHook.decryptMessage(nestedMsg.f(), nestedMsg.getFrom().getId()));
|
||||
}
|
||||
}
|
||||
|
||||
private static void editTextOfMsg(MsgFromUser msgFromUser) {
|
||||
if (!msgFromUser.f().startsWith(getPrefixUndelete())) {
|
||||
msgFromUser.d(getPrefixUndelete() + EncryptProvider.decryptMessage(msgFromUser));
|
||||
msgFromUser.d(getPrefixUndelete() + EncryptionMessagesHook.decryptMessage(msgFromUser));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +85,7 @@ public class DeletedMessagesHandler {
|
||||
@SuppressLint("Range")
|
||||
int localId = cursor.getInt(cursor.getColumnIndex("local_id"));
|
||||
|
||||
var className = DeletedMessagesHandler.class.getSimpleName();
|
||||
var className = DeletedMessagesHook.class.getSimpleName();
|
||||
var imEnvironment = msgDeleteLpTask.b;
|
||||
var cint = msgDeleteLpTask.c;
|
||||
imEnvironment.a(className, new OnMsgUpdateEvent(className, cint, localId));
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.MD5;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class DeviceInfoHook {
|
||||
public static String getDeviceInfo(String input) {
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.dialogs;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Environment;
|
||||
@@ -8,11 +8,11 @@ import com.vk.im.engine.models.EntityIntMap;
|
||||
import com.vk.im.engine.models.dialogs.Dialog;
|
||||
import com.vk.im.ui.components.common.DialogAction;
|
||||
import com.vk.im.ui.views.dialog_actions.DialogActionsListView;
|
||||
import ru.vtosters.lite.dialogs.Requests;
|
||||
import ru.vtosters.lite.downloaders.messages.HtmlDialogDownloaderFormatProvider;
|
||||
import ru.vtosters.lite.downloaders.messages.MessagesDownloader;
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
import ru.vtosters.lite.hooks.CryptImHook;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -35,12 +35,12 @@ public class DialogHeaderInjector {
|
||||
forceInvalidateDialogActions(dialog);
|
||||
}
|
||||
case DNR_ON, DNR_OFF -> {
|
||||
DNRModule.hookDNR(peerId);
|
||||
MessagesActivityHook.hookDNR(peerId);
|
||||
forceInvalidateDialogActions(dialog);
|
||||
return true;
|
||||
}
|
||||
case DNT_ON, DNT_OFF -> {
|
||||
DNRModule.hookDNT(peerId);
|
||||
MessagesActivityHook.hookDNT(peerId);
|
||||
forceInvalidateDialogActions(dialog);
|
||||
return true;
|
||||
}
|
||||
@@ -84,13 +84,13 @@ public class DialogHeaderInjector {
|
||||
|
||||
actions.add(DialogAction.DOWNLOAD);
|
||||
|
||||
if (DNRModule.isDnrEnabledFor(peerId)) {
|
||||
if (MessagesActivityHook.isDnrEnabledFor(peerId)) {
|
||||
actions.add(DialogAction.DNR_OFF);
|
||||
} else {
|
||||
actions.add(DialogAction.DNR_ON);
|
||||
}
|
||||
|
||||
if (DNRModule.isDntEnabledFor(peerId)) {
|
||||
if (MessagesActivityHook.isDntEnabledFor(peerId)) {
|
||||
actions.add(DialogAction.DNT_OFF);
|
||||
} else {
|
||||
actions.add(DialogAction.DNT_ON);
|
||||
+6
-6
@@ -1,14 +1,14 @@
|
||||
package ru.vtosters.lite.dialogs;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.os.Environment;
|
||||
import com.vk.im.engine.models.dialogs.Dialog;
|
||||
import com.vk.im.ui.components.common.DialogAction;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.dialogs.Requests;
|
||||
import ru.vtosters.lite.downloaders.messages.HtmlDialogDownloaderFormatProvider;
|
||||
import ru.vtosters.lite.downloaders.messages.MessagesDownloader;
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
import ru.vtosters.lite.hooks.CryptImHook;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -30,9 +30,9 @@ public class DialogMenuInjectors {
|
||||
list.add(DialogAction.pinmsg);
|
||||
list.add(DialogAction.unpinmsg);
|
||||
|
||||
list.add(DNRModule.isDnrEnabledFor(peerId) ? DialogAction.DNR_OFF : DialogAction.DNR_ON);
|
||||
list.add(MessagesActivityHook.isDnrEnabledFor(peerId) ? DialogAction.DNR_OFF : DialogAction.DNR_ON);
|
||||
|
||||
list.add(DNRModule.isDntEnabledFor(peerId) ? DialogAction.DNT_OFF : DialogAction.DNT_ON);
|
||||
list.add(MessagesActivityHook.isDntEnabledFor(peerId) ? DialogAction.DNT_OFF : DialogAction.DNT_ON);
|
||||
|
||||
list.add(DialogAction.ENCRYPT);
|
||||
|
||||
@@ -83,11 +83,11 @@ public class DialogMenuInjectors {
|
||||
return true;
|
||||
}
|
||||
case DNR_ON, DNR_OFF -> {
|
||||
DNRModule.hookDNR(peerId);
|
||||
MessagesActivityHook.hookDNR(peerId);
|
||||
return true;
|
||||
}
|
||||
case DNT_ON, DNT_OFF -> {
|
||||
DNRModule.hookDNT(peerId);
|
||||
MessagesActivityHook.hookDNT(peerId);
|
||||
return true;
|
||||
}
|
||||
case pinmsg -> {
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package ru.vtosters.lite.dialogs;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.content.Context;
|
||||
import com.vk.im.engine.models.messages.Msg;
|
||||
import com.vk.im.engine.models.messages.MsgFromUser;
|
||||
import com.vk.im.ui.components.common.MsgAction;
|
||||
import com.vk.im.ui.components.viewcontrollers.popup.DelegateMsg;
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
import ru.vtosters.lite.dialogs.Requests;
|
||||
import ru.vtosters.lite.ui.dialogs.Translate;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DialogMessageInjector {
|
||||
var isTextExist = !text.isEmpty() && !text.equals(" ");
|
||||
|
||||
if (isTextExist) {
|
||||
Translate.showTranslatedText(context, EncryptProvider.decryptMessage(text, peerId));
|
||||
Translate.showTranslatedText(context, EncryptionMessagesHook.decryptMessage(text, peerId));
|
||||
} else {
|
||||
AndroidUtils.sendToast(context.getString(com.vtosters.lite.R.string.translator_no_text));
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.feature.discover;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.dto.discover.DiscoverItem;
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.Menu;
|
||||
@@ -24,10 +24,10 @@ import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
import static com.vtosters.lite.R.id.*;
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
import static ru.vtosters.hooks.other.ThemesUtils.getCSTDock;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getCSTDock;
|
||||
|
||||
public class DockBarInjector {
|
||||
private static final DockBarEditorManager sManager = DockBarEditorManager.getInstance();
|
||||
@@ -0,0 +1,40 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.content.Context;
|
||||
import com.vk.core.dialogs.bottomsheet.MenuBottomSheetAction;
|
||||
import com.vk.dto.common.VideoFile;
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
import com.vk.dto.stories.model.StoryEntry;
|
||||
import ru.vtosters.lite.downloaders.AudioDownloader;
|
||||
import ru.vtosters.lite.downloaders.StoryDownloader;
|
||||
import ru.vtosters.lite.downloaders.VideoDownloader;
|
||||
import ru.vtosters.lite.utils.ExternalLinkParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DownloadersHook {
|
||||
public static boolean onClickVideo(int id, VideoFile video, Context ctx) {
|
||||
if (id == VideoDownloader.DOWNLOAD_ID) {
|
||||
VideoDownloader.downloadVideo(video, ctx);
|
||||
return true;
|
||||
} else if (id == VideoDownloader.OPEN_EXTERNAL_LINK_ID) {
|
||||
ExternalLinkParser.parseVideoFile(video, ctx, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void injectActionVideo(ArrayList<MenuBottomSheetAction> list, VideoFile video) {
|
||||
if (!video.U && !video.I1()) {
|
||||
VideoDownloader.addAction(list, VideoDownloader.DOWNLOAD_ID, com.vtosters.lite.R.drawable.ic_download_outline_24, com.vtosters.lite.R.string.download, 9);
|
||||
VideoDownloader.addAction(list, VideoDownloader.OPEN_EXTERNAL_LINK_ID, com.vtosters.lite.R.drawable.ic_link_outline_28, com.vtosters.lite.R.string.interfacevideoext_short, 9);
|
||||
}
|
||||
}
|
||||
|
||||
public static Runnable injectActionStory(StoryEntry story) {
|
||||
return () -> StoryDownloader.downloadStory(story);
|
||||
}
|
||||
|
||||
public static void injectCacheAudio(MusicTrack mt) {
|
||||
AudioDownloader.cacheTrack(mt);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.util.Log;
|
||||
import com.vk.im.engine.models.messages.Msg;
|
||||
import com.vk.im.engine.models.messages.MsgFromUser;
|
||||
import com.vk.im.ui.components.msg_list.MsgListComponent;
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
|
||||
import static ru.vtosters.hooks.MessagesHook.injectOwnText;
|
||||
import static ru.vtosters.hooks.MessagesHook.injectOwnTextAll;
|
||||
|
||||
public class EncryptionMessagesHook {
|
||||
// For message editing
|
||||
public static String decryptMessage(MsgFromUser msg, boolean showEmoji) {
|
||||
var decryptedMessage = decryptMessage(EncryptProvider.getBody(msg), EncryptProvider.getPeerId(msg));
|
||||
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(EncryptProvider.getBody(msg))))
|
||||
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
return decryptedMessage;
|
||||
}
|
||||
|
||||
public static String decryptMessage(String msg, MsgListComponent list) {
|
||||
var peerid = list.G().getId();
|
||||
var decryptedMessage = decryptMessage(msg, peerid);
|
||||
if (!decryptedMessage.equals(injectOwnTextAll(msg)))
|
||||
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
return decryptedMessage;
|
||||
}
|
||||
|
||||
public static CharSequence decryptMessage(CharSequence msg, int peerid) {
|
||||
return decryptMessage(msg.toString(), peerid);
|
||||
}
|
||||
|
||||
public static CharSequence decryptMessage(Msg msg, CharSequence orig) {
|
||||
if (msg instanceof MsgFromUser) {
|
||||
var decrypted = decryptMessage(((MsgFromUser) msg).f(), msg.v1());
|
||||
|
||||
if (decrypted.contains("\uD83D\uDD12")) {
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return orig;
|
||||
}
|
||||
|
||||
public static String decryptMessages(String msgBody, int peer, boolean showEmoji) {
|
||||
return (String) decryptMessage(msgBody, peer, showEmoji);
|
||||
}
|
||||
|
||||
public static CharSequence decryptMessage(CharSequence msgBody, MsgFromUser msgFromUser, boolean showEmoji) {
|
||||
try {
|
||||
return decryptMessage((String) msgBody, msgFromUser.v1(), showEmoji);
|
||||
} catch (Exception e) {
|
||||
return decryptMessage((String) msgBody, 0, showEmoji);
|
||||
}
|
||||
}
|
||||
|
||||
// For MentionsFormatter that requires CharSequence
|
||||
public static CharSequence decryptMessage(String msgBody, int peer, boolean showEmoji) {
|
||||
var decryptedMessage = decryptMessage(msgBody, peer);
|
||||
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(msgBody)))
|
||||
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
return decryptedMessage;
|
||||
}
|
||||
|
||||
// This will run through EVERY single processor available.
|
||||
public static String decryptMessage(MsgFromUser msg) {
|
||||
return decryptMessage(EncryptProvider.getBody(msg), EncryptProvider.getPeerId(msg));
|
||||
}
|
||||
|
||||
public static String decryptMessage(String msgBody, int peer) {
|
||||
try {
|
||||
for (IMProcessor processor : EncryptProvider.processors) {
|
||||
if ((processor.isUsed() || !processor.isPublic()) && processor.isEncrypted(msgBody) && (processor.isPublic() || EncryptProvider.getKeyForProcessor(processor, peer) != null))
|
||||
return "\uD83D\uDD12 " + injectOwnTextAll(processor.decode(msgBody, EncryptProvider.getKeyForProcessor(processor, peer)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return injectOwnTextAll(msgBody);
|
||||
}
|
||||
|
||||
// This will use only the processor which was chosen in chat menu
|
||||
public static String encryptMessage(MsgFromUser msg) {
|
||||
String msgBody = EncryptProvider.getBody(msg);
|
||||
|
||||
Log.d("EncryptProvider", "encryptMessage: msg = " + msg);
|
||||
Log.d("EncryptProvider", "encryptMessage: body = " + msgBody);
|
||||
Log.d("EncryptProvider", "encryptMessage: peerId = " + EncryptProvider.getPeerId(msg));
|
||||
|
||||
for (IMProcessor processor : EncryptProvider.processors) {
|
||||
int peer = EncryptProvider.getPeerId(msg);
|
||||
if (processor.isUsedToEncrypt(peer)) {
|
||||
return injectOwnText(processor.encode(msgBody, EncryptProvider.getKeyForProcessor(processor, peer)));
|
||||
}
|
||||
}
|
||||
|
||||
return injectOwnText(msgBody);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getString;
|
||||
import static ru.vtosters.lite.ui.components.FragAnimationKit.setAnimations;
|
||||
import static ru.vtosters.lite.utils.Preferences.getString;
|
||||
|
||||
public class FragAnimationHook {
|
||||
public static boolean animateOpen(FragmentTransaction transaction) {
|
||||
+4
-8
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Base64;
|
||||
@@ -15,15 +15,12 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
|
||||
import static ru.vtosters.hooks.other.Preferences.isValidSignature;
|
||||
|
||||
|
||||
public class GcmHook {
|
||||
|
||||
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;
|
||||
|
||||
static {
|
||||
@@ -35,15 +32,15 @@ public class GcmHook {
|
||||
}
|
||||
|
||||
public static String requestToken(String orig) {
|
||||
return "yssp9o9p9pamz5t-nvmq8spgwtin3e0==";
|
||||
return isValidSignature() ? "yssp9o9p9pamz5t-nvmq8spgwtin3e0==" : requestToken();
|
||||
}
|
||||
|
||||
public static String requestToken() {
|
||||
String xappide;
|
||||
try {
|
||||
String aid = getRandomAid();
|
||||
String pub2 = genNewKey();
|
||||
String sig = getSig(pub2);
|
||||
String xappide;
|
||||
try {
|
||||
byte[] bytes = MessageDigest.getInstance("SHA1").digest(pair.getPublic().getEncoded());
|
||||
bytes[0] = (byte) (((bytes[0] & 15) + 112) & 255);
|
||||
@@ -200,7 +197,6 @@ public class GcmHook {
|
||||
}).getBytes(StandardCharsets.UTF_8));
|
||||
return Base64.encodeToString(sign.sign(), 0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+17
-6
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
@@ -6,10 +6,12 @@ import android.content.Context;
|
||||
import android.os.Build;
|
||||
import com.google.firebase.iid.FirebaseInstanceIdReceiver;
|
||||
import com.google.firebase.iid.FirebaseInstanceIdReceiver2;
|
||||
import com.google.firebase.iid.FirebaseInstanceIdReceiver3;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class GmsUtils {
|
||||
private static final boolean needToSpoof = !isGmsInstalled() && isFakeGmsInstalled();
|
||||
public class GmsHook {
|
||||
private static final boolean needToSpoof = !isGmsInstalled() && (isFakeGmsInstalled() || isFakeGms2Installed());
|
||||
|
||||
public static boolean isGmsInstalled() {
|
||||
try {
|
||||
@@ -29,8 +31,17 @@ public class GmsUtils {
|
||||
}
|
||||
} // Microg Google Market Services check
|
||||
|
||||
public static boolean isFakeGms2Installed() {
|
||||
try {
|
||||
AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo("app.revanced.android.gms", 0);
|
||||
return true;
|
||||
} catch (Exception unused) {
|
||||
return false;
|
||||
}
|
||||
} // Microg Google Market Services check
|
||||
|
||||
public static boolean isAnyServicesInstalled() {
|
||||
return isGmsInstalled() || isFakeGmsInstalled();
|
||||
return isGmsInstalled() || isFakeGmsInstalled() || isFakeGms2Installed();
|
||||
}
|
||||
|
||||
public static void fixGapps() {
|
||||
@@ -44,7 +55,7 @@ public class GmsUtils {
|
||||
} // Music channels fix
|
||||
|
||||
public static String replaceGMSPackage(String str) {
|
||||
return needToSpoof ? str.replaceAll("com.google", "com.mgoogle") : str;
|
||||
return needToSpoof ? str.replaceAll("com.google", (isFakeGms2Installed() ? "app.revanced" : "com.mgoogle")) : str;
|
||||
}
|
||||
|
||||
public static String getFirebaseInstanceIdReceiver() {
|
||||
@@ -52,6 +63,6 @@ public class GmsUtils {
|
||||
}
|
||||
|
||||
public static Class getFirebaseInstanceIdReceiverClass() {
|
||||
return needToSpoof ? FirebaseInstanceIdReceiver2.class : FirebaseInstanceIdReceiver.class;
|
||||
return needToSpoof ? (isFakeGms2Installed() ? FirebaseInstanceIdReceiver3.class : FirebaseInstanceIdReceiver2.class) : FirebaseInstanceIdReceiver.class;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.feature.groupslist;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.util.Log;
|
||||
import org.json.JSONArray;
|
||||
@@ -0,0 +1,39 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.utils.FriendsCatalogUtils;
|
||||
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
|
||||
import ru.vtosters.lite.utils.OnlineBypass;
|
||||
import ru.vtosters.lite.utils.SuperAppUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
public class JsonInjectors {
|
||||
public static JSONObject menu(JSONObject orig) throws JSONException {
|
||||
return SuperAppUtils.menu(orig);
|
||||
}
|
||||
|
||||
public static JSONObject superapp(JSONObject json) throws JSONException {
|
||||
return SuperAppUtils.superapp(json);
|
||||
}
|
||||
|
||||
|
||||
public static JSONObject setOnlineInfo(JSONObject json) throws JSONException {
|
||||
return OnlineBypass.setOnlineInfo(json);
|
||||
}
|
||||
|
||||
public static JSONArray setOnlineInfoUsers(JSONArray profiles) throws JSONException {
|
||||
return OnlineBypass.setOnlineInfoUsers(profiles);
|
||||
}
|
||||
|
||||
public static JSONArray newsfeedlist(JSONArray items) throws JSONException {
|
||||
return NewsFeedFiltersUtils.newsfeedlist(items);
|
||||
}
|
||||
|
||||
public static JSONObject friends(JSONObject json) throws JSONException, ParseException, IOException {
|
||||
return FriendsCatalogUtils.inject(json);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
import ru.vtosters.lite.music.LastFMScrobbler;
|
||||
|
||||
public class LastFMHook {
|
||||
public static void grabMusicTrack(MusicTrack musictrack) {
|
||||
LastFMScrobbler.grabMusicTrack(musictrack);
|
||||
}
|
||||
}
|
||||
+17
-10
@@ -1,32 +1,36 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import b.h.g.k.VKProgressDialog;
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
import ru.vtosters.hooks.ui.SystemThemeChangerHook;
|
||||
import ru.vtosters.lite.concurrent.VTExecutors;
|
||||
import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
|
||||
import ru.vtosters.lite.hooks.ui.SystemThemeChangerHook;
|
||||
import ru.vtosters.lite.ssfs.UsersList;
|
||||
import ru.vtosters.lite.themes.ThemesManager;
|
||||
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;
|
||||
import ru.vtosters.lite.utils.*;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.NavigatorUtils;
|
||||
import ru.vtosters.lite.utils.VTVerifications;
|
||||
|
||||
import static ru.vtosters.lite.ui.dialogs.ServerDialog.sendRequest;
|
||||
import static ru.vtosters.hooks.other.Preferences.checkupdates;
|
||||
import static ru.vtosters.lite.utils.CacheUtils.getInstance;
|
||||
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
|
||||
import static ru.vtosters.lite.utils.Preferences.checkupdates;
|
||||
|
||||
public class MainActivityInjector {
|
||||
public static void inject(Activity activity) {
|
||||
SystemThemeChangerHook.themeOnStart(activity);
|
||||
sendRequest();
|
||||
UsersList.getUsersList();
|
||||
VTVerifications.load(activity);
|
||||
|
||||
if (checkupdates()) OTADialog.checkUpdates(activity);
|
||||
|
||||
@@ -40,12 +44,14 @@ public class MainActivityInjector {
|
||||
NotificationChannels.createChannels();
|
||||
}
|
||||
|
||||
if (Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent() && ThemesUtils.useNewColorEngine()) {
|
||||
if (Preferences.isNewBuild()
|
||||
&& !ThemesUtils.isMonetTheme()
|
||||
&& ThemesManager.canApplyCustomAccent()) {
|
||||
Preferences.updateBuildNumber();
|
||||
updateBinsAndTmpArchive(activity);
|
||||
}
|
||||
|
||||
VTExecutors.getIoScheduler().a(DeletedMessagesHandler::reloadMessagesList); // ioScheduler
|
||||
VTExecutors.getIoScheduler().a(DeletedMessagesHook::reloadMessagesList); // ioScheduler
|
||||
|
||||
if (activity.getIntent().getAction() != null && Intent.ACTION_APPLICATION_PREFERENCES.equals(activity.getIntent().getAction())) {
|
||||
NavigatorUtils.switchToSettings(activity);
|
||||
@@ -54,8 +60,9 @@ public class MainActivityInjector {
|
||||
|
||||
Start.alert(activity);
|
||||
InstallGMS.alert(activity);
|
||||
DisableBattery.alert(activity);
|
||||
// VKIDProtection.alert(activity);
|
||||
//needs to show selected tgs pack count in settings after cold launch
|
||||
TelegramStickersService.getInstance(activity);
|
||||
}
|
||||
|
||||
private static void updateBinsAndTmpArchive(Activity activity) {
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.dialogs;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.im.engine.commands.messages.SetUserActivityCmd;
|
||||
import com.vk.im.engine.models.dialogs.Dialog;
|
||||
@@ -7,7 +7,7 @@ import ru.vtosters.lite.dialogs.helpers.DoNotTypeDBHelper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DNRModule {
|
||||
public class MessagesActivityHook {
|
||||
public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper();
|
||||
public static DoNotTypeDBHelper mDoNotTypeDBHelper = new DoNotTypeDBHelper();
|
||||
|
||||
+11
-2
@@ -1,9 +1,12 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import com.vk.api.internal.MethodCall;
|
||||
import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider;
|
||||
import com.vk.im.ui.providers.audiomsg.PlayerActionSources;
|
||||
import com.vtosters.lite.im.ImEngineProvider;
|
||||
import ru.vtosters.lite.translators.BaseTranslator;
|
||||
import ru.vtosters.lite.ui.dialogs.MessageSettings;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
@@ -11,9 +14,9 @@ import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
import static ru.vtosters.lite.ui.dialogs.MessageSettings.bombCount;
|
||||
import static ru.vtosters.lite.ui.dialogs.MessageSettings.isSilentEnabled;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
|
||||
public class MessagesHook {
|
||||
public static String injectOwnText(String oldText) {
|
||||
@@ -104,4 +107,10 @@ public class MessagesHook {
|
||||
default -> 0;
|
||||
};
|
||||
}
|
||||
|
||||
public static void reloadMessages() {
|
||||
ImEngineProvider.b().a();
|
||||
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
|
||||
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
|
||||
} // Delete and reload msg cache
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.vk.core.preference.Preference;
|
||||
import com.vk.discover.DiscoverItemDecorator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.Long.MAX_VALUE;
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class NewsfeedHook {
|
||||
public static long getUpdateNewsfeed(boolean refresh_timeout) {
|
||||
if (vkme()) {
|
||||
return MAX_VALUE;
|
||||
}
|
||||
return switch (getString("newsupdate")) {
|
||||
case "no_update" -> MAX_VALUE;
|
||||
case "imd_update" -> 10000L;
|
||||
default ->
|
||||
Preference.b().getLong(refresh_timeout ? "refresh_timeout_top" : "refresh_timeout_recent", 600000L);
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean samsungFixRem(RecyclerView recyclerView, DiscoverItemDecorator discoverItemDecorator) {
|
||||
if (!recyclerView.isComputingLayout() && recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
recyclerView.removeItemDecoration(discoverItemDecorator);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean samsungFixAdd(RecyclerView recyclerView, DiscoverItemDecorator discoverItemDecorator) {
|
||||
if (!recyclerView.isComputingLayout() && recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
recyclerView.addItemDecoration(discoverItemDecorator);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List hideElement(ArrayList list) {
|
||||
if (!getBoolValue("whatsnew", true)) {
|
||||
list.clear();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] feedParams() {
|
||||
HashSet<String> params = new HashSet<>();
|
||||
params.add("post");
|
||||
params.add("photo");
|
||||
params.add("photo_tag");
|
||||
|
||||
if (!friendsrecomm()) {
|
||||
params.add("friends_recomm");
|
||||
}
|
||||
|
||||
if (!ads()) {
|
||||
params.add("app_widget");
|
||||
params.add("promo_button");
|
||||
}
|
||||
|
||||
if (!authorsrecomm()) {
|
||||
params.add("authors_rec");
|
||||
}
|
||||
|
||||
return params.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static void adsParams(HashSet<String> hashSet) {
|
||||
if (ads()) {
|
||||
hashSet.add("ads_disabled");
|
||||
} else {
|
||||
hashSet.add("ads_app_slider");
|
||||
hashSet.add("ads_site_slider");
|
||||
}
|
||||
|
||||
hashSet.add("ads_app");
|
||||
hashSet.add("ads_site");
|
||||
hashSet.add("ads_post");
|
||||
hashSet.add("ads_app_video");
|
||||
hashSet.add("ads_post_pretty_cards");
|
||||
hashSet.add("ads_post_snippet_video");
|
||||
}
|
||||
|
||||
public static boolean isPowerSaveMode() {
|
||||
var pw = (PowerManager) getGlobalContext().getSystemService(Context.POWER_SERVICE);
|
||||
|
||||
// return !getBoolValue("force_disable_psm", false) && pw.isPowerSaveMode();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+29
-20
@@ -1,22 +1,21 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.util.Log;
|
||||
import com.vtosters.lite.R;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import static ru.vtosters.lite.hooks.JsonInjectors.setOnlineInfo;
|
||||
import static ru.vtosters.lite.hooks.JsonInjectors.setOnlineInfoUsers;
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
import static ru.vtosters.lite.net.Request.makeRequest;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
|
||||
public class OnlineFormatterHook {
|
||||
private static String AppName;
|
||||
@@ -71,6 +70,7 @@ public class OnlineFormatterHook {
|
||||
case 6614620 -> "Laney";
|
||||
case 5632485 -> "SpaceVK";
|
||||
case 6287487 -> "vk.com";
|
||||
case 8202606 -> "VK Me Web";
|
||||
case 4542624 -> "Black VK";
|
||||
case 3917910 -> "Miranda NG (bridge)";
|
||||
case 8043814 -> "Quise";
|
||||
@@ -116,17 +116,23 @@ public class OnlineFormatterHook {
|
||||
return AndroidUtils.getString(R.string.custom_online) + " " + appname;
|
||||
}
|
||||
|
||||
public static JSONObject onlineHook(JSONObject json) throws ParseException, IOException, JSONException {
|
||||
if (getBoolValue("onlinefix", false)) setOnlineInfo(json);
|
||||
public static JSONObject onlineHook(JSONObject json) {
|
||||
if (!getBoolValue("onlinefix", false) || Preferences.serverFeaturesDisable()) return json;
|
||||
|
||||
try {
|
||||
JsonInjectors.setOnlineInfo(json);
|
||||
} catch (JSONException e) {
|
||||
Log.e("onlineHook", e.getMessage());
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JSONArray onlineHookList(JSONArray jsonArr) throws ParseException, IOException, JSONException {
|
||||
if (!getBoolValue("onlinefix", false)) return jsonArr;
|
||||
public static JSONArray onlineHookList(JSONArray jsonArr) {
|
||||
if (!getBoolValue("onlinefix", false) || Preferences.serverFeaturesDisable()) return jsonArr;
|
||||
|
||||
try {
|
||||
setOnlineInfoUsers(jsonArr);
|
||||
JsonInjectors.setOnlineInfoUsers(jsonArr);
|
||||
} catch (Exception e) {
|
||||
Log.e("onlineHookProfiles", e.getMessage());
|
||||
}
|
||||
@@ -134,48 +140,51 @@ public class OnlineFormatterHook {
|
||||
return jsonArr;
|
||||
}
|
||||
|
||||
public static JSONObject onlineHookProfiles(JSONObject json) throws ParseException, IOException, JSONException {
|
||||
if (!getBoolValue("onlinefix", false)) return json;
|
||||
public static JSONObject onlineHookProfiles(JSONObject json) {
|
||||
if (!getBoolValue("onlinefix", false) || Preferences.serverFeaturesDisable()) return json;
|
||||
|
||||
try {
|
||||
setOnlineInfoUsers(json.optJSONArray("profiles"));
|
||||
JsonInjectors.setOnlineInfoUsers(json.optJSONArray("profiles"));
|
||||
} catch (Exception e) {
|
||||
Log.e("onlineHookProfiles", e.getMessage());
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JSONObject onlineHookItems(JSONObject json) throws ParseException, IOException, JSONException {
|
||||
if (!getBoolValue("onlinefix", false)) return json;
|
||||
public static JSONObject onlineHookItems(JSONObject json) {
|
||||
if (!getBoolValue("onlinefix", false) || Preferences.serverFeaturesDisable()) return json;
|
||||
|
||||
try {
|
||||
setOnlineInfoUsers(json.optJSONArray("items"));
|
||||
JsonInjectors.setOnlineInfoUsers(json.optJSONArray("items"));
|
||||
} catch (Exception e) {
|
||||
Log.e("onlineHookItems", e.getMessage());
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static JSONObject onlineHookRequestsAndRecommendations(JSONObject json) throws ParseException, IOException, JSONException {
|
||||
if (!getBoolValue("onlinefix", false)) return json;
|
||||
public static JSONObject onlineHookRequestsAndRecommendations(JSONObject json) {
|
||||
if (!getBoolValue("onlinefix", false) || Preferences.serverFeaturesDisable()) return json;
|
||||
|
||||
try {
|
||||
setOnlineInfoUsers(json.optJSONObject("read_requests").optJSONArray("items"));
|
||||
JsonInjectors.setOnlineInfoUsers(json.optJSONObject("read_requests").optJSONArray("items"));
|
||||
} catch (Exception e) {
|
||||
Log.e("onlineHookItems", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
setOnlineInfoUsers(json.optJSONObject("recommendations").optJSONArray("items"));
|
||||
JsonInjectors.setOnlineInfoUsers(json.optJSONObject("recommendations").optJSONArray("items"));
|
||||
} catch (Exception e) {
|
||||
Log.e("onlineHookItems", e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
setOnlineInfoUsers(json.optJSONArray("profiles"));
|
||||
JsonInjectors.setOnlineInfoUsers(json.optJSONArray("profiles"));
|
||||
} catch (Exception e) {
|
||||
Log.e("onlineHookItems", e.getMessage());
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
import androidx.core.content.FileProvider;
|
||||
import com.vk.core.dialogs.actionspopup.ActionsPopup;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vk.core.util.ToastUtils;
|
||||
import com.vk.dto.common.AttachmentWithMedia;
|
||||
import com.vk.dto.common.ImageSize;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.attachments.DocumentAttachment;
|
||||
import com.vtosters.lite.attachments.PhotoAttachment;
|
||||
import okhttp3.*;
|
||||
import okio.Okio;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.themes.utils.RecolorUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.SearchEngine;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class PhotoViewer {
|
||||
static OkHttpClient client = VtOkHttpClient.getInstance();
|
||||
|
||||
//region INSERTION INTO SMALI
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
public static void addMenuItems(AttachmentWithMedia attachment, ActionsPopup.b actionPopup, int i, boolean z) {
|
||||
actionPopup.a(
|
||||
R.string.copy,
|
||||
RecolorUtils.fixActionMenuIcons(R.drawable.ic_copy_outline_28),
|
||||
false,
|
||||
() -> {
|
||||
copyImage(attachment);
|
||||
return null;
|
||||
}
|
||||
).a(
|
||||
R.string.search_photo_content,
|
||||
RecolorUtils.fixActionMenuIcons(R.drawable.ic_menu_search_outline_28),
|
||||
false,
|
||||
() -> {
|
||||
searchImageWithUrl(attachment);
|
||||
return null;
|
||||
}
|
||||
).a(
|
||||
R.string.copy_photo_url_content,
|
||||
RecolorUtils.fixActionMenuIcons(R.drawable.ic_copy_outline_28),
|
||||
false,
|
||||
() -> {
|
||||
copyImageUrl(attachment);
|
||||
return null;
|
||||
}
|
||||
).a(
|
||||
R.string.open_original_photo_content,
|
||||
RecolorUtils.fixActionMenuIcons(R.drawable.ic_link_outline_28),
|
||||
false,
|
||||
() -> {
|
||||
openUrl(getImageUrlFromAttachment(attachment));
|
||||
return null;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
public static boolean interceptClick(AttachmentWithMedia attachment, MenuItem item, View view) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.copy_image -> copyImage(attachment);
|
||||
case R.id.search_photo -> searchImageWithUrl(attachment);
|
||||
case R.id.copy_photo_url -> copyImageUrl(attachment);
|
||||
case R.id.open_original_photo -> openUrl(getImageUrlFromAttachment(attachment));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//endregion
|
||||
|
||||
private static void copyImage(AttachmentWithMedia attachment) {
|
||||
var req = new Request.a()
|
||||
.b(getImageUrlFromAttachment(attachment))
|
||||
.a();
|
||||
client.a(req).a(new Callback() {
|
||||
@Override
|
||||
public void a(Call call, IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Call call, Response response)
|
||||
throws IOException {
|
||||
var tmpImage = new File(AndroidUtils.getGlobalContext().getExternalCacheDir(), attachment.getId() + ".jpg");
|
||||
try (var resp = client.a(req).execute();
|
||||
var sink = Okio.a(Okio.b(tmpImage))) {
|
||||
sink.a(resp.a().f());
|
||||
var manager = (ClipboardManager) AndroidUtils.getGlobalContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
var uri = FileProvider.getUriForFile(
|
||||
AndroidUtils.getGlobalContext(),
|
||||
"com.vtosters.lite.common.VKFileProvider",
|
||||
tmpImage);
|
||||
var data = ClipData.newUri(
|
||||
AndroidUtils.getGlobalContext().getContentResolver(),
|
||||
"image",
|
||||
uri);
|
||||
manager.setPrimaryClip(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void searchImageWithUrl(AttachmentWithMedia attachment) {
|
||||
String url = getImageUrlFromAttachment(attachment);
|
||||
if (TextUtils.isEmpty(url)) return;
|
||||
int selectedEngine = SearchEngine.getDefaultSearchEngine();
|
||||
if (selectedEngine < 0) {
|
||||
var items = new String[SearchEngine.values().length];
|
||||
for (int i = 0; i < SearchEngine.values().length; ++i)
|
||||
items[i] = SearchEngine.values()[i].mTitle;
|
||||
new VkAlertDialog.Builder(LifecycleUtils.getCurrentActivity())
|
||||
.setItems(items, (di, i) -> openUrl(SearchEngine.values()[i].buildSearchUrl(url)))
|
||||
.show();
|
||||
} else {
|
||||
// index correction for old versions with numeration "1-x"
|
||||
if (selectedEngine >= SearchEngine.values().length) SearchEngine.setDefaultSearchEngine(--selectedEngine);
|
||||
openUrl(SearchEngine.values()[selectedEngine].buildSearchUrl(url));
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyImageUrl(AttachmentWithMedia attachment) {
|
||||
String url = getImageUrlFromAttachment(attachment);
|
||||
if (TextUtils.isEmpty(url)) return;
|
||||
ClipboardManager manager = (ClipboardManager) AndroidUtils.getGlobalContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
manager.setPrimaryClip(ClipData.newPlainText("vk_photo_url", url));
|
||||
Toast.makeText(AndroidUtils.getGlobalContext(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private static void openUrl(String url) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
Log.d("PhotoViewer", "url is null or empty");
|
||||
return;
|
||||
}
|
||||
var intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
AndroidUtils.getGlobalContext().startActivity(intent);
|
||||
}
|
||||
|
||||
private static String getImageUrlFromAttachment(AttachmentWithMedia attachment) {
|
||||
List<ImageSize> imageSizes;
|
||||
|
||||
if (attachment instanceof PhotoAttachment) {
|
||||
imageSizes = ((PhotoAttachment) attachment).D.Q.t1();
|
||||
} else if (attachment instanceof DocumentAttachment && ((DocumentAttachment) attachment).J != null) {
|
||||
imageSizes = ((DocumentAttachment) attachment).J.t1();
|
||||
} else {
|
||||
ToastUtils.a(R.string.photo_get_error);
|
||||
return "";
|
||||
}
|
||||
|
||||
if (imageSizes.isEmpty()) return "";
|
||||
|
||||
var max = imageSizes.get(0);
|
||||
for (int i = 1; i < imageSizes.size(); i++) {
|
||||
var tmp = imageSizes.get(i);
|
||||
if (max.t1() < tmp.t1()) max = tmp;
|
||||
}
|
||||
return max.url;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.graphics.*;
|
||||
import com.facebook.drawee.generic.RoundingParams;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
public class PicRoundingHook {
|
||||
private static final int pref = Preferences.getPreferences().getInt("pic_rounding", 0);
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -6,7 +6,7 @@ import android.widget.TextView;
|
||||
import com.vk.dto.polls.PollOption;
|
||||
import com.vk.polls.ui.views.PollOptionView;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class PollHook {
|
||||
public static void show(PollOptionView view) {
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -6,7 +6,7 @@ import android.widget.RelativeLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.vk.newsfeed.holders.BaseFooterHolder;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
|
||||
public class PostViewHook {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.core.dialogs.actionspopup.ActionsPopup;
|
||||
import com.vk.profile.ui.components.CommunityFragmentActionsMenuBuilder;
|
||||
import com.vk.profile.ui.components.ProfileFragmentActionsMenuBuilder;
|
||||
import ru.vtosters.lite.ui.vkui.MenuBuilder;
|
||||
|
||||
public class ProfileMenuHook {
|
||||
public static void inject(final CommunityFragmentActionsMenuBuilder mb, final ActionsPopup.b builder) {
|
||||
MenuBuilder.injectAP(mb, builder);
|
||||
}
|
||||
|
||||
public static void inject(final ProfileFragmentActionsMenuBuilder mb, final ActionsPopup.b builder) {
|
||||
MenuBuilder.injectAP(mb, builder);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class PromoStickersHook {
|
||||
public static String hook() {
|
||||
+73
-3
@@ -1,7 +1,8 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.RadioButton;
|
||||
@@ -10,18 +11,87 @@ import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import com.vk.auth.ui.VkAuthTextView;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.proxy.api.VikaMobile;
|
||||
import ru.vtosters.lite.ui.fragments.DataSettingsFragment;
|
||||
import ru.vtosters.lite.ui.fragments.ProxySettingsFragment;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.NavigatorUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getString;
|
||||
import static ru.vtosters.hooks.other.ThemesUtils.getTextAttr;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
public class ProxyHook {
|
||||
public static String linkReplacer(String link) {
|
||||
var vkapi = "api.vk.com";
|
||||
var oauth = "oauth.vk.com";
|
||||
var vkstatic = "static.vk.com";
|
||||
|
||||
var proxyapi = getString("proxyapi");
|
||||
var proxyoauth = getString("proxyoauth");
|
||||
var proxystatic = getString("proxystatic");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
proxyapi = VikaMobile.getApiHost();
|
||||
proxyoauth = VikaMobile.getOauthHost();
|
||||
proxystatic = VikaMobile.getStaticHost();
|
||||
}
|
||||
|
||||
if (!isAnyProxyEnabled() || link.isEmpty()) {
|
||||
return link;
|
||||
}
|
||||
|
||||
if (proxyapi.isEmpty() || proxyoauth.isEmpty() || proxystatic.isEmpty()) {
|
||||
Log.d("VTLite", "Proxy is not set" + " " + proxyapi + " " + proxyoauth + " " + proxystatic);
|
||||
return link;
|
||||
}
|
||||
|
||||
if (link.contains(vkapi)) {
|
||||
return link.replaceAll(vkapi, proxyapi);
|
||||
}
|
||||
|
||||
if (link.contains(oauth)) {
|
||||
return link.replaceAll(oauth, proxyoauth);
|
||||
}
|
||||
|
||||
if (link.contains(vkstatic)) {
|
||||
return link.replaceAll(vkstatic, proxystatic);
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
public static String staticFix(String str) {
|
||||
var string = getString("proxystatic");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
string = VikaMobile.getStaticHost();
|
||||
}
|
||||
|
||||
if (isAnyProxyEnabled() && !string.isEmpty()) {
|
||||
return str.replaceAll(string, "static.vk.com");
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String getAwayPhpCom() {
|
||||
var proxyapi = getString("proxyapi");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
proxyapi = VikaMobile.getApiHost();
|
||||
}
|
||||
|
||||
if (isAnyProxyEnabled() && !proxyapi.isEmpty()) {
|
||||
return proxyapi;
|
||||
}
|
||||
|
||||
return "m.vk.com";
|
||||
}
|
||||
|
||||
public static void hookAuth(View v) {
|
||||
VkAuthTextView button = v.findViewById(AndroidUtils.getIdentifier("already_have_account", "id"));
|
||||
button.setText(R.string.proxy_setup);
|
||||
@@ -0,0 +1,29 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class RenameHook {
|
||||
public static void injectIntoJson(JSONObject obj) throws JSONException {
|
||||
// int i = obj.getInt("id");
|
||||
// if (RenameTool.updateRequested) {
|
||||
// RenameTool.reloadDB();
|
||||
// }
|
||||
//
|
||||
// Pair<String, String> user = RenameTool.renamedUsers.get(i);
|
||||
// if (user == null) return;
|
||||
// obj.put(RenameTool.COLUMN_FIRSTNAME, user.first).put(RenameTool.COLUMN_LASTNAME, user.second);
|
||||
}
|
||||
|
||||
public static void injectIntoJsonGroup(JSONObject obj) throws JSONException {
|
||||
// int i = obj.getInt("id");
|
||||
//
|
||||
// if (RenameTool.updateRequested) {
|
||||
// RenameTool.reloadDB();
|
||||
// }
|
||||
//
|
||||
// String user = RenameTool.renamedGroups.get(i);
|
||||
// if (user == null) return;
|
||||
// obj.put("name", user);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.im.engine.models.ProfilesSimpleInfo;
|
||||
import com.vk.im.engine.models.messages.MsgFromUser;
|
||||
import com.vk.im.engine.models.messages.NestedMsg;
|
||||
import com.vk.im.ui.views.ReplyView;
|
||||
|
||||
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
|
||||
import static ru.vtosters.hooks.EncryptionMessagesHook.decryptMessage;
|
||||
|
||||
public class ReplyMsgHook {
|
||||
public static void injectWithDecrypt(ReplyView replyView, MsgFromUser msgFromUser, ProfilesSimpleInfo profilesSimpleInfo, boolean someBool) {
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.util.Log;
|
||||
import com.vk.api.internal.MethodCall;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
import static ru.vtosters.hooks.other.Preferences.dev;
|
||||
|
||||
public class RequestDumper {
|
||||
public static void addParams(MethodCall.a paramslist, String method, LinkedHashMap<String, String> params, String apiver) {
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.apps.AppsFragment;
|
||||
import com.vk.discover.DiscoverFragment;
|
||||
@@ -23,8 +23,8 @@ import com.vtosters.lite.fragments.y2.VideoCatalogFragment;
|
||||
import com.vtosters.lite.general.fragments.GamesFragment;
|
||||
import com.vtosters.lite.general.fragments.PhotosFragment;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
import static ru.vtosters.lite.ui.components.DockBarEditorManager.getInstance;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
|
||||
public class StartFragmentHook {
|
||||
public static Class getStartFragment() {
|
||||
+6
-3
@@ -1,7 +1,6 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.adsstories;
|
||||
import static ru.vtosters.lite.utils.Preferences.stories;
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
|
||||
public class StoriesHook {
|
||||
public static String ads() {
|
||||
@@ -11,4 +10,8 @@ public class StoriesHook {
|
||||
public static boolean showstories() {
|
||||
return stories();
|
||||
}
|
||||
|
||||
public static boolean getStoriesRead() {
|
||||
return getBoolValue("read_s", false);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
@@ -10,9 +10,9 @@ import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.core.widget.CompoundButtonCompat;
|
||||
import com.vk.core.util.ColorUtils;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
import static com.vtosters.lite.R.color.*;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class TabletHook {
|
||||
public static boolean hook() {
|
||||
return AndroidUtils.isTablet() && !Preferences.getBoolValue("disableForceTabletMode", false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import com.aefyr.tsg.g2.TelegramStickersPack;
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
import com.vk.dto.common.Attachment;
|
||||
import com.vk.dto.stickers.StickerItem;
|
||||
import com.vk.dto.stickers.StickerStockItem;
|
||||
import com.vk.im.engine.models.attaches.Attach;
|
||||
import com.vtosters.lite.attachments.PendingGraffitiAttachment;
|
||||
import com.vtosters.lite.im.AppAttachToImAttachConverter;
|
||||
import com.vtosters.lite.upload.Upload;
|
||||
import ru.vtosters.lite.tgs.TGRoot;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class TelegramStickersHook {
|
||||
public static StickerStockItem getPackBySticker(int stickerId) {
|
||||
if (stickerId < TGRoot.N) return null;
|
||||
int index = (stickerId - TGRoot.N) / 120;
|
||||
|
||||
TelegramStickersPack p = null;
|
||||
for (TelegramStickersPack p_ : TelegramStickersService.getInstance(AndroidUtils.getGlobalContext())
|
||||
.getActivePacksListReference()) {
|
||||
if (p_.index == index) {
|
||||
p = p_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p == null) return null;
|
||||
|
||||
try {
|
||||
return TGRoot.toStickerPack(p);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Attachment processSticker(StickerItem item) {
|
||||
int id = item.getId();
|
||||
if (id < TGRoot.N) return null;
|
||||
|
||||
int index = (id - TGRoot.N) / 120;
|
||||
int stickerId = (id - TGRoot.N) % 120;
|
||||
|
||||
TelegramStickersPack pack = null;
|
||||
for (TelegramStickersPack p : TelegramStickersService.getInstance(getGlobalContext()).getActivePacksListReference()) {
|
||||
if (p.index == index) {
|
||||
pack = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String image = pack.getStickerFile(stickerId).getAbsolutePath();
|
||||
|
||||
Bitmap bm = BitmapFactory.decodeFile(image);
|
||||
int upid = Upload.a();
|
||||
TGRoot.pendingStickers.push(upid);
|
||||
|
||||
Attachment att = new PendingGraffitiAttachment(upid, 0, image, bm.getWidth(), bm.getHeight(), null);
|
||||
bm.recycle();
|
||||
|
||||
return att;
|
||||
}
|
||||
|
||||
public static void injectStickers(List<StickerStockItem> list) {
|
||||
try {
|
||||
List<TelegramStickersPack> packs = TelegramStickersService.getInstance(getGlobalContext()).getActivePacksListReference();
|
||||
for (int i = packs.size() - 1; i >= 0; i--)
|
||||
list.add(0, TGRoot.toStickerPack(packs.get(i)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Attach modifyStickerIM(int i, StickerItem stickerItem, String str) {
|
||||
if (stickerItem.getId() < 76820000) {
|
||||
return AppAttachToImAttachConverter.a.a(i, stickerItem, str);
|
||||
}
|
||||
return AppAttachToImAttachConverter.a.a(processSticker(stickerItem));
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.app.Activity;
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
|
||||
public class ThemeChanging {
|
||||
public class ThemeChangeDrawerHook {
|
||||
public static void changeTheme(Activity activity, float[] f) {
|
||||
if (Preferences.systemtheme()) {
|
||||
new VkAlertDialog.Builder(activity)
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.medianative.MediaImageEncoder;
|
||||
import com.vk.toggle.FeatureManager;
|
||||
import com.vk.toggle.Features;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
|
||||
public class TogglesHook {
|
||||
public static boolean shouldPatch(Features.Type feature) {
|
||||
@@ -0,0 +1,49 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.webkit.WebView;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
import ru.vtosters.lite.themes.ThemesCore;
|
||||
import ru.vtosters.lite.utils.WebViewColoringUtils;
|
||||
|
||||
import static android.util.Base64.encodeToString;
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class VKUIHook {
|
||||
public static void inject(WebView webView) {
|
||||
debugWebView(webView);
|
||||
applyVKUIStyles(webView);
|
||||
}
|
||||
|
||||
private static void debugWebView(WebView webView) {
|
||||
if (Preferences.getBoolValue("__dbg_webview", false)) {
|
||||
WebView.setWebContentsDebuggingEnabled(true);
|
||||
webView.evaluateJavascript("if (!window.eruda) {let parent = document.head || document.documentElement; let script = parent.appendChild(document.createElement('script')); script.src = 'https://cdn.jsdelivr.net/npm/eruda'; script.onload = () => eruda.init();}", null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyVKUIStyles(WebView webView) {
|
||||
if (getBoolValue("VKUI_INJ", true) && webView != null && webView.getUrl() != null && !webView.getUrl().contains("static.vk.com/memories")) {
|
||||
if (!WebViewColoringUtils.isLoaded) {
|
||||
WebViewColoringUtils.load();
|
||||
}
|
||||
loadAndApplyCSS(webView);
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadAndApplyCSS(WebView webView) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (ThemesCore.isCachedAccents()) {
|
||||
sb.append("\n\n");
|
||||
sb.append(WebViewColoringUtils.loadedCSS);
|
||||
}
|
||||
|
||||
if (ThemesUtils.isAmoledTheme()) {
|
||||
sb.append("\n\n");
|
||||
sb.append(WebViewColoringUtils.loadedCSSAmoled);
|
||||
}
|
||||
|
||||
WebViewColoringUtils.inject(webView, encodeToString(sb.toString().getBytes(), 2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.dto.common.VerifyInfo;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.utils.VTVerifications;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class VerificationsHook {
|
||||
public static boolean isVerified(int id) {
|
||||
return VTVerifications.sVerifications.contains(id);
|
||||
}
|
||||
|
||||
public static boolean vtverif() {
|
||||
return getBoolValue("VT_Verification", true);
|
||||
}
|
||||
|
||||
public static boolean isVerified(JSONObject jSONObject) {
|
||||
if (jSONObject.optInt("verified", 0) == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getBoolValue("VT_Verification", true) || Preferences.serverFeaturesDisable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isVerified(VTVerifications.getId(jSONObject));
|
||||
}
|
||||
|
||||
public static boolean hasPrometheus(JSONObject jSONObject) {
|
||||
if (jSONObject.optInt("trending", 0) == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getBoolValue("VT_Fire", true) || Preferences.serverFeaturesDisable()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return VTVerifications.isPrometheus(VTVerifications.getId(jSONObject));
|
||||
}
|
||||
|
||||
public static boolean hasDeveloper(JSONObject jSONObject) {
|
||||
return VTVerifications.isDeveloper(VTVerifications.getId(jSONObject));
|
||||
}
|
||||
|
||||
public static VerifyInfo VerifyInfo(JSONObject jSONObject) {
|
||||
return new VerifyInfo(isVerified(jSONObject), hasPrometheus(jSONObject));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import com.vk.dto.common.VideoFile;
|
||||
import ru.vtosters.lite.utils.ExternalLinkParser;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.isEnableExternalOpening;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class VideoPlayerHook {
|
||||
public static boolean parseVideoFile(VideoFile file) {
|
||||
return ExternalLinkParser.parseVideoFile(file, getGlobalContext(), isEnableExternalOpening());
|
||||
}
|
||||
|
||||
public static boolean parseVideoFile(VideoFile file, Context context) {
|
||||
return ExternalLinkParser.parseVideoFile(file, context, isEnableExternalOpening());
|
||||
}
|
||||
|
||||
public static boolean parseVideoFile(VideoFile file, Activity activity) {
|
||||
return ExternalLinkParser.parseVideoFile(file, activity, isEnableExternalOpening());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class VoiceMessagesHook {
|
||||
public static boolean getVoiceListened() {
|
||||
return getBoolValue("listen_v", false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import com.vk.im.engine.h;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
|
||||
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.getWallpaper;
|
||||
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.hasWallpapers;
|
||||
|
||||
public class WallpapersHooks {
|
||||
public static void setBg(View view) {
|
||||
if (hasWallpapers()) {
|
||||
((ImageView) view).setImageDrawable(getWallpaper()); // set picture to background
|
||||
} else {
|
||||
view.setBackgroundColor(ThemesUtils.getColorFromAttr(h.im_bg_chat)); // set default bg color
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -1,21 +1,18 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vk.api.base.ApiConfig;
|
||||
import com.vk.core.preference.Preference;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.proxy.api.ApiProxy;
|
||||
|
||||
public class WebAppUtils {
|
||||
|
||||
public class WebAppHook {
|
||||
public static JSONObject getWebAppConfig() throws JSONException {
|
||||
JSONObject jSONObject = new JSONObject()
|
||||
return new JSONObject()
|
||||
.put("scheme", VKThemeHelper.l().b())
|
||||
.put("app", "vkclient")
|
||||
.put("app_id", ApiConfig.a)
|
||||
.put("appearance", VKThemeHelper.l().a() ? "light" : "dark")
|
||||
.put("api_host", ApiProxy.linkReplacer(Preference.a().getString("apiHost", "api.vk.com")));
|
||||
return jSONObject;
|
||||
.put("api_host", ProxyHook.linkReplacer(Preference.a().getString("apiHost", "api.vk.com")));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
package ru.vtosters.hooks;
|
||||
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.wbios;
|
||||
import static ru.vtosters.hooks.other.Preferences.wbios;
|
||||
|
||||
public class WritebarHook {
|
||||
public static int getWriteBar() {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.music.hook;
|
||||
package ru.vtosters.hooks.music;
|
||||
|
||||
import android.content.Context;
|
||||
import com.vk.music.fragment.MusicFragment;
|
||||
+15
-33
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.music.hook;
|
||||
package ru.vtosters.hooks.music;
|
||||
|
||||
import android.os.RemoteException;
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClientImpl;
|
||||
@@ -8,45 +8,29 @@ import com.vk.music.bottomsheets.a.MusicAction;
|
||||
import com.vk.music.common.MusicPlaybackLaunchContext;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.downloaders.AudioDownloader;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.music.cache.MusicCacheImpl;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.music.VKXUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.*;
|
||||
import static ru.vtosters.lite.music.cache.CacheDatabaseDelegate.isCached;
|
||||
import static ru.vtosters.lite.music.cache.CacheDatabaseDelegate.isVkxCached;
|
||||
import static ru.vtosters.hooks.other.Preferences.milkshake;
|
||||
import static ru.vtosters.lite.utils.NetworkUtils.isNetworkConnected;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
|
||||
public class MusicBottomSheetHook {
|
||||
public static ArrayList<MusicAction> hook(ArrayList<MusicAction> actions, MusicTrack musicTrack) {
|
||||
public static ArrayList<MusicAction> hook(final ArrayList<MusicAction> actions, final MusicTrack musicTrack) {
|
||||
if (musicTrack.F1()) return actions;
|
||||
|
||||
var trackid = asId(musicTrack);
|
||||
|
||||
if (isVkxInstalled()) {
|
||||
actions.add(getPlayInVKXAction());
|
||||
}
|
||||
|
||||
final var trackId = asId(musicTrack);
|
||||
if (isVkxInstalled()) actions.add(getPlayInVKXAction());
|
||||
if (isIntegrationEnabled()) {
|
||||
if (isVkxCached(trackid)) {
|
||||
actions.add(getRemoveCacheTrackVkxAction());
|
||||
} else if (isNetworkConnected()) {
|
||||
actions.add(addToCacheTrackVkxAction());
|
||||
}
|
||||
if (VKXUtils.isVkxCached(trackId)) actions.add(getRemoveCacheTrackVkxAction());
|
||||
else if (isNetworkConnected()) actions.add(addToCacheTrackVkxAction());
|
||||
} else {
|
||||
if (isCached(trackid)) {
|
||||
actions.add(getRemoveCacheTrackAction());
|
||||
} else if (isNetworkConnected()) {
|
||||
actions.add(addToCacheTrackAction());
|
||||
}
|
||||
if (MusicCacheImpl.isCachedTrack(trackId)) actions.add(getRemoveCacheTrackAction());
|
||||
else if (isNetworkConnected()) actions.add(addToCacheTrackAction());
|
||||
}
|
||||
|
||||
if (isNetworkConnected()) {
|
||||
actions.add(downloadAsMp3Action());
|
||||
}
|
||||
|
||||
if (isNetworkConnected()) actions.add(downloadAsMp3Action());
|
||||
return actions;
|
||||
}
|
||||
|
||||
@@ -54,9 +38,7 @@ public class MusicBottomSheetHook {
|
||||
public static ArrayList<MusicAction> hookDownloadBTN(ArrayList<MusicAction> actions, MusicTrack musicTrack) {
|
||||
if (musicTrack.F1()) return actions;
|
||||
|
||||
var trackid = asId(musicTrack);
|
||||
|
||||
if (isCached(trackid)) {
|
||||
if (MusicCacheImpl.isCachedTrack(musicTrack.y1())) {
|
||||
actions.add(new MusicAction(
|
||||
R.id.music_action_toggle_download,
|
||||
milkshake() ? R.drawable.ic_delete_outline_28 : R.drawable.ic_delete_24,
|
||||
@@ -85,7 +67,7 @@ public class MusicBottomSheetHook {
|
||||
if (isVkxInstalled()) actions.add(getPlayInVKXAction());
|
||||
|
||||
if (isIntegrationEnabled()) {
|
||||
if (isVkxCached(playlist.a, playlist.b)) {
|
||||
if (VKXUtils.isVkxCached(playlist.a, playlist.b)) {
|
||||
actions.add(getRemoveCacheTrackVkxAction());
|
||||
} else if (isNetworkConnected()) {
|
||||
actions.add(addToCacheTrackVkxAction());
|
||||
@@ -124,7 +106,7 @@ public class MusicBottomSheetHook {
|
||||
}
|
||||
|
||||
if (actionId == R.id.remove_from_cache) {
|
||||
CacheDatabaseDelegate.removeTrackFromCache(asId(track));
|
||||
MusicCacheImpl.removeTrack(asId(track));
|
||||
AndroidUtils.sendToast(AndroidUtils.getString("audio_deleted_from_cache"));
|
||||
return true;
|
||||
} else if (actionId == R.id.add_to_cache) {
|
||||
@@ -0,0 +1,16 @@
|
||||
package ru.vtosters.hooks.music;
|
||||
|
||||
import ru.vtosters.lite.music.cache.MusicCacheImpl;
|
||||
import ru.vtosters.lite.utils.music.MusicCacheStorageUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class MusicCacheFilesHook {
|
||||
public static File getTrackFile(String trackId) {
|
||||
return MusicCacheStorageUtils.getTrackFile(trackId);
|
||||
}
|
||||
|
||||
public static boolean isTrackExist(String trackId) {
|
||||
return MusicCacheImpl.isCachedTrack(trackId);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.music.hook;
|
||||
package ru.vtosters.hooks.music;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.AttrRes;
|
||||
+64
-94
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.music.catalog.inject;
|
||||
package ru.vtosters.hooks.music.injectors;
|
||||
|
||||
import android.util.Log;
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
@@ -10,117 +10,56 @@ import okhttp3.Request;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.music.cache.MusicCacheImpl;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static ru.vtosters.lite.feature.groupslist.GroupsCatalogInjector.injectIntoCatalog;
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.hooks.GroupsCatalogInjector.injectIntoCatalog;
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.music.cache.helpers.PlaylistHelper.*;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class CatalogJsonInjector {
|
||||
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
|
||||
|
||||
public static JSONObject music(JSONObject json) throws JSONException {
|
||||
var catalog = json.optJSONObject("catalog");
|
||||
|
||||
JSONArray oldItems = null;
|
||||
|
||||
if (catalog != null) {
|
||||
oldItems = catalog.optJSONArray("sections");
|
||||
}
|
||||
|
||||
var oldItems = catalog != null ? catalog.optJSONArray("sections") : null;
|
||||
var useOldAppVer = getBoolValue("useOldAppVer", false);
|
||||
var isUsersCatalog = oldItems.optJSONObject(0).optString("url").equals("https://vk.com/audios" + getUserId() + "?section=" + (useOldAppVer ? "all" : "general"));
|
||||
var blocks = oldItems.optJSONObject(0).optJSONArray("blocks");
|
||||
|
||||
if (isUsersCatalog) {
|
||||
var blocks = oldItems.optJSONObject(0).optJSONArray("blocks");
|
||||
|
||||
if (isUsersCatalog && blocks != null) {
|
||||
if (!useOldAppVer) {
|
||||
fixDailyMix(blocks);
|
||||
if (blocks != null) {
|
||||
for (int i = 0; i < blocks.length(); i++) {
|
||||
var block = blocks.optJSONObject(i);
|
||||
var layout = block.optJSONObject("layout");
|
||||
if (layout != null) {
|
||||
var name = layout.optString("name");
|
||||
if (name.equals("header_extended")) {
|
||||
if (layout.has("top_title")) blocks.remove(i);
|
||||
try {
|
||||
layout.put("name", "header");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var playlists = fetchCatalogId("https://vk.com/audio?section=my_playlists");
|
||||
if (playlists != null) {
|
||||
var catalogarr = playlists.optJSONObject("catalog").optJSONArray("sections").optJSONObject(0);
|
||||
removeUnsupportedLayouts(blocks);
|
||||
|
||||
var title = catalogarr.optString("title");
|
||||
var id = catalogarr.optString("id");
|
||||
var url = catalogarr.optString("url");
|
||||
fetchCatalogId("https://vk.com/audio?section=my_playlists", oldItems);
|
||||
|
||||
Log.d("VKMusic", "Added " + title + " in music sections");
|
||||
fetchCatalogId("https://vk.com/audio?section=albums", oldItems);
|
||||
|
||||
oldItems.put(new JSONObject().put("id", id).put("title", title).put("url", url));
|
||||
}
|
||||
|
||||
var albums = fetchCatalogId("https://vk.com/audio?section=albums");
|
||||
if (albums != null) {
|
||||
var catalogarr = albums.optJSONObject("catalog").optJSONArray("sections").optJSONObject(0);
|
||||
|
||||
var title = catalogarr.optString("title");
|
||||
var id = catalogarr.optString("id");
|
||||
var url = catalogarr.optString("url");
|
||||
|
||||
Log.d("VKMusic", "Added " + title + " in music sections");
|
||||
|
||||
oldItems.put(new JSONObject().put("id", id).put("title", title).put("url", url));
|
||||
}
|
||||
|
||||
for (int i = 0; i < oldItems.length(); i++) {
|
||||
var item = oldItems.optJSONObject(i);
|
||||
var title = item.optString("title");
|
||||
var id = item.optString("id");
|
||||
var url = item.optString("url");
|
||||
var value = Preferences.getString("musicdefcatalog");
|
||||
|
||||
Log.d("VKMusic", "title: " + title + " id: " + id + " url: " + url + " value: " + value);
|
||||
|
||||
if (url.contains(value) && !value.isEmpty()) {
|
||||
catalog.put("default_section", id);
|
||||
Log.d("VKMusic", "Added " + title + " as default music section");
|
||||
}
|
||||
}
|
||||
setDefaultAudioPage(oldItems, catalog);
|
||||
}
|
||||
|
||||
if (CacheDatabaseDelegate.hasTracks() && !LibVKXClient.isIntegrationEnabled()) { // inj in playlist list
|
||||
if (!MusicCacheImpl.isEmpty() && !LibVKXClient.isIntegrationEnabled()) { // inj in playlist list
|
||||
var noPlaylists = !json.has("playlists");
|
||||
|
||||
if (noPlaylists) {
|
||||
json.put("playlists", new JSONArray().put(getPlaylist()));
|
||||
Log.d("catalogInjector", "added new pl");
|
||||
} else {
|
||||
try {
|
||||
json.optJSONArray("playlists").put(getPlaylist());
|
||||
Log.d("catalogInjector", "added to exist pl");
|
||||
} catch (Exception e) {
|
||||
Log.d("catalogInjector", e.toString());
|
||||
}
|
||||
json.optJSONArray("playlists").put(getPlaylist());
|
||||
Log.d("catalogInjector", "added to exist pl");
|
||||
}
|
||||
|
||||
if (blocks != null && (!useOldAppVer || noPlaylists)) {
|
||||
if (!useOldAppVer || noPlaylists) {
|
||||
var newBlocks = new JSONArray();
|
||||
|
||||
newBlocks
|
||||
@@ -152,9 +91,10 @@ public class CatalogJsonInjector {
|
||||
|
||||
fixDailyMix(blocks);
|
||||
|
||||
if (!isUsersCatalog || !CacheDatabaseDelegate.hasTracks() || LibVKXClient.isIntegrationEnabled()) {
|
||||
if (!isUsersCatalog || MusicCacheImpl.isEmpty() || LibVKXClient.isIntegrationEnabled()) {
|
||||
return; // early return if not users catalog or no tracks or integration enabled
|
||||
}
|
||||
|
||||
var noPlaylists = !json.has("playlists");
|
||||
|
||||
if (noPlaylists) {
|
||||
@@ -169,7 +109,7 @@ public class CatalogJsonInjector {
|
||||
}
|
||||
}
|
||||
|
||||
if (!useOldAppVer || noPlaylists) {
|
||||
if (!useOldAppVer && !noPlaylists) {
|
||||
var newBlocks = new JSONArray();
|
||||
|
||||
newBlocks
|
||||
@@ -237,14 +177,8 @@ public class CatalogJsonInjector {
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject fixArtists(JSONObject json) {
|
||||
|
||||
try {
|
||||
fixHeaders(json.getJSONObject("catalog").getJSONArray("sections").getJSONObject(0));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public static JSONObject fixArtists(JSONObject json) throws JSONException {
|
||||
fixHeaders(json.getJSONObject("catalog").getJSONArray("sections").getJSONObject(0));
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -284,9 +218,38 @@ public class CatalogJsonInjector {
|
||||
}
|
||||
}
|
||||
|
||||
private static JSONObject fetchCatalogId(String section) {
|
||||
if (section.isEmpty()) return null;
|
||||
private static void removeUnsupportedLayouts(JSONArray blocks) throws JSONException {
|
||||
for (int i = 0; i < blocks.length(); i++) {
|
||||
var block = blocks.optJSONObject(i);
|
||||
var layout = block.optJSONObject("layout");
|
||||
if (layout != null) {
|
||||
var name = layout.optString("name");
|
||||
if (name.equals("header_extended")) {
|
||||
if (layout.has("top_title")) blocks.remove(i);
|
||||
layout.put("name", "header");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setDefaultAudioPage(JSONArray jsonArray, JSONObject catalog) throws JSONException {
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
var item = jsonArray.optJSONObject(i);
|
||||
var title = item.optString("title");
|
||||
var id = item.optString("id");
|
||||
var url = item.optString("url");
|
||||
var value = Preferences.getString("musicdefcatalog");
|
||||
|
||||
Log.d("VKMusic", "title: " + title + " id: " + id + " url: " + url + " value: " + value);
|
||||
|
||||
if (url.contains(value) && !value.isEmpty()) {
|
||||
catalog.put("default_section", id);
|
||||
Log.d("VKMusic", "Added " + title + " as default music section");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void fetchCatalogId(String sectionUrl, JSONArray jsonArray) {
|
||||
var request = new Request.a()
|
||||
.b("https://" + getApi() + "/method/" + "catalog.getAudio"
|
||||
+ "?v=5.119"
|
||||
@@ -297,16 +260,23 @@ public class CatalogJsonInjector {
|
||||
+ "&device_id="
|
||||
+ DeviceIdProvider.d(AndroidUtils.getGlobalContext())
|
||||
+ "&url="
|
||||
+ section
|
||||
+ sectionUrl
|
||||
+ "&access_token="
|
||||
+ AccountManagerUtils.getUserToken())
|
||||
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a();
|
||||
try {
|
||||
return new JSONObject(mClient.a(request).execute().a().g()).getJSONObject("response");
|
||||
var json = new JSONObject(mClient.a(request).execute().a().g()).getJSONObject("response");
|
||||
var catalogarr = json.optJSONObject("catalog").optJSONArray("sections").optJSONObject(0);
|
||||
|
||||
var title = catalogarr.optString("title");
|
||||
var id = catalogarr.optString("id");
|
||||
var url = catalogarr.optString("url");
|
||||
|
||||
Log.d("VKMusic", "Added " + title + " in music sections");
|
||||
|
||||
jsonArray.put(new JSONObject().put("id", id).put("title", title).put("url", url));
|
||||
} catch (JSONException | IOException e) {
|
||||
Log.d("VTLMusic", "Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.music.cache.injectors;
|
||||
package ru.vtosters.hooks.music.injectors;
|
||||
|
||||
import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
@@ -12,7 +12,7 @@ import io.reactivex.ObservableOnSubscribe;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.downloaders.AudioDownloader;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.music.cache.MusicCacheImpl;
|
||||
import ru.vtosters.lite.music.cache.helpers.PlaylistHelper;
|
||||
import ru.vtosters.lite.music.cache.helpers.TracklistHelper;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class PlaylistInjector {
|
||||
}
|
||||
|
||||
public static boolean eligibleForOfflineCaching() {
|
||||
return CacheDatabaseDelegate.hasTracks();
|
||||
return !MusicCacheImpl.isEmpty();
|
||||
}
|
||||
|
||||
public static Observable<AudioGetPlaylist.c> injectGetPlaylist(AudioGetPlaylist audioGetPlaylist) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.music.cache.injectors;
|
||||
package ru.vtosters.hooks.music.injectors;
|
||||
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
import com.vk.music.model.IpcPlayerModelImpl;
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.music.cache.injectors;
|
||||
package ru.vtosters.hooks.music.injectors;
|
||||
|
||||
import android.util.Log;
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
@@ -11,7 +11,7 @@ import io.reactivex.ObservableOnSubscribe;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.music.cache.MusicCacheImpl;
|
||||
import ru.vtosters.lite.music.cache.helpers.PlaylistHelper;
|
||||
import ru.vtosters.lite.music.cache.helpers.TracklistHelper;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
@@ -56,7 +56,7 @@ public class TracklistInjector {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!CacheDatabaseDelegate.hasTracks()) {
|
||||
if (MusicCacheImpl.isEmpty()) {
|
||||
observableEmitter.b(parser.c(getEmptyCatalog()));
|
||||
} else {
|
||||
observableEmitter.b(parser.c(createVirtualCatalog(TracklistHelper.getTracks())));
|
||||
@@ -135,7 +135,7 @@ public class TracklistInjector {
|
||||
|
||||
button.put("action", action);
|
||||
button.put("block_id", "shuffle");
|
||||
button.put("ref_items_count", CacheDatabaseDelegate.getTrackCount());
|
||||
button.put("ref_items_count", MusicCacheImpl.getTracksCount());
|
||||
button.put("ref_layout_name", "list");
|
||||
button.put("ref_data_type", "music_audios");
|
||||
|
||||
@@ -158,7 +158,7 @@ public class TracklistInjector {
|
||||
|
||||
JSONArray blocks = firstSection.getJSONArray("blocks");
|
||||
|
||||
if (CacheDatabaseDelegate.hasTracks() && !LibVKXClient.isIntegrationEnabled()) { // inj in playlist list
|
||||
if (!MusicCacheImpl.isEmpty() && !LibVKXClient.isIntegrationEnabled()) { // inj in playlist list
|
||||
boolean noPlaylists = hasNoPlaylists(blocks);
|
||||
|
||||
if (noPlaylists) {
|
||||
+28
-14
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
package ru.vtosters.hooks.other;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
@@ -7,11 +7,15 @@ import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.StrictMode;
|
||||
import com.vk.medianative.MediaImageEncoder;
|
||||
import com.vk.medianative.MediaNative;
|
||||
import com.vtosters.lite.data.Users;
|
||||
import com.vtosters.lite.fragments.SettingsListFragment;
|
||||
import ru.vtosters.hooks.GmsHook;
|
||||
import ru.vtosters.hooks.VerificationsHook;
|
||||
import ru.vtosters.lite.BuildConfig;
|
||||
import ru.vtosters.lite.proxy.ProxyUtils;
|
||||
import ru.vtosters.lite.ui.fragments.VTSettings;
|
||||
import ru.vtosters.lite.utils.*;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
@@ -19,9 +23,11 @@ public class Preferences {
|
||||
|
||||
public static void init(Application application) throws Exception {
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
StrictMode.setThreadPolicy(policy); // fix profiles hide hook
|
||||
|
||||
GmsUtils.fixGapps();
|
||||
MediaNative.init(application);
|
||||
|
||||
GmsHook.fixGapps();
|
||||
ProxyUtils.setProxy();
|
||||
NewsFeedFiltersUtils.setupFilters();
|
||||
VTVerifications.load(application);
|
||||
@@ -160,7 +166,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static boolean superapp() {
|
||||
return getBoolValue("superapp", true);
|
||||
return getBoolValue("superapp", true) && milkshake();
|
||||
}
|
||||
|
||||
public static boolean vkpay() {
|
||||
@@ -236,6 +242,10 @@ public class Preferences {
|
||||
return getBoolValue("autoalltranslate", false);
|
||||
}
|
||||
|
||||
public static boolean serverFeaturesDisable() {
|
||||
return getBoolValue("serverFeaturesDisable", false);
|
||||
}
|
||||
|
||||
public static boolean shortinfo() {
|
||||
return getBoolValue("shortinfo", true);
|
||||
}
|
||||
@@ -257,7 +267,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static boolean stories() {
|
||||
return getBoolValue("stories", true);
|
||||
return getBoolValue("stories", false);
|
||||
}
|
||||
|
||||
public static boolean swipe() {
|
||||
@@ -282,16 +292,20 @@ public class Preferences {
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static boolean checkupdates() {
|
||||
return !getBoolValue("isRoamingState", false) && isValidSignature() && BuildConfig.BUILD_TYPE.equals("release");
|
||||
return !getBoolValue("isRoamingState", false) && isValidSignature() && BuildConfig.BUILD_TYPE.equals("release") && getBoolValue("autoupdates", true);
|
||||
}
|
||||
|
||||
public static boolean isNewBuild() {
|
||||
try {
|
||||
return getPreferences().getLong("setupTime", 0L) != AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo(AndroidUtils.getPackageName(), 0).lastUpdateTime;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
if (Preferences.getBoolValue("invalidate_theme_cache_each_update", true))
|
||||
try {
|
||||
return AndroidUtils.getGlobalContext()
|
||||
.getPackageManager()
|
||||
.getPackageInfo(AndroidUtils.getPackageName(), 0)
|
||||
.lastUpdateTime != getPreferences().getLong("setupTime", 0L);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void updateBuildNumber() {
|
||||
@@ -312,7 +326,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static boolean hasVerification() {
|
||||
return VTVerifications.isVerified(AccountManagerUtils.getUserId());
|
||||
return VerificationsHook.isVerified(AccountManagerUtils.getUserId());
|
||||
}
|
||||
|
||||
public static boolean hasSpecialVerif() {
|
||||
@@ -324,7 +338,7 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public static long getSizeForDelete() {
|
||||
return switch (Preferences.getPreferences().getString("clearcache", "")) {
|
||||
return switch (Preferences.getPreferences().getString("autoclearcache", "")) {
|
||||
case "100mb" -> 104857600L;
|
||||
case "500mb" -> 524288000L;
|
||||
case "1gb" -> 1073741824L;
|
||||
+13
-44
@@ -1,4 +1,4 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
package ru.vtosters.hooks.other;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
@@ -16,26 +16,27 @@ import android.webkit.WebView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import com.vk.articles.preload.WebCachePreloader;
|
||||
import com.vk.core.drawable.RecoloredDrawable;
|
||||
import com.vk.core.preference.Preference;
|
||||
import com.vk.core.ui.themes.MilkshakeHelper;
|
||||
import com.vk.core.ui.themes.VKTheme;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.data.ThemeTracker;
|
||||
import ru.vtosters.lite.deviceinfo.OEMDetector;
|
||||
import ru.vtosters.lite.hooks.VKUIHook;
|
||||
import ru.vtosters.lite.themes.ThemesCore;
|
||||
import ru.vtosters.lite.themes.ThemesHacks;
|
||||
import ru.vtosters.lite.themes.ThemesManager;
|
||||
import ru.vtosters.lite.ui.wallpapers.WallpapersHooks;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.WebViewColoringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.*;
|
||||
import static ru.vtosters.lite.utils.Preferences.*;
|
||||
|
||||
public class ThemesUtils {
|
||||
public static void applyTheme(VKTheme theme, Boolean restartActivity) {
|
||||
@@ -46,22 +47,10 @@ public class ThemesUtils {
|
||||
}
|
||||
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
|
||||
|
||||
public static boolean isCustomAccentEnabled() {
|
||||
return ThemesUtils.isMonetTheme() || !useNewColorEngine();
|
||||
}
|
||||
|
||||
public static ColorStateList getAccenedColorStateList() {
|
||||
return ColorStateList.valueOf(getAccentColor());
|
||||
}
|
||||
|
||||
public static int getSystemModeTheme() {
|
||||
return AppCompatDelegate.getDefaultNightMode();
|
||||
}
|
||||
|
||||
public static void setSystemModeTheme(int theme) {
|
||||
AppCompatDelegate.setDefaultNightMode(theme);
|
||||
}
|
||||
|
||||
public static void setTheme(VKTheme theme, Activity activity, Boolean restartActivity) {
|
||||
setThemeFL(theme, activity, getCenterScreenCoords(), restartActivity);
|
||||
} // apply changed theme
|
||||
@@ -71,9 +60,10 @@ public class ThemesUtils {
|
||||
activity = LifecycleUtils.getCurrentActivity();
|
||||
}
|
||||
VKThemeHelper.theme(theme, activity, fl);
|
||||
if (isMonetTheme() || ThemesManager.canApplyCustomAccent()) ThemesCore.clear();
|
||||
if (restartActivity) activity.recreate();
|
||||
ThemeTracker.a();
|
||||
VKUIHook.isLoaded = false;
|
||||
WebViewColoringUtils.isLoaded = false;
|
||||
new WebView(activity).clearCache(true);
|
||||
WebCachePreloader.e();
|
||||
}
|
||||
@@ -90,13 +80,8 @@ public class ThemesUtils {
|
||||
return getBoolValue("amoledtheme", false);
|
||||
}
|
||||
|
||||
public static boolean useNewColorEngine() {
|
||||
return getBoolValue("useNewColorEngine", false);
|
||||
}
|
||||
|
||||
public static int getAccentColor() {
|
||||
var color = Preferences.getPreferences().getInt("accent_color", getColorFromAttr(R.attr.accent));
|
||||
return color == 0 || useNewColorEngine() || isMonetTheme() ? getColorFromAttr(R.attr.accent) : color;
|
||||
return getColorFromAttr(R.attr.accent);
|
||||
} // Color accent
|
||||
|
||||
//region Used for migrating accent color to new version
|
||||
@@ -260,14 +245,6 @@ public class ThemesUtils {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? isDarkTheme() ? View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
|
||||
}
|
||||
|
||||
public static int getStockAccent() {
|
||||
if (isMilkshake()) {
|
||||
return isDarkTheme() ? Color.parseColor("#71aaeb") : Color.parseColor("#3f8ae0");
|
||||
} else {
|
||||
return isDarkTheme() ? Color.parseColor("#71aaeb") : Color.parseColor("#528bcc");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getDarkThemeRes() {
|
||||
if (isMonetTheme()) {
|
||||
if (isAmoledTheme()) {
|
||||
@@ -322,7 +299,7 @@ public class ThemesUtils {
|
||||
} // Recolor drawable to accent color
|
||||
|
||||
public static Drawable recolorToolbarDrawable(Drawable drawable) {
|
||||
if (!ThemesUtils.isCustomAccentEnabled()) return drawable;
|
||||
if (!ThemesUtils.isMonetTheme()) return drawable;
|
||||
if (drawable == null) return null;
|
||||
return new RecoloredDrawable(drawable, (ThemesUtils.isMilkshake() && !ThemesUtils.isDarkTheme()) ? ThemesUtils.getAccentColor() : ThemesUtils.getHeaderText());
|
||||
}
|
||||
@@ -407,15 +384,11 @@ public class ThemesUtils {
|
||||
}
|
||||
|
||||
public static int getNavigationHeight(int Default) {
|
||||
int VKME = R.dimen.design_bottom_sheet_peek_height_min;
|
||||
|
||||
return vkme() ? VKME : Default;
|
||||
return vkme() ? R.dimen.design_bottom_sheet_peek_height_min : Default;
|
||||
}
|
||||
|
||||
public static int getNavigationWidth(int Default) {
|
||||
int VKME = R.dimen.app_minimumsize_h;
|
||||
|
||||
return vkme() ? VKME : Default;
|
||||
return vkme() ? R.dimen.app_minimumsize_h : Default;
|
||||
}
|
||||
|
||||
public static ColorStateList getCSTDock() {
|
||||
@@ -426,12 +399,8 @@ public class ThemesUtils {
|
||||
},
|
||||
new int[]{
|
||||
dockbar_accent() ? getAccentColor() : (isDarkTheme() ? getResources().getColor(R.color.white) : getResources().getColor(R.color.gray_700)),
|
||||
isDarkTheme() ? getResources().getColor(R.color.gray_500) : getResources().getColor(R.color.vk_steel_gray_300)
|
||||
getColorFromAttr(R.attr.tabbar_inactive_icon)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void getCurrentThemeID(VKTheme paramVKTheme) {
|
||||
Preference.b("vk_theme_helper", "current_theme", paramVKTheme.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package ru.vtosters.hooks.ssfs;
|
||||
|
||||
import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.lite.ssfs.ImBanner;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
public class BannerHook {
|
||||
public static JSONObject convBar(JSONObject orig) {
|
||||
return ImBanner.convertToBanner(orig);
|
||||
}
|
||||
|
||||
public static boolean showAlert() {
|
||||
var context = LifecycleUtils.getCurrentActivity();
|
||||
var bool = Preferences.getBoolValue("linkalert", false);
|
||||
|
||||
if (!bool) {
|
||||
new VkAlertDialog.Builder(context)
|
||||
.setTitle(com.vtosters.lite.R.string.warning)
|
||||
.setMessage(AndroidUtils.getString("custom_links_warning"))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(com.vtosters.lite.R.string.continue_, (dialogInterface, i) -> {
|
||||
Preferences.getPreferences().edit().putBoolean("linkalert", true).commit();
|
||||
})
|
||||
.setNeutralButton(com.vtosters.lite.R.string.cancel, (dialogInterface, i) -> {
|
||||
dialogInterface.cancel();
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
return bool;
|
||||
}
|
||||
}
|
||||
+14
-4
@@ -1,15 +1,18 @@
|
||||
package ru.vtosters.lite.ssfs;
|
||||
package ru.vtosters.hooks.ssfs;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.vk.profile.presenter.UserPresenter;
|
||||
import com.vtosters.lite.api.ExtendedUserProfile;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.ssfs.Handler;
|
||||
import ru.vtosters.lite.ssfs.ProfileButtons;
|
||||
import ru.vtosters.lite.ssfs.UsersList;
|
||||
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserID;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class ProfileHider {
|
||||
public class ProfileHook {
|
||||
private static final String TAG = "ProfileHider";
|
||||
|
||||
public static boolean isService(Integer id) {
|
||||
@@ -21,7 +24,10 @@ public class ProfileHider {
|
||||
|
||||
if (UsersList.hasDescription(userID)) {
|
||||
try {
|
||||
extendedUserProfile.z2 = Handler.getDescription(userID);
|
||||
String description = Handler.getDescription(userID);
|
||||
if (!TextUtils.isEmpty(description)) {
|
||||
extendedUserProfile.z2 = description;
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
Log.e(TAG, "null \"profiles\" node\n" + e);
|
||||
}
|
||||
@@ -39,4 +45,8 @@ public class ProfileHider {
|
||||
}
|
||||
return getGlobalContext().getString(UserPresenter.q0.a(userID));
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject getProfileButton(JSONObject orig) {
|
||||
return ProfileButtons.profileButton(orig);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package ru.vtosters.lite.hooks.ui;
|
||||
package ru.vtosters.hooks.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Configuration;
|
||||
import com.vk.core.ui.themes.VKTheme;
|
||||
import ru.vtosters.hooks.other.Preferences;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class SystemThemeChangerHook {
|
||||
public static void onThemeChanged(Configuration configuration) {
|
||||
@@ -1,7 +1,7 @@
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
import ru.vtosters.lite.utils.VersionReader;
|
||||
|
||||
import static ru.vtosters.lite.deviceinfo.OEMDetector.*;
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package ru.vtosters.lite.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import ru.vtosters.hooks.MessagesActivityHook;
|
||||
|
||||
import static ru.vtosters.hooks.other.Preferences.getBoolValue;
|
||||
|
||||
public class DNRPrefs {
|
||||
public static boolean getStoriesRead() {
|
||||
return getBoolValue("read_s", false);
|
||||
}
|
||||
|
||||
public static boolean getVoiceListened() {
|
||||
return getBoolValue("listen_v", false);
|
||||
}
|
||||
|
||||
public static boolean getMarkAsReadWithoutExceptions(int peerId) {
|
||||
if (readPM(peerId))
|
||||
@@ -24,34 +19,34 @@ public class DNRPrefs {
|
||||
}
|
||||
|
||||
public static boolean isInDNRExceptions(int peerId) {
|
||||
return DNRModule.mDoNotReadDBHelper.isEnabledForPeerId(peerId);
|
||||
return MessagesActivityHook.mDoNotReadDBHelper.isEnabledForPeerId(peerId);
|
||||
}
|
||||
|
||||
public static boolean isInDNTExceptions(int peerId) {
|
||||
return DNRModule.mDoNotTypeDBHelper.isEnabledForPeerId(peerId);
|
||||
return MessagesActivityHook.mDoNotTypeDBHelper.isEnabledForPeerId(peerId);
|
||||
}
|
||||
|
||||
public static boolean readPM(int peer) {
|
||||
private static boolean readPM(int peer) {
|
||||
return (peer > 0 && peer < 2000000000) && getBoolValue("read_pm", false);
|
||||
}
|
||||
|
||||
public static boolean readConversations(int peer) {
|
||||
private static boolean readConversations(int peer) {
|
||||
return (peer > 2000000000) && getBoolValue("read_conversations", false);
|
||||
}
|
||||
|
||||
public static boolean readBots(int peer) {
|
||||
private static boolean readBots(int peer) {
|
||||
return (peer < 0) && getBoolValue("read_bot", false);
|
||||
}
|
||||
|
||||
public static boolean writePM(int peer) {
|
||||
private static boolean writePM(int peer) {
|
||||
return (peer > 0 && peer < 2000000000) && getBoolValue("write_pm", false);
|
||||
}
|
||||
|
||||
public static boolean writeConversations(int peer) {
|
||||
private static boolean writeConversations(int peer) {
|
||||
return (peer > 2000000000) && getBoolValue("write_conversations", false);
|
||||
}
|
||||
|
||||
public static boolean writeBots(int peer) {
|
||||
private static boolean writeBots(int peer) {
|
||||
return (peer < 0) && getBoolValue("write_bot", false);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ import com.vk.im.engine.models.messages.Msg;
|
||||
import com.vk.im.engine.utils.ImDialogsUtils;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import ru.vtosters.hooks.other.ThemesUtils;
|
||||
import ru.vtosters.lite.concurrent.VTExecutors;
|
||||
import ru.vtosters.lite.net.Request;
|
||||
import ru.vtosters.lite.proxy.ProxyUtils;
|
||||
import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class Requests {
|
||||
public static void hookRead(Dialog dialog) {
|
||||
@@ -43,7 +44,7 @@ public class Requests {
|
||||
}
|
||||
|
||||
public static void pinnedMsg(int dialogid, boolean needToBePinned) {
|
||||
Thread thread = new Thread(() -> {
|
||||
VTExecutors.getIoExecutor().execute(() -> {
|
||||
try {
|
||||
var request = new okhttp3.Request.a()
|
||||
.b("https://" + ProxyUtils.getApi() + "/method/" + (needToBePinned ? "messages.pinConversation" : "messages.unpinConversation") + "?peer_id=" + dialogid + "&access_token=" + AccountManagerUtils.getUserToken() + "&v=5.119")
|
||||
@@ -56,8 +57,6 @@ public class Requests {
|
||||
}
|
||||
});
|
||||
|
||||
thread.start();
|
||||
|
||||
AndroidUtils.sendToast(AndroidUtils.getString(com.vtosters.lite.R.string.pin_dialog) + " " + AndroidUtils.getString(needToBePinned ? com.vtosters.lite.R.string.dialog_pinned : com.vtosters.lite.R.string.dialog_unpinned));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.vk.core.util.ToastUtils;
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
import com.vk.dto.music.Playlist;
|
||||
import com.vtosters.lite.R;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.music.cache.FileCacheImplementation;
|
||||
import ru.vtosters.hooks.music.MusicCacheFilesHook;
|
||||
import ru.vtosters.lite.music.cache.MusicCacheImpl;
|
||||
import ru.vtosters.lite.music.callback.MusicCallbackBuilder;
|
||||
import ru.vtosters.lite.music.converter.playlist.PlaylistConverter;
|
||||
import ru.vtosters.lite.music.downloader.AudioGet;
|
||||
@@ -58,15 +58,15 @@ public class AudioDownloader {
|
||||
}
|
||||
|
||||
public static void cacheTrack(MusicTrack track) {
|
||||
var trackId = track.y1();
|
||||
var trackId = LibVKXClient.asId(track);
|
||||
|
||||
if (CacheDatabaseDelegate.isCached(trackId)) {
|
||||
CacheDatabaseDelegate.removeTrackFromCache(LibVKXClient.asId(track));
|
||||
if (MusicCacheImpl.isCachedTrack(trackId)) {
|
||||
MusicCacheImpl.removeTrack(trackId);
|
||||
AndroidUtils.sendToast(AndroidUtils.getString("audio_deleted_from_cache"));
|
||||
return;
|
||||
}
|
||||
|
||||
var trackFile = FileCacheImplementation.getTrackFile(trackId);
|
||||
var trackFile = MusicCacheFilesHook.getTrackFile(trackId);
|
||||
if (!trackFile.exists())
|
||||
trackFile.getParentFile().mkdirs();
|
||||
executor.submit(() -> downloadM3U8(track, true));
|
||||
|
||||
@@ -13,9 +13,6 @@ import static ru.vtosters.lite.downloaders.VideoDownloader.downloadVideo;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
|
||||
public class StoryDownloader {
|
||||
public static Runnable injectButton(StoryEntry story) {
|
||||
return () -> downloadStory(story);
|
||||
}
|
||||
|
||||
public static void downloadStory(StoryEntry story) {
|
||||
if (story.T1()) {
|
||||
|
||||
@@ -20,39 +20,21 @@ import com.vtosters.lite.R;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import ru.vtosters.lite.utils.ExternalLinkParser;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.hooks.other.ThemesUtils.getTextAttr;
|
||||
import static ru.vtosters.lite.net.Request.makeRequest;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
public class VideoDownloader {
|
||||
private static final int DOWNLOAD_ID = 0;
|
||||
private static final int OPEN_EXTERNAL_LINK_ID = 1;
|
||||
public static final int DOWNLOAD_ID = 0;
|
||||
public static final int OPEN_EXTERNAL_LINK_ID = 1;
|
||||
|
||||
public static boolean onClick(int id, VideoFile video, Context ctx) {
|
||||
if (id == DOWNLOAD_ID) {
|
||||
downloadVideo(video, ctx);
|
||||
return true;
|
||||
} else if (id == OPEN_EXTERNAL_LINK_ID) {
|
||||
ExternalLinkParser.parseVideoFile(video, ctx, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void injectAction(ArrayList<MenuBottomSheetAction> list, VideoFile video) {
|
||||
if (!video.U && !video.I1()) {
|
||||
addAction(list, DOWNLOAD_ID, R.drawable.ic_download_outline_24, R.string.download, 9);
|
||||
addAction(list, OPEN_EXTERNAL_LINK_ID, R.drawable.ic_link_outline_28, R.string.interfacevideoext_short, 9);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addAction(List<MenuBottomSheetAction> actions, int... ints) {
|
||||
public static void addAction(List<MenuBottomSheetAction> actions, int... ints) {
|
||||
actions.add(new MenuBottomSheetAction(ints[0], ints[1], ints[2], ints[3]));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
|
||||
import static ru.vtosters.hooks.EncryptionMessagesHook.decryptMessage;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getArray;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.json.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
|
||||
import static ru.vtosters.hooks.EncryptionMessagesHook.decryptMessage;
|
||||
|
||||
public class MiniMsg {
|
||||
public long date;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user