Compare commits

..
Author SHA1 Message Date
gdlbo 45f7cc4484 fixed friends recomms issue 2023-12-13 21:23:31 +03:00
gdlbo 886ddd60c1 fix community 2023-12-13 21:00:02 +03:00
gdlbo adc06426ac fixed issue with country and city in profiles 2023-12-13 20:44:17 +03:00
gdlbo 62aa568599 rewrite to java 2023-12-13 17:54:28 +03:00
396 changed files with 11430 additions and 25913 deletions
+3 -12
View File
@@ -21,21 +21,14 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up NDK
uses: nttld/setup-ndk@v1
with:
ndk-version: r25c
add-to-path: false
- name: Set up JDK - name: Set up JDK
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
java-version: '17' java-version: '17'
distribution: 'adopt' distribution: 'adopt'
- uses: actions/checkout@v3
- name: Download tools - name: Download tools
run: | run: |
sudo apt update sudo apt update
@@ -54,8 +47,6 @@ jobs:
java -jar scripts/apktool.jar b smali -o smali/VTLite.apk --use-aapt2 -p scripts/framework/ java -jar scripts/apktool.jar b smali -o smali/VTLite.apk --use-aapt2 -p scripts/framework/
zipalign -p -f 4 smali/VTLite.apk smali/VTLite.apk_aligned zipalign -p -f 4 smali/VTLite.apk smali/VTLite.apk_aligned
mv smali/VTLite.apk_aligned smali/VTLite.apk mv smali/VTLite.apk_aligned smali/VTLite.apk
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Sign and verify the apk - name: Sign and verify the apk
run: | run: |
-28
View File
@@ -1,28 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="RClass Regeneration" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/rclass_regenerator.sh" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/bin/zsh" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="true" />
<envs />
<method v="2" />
</configuration>
<configuration default="false" name="RClass Regeneration" type="BatchConfigurationType" factoryName="Batch">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="WORKING_DIRECTORY" value="" />
<option name="PARENT_ENVS" value="true" />
<module name="" />
<option name="SCRIPT_NAME" value="./scripts/rclass_regenerator.bat" />
<option name="PARAMETERS" value="" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
-17
View File
@@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Update APKs Jars (MacOS)" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/update_jars_brew.sh" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/bin/zsh" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="true" />
<envs />
<method v="2" />
</configuration>
</component>
-17
View File
@@ -1,17 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Update APKs Jars" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/update_jars.sh" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/bin/zsh" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="true" />
<envs />
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildAndInstallVTLBeta]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildAndInstallVTLBeta" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildAndInstallVTLDev]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildAndInstallVTLDev" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildAndInstallVTLRelease]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildAndInstallVTLRelease" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildAndLaunchVTLBeta]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildAndLaunchVTLBeta" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildAndLaunchVTLDev]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildAndLaunchVTLDev" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildAndLaunchVTLRelease]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildAndLaunchVTLRelease" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
-24
View File
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildVTLBeta]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildVTLBeta" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
-24
View File
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildVTLDev]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildVTLDev" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
-24
View File
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:buildVTLRelease]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:buildVTLRelease" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
-24
View File
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:exportDexBeta]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:exportDexBeta" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
-24
View File
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:exportDexDev]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:exportDexDev" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
-24
View File
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:exportDexRelease]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:exportDexRelease" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:prepareDexForMergeDev]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:prepareDexForMergeDev" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
@@ -1,24 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="lite [app:prepareDexForMergeRelease]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="app:prepareDexForMergeRelease" />
</list>
</option>
<option name="vmOptions" value="-Xms4g -Xmx4g" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
+37 -34
View File
@@ -20,9 +20,9 @@ cargo {
def smaliFolder = projectDir.toPath().resolve("../smali").normalize() def smaliFolder = projectDir.toPath().resolve("../smali").normalize()
def scriptsFolder = projectDir.toPath().resolve("../scripts").normalize() def scriptsFolder = projectDir.toPath().resolve("../scripts").normalize()
//you can add own folders with decompiled smali code //you can add own folders with decompiled smali code
def dexes = smaliFolder.toFile() def dexes=smaliFolder.toFile()
.listFiles({ f -> f.isDirectory() && f.name.startsWith("smali") } as FileFilter) .listFiles( { f -> f.isDirectory() && f.name.startsWith("smali") } as FileFilter)
.size() .size()
versionFile { versionFile {
file = projectDir.toPath().resolve("src/main/assets/version.properties").toFile() file = projectDir.toPath().resolve("src/main/assets/version.properties").toFile()
@@ -91,11 +91,11 @@ task testClasses {
} }
dependencies { dependencies {
implementation 'com.microsoft.appcenter:appcenter-analytics:5.0.4' implementation 'com.microsoft.appcenter:appcenter-analytics:5.0.2'
implementation 'com.microsoft.appcenter:appcenter-crashes:5.0.4' implementation 'com.microsoft.appcenter:appcenter-crashes:5.0.2'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
implementation 'net.sourceforge.streamsupport:streamsupport-minifuture:1.7.4' implementation 'net.sourceforge.streamsupport:streamsupport-minifuture:1.7.4'
implementation 'com.google.guava:guava:32.0.0-android' implementation 'com.google.guava:guava:23.3-android'
implementation fileTree(dir: 'libs', include: ['*.aar']) implementation fileTree(dir: 'libs', include: ['*.aar'])
compileOnly fileTree(dir: 'libs', include: ['*.jar']) compileOnly fileTree(dir: 'libs', include: ['*.jar'])
@@ -105,35 +105,38 @@ task generateBuildTasks() {
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def buildType = output.name.toString().capitalize() def buildType = output.name.toString().capitalize()
if (buildType == "Base") return if(buildType=="Base")return
task "exportDex$buildType"() { task "exportDex$buildType"() {
dependsOn('assemble' + buildType) dependsOn('assemble' + buildType)
doLast { doLast {
try { try {
def suffix = buildType.toLowerCase() def suffix=buildType.toLowerCase()
String apkPath = projectDir.getAbsolutePath() + "/build/outputs/apk/$suffix/app-$suffix" String apkPath=projectDir.getAbsolutePath()+"/build/outputs/apk/$suffix/app-$suffix"
def apk = new File(apkPath + "-unsigned.apk") def apk=new File(apkPath+"-unsigned.apk")
if (!apk.exists()) apk = new File(apkPath + ".apk") if(!apk.exists())apk=new File(apkPath+".apk")
def zip = new ZipFile(apk) def zip=new ZipFile(apk)
def dexCounter = dexes def entries=zip.entries()
zip.stream() def dexCounter=dexes
.filter(entry -> entry.name.matches("^classes(?:(?=\\d)2|)\\.dex\$") || entry.name == "assets/version.properties") while(entries.hasMoreElements())
.forEach(entry -> { {
String filename def entry=entries.nextElement()
if (entry.name.matches("^classes(?:(?=\\d)2|)\\.dex\$")) filename = "classes${++dexCounter}.dex" String filename
else filename = "version.properties" if(entry.name.matches("^classes(?:(?=\\d)2|)\\.dex\$"))filename="classes${++dexCounter}.dex"
println("Exporting " + entry.name) else if(entry.name=="assets/version.properties")filename="version.properties"
def tmpFile = new File(projectDir, filename) else continue
try (def is = zip.getInputStream(entry); def fos = new FileOutputStream(tmpFile)) { println("Exporting "+entry.name)
def buff = new byte[0x800] def tmpFile=new File(projectDir,filename)
int len def is=zip.getInputStream(entry)
while ((len = is.read(buff)) > 0) fos.write(buff, 0, len) 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) { } catch (Exception e) {
e.printStackTrace() e.printStackTrace()
} }
} }
} }
task "prepareDexForMerge$buildType"(type: Copy) { task "prepareDexForMerge$buildType"(type: Copy) {
@@ -149,19 +152,19 @@ task generateBuildTasks() {
include 'version.properties' include 'version.properties'
into 'assets' into 'assets'
} }
from('../native-effects/target/aarch64-linux-android/release') { from('../native-effects/target/aarch64-linux-android/release'){
include 'libnative_effects.so' include 'libnative_effects.so'
into 'lib/arm64-v8a' into 'lib/arm64-v8a'
} }
from('../native-effects/target/armv7-linux-androideabi/release') { from('../native-effects/target/armv7-linux-androideabi/release'){
include 'libnative_effects.so' include 'libnative_effects.so'
into 'lib/armeabi-v7a' into 'lib/armeabi-v7a'
} }
} }
task "cleanTemporaryFiles$buildType"(type: Delete) task "cleanTemporaryFiles$buildType"(type:Delete)
{ {
delete fileTree(dir: projectDir, include: ["*.dex", "version.properties"]) delete fileTree(dir:projectDir,include:["*.dex","version.properties"])
delete fileTree(dir: smaliFolder, include: ['*.dex', "assets/version.properties"]) delete fileTree(dir:smaliFolder,include:['*.dex',"assets/version.properties"])
} }
task "buildVTL$buildType"(type: Exec) { task "buildVTL$buildType"(type: Exec) {
dependsOn('prepareDexForMerge' + buildType) dependsOn('prepareDexForMerge' + buildType)
+1 -1
View File
@@ -35,7 +35,7 @@
-optimizationpasses 5 -optimizationpasses 5
-keepattributes SourceFile, LineNumberTable -keepattributes SourceFile, LineNumberTable
-keep,allowoptimization class ru.vtosters.hooks.**, ru.vtosters.sponsorpost.internal.Native, 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 { -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 <fields>;
public <methods>; public <methods>;
public <init>(...); public <init>(...);
-2
View File
@@ -4,10 +4,8 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" android:maxSdkVersion="22"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" android:maxSdkVersion="22"/>
<application <application
android:allowBackup="true" android:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
@@ -6,7 +6,6 @@ import android.os.RemoteException;
import bruhcollective.itaysonlab.libvkx.ILibVkxService; import bruhcollective.itaysonlab.libvkx.ILibVkxService;
import com.vk.dto.music.MusicTrack; import com.vk.dto.music.MusicTrack;
import com.vk.music.common.MusicPlaybackLaunchContext; import com.vk.music.common.MusicPlaybackLaunchContext;
import ru.vtosters.hooks.other.Preferences;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -34,7 +33,7 @@ public class LibVKXClient {
public static boolean isVkxInstalled() { public static boolean isVkxInstalled() {
try { try {
getGlobalContext().getPackageManager().getPackageInfo("ua.itaysonlab.vkx", 0); getGlobalContext().getPackageManager().getPackageInfo("ua.itaysonlab.vkx", 0);
return isValidSignature() && !Preferences.serverFeaturesDisable(); return isValidSignature();
} catch (Exception unused) { } catch (Exception unused) {
return false; return false;
} }
@@ -81,7 +80,6 @@ public class LibVKXClient {
lambdaplay(list, musicTrack, iLibVkxService, null); lambdaplay(list, musicTrack, iLibVkxService, null);
} }
public static String asId(MusicTrack musicTrack) { public static String asId(MusicTrack musicTrack)
return musicTrack.y1(); { return musicTrack.y1(); }
}
} }
@@ -59,23 +59,27 @@ public class ArscBlamer {
* Maps type chunk entries to blamed resources. * Maps type chunk entries to blamed resources.
*/ */
private final Multimap<TypeChunk.Entry, ResourceEntry> typeEntryToBlame = HashMultimap.create(); private final Multimap<TypeChunk.Entry, ResourceEntry> typeEntryToBlame = HashMultimap.create();
/**
* This is the {@link ResourceTableChunk} inside of the resources.arsc file in the APK.
*/
private final ResourceTableChunk resourceTable;
/** /**
* Maps resources to the type chunk entries they reference. * Maps resources to the type chunk entries they reference.
*/ */
private Multimap<ResourceEntry, TypeChunk.Entry> resourceEntries; private Multimap<ResourceEntry, TypeChunk.Entry> resourceEntries;
/** /**
* Maps resources which have no base config to the type chunk entries they reference. * Maps resources which have no base config to the type chunk entries they reference.
*/ */
private Multimap<ResourceEntry, TypeChunk.Entry> baselessKeys; private Multimap<ResourceEntry, TypeChunk.Entry> baselessKeys;
/** /**
* Contains all of the type chunks in {@link #resourceTable}. * Contains all of the type chunks in {@link #resourceTable}.
*/ */
private List<TypeChunk> typeChunks; private List<TypeChunk> typeChunks;
/**
* This is the {@link ResourceTableChunk} inside of the resources.arsc file in the APK.
*/
private final ResourceTableChunk resourceTable;
/** /**
* Creates a new {@link ArscBlamer}. * Creates a new {@link ArscBlamer}.
* *
@@ -86,14 +90,6 @@ public class ArscBlamer {
this.stringToBlame = createEntryListArray(resourceTable.getStringPool().getStringCount()); this.stringToBlame = createEntryListArray(resourceTable.getStringPool().getStringCount());
} }
private static List<ResourceEntry>[] createEntryListArray(int size) {
ArrayListResourceEntry[] result = new ArrayListResourceEntry[size];
for (int i = 0; i < size; ++i) {
result[i] = new ArrayListResourceEntry();
}
return result;
}
/** /**
* Generates blame mappings. * Generates blame mappings.
*/ */
@@ -261,6 +257,14 @@ public class ArscBlamer {
return false; return false;
} }
private static List<ResourceEntry>[] createEntryListArray(int size) {
ArrayListResourceEntry[] result = new ArrayListResourceEntry[size];
for (int i = 0; i < size; ++i) {
result[i] = new ArrayListResourceEntry();
}
return result;
}
/** /**
* Allows creation of concrete parameterized type arr {@link ArscBlamer#createEntryListArray}. * Allows creation of concrete parameterized type arr {@link ArscBlamer#createEntryListArray}.
*/ */
@@ -279,12 +283,6 @@ public class ArscBlamer {
private final String typeName; private final String typeName;
private final String entryName; private final String entryName;
private ResourceEntry(String packageName, String typeName, String entryName) {
this.packageName = packageName;
this.typeName = typeName;
this.entryName = entryName;
}
static ResourceEntry create(TypeChunk.Entry entry) { static ResourceEntry create(TypeChunk.Entry entry) {
PackageChunk packageChunk = Preconditions.checkNotNull(entry.parent().getPackageChunk()); PackageChunk packageChunk = Preconditions.checkNotNull(entry.parent().getPackageChunk());
String packageName = packageChunk.getPackageName(); String packageName = packageChunk.getPackageName();
@@ -293,6 +291,12 @@ public class ArscBlamer {
return new ResourceEntry(packageName, typeName, entryName); return new ResourceEntry(packageName, typeName, entryName);
} }
private ResourceEntry(String packageName, String typeName, String entryName) {
this.packageName = packageName;
this.typeName = typeName;
this.entryName = entryName;
}
public String packageName() { public String packageName() {
return packageName; return packageName;
} }
@@ -31,148 +31,6 @@ import static java.nio.charset.StandardCharsets.US_ASCII;
* Describes a particular resource configuration. * Describes a particular resource configuration.
*/ */
public class BinaryResourceConfiguration implements SerializableResource { public class BinaryResourceConfiguration implements SerializableResource {
/**
* The below constants are from android.content.res.Configuration.
*/
private static final int DENSITY_DPI_UNDEFINED = 0;
private static final int DENSITY_DPI_LDPI = 120;
private static final int DENSITY_DPI_MDPI = 160;
private static final int DENSITY_DPI_TVDPI = 213;
private static final int DENSITY_DPI_HDPI = 240;
private static final int DENSITY_DPI_XHDPI = 320;
private static final int DENSITY_DPI_XXHDPI = 480;
private static final int DENSITY_DPI_XXXHDPI = 640;
private static final int DENSITY_DPI_ANY = 0xFFFE;
private static final int DENSITY_DPI_NONE = 0xFFFF;
private static final Map<Integer, String> DENSITY_DPI_VALUES =
ImmutableMap.<Integer, String>builder()
.put(DENSITY_DPI_UNDEFINED, "")
.put(DENSITY_DPI_LDPI, "ldpi")
.put(DENSITY_DPI_MDPI, "mdpi")
.put(DENSITY_DPI_TVDPI, "tvdpi")
.put(DENSITY_DPI_HDPI, "hdpi")
.put(DENSITY_DPI_XHDPI, "xhdpi")
.put(DENSITY_DPI_XXHDPI, "xxhdpi")
.put(DENSITY_DPI_XXXHDPI, "xxxhdpi")
.put(DENSITY_DPI_ANY, "anydpi")
.put(DENSITY_DPI_NONE, "nodpi")
.build();
private static final int KEYBOARD_NOKEYS = 1;
private static final int KEYBOARD_QWERTY = 2;
private static final int KEYBOARD_12KEY = 3;
private static final Map<Integer, String> KEYBOARD_VALUES = ImmutableMap.of(
KEYBOARD_NOKEYS, "nokeys",
KEYBOARD_QWERTY, "qwerty",
KEYBOARD_12KEY, "12key");
private static final int KEYBOARDHIDDEN_MASK = 0x03;
private static final int KEYBOARDHIDDEN_NO = 1;
private static final int KEYBOARDHIDDEN_YES = 2;
private static final int KEYBOARDHIDDEN_SOFT = 3;
private static final Map<Integer, String> KEYBOARDHIDDEN_VALUES = ImmutableMap.of(
KEYBOARDHIDDEN_NO, "keysexposed",
KEYBOARDHIDDEN_YES, "keyshidden",
KEYBOARDHIDDEN_SOFT, "keyssoft");
private static final int NAVIGATION_NONAV = 1;
private static final int NAVIGATION_DPAD = 2;
private static final int NAVIGATION_TRACKBALL = 3;
private static final int NAVIGATION_WHEEL = 4;
private static final Map<Integer, String> NAVIGATION_VALUES = ImmutableMap.of(
NAVIGATION_NONAV, "nonav",
NAVIGATION_DPAD, "dpad",
NAVIGATION_TRACKBALL, "trackball",
NAVIGATION_WHEEL, "wheel");
private static final int NAVIGATIONHIDDEN_MASK = 0x0C;
private static final int NAVIGATIONHIDDEN_NO = 0x04;
private static final int NAVIGATIONHIDDEN_YES = 0x08;
private static final Map<Integer, String> NAVIGATIONHIDDEN_VALUES = ImmutableMap.of(
NAVIGATIONHIDDEN_NO, "navexposed",
NAVIGATIONHIDDEN_YES, "navhidden");
private static final int ORIENTATION_PORTRAIT = 0x01;
private static final int ORIENTATION_LANDSCAPE = 0x02;
private static final Map<Integer, String> ORIENTATION_VALUES = ImmutableMap.of(
ORIENTATION_PORTRAIT, "port",
ORIENTATION_LANDSCAPE, "land");
private static final int SCREENLAYOUT_LAYOUTDIR_MASK = 0xC0;
private static final int SCREENLAYOUT_LAYOUTDIR_LTR = 0x40;
private static final int SCREENLAYOUT_LAYOUTDIR_RTL = 0x80;
private static final Map<Integer, String> SCREENLAYOUT_LAYOUTDIR_VALUES = ImmutableMap.of(
SCREENLAYOUT_LAYOUTDIR_LTR, "ldltr",
SCREENLAYOUT_LAYOUTDIR_RTL, "ldrtl");
private static final int SCREENLAYOUT_LONG_MASK = 0x30;
private static final int SCREENLAYOUT_LONG_NO = 0x10;
private static final int SCREENLAYOUT_LONG_YES = 0x20;
private static final Map<Integer, String> SCREENLAYOUT_LONG_VALUES = ImmutableMap.of(
SCREENLAYOUT_LONG_NO, "notlong",
SCREENLAYOUT_LONG_YES, "long");
private static final int SCREENLAYOUT_ROUND_MASK = 0x03;
private static final int SCREENLAYOUT_ROUND_NO = 0x01;
private static final int SCREENLAYOUT_ROUND_YES = 0x02;
private static final Map<Integer, String> SCREENLAYOUT_ROUND_VALUES = ImmutableMap.of(
SCREENLAYOUT_ROUND_NO, "notround",
SCREENLAYOUT_ROUND_YES, "round");
private static final int SCREENLAYOUT_SIZE_MASK = 0x0F;
private static final int SCREENLAYOUT_SIZE_SMALL = 0x01;
private static final int SCREENLAYOUT_SIZE_NORMAL = 0x02;
private static final int SCREENLAYOUT_SIZE_LARGE = 0x03;
private static final int SCREENLAYOUT_SIZE_XLARGE = 0x04;
private static final Map<Integer, String> SCREENLAYOUT_SIZE_VALUES = ImmutableMap.of(
SCREENLAYOUT_SIZE_SMALL, "small",
SCREENLAYOUT_SIZE_NORMAL, "normal",
SCREENLAYOUT_SIZE_LARGE, "large",
SCREENLAYOUT_SIZE_XLARGE, "xlarge");
private static final int TOUCHSCREEN_NOTOUCH = 1;
private static final int TOUCHSCREEN_FINGER = 3;
private static final Map<Integer, String> TOUCHSCREEN_VALUES = ImmutableMap.of(
TOUCHSCREEN_NOTOUCH, "notouch",
TOUCHSCREEN_FINGER, "finger");
private static final int UI_MODE_NIGHT_MASK = 0x30;
private static final int UI_MODE_NIGHT_NO = 0x10;
private static final int UI_MODE_NIGHT_YES = 0x20;
private static final Map<Integer, String> UI_MODE_NIGHT_VALUES = ImmutableMap.of(
UI_MODE_NIGHT_NO, "notnight",
UI_MODE_NIGHT_YES, "night");
private static final int UI_MODE_TYPE_MASK = 0x0F;
private static final int UI_MODE_TYPE_DESK = 0x02;
private static final int UI_MODE_TYPE_CAR = 0x03;
private static final int UI_MODE_TYPE_TELEVISION = 0x04;
private static final int UI_MODE_TYPE_APPLIANCE = 0x05;
private static final int UI_MODE_TYPE_WATCH = 0x06;
private static final int UI_MODE_TYPE_VR_HEADSET = 0x07;
// start - miui
private static final int UI_MODE_TYPE_GODZILLAUI = 0x0b;
private static final int UI_MODE_TYPE_SMALLUI = 0x0c;
private static final int UI_MODE_TYPE_MEDIUMUI = 0x0d;
private static final int UI_MODE_TYPE_LARGEUI = 0x0e;
private static final int UI_MODE_TYPE_HUGEUI = 0x0f;
private static final Map<Integer, String> UI_MODE_TYPE_VALUES =
ImmutableMap.<Integer, String>builder()
.put(UI_MODE_TYPE_DESK, "desk")
.put(UI_MODE_TYPE_CAR, "car")
.put(UI_MODE_TYPE_TELEVISION, "television")
.put(UI_MODE_TYPE_APPLIANCE, "appliance")
.put(UI_MODE_TYPE_WATCH, "watch")
.put(UI_MODE_TYPE_VR_HEADSET, "vrheadset")
.put(UI_MODE_TYPE_GODZILLAUI, "godzillaui")
.put(UI_MODE_TYPE_SMALLUI, "smallui")
.put(UI_MODE_TYPE_MEDIUMUI, "mediumui")
.put(UI_MODE_TYPE_LARGEUI, "largeui")
.put(UI_MODE_TYPE_HUGEUI, "hugeui").build();
/**
* The minimum size in bytes that this configuration must be to contain screen config info.
*/
private static final int SCREEN_CONFIG_MIN_SIZE = 32;
/**
* The minimum size in bytes that this configuration must be to contain screen dp info.
*/
private static final int SCREEN_DP_MIN_SIZE = 36;
/**
* The minimum size in bytes that this configuration must be to contain locale info.
*/
private static final int LOCALE_MIN_SIZE = 48;
/**
* The minimum size in bytes that this config must be to contain the screenConfig extension.
*/
private static final int SCREEN_CONFIG_EXTENSION_MIN_SIZE = 52;
private final int size; private final int size;
private final int mcc; private final int mcc;
private final int mnc; private final int mnc;
@@ -195,60 +53,9 @@ public class BinaryResourceConfiguration implements SerializableResource {
private final int screenHeightDp; private final int screenHeightDp;
private final byte[] localeScript; private final byte[] localeScript;
private final byte[] localeVariant; private final byte[] localeVariant;
// end - miui
private final int screenLayout2; private final int screenLayout2;
private final byte[] unknown; private final byte[] unknown;
private BinaryResourceConfiguration(int size,
int mcc,
int mnc,
byte[] language,
byte[] region,
int orientation,
int touchscreen,
int density,
int keyboard,
int navigation,
int inputFlags,
int screenWidth,
int screenHeight,
int sdkVersion,
int minorVersion,
int screenLayout,
int uiMode,
int smallestScreenWidthDp,
int screenWidthDp,
int screenHeightDp,
byte[] localeScript,
byte[] localeVariant,
int screenLayout2,
byte[] unknown) {
this.size = size;
this.mcc = mcc;
this.mnc = mnc;
this.language = language;
this.region = region;
this.orientation = orientation;
this.touchscreen = touchscreen;
this.density = density;
this.keyboard = keyboard;
this.navigation = navigation;
this.inputFlags = inputFlags;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
this.sdkVersion = sdkVersion;
this.minorVersion = minorVersion;
this.screenLayout = screenLayout;
this.uiMode = uiMode;
this.smallestScreenWidthDp = smallestScreenWidthDp;
this.screenWidthDp = screenWidthDp;
this.screenHeightDp = screenHeightDp;
this.localeScript = localeScript;
this.localeVariant = localeVariant;
this.screenLayout2 = screenLayout2;
this.unknown = unknown;
}
static BinaryResourceConfiguration create(ByteBuffer buffer) { static BinaryResourceConfiguration create(ByteBuffer buffer) {
int startPosition = buffer.position(); // The starting buffer position to calculate bytes read. int startPosition = buffer.position(); // The starting buffer position to calculate bytes read.
int size = buffer.getInt(); int size = buffer.getInt();
@@ -314,6 +121,245 @@ public class BinaryResourceConfiguration implements SerializableResource {
screenHeightDp, localeScript, localeVariant, screenLayout2, unknown); screenHeightDp, localeScript, localeVariant, screenLayout2, unknown);
} }
private BinaryResourceConfiguration(int size,
int mcc,
int mnc,
byte[] language,
byte[] region,
int orientation,
int touchscreen,
int density,
int keyboard,
int navigation,
int inputFlags,
int screenWidth,
int screenHeight,
int sdkVersion,
int minorVersion,
int screenLayout,
int uiMode,
int smallestScreenWidthDp,
int screenWidthDp,
int screenHeightDp,
byte[] localeScript,
byte[] localeVariant,
int screenLayout2,
byte[] unknown) {
this.size = size;
this.mcc = mcc;
this.mnc = mnc;
this.language = language;
this.region = region;
this.orientation = orientation;
this.touchscreen = touchscreen;
this.density = density;
this.keyboard = keyboard;
this.navigation = navigation;
this.inputFlags = inputFlags;
this.screenWidth = screenWidth;
this.screenHeight = screenHeight;
this.sdkVersion = sdkVersion;
this.minorVersion = minorVersion;
this.screenLayout = screenLayout;
this.uiMode = uiMode;
this.smallestScreenWidthDp = smallestScreenWidthDp;
this.screenWidthDp = screenWidthDp;
this.screenHeightDp = screenHeightDp;
this.localeScript = localeScript;
this.localeVariant = localeVariant;
this.screenLayout2 = screenLayout2;
this.unknown = unknown;
}
/**
* The different types of configs that can be present in a {@link BinaryResourceConfiguration}.
*/
public enum Type {
MCC,
MNC,
LANGUAGE_STRING,
REGION_STRING,
SCREEN_LAYOUT_DIRECTION,
SMALLEST_SCREEN_WIDTH_DP,
SCREEN_WIDTH_DP,
SCREEN_HEIGHT_DP,
SCREEN_LAYOUT_SIZE,
SCREEN_LAYOUT_LONG,
SCREEN_LAYOUT_ROUND,
ORIENTATION,
UI_MODE_TYPE,
UI_MODE_NIGHT,
DENSITY_DPI,
TOUCHSCREEN,
KEYBOARD_HIDDEN,
KEYBOARD,
NAVIGATION_HIDDEN,
NAVIGATION,
SDK_VERSION
}
/**
* The below constants are from android.content.res.Configuration.
*/
private static final int DENSITY_DPI_UNDEFINED = 0;
private static final int DENSITY_DPI_LDPI = 120;
private static final int DENSITY_DPI_MDPI = 160;
private static final int DENSITY_DPI_TVDPI = 213;
private static final int DENSITY_DPI_HDPI = 240;
private static final int DENSITY_DPI_XHDPI = 320;
private static final int DENSITY_DPI_XXHDPI = 480;
private static final int DENSITY_DPI_XXXHDPI = 640;
private static final int DENSITY_DPI_ANY = 0xFFFE;
private static final int DENSITY_DPI_NONE = 0xFFFF;
private static final Map<Integer, String> DENSITY_DPI_VALUES =
ImmutableMap.<Integer, String>builder()
.put(DENSITY_DPI_UNDEFINED, "")
.put(DENSITY_DPI_LDPI, "ldpi")
.put(DENSITY_DPI_MDPI, "mdpi")
.put(DENSITY_DPI_TVDPI, "tvdpi")
.put(DENSITY_DPI_HDPI, "hdpi")
.put(DENSITY_DPI_XHDPI, "xhdpi")
.put(DENSITY_DPI_XXHDPI, "xxhdpi")
.put(DENSITY_DPI_XXXHDPI, "xxxhdpi")
.put(DENSITY_DPI_ANY, "anydpi")
.put(DENSITY_DPI_NONE, "nodpi")
.build();
private static final int KEYBOARD_NOKEYS = 1;
private static final int KEYBOARD_QWERTY = 2;
private static final int KEYBOARD_12KEY = 3;
private static final Map<Integer, String> KEYBOARD_VALUES = ImmutableMap.of(
KEYBOARD_NOKEYS, "nokeys",
KEYBOARD_QWERTY, "qwerty",
KEYBOARD_12KEY, "12key");
private static final int KEYBOARDHIDDEN_MASK = 0x03;
private static final int KEYBOARDHIDDEN_NO = 1;
private static final int KEYBOARDHIDDEN_YES = 2;
private static final int KEYBOARDHIDDEN_SOFT = 3;
private static final Map<Integer, String> KEYBOARDHIDDEN_VALUES = ImmutableMap.of(
KEYBOARDHIDDEN_NO, "keysexposed",
KEYBOARDHIDDEN_YES, "keyshidden",
KEYBOARDHIDDEN_SOFT, "keyssoft");
private static final int NAVIGATION_NONAV = 1;
private static final int NAVIGATION_DPAD = 2;
private static final int NAVIGATION_TRACKBALL = 3;
private static final int NAVIGATION_WHEEL = 4;
private static final Map<Integer, String> NAVIGATION_VALUES = ImmutableMap.of(
NAVIGATION_NONAV, "nonav",
NAVIGATION_DPAD, "dpad",
NAVIGATION_TRACKBALL, "trackball",
NAVIGATION_WHEEL, "wheel");
private static final int NAVIGATIONHIDDEN_MASK = 0x0C;
private static final int NAVIGATIONHIDDEN_NO = 0x04;
private static final int NAVIGATIONHIDDEN_YES = 0x08;
private static final Map<Integer, String> NAVIGATIONHIDDEN_VALUES = ImmutableMap.of(
NAVIGATIONHIDDEN_NO, "navexposed",
NAVIGATIONHIDDEN_YES, "navhidden");
private static final int ORIENTATION_PORTRAIT = 0x01;
private static final int ORIENTATION_LANDSCAPE = 0x02;
private static final Map<Integer, String> ORIENTATION_VALUES = ImmutableMap.of(
ORIENTATION_PORTRAIT, "port",
ORIENTATION_LANDSCAPE, "land");
private static final int SCREENLAYOUT_LAYOUTDIR_MASK = 0xC0;
private static final int SCREENLAYOUT_LAYOUTDIR_LTR = 0x40;
private static final int SCREENLAYOUT_LAYOUTDIR_RTL = 0x80;
private static final Map<Integer, String> SCREENLAYOUT_LAYOUTDIR_VALUES = ImmutableMap.of(
SCREENLAYOUT_LAYOUTDIR_LTR, "ldltr",
SCREENLAYOUT_LAYOUTDIR_RTL, "ldrtl");
private static final int SCREENLAYOUT_LONG_MASK = 0x30;
private static final int SCREENLAYOUT_LONG_NO = 0x10;
private static final int SCREENLAYOUT_LONG_YES = 0x20;
private static final Map<Integer, String> SCREENLAYOUT_LONG_VALUES = ImmutableMap.of(
SCREENLAYOUT_LONG_NO, "notlong",
SCREENLAYOUT_LONG_YES, "long");
private static final int SCREENLAYOUT_ROUND_MASK = 0x03;
private static final int SCREENLAYOUT_ROUND_NO = 0x01;
private static final int SCREENLAYOUT_ROUND_YES = 0x02;
private static final Map<Integer, String> SCREENLAYOUT_ROUND_VALUES = ImmutableMap.of(
SCREENLAYOUT_ROUND_NO, "notround",
SCREENLAYOUT_ROUND_YES, "round");
private static final int SCREENLAYOUT_SIZE_MASK = 0x0F;
private static final int SCREENLAYOUT_SIZE_SMALL = 0x01;
private static final int SCREENLAYOUT_SIZE_NORMAL = 0x02;
private static final int SCREENLAYOUT_SIZE_LARGE = 0x03;
private static final int SCREENLAYOUT_SIZE_XLARGE = 0x04;
private static final Map<Integer, String> SCREENLAYOUT_SIZE_VALUES = ImmutableMap.of(
SCREENLAYOUT_SIZE_SMALL, "small",
SCREENLAYOUT_SIZE_NORMAL, "normal",
SCREENLAYOUT_SIZE_LARGE, "large",
SCREENLAYOUT_SIZE_XLARGE, "xlarge");
private static final int TOUCHSCREEN_NOTOUCH = 1;
private static final int TOUCHSCREEN_FINGER = 3;
private static final Map<Integer, String> TOUCHSCREEN_VALUES = ImmutableMap.of(
TOUCHSCREEN_NOTOUCH, "notouch",
TOUCHSCREEN_FINGER, "finger");
private static final int UI_MODE_NIGHT_MASK = 0x30;
private static final int UI_MODE_NIGHT_NO = 0x10;
private static final int UI_MODE_NIGHT_YES = 0x20;
private static final Map<Integer, String> UI_MODE_NIGHT_VALUES = ImmutableMap.of(
UI_MODE_NIGHT_NO, "notnight",
UI_MODE_NIGHT_YES, "night");
private static final int UI_MODE_TYPE_MASK = 0x0F;
private static final int UI_MODE_TYPE_DESK = 0x02;
private static final int UI_MODE_TYPE_CAR = 0x03;
private static final int UI_MODE_TYPE_TELEVISION = 0x04;
private static final int UI_MODE_TYPE_APPLIANCE = 0x05;
private static final int UI_MODE_TYPE_WATCH = 0x06;
private static final int UI_MODE_TYPE_VR_HEADSET = 0x07;
// start - miui
private static final int UI_MODE_TYPE_GODZILLAUI = 0x0b;
private static final int UI_MODE_TYPE_SMALLUI = 0x0c;
private static final int UI_MODE_TYPE_MEDIUMUI = 0x0d;
private static final int UI_MODE_TYPE_LARGEUI = 0x0e;
private static final int UI_MODE_TYPE_HUGEUI = 0x0f;
// end - miui
private static final Map<Integer, String> UI_MODE_TYPE_VALUES =
ImmutableMap.<Integer, String>builder()
.put(UI_MODE_TYPE_DESK, "desk")
.put(UI_MODE_TYPE_CAR, "car")
.put(UI_MODE_TYPE_TELEVISION, "television")
.put(UI_MODE_TYPE_APPLIANCE, "appliance")
.put(UI_MODE_TYPE_WATCH, "watch")
.put(UI_MODE_TYPE_VR_HEADSET, "vrheadset")
.put(UI_MODE_TYPE_GODZILLAUI, "godzillaui")
.put(UI_MODE_TYPE_SMALLUI, "smallui")
.put(UI_MODE_TYPE_MEDIUMUI, "mediumui")
.put(UI_MODE_TYPE_LARGEUI, "largeui")
.put(UI_MODE_TYPE_HUGEUI, "hugeui").build();
/**
* The minimum size in bytes that this configuration must be to contain screen config info.
*/
private static final int SCREEN_CONFIG_MIN_SIZE = 32;
/**
* The minimum size in bytes that this configuration must be to contain screen dp info.
*/
private static final int SCREEN_DP_MIN_SIZE = 36;
/**
* The minimum size in bytes that this configuration must be to contain locale info.
*/
private static final int LOCALE_MIN_SIZE = 48;
/**
* The minimum size in bytes that this config must be to contain the screenConfig extension.
*/
private static final int SCREEN_CONFIG_EXTENSION_MIN_SIZE = 52;
/** /**
* The number of bytes that this resource configuration takes up. * The number of bytes that this resource configuration takes up.
*/ */
@@ -662,7 +708,7 @@ public class BinaryResourceConfiguration implements SerializableResource {
Map<Type, String> result = new LinkedHashMap<>(); // Preserve order for #toString(). Map<Type, String> result = new LinkedHashMap<>(); // Preserve order for #toString().
result.put(Type.MCC, mcc() != 0 ? "mcc" + mcc() : ""); result.put(Type.MCC, mcc() != 0 ? "mcc" + mcc() : "");
result.put(Type.MNC, mnc() != 0 ? "mnc" + mnc() : ""); result.put(Type.MNC, mnc() != 0 ? "mnc" + mnc() : "");
result.put(Type.LANGUAGE_STRING, !languageString().isEmpty() ? languageString() : ""); result.put(Type.LANGUAGE_STRING, !languageString().isEmpty() ? "" + languageString() : "");
result.put(Type.REGION_STRING, !regionString().isEmpty() ? "r" + regionString() : ""); result.put(Type.REGION_STRING, !regionString().isEmpty() ? "r" + regionString() : "");
result.put(Type.SCREEN_LAYOUT_DIRECTION, result.put(Type.SCREEN_LAYOUT_DIRECTION,
getOrDefault(SCREENLAYOUT_LAYOUTDIR_VALUES, screenLayoutDirection(), "")); getOrDefault(SCREENLAYOUT_LAYOUTDIR_VALUES, screenLayoutDirection(), ""));
@@ -696,31 +742,4 @@ public class BinaryResourceConfiguration implements SerializableResource {
V value = map.get(key); V value = map.get(key);
return value != null ? value : defaultValue; return value != null ? value : defaultValue;
} }
/**
* The different types of configs that can be present in a {@link BinaryResourceConfiguration}.
*/
public enum Type {
MCC,
MNC,
LANGUAGE_STRING,
REGION_STRING,
SCREEN_LAYOUT_DIRECTION,
SMALLEST_SCREEN_WIDTH_DP,
SCREEN_WIDTH_DP,
SCREEN_HEIGHT_DP,
SCREEN_LAYOUT_SIZE,
SCREEN_LAYOUT_LONG,
SCREEN_LAYOUT_ROUND,
ORIENTATION,
UI_MODE_TYPE,
UI_MODE_NIGHT,
DENSITY_DPI,
TOUCHSCREEN,
KEYBOARD_HIDDEN,
KEYBOARD,
NAVIGATION_HIDDEN,
NAVIGATION,
SDK_VERSION
}
} }
@@ -49,12 +49,6 @@ public class BinaryResourceIdentifier {
private final int typeId; private final int typeId;
private final int entryId; private final int entryId;
private BinaryResourceIdentifier(int packageId, int typeId, int entryId) {
this.packageId = packageId;
this.typeId = typeId;
this.entryId = entryId;
}
/** /**
* Returns a {@link BinaryResourceIdentifier} from a {@code resourceId} of the form 0xpptteeee. * Returns a {@link BinaryResourceIdentifier} from a {@code resourceId} of the form 0xpptteeee.
*/ */
@@ -75,6 +69,12 @@ public class BinaryResourceIdentifier {
return new BinaryResourceIdentifier(packageId, typeId, entryId); return new BinaryResourceIdentifier(packageId, typeId, entryId);
} }
private BinaryResourceIdentifier(int packageId, int typeId, int entryId) {
this.packageId = packageId;
this.typeId = typeId;
this.entryId = entryId;
}
/** /**
* The (1-based) id of the {@link PackageChunk} containing this resource. * The (1-based) id of the {@link PackageChunk} containing this resource.
*/ */
@@ -31,6 +31,24 @@ import static java.nio.charset.StandardCharsets.UTF_8;
*/ */
public final class BinaryResourceString { public final class BinaryResourceString {
/**
* Type of {@link BinaryResourceString} to encode / decode.
*/
public enum Type {
UTF8(UTF_8),
UTF16(UTF_16LE);
private final Charset charset;
Type(Charset charset) {
this.charset = charset;
}
public Charset charset() {
return charset;
}
}
private BinaryResourceString() { private BinaryResourceString() {
} // Private constructor } // Private constructor
@@ -148,22 +166,4 @@ public final class BinaryResourceString {
} }
return length; return length;
} }
/**
* Type of {@link BinaryResourceString} to encode / decode.
*/
public enum Type {
UTF8(UTF_8),
UTF16(UTF_16LE);
private final Charset charset;
Type(Charset charset) {
this.charset = charset;
}
public Charset charset() {
return charset;
}
}
} }
@@ -31,78 +31,6 @@ import java.util.Objects;
*/ */
public class BinaryResourceValue implements SerializableResource { public class BinaryResourceValue implements SerializableResource {
/**
* The serialized size in bytes of a {@link BinaryResourceValue}.
*/
public static final int SIZE = 8;
public int size;
public Type type;
public int data;
public BinaryResourceValue(int size, Type type, int data) {
this.size = size;
this.type = type;
this.data = data;
}
public static BinaryResourceValue create(ByteBuffer buffer) {
int size = (buffer.getShort() & 0xFFFF);
buffer.get(); // Unused
Type type = Type.fromCode(buffer.get());
int data = buffer.getInt();
return new BinaryResourceValue(size, type, data);
}
/**
* The length in bytes of this value.
*/
public int size() {
return size;
}
/**
* The raw data type of this value.
*/
public Type type() {
return type;
}
/**
* The actual 4-byte value; interpretation of the value depends on {@code dataType}.
*/
public int data() {
return data;
}
@Override
public byte[] toByteArray() {
return toByteArray(false);
}
@Override
public byte[] toByteArray(boolean shrink) {
ByteBuffer buffer = ByteBuffer.allocate(SIZE).order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) size());
buffer.put((byte) 0); // Unused
buffer.put(type().code());
buffer.putInt(data());
return buffer.array();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BinaryResourceValue that = (BinaryResourceValue) o;
return size == that.size &&
data == that.data &&
type == that.type;
}
@Override
public int hashCode() {
return Objects.hash(size, type, data);
}
/** /**
* Resource type codes. * Resource type codes.
*/ */
@@ -172,6 +100,8 @@ public class BinaryResourceValue implements SerializableResource {
*/ */
INT_COLOR_RGB4(0x1f); INT_COLOR_RGB4(0x1f);
private final byte code;
private static final Map<Byte, Type> FROM_BYTE; private static final Map<Byte, Type> FROM_BYTE;
static { static {
@@ -182,18 +112,90 @@ public class BinaryResourceValue implements SerializableResource {
FROM_BYTE = builder.build(); FROM_BYTE = builder.build();
} }
private final byte code;
Type(int code) { Type(int code) {
this.code = UnsignedBytes.checkedCast(code); this.code = UnsignedBytes.checkedCast(code);
} }
public static Type fromCode(byte code) {
return Preconditions.checkNotNull(FROM_BYTE.get(code), "Unknown resource type: %s", code);
}
public byte code() { public byte code() {
return code; return code;
} }
public static Type fromCode(byte code) {
return Preconditions.checkNotNull(FROM_BYTE.get(code), "Unknown resource type: %s", code);
}
}
/**
* The serialized size in bytes of a {@link BinaryResourceValue}.
*/
public static final int SIZE = 8;
public int size;
public Type type;
public int data;
public static BinaryResourceValue create(ByteBuffer buffer) {
int size = (buffer.getShort() & 0xFFFF);
buffer.get(); // Unused
Type type = Type.fromCode(buffer.get());
int data = buffer.getInt();
return new BinaryResourceValue(size, type, data);
}
public BinaryResourceValue(int size, Type type, int data) {
this.size = size;
this.type = type;
this.data = data;
}
/**
* The length in bytes of this value.
*/
public int size() {
return size;
}
/**
* The raw data type of this value.
*/
public Type type() {
return type;
}
/**
* The actual 4-byte value; interpretation of the value depends on {@code dataType}.
*/
public int data() {
return data;
}
@Override
public byte[] toByteArray() {
return toByteArray(false);
}
@Override
public byte[] toByteArray(boolean shrink) {
ByteBuffer buffer = ByteBuffer.allocate(SIZE).order(ByteOrder.LITTLE_ENDIAN);
buffer.putShort((short) size());
buffer.put((byte) 0); // Unused
buffer.put(type().code());
buffer.putInt(data());
return buffer.array();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
BinaryResourceValue that = (BinaryResourceValue) o;
return size == that.size &&
data == that.data &&
type == that.type;
}
@Override
public int hashCode() {
return Objects.hash(size, type, data);
} }
} }
@@ -35,36 +35,86 @@ import java.util.Map;
*/ */
public abstract class Chunk implements SerializableResource { public abstract class Chunk implements SerializableResource {
/**
* Types of chunks that can exist.
*/
public enum Type {
NULL(0x0000),
STRING_POOL(0x0001),
TABLE(0x0002),
XML(0x0003),
XML_START_NAMESPACE(0x0100),
XML_END_NAMESPACE(0x0101),
XML_START_ELEMENT(0x0102),
XML_END_ELEMENT(0x0103),
XML_CDATA(0x0104),
XML_RESOURCE_MAP(0x0180),
TABLE_PACKAGE(0x0200),
TABLE_TYPE(0x0201),
TABLE_TYPE_SPEC(0x0202),
TABLE_LIBRARY(0x0203);
private final short code;
private static final Map<Short, Type> FROM_SHORT;
static {
Builder<Short, Type> builder = ImmutableMap.builder();
for (Type type : values()) {
builder.put(type.code(), type);
}
FROM_SHORT = builder.build();
}
Type(int code) {
this.code = Shorts.checkedCast(code);
}
public short code() {
return code;
}
public static Type fromCode(short code) {
return Preconditions.checkNotNull(FROM_SHORT.get(code), "Unknown chunk type: %s", code);
}
}
/** /**
* The byte boundary to pad chunks on. * The byte boundary to pad chunks on.
*/ */
public static final int PAD_BOUNDARY = 4; public static final int PAD_BOUNDARY = 4;
/** /**
* The number of bytes in every chunk that describes chunk type, header size, and chunk size. * The number of bytes in every chunk that describes chunk type, header size, and chunk size.
*/ */
public static final int METADATA_SIZE = 8; public static final int METADATA_SIZE = 8;
/** /**
* The offset in bytes, from the start of the chunk, where the chunk size can be found. * The offset in bytes, from the start of the chunk, where the chunk size can be found.
*/ */
private static final int CHUNK_SIZE_OFFSET = 4; private static final int CHUNK_SIZE_OFFSET = 4;
/**
* Size of the chunk header in bytes.
*/
protected final int headerSize;
/**
* headerSize + dataSize. The total size of this chunk.
*/
protected final int chunkSize;
/**
* Offset of this chunk from the start of the file.
*/
protected final int offset;
/** /**
* The parent to this chunk, if any. * The parent to this chunk, if any.
*/ */
@Nullable @Nullable
private final Chunk parent; private final Chunk parent;
/**
* Size of the chunk header in bytes.
*/
protected final int headerSize;
/**
* headerSize + dataSize. The total size of this chunk.
*/
protected final int chunkSize;
/**
* Offset of this chunk from the start of the file.
*/
protected final int offset;
protected Chunk(ByteBuffer buffer, @Nullable Chunk parent) { protected Chunk(ByteBuffer buffer, @Nullable Chunk parent) {
this.parent = parent; this.parent = parent;
offset = buffer.position() - 2; offset = buffer.position() - 2;
@@ -72,74 +122,6 @@ public abstract class Chunk implements SerializableResource {
chunkSize = buffer.getInt(); chunkSize = buffer.getInt();
} }
/**
* Creates a new chunk whose contents start at {@code buffer}'s current position.
*
* @param buffer A buffer positioned at the start of a chunk.
* @return new chunk
*/
public static Chunk newInstance(ByteBuffer buffer) {
return newInstance(buffer, null);
}
/**
* Creates a new chunk whose contents start at {@code buffer}'s current position.
*
* @param buffer A buffer positioned at the start of a chunk.
* @param parent The parent to this chunk (or null if there's no parent).
* @return new chunk
*/
public static Chunk newInstance(ByteBuffer buffer, @Nullable Chunk parent) {
Chunk result;
Type type = Type.fromCode(buffer.getShort());
switch (type) {
case STRING_POOL:
result = new StringPoolChunk(buffer, parent);
break;
case TABLE:
result = new ResourceTableChunk(buffer, parent);
break;
case XML:
result = new XmlChunk(buffer, parent);
break;
case XML_START_NAMESPACE:
result = new XmlNamespaceStartChunk(buffer, parent);
break;
case XML_END_NAMESPACE:
result = new XmlNamespaceEndChunk(buffer, parent);
break;
case XML_START_ELEMENT:
result = new XmlStartElementChunk(buffer, parent);
break;
case XML_END_ELEMENT:
result = new XmlEndElementChunk(buffer, parent);
break;
case XML_CDATA:
result = new XmlCdataChunk(buffer, parent);
break;
case XML_RESOURCE_MAP:
result = new XmlResourceMapChunk(buffer, parent);
break;
case TABLE_PACKAGE:
result = new PackageChunk(buffer, parent);
break;
case TABLE_TYPE:
result = new TypeChunk(buffer, parent);
break;
case TABLE_TYPE_SPEC:
result = new TypeSpecChunk(buffer, parent);
break;
case TABLE_LIBRARY:
result = new LibraryChunk(buffer, parent);
break;
default:
result = new UnknownChunk(buffer, parent);
}
result.init(buffer);
result.seekToEndOfChunk(buffer);
return result;
}
/** /**
* Finishes initialization of a chunk. This should be called immediately after the constructor. * Finishes initialization of a chunk. This should be called immediately after the constructor.
* This is separate from the constructor so that the header of a chunk can be fully initialized * This is separate from the constructor so that the header of a chunk can be fully initialized
@@ -274,46 +256,70 @@ public abstract class Chunk implements SerializableResource {
} }
/** /**
* Types of chunks that can exist. * Creates a new chunk whose contents start at {@code buffer}'s current position.
*
* @param buffer A buffer positioned at the start of a chunk.
* @return new chunk
*/ */
public enum Type { public static Chunk newInstance(ByteBuffer buffer) {
NULL(0x0000), return newInstance(buffer, null);
STRING_POOL(0x0001), }
TABLE(0x0002),
XML(0x0003),
XML_START_NAMESPACE(0x0100),
XML_END_NAMESPACE(0x0101),
XML_START_ELEMENT(0x0102),
XML_END_ELEMENT(0x0103),
XML_CDATA(0x0104),
XML_RESOURCE_MAP(0x0180),
TABLE_PACKAGE(0x0200),
TABLE_TYPE(0x0201),
TABLE_TYPE_SPEC(0x0202),
TABLE_LIBRARY(0x0203);
private static final Map<Short, Type> FROM_SHORT; /**
* Creates a new chunk whose contents start at {@code buffer}'s current position.
static { *
Builder<Short, Type> builder = ImmutableMap.builder(); * @param buffer A buffer positioned at the start of a chunk.
for (Type type : values()) { * @param parent The parent to this chunk (or null if there's no parent).
builder.put(type.code(), type); * @return new chunk
} */
FROM_SHORT = builder.build(); public static Chunk newInstance(ByteBuffer buffer, @Nullable Chunk parent) {
} Chunk result;
Type type = Type.fromCode(buffer.getShort());
private final short code; switch (type) {
case STRING_POOL:
Type(int code) { result = new StringPoolChunk(buffer, parent);
this.code = Shorts.checkedCast(code); break;
} case TABLE:
result = new ResourceTableChunk(buffer, parent);
public static Type fromCode(short code) { break;
return Preconditions.checkNotNull(FROM_SHORT.get(code), "Unknown chunk type: %s", code); case XML:
} result = new XmlChunk(buffer, parent);
break;
public short code() { case XML_START_NAMESPACE:
return code; result = new XmlNamespaceStartChunk(buffer, parent);
break;
case XML_END_NAMESPACE:
result = new XmlNamespaceEndChunk(buffer, parent);
break;
case XML_START_ELEMENT:
result = new XmlStartElementChunk(buffer, parent);
break;
case XML_END_ELEMENT:
result = new XmlEndElementChunk(buffer, parent);
break;
case XML_CDATA:
result = new XmlCdataChunk(buffer, parent);
break;
case XML_RESOURCE_MAP:
result = new XmlResourceMapChunk(buffer, parent);
break;
case TABLE_PACKAGE:
result = new PackageChunk(buffer, parent);
break;
case TABLE_TYPE:
result = new TypeChunk(buffer, parent);
break;
case TABLE_TYPE_SPEC:
result = new TypeSpecChunk(buffer, parent);
break;
case TABLE_LIBRARY:
result = new LibraryChunk(buffer, parent);
break;
default:
result = new UnknownChunk(buffer, parent);
} }
result.init(buffer);
result.seekToEndOfChunk(buffer);
return result;
} }
} }
@@ -43,7 +43,7 @@ public final class LibraryChunk extends Chunk {
*/ */
private final List<Entry> entries = new ArrayList<>(); private final List<Entry> entries = new ArrayList<>();
LibraryChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected LibraryChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
entryCount = buffer.getInt(); entryCount = buffer.getInt();
} }
@@ -98,17 +98,17 @@ public final class LibraryChunk extends Chunk {
private final int packageId; private final int packageId;
private final String packageName; private final String packageName;
private Entry(int packageId, String packageName) {
this.packageId = packageId;
this.packageName = packageName;
}
static Entry create(ByteBuffer buffer, int offset) { static Entry create(ByteBuffer buffer, int offset) {
int packageId = buffer.getInt(offset); int packageId = buffer.getInt(offset);
String packageName = PackageUtils.readPackageName(buffer, offset + 4); String packageName = PackageUtils.readPackageName(buffer, offset + 4);
return new Entry(packageId, packageName); return new Entry(packageId, packageName);
} }
private Entry(int packageId, String packageName) {
this.packageId = packageId;
this.packageName = packageName;
}
/** /**
* The id assigned to the shared library at build time. * The id assigned to the shared library at build time.
*/ */
@@ -43,48 +43,58 @@ public final class PackageChunk extends ChunkWithChunks {
* Offset in bytes, from the start of the chunk, where {@code keyStringsOffset} can be found. * Offset in bytes, from the start of the chunk, where {@code keyStringsOffset} can be found.
*/ */
private static final int KEY_OFFSET_OFFSET = 276; private static final int KEY_OFFSET_OFFSET = 276;
/**
* The offset (from {@code offset}) in the original buffer where type strings start.
*/
private final int typeStringsOffset;
/**
* The index into the type string pool of the last public type.
*/
private final int lastPublicType;
/**
* An offset to the string pool that contains the key strings for this package.
*/
private final int keyStringsOffset;
/**
* The index into the key string pool of the last public key.
*/
private final int lastPublicKey;
/**
* An offset to the type ID(s). This is undocumented in the original code.
*/
private final int typeIdOffset;
/**
* Contains a mapping of a type index to its {@link TypeSpecChunk}.
*/
private final Map<Integer, TypeSpecChunk> typeSpecs = new HashMap<>();
/**
* Contains a mapping of a type index to all of the {@link TypeChunk} with that index.
*/
private final Multimap<Integer, TypeChunk> types = ArrayListMultimap.create();
/** /**
* The package id if this is a base package, or 0 if not a base package. * The package id if this is a base package, or 0 if not a base package.
*/ */
private int id; private int id;
/** /**
* The name of the package. * The name of the package.
*/ */
private String packageName; private String packageName;
/**
* The offset (from {@code offset}) in the original buffer where type strings start.
*/
private final int typeStringsOffset;
/**
* The index into the type string pool of the last public type.
*/
private final int lastPublicType;
/**
* An offset to the string pool that contains the key strings for this package.
*/
private final int keyStringsOffset;
/**
* The index into the key string pool of the last public key.
*/
private final int lastPublicKey;
/**
* An offset to the type ID(s). This is undocumented in the original code.
*/
private final int typeIdOffset;
/**
* Contains a mapping of a type index to its {@link TypeSpecChunk}.
*/
private final Map<Integer, TypeSpecChunk> typeSpecs = new HashMap<>();
/**
* Contains a mapping of a type index to all of the {@link TypeChunk} with that index.
*/
private final Multimap<Integer, TypeChunk> types = ArrayListMultimap.create();
/** /**
* May contain a library chunk for mapping dynamic references to resolved references. * May contain a library chunk for mapping dynamic references to resolved references.
*/ */
private Optional<LibraryChunk> libraryChunk = Optional.empty(); private Optional<LibraryChunk> libraryChunk = Optional.empty();
PackageChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected PackageChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
id = buffer.getInt(); id = buffer.getInt();
packageName = PackageUtils.readPackageName(buffer, buffer.position()); packageName = PackageUtils.readPackageName(buffer, buffer.position());
@@ -36,16 +36,17 @@ import java.util.Map;
*/ */
public final class ResourceTableChunk extends ChunkWithChunks { public final class ResourceTableChunk extends ChunkWithChunks {
/**
* The packages contained in this resource table.
*/
private final Map<String, PackageChunk> packages = new HashMap<>();
/** /**
* A string pool containing all string resource values in the entire resource table. * A string pool containing all string resource values in the entire resource table.
*/ */
private StringPoolChunk stringPool; private StringPoolChunk stringPool;
ResourceTableChunk(ByteBuffer buffer, @Nullable Chunk parent) { /**
* The packages contained in this resource table.
*/
private final Map<String, PackageChunk> packages = new HashMap<>();
protected ResourceTableChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
// packageCount. We ignore this, because we already know how many chunks we have. // packageCount. We ignore this, because we already know how many chunks we have.
Preconditions.checkState(buffer.getInt() >= 1, "ResourceTableChunk package count was < 1."); Preconditions.checkState(buffer.getInt() >= 1, "ResourceTableChunk package count was < 1.");
@@ -89,7 +89,7 @@ public final class StringPoolChunk extends Chunk {
*/ */
private boolean isOriginalDeduped = false; private boolean isOriginalDeduped = false;
StringPoolChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected StringPoolChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
stringCount = buffer.getInt(); stringCount = buffer.getInt();
styleCount = buffer.getInt(); styleCount = buffer.getInt();
@@ -310,10 +310,6 @@ public final class StringPoolChunk extends Chunk {
static final int RES_STRING_POOL_SPAN_END = 0xFFFFFFFF; static final int RES_STRING_POOL_SPAN_END = 0xFFFFFFFF;
private final List<StringPoolSpan> spans; private final List<StringPoolSpan> spans;
private StringPoolStyle(List<StringPoolSpan> spans) {
this.spans = spans;
}
static StringPoolStyle create(ByteBuffer buffer, int offset, StringPoolChunk parent) { static StringPoolStyle create(ByteBuffer buffer, int offset, StringPoolChunk parent) {
Builder<StringPoolSpan> spans = ImmutableList.builder(); Builder<StringPoolSpan> spans = ImmutableList.builder();
int nameIndex = buffer.getInt(offset); int nameIndex = buffer.getInt(offset);
@@ -325,6 +321,10 @@ public final class StringPoolChunk extends Chunk {
return new StringPoolStyle(spans.build()); return new StringPoolStyle(spans.build());
} }
private StringPoolStyle(List<StringPoolSpan> spans) {
this.spans = spans;
}
@Override @Override
public byte[] toByteArray() throws IOException { public byte[] toByteArray() throws IOException {
return toByteArray(false); return toByteArray(false);
@@ -384,13 +384,6 @@ public final class StringPoolChunk extends Chunk {
private final int stop; private final int stop;
private final StringPoolChunk parent; private final StringPoolChunk parent;
private StringPoolSpan(int nameIndex, int start, int stop, StringPoolChunk parent) {
this.nameIndex = nameIndex;
this.start = start;
this.stop = stop;
this.parent = parent;
}
static StringPoolSpan create(ByteBuffer buffer, int offset, StringPoolChunk parent) { static StringPoolSpan create(ByteBuffer buffer, int offset, StringPoolChunk parent) {
int nameIndex = buffer.getInt(offset); int nameIndex = buffer.getInt(offset);
int start = buffer.getInt(offset + 4); int start = buffer.getInt(offset + 4);
@@ -398,6 +391,13 @@ public final class StringPoolChunk extends Chunk {
return new StringPoolSpan(nameIndex, start, stop, parent); return new StringPoolSpan(nameIndex, start, stop, parent);
} }
private StringPoolSpan(int nameIndex, int start, int stop, StringPoolChunk parent) {
this.nameIndex = nameIndex;
this.start = start;
this.stop = stop;
this.parent = parent;
}
@Override @Override
public final byte[] toByteArray() { public final byte[] toByteArray() {
return toByteArray(false); return toByteArray(false);
@@ -52,16 +52,18 @@ public final class TypeChunk extends Chunk {
* The offset (from {@code offset}) in the original buffer where {@code entries} start. * The offset (from {@code offset}) in the original buffer where {@code entries} start.
*/ */
private final int entriesStart; private final int entriesStart;
/**
* A sparse list of resource entries defined by this chunk.
*/
private final Map<Integer, Entry> entries = new TreeMap<>();
/** /**
* The resource configuration that these resource entries correspond to. * The resource configuration that these resource entries correspond to.
*/ */
private BinaryResourceConfiguration configuration; private BinaryResourceConfiguration configuration;
TypeChunk(ByteBuffer buffer, @Nullable Chunk parent) { /**
* A sparse list of resource entries defined by this chunk.
*/
private final Map<Integer, Entry> entries = new TreeMap<>();
protected TypeChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
id = UnsignedBytes.toInt(buffer.get()); id = UnsignedBytes.toInt(buffer.get());
buffer.position(buffer.position() + 3); // Skip 3 bytes for packing buffer.position(buffer.position() + 3); // Skip 3 bytes for packing
@@ -174,13 +176,13 @@ public final class TypeChunk extends Chunk {
} }
} }
private String getString(int index) { protected String getString(int index) {
ResourceTableChunk resourceTable = getResourceTableChunk(); ResourceTableChunk resourceTable = getResourceTableChunk();
Preconditions.checkNotNull(resourceTable, "%s has no resource table.", getClass()); Preconditions.checkNotNull(resourceTable, "%s has no resource table.", getClass());
return resourceTable.getStringPool().getString(index); return resourceTable.getStringPool().getString(index);
} }
private String getKeyName(int index) { protected String getKeyName(int index) {
PackageChunk packageChunk = getPackageChunk(); PackageChunk packageChunk = getPackageChunk();
Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass()); Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass());
StringPoolChunk keyPool = packageChunk.getKeyStringPool(); StringPoolChunk keyPool = packageChunk.getKeyStringPool();
@@ -188,7 +190,7 @@ public final class TypeChunk extends Chunk {
return keyPool.getString(index); return keyPool.getString(index);
} }
private void updateKey(int index, String value) { protected void updateKey(int index, String value) {
PackageChunk packageChunk = getPackageChunk(); PackageChunk packageChunk = getPackageChunk();
Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass()); Preconditions.checkNotNull(packageChunk, "%s has no parent package.", getClass());
StringPoolChunk keyPool = packageChunk.getKeyStringPool(); StringPoolChunk keyPool = packageChunk.getKeyStringPool();
@@ -291,10 +293,10 @@ public final class TypeChunk extends Chunk {
private final int headerSize; private final int headerSize;
private final int flags; private final int flags;
private final int keyIndex; private final int keyIndex;
private BinaryResourceValue value;
private Map<Integer, BinaryResourceValue> values;
private final int parentEntry; private final int parentEntry;
private final TypeChunk parent; private final TypeChunk parent;
private BinaryResourceValue value;
private final Map<Integer, BinaryResourceValue> values;
private Entry(int headerSize, private Entry(int headerSize,
int flags, int flags,
@@ -312,52 +314,6 @@ public final class TypeChunk extends Chunk {
this.parent = parent; this.parent = parent;
} }
/**
* Creates a new {@link Entry} whose contents start at the 0-based position in
* {@code buffer} given by a 4-byte value read from {@code buffer} and then added to
* {@code baseOffset}. If the value read from {@code buffer} is equal to {@link #NO_ENTRY}, then
* null is returned as there is no resource at that position.
*
* <p>Otherwise, this position is parsed and returned as an {@link Entry}.
*
* @param buffer A buffer positioned at an offset to an {@link Entry}.
* @param baseOffset Offset that must be added to the value at {@code buffer}'s position.
* @param parent The {@link TypeChunk} that this resource entry belongs to.
* @return New {@link Entry} or null if there is no resource at this location.
*/
@Nullable
public static Entry create(ByteBuffer buffer, int baseOffset, TypeChunk parent) {
int offset = buffer.getInt();
if (offset == NO_ENTRY) {
return null;
}
int position = buffer.position();
buffer.position(baseOffset + offset); // Set buffer position to resource entry start
Entry result = newInstance(buffer, parent);
buffer.position(position); // Restore buffer position
return result;
}
@Nullable
private static Entry newInstance(ByteBuffer buffer, TypeChunk parent) {
int headerSize = buffer.getShort() & 0xFFFF;
int flags = buffer.getShort() & 0xFFFF;
int keyIndex = buffer.getInt();
BinaryResourceValue value = null;
Map<Integer, BinaryResourceValue> values = new LinkedHashMap<>();
int parentEntry = 0;
if ((flags & FLAG_COMPLEX) != 0) {
parentEntry = buffer.getInt();
int valueCount = buffer.getInt();
for (int i = 0; i < valueCount; ++i) {
values.put(buffer.getInt(), BinaryResourceValue.create(buffer));
}
} else {
value = BinaryResourceValue.create(buffer);
}
return new Entry(headerSize, flags, keyIndex, value, values, parentEntry, parent);
}
/** /**
* Number of bytes in the header of the {@link Entry}. * Number of bytes in the header of the {@link Entry}.
*/ */
@@ -466,6 +422,52 @@ public final class TypeChunk extends Chunk {
return (flags() & FLAG_COMPLEX) != 0; return (flags() & FLAG_COMPLEX) != 0;
} }
/**
* Creates a new {@link Entry} whose contents start at the 0-based position in
* {@code buffer} given by a 4-byte value read from {@code buffer} and then added to
* {@code baseOffset}. If the value read from {@code buffer} is equal to {@link #NO_ENTRY}, then
* null is returned as there is no resource at that position.
*
* <p>Otherwise, this position is parsed and returned as an {@link Entry}.
*
* @param buffer A buffer positioned at an offset to an {@link Entry}.
* @param baseOffset Offset that must be added to the value at {@code buffer}'s position.
* @param parent The {@link TypeChunk} that this resource entry belongs to.
* @return New {@link Entry} or null if there is no resource at this location.
*/
@Nullable
public static Entry create(ByteBuffer buffer, int baseOffset, TypeChunk parent) {
int offset = buffer.getInt();
if (offset == NO_ENTRY) {
return null;
}
int position = buffer.position();
buffer.position(baseOffset + offset); // Set buffer position to resource entry start
Entry result = newInstance(buffer, parent);
buffer.position(position); // Restore buffer position
return result;
}
@Nullable
private static Entry newInstance(ByteBuffer buffer, TypeChunk parent) {
int headerSize = buffer.getShort() & 0xFFFF;
int flags = buffer.getShort() & 0xFFFF;
int keyIndex = buffer.getInt();
BinaryResourceValue value = null;
Map<Integer, BinaryResourceValue> values = new LinkedHashMap<>();
int parentEntry = 0;
if ((flags & FLAG_COMPLEX) != 0) {
parentEntry = buffer.getInt();
int valueCount = buffer.getInt();
for (int i = 0; i < valueCount; ++i) {
values.put(buffer.getInt(), BinaryResourceValue.create(buffer));
}
} else {
value = BinaryResourceValue.create(buffer);
}
return new Entry(headerSize, flags, keyIndex, value, values, parentEntry, parent);
}
@Override @Override
public final byte[] toByteArray() { public final byte[] toByteArray() {
return toByteArray(false); return toByteArray(false);
@@ -39,7 +39,7 @@ public final class TypeSpecChunk extends Chunk {
*/ */
private final int[] resources; private final int[] resources;
TypeSpecChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected TypeSpecChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
id = UnsignedBytes.toInt(buffer.get()); id = UnsignedBytes.toInt(buffer.get());
buffer.position(buffer.position() + 3); // Skip 3 bytes for packing buffer.position(buffer.position() + 3); // Skip 3 bytes for packing
@@ -34,7 +34,7 @@ public final class UnknownChunk extends Chunk {
private final byte[] payload; private final byte[] payload;
UnknownChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected UnknownChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
type = Type.fromCode(buffer.getShort(offset)); type = Type.fromCode(buffer.getShort(offset));
@@ -36,18 +36,6 @@ public class XmlAttribute implements SerializableResource {
private final BinaryResourceValue typedValue; private final BinaryResourceValue typedValue;
private final XmlNodeChunk parent; private final XmlNodeChunk parent;
private XmlAttribute(int namespaceIndex,
int nameIndex,
int rawValueIndex,
BinaryResourceValue typedValue,
XmlNodeChunk parent) {
this.namespaceIndex = namespaceIndex;
this.nameIndex = nameIndex;
this.rawValueIndex = rawValueIndex;
this.typedValue = typedValue;
this.parent = parent;
}
/** /**
* Creates a new {@link XmlAttribute} based on the bytes at the current {@code buffer} position. * Creates a new {@link XmlAttribute} based on the bytes at the current {@code buffer} position.
* *
@@ -62,6 +50,18 @@ public class XmlAttribute implements SerializableResource {
return new XmlAttribute(namespace, name, rawValue, typedValue, parent); return new XmlAttribute(namespace, name, rawValue, typedValue, parent);
} }
private XmlAttribute(int namespaceIndex,
int nameIndex,
int rawValueIndex,
BinaryResourceValue typedValue,
XmlNodeChunk parent) {
this.namespaceIndex = namespaceIndex;
this.nameIndex = nameIndex;
this.rawValueIndex = rawValueIndex;
this.typedValue = typedValue;
this.parent = parent;
}
/** /**
* A string reference to the namespace URI, or -1 if not present. * A string reference to the namespace URI, or -1 if not present.
*/ */
@@ -37,7 +37,7 @@ public final class XmlCdataChunk extends XmlNodeChunk {
*/ */
private final BinaryResourceValue binaryResourceValue; private final BinaryResourceValue binaryResourceValue;
XmlCdataChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlCdataChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
rawValue = buffer.getInt(); rawValue = buffer.getInt();
binaryResourceValue = BinaryResourceValue.create(buffer); binaryResourceValue = BinaryResourceValue.create(buffer);
@@ -28,7 +28,7 @@ import java.nio.ByteBuffer;
*/ */
public final class XmlChunk extends ChunkWithChunks { public final class XmlChunk extends ChunkWithChunks {
XmlChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
} }
@@ -37,7 +37,7 @@ public final class XmlEndElementChunk extends XmlNodeChunk {
*/ */
private final int name; private final int name;
XmlEndElementChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlEndElementChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
namespace = buffer.getInt(); namespace = buffer.getInt();
name = buffer.getInt(); name = buffer.getInt();
@@ -25,7 +25,7 @@ import java.nio.ByteBuffer;
*/ */
public final class XmlNamespaceEndChunk extends XmlNamespaceChunk { public final class XmlNamespaceEndChunk extends XmlNamespaceChunk {
XmlNamespaceEndChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlNamespaceEndChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
} }
@@ -25,7 +25,7 @@ import java.nio.ByteBuffer;
*/ */
public final class XmlNamespaceStartChunk extends XmlNamespaceChunk { public final class XmlNamespaceStartChunk extends XmlNamespaceChunk {
XmlNamespaceStartChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlNamespaceStartChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
} }
@@ -71,7 +71,7 @@ public final class XmlStartElementChunk extends XmlNodeChunk {
*/ */
private final List<XmlAttribute> attributes = new ArrayList<>(); private final List<XmlAttribute> attributes = new ArrayList<>();
XmlStartElementChunk(ByteBuffer buffer, @Nullable Chunk parent) { protected XmlStartElementChunk(ByteBuffer buffer, @Nullable Chunk parent) {
super(buffer, parent); super(buffer, parent);
namespace = buffer.getInt(); namespace = buffer.getInt();
name = buffer.getInt(); name = buffer.getInt();
@@ -25,7 +25,7 @@ public class AudioGetLyrics extends ApiRequest<AudioGetLyrics.a> {
public a a(@NonNull JSONObject jSONObject) { public a a(@NonNull JSONObject jSONObject) {
var aVar = new a(); var aVar = new a();
if (Preferences.getBoolValue("useGenius", false) && !Preferences.serverFeaturesDisable()) { if (Preferences.getBoolValue("useGenius", false)) {
aVar.a = Genius.getTextMusic(musicTrack); aVar.a = Genius.getTextMusic(musicTrack);
return aVar; return aVar;
} }
@@ -7,6 +7,16 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
public class GiftGetByStickerId extends ApiRequest<GiftGetByStickerId.a> { public class GiftGetByStickerId extends ApiRequest<GiftGetByStickerId.a> {
public static class a {
public final int a;
public final CatalogedGift b;
public a(int i, CatalogedGift catalogedGift) {
this.a = i;
this.b = catalogedGift;
}
}
public GiftGetByStickerId(Context context, int i) { public GiftGetByStickerId(Context context, int i) {
super("execute.getGiftByStickerId"); super("execute.getGiftByStickerId");
b("sticker_id", i); b("sticker_id", i);
@@ -20,14 +30,4 @@ public class GiftGetByStickerId extends ApiRequest<GiftGetByStickerId.a> {
return new a(jSONObject2.optInt("balance"), return new a(jSONObject2.optInt("balance"),
new CatalogedGift(jSONObject2.getJSONObject("gift"))); new CatalogedGift(jSONObject2.getJSONObject("gift")));
} }
public static class a {
public final int a;
public final CatalogedGift b;
public a(int i, CatalogedGift catalogedGift) {
this.a = i;
this.b = catalogedGift;
}
}
} }
@@ -1,200 +0,0 @@
package com.vk.contacts;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.core.util.ContextExtKt;
import com.vk.navigation.NavigatorKeys;
import com.vk.permission.PermissionHelper;
import com.vtosters.lite.R;
import com.vtosters.lite.VKActivity;
import com.vtosters.lite.activities.LogoutReceiver;
import java.util.List;
import kotlin.Unit;
import kotlin.jvm.b.Functions;
import kotlin.jvm.b.Functions2;
public class ContactsSyncAcitvity extends VKActivity implements View.OnClickListener {
private boolean I;
private View J;
private RadioButton K;
private RadioButton L;
private RadioButton M;
@Nullable
private String G = null;
private int H = 2;
private LogoutReceiver N = null;
public static void a(Context context) {
b(context, ContactsSyncUtils.b());
}
public static void b(Context context, int i) {
a(context, i, null);
}
private void f(int i) {
this.H = i;
this.K.setChecked(i == 0);
this.L.setChecked(i == 1);
this.M.setChecked(i == 2);
CheckBox checkBox = this.J.findViewById(R.id.sync_big_pictures);
checkBox.setEnabled(i != 2);
if (i == 2) {
checkBox.setChecked(false);
}
}
private void onDismiss() {
ContactsSyncReporter.a.a(ContactsSyncUtils.b(), this.G);
finish();
}
private void x1() {
this.H = getIntent().getIntExtra("force_select_sync_contacts", ContactsSyncUtils.b());
this.I = ContactsSyncUtils.d();
this.K = this.J.findViewById(R.id.welcome_sync_opt1);
this.L = this.J.findViewById(R.id.welcome_sync_opt2);
this.M = this.J.findViewById(R.id.welcome_sync_opt3);
this.K.setChecked(this.H == 0);
this.L.setChecked(this.H == 1);
this.M.setChecked(this.H == 2);
this.J.findViewById(R.id.welcome_sync1).setOnClickListener(this);
this.J.findViewById(R.id.welcome_sync2).setOnClickListener(this);
this.J.findViewById(R.id.welcome_sync3).setOnClickListener(this);
CheckBox checkBox = this.J.findViewById(R.id.sync_big_pictures);
checkBox.setChecked(this.I);
checkBox.setEnabled(this.H != 2);
checkBox.setOnCheckedChangeListener(ContactsSyncAcitvity.this::a);
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(this);
builder.setTitle(R.string.sett_sync);
builder.setView(this.J);
builder.setCancelable(false);
builder.setPositiveButton(R.string.save, ContactsSyncAcitvity.this::a);
builder.setNegativeButton(R.string.cancel, ContactsSyncAcitvity.this::b);
builder.show();
}
public Unit c(List list) {
ContactsSyncReporter.a.a(this.G);
finish();
return Unit.a;
}
@SuppressLint("NonConstantResourceId")
@Override // android.view.View.OnClickListener
public void onClick(View view) {
switch (view.getId()) {
case R.id.welcome_sync1 /* 2131365835 */:
f(0);
return;
case R.id.welcome_sync2 /* 2131365836 */:
f(1);
return;
case R.id.welcome_sync3 /* 2131365837 */:
f(2);
return;
default:
}
}
@Override // com.vtosters.lite.VKActivity, com.vk.core.ui.themes.ThemableActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
public void onCreate(Bundle bundle) {
setTheme(VKThemeHelper.n());
super.onCreate(bundle);
this.G = getIntent().getStringExtra(NavigatorKeys.l0);
this.N = LogoutReceiver.a(this);
overridePendingTransition(0, 0);
getWindow().setBackgroundDrawableResource(R.drawable.transparent);
setContentView(new View(this));
this.J = View.inflate(new ContextThemeWrapper(this, VKThemeHelper.n()), R.layout.welcome, null);
VKThemeHelper.d(this);
PermissionHelper permissionHelper = PermissionHelper.r;
permissionHelper.a(this, permissionHelper.e(), R.string.permissions_contacts_sync, R.string.permissions_contacts_sync_settings, new Functions() { // from class: com.vk.contacts.c
@Override // kotlin.jvm.b.Functions
public Object invoke() {
return ContactsSyncAcitvity.this.w1();
}
}, new Functions2() { // from class: com.vk.contacts.a
@Override // kotlin.jvm.b.Functions2
public Object invoke(Object obj) {
return ContactsSyncAcitvity.this.c((List) obj);
}
});
}
@Override // com.vtosters.lite.VKActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
public void onDestroy() {
this.N.a();
super.onDestroy();
}
@Override // android.app.Activity
protected void onRestoreInstanceState(Bundle bundle) {
super.onRestoreInstanceState(bundle);
this.H = bundle.getInt("state_option", 2);
this.I = bundle.getBoolean("state_sync_hq_photo", false);
f(this.H);
}
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
public void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putInt("state_option", this.H);
bundle.putBoolean("state_sync_hq_photo", this.I);
}
public Unit w1() {
x1();
return Unit.a;
}
public static void a(Context context, int i, @Nullable String str) {
Intent intent = new Intent(context, ContactsSyncAcitvity.class);
intent.setAction("syncsettings");
intent.putExtra("force_select_sync_contacts", i);
intent.putExtra(NavigatorKeys.l0, str);
if (ContextExtKt.e(context) == null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(intent);
}
public void b(DialogInterface dialogInterface, int i) {
onDismiss();
}
public void a(CompoundButton compoundButton, boolean z) {
this.I = z;
}
public void a(DialogInterface dialogInterface, int i) {
ContactsSyncUtils.b(this.H);
ContactsSyncUtils.a(this.I);
Intent intent = new Intent();
intent.putExtra("option", this.H);
setResult(-1, intent);
onDismiss();
}
public void a(DialogInterface dialogInterface) {
onDismiss();
}
}
@@ -1,45 +0,0 @@
package com.vk.contacts;
import com.vk.metrics.eventtracking.Event;
import com.vk.metrics.eventtracking.VkTracker;
import com.vk.navigation.NavigatorKeys;
public final class ContactsSyncReporter {
public static final ContactsSyncReporter a = new ContactsSyncReporter();
private static final String EVENT_NAME = "LoggingTracker";
private static final String ENABLE_CONTACTS_SYNC = "enable_contacts_sync";
private static final String HAS_CONTACTS_PERMISSION = "has_contacts_permission";
private static final String SELECTED_SYNC_OPTION = "selected_sync_option";
private static final String NAVIGATOR_KEYS_L0 = NavigatorKeys.l0;
private ContactsSyncReporter() {
}
private static Event createEvent(boolean z, int i, String str) {
Event.a a2 = Event.b.a();
a2.a(EVENT_NAME);
a2.a(ENABLE_CONTACTS_SYNC);
a2.a(HAS_CONTACTS_PERMISSION, z);
a2.a(SELECTED_SYNC_OPTION, i != 0 ? (i != 1 ? "disabled" : "contacts") : "all");
if (str == null) {
str = "";
}
a2.a(NAVIGATOR_KEYS_L0, str);
return a2.a();
}
public void a(String str) {
a(false, 2, str);
}
public void a(int i, String str) {
a(true, i, str);
}
private void a(boolean z, int i, String str) {
VkTracker vkTracker = VkTracker.k;
Event event = createEvent(z, i, str);
vkTracker.a(event);
}
}
@@ -1,112 +0,0 @@
package com.vk.contacts;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.ContentResolver;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import com.vk.auth.VKAuthUtils;
import com.vk.core.concurrent.VkExecutors;
import com.vk.core.preference.Preference;
import com.vk.core.util.AppContextHolder;
import com.vk.metrics.eventtracking.VkTracker;
import com.vtosters.lite.auth.VKAccountManager;
public final class ContactsSyncUtils {
private static final SharedPreferences prefs;
static {
prefs = Preference.b();
}
public static void a(boolean z) { // setSyncHqPhotos
try {
prefs.edit().putBoolean("sync_hq_photos", z).apply();
Log.d("Contacts", "setSyncHqPhotos");
} catch (Exception e) {
VkTracker.k.b(e);
e.fillInStackTrace();
}
}
public static void b(int i) { // setSyncOption
try {
prefs.edit().putInt("key_sync_option", i).apply();
syncAccount(i);
Log.d("Contacts", "setSyncOption");
} catch (Exception e) {
VkTracker.k.b(e);
e.fillInStackTrace();
}
}
public static boolean d() { // getSyncHqPhotos
return prefs.getBoolean("sync_hq_photos", false);
}
public static void e() { // syncAccount
syncAccount(b());
Log.d("Contacts", "syncAccount");
}
public static int b() { // getSyncOption
Account[] accounts;
try {
AccountManager accountManager = AccountManager.get(AppContextHolder.a);
accounts = accountManager.getAccountsByType("com.vkontakte.account");
if (accounts.length == 0) {
Account account = new Account(VKAccountManager.d().Z(), "com.vkontakte.account");
try {
accountManager.addAccountExplicitly(account, null, null);
} catch (Exception e) {
VkTracker.k.a(e);
e.fillInStackTrace();
}
accounts = new Account[]{account};
}
if (ContentResolver.getSyncAutomatically(accounts[0], "com.android.contacts")) {
if (prefs.contains("key_sync_option")) {
return prefs.getInt("key_sync_option", 2);
}
if (prefs.contains("sync_all")) {
return prefs.getBoolean("sync_all", false) ? 0 : 1;
}
return 2;
}
return 2;
} catch (Exception e2) {
VkTracker.k.b(e2);
e2.fillInStackTrace();
return 2;
}
}
private static void syncAccount(int i) {
Log.d("Contacts", String.valueOf(i));
if (!VKAccountManager.d().b1()) {
syncAllAccounts();
Log.d("Contacts", "VKAccountManager.d().b1() is not false");
return;
}
Account account = VKAuthUtils.a.a(VKAccountManager.d().Z());
if (i != 2 && account != null) {
syncSingleAccount(account);
Log.d("Contacts", "sync single account, account is " + account);
} else {
syncAllAccounts();
Log.d("Contacts", "sync all accounts, account is " + account);
}
}
private static void syncSingleAccount(Account account) {
Bundle bundle = new Bundle();
bundle.putBoolean("com.vtosters.lite.EXTRA_FORCE_KEY", true);
ContentResolver.requestSync(account, "com.android.contacts", bundle);
VkExecutors.x.l().submit(() -> ContactsSyncAdapterService.a(AppContextHolder.a, account, new Bundle()));
}
private static void syncAllAccounts() {
VkExecutors.x.l().submit(() -> ContactsSyncAdapterService.a(AppContextHolder.a.getContentResolver()));
}
}
@@ -27,15 +27,6 @@ public class RecoloredDrawable extends Drawable implements Drawable.Callback {
onStateChange(new int[0]); onStateChange(new int[0]);
} }
public RecoloredDrawable(Drawable drawable, int i) {
this(drawable, new ColorStateList(new int[][]{new int[0]}, new int[]{i}));
}
public RecoloredDrawable() {
this.c = 255;
this.d = 255;
}
public void a(int i) { public void a(int i) {
a(new ColorStateList(new int[][]{new int[0]}, new int[]{i})); a(new ColorStateList(new int[][]{new int[0]}, new int[]{i}));
} }
@@ -129,4 +120,13 @@ public class RecoloredDrawable extends Drawable implements Drawable.Callback {
public Drawable a() { public Drawable a() {
return this.drawable; return this.drawable;
} }
public RecoloredDrawable(Drawable drawable, int i) {
this(drawable, new ColorStateList(new int[][]{new int[0]}, new int[]{i}));
}
public RecoloredDrawable() {
this.c = 255;
this.d = 255;
}
} }
@@ -21,13 +21,6 @@ public final class VerifyInfoHelper {
public static final VerifyInfoHelper h; public static final VerifyInfoHelper h;
public static int devIcon = R.drawable.ic_favorite_16; public static int devIcon = R.drawable.ic_favorite_16;
static {
h = new VerifyInfoHelper();
}
private VerifyInfoHelper() {
}
public static Integer enumSwitchMapping(VerifyInfoHelper.ColorTheme color) { public static Integer enumSwitchMapping(VerifyInfoHelper.ColorTheme color) {
return switch (color) { return switch (color) {
case normal -> 1; case normal -> 1;
@@ -37,47 +30,18 @@ public final class VerifyInfoHelper {
}; };
} }
public static Drawable b(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, boolean dev, Context context, ColorTheme colorTheme, int i, Object obj) { public enum ColorTheme {
if ((i & 8) != 0) { white,
colorTheme = ColorTheme.normal; normal,
} light,
return verifyInfoHelper.b(z, z2, dev, context, colorTheme); ultraLight
} }
public static Drawable b(VerifyInfoHelper verifyInfoHelper, VerifyInfo verifyInfo, Context context, ColorTheme colorTheme, int i, Object obj) { static {
return b(verifyInfoHelper, verifyInfo.u1(), verifyInfo.t1(), verifyInfo.dev(), context, colorTheme, i, obj); h = new VerifyInfoHelper();
} }
public static Drawable b(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, Context context, ColorTheme colorTheme, int i, Object obj) { private VerifyInfoHelper() {
return b(verifyInfoHelper, z, z2, false, context, colorTheme, i, obj);
}
public static Drawable a(VerifyInfoHelper verifyInfoHelper, VerifyInfo verifyInfo, Context context, ColorTheme colorTheme, int i, Object obj) {
if ((i & 4) != 0) {
colorTheme = ColorTheme.normal;
}
return verifyInfoHelper.b(verifyInfo, context, colorTheme);
}
public static Drawable a(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, boolean dev, Context context, ColorTheme colorTheme, int i, Object obj) {
if ((i & 8) != 0) {
colorTheme = ColorTheme.normal;
}
return verifyInfoHelper.a(z, z2, dev, context, colorTheme);
}
public static Drawable a(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, Context context, ColorTheme colorTheme, int i, Object obj) {
return a(verifyInfoHelper, z, z2, false, context, colorTheme, i, obj);
}
public static void a(VerifyInfoHelper verifyInfoHelper, TextView textView, VerifyInfo verifyInfo, boolean z, ColorTheme colorTheme, int i, Object obj) {
if ((i & 4) != 0) {
z = false;
}
if ((i & 8) != 0) {
colorTheme = ColorTheme.normal;
}
verifyInfoHelper.a(textView, verifyInfo, z, colorTheme);
} }
private int a() { private int a() {
@@ -125,6 +89,7 @@ public final class VerifyInfoHelper {
return b(this, z, z2, false, context, null, 8, null); return b(this, z, z2, false, context, null, 8, null);
} }
public int b(ColorTheme colorTheme) { public int b(ColorTheme colorTheme) {
return a(colorTheme); return a(colorTheme);
} }
@@ -139,6 +104,7 @@ public final class VerifyInfoHelper {
}; };
} }
public Drawable b(Context context, VerifyInfo verifyInfo) { public Drawable b(Context context, VerifyInfo verifyInfo) {
if (verifyInfo.dev()) { if (verifyInfo.dev()) {
return new RecoloredDrawable(ContextCompat.getDrawable(context, devIcon), c(ColorTheme.normal)); return new RecoloredDrawable(ContextCompat.getDrawable(context, devIcon), c(ColorTheme.normal));
@@ -157,6 +123,21 @@ public final class VerifyInfoHelper {
return b(verifyInfo.u1(), verifyInfo.t1(), verifyInfo.dev(), context, colorTheme); return b(verifyInfo.u1(), verifyInfo.t1(), verifyInfo.dev(), context, colorTheme);
} }
public static Drawable b(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, boolean dev, Context context, ColorTheme colorTheme, int i, Object obj) {
if ((i & 8) != 0) {
colorTheme = ColorTheme.normal;
}
return verifyInfoHelper.b(z, z2, dev, context, colorTheme);
}
public static Drawable b(VerifyInfoHelper verifyInfoHelper, VerifyInfo verifyInfo, Context context, ColorTheme colorTheme, int i, Object obj) {
return b(verifyInfoHelper, verifyInfo.u1(), verifyInfo.t1(), verifyInfo.dev(), context, colorTheme, i, obj);
}
public static Drawable b(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, Context context, ColorTheme colorTheme, int i, Object obj) {
return b(verifyInfoHelper, z, z2, false, context, colorTheme, i, obj);
}
public Drawable a(Context context, VerifyInfo verifyInfo) { public Drawable a(Context context, VerifyInfo verifyInfo) {
if (verifyInfo.dev()) { if (verifyInfo.dev()) {
return new RecoloredDrawable(ContextCompat.getDrawable(context, devIcon), c(ColorTheme.normal)); return new RecoloredDrawable(ContextCompat.getDrawable(context, devIcon), c(ColorTheme.normal));
@@ -200,10 +181,28 @@ public final class VerifyInfoHelper {
return new RecoloredDrawable(ContextCompat.getDrawable(context, i), c2); return new RecoloredDrawable(ContextCompat.getDrawable(context, i), c2);
} }
public static Drawable a(VerifyInfoHelper verifyInfoHelper, VerifyInfo verifyInfo, Context context, ColorTheme colorTheme, int i, Object obj) {
if ((i & 4) != 0) {
colorTheme = ColorTheme.normal;
}
return verifyInfoHelper.b(verifyInfo, context, colorTheme);
}
public Drawable a(VerifyInfo verifyInfo, Context context, ColorTheme colorTheme) { public Drawable a(VerifyInfo verifyInfo, Context context, ColorTheme colorTheme) {
return a(verifyInfo.u1(), verifyInfo.t1(), verifyInfo.dev(), context, colorTheme); return a(verifyInfo.u1(), verifyInfo.t1(), verifyInfo.dev(), context, colorTheme);
} }
public static Drawable a(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, boolean dev, Context context, ColorTheme colorTheme, int i, Object obj) {
if ((i & 8) != 0) {
colorTheme = ColorTheme.normal;
}
return verifyInfoHelper.a(z, z2, dev, context, colorTheme);
}
public static Drawable a(VerifyInfoHelper verifyInfoHelper, boolean z, boolean z2, Context context, ColorTheme colorTheme, int i, Object obj) {
return a(verifyInfoHelper, z, z2, false, context, colorTheme, i, obj);
}
public Drawable a(boolean z, boolean z2, Context context, ColorTheme colorTheme) { public Drawable a(boolean z, boolean z2, Context context, ColorTheme colorTheme) {
return a(z, z2, false, context, colorTheme); return a(z, z2, false, context, colorTheme);
} }
@@ -231,6 +230,16 @@ public final class VerifyInfoHelper {
return new RecoloredDrawable(ContextCompat.getDrawable(context, i), c2); return new RecoloredDrawable(ContextCompat.getDrawable(context, i), c2);
} }
public static void a(VerifyInfoHelper verifyInfoHelper, TextView textView, VerifyInfo verifyInfo, boolean z, ColorTheme colorTheme, int i, Object obj) {
if ((i & 4) != 0) {
z = false;
}
if ((i & 8) != 0) {
colorTheme = ColorTheme.normal;
}
verifyInfoHelper.a(textView, verifyInfo, z, colorTheme);
}
public void a(TextView textView, VerifyInfo verifyInfo, boolean z, ColorTheme colorTheme) { public void a(TextView textView, VerifyInfo verifyInfo, boolean z, ColorTheme colorTheme) {
Drawable drawable; Drawable drawable;
Context context = textView.getContext(); Context context = textView.getContext();
@@ -258,11 +267,4 @@ public final class VerifyInfoHelper {
} }
ViewExtKt.p(imageView); ViewExtKt.p(imageView);
} }
public enum ColorTheme {
white,
normal,
light,
ultraLight
}
} }
@@ -31,6 +31,30 @@ public final class DialogGetMentionSuggestionCmd extends BaseImEngineCmd<Suggest
private final boolean e; private final boolean e;
private final Object f; private final Object f;
public static final class a<T> implements Comparator<Member> {
List a;
a(List list) {
this.a = list;
}
@Override // java.util.Comparator
/* renamed from: a */
public int compare(Member member, Member member2) {
int indexOf = this.a.indexOf(member);
int indexOf2 = this.a.indexOf(member2);
int i = indexOf;
if (indexOf < 0) {
i = Integer.MAX_VALUE;
}
int i2 = indexOf2;
if (indexOf2 < 0) {
i2 = Integer.MAX_VALUE;
}
return Intrinsics.a(i, i2);
}
}
public DialogGetMentionSuggestionCmd(int i, String str, Source source, boolean z, Object obj) { public DialogGetMentionSuggestionCmd(int i, String str, Source source, boolean z, Object obj) {
this.f2365b = i; this.f2365b = i;
this.c = str; this.c = str;
@@ -126,7 +150,7 @@ public final class DialogGetMentionSuggestionCmd extends BaseImEngineCmd<Suggest
Collection<Member> a2; Collection<Member> a2;
Source source; Source source;
if (ImDialogsUtils.d(this.f2365b) != PeerType.CHAT) { if (ImDialogsUtils.d(this.f2365b) != PeerType.CHAT) {
return new Suggestion(null, null); return new Suggestion((EntityValue) null, (ProfilesInfo) null);
} }
Member Z = imEnvironment.Z(); Member Z = imEnvironment.Z();
int d = imEnvironment.a0().n().d(); int d = imEnvironment.a0().n().d();
@@ -211,28 +235,4 @@ public final class DialogGetMentionSuggestionCmd extends BaseImEngineCmd<Suggest
public String toString() { public String toString() {
return "DialogGetMentionSuggestionCmd(dialogId=" + this.f2365b + ", query=" + this.c + ", source=" + this.d + ", isAwaitNetwork=" + this.e + ", changerTag=" + this.f + ")"; return "DialogGetMentionSuggestionCmd(dialogId=" + this.f2365b + ", query=" + this.c + ", source=" + this.d + ", isAwaitNetwork=" + this.e + ", changerTag=" + this.f + ")";
} }
public static final class a<T> implements Comparator<Member> {
List a;
a(List list) {
this.a = list;
}
@Override // java.util.Comparator
/* renamed from: a */
public int compare(Member member, Member member2) {
int indexOf = this.a.indexOf(member);
int indexOf2 = this.a.indexOf(member2);
int i = indexOf;
if (indexOf < 0) {
i = Integer.MAX_VALUE;
}
int i2 = indexOf2;
if (indexOf2 < 0) {
i2 = Integer.MAX_VALUE;
}
return Intrinsics.a(i, i2);
}
}
} }
@@ -19,7 +19,7 @@ import java.util.List;
public final class DialogActionsHelper { public final class DialogActionsHelper {
public static final DialogActionsHelper a = new DialogActionsHelper(); public static final DialogActionsHelper a = new DialogActionsHelper();
public List<DialogAction> a(ImConfig imConfig, Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo) { public final List<DialogAction> a(ImConfig imConfig, Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo) {
if (dialog != null && profilesSimpleInfo != null) { if (dialog != null && profilesSimpleInfo != null) {
long b2 = TimeProvider.f.b(); long b2 = TimeProvider.f.b();
ChatSettings z1 = dialog.z1(); ChatSettings z1 = dialog.z1();
@@ -84,7 +84,7 @@ public final class DialogActionsHelper {
return new ArrayList<>(); return new ArrayList<>();
} }
public List<DialogAction> a(Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo) { public final List<DialogAction> a(Dialog dialog, ProfilesSimpleInfo profilesSimpleInfo) {
long b2 = TimeProvider.f.b(); long b2 = TimeProvider.f.b();
Profile profile = profilesSimpleInfo.get(dialog.getId()); Profile profile = profilesSimpleInfo.get(dialog.getId());
@@ -138,7 +138,7 @@ public final class DialogActionsHelper {
return arrayList; return arrayList;
} }
public boolean a(Dialog dialog) { public final boolean a(Dialog dialog) {
if (dialog.V1() || !dialog.y1()) { if (dialog.V1() || !dialog.y1()) {
return false; return false;
} }
@@ -16,11 +16,11 @@ import java.util.List;
public final class MsgActionHelper { public final class MsgActionHelper {
public static final MsgActionHelper a = new MsgActionHelper(); public static final MsgActionHelper a = new MsgActionHelper();
public List<MsgAction> a(ImEngine imEngine, Dialog dialog, Collection<? extends Msg> collection) { public final List<MsgAction> a(ImEngine imEngine, Dialog dialog, Collection<? extends Msg> collection) {
return a(imEngine != null ? imEngine.g() : null, dialog, collection); return a(imEngine != null ? imEngine.g() : null, dialog, collection);
} }
public List<MsgAction> a(ImConfig imConfig, Dialog dialog, Collection<? extends Msg> collection) { public final List<MsgAction> a(ImConfig imConfig, Dialog dialog, Collection<? extends Msg> collection) {
if (imConfig != null && dialog != null && collection != null) { if (imConfig != null && dialog != null && collection != null) {
MsgPermissionHelper.a aVar = new MsgPermissionHelper.a(imConfig, dialog, collection); MsgPermissionHelper.a aVar = new MsgPermissionHelper.a(imConfig, dialog, collection);
ArrayList<MsgAction> arrayList = new ArrayList<>(); ArrayList<MsgAction> arrayList = new ArrayList<>();
@@ -74,7 +74,11 @@ public class VhBindArgs {
private boolean L() { private boolean L() {
boolean var1; boolean var1;
var1 = this.K() > this.m || TimeProvider.f.c(); if (this.K() <= this.m && !TimeProvider.f.c()) {
var1 = false;
} else {
var1 = true;
}
return var1; return var1;
} }
@@ -105,7 +109,11 @@ public class VhBindArgs {
public boolean B() { public boolean B() {
AdapterEntry var1 = this.a; AdapterEntry var1 = this.a;
boolean var2; boolean var2;
var2 = var1 != null && var1.c(); if (var1 != null && var1.c()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -113,7 +121,11 @@ public class VhBindArgs {
public boolean C() { public boolean C() {
AdapterEntry var1 = this.a; AdapterEntry var1 = this.a;
boolean var2; boolean var2;
var2 = var1 != null && var1.c() && this.a.c.getLocalId() == this.b.c.getLocalId(); if (var1 != null && var1.c() && this.a.c.getLocalId() == this.b.c.getLocalId()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -121,7 +133,11 @@ public class VhBindArgs {
public boolean D() { public boolean D() {
AdapterEntry var1 = this.a; AdapterEntry var1 = this.a;
boolean var2; boolean var2;
var2 = var1 != null && var1.a == 83; if (var1 != null && var1.a == 83) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -129,7 +145,11 @@ public class VhBindArgs {
public boolean E() { public boolean E() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 instanceof MsgFromUser && ((MsgFromUser) var1).i2(); if (var1 instanceof MsgFromUser && ((MsgFromUser) var1).i2()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -137,7 +157,11 @@ public class VhBindArgs {
public boolean F() { public boolean F() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 instanceof MsgFromUser && ((MsgFromUser) var1).F0(); if (var1 instanceof MsgFromUser && ((MsgFromUser) var1).F0()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -145,7 +169,11 @@ public class VhBindArgs {
public boolean G() { public boolean G() {
AdapterEntry var1 = this.b; AdapterEntry var1 = this.b;
boolean var2; boolean var2;
var2 = var1 != null && var1.a == 51; if (var1 != null && var1.a == 51) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -158,7 +186,11 @@ public class VhBindArgs {
long var1 = this.K(); long var1 = this.K();
long var3 = this.m; long var3 = this.m;
boolean var5; boolean var5;
var5 = var1 > var3 && var1 < var3 * 2L; if (var1 > var3 && var1 < var3 * 2L) {
var5 = true;
} else {
var5 = false;
}
return var5; return var5;
} }
@@ -174,10 +206,18 @@ public class VhBindArgs {
MsgFromUser var7 = (MsgFromUser) var1; MsgFromUser var7 = (MsgFromUser) var1;
Msg var3 = this.a.c; Msg var3 = this.a.c;
boolean var4; boolean var4;
var4 = var3 != null && var3.d() == MsgSyncState.DONE; if (var3 != null && var3.d() == MsgSyncState.DONE) {
var4 = true;
} else {
var4 = false;
}
boolean var5; boolean var5;
var5 = this.o == ImBgSyncState.CONNECTED; if (this.o == ImBgSyncState.CONNECTED) {
var5 = true;
} else {
var5 = false;
}
boolean var6 = var2; boolean var6 = var2;
if (!var7.H0()) { if (!var7.H0()) {
@@ -202,7 +242,7 @@ public class VhBindArgs {
byte var2 = 0; byte var2 = 0;
int var3 = var2; int var3 = var2;
if (var1) { if (var1) {
AttachAudioMsg var4 = ((MsgFromUser) this.b.c).c(AttachAudioMsg.class, false); AttachAudioMsg var4 = (AttachAudioMsg) ((MsgFromUser) this.b.c).c(AttachAudioMsg.class, false);
var3 = var2; var3 = var2;
if (var4 != null) { if (var4 != null) {
var3 = var4.f(); var3 = var4.f();
@@ -227,7 +267,11 @@ public class VhBindArgs {
public boolean c() { public boolean c() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 instanceof MsgFromUser && ((MsgFromUser) var1).I0(); if (var1 instanceof MsgFromUser && ((MsgFromUser) var1).I0()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -235,14 +279,22 @@ public class VhBindArgs {
public boolean d() { public boolean d() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 instanceof WithUserContent && ((WithUserContent) var1).D0() != null; if (var1 instanceof WithUserContent && ((WithUserContent) var1).D0() != null) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
public boolean e() { public boolean e() {
boolean var1; boolean var1;
var1 = this.b.i > 0; if (this.b.i > 0) {
var1 = true;
} else {
var1 = false;
}
return var1; return var1;
} }
@@ -265,7 +317,11 @@ public class VhBindArgs {
public boolean g() { public boolean g() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 instanceof MsgFromUser && ((MsgFromUser) var1).G0(); if (var1 instanceof MsgFromUser && ((MsgFromUser) var1).G0()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -273,21 +329,33 @@ public class VhBindArgs {
public boolean h() { public boolean h() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 instanceof MsgFromUser && ((MsgFromUser) var1).Z1(); if (var1 instanceof MsgFromUser && ((MsgFromUser) var1).Z1()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
public boolean i() { public boolean i() {
boolean var1; boolean var1;
var1 = this.j && !this.u() && !this.l(); if (this.j && !this.u() && !this.l()) {
var1 = true;
} else {
var1 = false;
}
return var1; return var1;
} }
public boolean j() { public boolean j() {
boolean var1; boolean var1;
var1 = this.j && !this.u() && (!this.B() || !this.A() || this.a.c.H1()); if (!this.j || this.u() || this.B() && this.A() && !this.a.c.H1()) {
var1 = false;
} else {
var1 = true;
}
return var1; return var1;
} }
@@ -295,7 +363,11 @@ public class VhBindArgs {
public boolean k() { public boolean k() {
Dialog var1 = this.e; Dialog var1 = this.e;
boolean var2; boolean var2;
var2 = var1 != null && var1.U1(); if (var1 != null && var1.U1()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -303,7 +375,11 @@ public class VhBindArgs {
public boolean l() { public boolean l() {
Dialog var1 = this.e; Dialog var1 = this.e;
boolean var2; boolean var2;
var2 = var1 != null && var1.V1(); if (var1 != null && var1.V1()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -311,7 +387,11 @@ public class VhBindArgs {
public boolean m() { public boolean m() {
Dialog var1 = this.e; Dialog var1 = this.e;
boolean var2; boolean var2;
var2 = var1 != null && var1.W1(); if (var1 != null && var1.W1()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -324,7 +404,11 @@ public class VhBindArgs {
public boolean o() { public boolean o() {
AdapterEntry var1 = this.b; AdapterEntry var1 = this.b;
boolean var2; boolean var2;
var2 = var1 != null && var1.a == 101; if (var1 != null && var1.a == 101) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -332,7 +416,11 @@ public class VhBindArgs {
public boolean p() { public boolean p() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 != null && var1.G1(); if (var1 != null && var1.G1()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -355,7 +443,11 @@ public class VhBindArgs {
public boolean r() { public boolean r() {
Msg var1 = this.b.c; Msg var1 = this.b.c;
boolean var2; boolean var2;
var2 = var1 instanceof MsgFromUser && ((MsgFromUser) var1).e2(); if (var1 instanceof MsgFromUser && ((MsgFromUser) var1).e2()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -396,19 +488,27 @@ public class VhBindArgs {
public boolean v() { public boolean v() {
IntSet var1 = this.r; IntSet var1 = this.r;
boolean var2; boolean var2;
var2 = var1 != null && var1.a(this.b.c.getLocalId()); if (var1 != null && var1.a(this.b.c.getLocalId())) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
public boolean w() { public boolean w() {
return !this.z(); return this.z() ^ true;
} }
public boolean x() { public boolean x() {
AdapterEntry var1 = this.c; AdapterEntry var1 = this.c;
boolean var2; boolean var2;
var2 = var1 != null && var1.a == 100; if (var1 != null && var1.a == 100) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -416,7 +516,11 @@ public class VhBindArgs {
public boolean y() { public boolean y() {
AdapterEntry var1 = this.c; AdapterEntry var1 = this.c;
boolean var2; boolean var2;
var2 = var1 != null && var1.a == 96; if (var1 != null && var1.a == 96) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -424,7 +528,11 @@ public class VhBindArgs {
public boolean z() { public boolean z() {
AdapterEntry var1 = this.c; AdapterEntry var1 = this.c;
boolean var2; boolean var2;
var2 = var1 != null && var1.c() && this.c.c.getLocalId() == this.b.c.getLocalId(); if (var1 != null && var1.c() && this.c.c.getLocalId() == this.b.c.getLocalId()) {
var2 = true;
} else {
var2 = false;
}
return var2; return var2;
} }
@@ -46,7 +46,7 @@ public final class MsgPartCallHolder extends MsgPartHolderBase<AttachCall> {
this.G = new StringBuilder(); this.G = new StringBuilder();
} }
private void a(Msg var1) { private final void a(Msg var1) {
this.G.setLength(0); this.G.setLength(0);
MsgTimeFormatter var2 = this.F; MsgTimeFormatter var2 = this.F;
Context var3 = this.C; Context var3 = this.C;
@@ -55,7 +55,7 @@ public final class MsgPartCallHolder extends MsgPartHolderBase<AttachCall> {
this.H.setTimeText(this.G); this.H.setTimeText(this.G);
} }
private void a(boolean var1) { private final void a(boolean var1) {
MsgPartIconTwoRowView var2 = this.H; MsgPartIconTwoRowView var2 = this.H;
int var3; int var3;
if (var1) { if (var1) {
@@ -67,7 +67,7 @@ public final class MsgPartCallHolder extends MsgPartHolderBase<AttachCall> {
var2.setIcon(var3); var2.setIcon(var3);
} }
private void a(boolean var1, AttachCall var2) { private final void a(boolean var1, AttachCall var2) {
boolean var3 = !var1; boolean var3 = !var1;
if (var2.h() == CallState.ERROR) { if (var2.h() == CallState.ERROR) {
this.H.setSubtitleText(m.vkim_msg_list_call_error); this.H.setSubtitleText(m.vkim_msg_list_call_error);
@@ -49,7 +49,6 @@ import com.vk.im.ui.views.msg.bubble.MsgBubbleView;
import com.vk.im.ui.views.sticker.StickerAnimationState; import com.vk.im.ui.views.sticker.StickerAnimationState;
import kotlin.Unit; import kotlin.Unit;
import kotlin.jvm.b.Functions; import kotlin.jvm.b.Functions;
import ru.vtosters.lite.themes.ThemesHacks;
public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b { public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
public static final int h0 = Screen.a(124); public static final int h0 = Screen.a(124);
@@ -57,6 +56,46 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
private static final int[][] j0; private static final int[][] j0;
private static final int[][] k0; private static final int[][] k0;
private static final int[][] l0; private static final int[][] l0;
private final MsgPartHolderBase B;
private final MsgPartHolderBindArgs C = new MsgPartHolderBindArgs();
private final Rect D = new Rect();
private final Rect E = new Rect();
private final Rect F = new Rect();
private final Rect G = new Rect();
private ColorDrawable H;
private final int I;
private final int J;
private final int K;
private final int L;
private final int M;
private Drawable N;
private Drawable O;
private BombView P;
private BombView.d Q;
private int R;
private int S;
private final DisplayNameFormatter T = new DisplayNameFormatter();
private final StringBuilder U = new StringBuilder();
private final StringBuilder V = new StringBuilder();
private final String W;
private final String X;
private final String Y;
private boolean Z;
private BubbleColors a0;
private final FluidHorizontalLayout b;
@ColorInt
private int b0;
private final AvatarView c;
private MsgListAdapterCallback c0;
private final Space d;
private Msg d0;
private final MsgBubbleView e;
private Dialog e0;
private final MsgStatusView f;
private int f0;
private final ImageView g;
private h g0 = new h();
private final Space h;
static { static {
int[] var0 = new int[]{0, 0, 0, 0}; int[] var0 = new int[]{0, 0, 0, 0};
@@ -80,61 +119,20 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
l0 = new int[][]{var0, {4, 4, 0, 0, 0, 2, 8, 0}, var1, var2, {4, 0, 0, 0, 0, 2, 8, 0}, {0, 0, 0, 0, 0, 2, 8, 0}, {4, 4, 0, 0, 0, 2, 8, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; l0 = new int[][]{var0, {4, 4, 0, 0, 0, 2, 8, 0}, var1, var2, {4, 0, 0, 0, 0, 2, 8, 0}, {0, 0, 0, 0, 0, 2, 8, 0}, {4, 4, 0, 0, 0, 2, 8, 0}, {0, 0, 0, 0, 0, 0, 0, 0}};
} }
private final MsgPartHolderBase B;
private final MsgPartHolderBindArgs C = new MsgPartHolderBindArgs();
private final Rect D = new Rect();
private final Rect E = new Rect();
private final Rect F = new Rect();
private final Rect G = new Rect();
private final int I;
private final int J;
private final int K;
private final int L;
private final int M;
private final DisplayNameFormatter T = new DisplayNameFormatter();
private final StringBuilder U = new StringBuilder();
private final StringBuilder V = new StringBuilder();
private final String W;
private final String X;
private final String Y;
private final FluidHorizontalLayout b;
private final AvatarView c;
private final Space d;
private final MsgBubbleView e;
private final MsgStatusView f;
private final ImageView g;
private final Space h;
private final ColorDrawable H;
private Drawable N;
private Drawable O;
private final BombView P;
private final BombView.d Q;
private final int R;
private final int S;
private boolean Z;
private BubbleColors a0;
@ColorInt
private int b0;
private MsgListAdapterCallback c0;
private Msg d0;
private Dialog e0;
private int f0;
private final h g0 = new h();
public VhMsg(View itemView, MsgPartHolderBase vhBase) { public VhMsg(View itemView, MsgPartHolderBase vhBase) {
super(itemView); super(itemView);
Context context = itemView.getContext(); Context context = itemView.getContext();
LayoutInflater var4 = LayoutInflater.from(context); LayoutInflater var4 = LayoutInflater.from(context);
this.b = (FluidHorizontalLayout) itemView; this.b = (FluidHorizontalLayout) itemView;
this.c = itemView.findViewById(com.vk.im.ui.h.avatar); this.c = (AvatarView) itemView.findViewById(com.vk.im.ui.h.avatar);
this.d = itemView.findViewById(com.vk.im.ui.h.avatar_space); this.d = (Space) itemView.findViewById(com.vk.im.ui.h.avatar_space);
this.e = itemView.findViewById(com.vk.im.ui.h.bubble); this.e = (MsgBubbleView) itemView.findViewById(com.vk.im.ui.h.bubble);
this.f = itemView.findViewById(com.vk.im.ui.h.status); this.f = (MsgStatusView) itemView.findViewById(com.vk.im.ui.h.status);
this.g = itemView.findViewById(com.vk.im.ui.h.vkim_channel_share); this.g = (ImageView) itemView.findViewById(com.vk.im.ui.h.vkim_channel_share);
this.h = itemView.findViewById(com.vk.im.ui.h.status_space); this.h = (Space) itemView.findViewById(com.vk.im.ui.h.status_space);
this.P = itemView.findViewById(com.vk.im.ui.h.bomb); this.P = (BombView) itemView.findViewById(com.vk.im.ui.h.bomb);
this.B = vhBase; this.B = vhBase;
this.H = new ColorDrawable(ThemesHacks.getColors(context, com.vk.im.ui.d.msg_search_selection)); this.H = new ColorDrawable(context.getResources().getColor(com.vk.im.ui.d.msg_search_selection));
this.I = ContextExtKt.b(context, com.vk.im.ui.e.msg_bubble_max_width); this.I = ContextExtKt.b(context, com.vk.im.ui.e.msg_bubble_max_width);
this.J = ContextExtKt.b(context, com.vk.im.ui.e.msg_reply_max_width); this.J = ContextExtKt.b(context, com.vk.im.ui.e.msg_reply_max_width);
this.K = ContextExtKt.b(context, com.vk.im.ui.e.msg_sticker_max_width); this.K = ContextExtKt.b(context, com.vk.im.ui.e.msg_sticker_max_width);
@@ -151,39 +149,49 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
var6.right = var7.rightMargin; var6.right = var7.rightMargin;
var6.top = var7.topMargin; var6.top = var7.topMargin;
var6.bottom = var7.bottomMargin; var6.bottom = var7.bottomMargin;
ViewExtKt.b(this.c, var1 -> { ViewExtKt.b(this.c, new View.OnClickListener() {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) { public void onClick(View var1) {
VhMsg.this.c0.a(VhMsg.this.d0.getFrom()); if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
} VhMsg.this.c0.a(VhMsg.this.d0.getFrom());
}
}
}); });
this.c.setOnLongClickListener(var1 -> { this.c.setOnLongClickListener(new View.OnLongClickListener() {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) { public boolean onLongClick(View var1) {
VhMsg.this.c0.a(VhMsg.this.d0.getFrom()); if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
VhMsg.this.c0.a(VhMsg.this.d0.getFrom());
return true;
} else {
return false;
}
}
});
ViewExtKt.b(this.g, new View.OnClickListener() {
public void onClick(View var1) {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
VhMsg.this.c0.a(VhMsg.this.d0);
}
}
});
ViewExtKt.b(this.itemView, new View.OnClickListener() {
public void onClick(View var1) {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
VhMsg.this.c0.a(VhMsg.this.d0.getLocalId());
}
}
});
this.itemView.setOnLongClickListener(new View.OnLongClickListener() {
public boolean onLongClick(View var1) {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
VhMsg.this.c0.b(VhMsg.this.d0.getLocalId());
}
return true; return true;
} else {
return false;
} }
}); });
ViewExtKt.b(this.g, var1 -> {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
VhMsg.this.c0.a(VhMsg.this.d0);
}
});
ViewExtKt.b(this.itemView, (View.OnClickListener) var1 -> {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
VhMsg.this.c0.a(VhMsg.this.d0.getLocalId());
}
});
this.itemView.setOnLongClickListener((View.OnLongClickListener) var1 -> {
if (VhMsg.this.c0 != null && VhMsg.this.d0 != null) {
VhMsg.this.c0.b(VhMsg.this.d0.getLocalId());
}
return true;
});
this.R = ContextExtKt.i(context, com.vk.im.ui.c.im_msg_part_corner_radius_small); this.R = ContextExtKt.i(context, com.vk.im.ui.c.im_msg_part_corner_radius_small);
this.S = ContextExtKt.i(context, com.vk.im.ui.c.im_msg_part_corner_radius_big); this.S = ContextExtKt.i(context, com.vk.im.ui.c.im_msg_part_corner_radius_big);
this.c0 = null; this.c0 = null;
@@ -195,10 +203,6 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
}; };
} }
public static VhMsg a(LayoutInflater var0, ViewGroup var1, MsgPartHolderBase var2) {
return new VhMsg(var0.inflate(j.vkim_msg_list_item_msg_from_user, var1, false), var2);
}
private int a(Style var1, Style var2, boolean var3) { private int a(Style var1, Style var2, boolean var3) {
int var4; int var4;
if (var3) { if (var3) {
@@ -279,15 +283,20 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
case 103: case 103:
return VhMsg.Style.EMPTY; return VhMsg.Style.EMPTY;
default: default:
String var3 = "Unknown viewType: " + StringBuilder var3 = new StringBuilder();
var1; var3.append("Unknown viewType: ");
throw new IllegalArgumentException(var3); var3.append(var1);
throw new IllegalArgumentException(var3.toString());
} }
} }
return VhMsg.Style.TWO_LINE; return VhMsg.Style.TWO_LINE;
} }
public static VhMsg a(LayoutInflater var0, ViewGroup var1, MsgPartHolderBase var2) {
return new VhMsg(var0.inflate(j.vkim_msg_list_item_msg_from_user, var1, false), var2);
}
private void a(VhBindArgs args, Rect rect) { private void a(VhBindArgs args, Rect rect) {
Style var3 = this.a(args.b); Style var3 = this.a(args.b);
boolean var4 = args.b.f(); boolean var4 = args.b.f();
@@ -402,7 +411,11 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
Msg var10 = var5.c; Msg var10 = var5.c;
var9 = var6; var9 = var6;
if (var10 != null) { if (var10 != null) {
var9 = var10.v1() == args.g.t1(); if (var10.v1() == args.g.t1()) {
var9 = true;
} else {
var9 = false;
}
if (var10.O1()) { if (var10.O1()) {
int var12 = var10.d().ordinal(); int var12 = var10.d().ordinal();
@@ -420,7 +433,11 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
b = args.I(); b = args.I();
} }
} else { } else {
var6 = var10.C1() <= args.i; if (var10.C1() <= args.i) {
var6 = true;
} else {
var6 = false;
}
if (!var6 && !var9) { if (!var6 && !var9) {
var11 = MsgStatus.UNREAD; var11 = MsgStatus.UNREAD;
@@ -558,14 +575,18 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
partArgs.o = args.n; partArgs.o = args.n;
partArgs.s = args.v(); partArgs.s = args.v();
partArgs.t = args.q; partArgs.t = args.q;
partArgs.u = !var4.b(); partArgs.u = var4.b() ^ true;
boolean var5; boolean var5;
var5 = var3.i > 0; if (var3.i > 0) {
var5 = true;
} else {
var5 = false;
}
partArgs.v = var5; partArgs.v = var5;
partArgs.w = args.k; partArgs.w = args.k;
partArgs.x = args.l; partArgs.x = args.l;
partArgs.y = !this.Z; partArgs.y = this.Z ^ true;
partArgs.z = args.s; partArgs.z = args.s;
partArgs.A = args.t; partArgs.A = args.t;
partArgs.l = this.b0; partArgs.l = this.b0;
@@ -650,7 +671,7 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
private void f(VhBindArgs args) { private void f(VhBindArgs args) {
Msg var2 = args.b.c; Msg var2 = args.b.c;
if (var2 != null) { if (var2 != null) {
this.P.setStateListener(null); this.P.setStateListener((BombView.d) null);
if (var2.M1() && !var2.E1()) { if (var2.M1() && !var2.E1()) {
this.P.setVisibility(View.GONE); this.P.setVisibility(View.GONE);
} else { } else {
@@ -789,12 +810,24 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
this.e.setFwdPadding(this.D); this.e.setFwdPadding(this.D);
this.e.setContentPadding(this.E); this.e.setContentPadding(this.E);
boolean var7; boolean var7;
var7 = args.b.a == 83; if (args.b.a == 83) {
var7 = true;
} else {
var7 = false;
}
boolean var5; boolean var5;
var5 = args.a.a == 83; if (args.a.a == 83) {
var5 = true;
} else {
var5 = false;
}
var5 = !args.F() || !var7 && !var5; if (!args.F() || !var7 && !var5) {
var5 = true;
} else {
var5 = false;
}
MsgBubbleView var8 = this.e; MsgBubbleView var8 = this.e;
boolean var6 = var4; boolean var6 = var4;
@@ -871,10 +904,18 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
return false; return false;
} else { } else {
boolean var5; boolean var5;
var5 = var2.a == 50; if (var2.a == 50) {
var5 = true;
} else {
var5 = false;
}
boolean var6; boolean var6;
var6 = !args.z() && var2.i == 0; if (!args.z() && var2.i == 0) {
var6 = true;
} else {
var6 = false;
}
if (var5 || var6 || args.y() || args.x()) { if (var5 || var6 || args.y() || args.x()) {
var4 = true; var4 = true;
@@ -893,7 +934,11 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
private boolean u(int var1) { private boolean u(int var1) {
boolean var2; boolean var2;
var2 = var1 == 2 || var1 == 3; if (var1 != 2 && var1 != 3) {
var2 = false;
} else {
var2 = true;
}
return var2; return var2;
} }
@@ -915,7 +960,9 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
Msg var1 = this.d0; Msg var1 = this.d0;
if (var1 != null) { if (var1 != null) {
Dialog var2 = this.e0; Dialog var2 = this.e0;
return var2 != null && MsgPermissionHelper.b.a(var2, var1); if (var2 != null && MsgPermissionHelper.b.a(var2, var1)) {
return true;
}
} }
} }
return false; return false;
@@ -950,7 +997,11 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
public void a(VhBindArgs args) { public void a(VhBindArgs args) {
boolean var2; boolean var2;
var2 = VKThemeHelper.l() == VKTheme.VKAPP_LIGHT; if (VKThemeHelper.l() == VKTheme.VKAPP_LIGHT) {
var2 = true;
} else {
var2 = false;
}
this.Z = var2; this.Z = var2;
AdapterEntry var3 = args.b; AdapterEntry var3 = args.b;
@@ -1011,7 +1062,11 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
public boolean f0() { public boolean f0() {
boolean var1; boolean var1;
var1 = this.f0 == 100; if (this.f0 == 100) {
var1 = true;
} else {
var1 = false;
}
return var1; return var1;
} }
@@ -1028,7 +1083,7 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
this.B.c(var1); this.B.c(var1);
} }
private enum Style { private static enum Style {
BUTTON(6), BUTTON(6),
EMPTY(7), EMPTY(7),
FWD_SENDER(4), FWD_SENDER(4),
@@ -1040,14 +1095,14 @@ public class VhMsg extends VhBase implements SwipeToReplyItemTouchCallback.b {
public final int index; public final int index;
Style(int var3) { private Style(int var3) {
this.index = var3; this.index = var3;
} }
} }
private class h implements Functions<Unit> { private class h implements Functions<Unit> {
private final int a; private int a;
private final Runnable b; private Runnable b;
private h() { private h() {
this.a = Screen.a(12); this.a = Screen.a(12);
@@ -26,23 +26,30 @@ import com.vtosters.lite.R;
public final class MentionsController { public final class MentionsController {
private final RichEditText a; private final RichEditText a;
private final ImEngine mImEngine;
private final View j;
private final b k;
private boolean state; private boolean state;
private CoordinatorLayout mCoordinatorLayout; private CoordinatorLayout mCoordinatorLayout;
private VkBottomSheetBehavior<RecyclerView> mBottomSheetBehavior; private VkBottomSheetBehavior<RecyclerView> mBottomSheetBehavior;
private boolean e; private boolean e;
private final DialogMentionComponent mDialogMentionComponent; private DialogMentionComponent mDialogMentionComponent;
private final MentionsManager mMentionsManager; private MentionsManager mMentionsManager;
private final int i; private final ImEngine mImEngine;
private int i;
private final View j;
private final b k;
public interface b {
boolean c();
boolean d();
}
public MentionsController(ImEngine imEngine, int i, View view, b bVar) { public MentionsController(ImEngine imEngine, int i, View view, b bVar) {
this.mImEngine = imEngine; this.mImEngine = imEngine;
this.i = i; this.i = i;
this.j = view; this.j = view;
this.k = bVar; this.k = bVar;
this.a = this.j.findViewById(R.id.writebar_edit); this.a = (RichEditText) this.j.findViewById(R.id.writebar_edit);
this.mMentionsManager = new MentionsManager(this.a, new MentionSuggestionsSupplier() { this.mMentionsManager = new MentionsManager(this.a, new MentionSuggestionsSupplier() {
@Override @Override
@@ -64,7 +71,7 @@ public final class MentionsController {
@Override @Override
public void b() { public void b() {
MentionsController.this.mDialogMentionComponent.a(0, null); MentionsController.this.mDialogMentionComponent.a(0, (String) null);
MentionsController.this.g(); MentionsController.this.g();
} }
}); });
@@ -85,18 +92,18 @@ public final class MentionsController {
}); });
} }
public void g() { public final void g() {
this.e = false; this.e = false;
j(); j();
} }
private void h() { private final void h() {
if (this.state) { if (this.state) {
return; return;
} }
View inflate = ((ViewStub) this.j.findViewById(R.id.mentions_container_stub)).inflate(); View inflate = ((ViewStub) this.j.findViewById(R.id.mentions_container_stub)).inflate();
ViewGroup viewGroup = inflate.findViewById(R.id.mentions_container); ViewGroup viewGroup = (ViewGroup) inflate.findViewById(R.id.mentions_container);
viewGroup.addView(this.mDialogMentionComponent.a(viewGroup, null)); viewGroup.addView(this.mDialogMentionComponent.a(viewGroup, (Bundle) null));
this.mCoordinatorLayout = inflate.findViewById(R.id.mentions_cl); this.mCoordinatorLayout = inflate.findViewById(R.id.mentions_cl);
this.mBottomSheetBehavior = (VkBottomSheetBehavior<RecyclerView>) ((CoordinatorLayout.LayoutParams) viewGroup.getLayoutParams()).getBehavior(); this.mBottomSheetBehavior = (VkBottomSheetBehavior<RecyclerView>) ((CoordinatorLayout.LayoutParams) viewGroup.getLayoutParams()).getBehavior();
this.mBottomSheetBehavior.a(new VkBottomSheetBehavior.b() { this.mBottomSheetBehavior.a(new VkBottomSheetBehavior.b() {
@@ -113,12 +120,12 @@ public final class MentionsController {
this.state = true; this.state = true;
} }
public void i() { public final void i() {
this.e = true; this.e = true;
j(); j();
} }
public void j() { public final void j() {
if (this.k.d()) { if (this.k.d()) {
Context context = this.j.getContext(); Context context = this.j.getContext();
Activity f = ContextExtKt.f(context); Activity f = ContextExtKt.f(context);
@@ -132,33 +139,27 @@ public final class MentionsController {
} }
} }
public void a() { public final void a() {
this.mDialogMentionComponent.g(); this.mDialogMentionComponent.g();
} }
public void b() { public final void b() {
this.mDialogMentionComponent.h(); this.mDialogMentionComponent.h();
} }
public b c() { public final b c() {
return this.k; return this.k;
} }
public int d() { public final int d() {
return this.i; return this.i;
} }
public void e() { public final void e() {
this.mDialogMentionComponent.q(); this.mDialogMentionComponent.q();
} }
public void f() { public final void f() {
this.mDialogMentionComponent.r(); this.mDialogMentionComponent.r();
} }
public interface b {
boolean c();
boolean d();
}
} }
@@ -12,15 +12,15 @@ import android.view.ViewGroup;
import com.vk.im.ui.o; import com.vk.im.ui.o;
public class StoryBorderView extends View { public class StoryBorderView extends View {
private final Paint a;
private final int g;
private final int h;
private boolean B; private boolean B;
private final Paint a;
private LinearGradient f15747b; private LinearGradient f15747b;
private int f15748c; private int f15748c;
private int f15749d; private int f15749d;
private int f15750e; private int f15750e;
private int f15751f; private int f15751f;
private final int g;
private final int h;
public StoryBorderView(Context context) { public StoryBorderView(Context context) {
this(context, null, 0, 6); this(context, null, 0, 6);
@@ -34,32 +34,10 @@ public class StoryBorderView extends View {
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i); this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
} }
public StoryBorderView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.STROKE);
this.a = paint;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, o.StoryBorderView);
setBorderColor(obtainStyledAttributes.getInt(o.StoryBorderView_vkim_borderColor, 0));
this.g = obtainStyledAttributes.getInt(o.StoryBorderView_vkim_borderGradientStartColor, 0);
this.h = obtainStyledAttributes.getInt(o.StoryBorderView_vkim_borderGradientEndColor, 0);
setBorderWidth(obtainStyledAttributes.getDimensionPixelSize(o.StoryBorderView_vkim_borderWidth, 0));
obtainStyledAttributes.recycle();
}
public int getBorderColor() { public int getBorderColor() {
return this.f15749d; return this.f15749d;
} }
public void setBorderColor(int i) {
if (this.f15749d != i) {
this.f15749d = i;
this.a.setColor(i);
invalidate();
}
}
public int getBorderGradientEndColor() { public int getBorderGradientEndColor() {
return this.h; return this.h;
} }
@@ -72,33 +50,14 @@ public class StoryBorderView extends View {
return this.f15750e; return this.f15750e;
} }
public void setBorderWidth(int i) {
if (this.f15750e != i) {
this.f15750e = i;
this.a.setStrokeWidth(i);
invalidate();
}
}
public int getPadding() { public int getPadding() {
return this.f15751f; return this.f15751f;
} }
public void setPadding(int i) {
if (this.f15751f != i) {
this.f15751f = i;
setPadding(i, i, i, i);
}
}
public int getViewSize() { public int getViewSize() {
return this.f15748c; return this.f15748c;
} }
public void setViewSize(int i) {
this.f15748c = i;
}
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
canvas.drawOval(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom(), this.a); canvas.drawOval(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom(), this.a);
@@ -110,6 +69,22 @@ public class StoryBorderView extends View {
setMeasuredDimension(i3, i3); setMeasuredDimension(i3, i3);
} }
public void setBorderColor(int i) {
if (this.f15749d != i) {
this.f15749d = i;
this.a.setColor(i);
invalidate();
}
}
public void setBorderWidth(int i) {
if (this.f15750e != i) {
this.f15750e = i;
this.a.setStrokeWidth(i);
invalidate();
}
}
@Override @Override
public void setLayoutParams(ViewGroup.LayoutParams layoutParams) { public void setLayoutParams(ViewGroup.LayoutParams layoutParams) {
super.setLayoutParams(layoutParams); super.setLayoutParams(layoutParams);
@@ -133,4 +108,29 @@ public class StoryBorderView extends View {
invalidate(); invalidate();
} }
} }
public void setPadding(int i) {
if (this.f15751f != i) {
this.f15751f = i;
setPadding(i, i, i, i);
}
}
public void setViewSize(int i) {
this.f15748c = i;
}
public StoryBorderView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.STROKE);
this.a = paint;
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, o.StoryBorderView);
setBorderColor(obtainStyledAttributes.getInt(o.StoryBorderView_vkim_borderColor, 0));
this.g = obtainStyledAttributes.getInt(o.StoryBorderView_vkim_borderGradientStartColor, 0);
this.h = obtainStyledAttributes.getInt(o.StoryBorderView_vkim_borderGradientEndColor, 0);
setBorderWidth(obtainStyledAttributes.getDimensionPixelSize(o.StoryBorderView_vkim_borderWidth, 0));
obtainStyledAttributes.recycle();
}
} }
@@ -10,7 +10,6 @@ import android.util.Log;
import androidx.annotation.Keep; import androidx.annotation.Keep;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.facebook.soloader.SoLoader; import com.facebook.soloader.SoLoader;
import ru.vtosters.sponsorpost.internal.Native;
import java.io.InputStream; import java.io.InputStream;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@@ -275,7 +274,6 @@ public final class MediaNative {
SoLoader.init(context2, false); SoLoader.init(context2, false);
NativeLibLoader.loadLibrary("gnustl_shared"); NativeLibLoader.loadLibrary("gnustl_shared");
NativeLibLoader.loadLibrary("vkchronicle"); NativeLibLoader.loadLibrary("vkchronicle");
Native.canVote = NativeLibLoader.loadLibrary("sponsorpost");
loadVKMediaLibs(); loadVKMediaLibs();
f17443d.notifyAll(); f17443d.notifyAll();
} }
@@ -156,7 +156,7 @@ public class LyricsHolder extends RecyclerHolder<PlayerInfo> implements View.OnC
@Override // com.vk.api.base.ApiCallback @Override // com.vk.api.base.ApiCallback
public void a(VKApiExecutionException vKApiExecutionException) { public void a(VKApiExecutionException vKApiExecutionException) {
if (Preferences.getBoolValue("useGenius", false) && !Preferences.serverFeaturesDisable()) { if (Preferences.getBoolValue("useGenius", false)) {
var text = Genius.getTextMusic(a); var text = Genius.getTextMusic(a);
var lyrics = new AudioGetLyrics.a(); var lyrics = new AudioGetLyrics.a();
lyrics.a = text; lyrics.a = text;
@@ -1,106 +0,0 @@
package com.vk.newsfeed.holders;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.ui.themes.VKThemeHelper;
import com.vk.dto.newsfeed.entries.NewsEntry;
import com.vk.dto.newsfeed.entries.Post;
import com.vk.dto.newsfeed.entries.PromoPost;
import com.vk.extensions.ViewExtKt;
import com.vtosters.lite.R;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.newsfeed.NewsFeedFiltersUtils;
import ru.vtosters.sponsorpost.internal.Native;
import ru.vtosters.sponsorpost.internal.VotesPreferences;
import ru.vtosters.sponsorpost.internal.VotesService;
import ru.vtosters.sponsorpost.utils.PostsPreferences;
public final class AdMarkHolder extends BaseNewsEntryHolder<NewsEntry> {
private final TextView F;
@SuppressLint("ResourceType")
public AdMarkHolder(ViewGroup viewGroup) {
super(R.layout.marked_as_ads, viewGroup);
View view = ((RecyclerView.ViewHolder) this).itemView;
this.F = ViewExtKt.a(view, R.id.text, (View.OnClickListener) null);
}
@SuppressLint("ResourceType")
public void b(NewsEntry newsEntry) { // onBind
String disclamer = null;
Drawable drawable = null;
int height = 0;
if (newsEntry instanceof Post) {
Post post = ((Post) newsEntry);
if (post.L1()) {
drawable = VKThemeHelper.a(R.drawable.marked_as_ads, R.attr.icon_tertiary);
int ownerId = post.b();
int postId = post.P1();
int date = post.K();
String text = post.getText();
if (PostsPreferences.isPostAd(ownerId, postId)) {
disclamer = "SponsorPost: Реклама";
if (Preferences.isValidSignature() && Native.canVote()) {
this.F.setOnClickListener(listener -> voteDialog(ownerId, postId, date, this.F.getContext()));
}
} else if (VotesPreferences.isPostAd(ownerId, postId)) {
disclamer = "SponsorPost: Возможно реклама";
if (Preferences.isValidSignature() && Native.canVote()) {
this.F.setOnClickListener(listener -> voteDialog(ownerId, postId, date, this.F.getContext()));
}
} else if (NewsFeedFiltersUtils.sponsorFilters(text)) {
disclamer = "SponsorPost: Заблокировано фильтрами";
this.F.setOnClickListener(listener -> AndroidUtils.sendToast("Заблокировано по выражению: " + NewsFeedFiltersUtils.sponsorFiltersBanWord(text)));
} else {
disclamer = m(R.string.sponsored_post_in_group);
}
height = e0().getDimensionPixelSize(R.dimen.newsfeed_ad_mark_post_height);
}
} else if (newsEntry instanceof PromoPost) {
PromoPost promoPost = (PromoPost) newsEntry;
if (!promoPost.E1().isEmpty()) {
height = e0().getDimensionPixelSize(R.dimen.newsfeed_ad_mark_promo_post_height);
disclamer = promoPost.E1();
}
}
this.F.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, null, null, null);
this.F.setMinHeight(height);
this.F.setText(disclamer);
}
public static void voteDialog(int ownerId, int postId, int date, Context ctx) {
new VkAlertDialog.Builder(ctx)
.setTitle("SponsorPost")
.setMessage("Этот пост является рекламным?")
.setPositiveButton("Да", ((dialog, which) -> {
int resp = VotesService.ratePost(ownerId, postId, date, true).optInt("code");
if (resp == 201 || resp == 100) {
AndroidUtils.sendToast("Спасибо за голос!");
} else {
AndroidUtils.sendToast("Ваш голос уже учтен");
}
}))
.setNeutralButton("Нет", ((dialog, which) -> {
int resp = VotesService.ratePost(ownerId, postId, date, false).optInt("code");
if (resp == 201 || resp == 100) {
AndroidUtils.sendToast("Спасибо за голос!");
} else {
AndroidUtils.sendToast("Ваш голос уже учтен");
}
}))
.show();
}
}
@@ -36,37 +36,37 @@ public final class CommunityBorderedImageView extends BorderedCircleImageView im
public CommunityBorderedImageView(Context context, AttributeSet attributeSet, int i) { public CommunityBorderedImageView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i); super(context, attributeSet, i);
this.g0 = VKThemeHelper.d(R.attr.accent); this.g0 = VKThemeHelper.d((int) R.attr.accent);
this.h0 = ContextExtKt.a(context, R.color.gray_200); this.h0 = ContextExtKt.a(context, (int) R.color.gray_200);
this.i0 = new PorterDuffColorFilter(this.g0, PorterDuff.Mode.SRC_IN); this.i0 = new PorterDuffColorFilter(this.g0, PorterDuff.Mode.SRC_IN);
this.j0 = new PorterDuffColorFilter(this.h0, PorterDuff.Mode.SRC_IN); this.j0 = new PorterDuffColorFilter(this.h0, PorterDuff.Mode.SRC_IN);
} }
public void c(int unread, int read) { // get unread and read resid public final void c(int unread, int read) { // get unread and read resid
this.unread = unread; this.unread = unread;
this.read = read; this.read = read;
this.T = BitmapFactory.decodeResource(getResources(), this.unread); this.T = BitmapFactory.decodeResource(getResources(), this.unread);
} }
public int getPrimaryColor() { public final int getPrimaryColor() {
return this.g0; return this.g0;
} }
public void setPrimaryColor(int i) { public final void setPrimaryColor(int i) {
this.g0 = i; this.g0 = i;
this.i0 = new PorterDuffColorFilter(i, PorterDuff.Mode.SRC_IN); this.i0 = new PorterDuffColorFilter(i, PorterDuff.Mode.SRC_IN);
} }
public int getWasViewedColor() { public final int getWasViewedColor() {
return this.h0; return this.h0;
} }
public void setWasViewedColor(int i) { public final void setWasViewedColor(int i) {
this.h0 = i; this.h0 = i;
this.j0 = new PorterDuffColorFilter(i, PorterDuff.Mode.SRC_IN); this.j0 = new PorterDuffColorFilter(i, PorterDuff.Mode.SRC_IN);
} }
public void o() { public final void o() {
this.f0 = false; this.f0 = false;
l(); l();
} }
@@ -79,7 +79,7 @@ public final class CommunityBorderedImageView extends BorderedCircleImageView im
} }
} }
public void setStoryContainer(StoriesContainer storiesContainer) { public final void setStoryContainer(StoriesContainer storiesContainer) {
if (storiesContainer.L1()) { if (storiesContainer.L1()) {
this.f0 = true; this.f0 = true;
m(); m();
@@ -30,14 +30,14 @@ public class TargetImageView extends VKMultiImageView {
private static final int I = Screen.a(2); private static final int I = Screen.a(2);
private final int B; private final int B;
private final int C; private final int C;
private final RectF f21629d;
private final Paint f21630e;
private final RectF g;
private final Paint h;
private Drawable D; private Drawable D;
private String[] F; private String[] F;
private int G; private int G;
private final RectF f21629d;
private final Paint f21630e;
private Canvas f21631f; private Canvas f21631f;
private final RectF g;
private final Paint h;
public TargetImageView(Context context, Drawable d) { public TargetImageView(Context context, Drawable d) {
this(context, null, 0, 6); this(context, null, 0, 6);
@@ -51,43 +51,6 @@ public class TargetImageView extends VKMultiImageView {
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i); this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
} }
public TargetImageView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.f21629d = new RectF();
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setFilterBitmap(true);
this.f21630e = paint;
this.g = new RectF();
Paint paint2 = new Paint();
paint2.setAntiAlias(true);
paint2.setStrokeWidth(I);
paint2.setStyle(Paint.Style.STROKE);
this.h = paint2;
this.B = getAccentColor();
this.C = this.B;
Drawable c2 = ContextExtKt.c(context, R.drawable.ic_check_circle_composite_24_full);
if (c2 != null) {
this.D = c2;
this.F = new String[4];
int i2 = I * 2;
setPadding(i2, i2, i2, i2);
if (attributeSet != null) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, a0.TargetImageView);
setSelected(obtainStyledAttributes.getBoolean(0, false));
obtainStyledAttributes.recycle();
}
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.user_placeholder);
for (int i3 = 0; i3 <= 3; i3++) {
a();
DraweeHolder<GenericDraweeHierarchy> a3 = this.a.a(i3);
a3.b().e(drawable);
}
setScaleType(ScalingUtils.b.o);
}
}
private void e() { private void e() {
int i = this.G; int i = this.G;
for (int i2 = 0; i2 < i; i2++) { for (int i2 = 0; i2 < i; i2++) {
@@ -288,4 +251,41 @@ public class TargetImageView extends VKMultiImageView {
drawable.setBounds(i - drawable.getIntrinsicWidth(), i2 - this.D.getIntrinsicHeight(), i, i2); drawable.setBounds(i - drawable.getIntrinsicWidth(), i2 - this.D.getIntrinsicHeight(), i, i2);
f(); f();
} }
public TargetImageView(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.f21629d = new RectF();
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setDither(true);
paint.setFilterBitmap(true);
this.f21630e = paint;
this.g = new RectF();
Paint paint2 = new Paint();
paint2.setAntiAlias(true);
paint2.setStrokeWidth(I);
paint2.setStyle(Paint.Style.STROKE);
this.h = paint2;
this.B = getAccentColor();
this.C = this.B;
Drawable c2 = ContextExtKt.c(context, R.drawable.ic_check_circle_composite_24_full);
if (c2 != null) {
this.D = c2;
this.F = new String[4];
int i2 = I * 2;
setPadding(i2, i2, i2, i2);
if (attributeSet != null) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, a0.TargetImageView);
setSelected(obtainStyledAttributes.getBoolean(0, false));
obtainStyledAttributes.recycle();
}
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.user_placeholder);
for (int i3 = 0; i3 <= 3; i3++) {
a();
DraweeHolder<GenericDraweeHierarchy> a3 = this.a.a(i3);
a3.b().e(drawable);
}
setScaleType(ScalingUtils.b.o);
}
}
} }
@@ -104,25 +104,6 @@ public final class StickerDetailsAdapter extends RecyclerView.Adapter<RecyclerVi
} }
} }
private static final class d extends RecyclerView.ViewHolder {
private final VKStickerImageView mImage;
public d(ViewGroup viewGroup) {
super(new VKStickerImageView(viewGroup.getContext()));
this.mImage = (VKStickerImageView) itemView;
this.mImage.setAspectRatio(1.0f);
this.mImage.setClickable(true);
this.mImage.getHierarchy().a().setVisible(true, true);
this.mImage.getHierarchy().a(0);
this.mImage.setContentDescription(this.mImage.getContext().getString(R.string.stickers_accessibility_sticker));
}
public void a(StickerItem stickerItem) {
this.mImage.a(stickerItem.h(Screen.a(80)));
this.mImage.setTag(R.id.id, stickerItem.getId());
}
}
private final class c extends RecyclerView.ViewHolder { private final class c extends RecyclerView.ViewHolder {
private final VKImageView mImageBg; private final VKImageView mImageBg;
private final VKImageView mPackImage; private final VKImageView mPackImage;
@@ -168,4 +149,23 @@ public final class StickerDetailsAdapter extends RecyclerView.Adapter<RecyclerVi
this.mDescription.setText(stickerStockItem.C1()); this.mDescription.setText(stickerStockItem.C1());
} }
} }
private static final class d extends RecyclerView.ViewHolder {
private final VKStickerImageView mImage;
public d(ViewGroup viewGroup) {
super(new VKStickerImageView(viewGroup.getContext()));
this.mImage = (VKStickerImageView) itemView;
this.mImage.setAspectRatio(1.0f);
this.mImage.setClickable(true);
this.mImage.getHierarchy().a().setVisible(true, true);
this.mImage.getHierarchy().a(0);
this.mImage.setContentDescription(this.mImage.getContext().getString(R.string.stickers_accessibility_sticker));
}
public void a(StickerItem stickerItem) {
this.mImage.a(stickerItem.h(Screen.a(80)));
this.mImage.setTag(R.id.id, stickerItem.getId());
}
}
} }
@@ -382,7 +382,7 @@ public class StoryCircleImageView extends BorderedCircleImageView implements The
return; return;
} }
pipelineDraweeControllerBuilder.a(() -> StoryCircleImageView.this.a(list)); pipelineDraweeControllerBuilder.a((Supplier<DataSource<CloseableReference<CloseableImage>>>) () -> StoryCircleImageView.this.a(list));
return; return;
} }
pipelineDraweeControllerBuilder.b(null); pipelineDraweeControllerBuilder.b(null);
+4 -34
View File
@@ -13025,7 +13025,7 @@ public final class R {
public static final int ic_launcher_shine = 0x7f0f005d; // 2131689565 public static final int ic_launcher_shine = 0x7f0f005d; // 2131689565
public static final int ic_launcher_shine_background = 0x7f0f005e; // 2131689566 public static final int ic_launcher_shine_background = 0x7f0f005e; // 2131689566
public static final int ic_launcher_shine_foreground = 0x7f0f005f; // 2131689567 public static final int ic_launcher_shine_foreground = 0x7f0f005f; // 2131689567
public static final int vt_adaptive_launcher_foreground = 0x7f0f0043; // 2131689539 public static final int vt_adaptive_launcher_foneground = 0x7f0f0043; // 2131689539
public static final int vt_launcher_round = 0x7f0f0046; // 2131689542 public static final int vt_launcher_round = 0x7f0f0046; // 2131689542
public static final int ic_logo_facebook_28 = 0x7f0f0003; // 2131689475 public static final int ic_logo_facebook_28 = 0x7f0f0003; // 2131689475
public static final int ic_logo_google_28 = 0x7f0f0004; // 2131689476 public static final int ic_logo_google_28 = 0x7f0f0004; // 2131689476
@@ -19661,39 +19661,9 @@ public final class R {
public static final int cache_size = 0x7f12188d; // 2131892365 public static final int cache_size = 0x7f12188d; // 2131892365
public static final int cache_size_summ = 0x7f12188e; // 2131892366 public static final int cache_size_summ = 0x7f12188e; // 2131892366
public static final int clear_all_cache = 0x7f12188f; // 2131892367 public static final int clear_all_cache = 0x7f12188f; // 2131892367
public static final int disable_roaming_state = 0x7f121890; // 2131892368 public static final int invalidate_theme_cache_each_update_title = 0x7f121890; // 2131892368
public static final int disable_roaming_state_submit = 0x7f121891; // 2131892369 public static final int invertFilters = 0x7f121891; // 2131892369
public static final int invalidate_theme_cache_each_update_title = 0x7f121892; // 2131892370 public static final int invertFilters_summ = 0x7f121892; // 2131892370
public static final int invertFilters = 0x7f121893; // 2131892371
public static final int invertFilters_summ = 0x7f121894; // 2131892372
public static final int invertcached_summ = 0x7f121895; // 2131892373
public static final int invertcached_title = 0x7f121896; // 2131892374
public static final int microg_dialog1 = 0x7f121897; // 2131892375
public static final int microg_dialog2 = 0x7f121898; // 2131892376
public static final int microg_dialog3 = 0x7f121899; // 2131892377
public static final int serverFeaturesDisable = 0x7f12189a; // 2131892378
public static final int serverFeaturesDisable_summ = 0x7f12189b; // 2131892379
public static final int sett_autoupdates = 0x7f12189c; // 2131892380
public static final int sett_autoupdates_summ = 0x7f12189d; // 2131892381
public static final int sett_battery = 0x7f12189e; // 2131892382
public static final int sett_battery_summ1 = 0x7f12189f; // 2131892383
public static final int sett_battery_summ2 = 0x7f1218a0; // 2131892384
public static final int sett_chats = 0x7f1218a1; // 2131892385
public static final int sett_chats_summ = 0x7f1218a2; // 2131892386
public static final int sett_community = 0x7f1218a3; // 2131892387
public static final int sett_community_summ = 0x7f1218a4; // 2131892388
public static final int sett_missing_links = 0x7f1218a5; // 2131892389
public static final int sett_missing_links_summ = 0x7f1218a6; // 2131892390
public static final int sett_nogms_summ = 0x7f1218a7; // 2131892391
public static final int sett_notifs = 0x7f1218a8; // 2131892392
public static final int sett_notifs_summ = 0x7f1218a9; // 2131892393
public static final int sett_recommendations = 0x7f1218aa; // 2131892394
public static final int tgs_token_missing = 0x7f1218ab; // 2131892395
public static final int tgs_token_reset = 0x7f1218ac; // 2131892396
public static final int tgs_token_reset_dialog = 0x7f1218ad; // 2131892397
public static final int tgs_token_reset_menu = 0x7f1218ae; // 2131892398
public static final int update_err = 0x7f1218af; // 2131892399
public static final int update_latest = 0x7f1218b0; // 2131892400
} }
public static final class style { 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);
}
}
@@ -35,16 +35,16 @@ public class BottomNavigationItemView extends FrameLayout implements MenuView.It
private final View mCounterContainer; private final View mCounterContainer;
private final TextView mCounter; private final TextView mCounter;
private final View mDot; private final View mDot;
private final int mMargin;
private final float mSmallScale;
private final ImageView mIcon;
private final ImageView mActionIcon;
private int mItemPos; private int mItemPos;
private MenuItemImpl mItemData; private MenuItemImpl mItemData;
private ColorStateList mColorStateList; private ColorStateList mColorStateList;
private final int mMargin;
private final float mSmallScale;
private boolean mShiftingModeEnabled; private boolean mShiftingModeEnabled;
private boolean mIconsModeEnabled; private boolean mIconsModeEnabled;
private boolean mStaticModeEnabled; private boolean mStaticModeEnabled;
private final ImageView mIcon;
private final ImageView mActionIcon;
public BottomNavigationItemView(@NonNull Context context) { public BottomNavigationItemView(@NonNull Context context) {
this(context, null); this(context, null);
@@ -69,10 +69,10 @@ public class BottomNavigationItemView extends FrameLayout implements MenuView.It
this.mIcon.getLayoutParams().height = V.a(28.0F); this.mIcon.getLayoutParams().height = V.a(28.0F);
this.mSmallLabel = this.findViewById(R.id.smallLabel); this.mSmallLabel = this.findViewById(R.id.smallLabel);
mSmallLabel.setTextColor(getCSTDock(this.getContext())); mSmallLabel.setTextColor(getCSTDock());
this.mLargeLabel = this.findViewById(R.id.largeLabel); this.mLargeLabel = this.findViewById(R.id.largeLabel);
mLargeLabel.setTextColor(getCSTDock(this.getContext())); mLargeLabel.setTextColor(getCSTDock());
LayoutInflater.from(this.getContext()).inflate(R.layout.navigation_bottom_counter, this, true); LayoutInflater.from(this.getContext()).inflate(R.layout.navigation_bottom_counter, this, true);
this.mCounterContainer = this.findViewById(R.id.counter_container); this.mCounterContainer = this.findViewById(R.id.counter_container);
@@ -101,10 +101,6 @@ public class BottomNavigationItemView extends FrameLayout implements MenuView.It
return this.mItemPos; return this.mItemPos;
} }
public void setItemPosition(int pos) {
this.mItemPos = pos;
}
@SuppressLint("RestrictedApi") @SuppressLint("RestrictedApi")
public void initialize(MenuItemImpl impl, int i) { public void initialize(MenuItemImpl impl, int i) {
this.mItemData = impl; this.mItemData = impl;
@@ -314,6 +310,10 @@ public class BottomNavigationItemView extends FrameLayout implements MenuView.It
ViewCompat.setBackground(this, resId != 0 ? ContextCompat.getDrawable(this.getContext(), resId) : null); ViewCompat.setBackground(this, resId != 0 ? ContextCompat.getDrawable(this.getContext(), resId) : null);
} }
public void setItemPosition(int pos) {
this.mItemPos = pos;
}
public void setShiftingMode(boolean var1) { public void setShiftingMode(boolean var1) {
this.mShiftingModeEnabled = var1; this.mShiftingModeEnabled = var1;
} }
@@ -3,7 +3,7 @@ package ru.vtosters.hooks;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.utils.newsfeed.NewsFeedFiltersUtils; import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
public class AdBlockHook { public class AdBlockHook {
public static JSONObject discoverInject(JSONObject json) throws JSONException { public static JSONObject discoverInject(JSONObject json) throws JSONException {
@@ -11,15 +11,11 @@ public class AdBlockHook {
} }
public static JSONArray feedInject(JSONArray items) { public static JSONArray feedInject(JSONArray items) {
return NewsFeedFiltersUtils.feedInject(items, false); return NewsFeedFiltersUtils.feedInject(items);
} }
public static JSONArray wallGetById(JSONArray items) { public static JSONObject storiesads(JSONObject json, boolean isDeleteFix) throws JSONException {
return NewsFeedFiltersUtils.feedInject(items, true); return NewsFeedFiltersUtils.storiesads(json, isDeleteFix);
}
public static JSONObject storiesads(JSONObject json, boolean isDeleteFix) {
return NewsFeedFiltersUtils.storiesAds(json, isDeleteFix);
} }
} }
@@ -65,7 +65,7 @@ public class DockBarInjector {
for (DockBarTab tab : sManager.getSelectedTabs()) { for (DockBarTab tab : sManager.getSelectedTabs()) {
MenuItem add = menu.add(0, tab.id, 0, tab.titleID); MenuItem add = menu.add(0, tab.id, 0, tab.titleID);
add.setIcon(new RecoloredDrawable(getResources().getDrawable(tab.iconID), getCSTDock(navigationView.getContext()))); add.setIcon(new RecoloredDrawable(getResources().getDrawable(tab.iconID), getCSTDock()));
add.setTitle(getGlobalContext().getString(tab.titleID)); add.setTitle(getGlobalContext().getString(tab.titleID));
add.setCheckable(true); add.setCheckable(true);
} }
@@ -76,7 +76,7 @@ public class DockBarInjector {
item.setStaticMode(true); item.setStaticMode(true);
item.setIconsMode(false); item.setIconsMode(false);
item.setShiftingMode(false); item.setShiftingMode(false);
item.setTextColor(getCSTDock(item.getContext())); item.setTextColor(getCSTDock());
} }
} }
} }
@@ -1,38 +0,0 @@
package ru.vtosters.hooks;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;
public class FirebaseGzipSupport {
public static JSONObject getJsonObjectFromConnection(URLConnection connection) throws IOException, JSONException {
InputStream inputStream = getDecompressedInputStream(connection);
String jsonString = readInputStream(inputStream);
return new JSONObject(jsonString);
}
private static InputStream getDecompressedInputStream(URLConnection connection) throws IOException {
String contentEncoding = connection.getHeaderField("Content-Encoding");
if (contentEncoding != null && contentEncoding.equalsIgnoreCase("gzip")) {
return new GZIPInputStream(connection.getInputStream());
}
return connection.getInputStream();
}
private static String readInputStream(InputStream inputStream) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
int read;
while ((read = bufferedReader.read()) != -1) {
sb.append((char) read);
}
return sb.toString();
}
}
@@ -1,9 +0,0 @@
package ru.vtosters.hooks;
import ru.vtosters.hooks.other.Preferences;
public class GroupCoverHook {
public static boolean needToDisableCovers() {
return Preferences.getBoolValue("disablevideoscovers", false);
}
}
@@ -3,11 +3,10 @@ package ru.vtosters.hooks;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.utils.FriendsCatalogUtils; import ru.vtosters.lite.utils.FriendsCatalogUtils;
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
import ru.vtosters.lite.utils.OnlineBypass; import ru.vtosters.lite.utils.OnlineBypass;
import ru.vtosters.lite.utils.SuperAppUtils; import ru.vtosters.lite.utils.SuperAppUtils;
import ru.vtosters.lite.utils.newsfeed.NewsFeedFiltersUtils;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
@@ -31,10 +30,10 @@ public class JsonInjectors {
} }
public static JSONArray newsfeedlist(JSONArray items) throws JSONException { public static JSONArray newsfeedlist(JSONArray items) throws JSONException {
return Preferences.getBoolValue("unlockCustomLists", false) ? NewsFeedFiltersUtils.setNewsfeedLists(items) : items; return NewsFeedFiltersUtils.newsfeedlist(items);
} }
public static JSONObject friends(JSONObject json) throws JSONException, ParseException, IOException { public static JSONObject friends(JSONObject json) throws JSONException, ParseException, IOException {
return FriendsCatalogUtils.inject(json); return FriendsCatalogUtils.inject(json);
} }
} }
@@ -21,15 +21,14 @@ import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils; import ru.vtosters.lite.utils.LifecycleUtils;
import ru.vtosters.lite.utils.NavigatorUtils; import ru.vtosters.lite.utils.NavigatorUtils;
import ru.vtosters.lite.utils.VTVerifications; import ru.vtosters.lite.utils.VTVerifications;
import ru.vtosters.sponsorpost.utils.Updates;
import static ru.vtosters.hooks.other.Preferences.checkupdates; import static ru.vtosters.hooks.other.Preferences.checkupdates;
import static ru.vtosters.lite.utils.CacheUtils.getInstance; import static ru.vtosters.lite.utils.CacheUtils.getInstance;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
public class MainActivityInjector { public class MainActivityInjector {
public static void inject(Activity activity) { public static void inject(Activity activity) {
SystemThemeChangerHook.themeOnStart(activity); SystemThemeChangerHook.themeOnStart(activity);
UsersList.getUsersList(); UsersList.getUsersList();
VTVerifications.load(activity); VTVerifications.load(activity);
@@ -37,13 +36,10 @@ public class MainActivityInjector {
VTExecutors.getSlowTasksScheduler().a(() -> { VTExecutors.getSlowTasksScheduler().a(() -> {
getInstance().autoCleaningCache(); getInstance().autoCleaningCache();
if (!Preferences.serverFeaturesDisable()) {
Updates.updateFilters();
Updates.updatePosts();
}
}); // slowTasksScheduler }); // slowTasksScheduler
setupFilters();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannels.createChannels(); NotificationChannels.createChannels();
} }
@@ -7,7 +7,6 @@ import com.vk.api.internal.MethodCall;
import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider; import com.vk.im.ui.providers.audiomsg.ImAudioMsgPlayerProvider;
import com.vk.im.ui.providers.audiomsg.PlayerActionSources; import com.vk.im.ui.providers.audiomsg.PlayerActionSources;
import com.vtosters.lite.im.ImEngineProvider; import com.vtosters.lite.im.ImEngineProvider;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.translators.BaseTranslator; import ru.vtosters.lite.translators.BaseTranslator;
import ru.vtosters.lite.ui.dialogs.MessageSettings; import ru.vtosters.lite.ui.dialogs.MessageSettings;
import ru.vtosters.lite.utils.LifecycleUtils; import ru.vtosters.lite.utils.LifecycleUtils;
@@ -21,7 +20,7 @@ import static ru.vtosters.lite.ui.dialogs.MessageSettings.isSilentEnabled;
public class MessagesHook { public class MessagesHook {
public static String injectOwnText(String oldText) { public static String injectOwnText(String oldText) {
if (!autotranslate() || Preferences.serverFeaturesDisable() || TextUtils.isEmpty(oldText)) if (!autotranslate() || TextUtils.isEmpty(oldText))
return oldText; return oldText;
var instance = BaseTranslator.getInstance(); var instance = BaseTranslator.getInstance();
@@ -29,7 +28,7 @@ public class MessagesHook {
} }
public static String injectOwnTextAll(String oldText) { public static String injectOwnTextAll(String oldText) {
if (!autoalltranslate() || Preferences.serverFeaturesDisable() || TextUtils.isEmpty(oldText)) { if (!autoalltranslate() || TextUtils.isEmpty(oldText)) {
return oldText; return oldText;
} }
var instance = BaseTranslator.getInstance(); var instance = BaseTranslator.getInstance();
@@ -1,27 +1,18 @@
package ru.vtosters.hooks; package ru.vtosters.hooks;
import android.content.Context; import android.content.Context;
import android.net.NetworkInfo;
import android.os.PowerManager; import android.os.PowerManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.vk.core.preference.Preference; import com.vk.core.preference.Preference;
import com.vk.discover.DiscoverItemDecorator; import com.vk.discover.DiscoverItemDecorator;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.concurrent.VTExecutors;
import ru.vtosters.lite.utils.NetworkUtils;
import ru.vtosters.sponsorpost.internal.VotesPreferences;
import ru.vtosters.sponsorpost.internal.VotesService;
import ru.vtosters.sponsorpost.services.PostService;
import ru.vtosters.sponsorpost.utils.PostsPreferences;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import static java.lang.Long.MAX_VALUE; import static java.lang.Long.MAX_VALUE;
import static ru.vtosters.hooks.other.Preferences.*; import static ru.vtosters.hooks.other.Preferences.*;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext; import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
public class NewsfeedHook { public class NewsfeedHook {
public static long getUpdateNewsfeed(boolean refresh_timeout) { public static long getUpdateNewsfeed(boolean refresh_timeout) {
@@ -31,7 +22,8 @@ public class NewsfeedHook {
return switch (getString("newsupdate")) { return switch (getString("newsupdate")) {
case "no_update" -> MAX_VALUE; case "no_update" -> MAX_VALUE;
case "imd_update" -> 10000L; case "imd_update" -> 10000L;
default -> Preference.b().getLong(refresh_timeout ? "refresh_timeout_top" : "refresh_timeout_recent", 600000L); default ->
Preference.b().getLong(refresh_timeout ? "refresh_timeout_top" : "refresh_timeout_recent", 600000L);
}; };
} }
@@ -61,89 +53,41 @@ public class NewsfeedHook {
} }
public static String[] feedParams() { public static String[] feedParams() {
List<String> params = List.of("post", "photo", "photo_tag", "friends_recomm", "app_widget", "promo_button", "authors_rec"); HashSet<String> params = new HashSet<>();
params.add("post");
params.add("photo");
params.add("photo_tag");
HashSet<String> filteredParams = new HashSet<>(); if (!friendsrecomm()) {
params.add("friends_recomm");
for (String param : params) {
if (!isDisabled(param)) {
filteredParams.add(param);
}
} }
return filteredParams.toArray(new String[0]); if (!ads()) {
} params.add("app_widget");
params.add("promo_button");
}
private static boolean isDisabled(String param) { if (!authorsrecomm()) {
return switch (param) { params.add("authors_rec");
case "friends_recomm" -> friendsrecomm(); }
case "app_widget", "promo_button" -> ads();
case "authors_rec" -> authorsrecomm(); return params.toArray(new String[0]);
default -> false;
};
} }
public static void adsParams(HashSet<String> hashSet) { public static void adsParams(HashSet<String> hashSet) {
String[] adsParams = {"ads_app_slider", "ads_site_slider", "ads_app", "ads_site", "ads_post", "ads_app_video", "ads_post_pretty_cards", "ads_post_snippet_video"};
String noAdParam = "ads_disabled";
if (ads()) { if (ads()) {
hashSet.add(noAdParam); hashSet.add("ads_disabled");
if (!Preferences.milkshake()) {
hashSet.add(adsParams[0]);
}
} else { } else {
Collections.addAll(hashSet, adsParams); hashSet.add("ads_app_slider");
} hashSet.add("ads_site_slider");
}
public static void takeOwnerIdSponsorPost(int ownerid) {
if (NetworkUtils.isNetworkConnected() && PostsPreferences.isEnabled() && !Preferences.serverFeaturesDisable()) {
VTExecutors.getIoScheduler().a(() -> {
if (PostsPreferences.isGroupAd(ownerid) || VotesPreferences.isGroupAd(ownerid)) {
if (VotesPreferences.isEnabled()) {
Map<String, List<String>> postIds = VotesService.getPostIdsByOwnerId((long) ownerid, 0L);
VotesPreferences.saveGroupSpecifiedPosts(postIds.get("vote"), (long) ownerid);
PostsPreferences.saveGroupSpecifiedPosts(postIds.get("prod"), (long) ownerid);
} else {
List<Long> postIds = PostService.getPostIdsByOwnerId((long) ownerid, 0L);
PostsPreferences.saveGroupSpecifiedPosts(postIds, (long) ownerid);
}
}
});
}
}
public static void takeOwnerIdPostIdSponsorPost(String[] strArr) {
long ownerid = Long.parseLong(strArr[0].split("_")[0]);
long postId = Long.parseLong(strArr[0].split("_")[1]);
if (PostsPreferences.isPostAd(ownerid, postId) || VotesPreferences.isPostAd(ownerid, postId)) {
return;
} }
if (NetworkUtils.isNetworkConnected() && PostsPreferences.isEnabled() && !Preferences.serverFeaturesDisable()) { hashSet.add("ads_app");
VTExecutors.getIoScheduler().a(() -> { hashSet.add("ads_site");
if (VotesPreferences.isEnabled()) { hashSet.add("ads_post");
boolean postIds = VotesService.isPostAd(ownerid, postId); hashSet.add("ads_app_video");
hashSet.add("ads_post_pretty_cards");
if (postIds) { hashSet.add("ads_post_snippet_video");
VotesPreferences.saveAdPostInfo(ownerid, postId);
}
} else {
boolean postIds = PostService.isPostAd(ownerid, postId);
if (postIds) {
PostsPreferences.saveAdPostInfo(ownerid, postId);
if (!PostsPreferences.isEnabledMarking()) {
sendToast("Этот пост помечен как рекламный");
}
}
}
});
}
} }
public static boolean isPowerSaveMode() { public static boolean isPowerSaveMode() {
@@ -152,12 +96,4 @@ public class NewsfeedHook {
// return !getBoolValue("force_disable_psm", false) && pw.isPowerSaveMode(); // return !getBoolValue("force_disable_psm", false) && pw.isPowerSaveMode();
return false; return false;
} }
public static boolean isRoaming(NetworkInfo networkInfo) {
return !Preferences.disableForceTrafficSaver() && networkInfo.isRoaming();
}
public static boolean isNetworkRoaming(TelephonyManager telephonyManager) {
return !Preferences.disableForceTrafficSaver() && telephonyManager.isNetworkRoaming();
}
} }
@@ -1,22 +1,16 @@
package ru.vtosters.hooks; package ru.vtosters.hooks;
import android.util.Log; import android.util.Log;
import com.vk.core.network.Network;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.hooks.other.Preferences; import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.proxy.ProxyUtils;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import static com.vk.core.network.Network.ClientType.CLIENT_API;
import static ru.vtosters.hooks.other.Preferences.*; import static ru.vtosters.hooks.other.Preferences.*;
import static ru.vtosters.lite.net.Request.makeRequest; import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi; import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
@@ -94,34 +88,22 @@ public class OnlineFormatterHook {
if (appname != null) return appname; if (appname != null) return appname;
okhttp3.Request req = new okhttp3.Request.a() makeRequest("https://" + getApi() + "/method/apps.get?app_id=" + appid + "&v=5.99&access_token=" + getUserToken(),
.b("https://" + getApi() + "/method/apps.get?app_id=" + appid + "&v=5.99&access_token=" + getUserToken()) response -> {
.a(); try {
JSONObject mainJson = new JSONObject(response);
JSONObject responseJson = mainJson.getJSONObject("response");
JSONArray itemsJson = responseJson.getJSONArray("items");
Network.b(CLIENT_API).a(req).a(new Callback() { AppName = itemsJson.getJSONObject(0).optString("title", "");
@Override
public void a(Call call, IOException e) {
e.fillInStackTrace();
}
@Override prefs.edit().putString(String.valueOf(appid), AppName).apply();
public void a(Call call, Response response) throws IOException {
try {
JSONObject mainJson = new JSONObject(response.a().g());
JSONObject responseJson = mainJson.getJSONObject("response");
JSONArray itemsJson = responseJson.getJSONArray("items");
AppName = itemsJson.getJSONObject(0).optString("title", "");
prefs.edit().putString(String.valueOf(appid), AppName).apply();
if (dev()) sendToast("AppName: " + AppName + " for appid: " + appid);
} catch (JSONException e) {
e.fillInStackTrace();
}
}
});
if (dev()) sendToast("AppName: " + AppName + " for appid: " + appid);
} catch (JSONException e) {
e.printStackTrace();
}
});
return AppName; return AppName;
} }
@@ -15,7 +15,6 @@ import android.widget.Toast;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import com.vk.core.dialogs.actionspopup.ActionsPopup; import com.vk.core.dialogs.actionspopup.ActionsPopup;
import com.vk.core.dialogs.alert.VkAlertDialog; import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.network.Network;
import com.vk.core.util.ToastUtils; import com.vk.core.util.ToastUtils;
import com.vk.dto.common.AttachmentWithMedia; import com.vk.dto.common.AttachmentWithMedia;
import com.vk.dto.common.ImageSize; import com.vk.dto.common.ImageSize;
@@ -91,7 +90,7 @@ public class PhotoViewer {
var req = new Request.a() var req = new Request.a()
.b(getImageUrlFromAttachment(attachment)) .b(getImageUrlFromAttachment(attachment))
.a(); .a();
Network.b(Network.ClientType.CLIENT_API).a(req).a(new Callback() { client.a(req).a(new Callback() {
@Override @Override
public void a(Call call, IOException e) { public void a(Call call, IOException e) {
e.printStackTrace(); e.printStackTrace();
@@ -101,7 +100,7 @@ public class PhotoViewer {
public void a(Call call, Response response) public void a(Call call, Response response)
throws IOException { throws IOException {
var tmpImage = new File(AndroidUtils.getGlobalContext().getExternalCacheDir(), attachment.getId() + ".jpg"); var tmpImage = new File(AndroidUtils.getGlobalContext().getExternalCacheDir(), attachment.getId() + ".jpg");
try (var resp = Network.b(Network.ClientType.CLIENT_IMAGE_LOADER).a(req).execute(); try (var resp = client.a(req).execute();
var sink = Okio.a(Okio.b(tmpImage))) { var sink = Okio.a(Okio.b(tmpImage))) {
sink.a(resp.a().f()); sink.a(resp.a().f());
var manager = (ClipboardManager) AndroidUtils.getGlobalContext().getSystemService(Context.CLIPBOARD_SERVICE); var manager = (ClipboardManager) AndroidUtils.getGlobalContext().getSystemService(Context.CLIPBOARD_SERVICE);
@@ -176,4 +175,4 @@ public class PhotoViewer {
} }
return max.url; return max.url;
} }
} }
@@ -1,43 +0,0 @@
package ru.vtosters.hooks;
import android.content.Context;
import android.util.Log;
import com.vk.dto.newsfeed.entries.NewsEntry;
import com.vk.dto.newsfeed.entries.Post;
import com.vk.newsfeed.NewsEntryActionsAdapter;
import com.vk.newsfeed.holders.AdMarkHolder;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.sponsorpost.internal.Native;
import ru.vtosters.sponsorpost.utils.PostsPreferences;
public class PostsMenuHook {
private static final int id = 200;
public static void injectList(NewsEntryActionsAdapter actionsAdapter, NewsEntry newsEntry) {
if (newsEntry instanceof Post && Preferences.isValidSignature() && Native.canVote()) {
int ownerId = ((Post) newsEntry).b();
if (ownerId != AccountManagerUtils.getUserId() && PostsPreferences.isEnabled()) {
actionsAdapter.a(id, "SponsorPost");
}
}
}
public static void injectButtons(int i, NewsEntry newsEntry, Context context) {
if (newsEntry instanceof Post) {
Post post = (Post) newsEntry;
int ownerId = post.b();
int postId = post.P1();
int date = post.K();
AdMarkHolder.voteDialog(ownerId, postId, date, context);
} else {
Log.d("PostsMenuHook", "unsupported instance");
}
}
public static boolean isCustomButton(int i) {
return i == id;
}
}
@@ -26,15 +26,26 @@ import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
public class ProxyHook { public class ProxyHook {
public static String linkReplacer(String link) { public static String linkReplacer(String link) {
String vkapi = "api.vk.com"; var vkapi = "api.vk.com";
String oauth = "oauth.vk.com"; var oauth = "oauth.vk.com";
String vkstatic = "static.vk.com"; var vkstatic = "static.vk.com";
String proxyapi = getProxyHost("proxyapi"); var proxyapi = getString("proxyapi");
String proxyoauth = getProxyHost("proxyoauth"); var proxyoauth = getString("proxyoauth");
String proxystatic = getProxyHost("proxystatic"); var proxystatic = getString("proxystatic");
if (!isAnyProxyEnabled() || link.isEmpty() || areProxyHostsEmpty(proxyapi, proxyoauth, 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; return link;
} }
@@ -53,29 +64,6 @@ public class ProxyHook {
return link; return link;
} }
private static String getProxyHost(String hostType) {
if (isVikaProxyEnabled()) {
return switch (hostType) {
case "proxyapi" -> VikaMobile.getApiHost();
case "proxyoauth" -> VikaMobile.getOauthHost();
case "proxystatic" -> VikaMobile.getStaticHost();
default -> "";
};
} else {
return "";
}
}
private static boolean areProxyHostsEmpty(String... hosts) {
for (String host : hosts) {
if (host.isEmpty()) {
Log.d("VTLite", "Proxy is not set: " + host);
return true;
}
}
return false;
}
public static String staticFix(String str) { public static String staticFix(String str) {
var string = getString("proxystatic"); var string = getString("proxystatic");
@@ -120,18 +108,22 @@ public class ProxyHook {
RadioButton rgDefault = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton)); RadioButton rgDefault = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgZaborona = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton)); RadioButton rgZaborona = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgRandomProxy = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
RadioButton rgVika = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton)); RadioButton rgVika = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
SwitchHook.setCompoundButton(rgDefault); SwitchHook.setCompoundButton(rgDefault);
SwitchHook.setCompoundButton(rgZaborona); SwitchHook.setCompoundButton(rgZaborona);
SwitchHook.setCompoundButton(rgRandomProxy);
SwitchHook.setCompoundButton(rgVika); SwitchHook.setCompoundButton(rgVika);
rg.addView(rgDefault); rg.addView(rgDefault);
rg.addView(rgVika); rg.addView(rgVika);
rg.addView(rgZaborona); rg.addView(rgZaborona);
rg.addView(rgRandomProxy);
rgDefault.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f)); rgDefault.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
rgZaborona.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f)); rgZaborona.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
rgRandomProxy.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
rgVika.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f)); rgVika.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
rg.setPadding(dp2px(18f), dp2px(12f), dp2px(18f), 0); rg.setPadding(dp2px(18f), dp2px(12f), dp2px(18f), 0);
@@ -142,21 +134,28 @@ public class ProxyHook {
rgZaborona.setText(ctx.getString(R.string.proxy_enable) + " (Zaborona)"); rgZaborona.setText(ctx.getString(R.string.proxy_enable) + " (Zaborona)");
rgZaborona.setTextColor(getTextAttr()); rgZaborona.setTextColor(getTextAttr());
rgRandomProxy.setText(ctx.getString(R.string.proxy_enable) + " (Random Socks Proxy)");
rgRandomProxy.setTextColor(getTextAttr());
rgVika.setText(ctx.getString(R.string.proxy_enable) + " (Vika Mobile)"); rgVika.setText(ctx.getString(R.string.proxy_enable) + " (Vika Mobile)");
rgVika.setTextColor(getTextAttr()); rgVika.setTextColor(getTextAttr());
rgZaborona.setChecked(isZaboronaEnabled()); rgZaborona.setChecked(isZaboronaEnabled());
rgDefault.setChecked(!isZaboronaEnabled() && !isVikaProxyEnabled()); rgDefault.setChecked(!isZaboronaEnabled() && !isRandomProxyEnabled() && !isVikaProxyEnabled());
rgRandomProxy.setChecked(isRandomProxyEnabled());
rgVika.setChecked(isVikaProxyEnabled()); rgVika.setChecked(isVikaProxyEnabled());
new VkAlertDialog.Builder(ctx) new VkAlertDialog.Builder(ctx)
.setTitle(ctx.getString(R.string.vtlproxy)) .setTitle(ctx.getString(R.string.vtlproxy))
.setMessage(ctx.getString(R.string.proxy_warning) + "\n\nТак же можно включить встроенный прокси от ВКонтакте перейдя в настройки прокси") .setMessage(ctx.getString(R.string.proxy_warning))
.setView(rg) .setView(rg)
.setPositiveButton(ctx.getString(R.string.vtl_confirm), ((dialog, which) -> { // Применить .setPositiveButton(ctx.getString(R.string.vtl_confirm), ((dialog, which) -> { // Применить
if (rgZaborona.isChecked()) { if (rgZaborona.isChecked()) {
Preferences.getPreferences().edit().putString("proxy", "zaborona").commit(); Preferences.getPreferences().edit().putString("proxy", "zaborona").commit();
restartApplication(); restartApplication();
} else if (rgRandomProxy.isChecked()) {
Preferences.getPreferences().edit().putString("proxy", "randomproxy").commit();
restartApplication();
} else if (rgVika.isChecked()) { } else if (rgVika.isChecked()) {
Preferences.getPreferences().edit().putString("proxy", "vika").commit(); Preferences.getPreferences().edit().putString("proxy", "vika").commit();
restartApplication(); restartApplication();
@@ -170,4 +169,4 @@ public class ProxyHook {
}) })
.show(); .show();
} }
} }
@@ -9,7 +9,7 @@ import static ru.vtosters.hooks.other.Preferences.*;
public class TogglesHook { public class TogglesHook {
public static boolean shouldPatch(Features.Type feature) { public static boolean shouldPatch(Features.Type feature) {
return switch (feature) { return switch (feature) {
case AB_MULTI_GIFTS, AB_NEWS_VIDEO_LAYOUT_TEXT, AB_STICKERS_DISCOVER, AB_GIFTS_FROM_KEYBOARD, EXPERIMENT_NEWS_VIDEO_LAYOUT_TEXT, FEATURE_DISCOVER_CATEGORIES, FEATURE_FAVE_PERF_IMPROVE, FEATURE_GROUP_ADMIN_MESSAGES, FEATURE_GROUP_MSG_PUSH_PARAM, FEATURE_IMAGE_QUALITY_UPGRADE, FEATURE_IM_AUDIO_MSG_TRANSCRIPT, FEATURE_IM_CASPER_MSGS, FEATURE_IM_DISABLE_FORCE_OPEN_VK_ME, FEATURE_IM_GIF_AUTOPLAY, FEATURE_IM_MR_IN_VKAPP, FEATURE_MEMORIES_ENABLED, FEATURE_MENU_GAMES_CAROUSEL, FEATURE_MILKSHAKE, FEATURE_MILKSHAKE_NEWS_SCROLL_ON_BACK, FEATURE_MILKSHAKE_SWITCH_THEME_ON_TAP, FEATURE_ML_BRANDS, FEATURE_ML_FEATURES, FEATURE_ML_MODELS_LOADING, FEATURE_MONEY_TRANSFERS_VKPAY, FEATURE_MUSIC_ARTIST_CATALOG, FEATURE_MUSIC_NEW_CATALOG, FEATURE_NARRATIVE_SNIPPET_TYPE, FEATURE_NEWS_GAMES_IN_DISCOVER, FEATURE_NEWS_HEADER_SCROLL, FEATURE_NEW_FORMAT_SHOW_WPB, FEATURE_PODCASTS_PAGE, FEATURE_QR_CREATE_QR, FEATURE_QR_DYNAMIC_FRAME, FEATURE_QR_SCAN_FROM_PHOTO, FEATURE_QR_VISION_DECODER, FEATURE_QUEUE_COUNTERS, FEATURE_REEF, FEATURE_ROAMING_AUTOPLAY, FEATURE_SHARE_MSGS_ON_INVITE, FEATURE_STICKERS_BOT_LINK, FEATURE_STICKERS_NEW_CATALOG, FEATURE_STORIES_AVATAR, FEATURE_STORIES_FEED_TYPE, FEATURE_STORIES_SHOW_ALWAYS, FEATURE_STORY_ANSWER_PUBLIC, FEATURE_STORY_APP_STICKER, FEATURE_STORY_ARCHIVE, FEATURE_STORY_ARCHIVE_POST, FEATURE_STORY_BAKGROUND_ALL, FEATURE_STORY_BOX, FEATURE_STORY_CADRE, FEATURE_STORY_CAMERA_TOOLTIP, FEATURE_STORY_EDITOR_GALLERY, FEATURE_STORY_EDITOR_TYPE, FEATURE_STORY_ENDLESS_VIDEO, FEATURE_STORY_FAST_REACTIONS, FEATURE_STORY_GIF, FEATURE_STORY_GROUPED, FEATURE_STORY_HIGH_QUALITY, FEATURE_STORY_MASKS_FRONTAL, FEATURE_STORY_MENTION_ICON, FEATURE_STORY_MODERN_PUBLISH, FEATURE_STORY_MUSIC_EDITOR, FEATURE_STORY_MUSIC_REPLIES, FEATURE_STORY_MUSIC_REPLIES_2, FEATURE_STORY_NEW_FRAME, FEATURE_STORY_ONE_TIME, FEATURE_STORY_PHOTO_SHARING, FEATURE_STORY_PHOTO_STICKER, FEATURE_STORY_POLLS, FEATURE_STORY_POST_REPOST, FEATURE_STORY_PRELOADING, FEATURE_STORY_QUESTION, FEATURE_STORY_QUESTION_STYLE, FEATURE_STORY_RLOTTIE, FEATURE_STORY_RLOTTIE_CACHE, FEATURE_STORY_SAVE_DEFAULT_ON, FEATURE_STORY_SEND_DIALOG_LIST, FEATURE_STORY_STICKER_PACK, FEATURE_STORY_TIME, FEATURE_STORY_VIEWER_CAMERA, FEATURE_STORY_VOICE_ANSWER, FEATURE_STORY_WITH_CONTEXT, FEATURE_SUPERAPP_MENU, FEATURE_TRAFFIC_SAVER, FEATURE_VKPAY_WIDGET, FEATURE_VKUI_INTERNAL_TO_MINI_APPS, FEATURE_VKUI_TOKEN_CACHE, FEATURE_VK_APPS_SEARCH, FEATURE_VOTES_BALANCE, FEATURE_WEBVIEW_TOKEN_ACTIVE, FEATURE_MILKSHAKE_FORCE_DISABLED, FEATURE_MILKSHAKE_ACTIVATION_DISABLED, EXPERIMENT_NEWS_DISABLE_CACHE -> case AB_IM_LONGPOLL_MSG_BATCHING, AB_IM_VIEW_POOL, AB_MULTI_GIFTS, AB_NEWS_VIDEO_LAYOUT_TEXT, AB_STICKERS_DISCOVER, AB_GIFTS_FROM_KEYBOARD, FEATURE_FEED_DEFAULT_LIST_ALWAYS, EXPERIMENT_NEWS_VIDEO_LAYOUT_TEXT, FEATURE_DISCOVER_CATEGORIES, FEATURE_FAVE_PERF_IMPROVE, FEATURE_GROUP_ADMIN_MESSAGES, FEATURE_GROUP_MSG_PUSH_PARAM, FEATURE_IMAGE_QUALITY_UPGRADE, FEATURE_IM_AUDIO_MSG_TRANSCRIPT, FEATURE_IM_CASPER_MSGS, FEATURE_IM_DISABLE_FORCE_OPEN_VK_ME, FEATURE_IM_GIF_AUTOPLAY, FEATURE_IM_MR_IN_VKAPP, FEATURE_MEMORIES_ENABLED, FEATURE_MENU_GAMES_CAROUSEL, FEATURE_MILKSHAKE, FEATURE_MILKSHAKE_CHANGE_FEED_BY_TIMEOUT, FEATURE_MILKSHAKE_NEWS_SCROLL_ON_BACK, FEATURE_MILKSHAKE_SWITCH_THEME_ON_TAP, FEATURE_ML_BRANDS, FEATURE_ML_FEATURES, FEATURE_ML_MODELS_LOADING, FEATURE_MONEY_TRANSFERS_VKPAY, FEATURE_MUSIC_ARTIST_CATALOG, FEATURE_MUSIC_NEW_CATALOG, FEATURE_NARRATIVE_SNIPPET_TYPE, FEATURE_NEWS_GAMES_IN_DISCOVER, FEATURE_NEWS_HEADER_SCROLL, FEATURE_NEW_FORMAT_SHOW_WPB, FEATURE_PODCASTS_PAGE, FEATURE_QR_CREATE_QR, FEATURE_QR_DYNAMIC_FRAME, FEATURE_QR_SCAN_FROM_PHOTO, FEATURE_QR_VISION_DECODER, FEATURE_QUEUE_COUNTERS, FEATURE_REEF, FEATURE_ROAMING_AUTOPLAY, FEATURE_SHARE_MSGS_ON_INVITE, FEATURE_STICKERS_BOT_LINK, FEATURE_STICKERS_NEW_CATALOG, FEATURE_STORIES_AVATAR, FEATURE_STORIES_FEED_TYPE, FEATURE_STORIES_SHOW_ALWAYS, FEATURE_STORY_ANSWER_PUBLIC, FEATURE_STORY_APP_STICKER, FEATURE_STORY_ARCHIVE, FEATURE_STORY_ARCHIVE_POST, FEATURE_STORY_BAKGROUND_ALL, FEATURE_STORY_BOX, FEATURE_STORY_CADRE, FEATURE_STORY_CAMERA_TOOLTIP, FEATURE_STORY_EDITOR_GALLERY, FEATURE_STORY_EDITOR_TYPE, FEATURE_STORY_ENDLESS_VIDEO, FEATURE_STORY_FAST_REACTIONS, FEATURE_STORY_GIF, FEATURE_STORY_GROUPED, FEATURE_STORY_HIGH_QUALITY, FEATURE_STORY_MASKS_FRONTAL, FEATURE_STORY_MENTION_ICON, FEATURE_STORY_MODERN_PUBLISH, FEATURE_STORY_MUSIC_EDITOR, FEATURE_STORY_MUSIC_REPLIES, FEATURE_STORY_MUSIC_REPLIES_2, FEATURE_STORY_NEW_FRAME, FEATURE_STORY_ONE_TIME, FEATURE_STORY_PHOTO_SHARING, FEATURE_STORY_PHOTO_STICKER, FEATURE_STORY_POLLS, FEATURE_STORY_POST_REPOST, FEATURE_STORY_PRELOADING, FEATURE_STORY_QUESTION, FEATURE_STORY_QUESTION_STYLE, FEATURE_STORY_RLOTTIE, FEATURE_STORY_RLOTTIE_CACHE, FEATURE_STORY_SAVE_DEFAULT_ON, FEATURE_STORY_SEND_DIALOG_LIST, FEATURE_STORY_STICKER_PACK, FEATURE_STORY_TIME, FEATURE_STORY_VIEWER_CAMERA, FEATURE_STORY_VOICE_ANSWER, FEATURE_STORY_WITH_CONTEXT, FEATURE_SUPERAPP_MENU, FEATURE_TRAFFIC_SAVER, FEATURE_VKPAY_WIDGET, FEATURE_VKUI_INTERNAL_TO_MINI_APPS, FEATURE_VKUI_TOKEN_CACHE, FEATURE_VK_APPS_SEARCH, FEATURE_VOTES_BALANCE, FEATURE_WEBVIEW_TOKEN_ACTIVE, FEATURE_MILKSHAKE_FORCE_DISABLED, FEATURE_MILKSHAKE_ACTIVATION_DISABLED, EXPERIMENT_NEWS_DISABLE_CACHE ->
true; true;
default -> false; default -> false;
}; };
@@ -25,7 +25,6 @@ public class TogglesHook {
postsredesign(); postsredesign();
case FEATURE_IMAGE_QUALITY_UPGRADE -> MediaImageEncoder.needToSkipCompression(); case FEATURE_IMAGE_QUALITY_UPGRADE -> MediaImageEncoder.needToSkipCompression();
case FEATURE_MENU_GAMES_CAROUSEL -> miniapps(); case FEATURE_MENU_GAMES_CAROUSEL -> miniapps();
case FEATURE_TRAFFIC_SAVER -> !disableForceTrafficSaver();
default -> true; default -> true;
}; };
} }
@@ -5,20 +5,19 @@ import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
import com.vk.core.network.Network; import com.vk.core.network.Network;
import com.vk.core.util.DeviceIdProvider; import com.vk.core.util.DeviceIdProvider;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.hooks.other.Preferences; import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.music.cache.MusicCacheImpl; import ru.vtosters.lite.music.cache.MusicCacheImpl;
import ru.vtosters.lite.utils.AccountManagerUtils; import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.sponsorpost.utils.GzipDecompressor;
import java.io.IOException; import java.io.IOException;
import static com.vk.core.network.Network.ClientType.CLIENT_API;
import static ru.vtosters.hooks.DateHook.getLocale; import static ru.vtosters.hooks.DateHook.getLocale;
import static ru.vtosters.hooks.GroupsCatalogInjector.injectIntoCatalog; import static ru.vtosters.hooks.GroupsCatalogInjector.injectIntoCatalog;
import static ru.vtosters.hooks.other.Preferences.getBoolValue; import static ru.vtosters.hooks.other.Preferences.getBoolValue;
@@ -27,6 +26,8 @@ import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId; import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
public class CatalogJsonInjector { public class CatalogJsonInjector {
private static final OkHttpClient mClient = VtOkHttpClient.getInstance();
public static JSONObject music(JSONObject json) throws JSONException { public static JSONObject music(JSONObject json) throws JSONException {
var catalog = json.optJSONObject("catalog"); var catalog = json.optJSONObject("catalog");
var oldItems = catalog != null ? catalog.optJSONArray("sections") : null; var oldItems = catalog != null ? catalog.optJSONArray("sections") : null;
@@ -262,10 +263,9 @@ public class CatalogJsonInjector {
+ sectionUrl + sectionUrl
+ "&access_token=" + "&access_token="
+ AccountManagerUtils.getUserToken()) + AccountManagerUtils.getUserToken())
.a("Accept-Encoding", "gzip")
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a(); .a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a();
try (Response resp = Network.b(CLIENT_API).a(request).execute()) { try {
var json = new JSONObject(GzipDecompressor.decompressResponse(resp)).getJSONObject("response"); var json = new JSONObject(mClient.a(request).execute().a().g()).getJSONObject("response");
var catalogarr = json.optJSONObject("catalog").optJSONArray("sections").optJSONObject(0); var catalogarr = json.optJSONObject("catalog").optJSONArray("sections").optJSONObject(0);
var title = catalogarr.optString("title"); var title = catalogarr.optString("title");
@@ -279,4 +279,4 @@ public class CatalogJsonInjector {
Log.d("VTLMusic", "Error: " + e.getMessage()); Log.d("VTLMusic", "Error: " + e.getMessage());
} }
} }
} }
@@ -29,6 +29,7 @@ public class Preferences {
GmsHook.fixGapps(); GmsHook.fixGapps();
ProxyUtils.setProxy(); ProxyUtils.setProxy();
NewsFeedFiltersUtils.setupFilters();
VTVerifications.load(application); VTVerifications.load(application);
LifecycleUtils.registerActivities(application); LifecycleUtils.registerActivities(application);
@@ -176,10 +177,6 @@ public class Preferences {
return getBoolValue("miniapps", true); return getBoolValue("miniapps", true);
} }
public static boolean disableForceTrafficSaver() {
return getBoolValue("disableForceTrafficSaver", false);
}
public static boolean savemsgsett() { public static boolean savemsgsett() {
return getBoolValue("savemsgsett", false); return getBoolValue("savemsgsett", false);
} }
@@ -270,7 +267,7 @@ public class Preferences {
} }
public static boolean stories() { public static boolean stories() {
return getBoolValue("stories", true); return getBoolValue("stories", false);
} }
public static boolean swipe() { public static boolean swipe() {
@@ -295,7 +292,7 @@ public class Preferences {
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public static boolean checkupdates() { public static boolean checkupdates() {
return !getBoolValue("isRoamingState", false) && isValidSignature() && BuildConfig.BUILD_TYPE.equals("release") && getBoolValue("autoupdates", true) && !serverFeaturesDisable(); return !getBoolValue("isRoamingState", false) && isValidSignature() && BuildConfig.BUILD_TYPE.equals("release") && getBoolValue("autoupdates", true);
} }
public static boolean isNewBuild() { public static boolean isNewBuild() {
@@ -311,10 +308,6 @@ public class Preferences {
return false; return false;
} }
public static String getId() {
return String.valueOf(AccountManagerUtils.getUserId());
}
public static void updateBuildNumber() { public static void updateBuildNumber() {
try { try {
getPreferences().edit().putLong("setupTime", AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo(AndroidUtils.getPackageName(), 0).lastUpdateTime).apply(); getPreferences().edit().putLong("setupTime", AndroidUtils.getGlobalContext().getPackageManager().getPackageInfo(AndroidUtils.getPackageName(), 0).lastUpdateTime).apply();
@@ -2,7 +2,6 @@ package ru.vtosters.hooks.other;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
@@ -74,7 +73,7 @@ public class ThemesUtils {
} }
public static boolean isMonetTheme() { public static boolean isMonetTheme() {
return getBoolValue("monettheme", false); return getBoolValue("monettheme", false) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S;
} }
public static boolean isAmoledTheme() { public static boolean isAmoledTheme() {
@@ -341,7 +340,7 @@ public class ThemesUtils {
} }
public static int getColor(int i) { public static int getColor(int i) {
return ThemesHacks.getHackedColor(LifecycleUtils.getCurrentActivity(), i); return ThemesHacks.getHackedColor(getGlobalContext(), i);
} // Android Support color injector + accent color checker } // Android Support color injector + accent color checker
public static int getAlertStyle() { public static int getAlertStyle() {
@@ -392,14 +391,14 @@ public class ThemesUtils {
return vkme() ? R.dimen.app_minimumsize_h : Default; return vkme() ? R.dimen.app_minimumsize_h : Default;
} }
public static ColorStateList getCSTDock(Context ctx) { public static ColorStateList getCSTDock() {
return new ColorStateList( return new ColorStateList(
new int[][]{ new int[][]{
new int[]{android.R.attr.state_checked}, new int[]{android.R.attr.state_checked},
new int[]{-android.R.attr.state_checked} new int[]{-android.R.attr.state_checked}
}, },
new int[]{ new int[]{
dockbar_accent() ? getAccentColor() : (isDarkTheme() ? ThemesHacks.getColors(ctx, R.color.white) : ThemesHacks.getColors(ctx, R.color.gray_700)), dockbar_accent() ? getAccentColor() : (isDarkTheme() ? getResources().getColor(R.color.white) : getResources().getColor(R.color.gray_700)),
getColorFromAttr(R.attr.tabbar_inactive_icon) getColorFromAttr(R.attr.tabbar_inactive_icon)
} }
); );
@@ -10,4 +10,4 @@ public class VtOkHttpClient extends OkHttpClient {
private static class LazyHolder { private static class LazyHolder {
private static final VtOkHttpClient instance = new VtOkHttpClient(); private static final VtOkHttpClient instance = new VtOkHttpClient();
} }
} }
@@ -6,6 +6,7 @@ import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.engine.models.messages.Msg; import com.vk.im.engine.models.messages.Msg;
import com.vk.im.engine.utils.ImDialogsUtils; import com.vk.im.engine.utils.ImDialogsUtils;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.OkHttpClient;
import ru.vtosters.hooks.other.ThemesUtils; import ru.vtosters.hooks.other.ThemesUtils;
import ru.vtosters.lite.concurrent.VTExecutors; import ru.vtosters.lite.concurrent.VTExecutors;
import ru.vtosters.lite.net.Request; import ru.vtosters.lite.net.Request;
@@ -14,49 +15,21 @@ import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils; import ru.vtosters.lite.utils.LifecycleUtils;
import java.io.IOException;
import static com.vk.core.network.Network.ClientType.CLIENT_API;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
public class Requests { public class Requests {
public static void hookRead(Dialog dialog) { public static void hookRead(Dialog dialog) {
okhttp3.Request req = new okhttp3.Request.a() Request.makeRequest("https://" + ProxyUtils.getApi() + "/method/messages.markAsRead?start_message_id=" + dialog.F1() + "&peer_id=" + dialog.getId() + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken(), response -> {
.b("https://" + ProxyUtils.getApi() + "/method/messages.markAsRead?start_message_id=" + dialog.F1() + "&peer_id=" + dialog.getId() + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken()) });
.a();
try {
Network.b(CLIENT_API).a(req).execute().close();;
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
public static void hookReadStartMsgTo(Msg dialog) { public static void hookReadStartMsgTo(Msg dialog) {
okhttp3.Request req = new okhttp3.Request.a() Request.makeRequest("https://" + ProxyUtils.getApi() + "/method/messages.markAsRead?start_message_id=" + dialog.C1() + "&peer_id=" + dialog.v1() + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken(), response -> {
.b("https://" + ProxyUtils.getApi() + "/method/messages.markAsRead?start_message_id=" + dialog.C1() + "&peer_id=" + dialog.v1() + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken()) });
.a();
try {
Network.b(CLIENT_API).a(req).execute().close();
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
public static void hookKick(Msg dialog) { public static void hookKick(Msg dialog) {
if (dialog.getFrom().t1() == AccountManagerUtils.getUserId()) return; if (dialog.getFrom().t1() == AccountManagerUtils.getUserId()) return;
Request.makeRequest("https://" + ProxyUtils.getApi() + "/method/messages.removeChatUser?member_id=" + dialog.getFrom().t1() + "&chat_id=" + ImDialogsUtils.c(dialog.v1()) + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken(), response -> {
okhttp3.Request req = new okhttp3.Request.a() });
.b("https://" + ProxyUtils.getApi() + "/method/messages.removeChatUser?member_id=" + dialog.getFrom().t1() + "&chat_id=" + ImDialogsUtils.c(dialog.v1()) + "&v=5.119&access_token=" + AccountManagerUtils.getUserToken())
.a();
try {
Network.b(CLIENT_API).a(req).execute().close();;
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
public static void hookDialogInfo(Dialog dialog) { public static void hookDialogInfo(Dialog dialog) {
@@ -78,7 +51,7 @@ public class Requests {
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")) .a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"))
.a(); .a();
Network.b(CLIENT_API).a(request).execute().a().g(); new OkHttpClient().a(request).execute().a().g();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -7,7 +7,6 @@ import com.vk.dto.music.MusicTrack;
import com.vk.dto.music.Playlist; import com.vk.dto.music.Playlist;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import ru.vtosters.hooks.music.MusicCacheFilesHook; import ru.vtosters.hooks.music.MusicCacheFilesHook;
import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.music.cache.MusicCacheImpl; import ru.vtosters.lite.music.cache.MusicCacheImpl;
import ru.vtosters.lite.music.callback.MusicCallbackBuilder; import ru.vtosters.lite.music.callback.MusicCallbackBuilder;
import ru.vtosters.lite.music.converter.playlist.PlaylistConverter; import ru.vtosters.lite.music.converter.playlist.PlaylistConverter;
@@ -33,14 +32,13 @@ import static ru.vtosters.lite.utils.AndroidUtils.getString;
public class AudioDownloader { public class AudioDownloader {
public static final ExecutorService executor = Executors.newCachedThreadPool(); public static final ExecutorService executor = Executors.newCachedThreadPool();
public static final String dlpath = Preferences.getBoolValue("dldir", false) ? Environment.DIRECTORY_DOWNLOADS : Environment.DIRECTORY_MUSIC;
public static void downloadPlaylist(Playlist playlist) { public static void downloadPlaylist(Playlist playlist) {
var tracks = PlaylistConverter.getPlaylist(playlist); var tracks = PlaylistConverter.getPlaylist(playlist);
var playlistName = IOUtils.getValidFileName(playlist.g); var playlistName = IOUtils.getValidFileName(playlist.g);
var musicPath = Environment.getExternalStoragePublicDirectory(dlpath).getAbsolutePath(); var musicPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
var downloadPath = musicPath + File.separator + playlistName; var downloadPath = musicPath + File.separator + playlistName;
var notificationId = playlistName.hashCode(); var notificationId = playlistName.hashCode();
@@ -106,7 +104,7 @@ public class AudioDownloader {
var playlistName = "Audios of " + AccountManagerUtils.getUserId(); var playlistName = "Audios of " + AccountManagerUtils.getUserId();
var musicPath = Environment.getExternalStoragePublicDirectory(dlpath).getAbsolutePath(); var musicPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
var downloadPath = musicPath + File.separator + playlistName; var downloadPath = musicPath + File.separator + playlistName;
PlaylistDownloader.downloadPlaylist( PlaylistDownloader.downloadPlaylist(
@@ -123,7 +121,7 @@ public class AudioDownloader {
return; return;
} }
var musicPath = Environment.getExternalStoragePublicDirectory(dlpath).getAbsolutePath(); var musicPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
var tempId = track.d; var tempId = track.d;
var downloadPath = musicPath + File.separator; var downloadPath = musicPath + File.separator;
var notification = MusicNotificationBuilder.buildDownloadNotification(track, tempId); var notification = MusicNotificationBuilder.buildDownloadNotification(track, tempId);
@@ -1,29 +1,29 @@
package ru.vtosters.lite.downloaders; package ru.vtosters.lite.downloaders;
import android.media.MediaScannerConnection; import android.app.DownloadManager;
import android.content.Context;
import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import com.vk.core.network.Network;
import com.vk.dto.common.ImageSize; import com.vk.dto.common.ImageSize;
import com.vk.dto.stories.model.StoryEntry; import com.vk.dto.stories.model.StoryEntry;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import ru.vtosters.lite.utils.AndroidUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List; import java.util.List;
import static ru.vtosters.lite.downloaders.VideoDownloader.downloadVideo; import static ru.vtosters.lite.downloaders.VideoDownloader.downloadVideo;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class StoryDownloader { public class StoryDownloader {
public static void downloadStory(StoryEntry story) { public static void downloadStory(StoryEntry story) {
if (story.T1()) { if (story.T1()) {
downloadImage(story); List<ImageSize> imageSizes = story.E.Q.t1();
String url = imageSizes.get(imageSizes.size() - 1).url;
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle("photo" + story.E.a + ".jpg");
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES, "photo" + story.E.a + ".jpg");
request.allowScanningByMediaScanner();
((DownloadManager) getGlobalContext().getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
return; return;
} }
// if story is a video // if story is a video
@@ -31,55 +31,4 @@ public class StoryDownloader {
downloadVideo(story.F, null); downloadVideo(story.F, null);
} }
} }
}
public static void downloadImage(StoryEntry story) {
List<ImageSize> imageSizes = story.E.Q.t1();
String url = imageSizes.get(imageSizes.size() - 1).url;
OkHttpClient client = Network.b(Network.ClientType.CLIENT_IMAGE_LOADER);
Request request = new Request.a()
.b(url)
.a();
try (Response response = client.a(request).execute()) {
if (!response.h()) {
throw new IOException("Unexpected code " + response);
}
ResponseBody responseBody = response.a();
if (responseBody == null) {
throw new IOException("No response body");
}
String fileName = "photo" + story.E.a + ".jpg";
File outputDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "/Stories/");
if (!outputDir.exists()) {
outputDir.mkdirs();
}
File outputFile = new File(outputDir, fileName);
try (InputStream inputStream = responseBody.a();
FileOutputStream outputStream = new FileOutputStream(outputFile)) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
MediaScannerConnection.scanFile(AndroidUtils.getGlobalContext(), new String[]{outputFile.toString()}, null, null);
AndroidUtils.sendToast("Файл скачан в Pictures/Stories");
} catch (IOException e) {
e.fillInStackTrace();
}
} catch (IOException e) {
e.fillInStackTrace();
}
}
}
@@ -1,8 +1,9 @@
package ru.vtosters.lite.downloaders; package ru.vtosters.lite.downloaders;
import android.app.DownloadManager;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.media.MediaScannerConnection; import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
@@ -12,113 +13,35 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.vk.core.dialogs.alert.VkAlertDialog; import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.dialogs.bottomsheet.MenuBottomSheetAction; import com.vk.core.dialogs.bottomsheet.MenuBottomSheetAction;
import com.vk.core.network.Network;
import com.vk.core.util.ToastUtils; import com.vk.core.util.ToastUtils;
import com.vk.dto.common.VideoFile; import com.vk.dto.common.VideoFile;
import com.vk.dto.stories.model.StoryEntry; import com.vk.dto.stories.model.StoryEntry;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import okhttp3.*;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils; import ru.vtosters.lite.utils.LifecycleUtils;
import ru.vtosters.sponsorpost.utils.GzipDecompressor;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.vk.core.network.Network.ClientType.CLIENT_API;
import static ru.vtosters.hooks.other.ThemesUtils.getTextAttr; 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.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken; import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
public class VideoDownloader { public class VideoDownloader {
public static int DOWNLOAD_ID = 0; public static final int DOWNLOAD_ID = 0;
public static int OPEN_EXTERNAL_LINK_ID = 1; public static final int OPEN_EXTERNAL_LINK_ID = 1;
public 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])); actions.add(new MenuBottomSheetAction(ints[0], ints[1], ints[2], ints[3]));
} }
public static void downloadVideo(VideoFile videoFile, Context context) { public static void downloadVideo(VideoFile videoFile, Context context) {
List<String> qualities = new ArrayList<>(); final List<String> qualities = new ArrayList<>();
List<String> urls = new ArrayList<>(); final List<String> urls = new ArrayList<>();
addVideos(videoFile, qualities, urls);
Context finalContext = context != null ? context : LifecycleUtils.getCurrentActivity();
if (qualities.isEmpty()) {
ToastUtils.a(finalContext.getString(R.string.videodownloaderr));
return;
}
var adapter = new ArrayAdapter(
finalContext,
android.R.layout.simple_list_item_1,
qualities.toArray(new String[0])) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
textView.setTextColor(getTextAttr());
return textView;
}
};
new VkAlertDialog.Builder(finalContext)
.setAdapter(adapter, (dialog, which) -> {
String url = urls.get(which);
OkHttpClient client = Network.b(Network.ClientType.CLIENT_IMAGE_LOADER);;
Request request = new Request.a()
.b(url)
.a();
try (Response response = client.a(request).execute()) {
if (!response.h()) {
throw new IOException("Unexpected code " + response);
}
ResponseBody responseBody = response.a();
File outputDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES), "/VKVideo/");
if (!outputDir.exists()) {
outputDir.mkdirs();
}
File outputFile = new File(outputDir, videoFile + ".mp4");
try (InputStream inputStream = responseBody.a();
FileOutputStream outputStream = new FileOutputStream(outputFile)) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
MediaScannerConnection.scanFile(finalContext, new String[]{outputFile.toString()}, null, null);
AndroidUtils.sendToast("Файл скачан в Movies/VKVideo");
} catch (IOException e) {
e.fillInStackTrace();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.show();
}
public static void addVideos(VideoFile videoFile, List<String> qualities, List<String> urls) {
if (!TextUtils.isEmpty(videoFile.D)) { if (!TextUtils.isEmpty(videoFile.D)) {
qualities.add("2160p"); qualities.add("2160p");
urls.add(videoFile.D); urls.add(videoFile.D);
@@ -152,6 +75,40 @@ public class VideoDownloader {
qualities.add("240p"); qualities.add("240p");
urls.add(videoFile.e); urls.add(videoFile.e);
} }
Context finalContext = context != null ? context : LifecycleUtils.getCurrentActivity();
if (qualities.isEmpty()) {
ToastUtils.a(finalContext.getString(R.string.videodownloaderr));
return;
}
var adapter = new ArrayAdapter(
finalContext,
android.R.layout.simple_list_item_1,
qualities.toArray(new String[0])) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
textView.setTextColor(getTextAttr());
return textView;
}
};
new VkAlertDialog.Builder(finalContext)
.setAdapter(adapter, (dialog, which) -> {
try {
var url = urls.get(which);
var request = new DownloadManager.Request(Uri.parse(url))
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
.setTitle(videoFile.toString())
.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile + ".mp4");
request.allowScanningByMediaScanner();
((DownloadManager) finalContext.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
} catch (Throwable ignored) {
}
})
.show();
} }
public static void parseVideoLink(String url, Context ctx) { public static void parseVideoLink(String url, Context ctx) {
@@ -167,35 +124,20 @@ public class VideoDownloader {
progressDialog.setMessage(ctx.getString(R.string.video_dl_progress)); progressDialog.setMessage(ctx.getString(R.string.video_dl_progress));
progressDialog.show(); progressDialog.show();
var req = new Request.a() makeRequest("https://" + getApi() + "/method/stories.getById?stories=" + storyId + "&v=5.99&access_token=" + getUserToken(),
.b("https://" + getApi() + "/method/stories.getById?stories=" + storyId + "&v=5.99&access_token=" + getUserToken()) response -> {
.a("Accept-Encoding", "gzip") progressDialog.cancel();
.a();
Network.b(CLIENT_API).a(req).a(new Callback() {
@Override try {
public void a(Call call, IOException e) { JSONObject mainJson = new JSONObject(response);
e.fillInStackTrace(); JSONObject responseJson = mainJson.getJSONObject("response").optJSONArray("items").optJSONObject(0);
Toast.makeText(ctx, ctx.getString(R.string.video_dl_error), Toast.LENGTH_SHORT).show(); StoryEntry story = new StoryEntry(responseJson);
} StoryDownloader.downloadStory(story);
} catch (JSONException e) {
@Override e.printStackTrace();
public void a(Call call, Response response) throws IOException { Toast.makeText(ctx, ctx.getString(R.string.video_dl_error), Toast.LENGTH_SHORT).show();
progressDialog.cancel(); }
});
try {
JSONObject mainJson = new JSONObject(GzipDecompressor.decompressResponse(response));
JSONObject responseJson = mainJson.getJSONObject("response").optJSONArray("items").optJSONObject(0);
StoryEntry story = new StoryEntry(responseJson);
StoryDownloader.downloadStory(story);
} catch (JSONException e) {
e.fillInStackTrace();
Toast.makeText(ctx, ctx.getString(R.string.video_dl_error), Toast.LENGTH_SHORT).show();
}
}
});
return; return;
} }
@@ -207,38 +149,25 @@ public class VideoDownloader {
String videoId = url.split("video")[1]; String videoId = url.split("video")[1];
String ownerId = videoId.split("_")[0]; String ownerId = videoId.split("_")[0];
ProgressDialog progressDialog = new ProgressDialog(ctx); final ProgressDialog progressDialog = new ProgressDialog(ctx);
progressDialog.setMessage(ctx.getString(R.string.video_dl_progress)); progressDialog.setMessage(ctx.getString(R.string.video_dl_progress));
progressDialog.show(); progressDialog.show();
var req = new Request.a() makeRequest("https://" + getApi() + "/method/video.get?owner_id=" + ownerId + "&videos=" + videoId + "&v=5.99&access_token=" + getUserToken(),
.b("https://" + getApi() + "/method/video.get?owner_id=" + ownerId + "&videos=" + videoId + "&v=5.99&access_token=" + getUserToken()) response -> {
.a("Accept-Encoding", "gzip") progressDialog.cancel();
.a();
Network.b(CLIENT_API).a(req).a(new Callback() { try {
@Override JSONObject mainJson = new JSONObject(response);
public void a(Call call, IOException e) { JSONObject responseJson = mainJson.getJSONObject("response");
e.fillInStackTrace(); JSONArray itemsJson = responseJson.getJSONArray("items");
Toast.makeText(ctx, ctx.getString(R.string.video_dl_error), Toast.LENGTH_SHORT).show();
}
@Override VideoFile videoFile = new VideoFile(itemsJson.getJSONObject(0));
public void a(Call call, Response response) throws IOException { downloadVideo(videoFile, ctx);
progressDialog.cancel(); } catch (JSONException e) {
e.printStackTrace();
try { Toast.makeText(ctx, ctx.getString(R.string.video_dl_error), Toast.LENGTH_SHORT).show();
JSONObject mainJson = new JSONObject(GzipDecompressor.decompressResponse(response)); }
JSONObject responseJson = mainJson.getJSONObject("response"); });
JSONArray itemsJson = responseJson.getJSONArray("items");
VideoFile videoFile = new VideoFile(itemsJson.getJSONObject(0));
downloadVideo(videoFile, ctx);
} catch (JSONException e) {
e.fillInStackTrace();
Toast.makeText(ctx, ctx.getString(R.string.video_dl_error), Toast.LENGTH_SHORT).show();
}
}
});
} }
} }
@@ -3,7 +3,6 @@ package ru.vtosters.lite.downloaders.messages;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.vk.core.network.Network;
import com.vk.core.util.ToastUtils; import com.vk.core.util.ToastUtils;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import okhttp3.Call; import okhttp3.Call;
@@ -13,12 +12,12 @@ import okhttp3.Response;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.downloaders.messages.items.MiniMsg; import ru.vtosters.lite.downloaders.messages.items.MiniMsg;
import ru.vtosters.lite.downloaders.messages.items.MiniUser; import ru.vtosters.lite.downloaders.messages.items.MiniUser;
import ru.vtosters.lite.proxy.ProxyUtils; import ru.vtosters.lite.proxy.ProxyUtils;
import ru.vtosters.lite.utils.AccountManagerUtils; import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.sponsorpost.utils.GzipDecompressor;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@@ -29,8 +28,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import static com.vk.core.network.Network.ClientType.CLIENT_API;
public class MessagesDownloader { public class MessagesDownloader {
private static final int[] VIDEO_QUALITIES = {144, 240, 360, 480, 720, 1080, 1440, 2160}; private static final int[] VIDEO_QUALITIES = {144, 240, 360, 480, 720, 1080, 1440, 2160};
@@ -107,9 +104,8 @@ public class MessagesDownloader {
AccountManagerUtils.getUserToken()); AccountManagerUtils.getUserToken());
var req = new Request.a() var req = new Request.a()
.b(url) .b(url)
.a("Accept-Encoding", "gzip")
.a(); .a();
Network.b(CLIENT_API).a(req).a(new Callback() { VtOkHttpClient.getInstance().a(req).a(new Callback() {
@Override @Override
public void a(Call call, IOException e) { public void a(Call call, IOException e) {
Log.d("MessagesDownloader", e.getMessage()); Log.d("MessagesDownloader", e.getMessage());
@@ -118,7 +114,7 @@ public class MessagesDownloader {
@Override @Override
public void a(Call call, Response response) { public void a(Call call, Response response) {
try { try {
JSONObject obj = new JSONObject(GzipDecompressor.decompressResponse(response)).getJSONObject("response"); JSONObject obj = new JSONObject(response.a().g()).getJSONObject("response");
SparseArray<MiniUser> users = new SparseArray<>(); SparseArray<MiniUser> users = new SparseArray<>();
parseUsers(users, obj.optJSONArray("profiles"), false); parseUsers(users, obj.optJSONArray("profiles"), false);
@@ -1,53 +1,48 @@
package ru.vtosters.lite.foaf; package ru.vtosters.lite.foaf;
import android.annotation.SuppressLint;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import com.vk.core.dialogs.alert.VkAlertDialog; import com.vk.core.dialogs.alert.VkAlertDialog;
import com.vk.core.network.Network;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.di.singleton.VtOkHttpClient; import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.proxy.ProxyUtils; import ru.vtosters.lite.net.Request;
import ru.vtosters.lite.proxy.api.VikaMobile;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.LifecycleUtils; import ru.vtosters.lite.utils.LifecycleUtils;
import ru.vtosters.sponsorpost.utils.GzipDecompressor;
import java.io.IOException; import java.text.ParseException;
import java.time.LocalDate; import java.text.SimpleDateFormat;
import java.time.OffsetDateTime; import java.util.Date;
import java.time.format.DateTimeFormatter; import java.util.concurrent.TimeUnit;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.Optional;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.vk.core.network.Network.ClientType.CLIENT_API; import static android.widget.Toast.LENGTH_SHORT;
import static android.widget.Toast.makeText;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.proxy.ProxyUtils.isAnyProxyEnabled;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
public class FoafBase { public class FoafBase {
private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\""); private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\"");
private static final String DELETED = "<ya:profileState>deleted</ya:profileState>";
private static final String API_VKNEXT = "https://api.vtosters.app/v1/getBypassedOnlineInfo?json=1&ids="; private static final String API_VKNEXT = "https://api.vtosters.app/v1/getBypassedOnlineInfo?json=1&ids=";
private static final OkHttpClient client = VtOkHttpClient.getInstance(); private static final OkHttpClient client = VtOkHttpClient.getInstance();
public static JSONObject getBypassedOnlineInfo(int id) throws JSONException { public static JSONObject getBypassedOnlineInfo(int id) throws JSONException {
Request request = new Request.a() var request = new okhttp3.Request.a()
.b(API_VKNEXT + id) .b(API_VKNEXT + id)
.a("Accept-Encoding", "gzip")
.a(); .a();
JSONObject dummy = new JSONObject(); String response;
var dummy = new JSONObject();
dummy.put("last_seen", 0); dummy.put("last_seen", 0);
try (Response response = client.a(request).execute()) { try {
JSONObject online_info = new JSONObject(GzipDecompressor.decompressResponse(response)).getJSONObject("response").optJSONObject(Integer.toString(id)); response = client.a(request).execute().a().g();
var online_info = new JSONObject(response).optJSONObject("response").optJSONObject(Integer.toString(id));
return online_info == null ? dummy : online_info; return online_info == null ? dummy : online_info;
} catch (Exception e) { } catch (Exception e) {
Log.e("GetBypassedOnlineInfo", e.getMessage()); Log.e("GetBypassedOnlineInfo", e.getMessage());
@@ -56,15 +51,17 @@ public class FoafBase {
} }
public static JSONObject getBypassedOnlineInfo(String ids) { public static JSONObject getBypassedOnlineInfo(String ids) {
Request request = new Request.a() var request = new okhttp3.Request.a()
.b(API_VKNEXT + ids) .b(API_VKNEXT + ids)
.a("Accept-Encoding", "gzip")
.a(); .a();
JSONObject dummy = new JSONObject(); String response;
try (Response response = client.a(request).execute()) { var dummy = new JSONObject();
JSONObject online_info = new JSONObject(GzipDecompressor.decompressResponse(response)).getJSONObject("response").optJSONObject("response");
try {
response = client.a(request).execute().a().g();
var online_info = new JSONObject(response).optJSONObject("response");
return online_info == null ? dummy : online_info; return online_info == null ? dummy : online_info;
} catch (Exception e) { } catch (Exception e) {
Log.e("GetBypassedOnlineInfo1", e.getMessage()); Log.e("GetBypassedOnlineInfo1", e.getMessage());
@@ -72,9 +69,19 @@ public class FoafBase {
} }
} }
@SuppressLint("DefaultLocale")
private static String getLink(int i) { private static String getLink(int i) {
return ProxyUtils.isAnyProxyEnabled() ? String.format("https://%s/_/vk.com/foaf.php?id=%d", ProxyUtils.getApi(), i) : String.format("https://vk.com/foaf.php?id=%d", i); String str;
StringBuilder sb;
if (isAnyProxyEnabled()) {
sb = new StringBuilder();
str = "https://" + getApi() + "/_/vk.com/foaf.php?id=";
} else {
sb = new StringBuilder();
str = "https://vk.com/foaf.php?id=";
}
sb.append(str);
sb.append(i);
return sb.toString();
} }
public static void loadAndShow(Context context, int i) { public static void loadAndShow(Context context, int i) {
@@ -83,71 +90,49 @@ public class FoafBase {
progressDialog.setCancelable(false); progressDialog.setCancelable(false);
progressDialog.show(); progressDialog.show();
Request request = new Request.a() Request.RequestCallback callback = str -> FoafBase.lambdaLoadAndShow(progressDialog, context, i, str);
.b(getLink(i)) Request.makeRequest(getLink(i), callback);
.a("Accept-Encoding", "gzip") }
.a();
try (Response response = Network.b(CLIENT_API).a(request).execute()) { static void lambdaLoadAndShow(ProgressDialog progressDialog, Context context, int i, String str) {
LifecycleUtils.getCurrentActivity().runOnUiThread(() -> { try {
try { progressDialog.cancel();
showFoafInfo(progressDialog, context, i, GzipDecompressor.decompressResponse(response)); Matcher matcher = FOAF_REGEX.matcher(str);
} catch (IOException e) { matcher.find();
throw new RuntimeException(e);
} String m = matcher.group(1);
});
if (m == null) {
LifecycleUtils.getCurrentActivity().runOnUiThread(() -> makeText(getGlobalContext(), context.getString(R.string.foaferr), LENGTH_SHORT).show());
return;
}
String normalHumanDate = getNormalHumanDate(m);
LifecycleUtils.getCurrentActivity().runOnUiThread(() -> new VkAlertDialog.Builder(context)
.setTitle(R.string.addinf)
.setMessage(context.getString(R.string.foafid) +
" " + i + context.getString(R.string.foafregdate)
+ " " + normalHumanDate + context.getString(R.string.foafdate)
+ " " + daysPassedFromFoafDate(normalHumanDate))
.setPositiveButton(android.R.string.ok, null)
.show());
} catch (Exception e) { } catch (Exception e) {
Log.e("FoafBase", e.getMessage()); LifecycleUtils.getCurrentActivity().runOnUiThread(() -> makeText(getGlobalContext(), context.getString(R.string.foaferr), LENGTH_SHORT).show());
} }
} }
private static void showFoafInfo(ProgressDialog progressDialog, Context context, int i, String str) {
progressDialog.cancel();
Optional<String> foafDate = findPattern(str, FOAF_REGEX);
Log.e("FoafBase", str);
if (foafDate.isPresent()) {
String normalHumanDate = getNormalHumanDate(foafDate.get());
long daysPassed = daysPassedFromFoafDate(normalHumanDate);
showFoafDialog(context, i, normalHumanDate, daysPassed);
} else if (str.contains(DELETED)) {
AndroidUtils.sendToast("Профиль удален или не существует (аккаунт VK Мессенджера)");
} else {
AndroidUtils.sendToast(context.getString(R.string.foaferr));
}
}
private static Optional<String> findPattern(String str, Pattern pattern) {
Matcher matcher = pattern.matcher(str);
if (matcher.find() && matcher.groupCount() != 0) {
return Optional.ofNullable(matcher.group(1));
} else {
return Optional.empty();
}
}
@SuppressLint("DefaultLocale")
private static void showFoafDialog(Context context, int i, String normalHumanDate, long daysPassed) {
String message = String.format("%s %d%s %s%s %d", context.getString(R.string.foafid), i, context.getString(R.string.foafregdate), normalHumanDate, context.getString(R.string.foafdate), daysPassed);
new VkAlertDialog.Builder(context)
.setTitle(R.string.addinf)
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.show();
}
private static long daysPassedFromFoafDate(String str) { private static long daysPassedFromFoafDate(String str) {
try { try {
LocalDate foafDate = LocalDate.parse(str.split(" ")[1]); Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(str.split(" ")[1]);
return ChronoUnit.DAYS.between(foafDate, LocalDate.now()); return TimeUnit.DAYS.convert(new Date().getTime() - parse.getTime(), TimeUnit.MILLISECONDS);
} catch (DateTimeParseException e) { } catch (ParseException e) {
return -1; return -1;
} }
} }
private static String getNormalHumanDate(String str) { private static String getNormalHumanDate(String str) {
OffsetDateTime dateTime = OffsetDateTime.parse(str); String[] split = str.split("T");
return dateTime.format(DateTimeFormatter.ofPattern("HH:mm:ss yyyy-MM-dd")); return split[1].split("\\+")[0] + " " + split[0];
} }
} }
@@ -6,14 +6,11 @@ import com.vk.dto.music.MusicTrack;
import com.vtosters.lite.R; import com.vtosters.lite.R;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.di.singleton.VtOkHttpClient; import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.music.downloader.M3UDownloader;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.sponsorpost.utils.GzipDecompressor;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
@@ -24,10 +21,10 @@ public class Genius {
private static final OkHttpClient client = VtOkHttpClient.getInstance(); private static final OkHttpClient client = VtOkHttpClient.getInstance();
public static String getTextMusic(MusicTrack musictrack) { public static String getTextMusic(MusicTrack musictrack) {
String uid = musictrack.y1(); var uid = musictrack.y1();
String artist = removeExtras(M3UDownloader.getArtists(musictrack)); var artist = musictrack.C;
String title = removeExtras(musictrack.f); var title = musictrack.f;
int duration = musictrack.h; var duration = musictrack.h;
if (TextUtils.isEmpty(uid) || TextUtils.isEmpty(artist) || TextUtils.isEmpty(title) || duration == 0) { if (TextUtils.isEmpty(uid) || TextUtils.isEmpty(artist) || TextUtils.isEmpty(title) || duration == 0) {
Log.d("Genius", "grabTrackInfo: " + "Empty track, info: " + artist + " - " + title + " - " + duration + " - " + uid); Log.d("Genius", "grabTrackInfo: " + "Empty track, info: " + artist + " - " + title + " - " + duration + " - " + uid);
@@ -44,18 +41,17 @@ public class Genius {
} }
Request request = new Request.a() Request request = new Request.a()
.b(String.format("%s/search/songs?q=%s&from_background=0&page=1", URL, URLEncoder.encode(artist + " " + track))) .b(URL + "/search/multi?q=" + URLEncoder.encode(artist + " " + track) + "&from_background=0")
.a("User-Agent", "Genius/5.21.3 (Android; Android 13; Google Pixel 4 XL)") .a("User-Agent", "Genius/5.14.0 (Android; Android 13; Google Pixel 4 XL)")
.a("Authorization", KEY) .a("Authorization", KEY)
.a("x-genius-app-background-request", "0") .a("x-genius-app-background-request", "0")
.a("x-genius-logged-out", "true") .a("x-genius-logged-out", "true")
.a("host", "api.genius.com") .a("host", "api.genius.com")
.a("Content-Type", "application/x-www-form-urlencoded") .a("Content-Type", "application/x-www-form-urlencoded")
.a("Accept-Encoding", "gzip")
.b() .b()
.a(); .a();
try (Response resp = client.a(request).execute()) { try {
String payload = GzipDecompressor.decompressResponse(resp); String payload = client.a(request).execute().a().g();
JSONArray sections = new JSONObject(payload).getJSONObject("response").getJSONArray("sections"); JSONArray sections = new JSONObject(payload).getJSONObject("response").getJSONArray("sections");
for (int i = 0; i < sections.length(); i++) { for (int i = 0; i < sections.length(); i++) {
@@ -74,33 +70,26 @@ public class Genius {
} }
} }
} }
return AndroidUtils.getString("error_no_text"); return AndroidUtils.getString("error_no_text");
} catch (JSONException | IOException e) { } catch (JSONException | IOException e) {
return AndroidUtils.getString("error_no_text") + "\n\n" + AndroidUtils.getString(R.string.error) + ": \n" + e.getMessage(); return AndroidUtils.getString("error_no_text") + "\n\n" + AndroidUtils.getString(R.string.error) + ": \n" + e.getMessage();
} }
} }
public static String removeExtras(String title) {
return title
.replaceAll("[\\[\\]]", "(")
.replaceAll("[()]", "")
.trim();
}
private static String getText(String track) { private static String getText(String track) {
Request request = new Request.a() Request request = new Request.a()
.b(String.format("%s%s?text_format=plain", URL, track)) .b(URL + track + "?text_format=plain")
.a("User-Agent", "Genius/5.21.3 (Android; Android 13; Google Pixel 4 XL)") .a("User-Agent", "Genius/5.14.0 (Android; Android 13; Google Pixel 4 XL)")
.a("Authorization", KEY) .a("Authorization", KEY)
.a("x-genius-app-background-request", "0") .a("x-genius-app-background-request", "0")
.a("x-genius-logged-out", "true") .a("x-genius-logged-out", "true")
.a("host", "api.genius.com") .a("host", "api.genius.com")
.a("Content-Type", "application/x-www-form-urlencoded") .a("Content-Type", "application/x-www-form-urlencoded")
.a("Accept-Encoding", "gzip")
.b() .b()
.a(); .a();
try (Response resp = client.a(request).execute()) { try {
JSONObject payload = new JSONObject(GzipDecompressor.decompressResponse(resp)); JSONObject payload = new JSONObject(client.a(request).execute().a().g());
if (!payload.has("response")) { if (!payload.has("response")) {
return AndroidUtils.getString("error_no_text"); return AndroidUtils.getString("error_no_text");
@@ -111,4 +100,4 @@ public class Genius {
return AndroidUtils.getString("error_no_text") + "\n\n" + AndroidUtils.getString(R.string.error) + ": \n" + e.getMessage(); return AndroidUtils.getString("error_no_text") + "\n\n" + AndroidUtils.getString(R.string.error) + ": \n" + e.getMessage();
} }
} }
} }
@@ -14,7 +14,6 @@ import ru.vtosters.hooks.other.Preferences;
import ru.vtosters.lite.di.singleton.VtOkHttpClient; import ru.vtosters.lite.di.singleton.VtOkHttpClient;
import ru.vtosters.lite.downloaders.AudioDownloader; import ru.vtosters.lite.downloaders.AudioDownloader;
import ru.vtosters.lite.music.cache.MusicCacheImpl; import ru.vtosters.lite.music.cache.MusicCacheImpl;
import ru.vtosters.lite.music.downloader.M3UDownloader;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import java.io.IOException; import java.io.IOException;
@@ -33,7 +32,7 @@ public class LastFMScrobbler {
public static void grabMusicTrack(MusicTrack musictrack) { public static void grabMusicTrack(MusicTrack musictrack) {
var uid = musictrack.y1(); var uid = musictrack.y1();
var artist = M3UDownloader.getArtists(musictrack); var artist = musictrack.C;
var title = musictrack.f; var title = musictrack.f;
var duration = musictrack.h; var duration = musictrack.h;
var track_id = musictrack.d; var track_id = musictrack.d;
@@ -84,12 +83,12 @@ public class LastFMScrobbler {
params.put("sk", getSessionKey()); params.put("sk", getSessionKey());
params.put("artist[0]", artist); params.put("artist[0]", artist);
params.put("track[0]", title); params.put("track[0]", title);
if (!TextUtils.isEmpty(album)) { if (!TextUtils.isEmpty(album))
params.put("album[0]", album); params.put("album[0]", album);
}
params.put("duration[0]", String.valueOf(duration)); params.put("duration[0]", String.valueOf(duration));
params.put("timestamp[0]", String.valueOf(System.currentTimeMillis() / 1000)); params.put("timestamp[0]", String.valueOf(System.currentTimeMillis() / 1000));
fetch(params, new Callback() { fetch(params, new Callback() {
@Override @Override
public void a(Call call, IOException e) { public void a(Call call, IOException e) {
@@ -151,9 +150,8 @@ public class LastFMScrobbler {
params.put("format", "json"); params.put("format", "json");
var reqBodyBuilder = new FormBody.a(StandardCharsets.UTF_8); var reqBodyBuilder = new FormBody.a(StandardCharsets.UTF_8);
for (var entry : params.entrySet()) { for (var entry : params.entrySet())
reqBodyBuilder.a(entry.getKey(), entry.getValue()); reqBodyBuilder.a(entry.getKey(), entry.getValue());
}
var req = new Request.a() var req = new Request.a()
.b(URL) .b(URL)
@@ -166,7 +164,6 @@ public class LastFMScrobbler {
public static void fetchSession(JSONObject json) throws JSONException { public static void fetchSession(JSONObject json) throws JSONException {
if (!json.has("session")) { if (!json.has("session")) {
Log.d("Scrobbler", "Auth failed - no session"); Log.d("Scrobbler", "Auth failed - no session");
AndroidUtils.sendToast("Ошибка входа");
return; return;
} }
@@ -180,8 +177,6 @@ public class LastFMScrobbler {
.putBoolean("lastfm_enabled", true) .putBoolean("lastfm_enabled", true)
.apply(); .apply();
AndroidUtils.sendToast("Успешный вход");
Log.d("Scrobbler", "Auth success as " + name + ", key " + key); Log.d("Scrobbler", "Auth success as " + name + ", key " + key);
} }
@@ -6,7 +6,6 @@ import bruhcollective.itaysonlab.libvkx.ILibVkxService;
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient; import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
import bruhcollective.itaysonlab.libvkx.client.LibVKXClientImpl; import bruhcollective.itaysonlab.libvkx.client.LibVKXClientImpl;
import com.vk.dto.music.MusicTrack; import com.vk.dto.music.MusicTrack;
import ru.vtosters.lite.music.downloader.M3UDownloader;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.music.MusicCacheStorageUtils; import ru.vtosters.lite.utils.music.MusicCacheStorageUtils;
@@ -20,7 +19,7 @@ public class MusicCacheImpl {
track.I != null ? track.I.getId() + "" : "-1", track.I != null ? track.I.getId() + "" : "-1",
track.f, track.f,
!TextUtils.isEmpty(track.g) ? track.g : "", !TextUtils.isEmpty(track.g) ? track.g : "",
M3UDownloader.getArtists(track), track.C,
track.I != null ? track.I.getTitle() : "", track.I != null ? track.I.getTitle() : "",
track.K, track.K,
track.h, track.h,
@@ -13,7 +13,6 @@ import com.vk.dto.music.AlbumLink;
import com.vk.dto.music.MusicTrack; import com.vk.dto.music.MusicTrack;
import com.vk.dto.music.Thumb; import com.vk.dto.music.Thumb;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.music.downloader.M3UDownloader;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.music.MusicCacheStorageUtils; import ru.vtosters.lite.utils.music.MusicCacheStorageUtils;
@@ -96,7 +95,6 @@ public class MusicCacheDb extends SQLiteOpenHelper implements AutoCloseable { //
} }
return null; return null;
} }
@Override @Override
public void onCreate(SQLiteDatabase db) { public void onCreate(SQLiteDatabase db) {
db.execSQL(Constants.CREATE_QUERY); db.execSQL(Constants.CREATE_QUERY);
@@ -106,18 +104,18 @@ public class MusicCacheDb extends SQLiteOpenHelper implements AutoCloseable { //
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (oldVersion < newVersion) { if (oldVersion < newVersion) {
List<MusicTrack> tracks = getTracksWithCursor(db.query(Constants.TABLE_NAME, null, null, null, null, null, null)); List<MusicTrack> tracks = getTracksWithCursor(db.query(Constants.TABLE_NAME, null, null, null, null, null, null));
db.execSQL(Constants.DROP_QUERY); db.execSQL(Constants.DROP_QUERY);
onCreate(db); onCreate(db);
for (MusicTrack track : tracks) { for (MusicTrack track : tracks) {
ContentValues vals = new ContentValues(); ContentValues vals = new ContentValues();
vals.put(Constants.COLUMN_TRACK_ID, track.y1()); vals.put(Constants.COLUMN_TRACK_ID, track.y1());
vals.put(Constants.COLUMN_ALBUM_ID, track.I != null ? track.I.getId() + "" : "-1"); vals.put(Constants.COLUMN_ALBUM_ID, track.I != null ? track.I.getId() + "" : "-1");
vals.put(Constants.COLUMN_TITLE, track.f); vals.put(Constants.COLUMN_TITLE, track.f);
vals.put(Constants.COLUMN_SUBTITLE, track.g); vals.put(Constants.COLUMN_SUBTITLE, track.g);
vals.put(Constants.COLUMN_ARTIST, M3UDownloader.getArtists(track)); vals.put(Constants.COLUMN_ARTIST, track.C);
vals.put(Constants.COLUMN_ALBUM_TITLE, track.I != null ? track.I.getTitle() : ""); vals.put(Constants.COLUMN_ALBUM_TITLE, track.I != null ? track.I.getTitle() : "");
vals.put(Constants.COLUMN_EXPLICIT, Boolean.compare(track.K, true)); vals.put(Constants.COLUMN_EXPLICIT, Boolean.compare(track.K, true));
vals.put(Constants.COLUMN_DURATION, track.h); vals.put(Constants.COLUMN_DURATION, track.h);
@@ -138,9 +136,9 @@ public class MusicCacheDb extends SQLiteOpenHelper implements AutoCloseable { //
vals.put(Constants.COLUMN_EXPLICIT, Boolean.compare(explicit, true)); vals.put(Constants.COLUMN_EXPLICIT, Boolean.compare(explicit, true));
vals.put(Constants.COLUMN_DURATION, duration); vals.put(Constants.COLUMN_DURATION, duration);
vals.put(Constants.COLUMN_HAS_ARTWORK, Boolean.compare(hasArtwork, true)); vals.put(Constants.COLUMN_HAS_ARTWORK, Boolean.compare(hasArtwork, true));
long row = getWritableDatabase().insert(Constants.TABLE_NAME, null, vals); long row = getWritableDatabase().insert(Constants.TABLE_NAME, null, vals);
if (AndroidUtils.isDebuggable()) Log.d("MusicCacheDb", "addTrack(): " + row); if (AndroidUtils.isDebuggable()) Log.d("MusicCacheDb", "addTrack(): " + row);
} }
@@ -7,7 +7,6 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.music.cache.MusicCacheImpl; import ru.vtosters.lite.music.cache.MusicCacheImpl;
import ru.vtosters.lite.music.downloader.M3UDownloader;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.music.MusicCacheStorageUtils; import ru.vtosters.lite.utils.music.MusicCacheStorageUtils;
@@ -34,7 +33,7 @@ public class PlaylistHelper {
return createAlbum( return createAlbum(
thumb != null ? thumb.h(600) : "", thumb != null ? thumb.h(600) : "",
albumLink.getTitle(), albumLink.getTitle(),
M3UDownloader.getArtists(track), track.C,
track.y1(), track.y1(),
albumLink.getId() albumLink.getId()
); );
@@ -76,7 +75,7 @@ public class PlaylistHelper {
list.add(createAlbum( list.add(createAlbum(
thumb != null ? thumb.h(600) : "", thumb != null ? thumb.h(600) : "",
albumLink.getTitle(), albumLink.getTitle(),
M3UDownloader.getArtists(track), track.C,
track.y1(), track.y1(),
albumLink.getId() albumLink.getId()
)); ));
@@ -6,13 +6,12 @@ import com.vk.dto.music.MusicTrack;
import com.vk.dto.music.Playlist; import com.vk.dto.music.Playlist;
import java8.util.concurrent.CompletableFuture; import java8.util.concurrent.CompletableFuture;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.utils.AccountManagerUtils; import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.sponsorpost.utils.GzipDecompressor;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@@ -20,7 +19,6 @@ import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.vk.core.network.Network.ClientType.CLIENT_API;
import static ru.vtosters.hooks.DateHook.getLocale; import static ru.vtosters.hooks.DateHook.getLocale;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi; import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
@@ -52,17 +50,17 @@ public class PlaylistConverter {
var request = new Request.a() var request = new Request.a()
.b(requestUrl) .b(requestUrl)
.a("Accept-Encoding", "gzip")
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a(); .a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a();
try { try {
var response = CompletableFuture.supplyAsync(() -> { var response = CompletableFuture.supplyAsync(() -> {
try (Response resp = Network.b(CLIENT_API).a(request).execute()) { try {
return GzipDecompressor.decompressResponse(resp); return new OkHttpClient().a(request).execute().a().g();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
}).get(); }
).get();
var jsonObj = new JSONObject(response); var jsonObj = new JSONObject(response);
if (!jsonObj.has("response")) if (!jsonObj.has("response"))
return null; return null;
@@ -8,6 +8,7 @@ import ru.vtosters.lite.music.downloader.M3UDownloader;
import ru.vtosters.lite.utils.IOUtils; import ru.vtosters.lite.utils.IOUtils;
import java.io.File; import java.io.File;
import java.text.Normalizer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class FFMpeg { public class FFMpeg {
@@ -32,11 +33,9 @@ public class FFMpeg {
} }
private static String setMetadata(MusicTrack track) { private static String setMetadata(MusicTrack track) {
return Preferences.getBoolValue("setMetaData", true) ? " -metadata title=\"" + IOUtils.getValidFileName(M3UDownloader.getTitle(track)) + '"' return Preferences.getBoolValue("setMetaData", false) ? " -metadata title=\"" + IOUtils.getValidFileName(M3UDownloader.getTitle(track)) + '"'
+ (track.L == null || track.I == null + " -metadata artist=\"" + normalizeMetadata(track.L.stream().map(Artist::w1).collect(Collectors.joining(", "))) + '"'
? " -metadata artist=\"" + normalizeMetadata(track.C) + '"' + " -metadata album=\"" + normalizeMetadata(track.I.getTitle()) + '"' : "";
: " -metadata artist=\"" + normalizeMetadata(track.L.stream().map(Artist::w1).collect(Collectors.joining(", "))) + '"'
+ " -metadata album=\"" + normalizeMetadata(track.I.getTitle()) + '"') : "";
} }
private static String normalizeMetadata(String in) { private static String normalizeMetadata(String in) {
@@ -6,12 +6,11 @@ import com.vk.core.util.DeviceIdProvider;
import com.vk.dto.music.MusicTrack; import com.vk.dto.music.MusicTrack;
import java8.util.concurrent.CompletableFuture; import java8.util.concurrent.CompletableFuture;
import okhttp3.Headers; import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import ru.vtosters.lite.utils.AndroidUtils; import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.sponsorpost.utils.GzipDecompressor;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@@ -19,7 +18,6 @@ import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.vk.core.network.Network.ClientType.CLIENT_API;
import static ru.vtosters.hooks.DateHook.getLocale; import static ru.vtosters.hooks.DateHook.getLocale;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi; import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId; import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
@@ -46,13 +44,12 @@ public class AudioGet {
var request = new Request.a() var request = new Request.a()
.b(requestUrl) .b(requestUrl)
.a("Accept-Encoding", "gzip")
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a(); .a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8")).a();
try { try {
var response = CompletableFuture.supplyAsync(() -> { var response = CompletableFuture.supplyAsync(() -> {
try (Response resp = Network.b(CLIENT_API).a(request).execute()) { try {
return GzipDecompressor.decompressResponse(resp); return new OkHttpClient().a(request).execute().a().g();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -6,7 +6,6 @@ import android.util.Log;
import com.google.android.exoplayer2.source.hls.playlist.e; import com.google.android.exoplayer2.source.hls.playlist.e;
import com.google.android.exoplayer2.source.hls.playlist.f; import com.google.android.exoplayer2.source.hls.playlist.f;
import com.google.android.exoplayer2.source.hls.playlist.f.a; import com.google.android.exoplayer2.source.hls.playlist.f.a;
import com.vk.dto.music.Artist;
import com.vk.dto.music.MusicTrack; import com.vk.dto.music.MusicTrack;
import java8.util.concurrent.CompletableFuture; import java8.util.concurrent.CompletableFuture;
import java8.util.concurrent.CompletionException; import java8.util.concurrent.CompletionException;
@@ -27,7 +26,6 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class M3UDownloader public class M3UDownloader
implements ITrackDownloader { implements ITrackDownloader {
@@ -138,7 +136,7 @@ public class M3UDownloader
} }
public static String getTitle(MusicTrack track) { public static String getTitle(MusicTrack track) {
return track.f + (!TextUtils.isEmpty(track.g) ? +'(' + track.g + ')' : ""); return track.f + (!TextUtils.isEmpty(track.g) ? + '(' + track.g + ')' : "");
} }
static File getTsesDir(MusicTrack track) { static File getTsesDir(MusicTrack track) {
@@ -153,7 +151,7 @@ public class M3UDownloader
} }
static File getResultMp3File(File outDir, boolean cache, MusicTrack track) { static File getResultMp3File(File outDir, boolean cache, MusicTrack track) {
return new File(outDir, IOUtils.getValidFileName((cache ? "track" : getArtists(track) + " - " + getTitle(track)) + ".mp3")); return new File(outDir, IOUtils.getValidFileName((cache ? "track" : track.C + " - " + getTitle(track)) + ".mp3"));
} }
@Override @Override
@@ -180,14 +178,4 @@ public class M3UDownloader
private static class Holder { private static class Holder {
private static final M3UDownloader INSTANCE = new M3UDownloader(); private static final M3UDownloader INSTANCE = new M3UDownloader();
} }
}
public static String getArtists(MusicTrack track) {
return (track.L == null || track.I == null
? normalizeMetadata(track.C)
: normalizeMetadata(track.L.stream().map(Artist::w1).collect(Collectors.joining(", "))));
}
private static String normalizeMetadata(String in) {
return in.replaceAll("[\\\\/:*?\"<>|]", "");
}
}
@@ -1,6 +1,7 @@
package ru.vtosters.lite.net; package ru.vtosters.lite.net;
import android.util.Base64; import android.util.Base64;
import android.util.Log;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;

Some files were not shown because too many files have changed in this diff Show More