Compare commits

...
Author SHA1 Message Date
aliveoutside 63f4ed3885 fix AudioDownloader 2022-09-06 14:00:35 +03:00
aliveoutside ad90c522ac move image downloader to IOExecutor 2022-09-06 13:57:24 +03:00
aliveoutside 374b221f0d fix #627
also fix wrong mime-types for downloaded files
2022-09-06 13:39:39 +03:00
Erik Kiznov 99adb95816 download fix 2022-09-06 12:38:00 +05:00
gdlbo e96a3b304f Update AdBlockHook.java 2022-09-04 16:39:29 +03:00
gdlbo cf4855bdd1 fixed newsfeed issues 2022-09-04 16:32:22 +03:00
gdlbo 8c8c574a4e Update OnlineFormatterHook.java 2022-09-04 14:55:23 +03:00
gdlbo 653afd69b6 Fix null dialog.getId() 2022-09-04 13:44:30 +03:00
aliveoutside 0660c9664d fix #713 2022-09-04 11:56:37 +03:00
aliveoutside a72ef8570a simplify post != null in AdBlockHook 2022-09-04 11:23:42 +03:00
gdlbo 4ce55a22f9 removed custom folders path feature 2022-09-03 23:37:00 +03:00
gdlbo 910c991adb Update CacheUtils.java 2022-09-03 23:23:56 +03:00
gdlbo b746594b1d some adblock refactoring 2022-09-03 23:18:12 +03:00
Erik Kiznov 0698985623 discover adblock logging fix 2022-09-02 21:45:04 +05:00
gdlbo 859d9dd2b8 discoverAdBlock + try catch hack
trying to find bug
2022-09-02 19:03:21 +03:00
gdlbo 341d1b6e70 Update JsonInjectors.java 2022-09-02 17:40:50 +03:00
gdlbo cbdf33f253 discover adblock 2022-09-02 17:40:04 +03:00
Erik Kiznov 536dd9ea51 i hate vk api error codes
v=5.187 -> "error_msg": "Access token has expired"

v=5.186 -> "response": "..."
2022-09-02 00:11:49 +05:00
gdlbo 624b4d4724 Update RequestDumper.java 2022-09-01 21:45:27 +03:00
k1zn 0e604c81c7 params to map<string, string> 2022-09-01 23:42:21 +05:00
gdlbo 3175fe3af2 Update WallGetById.smali 2022-09-01 21:40:47 +03:00
gdlbo 9f37390d59 removed legacy ad remover 2022-09-01 21:26:39 +03:00
gdlbo 2dfcc9096f Revert "speedup chats opening with wp"
This reverts commit 00d8e60d1e.
2022-09-01 21:03:09 +03:00
gdlbo 00d8e60d1e speedup chats opening with wp 2022-09-01 21:00:08 +03:00
Erik Kiznov 010a71ecca remove file remove 2022-09-01 22:40:07 +05:00
gdlbo e82547ddbb deleted 2/3 compressing shit 2022-09-01 20:37:07 +03:00
gdlbo 484b0f5850 fix deleting 2022-09-01 19:55:50 +03:00
gdlbo fd9837aee4 some shitcode for saving wp + true compressing + moved to webp format of file 2022-09-01 19:54:49 +03:00
aliveoutside 255e5e62db fix discover tab #481 2022-09-01 15:08:28 +03:00
gdlbo 4da1ec3b76 some theme fixes 2022-08-31 13:48:45 +03:00
gdlbo 296b717891 Update ServerDialog.java 2022-08-30 13:51:33 +03:00
gdlbo e709f6ac68 some fixes
force updates + setup filters fixes
2022-08-30 13:45:54 +03:00
aliveoutside e231e4a2b4 Revert "Update Preferences.java"
This reverts commit 2e8f168d9f.
2022-08-30 12:07:43 +03:00
Erik Kiznov 2e8f168d9f Update Preferences.java 2022-08-30 13:49:30 +05:00
Erik Kiznov e75eb4caa5 remove adblock from create new post
пост все равно создается, а фрагмент создания новой записи не закрывается, так что удалим отсюда фильтрацию
2022-08-30 01:02:14 +05:00
Erik Kiznov 58905bbc59 fix default filters value
все фильтры из mFilters при первом запуске VTLite работали и удаляли посты, даже если фильтры не были включены
2022-08-30 00:45:51 +05:00
k1zn ae9d89c6c6 update README.md to v0.4.12-beta 2022-08-28 21:20:34 +05:00
55 changed files with 890 additions and 1114 deletions
+8 -4
View File
@@ -55,6 +55,7 @@
* Лента
* Блокировка рекламы в ленте
* Блокировка постов через фильтры
* Возможность добавлять в вайтлист фильтров группы, чтобы в них не удалялись посты
* Возможность отключить рекомендации от ВК
* Редактор докбара
* Редактор элементов Superapp
@@ -69,26 +70,28 @@
* Возможность указывать папку для загрузки фото/видео/музыки/всего
* Интеграция с <a href="https://www.last.fm/">LAST.FM</a> (а также возможность скробблинга)
* Новый раздел музыки
* Возможность скачивать видео
* Возможность скачивать видео, очищать историю просмотра видео
* Возможность найти фотографию через поисковые системы
* Интеграция с <a href="https://vkx.app/">VK X</a>
* Сообщения
* Обои в сообщениях
* ~Обои в сообщениях~ (временно недоступно из-за проблем с производительностью)
* Возможность выключения кнопки записи голосовых сообщений
* Возможность скрыть блок рекомендаций в сообщениях
* Режим **VK Me**
* Возможность вернуть вкладку уведомлений
* Возможность вернуть вкладку уведомлений для режима VK Me
* Встроенный переводчик текста для сообщений
* Возможность выбрать язык перевода
* Автоматический перевод ваших сообщений на выбранный язык
* Автоматический перевод ваших сообщений на выбранный язык
* Альтернативный дизайн эмодзи меню
* Возможность использовать системные эмодзи
* Возможнсть использовать Enter с аппаратной клавиатуры
* Активность
* Возможность видеть удаленные сообщения
* Функционал, позволяющий оставаться в «оффлайне» (принудительный оффлайн/не отправлять статус онлайна и т.п.)
* Нечиталка/неписалка для ЛС/бесед/ботов/групп
* Возможность отключить информацию о том, что вы просмотрели историю/прослушали голосовое сообщение
* Возможность видеть онлайн пользователей, если у вас скрыт онлайн через VK Messenger
* Возможность сохранять настройки бесшумных сообщений/сообщений-бомбочек
* Отключить уведомление о том, что вы сделали скриншот в беседе
* Отключение редиректа через away.php
* Отключение отправки метрики
@@ -115,6 +118,7 @@
* Возможность скрыть блок рекомендаций друзей в разделе «Друзья»
* Возможность скрыть подписи в настройках
* Прокси
* Поддержка сторонних прокси, таких как: Zaborona, VikaMobile, рандомные прокси и прочие
* Возможность использовать **HTTP/HTTPS/SOCKS** прокси, менять домены **API/OAuth/Static**
* Другое
* Очистка кеша приложения (**всё/стикеры/изображения/видео/сообщения/WebView**)
@@ -1,10 +1,5 @@
package com.vk.core.util;
import static ru.vtosters.lite.utils.Preferences.getDownloadsDir;
import static ru.vtosters.lite.utils.Preferences.getMusicDir;
import static ru.vtosters.lite.utils.Preferences.getPhotosDir;
import static ru.vtosters.lite.utils.Preferences.getVideosDir;
import android.annotation.SuppressLint;
import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
@@ -13,7 +8,9 @@ import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Log;
import com.facebook.common.i.MediaUtils;
import com.facebook.x.g.EncodedImage;
@@ -24,6 +21,8 @@ import com.vk.metrics.eventtracking.VkTracker;
import com.vtosters.lite.R;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.HashSet;
@@ -51,52 +50,61 @@ public class DownloadUtils {
}
}
private static void b(final Context context, String str, String str2, boolean z) {
if (TextUtils.isEmpty(str2)) {
private static void b(final Context context, String str, String uri, boolean z) {
if (TextUtils.isEmpty(uri)) {
return;
}
String file = a(str, str2);
File b2;
boolean pic = false;
boolean c2 = MediaUtils.c(MediaUtils.b(str2));
String fileName = a(str, uri);
File file;
if (file.endsWith(".jpg") || file.endsWith(".png") || file.endsWith(".jpeg")) {
b2 = new File(getPhotosDir(), file);
pic = true;
} else if (file.endsWith(".mp3") || file.endsWith(".wav") || file.endsWith(".ogg") || file.endsWith(".aac") || file.endsWith(".flac") || file.endsWith(".m4a")) {
b2 = new File(getMusicDir(), file);
} else if (file.endsWith(".mp4") || file.endsWith(".mkv") || file.endsWith(".avi") || file.endsWith(".flv") || file.endsWith(".wmv") || file.endsWith(".mov") || file.endsWith(".3gp")) {
b2 = new File(getVideosDir(), file);
Log.v("DownloadUtils", "download: filename = " + fileName + " | str = " + str + "| str2 = " + uri);
if (fileName.endsWith(".jpg") || fileName.endsWith(".png") || fileName.endsWith(".jpeg")) {
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath(), fileName);
} else if (fileName.endsWith(".mp3") || fileName.endsWith(".wav") || fileName.endsWith(".ogg") || fileName.endsWith(".aac") || fileName.endsWith(".flac") || fileName.endsWith(".m4a")) {
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath(), fileName);
} else if (fileName.endsWith(".mp4") || fileName.endsWith(".mkv") || fileName.endsWith(".avi") || fileName.endsWith(".flv") || fileName.endsWith(".wmv") || fileName.endsWith(".mov") || fileName.endsWith(".3gp")) {
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath(), fileName);
} else {
b2 = new File(getDownloadsDir(), file);
file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(), fileName);
}
if (c2) {
EncodedImage c3 = VKImageLoader.c(Uri.parse(str2));
final InputStream h = c3 == null ? null : c3.h();
boolean isImage = MediaUtils.c(FileUtils.f(file));
if (isImage) {
EncodedImage encodedImage = VKImageLoader.c(Uri.parse(uri));
final InputStream h = encodedImage == null ? null : encodedImage.h();
if (h != null) {
try {
if (b2.getParentFile() != null) {
b2.createNewFile();
if (file.getParentFile() != null) {
file.createNewFile();
}
if (b2.exists()) {
VkExecutors.x.a().execute(() -> ToastUtils.a(context.getString(R.string.file_saved, b2.getAbsoluteFile())));
if (file.exists()) {
VkExecutors.x.e().execute(() -> {
try {
FileUtils.b.a(h, new FileOutputStream(file), h.available(), null);
ToastUtils.a(context.getString(R.string.file_saved, file.getAbsoluteFile()));
} catch (IOException e) {
ToastUtils.a(context.getString(R.string.error) + " [" + e.getMessage() + "]");
e.printStackTrace();
}
});
}
} catch (Exception e2) {
L.a(e2);
}
CameraUtils.a(context, b2, null);
CameraUtils.a(context, file, null);
return;
}
}
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str2));
request.setDestinationUri(Uri.fromFile(b2));
request.setMimeType(FileUtils.f(new File(str)));
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(uri));
var mimeType = FileUtils.f(file);
request.setDestinationUri(Uri.fromFile(file));
request.setMimeType(mimeType);
request.setNotificationVisibility(1);
request.allowScanningByMediaScanner();
request.setTitle(str);
@@ -106,9 +114,6 @@ public class DownloadUtils {
}
try {
long enqueue = a2.enqueue(request);
if (pic) {
CameraUtils.a(context, b2, null);
}
if (!z) {
return;
}
@@ -188,10 +193,12 @@ public class DownloadUtils {
}
Intent intent = new Intent("android.intent.action.VIEW");
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
String f2 = FileUtils.f(file);
if (!TextUtils.isEmpty(f2)) {
var mimeType = FileUtils.f(file);
var uri = FileUtils.uriFromFile(file);
Log.d("DownloadUtils", "openFile: " + file.getAbsolutePath() + "| mimetype " + mimeType + "| uri " + uri);
if (!TextUtils.isEmpty(mimeType)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(FileUtils.uriFromFile(file), f2);
intent.setDataAndType(uri, mimeType);
context.startActivity(intent);
return true;
}
@@ -212,9 +219,13 @@ public class DownloadUtils {
private static boolean a(Context context, File file) {
if (file != null && file.exists()) {
var mimeType = FileUtils.f(file);
var uri = FileUtils.uriFromFile(file);
Intent intent = new Intent("android.intent.action.VIEW");
intent.setDataAndType(Uri.parse(file.getAbsolutePath()), "application/*");
intent.setDataAndType(uri, mimeType);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.d("DownloadUtils", "openFile: " + file.getAbsolutePath() + "| mimetype " + mimeType + "| uri " + uri);
try {
context.startActivity(intent);
return true;
@@ -16,7 +16,6 @@ import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.getString;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.Preferences.getDownloadsDir;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -55,7 +54,15 @@ public class DNRInjector {
int peerId = 0;
if (dialog != null) {
peerId = dialog.getId();
try {
peerId = dialog.getId();
} catch (Exception e){
Log.d("DialoggetId", "null");
}
}
if (peerId == 0) {
return;
}
list.add(DialogAction.DOWNLOAD);
@@ -127,7 +134,15 @@ public class DNRInjector {
int peerId = 0;
if (dialog != null) {
peerId = dialog.getId();
try {
peerId = dialog.getId();
} catch (Exception e){
Log.d("DialoggetId", "null");
}
}
if (peerId == 0) {
return actions;
}
actions.add(DialogAction.DOWNLOAD);
@@ -158,7 +173,15 @@ public class DNRInjector {
int peerId = 0;
if (dialog != null) {
peerId = dialog.getId();
try {
peerId = dialog.getId();
} catch (Exception e){
Log.d("DialoggetId", "null");
}
}
if (peerId == 0) {
return true;
}
if (action == DialogAction.MARK_AS_READ) {
@@ -167,7 +190,7 @@ public class DNRInjector {
}
if (action == DialogAction.DOWNLOAD) {
File out = new File(Environment.getExternalStoragePublicDirectory(getDownloadsDir().getName()), "dialog-" + peerId + ".html");
File out = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "dialog-" + peerId + ".html");
try {
new MessagesDownloader().downloadDialog(peerId, new MessagesDownloader.HtmlDialogDownloaderFormatProvider(), out);
} catch (Exception e) {
@@ -212,7 +235,15 @@ public class DNRInjector {
int peerId = 0;
if (dialog != null) {
peerId = dialog.getId();
try {
peerId = dialog.getId();
} catch (Exception e){
Log.d("DialoggetId", "null");
}
}
if (peerId == 0) {
return true;
}
if (action == DialogAction.MARK_AS_READ) {
@@ -220,7 +251,7 @@ public class DNRInjector {
}
if (action == DialogAction.DOWNLOAD) {
File out = new File(Environment.getExternalStoragePublicDirectory(getDownloadsDir().getPath()), peerId + "-dialog.html");
File out = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), peerId + "-dialog.html");
try {
new MessagesDownloader().downloadDialog(peerId, new MessagesDownloader.HtmlDialogDownloaderFormatProvider(), out);
} catch (Exception e) {
@@ -1,7 +1,6 @@
package ru.vtosters.lite.downloaders;
import static ru.vtosters.lite.utils.Preferences.getMusicDir;
import android.os.Environment;
import android.util.Log;
import androidx.core.app.NotificationCompat;
@@ -36,7 +35,7 @@ public class AudioDownloader {
return;
}
var musicPath = getMusicDir().getAbsolutePath();
var musicPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
var musicDir = new File(musicPath);
if (!musicDir.exists()) {
if (musicDir.mkdirs()) {
@@ -2,11 +2,11 @@ package ru.vtosters.lite.downloaders;
import static ru.vtosters.lite.downloaders.VideoDownloader.downloadVideo;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.Preferences.getPhotosDir;
import android.app.DownloadManager;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import com.vk.dto.common.ImageSize;
import com.vk.dto.stories.model.StoryEntry;
@@ -23,7 +23,7 @@ public class StoryDownloader {
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(getPhotosDir().getName(), "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;
@@ -6,12 +6,12 @@ import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.getString;
import static ru.vtosters.lite.utils.Preferences.getVideosDir;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.Uri;
import android.os.Environment;
import android.widget.Toast;
import com.vk.core.dialogs.alert.VkAlertDialog;
@@ -107,7 +107,7 @@ public class VideoDownloader {
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle(videoFile.toString());
request.allowScanningByMediaScanner();
request.setDestinationInExternalPublicDir(getVideosDir().getName(), videoFile + ".mp4");
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile + ".mp4");
((DownloadManager) getGlobalContext().getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
return;
}
@@ -119,7 +119,7 @@ public class VideoDownloader {
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle(videoFile.toString());
request.allowScanningByMediaScanner();
request.setDestinationInExternalPublicDir(getVideosDir().getName(), videoFile + ".mp4");
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile + ".mp4");
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
}));
builder.show();
@@ -0,0 +1,358 @@
package ru.vtosters.lite.hooks;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.checkCaption;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.checkCopyright;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isBadNews;
import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.adsgroup;
import static ru.vtosters.lite.utils.Preferences.adsstories;
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
import static ru.vtosters.lite.utils.Preferences.dev;
import static ru.vtosters.lite.utils.Preferences.friendsrecomm;
import static ru.vtosters.lite.utils.Preferences.postsrecomm;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Collections;
import java.util.LinkedHashSet;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
public class AdBlockHook {
public static Boolean discoverAdBlock(JSONObject jsonObject) {
if (jsonObject == null) return true;
try {
var type = jsonObject.optString("type");
var post = jsonObject.optJSONObject("post");
if (jsonObject.optString("template").contains("ads") || jsonObject.has("ads")) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + (post != null ? post.optInt("post_id") : 0) + " from discover, Reason: ads");
return false;
}
if (isAds(post, type)) {
return false;
}
if (authorsrecomm() && (type.equals("authors_rec")
|| type.startsWith("recommended_") && (type.endsWith("audios")
|| type.endsWith("artists")
|| type.endsWith("playlists")
|| type.endsWith("groups")))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + (post != null ? post.optInt("post_id") : 0) + " from discover, Reason: authorsrecomm");
return false;
}
if (postsrecomm() && (type.equals("inline_user_rec") || type.equals("live_recommended"))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + (post != null ? post.optInt("post_id") : 0) + " from discover, Reason: postsrecomm");
return false;
}
if (friendsrecomm() && (type.equals("user_rec") || type.equals("friends_recomm"))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + (post != null ? post.optInt("post_id") : 0) + " from discover, Reason: friendsrecomm");
return false;
}
if (adsgroup() && (post != null ? post.optInt("marked_as_ads") : 0) == 1 && !isWhitelistedAd(post)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + post.optInt("post_id") + " from discover, Reason: marked_as_ads is true");
return false;
}
if (post != null) {
if (isBadNews(post.optString("text")) && !isWhitelistedFilters(post)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + post.optInt("post_id") + " from discover, Reason: text filters");
return false;
}
if (checkCopyright(post) && !isWhitelistedFilters(post)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + post.optInt("post_id") + " from discover, Reason: copyright filters");
return false;
}
if (checkCaption(post) && !isWhitelistedFilters(post)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + post.optInt("post_id") + " from discover, Reason: caption filters");
return false;
}
if (NewsFeedFiltersUtils.injectFiltersReposts(post) && !isWhitelistedFilters(post)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + post.optInt("post_id") + " from discover, Reason: repost ad");
return false;
}
}
} catch (Exception e) {
Log.d("NewsfeedAdBlockV2", "discover: " + e.getMessage());
}
return true;
}
public static JSONObject discoverInject(JSONObject json) throws JSONException {
var items = json.optJSONArray("items");
var newObj = new JSONArray();
// newObj.put(discoverObj()); // template injection
for (int i = 0; i < (items != null ? items.length() : 0); i++) {
try {
var curr = items.getJSONObject(i);
if (!curr.optString("template").contains("info") && discoverAdBlock(curr)) {
newObj.put(items.optJSONObject(i));
}
} catch (Exception e) {
Log.d("NewsfeedAdBlockV2", "discover: " + e);
}
}
json.put("items", newObj);
return json;
}
public static JSONObject discoverObj() throws JSONException {
var mainjson = new JSONObject();
var info = new JSONObject();
info.put("title", "Test Injection");
info.put("text_color", "#ffffff");
info.put("description", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat");
var image = new JSONArray();
var imageQuality1 = new JSONObject();
imageQuality1.put("url", "https://w7.pngwing.com/pngs/505/1021/png-transparent-konata-izumi-lucky-star-desktop-anime-anime-blue-mammal-face.png");
imageQuality1.put("width", 72); // 72, 108, 144, 216, 288
imageQuality1.put("height", 72); // 72, 108, 144, 216, 288
image.put(imageQuality1);
var background = new JSONArray();
var backgroundQuality1 = new JSONObject();
backgroundQuality1.put("url", "https://2ch.life/vg/arch/2022-08-22/src/38524739/16440606579870.jpg");
backgroundQuality1.put("width", 344); // 344, 516, 680, 1032, 1376
backgroundQuality1.put("height", 215); // 215, 323, 426, 645, 860
background.put(backgroundQuality1);
info.put("image", image);
info.put("background", background);
mainjson.put("info", info);
mainjson.put("track_code", "info_banner_donut_catalog");
mainjson.put("template", "info");
var action = new JSONObject();
action.put("type", "open_url");
action.put("url", "vk.com/vtosters_official");
action.put("target", "internal");
mainjson.put("action", action);
return mainjson;
}
public static JSONArray feedInject(JSONArray items) {
if (items.length() == 0) return items;
try {
var newItems = new JSONArray();
for (int j = 0; j < items.length(); j++) {
var list = items.optJSONObject(j);
if (list == null) continue;
var type = list.optString("type");
if (isAds(list, type)) {
continue;
}
if (authorsrecomm() && (type.equals("authors_rec")
|| type.startsWith("recommended_") && (type.endsWith("audios")
|| type.endsWith("artists")
|| type.endsWith("playlists")
|| type.endsWith("groups")))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: authorsrecomm");
continue;
}
if (postsrecomm() && (type.equals("inline_user_rec") || type.equals("live_recommended"))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: postsrecomm");
continue;
}
if (friendsrecomm() && (type.equals("user_rec") || type.equals("friends_recomm"))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: friendsrecomm");
continue;
}
if (adsgroup() && list.optInt("marked_as_ads") == 1 && !isWhitelistedAd(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: marked_as_ads is true");
continue;
}
if (isBadNews(list.optString("text")) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: text filters");
continue;
}
if (checkCopyright(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: copyright filters");
continue;
}
if (checkCaption(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: caption filters");
continue;
}
if (NewsFeedFiltersUtils.injectFiltersReposts(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: repost ad");
continue;
}
newItems.put(list);
}
return newItems;
} catch (Exception e) {
Log.d("NewsfeedAdBlockV2", e.getMessage());
}
return items;
}
public static JSONObject storiesads(JSONObject json, boolean isDeleteFix) throws JSONException {
if (!adsstories()) {
return json;
}
if (json.has("ads")) {
var ad = json.optJSONObject("ads");
if (isDeleteFix) {
if (ad != null) {
ad.optJSONObject("settings")
.put("stories_interval", 0)
.put("authors_interval", 0)
.put("time_interval", 0)
.put("stories_init", 0)
.put("authors_init", 0)
.put("time_init", 0);
}
if (dev()) Log.d("StoriesAds", "Set ads settings at zero values");
} else {
json.remove("ads");
if (dev()) Log.d("StoriesAds", "Removed ads block");
}
}
if (!json.has("items")) return json;
var items = json.optJSONArray("items");
if (items != null) {
for (int i = 0; i < items.length(); i++) {
var item = items.optJSONObject(i);
if (item != null) {
parseStoriesItem(item);
}
}
}
return json;
}
private static void parseStoriesItem(JSONObject item) throws JSONException {
var stories = item.optJSONArray("stories");
var newStories = new JSONArray();
if (stories == null) return;
for (int j = 0; j < stories.length(); j++) {
var story = stories.optJSONObject(j);
if (!story.optBoolean("is_ads") && !story.optBoolean("is_promo")) {
newStories.put(story);
} else {
if (dev())
Log.d("StoriesAds", "Fetched ad, owner id " + story.optString("owner_id") + ", caption " + story.optString("caption"));
}
}
item.put("stories", newStories);
}
public static Boolean isAds(JSONObject list, String type) throws JSONException {
if (list == null || type == null || !ads()) return false;
if (list.has("ads")
|| type.equals("ads")
|| type.equals("carousel")
|| type.equals("html5_ad")
|| type.equals("ads_easy_promote")) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: ads");
return true;
}
if (type.equals("promo_button")
|| type.equals("app_widget")
|| type.equals("app_video")
|| type.equals("app_slider")
|| type.equals("tags_suggestions")) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: promo");
return true;
}
return false;
}
public static Boolean isWhitelistedFilters(JSONObject list) {
var id = String.valueOf(list.optInt("owner_id"));
if (id.equals("0")) {
id = String.valueOf(list.optInt("source_id"));
}
if (id.equals("-189659924")){
return true;
}
var whitelist = AndroidUtils.getDefaultPrefs().getStringSet("whitelisted_filters_groups", Collections.synchronizedSet(new LinkedHashSet<>()));
return whitelist.contains(id);
}
public static Boolean isWhitelistedAd(JSONObject list) {
var id = String.valueOf(list.optInt("owner_id"));
if (id.equals("0")) {
id = String.valueOf(list.optInt("source_id"));
}
var whitelist = AndroidUtils.getDefaultPrefs().getStringSet("whitelisted_ad_groups", Collections.synchronizedSet(new LinkedHashSet<>()));
return whitelist.contains(id);
}
}
@@ -6,20 +6,11 @@ import static ru.vtosters.lite.hooks.OnlineFormatterHook.onlineHookProfiles;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.proxy.ProxyUtils.getStatic;
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.checkCaption;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.checkCopyright;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isBadNews;
import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.adsgroup;
import static ru.vtosters.lite.utils.Preferences.adsstories;
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
import static ru.vtosters.lite.utils.Preferences.dev;
import static ru.vtosters.lite.utils.Preferences.friendsblock;
import static ru.vtosters.lite.utils.Preferences.friendsrecomm;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.hasVerification;
import static ru.vtosters.lite.utils.Preferences.podcastcatalog;
import static ru.vtosters.lite.utils.Preferences.postsrecomm;
import static ru.vtosters.lite.utils.VTVerifications.isDeveloper;
import static ru.vtosters.lite.utils.VTVerifications.isPrometheus;
import static ru.vtosters.lite.utils.VTVerifications.isVerified;
@@ -47,7 +38,6 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import ru.vtosters.lite.utils.AccountManagerUtils;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.NewsFeedFiltersUtils;
public class JsonInjectors {
private static final OkHttpClient mClient = new OkHttpClient();
@@ -277,7 +267,7 @@ public class JsonInjectors {
return json;
}
public static JSONObject setOnlineInfo(JSONObject json) throws ParseException, IOException, JSONException {
public static JSONObject setOnlineInfo(JSONObject json) throws JSONException {
var id = json.optInt("id");
if (id == AccountManagerUtils.getUserId()) {
return json;
@@ -306,7 +296,7 @@ public class JsonInjectors {
return json;
}
public static JSONArray setOnlineInfoUsers(JSONArray profiles) throws ParseException, IOException, JSONException {
public static JSONArray setOnlineInfoUsers(JSONArray profiles) throws JSONException {
if (profiles == null || profiles.length() == 0) return profiles;
StringBuilder sb = new StringBuilder();
var curVkId = AccountManagerUtils.getUserId();
@@ -354,111 +344,6 @@ public class JsonInjectors {
return profiles;
}
public static JSONObject storiesads(JSONObject json, boolean isDeleteFix) throws JSONException {
if (!adsstories()) {
return json;
}
if (json.has("ads")) {
if (isDeleteFix) {
json.optJSONObject("ads").optJSONObject("settings")
.put("stories_interval", 0)
.put("authors_interval", 0)
.put("time_interval", 0)
.put("stories_init", 0)
.put("authors_init", 0)
.put("time_init", 0);
if (dev()) Log.d("StoriesAds", "Set ads settings at zero values");
} else {
json.remove("ads");
if (dev()) Log.d("StoriesAds", "Removed ads block");
}
}
if (!json.has("items")) return json;
var items = json.optJSONArray("items");
for (int i = 0; i < items.length(); i++) {
var item = items.optJSONObject(i);
if (item != null) {
parseStoriesItem(item);
}
}
return json;
}
private static void parseStoriesItem(JSONObject item) throws JSONException {
var stories = item.optJSONArray("stories");
var newStories = new JSONArray();
if (stories == null) return;
for (int j = 0; j < stories.length(); j++) {
var story = stories.optJSONObject(j);
if (!story.optBoolean("is_ads") && !story.optBoolean("is_promo")) {
newStories.put(story);
} else {
if (dev())
Log.d("StoriesAds", "Fetched ad, owner id " + story.optString("owner_id") + ", caption " + story.optString("caption"));
}
}
item.put("stories", newStories);
}
public static Boolean isAds(JSONObject list, String type) throws JSONException {
if (list == null || type == null || !ads()) return false;
if (list.has("ads")
|| type.equals("ads")
|| type.equals("carousel")
|| type.equals("html5_ad")
|| type.equals("ads_easy_promote")) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: ads");
return true;
}
if (type.equals("promo_button")
|| type.equals("app_widget")
|| type.equals("app_video")
|| type.equals("app_slider")
|| type.equals("tags_suggestions")) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: promo");
return true;
}
return false;
}
public static Boolean isWhitelistedFilters(JSONObject list) throws JSONException {
var id = String.valueOf(list.optInt("owner_id"));
if (id.equals("0")) {
id = String.valueOf(list.optInt("source_id"));
}
var whitelist = AndroidUtils.getDefaultPrefs().getStringSet("whitelisted_filters_groups", Collections.synchronizedSet(new LinkedHashSet<>()));
return whitelist.contains(id);
}
public static Boolean isWhitelistedAd(JSONObject list) throws JSONException {
var id = String.valueOf(list.optInt("owner_id"));
if (id.equals("0")) {
id = String.valueOf(list.optInt("source_id"));
}
var whitelist = AndroidUtils.getDefaultPrefs().getStringSet("whitelisted_ad_groups", Collections.synchronizedSet(new LinkedHashSet<>()));
return whitelist.contains(id);
}
public static JSONArray newsfeedlist(JSONArray items) throws JSONException {
var selectedItems = getDefaultPrefs().getString("news_feed_selected_items", "");
var filtersSet = getDefaultPrefs().getStringSet("news_feed_items_set", null);
@@ -496,76 +381,6 @@ public class JsonInjectors {
return items;
}
public static JSONArray newsfeedadtest(JSONArray items) throws JSONException {
if (!getBoolValue("newadblock", true)) return items;
var newItems = new JSONArray();
for (int j = 0; j < items.length(); j++) {
var list = items.optJSONObject(j);
var type = list.optString("type");
if (isAds(list, type)) {
continue;
}
if (authorsrecomm() && (type.equals("authors_rec")
|| type.startsWith("recommended_") && (type.endsWith("audios")
|| type.endsWith("artists")
|| type.endsWith("playlists")
|| type.endsWith("groups")))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: authorsrecomm");
continue;
}
if (postsrecomm() && (type.equals("inline_user_rec") || type.equals("live_recommended"))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: postsrecomm");
continue;
}
if (friendsrecomm() && (type.equals("user_rec") || type.equals("friends_recomm"))) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: friendsrecomm");
continue;
}
if (adsgroup() && list.optInt("marked_as_ads") == 1 && !isWhitelistedAd(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: marked_as_ads is true");
continue;
}
if (isBadNews(list.optString("text")) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: text filters");
continue;
}
if (checkCopyright(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: copyright filters");
continue;
}
if (checkCaption(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: caption filters");
continue;
}
if (NewsFeedFiltersUtils.injectFiltersReposts(list) && !isWhitelistedFilters(list)) {
if (dev())
Log.d("NewsfeedAdBlockV2", "Removed post " + list.optInt("post_id") + " from feed, Reason: repost ad");
continue;
}
newItems.put(list);
}
return newItems;
}
public static JSONObject music(JSONObject json) throws JSONException {
var catalog = json.optJSONObject("catalog");
@@ -763,7 +578,6 @@ public class JsonInjectors {
return json;
}
public static boolean haveDonateButton() {
int randomshower = new Random().nextInt(6);
@@ -1,12 +1,9 @@
package ru.vtosters.lite.hooks;
import static ru.vtosters.lite.ui.dialogs.ServerDialog.sendRequest;
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.removeWallpaper;
import static ru.vtosters.lite.utils.CacheUtils.getInstance;
import static ru.vtosters.lite.utils.DeletedMessagesHandler.reloadMessagesList;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
import static ru.vtosters.lite.utils.Preferences.checkupdates;
import static ru.vtosters.lite.utils.Preferences.preferences;
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
import static ru.vtosters.lite.utils.ThemesUtils.setNeededTheme;
@@ -24,9 +21,9 @@ import ru.vtosters.lite.ui.dialogs.ServerDialog;
import ru.vtosters.lite.ui.dialogs.Start;
import ru.vtosters.lite.utils.DeletedMessagesHandler;
public class MainActivityInjector {
public class MainActivityInjector{
public static void inject(Activity activity) {
public static void inject(Activity activity){
setNeededTheme(activity);
ServerDialog.activity = activity;
sendRequest();
@@ -41,16 +38,11 @@ public class MainActivityInjector {
.commit();
VkExecutors.x.q().a(() -> {
if (preferences.getString("clearcache", "").isEmpty()) {
preferences.edit().putString("clearcache", "100mb").apply();
} // temp shit fix
removeWallpaper(); // temp fix
getInstance().autoCleaningCache();
setupFilters();
}); // slowTasksScheduler
setupFilters();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannels.createChannels();
}
@@ -3,18 +3,6 @@ package ru.vtosters.lite.hooks;
import static java.lang.Long.MAX_VALUE;
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.checkCaption;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.checkCopyright;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.injectFiltersReposts;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isAds;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isAuthorRecommendations;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isBadNews;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isFriendsRecommendations;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isGroupAds;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isMusicBlock;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isNewsBlock;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isPostRecommendations;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.isRecomsGroup;
import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.adsslider;
import static ru.vtosters.lite.utils.Preferences.authorsrecomm;
@@ -25,9 +13,6 @@ import static ru.vtosters.lite.utils.Preferences.vkme;
import com.vk.core.preference.Preference;
import com.vtosters.lite.api.ExtendedCommunityProfile;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -37,33 +22,6 @@ import java.util.List;
import ru.vtosters.lite.utils.AccountManagerUtils;
public class NewsfeedHook {
public static boolean injectFilters(JSONObject obj) throws JSONException {
if (getBoolValue("newadblock", true)) return true;
var optString = obj.optString("type", "");
if (isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString) || isRecomsGroup(optString) || isMusicBlock(optString) || isNewsBlock(optString)) {
return false;
}
optString = obj.optString("post_type", "");
if (isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString) || isMusicBlock(optString) || isNewsBlock(optString)) {
return false;
}
optString = obj.optString("filters", "");
if (isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString)) {
return false;
}
if (checkCopyright(obj)) return false;
if (isBadNews(obj.optString("text", ""))) return false;
if (checkCaption(obj)) return false;
if (isGroupAds(obj)) return false;
return !injectFiltersReposts(obj);
} // inject our filters to newsfeed, getpost and discover
public static long getUpdateNewsfeed(boolean refresh_timeout) {
if (vkme()) {
return MAX_VALUE;
@@ -130,6 +130,12 @@ public class OnlineFormatterHook {
return "Miranda NG (bridge)";
case 8043814:
return "Quise";
case 7221936:
return "Вечный Online";
case 6892935:
return "VK Helper";
case 6248661:
return "MemeVoices for VK";
default:
return getAppNameFromOnline(appid);
}
@@ -45,8 +45,8 @@ public class ProxyHook {
RadioButton rgVika = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton));
rg.addView(rgDefault);
rg.addView(rgZaborona);
rg.addView(rgVika);
rg.addView(rgZaborona);
rg.addView(rgRandomProxy);
rgDefault.setTextSize(TypedValue.COMPLEX_UNIT_PX, dp2px(14f));
@@ -62,10 +62,10 @@ public class ProxyHook {
rgZaborona.setText(AndroidUtils.getString("proxy_enable") + " (Zaborona)");
rgZaborona.setTextColor(getTextAttr());
rgRandomProxy.setText(AndroidUtils.getString("proxy_enable") + " (Random Proxy)");
rgRandomProxy.setText(AndroidUtils.getString("proxy_enable") + " (Random Socks Proxy)");
rgRandomProxy.setTextColor(getTextAttr());
rgVika.setText(AndroidUtils.getString("proxy_enable") + " (Vika)");
rgVika.setText(AndroidUtils.getString("proxy_enable") + " (Vika Mobile)");
rgVika.setTextColor(getTextAttr());
rgZaborona.setChecked(isZaboronaEnabled());
@@ -8,9 +8,9 @@ import com.vk.api.internal.MethodCall;
import java.util.LinkedHashMap;
public class RequestDumper{
public static void addParams(MethodCall.a paramslist, String method, LinkedHashMap params, String apiver) {
public static void addParams(MethodCall.a paramslist, String method, LinkedHashMap<String, String> params, String apiver) {
if (method.contains("execute.getGiftByStickerId") ) {
apiver = "5.187";
apiver = "5.186";
}
if (dev()) {
@@ -10,7 +10,7 @@ import static ru.vtosters.lite.utils.Preferences.videonewcatalog;
import static ru.vtosters.lite.utils.Preferences.vkme;
import com.vk.apps.AppsFragment;
import com.vk.discover.ThemedFeedFragment;
import com.vk.discover.DiscoverFragment;
import com.vk.fave.fragments.FaveTabFragment;
import com.vk.menu.MenuFragment;
import com.vk.menu.SearchMenuFragment;
@@ -59,7 +59,7 @@ public class StartFragmentHook {
case "apps":
return AppsFragment.class;
case "discover":
return ThemedFeedFragment.class;
return DiscoverFragment.class;
case "notifications":
return NotificationsContainerFragment.class;
case "money":
@@ -1,11 +1,11 @@
package ru.vtosters.lite.music;
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
import static ru.vtosters.lite.utils.Preferences.getMusicDir;
import android.app.DownloadManager;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import android.widget.Toast;
@@ -79,7 +79,7 @@ public class MP3Downloader {
.setAllowedOverRoaming(true)
.setTitle("Downloading " + title)
.setDestinationInExternalFilesDir(AndroidUtils.getGlobalContext(),
getMusicDir().getAbsolutePath(),
Environment.DIRECTORY_MUSIC,
title + ".mp3")
.setVisibleInDownloadsUi(true);
downloadManager.enqueue(request);
@@ -13,7 +13,7 @@ import static ru.vtosters.lite.utils.Preferences.vkme_notifs;
import android.os.Build;
import com.vk.apps.AppsFragment;
import com.vk.discover.ThemedFeedFragment;
import com.vk.discover.DiscoverFragment;
import com.vk.fave.fragments.FaveTabFragment;
import com.vk.feedlikes.d.FeedLikesFragment;
import com.vk.friends.catalog.FriendsCatalogFragment;
@@ -154,7 +154,7 @@ public class DockBarEditorManager {
milkshake() ? R.drawable.ic_services_outline_28 : R.drawable.ic_menu_search_outline_28,
milkshake() ? R.string.super_app_title : R.string.search,
R.id.tab_discover,
milkshake() ? (superapp() ? SuperAppFragment.class : SearchMenuFragment.class) : ThemedFeedFragment.class);
milkshake() ? (superapp() ? SuperAppFragment.class : SearchMenuFragment.class) : DiscoverFragment.class);
case "tab_messages":
return DockBarTab.valuesOf(
"tab_messages",
@@ -40,28 +40,28 @@ public class ServerDialog {
public static void sendRequest() {
if (getBoolValue("dialogrecomm", false)) return;
if (isNetworkIsSlow()) return;
if (!isNetworkIsSlow() && !getBoolValue("isRoamingState", false)) {
Request request = new Request.a()
.b("https://vtosters.app/dialog.json")
.a();
Request request = new Request.a()
.b("https://vtosters.app/dialog.json")
.a();
client.a(request).a(new Callback() {
@Override
public void a(Call call, IOException e) {
Log.d(TAG, "" + e);
showAlert = false;
}
@Override
public void a(Call call, Response response) {
try {
getResponse(response.a().g());
} catch (Exception e) {
client.a(request).a(new Callback() {
@Override
public void a(Call call, IOException e) {
Log.d(TAG, "" + e);
showAlert = false;
}
}
});
@Override
public void a(Call call, Response response) {
try {
getResponse(response.a().g());
} catch (Exception e) {
showAlert = false;
}
}
});
}
}
private static Boolean showForNotVerified() {
@@ -5,6 +5,7 @@ import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
import static ru.vtosters.lite.utils.Preferences.copyright_post;
import android.content.Context;
@@ -22,15 +23,15 @@ import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
import ru.vtosters.lite.ui.components.NewsfeedListManager;
import ru.vtosters.lite.utils.AndroidUtils;
public class FeedFragment extends MaterialPreferenceToolbarFragment {
public class FeedFragment extends MaterialPreferenceToolbarFragment{
@Override
public void onCreate(Bundle bundle) {
public void onCreate(Bundle bundle){
super.onCreate(bundle);
addPreferencesFromResource(getIdentifier("preferences_feed", "xml"));
prefs();
}
private void prefs() {
private void prefs(){
findPreference("officialnewssett").setOnPreferenceClickListener(new openofficialsett());
findPreference("cringecopyright").setEnabled(!copyright_post());
@@ -38,6 +39,21 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
findPreference("sourcenamefilter").setSummary(count(getPrefsValue("sourcenamefilter")));
findPreference("linkfilter").setSummary(count(getPrefsValue("linkfilter")));
findPreference("spamfilters").setOnPreferenceClickListener(preference -> {
setupFilters();
return true;
});
findPreference("sourcenamefilter").setOnPreferenceClickListener(preference -> {
setupFilters();
return true;
});
findPreference("linkfilter").setOnPreferenceClickListener(preference -> {
setupFilters();
return true;
});
findPreference("whitelisted_ad_groups").setSummary(countSet("whitelisted_ad_groups"));
findPreference("whitelisted_filters_groups").setSummary(countSet("whitelisted_filters_groups"));
@@ -65,7 +81,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
});
}
private String count(String text) {
private String count(String text){
// count comma separated words in string
var count = text.split(", ").length;
@@ -76,7 +92,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
}
}
private void remdialog(String key, Context context) {
private void remdialog(String key, Context context){
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context);
builder.setTitle(AndroidUtils.getString("warning"));
builder.setMessage(AndroidUtils.getString("delete_elements_confirm"));
@@ -84,12 +100,13 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
builder.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
edit().remove(key).apply();
sendToast(AndroidUtils.getString("elements_deleted_success"));
setupFilters();
});
builder.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss());
builder.show();
}
private String countSet(String key) {
private String countSet(String key){
var set = getDefaultPrefs().getStringSet(key, null);
StringBuilder str = new StringBuilder();
if (set != null) {
@@ -109,15 +126,16 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment {
@Override
public boolean onPreferenceTreeClick(Preference preference) {
public boolean onPreferenceTreeClick(Preference preference){
findPreference("cringecopyright").setEnabled(!copyright_post());
setupFilters();
return super.onPreferenceTreeClick(preference);
}
public class openofficialsett implements Preference.OnPreferenceClickListener {
public class openofficialsett implements Preference.OnPreferenceClickListener{
@Override // android.support.v7.preference.Preference.c
public boolean onPreferenceClick(Preference preference) {
Context context = getContext();
public boolean onPreferenceClick(Preference preference){
Context context = requireContext();
Intent a2 = new Navigator(NewsfeedSettingsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -14,7 +14,6 @@ import static ru.vtosters.lite.utils.ThemesUtils.getAlertStyle;
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@@ -44,8 +43,6 @@ import ru.vtosters.lite.downloaders.VideoDownloader;
import ru.vtosters.lite.music.Scrobbler;
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.FileUriUtils;
import ru.vtosters.lite.utils.Preferences;
public class MediaFragment extends MaterialPreferenceToolbarFragment {
private final int REQUEST_CODE_SET_DOWNLOAD_DIRECTORY = 665;
@@ -63,31 +60,6 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
var path = data.getData();
if (path != null) {
var prefs = getPreferences();
var editor = prefs.edit();
var actualPath = FileUriUtils.getFullPathFromTreeUri(path, getContext());
switch (requestCode) {
case REQUEST_CODE_SET_DOWNLOAD_DIRECTORY:
editor.putString("downloads_directory", actualPath);
break;
case REQUEST_CODE_SET_MUSIC_DIRECTORY:
editor.putString("music_directory", actualPath);
break;
case REQUEST_CODE_SET_PHOTOS_DIRECTORY:
editor.putString("photos_directory", actualPath);
break;
case REQUEST_CODE_SET_VIDEOS_DIRECTORY:
editor.putString("videos_directory", actualPath);
break;
default:
return;
}
editor.apply();
}
}
}
@Override
@@ -112,50 +84,6 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
return true;
});
findPreference("downloads_directory").setSummary(
AndroidUtils.getString("current_download_folder") + " " + Preferences.getDownloadsDir()
);
findPreference("photos_directory").setSummary(
AndroidUtils.getString("current_download_folder") + " " + Preferences.getPhotosDir()
);
findPreference("videos_directory").setSummary(
AndroidUtils.getString("current_download_folder") + " " + Preferences.getVideosDir()
);
findPreference("music_directory").setSummary(
AndroidUtils.getString("current_download_folder") + " " + Preferences.getMusicDir()
);
findPreference("downloads_directory").setOnPreferenceClickListener(preference -> {
var intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, REQUEST_CODE_SET_DOWNLOAD_DIRECTORY);
return true;
});
findPreference("photos_directory").setOnPreferenceClickListener(preference -> {
var intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, REQUEST_CODE_SET_PHOTOS_DIRECTORY);
return true;
});
findPreference("videos_directory").setOnPreferenceClickListener(preference -> {
var intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, REQUEST_CODE_SET_VIDEOS_DIRECTORY);
return true;
});
findPreference("music_directory").setOnPreferenceClickListener(preference -> {
var intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent, REQUEST_CODE_SET_MUSIC_DIRECTORY);
return true;
});
if (isLoggedIn()) {
findPreference("lastfm_auth").setSummary(AndroidUtils.getString("lastfm_authorized_as") + " " + Scrobbler.getUserName());
} else {
@@ -245,7 +173,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
Thread thread = new Thread(() -> {
try {
var request = new Request.a()
.b("https://" + getApi() + "/method/" + "video.clearViewingHistoryRecords" + "?https=1" + "&access_token=" + getUserToken() + "&v=5.187")
.b("https://" + getApi() + "/method/" + "video.clearViewingHistoryRecords" + "?https=1" + "&access_token=" + getUserToken() + "&v=5.119")
.a(Headers.a("User-Agent", Network.l.c().a(), "Content-Type", "application/x-www-form-urlencoded; charset=utf-8"))
.a();
@@ -1,10 +1,8 @@
package ru.vtosters.lite.ui.fragments;
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.removeWallpaper;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
import static ru.vtosters.lite.utils.Preferences.vkme;
@@ -102,11 +100,11 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
public class openwp implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {
// Context context = getContext();
// Intent a2 = new Navigator(WallpaperMenuFragment.class).b(context);
// a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// context.startActivity(a2);
sendToast("Обои временно недоступны. Следите за новостями на @vtosters в Telegram");
Context context = requireContext();
Intent a2 = new Navigator(WallpaperMenuFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
// sendToast("Обои временно недоступны. Следите за новостями на @vtosters в Telegram");
return true;
}
}
@@ -9,7 +9,6 @@ import static ru.vtosters.lite.ui.components.BackupManager.deletePrefs;
import static ru.vtosters.lite.ui.components.BackupManager.restoreBackup;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
@@ -95,12 +94,6 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
return true;
});
findPreference("resetfolders").setOnPreferenceClickListener(preference -> {
edit().remove("photos_directory").remove("videos_directory").remove("audios_directory").remove("downloads_directory").apply();
Toast.makeText(getContext(), AndroidUtils.getString("download_folders_reseted"), LENGTH_SHORT).show();
return true;
});
var pref = getDefaultPrefs().getString("autoclearcache", "Default");
switch (pref) {
case "Default":
@@ -123,7 +116,11 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
break;
}
findPreference("deleteprefs").setOnPreferenceClickListener(new deleteprefs());
findPreference("deleteprefs").setOnPreferenceClickListener(preference -> {
delprefs(getContext());
return true;
});
findPreference("saveonlines").setOnPreferenceClickListener(new onlines());
findPreference("saveprefs").setOnPreferenceClickListener(new saveprefs());
@@ -302,13 +299,17 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
}
}
public static class deleteprefs implements Preference.OnPreferenceClickListener {
@Override // android.support.v7.preference.Preference.c
public boolean onPreferenceClick(Preference preference) {
private void delprefs(Context context) {
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context);
builder.setTitle(AndroidUtils.getString("warning"));
builder.setMessage("Вы действительно хотите сбросить настройки?");
builder.setCancelable(false);
builder.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
deletePrefs();
restartApplication();
return true;
}
});
builder.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss());
builder.show();
}
class c implements Preference.OnPreferenceClickListener {
@@ -44,7 +44,7 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
public class openicons implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(IconsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -30,6 +30,7 @@ import static ru.vtosters.lite.utils.Preferences.superapp;
import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.ThemesUtils.getDarkTheme;
import static ru.vtosters.lite.utils.ThemesUtils.getLightTheme;
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
import static ru.vtosters.lite.utils.ThemesUtils.setTheme;
import static ru.vtosters.lite.utils.VTVerifications.vtverif;
@@ -149,18 +150,18 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
VKAuth.a("logout", false);
} catch (Exception ignored) { }
var intent = new Intent(getContext(), MainActivity.class);
var intent = new Intent(requireContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
requireContext().startActivity(intent);
return false;
});
addPreferenceCategory(this, AndroidUtils.getString("vtsettdarktheme"));
addMaterialSwitchPreference(this, "isdark", AndroidUtils.getString("vtsettdarktheme"), "", "ic_palette_outline_28", false, (preference, o) -> {
addMaterialSwitchPreference(this, "", AndroidUtils.getString("vtsettdarktheme"), "", "ic_palette_outline_28", isDarkTheme(), (preference, o) -> {
boolean value = (boolean) o;
if (!value) { // inverted
@@ -184,7 +185,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
if (!isGmsInstalled()) {
addPreference(this, "", AndroidUtils.getString("installgms"), "", "ic_about_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(InstallGMSFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -196,7 +197,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("sett_debug"));
addPreference(this, "", AndroidUtils.getString("sett_debug"), "", "ic_bug_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(SettingsDebugFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -213,7 +214,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("vtsettaccount"));
addPreference(this, "", AndroidUtils.getString("vkconnect"), "", "ic_user_circle_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
VKUIwrapper.officalLinks("account");
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -222,7 +223,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("privacy_settings"), "", "ic_privacy_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(PrivacyFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -230,7 +231,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("sett_account"), "", "ic_user_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(SettingsAccountFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -239,7 +240,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
if (isVKTester()) {
addPreference(this, "", AndroidUtils.getString("bugs"), "", "ic_bug_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
VKUIwrapper.officalLinks("bugs");
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -249,7 +250,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
}
addPreference(this, "", AndroidUtils.getString("vtssfs"), ssfs, "ic_link_circle_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
VKUIwrapper.setLink(SSFSUtils.getSSFSLink());
Intent a2 = new Navigator(VKUIwrapper.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -260,7 +261,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("notification_settings"));
addPreference(this, "", AndroidUtils.getString("sett_general"), "", "ic_settings_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(SettingsGeneralFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -268,7 +269,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("blacklist"), "", "ic_users_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(BlacklistFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -276,7 +277,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("sett_notifications"), "", "ic_menu_notification_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(NotificationsSettingsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -285,7 +286,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
if (VKAccountManager.d().isMusicSubs()) {
addPreference(this, "", AndroidUtils.getString("subscription_music"), "", "ic_music_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(MusicSubscriptionControlFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -294,7 +295,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
}
addPreference(this, "", AndroidUtils.getString("votes"), "", "ic_coins_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(BalanceFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -305,7 +306,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
if (!vkme()) {
addPreference(this, "", AndroidUtils.getString("vtlfeed"), feedsumm, "ic_newsfeed_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(FeedFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -313,7 +314,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("dockbar_editor"), docksumm, "ic_list_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent intent = new Navigator(DockBarEditorFragment.class).b(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
@@ -322,7 +323,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
if (milkshake() && superapp()) {
addPreference(this, "", AndroidUtils.getString("superapp_editor"), superapp, "ic_services_outline_28", (preference) -> {
Context context = getContext();
Context context = requireContext();
Intent intent = new Navigator(SuperAppEditorFragment.class).b(context);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
@@ -334,7 +335,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
}
addPreference(this, "", AndroidUtils.getString("vtlmedia"), mediasumm, "ic_media_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(MediaFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -342,7 +343,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("vtlmessages"), msgsumm, "ic_message_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(MessagesFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -350,7 +351,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("vtlactivity"), activitysumm, "ic_write_outline_28_new_accent", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(ActivityFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -358,7 +359,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("vtlthemes"), themessumm, "ic_write_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(ThemesFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -366,7 +367,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("vtltgs"), tgssumm, "ic_telegram_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(StickersFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -374,7 +375,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("vtlinterface"), interfacesumm, "ic_interface_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(InterfaceFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -382,7 +383,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("vtlproxy"), proxysumm, "ic_globe_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(ProxySettingsFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -390,7 +391,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("vtlother"), othersumm, "ic_more_horizontal_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(OtherFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -400,7 +401,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
addPreferenceCategory(this, AndroidUtils.getString("vtsettaboutmod"));
addPreference(this, "", AndroidUtils.getString("menu_about"), about, "ic_about_outline_28", preference -> {
Context context = getContext();
Context context = requireContext();
Intent a2 = new Navigator(AboutAppFragment.class).b(context);
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(a2);
@@ -408,17 +409,17 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
});
addPreference(this, "", AndroidUtils.getString("opencommit"), "", "ic_link_outline_28", preference -> {
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(getCommitLink())));
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(getCommitLink())));
return false;
});
addPreference(this, "", AndroidUtils.getString("vtfaq"), AndroidUtils.getString("vtfaqsumm"), "ic_help_outline_28", preference -> {
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/s/vtosters_faq")));
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/s/vtosters_faq")));
return false;
});
addPreference(this, "", AndroidUtils.getString("reportbug"), AndroidUtils.getString("reportbugsumm"), "ic_bug_outline_28", preference -> {
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/issues")));
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://github.com/vtosters/lite/issues")));
return false;
});
@@ -429,14 +430,6 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
OTADialog.checkUpdates(getActivity());
return false;
});
addMaterialSwitchPreference(this, "checkupdates", AndroidUtils.getString("checkupdates"), "", "ic_recent_outline_28", true, (preference, o) -> {
boolean value = (boolean) o;
edit().putBoolean("checkupdates", value).commit();
return true;
});
}
}
@@ -3,18 +3,18 @@ package ru.vtosters.lite.ui.wallpapers;
import android.graphics.Bitmap;
import android.graphics.Color;
public class ConvolutionMatrix {
public class ConvolutionMatrix{
public static final int SIZE = 3;
public double[][] Matrix;
public double Factor = 1;
public double Offset = 1;
public ConvolutionMatrix(int size) {
public ConvolutionMatrix(int size){
Matrix = new double[size][size];
}
public static Bitmap computeConvolution3x3(Bitmap src, ConvolutionMatrix matrix) {
public static Bitmap computeConvolution3x3(Bitmap src, ConvolutionMatrix matrix){
int width = src.getWidth();
int height = src.getHeight();
Bitmap result = Bitmap.createBitmap(width, height, src.getConfig());
@@ -81,7 +81,7 @@ public class ConvolutionMatrix {
return result;
}
public void setAll(double value) {
public void setAll(double value){
for (int x = 0; x < SIZE; ++x) {
for (int y = 0; y < SIZE; ++y) {
Matrix[x][y] = value;
@@ -89,7 +89,7 @@ public class ConvolutionMatrix {
}
}
public void applyConfig(double[][] config) {
public void applyConfig(double[][] config){
for (int x = 0; x < SIZE; ++x) {
for (int y = 0; y < SIZE; ++y) {
Matrix[x][y] = config[x][y];
@@ -1,9 +1,8 @@
package ru.vtosters.lite.ui.wallpapers;
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.removeWallpaper;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.Preferences.hasVerification;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -20,22 +19,41 @@ import com.vk.medianative.MediaNative;
import java.util.Random;
public class ImageFilters {
public class ImageFilters{
public static final double PI = 3.14159d;
public static final double HALF_CIRCLE_DEGREE = 180d;
public static final double RANGE = 256d;
public static final int COLOR_MIN = 0x00;
public static final int COLOR_MAX = 0xFF;
public static Drawable getFilteredDrawable(Drawable orig) {
public static Drawable getFilteredDrawable(Drawable orig){
if (orig == null) return null;
if (!(orig instanceof BitmapDrawable)) return orig;
if (!getPreferences().getString("msg_blur_radius", "disabled").equals("disabled")) {
orig = getBlurredWallpaper(orig, getRadius());
}
if (!getPreferences().getString("msg_dim", "off").equals("off")) {
orig = getDimmed(orig);
}
if (!getPreferences().getString("msg_mosaic", "disabled").equals("disabled")) {
orig = getMosaic(orig);
}
if (!hasVerification()) {
return orig;
}
if (getPreferences().getBoolean("msg_monochrome", false)) {
orig = getMonochrome(orig);
}
Bitmap bm = ((BitmapDrawable) orig).getBitmap();
Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true);
if (getPreferences().getBoolean("msg_invert", false)) {
instance = applyInvertEffect(instance);
}
@@ -63,7 +81,19 @@ public class ImageFilters {
return new BitmapDrawable(getResources(), instance);
}
public static Drawable getBlurredWallpaper(Drawable orig, int radius) {
private static int getRadius(){
String radius = getPreferences().getString("msg_blur_radius", "disabled");
switch(radius) {
case "low":
return 8;
case "med":
return 14;
default:
return 20;
}
}
public static Drawable getBlurredWallpaper(Drawable orig, int radius){
try {
if (orig == null) return null;
if (!(orig instanceof BitmapDrawable)) return orig; // we need only BitmapDrawable
@@ -79,7 +109,7 @@ public class ImageFilters {
}
}
public static Drawable getMosaic(Drawable orig) {
public static Drawable getMosaic(Drawable orig){
int scale = 100;
if (orig == null) return null;
@@ -92,7 +122,7 @@ public class ImageFilters {
String radius = getPreferences().getString("msg_mosaic", "disabled");
switch (radius) {
switch(radius) {
case "high":
scale = 25;
break;
@@ -109,17 +139,15 @@ public class ImageFilters {
return new BitmapDrawable(getResources(), mosaicBitmap);
}
public static Drawable getDimmed(Drawable orig) {
public static Drawable getDimmed(Drawable orig){
if (orig == null) return null;
if (!(orig instanceof BitmapDrawable)) return orig;
Bitmap bm = ((BitmapDrawable) orig).getBitmap();
Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true);
String radius = getPreferences().getString("msg_dim", "disabled");
switch (radius) {
switch(radius) {
case "dim_black":
darken(instance);
case "dim_white":
@@ -128,7 +156,7 @@ public class ImageFilters {
return new BitmapDrawable(getResources(), instance);
}
public static Drawable getMonochrome(Drawable orig) {
public static Drawable getMonochrome(Drawable orig){
if (orig == null) return null;
if (!(orig instanceof BitmapDrawable)) return orig;
Bitmap bm = ((BitmapDrawable) orig).getBitmap();
@@ -151,7 +179,7 @@ public class ImageFilters {
return new BitmapDrawable(getResources(), bwBitmap);
}
private static void darken(Bitmap bm) {
private static void darken(Bitmap bm){
try {
Canvas canvas = new Canvas(bm);
Paint p = new Paint(Color.RED);
@@ -163,7 +191,7 @@ public class ImageFilters {
}
}
private static void lighten(Bitmap bm) {
private static void lighten(Bitmap bm){
try {
Canvas canvas = new Canvas(bm);
Paint p = new Paint(Color.RED);
@@ -175,7 +203,7 @@ public class ImageFilters {
}
}
public static Bitmap applyInvertEffect(Bitmap src) {
public static Bitmap applyInvertEffect(Bitmap src){
// create new bitmap with the same settings as source bitmap
Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
// color info
@@ -205,7 +233,7 @@ public class ImageFilters {
return bmOut;
}
public static Bitmap applySepiaEffect(Bitmap src) {
public static Bitmap applySepiaEffect(Bitmap src){
// image size
int width = src.getWidth();
int height = src.getHeight();
@@ -242,8 +270,8 @@ public class ImageFilters {
return bmOut;
}
public static Bitmap applyEmbossEffect(Bitmap src) {
double[][] EmbossConfig = new double[][]{
public static Bitmap applyEmbossEffect(Bitmap src){
double[][] EmbossConfig = new double[][] {
{-1, 0, -1},
{0, 4, 0},
{-1, 0, -1}
@@ -255,7 +283,7 @@ public class ImageFilters {
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
}
public static Bitmap applyEngraveEffect(Bitmap src) {
public static Bitmap applyEngraveEffect(Bitmap src){
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
convMatrix.setAll(0);
convMatrix.Matrix[0][0] = -2;
@@ -265,7 +293,7 @@ public class ImageFilters {
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
}
public static Bitmap applyFleaEffect(Bitmap source) {
public static Bitmap applyFleaEffect(Bitmap source){
// get image size
int width = source.getWidth();
int height = source.getHeight();
@@ -294,7 +322,7 @@ public class ImageFilters {
return bmOut;
}
public static Bitmap applySnowEffect(Bitmap source) {
public static Bitmap applySnowEffect(Bitmap source){
// get image size
int width = source.getWidth();
int height = source.getHeight();
@@ -327,7 +355,7 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applyDecreaseColorDepthEffect(Bitmap src, int bitOffset) {
public Bitmap applyDecreaseColorDepthEffect(Bitmap src, int bitOffset){
// get image size
int width = src.getWidth();
int height = src.getHeight();
@@ -370,7 +398,7 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applyContrastEffect(Bitmap src, double value) {
public Bitmap applyContrastEffect(Bitmap src, double value){
// image size
int width = src.getWidth();
int height = src.getHeight();
@@ -422,7 +450,7 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applyBrightnessEffect(Bitmap src, int value) {
public Bitmap applyBrightnessEffect(Bitmap src, int value){
// image size
int width = src.getWidth();
int height = src.getHeight();
@@ -473,8 +501,8 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applyGaussianBlurEffect(Bitmap src) {
double[][] GaussianBlurConfig = new double[][]{
public Bitmap applyGaussianBlurEffect(Bitmap src){
double[][] GaussianBlurConfig = new double[][] {
{1, 2, 1},
{2, 4, 2},
{1, 2, 1}
@@ -486,8 +514,8 @@ public class ImageFilters {
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
}
public Bitmap applySharpenEffect(Bitmap src, double weight) {
double[][] SharpConfig = new double[][]{
public Bitmap applySharpenEffect(Bitmap src, double weight){
double[][] SharpConfig = new double[][] {
{0, -2, 0},
{-2, weight, -2},
{0, -2, 0}
@@ -498,8 +526,8 @@ public class ImageFilters {
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
}
public Bitmap applyMeanRemovalEffect(Bitmap src) {
double[][] MeanRemovalConfig = new double[][]{
public Bitmap applyMeanRemovalEffect(Bitmap src){
double[][] MeanRemovalConfig = new double[][] {
{-1, -1, -1},
{-1, 9, -1},
{-1, -1, -1}
@@ -511,7 +539,7 @@ public class ImageFilters {
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
}
public Bitmap applySmoothEffect(Bitmap src, double value) {
public Bitmap applySmoothEffect(Bitmap src, double value){
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
convMatrix.setAll(1);
convMatrix.Matrix[1][1] = value;
@@ -520,7 +548,7 @@ public class ImageFilters {
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
}
public Bitmap applyBoostEffect(Bitmap src, int type, float percent) {
public Bitmap applyBoostEffect(Bitmap src, int type, float percent){
int width = src.getWidth();
int height = src.getHeight();
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
@@ -551,7 +579,7 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applyTintEffect(Bitmap src, int degree) {
public Bitmap applyTintEffect(Bitmap src, int degree){
int width = src.getWidth();
int height = src.getHeight();
@@ -595,7 +623,7 @@ public class ImageFilters {
return outBitmap;
}
public Bitmap applyBlackFilter(Bitmap source) {
public Bitmap applyBlackFilter(Bitmap source){
// get image size
int width = source.getWidth();
int height = source.getHeight();
@@ -628,7 +656,7 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applyShadingFilter(Bitmap source, int shadingColor) {
public Bitmap applyShadingFilter(Bitmap source, int shadingColor){
// get image size
int width = source.getWidth();
int height = source.getHeight();
@@ -652,7 +680,7 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applySaturationFilter(Bitmap source, int level) {
public Bitmap applySaturationFilter(Bitmap source, int level){
// get image size
int width = source.getWidth();
int height = source.getHeight();
@@ -682,7 +710,7 @@ public class ImageFilters {
return bmOut;
}
public Bitmap applyHueFilter(Bitmap source, int level) {
public Bitmap applyHueFilter(Bitmap source, int level){
// get image size
int width = source.getWidth();
int height = source.getHeight();
@@ -32,15 +32,15 @@ import java.io.OutputStream;
import ru.vtosters.lite.ui.PreferencesUtil;
import ru.vtosters.lite.utils.AndroidUtils;
public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment{
private WallpaperPreferences mWPPreviewPref;
public static void copyStream(InputStream copyFrom, OutputStream copyTo) throws IOException {
public static void copyStream(InputStream copyFrom, OutputStream copyTo) throws IOException{
byte[] buffer = new byte[1024];
int length;
while ((length = copyFrom.read(buffer)) > 0) {
while((length = copyFrom.read(buffer)) > 0) {
copyTo.write(buffer, 0, length);
}
@@ -50,7 +50,7 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
}
@Override
public void onCreate(Bundle bundle) {
public void onCreate(Bundle bundle){
super.onCreate(bundle);
int vtosterXml = getIdentifier("empty", "xml");
@@ -86,16 +86,16 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
});
}
PreferencesUtil.addListPreference(this, "msg_blur_radius", "disabled", AndroidUtils.getString("filter_blur"), AndroidUtils.getArray("filter_types"), new String[]{
PreferencesUtil.addListPreference(this, "msg_blur_radius", "disabled", AndroidUtils.getString("filter_blur"), AndroidUtils.getArray("filter_types"), new String[] {
"disabled", "low", "med", "high"
});
PreferencesUtil.addListPreference(this, "msg_dim", "off", AndroidUtils.getString("filter_dim"), AndroidUtils.getArray("filter_dim_types"), new String[]{
PreferencesUtil.addListPreference(this, "msg_dim", "off", AndroidUtils.getString("filter_dim"), AndroidUtils.getArray("filter_dim_types"), new String[] {
"off", "dim_black", "dim_white"
});
PreferencesUtil.addListPreference(this, "msg_mosaic", "disabled", AndroidUtils.getString("filter_mosaic"), AndroidUtils.getArray("filter_types"), new String[]{
PreferencesUtil.addListPreference(this, "msg_mosaic", "disabled", AndroidUtils.getString("filter_mosaic"), AndroidUtils.getArray("filter_types"), new String[] {
"disabled", "low", "med", "high"
});
@@ -199,13 +199,14 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
}
@Override
public void onActivityResult(int i, int i1, @Nullable Intent intent) {
public void onActivityResult(int i, int i1, @Nullable Intent intent){
super.onActivityResult(i, i1, intent);
if (intent == null || intent.getData() == null)
return;
try {
removeWallpaper();
InputStream fileInputStream = requireActivity().getContentResolver().openInputStream(intent.getData());
OutputStream outputStream = new FileOutputStream(getWallpaperFile());
@@ -216,20 +217,21 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment {
if (i == 1488) {
mWPPreviewPref.redraw();
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(requireActivity(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
}
private void removeStickCache() {
private void removeStickCache(){
SharedPreferences prefs2 = getContext().getSharedPreferences("stickers_storage", Context.MODE_PRIVATE);
prefs2.edit().clear().apply();
ImEngineProvider.b().a();
}
@Override
public int T4() {
public int T4(){
return getIdentifier("wallpapers", "string");
}
}
@@ -1,6 +1,6 @@
package ru.vtosters.lite.ui.wallpapers;
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.getWallpaper;
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.getFilteredFile;
import static ru.vtosters.lite.ui.wallpapers.WallpapersHooks.getWallpaperFile;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
@@ -18,31 +18,31 @@ import androidx.recyclerview.widget.RecyclerView;
import ru.vtosters.lite.ui.adapters.MessagesPreviewAdapter;
public class WallpaperPreferences extends Preference {
public class WallpaperPreferences extends Preference{
private MessagesPreviewAdapter mAdapter;
RecyclerView mRecyclerView;
ImageView mChatBackground;
private MessagesPreviewAdapter mAdapter;
public WallpaperPreferences(Context context) {
public WallpaperPreferences(Context context){
this(context, null, -1, -1);
}
public WallpaperPreferences(Context context, AttributeSet attributeSet) {
public WallpaperPreferences(Context context, AttributeSet attributeSet){
this(context, attributeSet, -1, -1);
}
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr) {
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr){
this(context, attributeSet, defStyleAttr, -1);
}
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr, int i1) {
public WallpaperPreferences(Context context, AttributeSet attributeSet, int defStyleAttr, int i1){
super(context, attributeSet, defStyleAttr, i1);
setLayoutResource(getIdentifier("wppreview", "layout"));
}
@Override
public void onBindViewHolder(PreferenceViewHolder preferenceViewHolder) {
public void onBindViewHolder(PreferenceViewHolder preferenceViewHolder){
super.onBindViewHolder(preferenceViewHolder);
mRecyclerView = (RecyclerView) preferenceViewHolder.findViewById(getIdentifier("install_btn_container", "id"));
@@ -56,17 +56,17 @@ public class WallpaperPreferences extends Preference {
requestBg();
}
private void requestBg() {
final Drawable drawable = getWallpaper();
private void requestBg(){
final Drawable drawable = getFilteredFile();
if (drawable != null && getWallpaperFile().exists())
if (drawable != null && getWallpaperFile() != null)
mChatBackground.setImageDrawable(drawable);
else
mChatBackground.setImageDrawable(null);
}
@SuppressLint("NotifyDataSetChanged")
void redraw() {
void redraw(){
mAdapter.notifyDataSetChanged();
requestBg();
}
@@ -1,50 +1,75 @@
package ru.vtosters.lite.ui.wallpapers;
import static com.vk.im.engine.h.im_bg_chat;
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getBlurredWallpaper;
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getDimmed;
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getFilteredDrawable;
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getMonochrome;
import static ru.vtosters.lite.ui.wallpapers.ImageFilters.getMosaic;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.hasVerification;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import ru.vtosters.lite.utils.AndroidUtils;
import ru.vtosters.lite.utils.ThemesUtils;
import vigo.sdk.Log;
public class WallpapersHooks {
public class WallpapersHooks{
private static final boolean compress = getBoolValue("compresswp", true);
private static File mWallpaperFile;
private static File mWallpaperFilteredFile; // TODO
private static Drawable mWallpaper;
private static boolean mUpdateWallpaperRequested = true;
private static boolean mUpdateWallpaperFileRequested = true;
public static File getWallpaperFile() {
public static File getWallpaperFile(){
if (mWallpaperFile == null) {
return mWallpaperFile = new File(getGlobalContext().getFilesDir(), "wallpaper.png");
mWallpaperFile = new File(getGlobalContext().getFilesDir(), "wallpaper.webp");
}
return mWallpaperFile;
}
private static Boolean eligibleWallpaperFile(File file) {
public static Drawable getFilteredFile(){
File file = null;
File wp = mWallpaperFile;
String temp = getGlobalContext().getFilesDir() + File.separator + "filteredwp.webp";
if (wp != null && mUpdateWallpaperFileRequested) {
try {
file = new File(temp);
file.createNewFile();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
((BitmapDrawable) getFilteredDrawable(Drawable.createFromPath(wp.getAbsolutePath()))).getBitmap().compress(Bitmap.CompressFormat.WEBP, (compress ? 80 : 95), bos);
byte[] bitmapdata = bos.toByteArray();
FileOutputStream fos = new FileOutputStream(file);
fos.write(bitmapdata);
fos.flush();
fos.close();
} catch (Exception e) {
Log.d("Wallpapers", e.getMessage());
}
mUpdateWallpaperFileRequested = false;
}
try {
return Drawable.createFromPath(temp);
} catch (Exception e) {
return Drawable.createFromPath(file.getAbsolutePath());
}
}
private static Boolean eligibleWallpaperFile(File file){
if (file.length() >= 6291456) {
sendToast("Размер файла превышает лимит 6 MB");
removeWallpaper();
@@ -54,70 +79,26 @@ public class WallpapersHooks {
}
}
public static File compress(File file){
return file;
// try {
// BitmapFactory.Options o = new BitmapFactory.Options();
// o.inJustDecodeBounds = true;
// o.inSampleSize = 6;
//
// FileInputStream inputStream = new FileInputStream(file);
// BitmapFactory.decodeStream(inputStream, null, o);
// inputStream.close();
//
// final int REQUIRED_SIZE=200;
//
// int scale = 1;
// while(o.outWidth / scale / 2 >= REQUIRED_SIZE && o.outHeight / scale / 2 >= REQUIRED_SIZE) {
// scale *= 2;
// }
//
// BitmapFactory.Options o2 = new BitmapFactory.Options();
// o2.inSampleSize = scale;
// inputStream = new FileInputStream(file);
//
// Bitmap selectedBitmap = BitmapFactory.decodeStream(inputStream, null, o2);
// inputStream.close();
//
// File outPutFile = File.createTempFile("wallpaper_temp","image");
//
// FileOutputStream outputStream = new FileOutputStream(outPutFile);
//
// selectedBitmap.compress(Bitmap.CompressFormat.PNG, 85 , outputStream);
//
// outputStream.close();
//
// return outPutFile;
// } catch (Exception e) {
// Log.d("Wallpapers", e.getMessage());
// return file;
// }
}
public static void setBg(View view) {
// if (getWallpaper() != null) {
// ((ImageView) view).setImageDrawable(getWallpaper()); // set picture to background
// return;
// }
public static void setBg(View view){
if (getWallpaper() != null) {
((ImageView) view).setImageDrawable(getFilteredFile()); // set picture to background
return;
}
view.setBackgroundColor(ThemesUtils.getColorFromAttr(im_bg_chat)); // set default bg color
}
public static String getWallpaperUrl() {
// var file = getWallpaperFile();
//
// if (file.exists() && eligibleWallpaperFile(file)) {
// if (getBoolValue("compresswp", true)) {
// return compress(file).getAbsolutePath();
// } else {
// return file.getAbsolutePath();
// }
// }
public static String getWallpaperUrl(){
var file = getWallpaperFile();
if (file.exists() && eligibleWallpaperFile(file)) {
return file.getAbsolutePath();
}
return "default";
}
public static Drawable getWallpaper() {
public static Drawable getWallpaper(){
if (mWallpaper == null || mUpdateWallpaperRequested) {
String url = getWallpaperUrl();
@@ -131,26 +112,9 @@ public class WallpapersHooks {
return null;
}
if (!getPreferences().getString("msg_blur_radius", "disabled").equals("disabled")) {
mWallpaper = getBlurredWallpaper(drawable, getRadius());
} else {
mWallpaper = drawable;
}
if (!getPreferences().getString("msg_dim", "off").equals("off")) {
mWallpaper = getDimmed(mWallpaper);
}
mWallpaper = drawable;
if (!getPreferences().getString("msg_mosaic", "disabled").equals("disabled")) {
mWallpaper = getMosaic(mWallpaper);
}
if (hasVerification()) {
if (getPreferences().getBoolean("msg_monochrome", false)) {
mWallpaper = getMonochrome(mWallpaper);
}
mWallpaper = getFilteredDrawable(mWallpaper);
}
mWallpaper = getFilteredDrawable(mWallpaper);
mUpdateWallpaperRequested = false;
}
@@ -158,25 +122,14 @@ public class WallpapersHooks {
return mWallpaper;
}
public static void requestUpdateWallpaper() {
public static void requestUpdateWallpaper(){
mUpdateWallpaperRequested = true;
mUpdateWallpaperFileRequested = true;
}
private static int getRadius() {
public static String getRadiusSummary(){
String radius = getPreferences().getString("msg_blur_radius", "disabled");
switch (radius) {
case "low":
return 8;
case "med":
return 14;
default:
return 20;
}
}
public static String getRadiusSummary() {
String radius = getPreferences().getString("msg_blur_radius", "disabled");
switch (radius) {
switch(radius) {
case "low":
return AndroidUtils.getString("wallpapers_low");
case "med":
@@ -188,21 +141,21 @@ public class WallpapersHooks {
}
}
public static String getDimmingSummary() {
public static String getDimmingSummary(){
String radius = getPreferences().getString("msg_dim", "disabled");
switch (radius) {
switch(radius) {
case "dim_black":
return AndroidUtils.getString("wallpapers_dim_black");
case "dim_white":
return AndroidUtils.getString("wallpapers_dim_white");
return AndroidUtils.getString("wallpapers_dim_white");
default:
return AndroidUtils.getString("wallpapers_disabled");
}
}
public static String getMosaicSummary() {
public static String getMosaicSummary(){
String radius = getPreferences().getString("msg_mosaic", "disabled");
switch (radius) {
switch(radius) {
case "low":
return AndroidUtils.getString("wallpapers_low");
case "med":
@@ -215,7 +168,13 @@ public class WallpapersHooks {
}
public static void removeWallpaper() {
getWallpaperFile().delete();
public static void removeWallpaper(){
try {
new File(getGlobalContext().getFilesDir(), "wallpaper.webp").delete();
new File(getGlobalContext().getFilesDir(), "filteredwp.webp").delete();
mWallpaperFile = null;
} catch (Exception e) {
Log.d("Wallpapers", e.getMessage());
}
}
}
@@ -12,7 +12,6 @@ import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import java.security.MessageDigest;
@@ -39,14 +38,13 @@ public class AndroidUtils {
return PreferenceManager.getDefaultSharedPreferences(getGlobalContext()).edit();
} // Edit SharedPreferences
@NonNull
public static Context getGlobalContext() {
try {
return ReflectionUtils.invokeStaticMethod("android.app.AppGlobals", "getInitialApplication");
} catch (Exception e) {
e.printStackTrace();
Log.d("GlobalContext", "Error while fetching context via refl");
}
return null;
return null; // need fix for a13+ cuz google shit disabled global context via refl
} // Getting the global context through reflection to use context on application initialization
public static Resources getResources() {
@@ -18,8 +18,6 @@ import com.vk.stickers.Stickers;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import b.h.g.m.FileUtils;
public class CacheUtils {
private static CacheUtils sInstance = new CacheUtils();
public long size = 0;
@@ -30,10 +28,6 @@ public class CacheUtils {
return sInstance;
}
public static void deleteCache() {
IOUtils.deleteRecursive(getGlobalContext().getCacheDir());
}
@SuppressLint("DefaultLocale")
public static String humanReadableByteCountBin(long bytes) {
long absB = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes);
@@ -58,7 +52,6 @@ public class CacheUtils {
VKImageLoader.e();
ImAudioMsgPlayerProvider.b().e(PlayerActionSources.a);
ImAudioMsgPlayerProvider.b().d(PlayerActionSources.a);
FileUtils.l();
Stickers.l.c();
ImEngineExt.a(ImEngine1.a());
AutoPlayCacheHolder.d.a();
@@ -1,119 +0,0 @@
package ru.vtosters.lite.utils;
import android.annotation.TargetApi;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.DocumentsContract;
import androidx.annotation.Nullable;
import java.io.File;
import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.List;
// https://stackoverflow.com/questions/34927748/android-5-0-documentfile-from-tree-uri/36162691#36162691
public final class FileUriUtils {
private static final String PRIMARY_VOLUME_NAME = "primary";
@Nullable
public static String getFullPathFromTreeUri(@Nullable final Uri treeUri, Context con) {
if (treeUri == null) return null;
String volumePath = getVolumePath(getVolumeIdFromTreeUri(treeUri),con);
if (volumePath == null) return File.separator;
if (volumePath.endsWith(File.separator))
volumePath = volumePath.substring(0, volumePath.length() - 1);
String documentPath = getDocumentPathFromTreeUri(treeUri);
if (documentPath.endsWith(File.separator))
documentPath = documentPath.substring(0, documentPath.length() - 1);
if (documentPath.length() > 0) {
if (documentPath.startsWith(File.separator))
return volumePath + documentPath;
else
return volumePath + File.separator + documentPath;
}
else return volumePath;
}
private static String getVolumePath(final String volumeId, Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
return getVolumePathForAndroid11AndAbove(volumeId, context);
else
return getVolumePathBeforeAndroid11(volumeId, context);
}
private static String getVolumePathBeforeAndroid11(final String volumeId, Context context){
try {
StorageManager mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
Class<?> storageVolumeClazz = Class.forName("android.os.storage.StorageVolume");
Method getVolumeList = mStorageManager.getClass().getMethod("getVolumeList");
Method getUuid = storageVolumeClazz.getMethod("getUuid");
Method getPath = storageVolumeClazz.getMethod("getPath");
Method isPrimary = storageVolumeClazz.getMethod("isPrimary");
Object result = getVolumeList.invoke(mStorageManager);
final int length = Array.getLength(result);
for (int i = 0; i < length; i++) {
Object storageVolumeElement = Array.get(result, i);
String uuid = (String) getUuid.invoke(storageVolumeElement);
Boolean primary = (Boolean) isPrimary.invoke(storageVolumeElement);
if (primary && PRIMARY_VOLUME_NAME.equals(volumeId)) // primary volume?
return (String) getPath.invoke(storageVolumeElement);
if (uuid != null && uuid.equals(volumeId)) // other volumes?
return (String) getPath.invoke(storageVolumeElement);
}
// not found.
return null;
} catch (Exception ex) {
return null;
}
}
@TargetApi(Build.VERSION_CODES.R)
private static String getVolumePathForAndroid11AndAbove(final String volumeId, Context context) {
try {
StorageManager mStorageManager = (StorageManager) context.getSystemService(Context.STORAGE_SERVICE);
List<StorageVolume> storageVolumes = mStorageManager.getStorageVolumes();
for (StorageVolume storageVolume : storageVolumes) {
// primary volume?
if (storageVolume.isPrimary() && PRIMARY_VOLUME_NAME.equals(volumeId))
return storageVolume.getDirectory().getPath();
// other volumes?
String uuid = storageVolume.getUuid();
if (uuid != null && uuid.equals(volumeId))
return storageVolume.getDirectory().getPath();
}
// not found.
return null;
} catch (Exception ex) {
return null;
}
}
private static String getVolumeIdFromTreeUri(final Uri treeUri) {
final String docId = DocumentsContract.getTreeDocumentId(treeUri);
final String[] split = docId.split(":");
if (split.length > 0) return split[0];
else return null;
}
private static String getDocumentPathFromTreeUri(final Uri treeUri) {
final String docId = DocumentsContract.getTreeDocumentId(treeUri);
final String[] split = docId.split(":");
if ((split.length >= 2) && (split[1] != null)) return split[1];
else return File.separator;
}
}
@@ -23,14 +23,14 @@ import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import ru.vtosters.lite.hooks.JsonInjectors;
import ru.vtosters.lite.hooks.AdBlockHook;
public class NewsFeedFiltersUtils {
public class NewsFeedFiltersUtils{
public static List<String> mFilters;
public static List<String> mFiltersNames;
public static List<String> mFiltersLinks;
public static void setupFilters() {
public static void setupFilters(){
mFilters = new ArrayList<>();
mFiltersNames = new ArrayList<>();
mFiltersLinks = new ArrayList<>();
@@ -57,43 +57,53 @@ public class NewsFeedFiltersUtils {
}
}
public static void getFilter(String boolname, String filename, List<String> list) {
if (getBoolValue(boolname, true)) {
public static void getFilter(String boolname, String filename, List<String> list){
var ctx = getGlobalContext();
if (getBoolValue(boolname, false)) {
try {
var scanner = new Scanner(getGlobalContext().getAssets().open(filename));
while (scanner.hasNextLine()) {
var line = scanner.nextLine();
if (!line.isEmpty())
list.add(line.toLowerCase());
Scanner scanner;
if (ctx != null) {
scanner = new Scanner(ctx.getAssets().open(filename));
while(scanner.hasNextLine()) {
var line = scanner.nextLine();
if (!line.isEmpty())
list.add(line.toLowerCase());
}
}
} catch (IOException e) {
e.printStackTrace();
Log.d("NewsFeedFiltersUtils", e.getMessage());
}
}
} // Get needed filter list from assets
public static boolean injectFiltersReposts(JSONObject obj) throws JSONException {
public static boolean injectFiltersReposts(JSONObject obj) throws JSONException{
if (getBoolValue("cringerepost", false) && obj.has("copy_history")) {
var copyHistoryNode = obj.optJSONArray("copy_history");
for (int i = 0; i < copyHistoryNode.length(); i++) {
var item = copyHistoryNode.optJSONObject(i);
var text = item.optString("text");
if (copyHistoryNode != null && copyHistoryNode.length() != 0) {
for (int i = 0; i < copyHistoryNode.length(); i++) {
var item = copyHistoryNode.optJSONObject(i);
var text = item.optString("text");
if (isBadNews(text)) {
if (dev())
Log.d("RepostFilter", "Fetched repost ad (isBadNews), owner id " + item.optString("owner_id") + ", text: " + text);
return true;
} else if (JsonInjectors.isAds(item, item.optString("post_type"))) {
if (dev())
Log.d("RepostFilter", "Fetched repost ad (ads), owner id " + item.optString("owner_id") + ", text: " + text);
return true;
}
for (String filter : mFiltersLinks) {
if (text.contains(filter)) {
if (isBadNews(text)) {
if (dev())
Log.d("RepostFilter", "Fetched repost ad, owner id " + item.optString("owner_id") + ", text: " + text);
Log.d("RepostFilter", "Fetched repost ad (isBadNews), owner id " + item.optString("owner_id") + ", text: " + text);
return true;
} else if (AdBlockHook.isAds(item, item.optString("post_type"))) {
if (dev())
Log.d("RepostFilter", "Fetched repost ad (ads), owner id " + item.optString("owner_id") + ", text: " + text);
return true;
}
if (mFiltersLinks != null) {
for (String filter : mFiltersLinks) {
if (text.contains(filter)) {
if (dev())
Log.d("RepostFilter", "Fetched repost ad, owner id " + item.optString("owner_id") + ", text: " + text);
return true;
}
}
}
}
}
@@ -101,65 +111,89 @@ public class NewsFeedFiltersUtils {
return false;
}
public static boolean checkCopyright(JSONObject json) throws JSONException {
public static boolean checkCopyright(JSONObject json) throws JSONException{
if (json.has("copyright")) {
if (copyright_post()) return true;
var copyright = json.optJSONObject("copyright");
var copyrightName = copyright.getString("name").toLowerCase();
var copyrightLink = copyright.getString("link").toLowerCase();
for (String filter : mFiltersNames) {
if (copyrightName.contains(filter)) return true;
String copyrightName = null;
if (copyright != null) {
copyrightName = copyright.getString("name").toLowerCase();
}
for (String filter : mFiltersLinks) {
if (copyrightLink.contains(filter)) return true;
String copyrightLink = null;
if (copyright != null) {
copyrightLink = copyright.getString("link").toLowerCase();
}
if (mFiltersNames != null) {
for (String filter : mFiltersNames) {
if (copyrightName != null && copyrightName.contains(filter)) return true;
}
}
if (mFiltersLinks != null) {
for (String filter : mFiltersLinks) {
if (copyrightLink != null && copyrightLink.contains(filter)) return true;
}
}
}
return false;
}
public static boolean isRecomsGroup(String src) {
public static boolean isRecomsGroup(String src){
return authorsrecomm() && src.equals("recommended_groups");
}
public static boolean isMusicBlock(String src) {
public static boolean isMusicBlock(String src){
return authorsrecomm() && (src.equals("recommended_audios") || src.equals("recommended_artists") || src.equals("recommended_playlists"));
}
public static boolean isNewsBlock(String src) {
public static boolean isNewsBlock(String src){
return ads() && src.equals("tags_suggestions");
}
public static String getAllFilters() {
public static String getAllFilters(){
return getPrefsValue("spamfilters");
}
public static boolean isBadNews(String text) {
public static boolean isBadNews(String text){
var textInLowerCase = text.toLowerCase();
for (String filter : mFilters) {
if (textInLowerCase.contains(filter)) {
if (dev())
Log.d("VTLite", text);
return true;
if (mFilters != null) {
for (String filter : mFilters) {
if (textInLowerCase.contains(filter)) {
if (dev())
Log.d("NewsfeedAdBlockV2", text);
return true;
}
}
}
return false;
}
public static boolean checkCaption(JSONObject postJson) {
public static boolean checkCaption(JSONObject postJson){
if (postJson.has("caption")) {
if (captions()) return true;
var caption = postJson.optJSONObject("caption");
if (postsrecomm()) {
try {
var type = caption.getString("type");
return type.equals("explorebait") || // Может быть интересно
type.equals("shared") || // Поделился записью
type.equals("digest") || // Рекомедации
type.equals("commented") || // Комментирует
type.equals("voted"); // Проголосовал в опросе
String type;
if (caption != null) {
type = caption.getString("type");
return type.equals("explorebait") || // Может быть интересно
type.equals("shared") || // Поделился записью
type.equals("digest") || // Рекомедации
type.equals("commented") || // Комментирует
type.equals("voted"); // Проголосовал в опросе
}
} catch (JSONException e) {
Log.d("checkCaption", "Caption error");
}
@@ -169,29 +203,29 @@ public class NewsFeedFiltersUtils {
return false;
}
public static boolean isAds(String optString) {
public static boolean isAds(String optString){
return ads() && (optString.equals("ads_easy_promote") ||
optString.equals("promo_button") ||
optString.equals("app_widget") ||
optString.equals("ads"));
}
public static boolean isAuthorRecommendations(String optString) {
public static boolean isAuthorRecommendations(String optString){
return authorsrecomm() && optString.equals("authors_rec");
}
public static boolean isPostRecommendations(String optString) {
public static boolean isPostRecommendations(String optString){
return postsrecomm() && (optString.equals("live_recommended") ||
optString.equals("inline_user_rec"));
}
public static boolean isFriendsRecommendations(String optString) {
public static boolean isFriendsRecommendations(String optString){
return friendsrecomm() && (optString.equals("user_rec") ||
optString.equals("friends_recommendations") ||
optString.equals("friends_recomm"));
}
public static boolean isGroupAds(JSONObject obj) {
public static boolean isGroupAds(JSONObject obj){
return adsgroup() && obj.optInt("marked_as_ads", 0) == 1;
}
}
@@ -4,10 +4,7 @@ import static java.lang.Long.MAX_VALUE;
import static ru.vtosters.lite.proxy.ProxyUtils.setProxy;
import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
import static ru.vtosters.lite.utils.CacheUtils.getInstance;
import static ru.vtosters.lite.utils.DeletedMessagesHandler.reloadMessagesList;
import static ru.vtosters.lite.utils.NewsFeedFiltersUtils.setupFilters;
import static ru.vtosters.lite.utils.SignatureChecker.validateAppSignature;
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
@@ -18,13 +15,11 @@ import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.preference.PreferenceManager;
import com.vtosters.lite.data.Users;
import com.vtosters.lite.fragments.SettingsListFragment;
import java.io.File;
import java.security.NoSuchAlgorithmException;
import ru.vtosters.lite.ui.fragments.VTSettings;
@@ -42,6 +37,8 @@ public class Preferences {
public static void forceOffline() {
edit().putBoolean("isdark", isDarkTheme()).commit();
setupFilters();
if (setoffline() && offline()) {
Users.a();
}
@@ -326,7 +323,7 @@ public class Preferences {
}
public static boolean checkupdates() {
return getBoolValue("checkupdates", true) && isValidSignature();
return !getBoolValue("isRoamingState", false) && isValidSignature();
}
public static boolean isValidSignature() {
@@ -377,28 +374,4 @@ public class Preferences {
}
return origquality;
}
public static File getDownloadsDir() {
return new File(getPreferences().getString(
"downloads_directory",
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath()));
}
public static File getPhotosDir() {
return new File(getPreferences().getString(
"photos_directory",
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath()));
}
public static File getVideosDir() {
return new File(getPreferences().getString(
"videos_directory",
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getAbsolutePath()));
}
public static File getMusicDir() {
return new File(getPreferences().getString(
"music_directory",
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath()));
}
}
@@ -34,7 +34,7 @@ public class VTVerifications {
public static void load(Context context) {
var prefs = context.getSharedPreferences("vt_another_data", 0);
if (!NetworkUtils.isNetworkConnected() && prefs.contains("ids")) {
if ((!NetworkUtils.isNetworkConnected() || getBoolValue("isRoamingState", false)) && prefs.contains("ids")) {
parseJson(prefs.getString("ids", "[]"));
return;
}
+1 -2
View File
@@ -5433,7 +5433,7 @@
<string name="vtlfeedwork">Прочее</string>
<string name="vtlfeedreload">Автоматическое обновление ленты</string>
<string name="vtlfeedcache">Кешировать посты в ленте</string>
<string name="vtlrecommendmark">Отключить посты с пометкой рекомендовано</string>
<string name="vtlrecommendmark">Отключить посты с пометкой</string>
<string name="vtlmsgtails">Хвосты сообщений</string>
<string name="vtlmsgflat">Плоские сообщения</string>
<string name="vtlupdmsg">Обновить</string>
@@ -5651,7 +5651,6 @@
<string name="screenshotdetect_summ">Отключить уведомление о том, что вы сделали скриншот</string>
<string name="hideDeviceInfo_title">Отключить отправку метрики</string>
<string name="hideDeviceInfo_summ">Отключить отправку информации об устройстве пользователя и вашем местоположении</string>
<string name="newadblock_title">Использовать новый AdBlock (Beta)</string>
<string name="podcastcatalog_title">Добавить каталог подкастов</string>
<string name="useNewSettings_title">Использовать новые настройки</string>
<string name="musicFixNew_title">Фикс музыки v2</string>
+1 -2
View File
@@ -5567,7 +5567,7 @@ Does not affect vk.cc links"</string>
<string name="vtlfeedwork">Other</string>
<string name="vtlfeedreload">Automatic feed update</string>
<string name="vtlfeedcache">Cache feed posts</string>
<string name="vtlrecommendmark">Disable posts with recommended mark</string>
<string name="vtlrecommendmark">Disable posts with mark</string>
<string name="vtlmsgtails">Message tails</string>
<string name="vtlmsgflat">Flat Messages</string>
<string name="vtlupdmsg">Update</string>
@@ -5785,7 +5785,6 @@ You need to restart the application to apply proxy settings"</string>
<string name="screenshotdetect_summ">Turn off the notification that you took a screenshot</string>
<string name="hideDeviceInfo_title">Disable sending metric</string>
<string name="hideDeviceInfo_summ">Disable sending information about the user\'s device and your location</string>
<string name="newadblock_title">Use new AdBlock (Beta)</string>
<string name="podcastcatalog_title">Add podcast catalog</string>
<string name="useNewSettings_title">Use new settings</string>
<string name="musicFixNew_title">Music fix v2</string>
-4
View File
@@ -22,10 +22,6 @@
android:key="calls"
android:summary="@string/messages_interface_calls_summary"
android:title="@string/vtlcalls" />
<com.vtosters.lite.ui.MaterialSwitchPreference
android:defaultValue="true"
android:key="newadblock"
android:title="@string/newadblock_title" />
<com.vtosters.lite.ui.MaterialSwitchPreference
android:defaultValue="false"
android:key="podcastcatalog"
+1 -1
View File
@@ -134,7 +134,7 @@
<com.vtosters.lite.ui.MaterialSwitchPreference
android:defaultValue="false"
android:key="donotgetads"
android:summary="Не запрашивать рекламу и рекомендации\nМогуть быть проблемы"
android:summary="Не запрашивать рекламу и рекомендации\n\nМогуть быть проблемы"
android:title="Не пытаться получать рекламу" />
</PreferenceCategory>
</PreferenceScreen>
-18
View File
@@ -24,24 +24,6 @@
android:summary="@string/pollresults_summ"
android:title="@string/pollresults_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/vtl_downloads_title">
<Preference
android:key="downloads_directory"
android:summary="@string/current_download_folder"
android:title="@string/folder_for_downloads" />
<Preference
android:key="photos_directory"
android:summary="@string/current_download_folder"
android:title="@string/folder_for_photos" />
<Preference
android:key="videos_directory"
android:summary="@string/current_download_folder"
android:title="@string/folder_for_videos" />
<Preference
android:key="music_directory"
android:summary="@string/current_download_folder"
android:title="@string/folder_for_music" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/sett_media">
<com.vtosters.lite.ui.MaterialSwitchPreference
android:defaultValue="true"
-3
View File
@@ -19,9 +19,6 @@
<Preference
android:key="applicationstop"
android:title="@string/killappbtn" />
<Preference
android:key="resetfolders"
android:title="@string/reset_folders_locations" />
<Preference
android:key="tokencopy"
android:title="@string/copytokenbtn" />
@@ -539,10 +539,6 @@
move-result-object p1
invoke-static {p1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object p1
const/4 v0, 0x0
if-eqz p1, :cond_7
+16 -28
View File
@@ -187,17 +187,13 @@
.locals 2
.line 6
# invoke-static {}, Lb/h/g/m/FileUtils;->getVKDir()Ljava/io/File;
#
# move-result-object v0
#
# const-string v1, "Downloads"
#
# invoke-static {v0, v1}, Lb/h/g/m/FileUtils;->a(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;
#
# move-result-object v0
invoke-static {}, Lb/h/g/m/FileUtils;->getVKDir()Ljava/io/File;
invoke-static {}, Lru/vtosters/lite/utils/Preferences;->getDownloadsDir()Ljava/io/File;
move-result-object v0
const-string v1, "Downloads"
invoke-static {v0, v1}, Lb/h/g/m/FileUtils;->a(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;
move-result-object v0
@@ -1811,18 +1807,14 @@
.method private static c()Ljava/io/File;
.locals 2
# .line 1
# invoke-static {}, Lb/h/g/m/FileUtils;->getVKDir()Ljava/io/File;
.line 1
invoke-static {}, Lb/h/g/m/FileUtils;->getVKDir()Ljava/io/File;
# move-result-object v0
move-result-object v0
# const-string v1, "Photos"
const-string v1, "Photos"
# invoke-static {v0, v1}, Lb/h/g/m/FileUtils;->a(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;
# move-result-object v0
invoke-static {}, Lru/vtosters/lite/utils/Preferences;->getPhotosDir()Ljava/io/File;
invoke-static {v0, v1}, Lb/h/g/m/FileUtils;->a(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;
move-result-object v0
@@ -2109,18 +2101,14 @@
.method private static e()Ljava/io/File;
.locals 2
# .line 1
# invoke-static {}, Lb/h/g/m/FileUtils;->getVKDir()Ljava/io/File;
.line 1
invoke-static {}, Lb/h/g/m/FileUtils;->getVKDir()Ljava/io/File;
# move-result-object v0
move-result-object v0
# const-string v1, "Videos"
const-string v1, "Videos"
# invoke-static {v0, v1}, Lb/h/g/m/FileUtils;->a(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;
# move-result-object v0
invoke-static {}, Lru/vtosters/lite/utils/Preferences;->getVideosDir()Ljava/io/File;
invoke-static {v0, v1}, Lb/h/g/m/FileUtils;->a(Ljava/io/File;Ljava/lang/String;)Ljava/io/File;
move-result-object v0
@@ -122,17 +122,6 @@
move-result-object v10
invoke-static {v10}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v11
if-nez v11, :cond_229
add-int/lit8 v9, v9, 0x1
goto :goto_0
:cond_229
if-eqz v10, :cond_0
.line 7
@@ -268,7 +257,7 @@
goto :goto_2
:cond_6
const-string v0, "null"
const-string v0, "ads"
.line 14
:goto_2
@@ -539,19 +528,6 @@
move-object/from16 v21, v5
invoke-static {v13}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v16
if-nez v16, :cond_228
add-int/lit8 v12, v12, 0x1
move-object/from16 v5, v21
goto :goto_7
:cond_228
if-eqz v13, :cond_c
.line 34
@@ -703,8 +679,6 @@
.line 42
:goto_c
const/4 v2, 0x0
new-instance v32, Lcom/vk/dto/discover/DiscoverItem;
move-object/from16 v4, v32
@@ -65,17 +65,6 @@
move-result-object v2
invoke-static {v2}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v10
if-nez v10, :cond_2
add-int/lit8 v0, v0, 0x1
goto :goto_0
:cond_2
if-eqz v2, :cond_0
.line 47
@@ -242,17 +231,6 @@
move-result-object v2
invoke-static {v2}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v10
if-nez v10, :cond_2
add-int/lit8 v0, v0, 0x1
goto :goto_0
:cond_2
if-eqz v2, :cond_0
.line 3
@@ -89,6 +89,10 @@
move-result-object v1
invoke-static {v1}, Lru/vtosters/lite/hooks/AdBlockHook;->discoverInject(Lorg/json/JSONObject;)Lorg/json/JSONObject;
move-result-object v1
iget-object v2, p0, Lcom/vk/api/discover/DiscoverGet;->F:Ljava/lang/String;
const/4 v3, 0x0
@@ -171,7 +171,7 @@
.line 14
:cond_4
invoke-static {v4}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {v4}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object v4
@@ -187,19 +187,6 @@
move-result-object v7
invoke-static {v7}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v9
if-nez v9, :cond_99
add-int/lit8 v3, v3, 0x1
goto :goto_4
:cond_99
invoke-static {v7, v2}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
.line 16
@@ -235,7 +235,7 @@
.line 20
:cond_5
invoke-static {v11}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {v11}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object v11
@@ -251,19 +251,6 @@
move-result-object v0
invoke-static {v0}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v15
if-nez v15, :cond_99
add-int/lit8 v10, v10, 0x1
goto :goto_5
:cond_99
invoke-static {v0, v6}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
.line 22
@@ -208,7 +208,7 @@
.method public constructor <init>(Lorg/json/JSONObject;Z)V
.locals 7
invoke-static {p1, p2}, Lru/vtosters/lite/hooks/JsonInjectors;->storiesads(Lorg/json/JSONObject;Z)Lorg/json/JSONObject;
invoke-static {p1, p2}, Lru/vtosters/lite/hooks/AdBlockHook;->storiesads(Lorg/json/JSONObject;Z)Lorg/json/JSONObject;
move-result-object p1
@@ -398,7 +398,7 @@
const v0, 0x0
invoke-static {p1, v0}, Lru/vtosters/lite/hooks/JsonInjectors;->storiesads(Lorg/json/JSONObject;Z)Lorg/json/JSONObject;
invoke-static {p1, v0}, Lru/vtosters/lite/hooks/AdBlockHook;->storiesads(Lorg/json/JSONObject;Z)Lorg/json/JSONObject;
move-result-object p1
@@ -1808,7 +1808,7 @@
.end method
.method public onCreateView(Landroid/view/LayoutInflater;Landroid/view/ViewGroup;Landroid/os/Bundle;)Landroid/view/View;
.locals 8
.locals 10
const/4 v0, 0x0
@@ -2007,7 +2007,11 @@
.line 27
new-instance v5, Lcom/vk/discover/ThemedFeedFragment$a;
invoke-direct {v5, v4, v2, v4}, Lcom/vk/discover/ThemedFeedFragment$a;-><init>(Ljava/lang/Class;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
const-class v8, Lcom/vk/discover/DiscoverFragment;
const/4 v9, 0x0
invoke-direct {v5, v8, v9, v4}, Lcom/vk/discover/ThemedFeedFragment$a;-><init>(Ljava/lang/Class;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
invoke-virtual {v5}, Lcom/vk/discover/ThemedFeedFragment$a;->i()Lcom/vk/discover/ThemedFeedFragment$a;
@@ -131,17 +131,6 @@
move-result-object v7
invoke-static {v7}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v10
if-nez v10, :cond_28
add-int/lit8 v5, v5, 0x1
goto :goto_0
:cond_28
const-string v9, "profiles.getJSONObject(i)"
invoke-static {v7, v9}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
@@ -179,17 +168,6 @@
move-result-object v6
invoke-static {v6}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v10
if-nez v10, :cond_29
add-int/lit8 v4, v4, 0x1
goto :goto_1
:cond_29
const-string v7, "groups.getJSONObject(i)"
invoke-static {v6, v7}, Lkotlin/jvm/internal/Intrinsics;->a(Ljava/lang/Object;Ljava/lang/String;)V
@@ -210,7 +188,7 @@
.line 13
:cond_2
invoke-static {p2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {p2}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object p2
@@ -227,17 +205,6 @@
move-result-object p3
invoke-static {p3}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v10
if-nez v10, :cond_30
add-int/lit8 v3, v3, 0x1
goto :goto_2
:cond_30
invoke-virtual {p3, v0, v1}, Lorg/json/JSONObject;->optString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v4
@@ -734,7 +734,7 @@
.line 37
:cond_2
:goto_2
invoke-static {v1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {v1}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object v1
@@ -749,21 +749,10 @@
move-result-object v2
invoke-static {v2}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v10
if-nez v10, :cond_70
add-int/lit8 v5, v5, 0x1
goto :goto_2
:try_end_0
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1
.line 39
:cond_70
:try_start_1
iget-object v3, p0, Lcom/vtosters/lite/api/newsfeed/NewsfeedGet;->H:Ljava/lang/String;
@@ -139,7 +139,7 @@
move-result-object v1
invoke-static {v1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {v1}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object v1
@@ -365,7 +365,7 @@
.line 14
:goto_2
invoke-static {v4}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {v4}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object v4
@@ -380,17 +380,6 @@
move-result-object v6
invoke-static {v6}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v9
if-nez v9, :cond_71
add-int/lit8 v3, v3, 0x1
goto :goto_3
:cond_71
invoke-static {v6}, Lcom/vk/dto/newsfeed/Owner;->b(Lorg/json/JSONObject;)Lcom/vk/dto/newsfeed/Owner;
move-result-object v6
@@ -411,7 +400,7 @@
.line 17
:goto_3
invoke-static {v2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {v2}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object v2
@@ -431,19 +420,6 @@
move-result-object v6
invoke-static {v6}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v9
if-nez v9, :cond_70
add-int/lit8 v3, v3, 0x1
goto :goto_3
:cond_70
invoke-static {v4, v6, p1, v1}, Lcom/vk/dto/newsfeed/entries/NewsEntryFactory;->a(Ljava/lang/String;Lorg/json/JSONObject;Landroid/util/SparseArray;Ljava/lang/String;)Lcom/vk/dto/newsfeed/entries/NewsEntry;
move-result-object v4
@@ -351,7 +351,7 @@
# virtual methods
.method public a(Lorg/json/JSONObject;)Lcom/vtosters/lite/api/wall/WallGet$Result;
.locals 11
.locals 10
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/Exception;
@@ -524,7 +524,7 @@
.line 19
:goto_2
invoke-static {p1}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {p1}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object p1
@@ -539,21 +539,10 @@
move-result-object v8
invoke-static {v8}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v10
if-nez v10, :cond_70
add-int/lit8 v4, v4, 0x1
goto :goto_2
:try_end_1
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_2
.line 21
:cond_70
:try_start_2
iget-object v9, p0, Lcom/vtosters/lite/api/wall/WallGet;->F:Ljava/lang/String;
@@ -75,7 +75,7 @@
}
.end annotation
invoke-static {p2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
invoke-static {p2}, Lru/vtosters/lite/hooks/AdBlockHook;->feedInject(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object p2
@@ -90,10 +90,6 @@
.line 15
:goto_0
invoke-static {p2}, Lru/vtosters/lite/hooks/JsonInjectors;->newsfeedadtest(Lorg/json/JSONArray;)Lorg/json/JSONArray;
move-result-object p2
invoke-virtual {p2}, Lorg/json/JSONArray;->length()I
move-result v2
@@ -105,17 +101,6 @@
move-result-object v2
invoke-static {v2}, Lru/vtosters/lite/hooks/NewsfeedHook;->injectFilters(Lorg/json/JSONObject;)Z
move-result v5
if-nez v5, :cond_70
add-int/lit8 v1, v1, 0x1
goto :goto_0
:cond_70
const-string v3, "type"
const-string v4, "post"