cleanup code
This commit is contained in:
@@ -1,58 +1,22 @@
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import static ru.vtosters.lite.utils.About.getBuildNumber;
|
||||
|
||||
public class Device {
|
||||
private String androidId;
|
||||
private String bluetoothMac;
|
||||
private String boardName;
|
||||
private String brandName;
|
||||
private String cpuAbi;
|
||||
private String deviceName;
|
||||
private String firmwareDisplay;
|
||||
private String firmwareId;
|
||||
private String manufacturerName;
|
||||
private String modelName;
|
||||
private String productName;
|
||||
private int sdkVersion;
|
||||
private String serialId;
|
||||
private String wifiMac;
|
||||
|
||||
public Device withSerialId(String str) {
|
||||
this.serialId = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withAndroidId(String str) {
|
||||
this.androidId = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withWifiMac(String str) {
|
||||
this.wifiMac = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withBluetoothMac(String str) {
|
||||
this.bluetoothMac = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withSdkVersion(int i) {
|
||||
this.sdkVersion = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withFirmwareId(String str) {
|
||||
this.firmwareId = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withFirmwareDisplay(String str) {
|
||||
this.firmwareDisplay = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withProductName(String str) {
|
||||
this.productName = str;
|
||||
return this;
|
||||
@@ -68,11 +32,6 @@ public class Device {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withCpuAbi(String str) {
|
||||
this.cpuAbi = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Device withManufacturerName(String str) {
|
||||
this.manufacturerName = str;
|
||||
return this;
|
||||
@@ -88,12 +47,7 @@ public class Device {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String toString() {
|
||||
return "Device{serialId='" + this.serialId + "', androidId='" + this.androidId + "', wifiMac='" + this.wifiMac + "', bluetoothMac='" + this.bluetoothMac + "'}";
|
||||
}
|
||||
|
||||
public String toDeviceName() {
|
||||
return "Device{sdkVersion=" + this.sdkVersion + ", productName='" + this.productName + "', deviceName='" + this.deviceName + "', boardName='" + this.boardName + "', cpuAbi='" + this.cpuAbi + "', manufacturerName='" + this.manufacturerName + "', brandName='" + this.brandName + "', modelName='" + this.modelName + "'}";
|
||||
return "Device information: " + "commit='" + getBuildNumber() + "', sdkVersion=" + this.sdkVersion + ", productName='" + this.productName + "', deviceName='" + this.deviceName + "', boardName='" + this.boardName + "', manufacturerName='" + this.manufacturerName + "', brandName='" + this.brandName + "', modelName='" + this.modelName + "'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,195 +1,11 @@
|
||||
package ru.vtosters.lite.deviceinfo;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.os.EnvironmentCompat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.Collections;
|
||||
|
||||
public class DeviceInfoCollector {
|
||||
private static final String TAG = "DeviceInfoCollector";
|
||||
|
||||
public Device collect(Context context) {
|
||||
return new Device().withSerialId(serialId()).withAndroidId(androidId(context)).withWifiMac(wifiMac(context)).withBluetoothMac(bluetoothMac(context)).withSdkVersion(Build.VERSION.SDK_INT).withFirmwareId(Build.ID).withFirmwareDisplay(Build.DISPLAY).withProductName(Build.PRODUCT).withDeviceName(Build.DEVICE).withBoardName(Build.BOARD).withCpuAbi(Build.CPU_ABI).withManufacturerName(Build.MANUFACTURER).withBrandName(Build.BRAND).withModelName(Build.MODEL);
|
||||
}
|
||||
|
||||
private String serialId() {
|
||||
String str;
|
||||
try {
|
||||
@SuppressLint("PrivateApi")
|
||||
Class<?> cls = Class.forName("android.os.SystemProperties");
|
||||
Method method = cls.getMethod("get", String.class);
|
||||
str = (String) method.invoke(cls, "gsm.sn1");
|
||||
if (isInvalidSerial(str)) {
|
||||
str = (String) method.invoke(cls, "ril.serialnumber");
|
||||
}
|
||||
if (isInvalidSerial(str)) {
|
||||
str = (String) method.invoke(cls, "ro.serialno");
|
||||
}
|
||||
if (isInvalidSerial(str)) {
|
||||
str = (String) method.invoke(cls, "sys.serialnumber");
|
||||
}
|
||||
if (isInvalidSerial(str)) {
|
||||
str = Build.SERIAL;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "Serial ID obtaining failed: ", e);
|
||||
}
|
||||
str = null;
|
||||
if (str != null) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
private String androidId(Context context) {
|
||||
return Settings.Secure.getString(context.getContentResolver(), "android_id").toLowerCase();
|
||||
}
|
||||
|
||||
private String wifiMac(Context context) {
|
||||
String wifiMacFromManager = wifiMacFromManager(context);
|
||||
if (isInvalidMac(wifiMacFromManager)) {
|
||||
wifiMacFromManager = wifiMacFromNetworkInterfaces();
|
||||
}
|
||||
if (isInvalidMac(wifiMacFromManager)) {
|
||||
wifiMacFromManager = wifiMacFromFileSystem();
|
||||
}
|
||||
if (isInvalidMac(wifiMacFromManager)) {
|
||||
wifiMacFromManager = null;
|
||||
}
|
||||
if (wifiMacFromManager != null) {
|
||||
return wifiMacFromManager.toLowerCase();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String wifiMacFromManager(Context context) {
|
||||
WifiInfo connectionInfo;
|
||||
try {
|
||||
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
if (wifiManager == null || (connectionInfo = wifiManager.getConnectionInfo()) == null) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "WiFi MAC obtaining from manager failed: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String wifiMacFromNetworkInterfaces() {
|
||||
try {
|
||||
for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
|
||||
if ("wlan0".equalsIgnoreCase(networkInterface.getName())) {
|
||||
byte[] hardwareAddress = networkInterface.getHardwareAddress();
|
||||
if (hardwareAddress == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int length = hardwareAddress.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
sb.append(String.format("%02X:", hardwareAddress[i]));
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "WiFi MAC obtaining from network interfaces failed: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String wifiMacFromFileSystem() {
|
||||
try {
|
||||
FileReader fileReader = new FileReader("/sys/class/net/wlan0/address");
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
try {
|
||||
String readLine = bufferedReader.readLine();
|
||||
bufferedReader.close();
|
||||
fileReader.close();
|
||||
return readLine;
|
||||
} catch (Throwable th) {
|
||||
th.addSuppressed(th);
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
throw th2;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "WiFi MAC obtaining from file system failed: ", e);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String bluetoothMac(Context context) {
|
||||
String bluetoothMacFromAdapter = bluetoothMacFromAdapter();
|
||||
if (isInvalidMac(bluetoothMacFromAdapter)) {
|
||||
bluetoothMacFromAdapter = bluetoothMacFromContentResolver(context);
|
||||
}
|
||||
if (isInvalidMac(bluetoothMacFromAdapter)) {
|
||||
bluetoothMacFromAdapter = null;
|
||||
}
|
||||
if (bluetoothMacFromAdapter != null) {
|
||||
return bluetoothMacFromAdapter.toLowerCase();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String bluetoothMacFromAdapter() {
|
||||
try {
|
||||
BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (defaultAdapter == null) {
|
||||
return null;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return null;
|
||||
}
|
||||
Field declaredField = defaultAdapter.getClass().getDeclaredField("mService");
|
||||
declaredField.setAccessible(true);
|
||||
Object obj = declaredField.get(defaultAdapter);
|
||||
if (obj != null) {
|
||||
return (String) obj.getClass().getMethod("getAddress").invoke(obj, new Object[0]);
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "BT MAC obtaining from adapter failed: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String bluetoothMacFromContentResolver(Context context) {
|
||||
try {
|
||||
return Settings.Secure.getString(context.getContentResolver(), "bluetooth_address");
|
||||
} catch (Exception e) {
|
||||
Log.d(TAG, "BT MAC obtaining from content resolver failed: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInvalidSerial(String str) {
|
||||
return TextUtils.isEmpty(str) || EnvironmentCompat.MEDIA_UNKNOWN.equalsIgnoreCase(str);
|
||||
}
|
||||
|
||||
private boolean isInvalidMac(String str) {
|
||||
return TextUtils.isEmpty(str) || "02:00:00:00:00:00".equalsIgnoreCase(str) || "00:00:00:00:00:00".equalsIgnoreCase(str);
|
||||
public Device collect() {
|
||||
return new Device().withSdkVersion(Build.VERSION.SDK_INT).withProductName(Build.PRODUCT).withDeviceName(Build.DEVICE).withBoardName(Build.BOARD).withManufacturerName(Build.MANUFACTURER).withBrandName(Build.BRAND).withModelName(Build.MODEL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DNRInjector {
|
||||
if (dialog != null) {
|
||||
try {
|
||||
peerId = dialog.getId();
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
Log.d("DialoggetId", "null");
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class DNRInjector {
|
||||
if (dialog != null) {
|
||||
try {
|
||||
peerId = dialog.getId();
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
Log.d("DialoggetId", "null");
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public class DNRInjector {
|
||||
if (dialog != null) {
|
||||
try {
|
||||
peerId = dialog.getId();
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
Log.d("DialoggetId", "null");
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class DNRInjector {
|
||||
if (dialog != null) {
|
||||
try {
|
||||
peerId = dialog.getId();
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
Log.d("DialoggetId", "null");
|
||||
}
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public class DNRInjector {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg instanceof MsgFromUser){
|
||||
if (msg instanceof MsgFromUser) {
|
||||
var text = ((MsgFromUser) msg).f();
|
||||
var fullMsg = ((MsgFromUser) msg).j2(); // text + reply
|
||||
var reply = fullMsg.substring(text.length() + 1);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package ru.vtosters.lite.downloaders;
|
||||
|
||||
import static ru.vtosters.lite.music.cache.FileCacheImplementation.getTrackFolder;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getString;
|
||||
|
||||
@@ -11,8 +10,6 @@ import com.vk.dto.music.MusicTrack;
|
||||
import com.vk.dto.music.Playlist;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
@@ -32,7 +29,6 @@ import ru.vtosters.lite.utils.IOUtils;
|
||||
*/
|
||||
|
||||
public class AudioDownloader {
|
||||
private static final Executor executor = Executors.newFixedThreadPool(4);
|
||||
|
||||
public static void downloadPlaylist(Playlist playlist) {
|
||||
var tracks = PlaylistConverter.getPlaylist(playlist);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.downloaders;
|
||||
|
||||
import static ru.vtosters.lite.encryption.EncryptProvider.decryptMessage;
|
||||
import static ru.vtosters.lite.net.Request.makeRequest;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
@@ -30,18 +31,16 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MessagesDownloader{
|
||||
public class MessagesDownloader {
|
||||
private static final String VK_DOMAIN = "vk.com";
|
||||
private static SimpleDateFormat sdformat;
|
||||
|
||||
private static SparseArray<MiniUser> usersArray;
|
||||
|
||||
private static final String VK_DOMAIN = "vk.com";
|
||||
|
||||
public static String formatTime(long now){
|
||||
public static String formatTime(long now) {
|
||||
return sdformat.format(new Date(now));
|
||||
}
|
||||
|
||||
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements){
|
||||
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) {
|
||||
Objects.requireNonNull(delimiter);
|
||||
Objects.requireNonNull(elements);
|
||||
|
||||
@@ -54,7 +53,48 @@ public class MessagesDownloader{
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public void downloadDialog(int peer_id, DialogDownloaderFormatProvider format, File out) throws Exception{
|
||||
private static String getPollHtml(JSONObject poll) throws JSONException {
|
||||
StringBuilder pollHtml = new StringBuilder(
|
||||
"<div class=\"vtex-milk-msg poll\">" +
|
||||
"<p style=\"text-align:center;\">" + poll.optString("question") + "</p>"
|
||||
);
|
||||
|
||||
var answers = poll.optJSONArray("answers");
|
||||
|
||||
for (int i = 0; i < answers.length(); i++) {
|
||||
var jsonObject = answers.optJSONObject(i);
|
||||
if (jsonObject != null)
|
||||
pollHtml.append("<hr><p>").append(jsonObject.optString("text")).append(" · ").append(jsonObject.optString("votes")).append(" (").append(jsonObject.optString("rate")).append("%)</p>");
|
||||
}
|
||||
|
||||
pollHtml.append("<hr><p style=\"text-align:center;\">").append(getString("chat_export_poll_voted")).append(" ").append(poll.optString("votes")).append(" ").append(getString("chat_export_users_name")).append("</p>");
|
||||
|
||||
return pollHtml.append("</div>").toString();
|
||||
}
|
||||
|
||||
private static String getVideoHtml(JSONObject files) throws JSONException {
|
||||
if (files == null) return getString("chat_export_video_nolinks");
|
||||
|
||||
Iterator<?> keys = files.keys();
|
||||
StringBuilder videoHtml = new StringBuilder();
|
||||
|
||||
int qualityIndex = 0;
|
||||
String[] quality = {"144", "240", "360", "480", "720", "1080", "1440", "2160"};
|
||||
|
||||
while (keys.hasNext()) {
|
||||
String key = (String) keys.next();
|
||||
if (key.equals("mp4_" + quality[qualityIndex])) {
|
||||
videoHtml.append("<a class=\"msg-attach-link\" href=\"").append(files.get(key)).append("\">").append(quality[qualityIndex]).append("p</a>").append(" ");
|
||||
|
||||
if (qualityIndex == quality.length - 1) break;
|
||||
++qualityIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return videoHtml.toString();
|
||||
}
|
||||
|
||||
public void downloadDialog(int peer_id, DialogDownloaderFormatProvider format, File out) throws Exception {
|
||||
sdformat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss", getResources().getConfiguration().locale);
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(out);
|
||||
@@ -77,7 +117,7 @@ public class MessagesDownloader{
|
||||
}));
|
||||
}
|
||||
|
||||
public void fetchDialogInfo(int peer_id, int offset, FetchListener fl){
|
||||
public void fetchDialogInfo(int peer_id, int offset, FetchListener fl) {
|
||||
makeRequest("https://" + getApi() + "/method/messages.getHistory?extended=1&v=5.140&offset=" + offset + "&count=200&peer_id=" + peer_id + "&access_token=" + getUserToken(),
|
||||
response -> {
|
||||
try {
|
||||
@@ -99,7 +139,7 @@ public class MessagesDownloader{
|
||||
});
|
||||
}
|
||||
|
||||
private List<MiniMsg> parseMessages(JSONArray jsonArray) throws JSONException{
|
||||
private List<MiniMsg> parseMessages(JSONArray jsonArray) throws JSONException {
|
||||
ArrayList<MiniMsg> thing = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
@@ -110,7 +150,7 @@ public class MessagesDownloader{
|
||||
return thing;
|
||||
}
|
||||
|
||||
private void parseUsers(SparseArray<MiniUser> array, @Nullable JSONArray jsonArray, boolean groups) throws JSONException{
|
||||
private void parseUsers(SparseArray<MiniUser> array, @Nullable JSONArray jsonArray, boolean groups) throws JSONException {
|
||||
if (jsonArray == null) return;
|
||||
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
@@ -119,11 +159,11 @@ public class MessagesDownloader{
|
||||
}
|
||||
}
|
||||
|
||||
interface FetchListener{
|
||||
interface FetchListener {
|
||||
void onReceive(SparseArray<MiniUser> users, List<MiniMsg> messages);
|
||||
}
|
||||
|
||||
static class MiniUser{
|
||||
static class MiniUser {
|
||||
public String firstName;
|
||||
public String lastName;
|
||||
public boolean isGroup;
|
||||
@@ -139,7 +179,7 @@ public class MessagesDownloader{
|
||||
}
|
||||
}
|
||||
|
||||
static class MiniMsg{
|
||||
static class MiniMsg {
|
||||
long date;
|
||||
int fromId;
|
||||
int id; // message id
|
||||
@@ -150,7 +190,7 @@ public class MessagesDownloader{
|
||||
JSONObject chat_action;
|
||||
JSONObject geo;
|
||||
|
||||
public MiniMsg(JSONObject obj) throws JSONException{
|
||||
public MiniMsg(JSONObject obj) throws JSONException {
|
||||
date = obj.getLong("date") * 1000;
|
||||
fromId = obj.getInt("from_id");
|
||||
id = obj.getInt("id");
|
||||
@@ -173,7 +213,7 @@ public class MessagesDownloader{
|
||||
}
|
||||
|
||||
// This class defines everything which is needed to create an output file
|
||||
abstract static class DialogDownloaderFormatProvider{
|
||||
abstract static class DialogDownloaderFormatProvider {
|
||||
// Internal, for JSON/HTML
|
||||
abstract String provideDocumentStart(String dialogName, String date);
|
||||
|
||||
@@ -184,9 +224,9 @@ public class MessagesDownloader{
|
||||
abstract String provideMessage(MiniMsg message, MiniUser user) throws JSONException;
|
||||
}
|
||||
|
||||
public static class HtmlDialogDownloaderFormatProvider extends DialogDownloaderFormatProvider{
|
||||
public static class HtmlDialogDownloaderFormatProvider extends DialogDownloaderFormatProvider {
|
||||
@Override
|
||||
String provideDocumentStart(String dialogName, String date){
|
||||
String provideDocumentStart(String dialogName, String date) {
|
||||
String style = ".vtex-milk-msg {\n" +
|
||||
" border-radius: 8px;\n" +
|
||||
" padding: 24px;\n" +
|
||||
@@ -282,17 +322,17 @@ public class MessagesDownloader{
|
||||
}
|
||||
|
||||
@Override
|
||||
String provideDocumentEnd(){
|
||||
String provideDocumentEnd() {
|
||||
return "</div></body></html>";
|
||||
}
|
||||
|
||||
@Override
|
||||
String provideHeader(String dialogName, String date){
|
||||
String provideHeader(String dialogName, String date) {
|
||||
return "<div class=\"vtex-milk-header\"><h4 class=\"vtex-milk-header-txt\">VTLite</h4><h5 class=\"vtex-milk-header-sub\">" + getString("chat_export_header") + " (" + date + ")</h5></div><div class=\"vtex-milk-msgcont\">";
|
||||
}
|
||||
|
||||
@Override
|
||||
String provideMessage(MiniMsg message, MiniUser user) throws JSONException{
|
||||
String provideMessage(MiniMsg message, MiniUser user) throws JSONException {
|
||||
String isOut = (user.id == getUserId()) ? " vtex-milk-msg-out" : "";
|
||||
|
||||
String geoPosition = "";
|
||||
@@ -315,13 +355,13 @@ public class MessagesDownloader{
|
||||
String userLink = (user.isGroup ? "club" : "id") + user.id;
|
||||
|
||||
return "<div class=\"vtex-milk-msg" + isOut + "\" id=\"" + message.id + "\">" +
|
||||
"<p class=\"msg-from\">" + getString("from_lower") + " <a href=\"https://" + VK_DOMAIN + "/" + userLink + "\">" + user.firstName + " " + user.lastName + "</a> <span class=\"msg-from-date\">" + formatTime(message.date) + "</span></p>" + // TODO photo100
|
||||
"<p class=\"msg-body\">" + mentionsReplace(message.text) + "</p>" +
|
||||
geoPosition +
|
||||
chatAction +
|
||||
attaches +
|
||||
reply +
|
||||
fwdMessages +
|
||||
"<p class=\"msg-from\">" + getString("from_lower") + " <a href=\"https://" + VK_DOMAIN + "/" + userLink + "\">" + user.firstName + " " + user.lastName + "</a> <span class=\"msg-from-date\">" + formatTime(message.date) + "</span></p>" + // TODO photo100
|
||||
"<p class=\"msg-body\">" + mentionsReplace(message.text) + "</p>" +
|
||||
geoPosition +
|
||||
chatAction +
|
||||
attaches +
|
||||
reply +
|
||||
fwdMessages +
|
||||
"</div>";
|
||||
}
|
||||
|
||||
@@ -342,10 +382,10 @@ public class MessagesDownloader{
|
||||
}
|
||||
|
||||
return "<a href=\"#" + messageId + "\" class=\"msg-attach-link\">" +
|
||||
"<div class=\"msg-reply\">" +
|
||||
"<p class=\"reply-header\">" + getString("vkim_msg_fwd_single") + "</p>" +
|
||||
"<p class=\"reply-content\">" + user.firstName + " " + user.lastName + ": " + text + "</p>" +
|
||||
"</div>" +
|
||||
"<div class=\"msg-reply\">" +
|
||||
"<p class=\"reply-header\">" + getString("vkim_msg_fwd_single") + "</p>" +
|
||||
"<p class=\"reply-content\">" + user.firstName + " " + user.lastName + ": " + text + "</p>" +
|
||||
"</div>" +
|
||||
"</a>";
|
||||
}
|
||||
|
||||
@@ -424,7 +464,7 @@ public class MessagesDownloader{
|
||||
|
||||
StringBuilder htmlAction = new StringBuilder("<p class=\"chat-action\">");
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case "chat_photo_update":
|
||||
htmlAction.append(getString("chat_export_avatar_update"));
|
||||
break;
|
||||
@@ -479,7 +519,7 @@ public class MessagesDownloader{
|
||||
return htmlAction.append("</p>").toString();
|
||||
}
|
||||
|
||||
private String getHtmlForAttach(List<JSONObject> attaches) throws JSONException{
|
||||
private String getHtmlForAttach(List<JSONObject> attaches) throws JSONException {
|
||||
StringBuilder rs = new StringBuilder();
|
||||
|
||||
for (JSONObject attach : attaches) {
|
||||
@@ -488,7 +528,7 @@ public class MessagesDownloader{
|
||||
|
||||
if (item == null) continue;
|
||||
|
||||
switch(type) { // market_album is not supported
|
||||
switch (type) { // market_album is not supported
|
||||
case "photo":
|
||||
var sizes = item.getJSONArray("sizes");
|
||||
rs.append("<a href=\"").append(sizes.getJSONObject(sizes.length() - 1).getString("url")).append("\" class=\"msg-attach-link\">").append(getString("chat_export_type_photo")).append("</a>");
|
||||
@@ -562,45 +602,4 @@ public class MessagesDownloader{
|
||||
return rs.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPollHtml(JSONObject poll) throws JSONException {
|
||||
StringBuilder pollHtml = new StringBuilder(
|
||||
"<div class=\"vtex-milk-msg poll\">" +
|
||||
"<p style=\"text-align:center;\">" + poll.optString("question") + "</p>"
|
||||
);
|
||||
|
||||
var answers = poll.optJSONArray("answers");
|
||||
|
||||
for (int i = 0; i < answers.length(); i++) {
|
||||
var jsonObject = answers.optJSONObject(i);
|
||||
if (jsonObject != null)
|
||||
pollHtml.append("<hr><p>").append(jsonObject.optString("text")).append(" · ").append(jsonObject.optString("votes")).append(" (").append(jsonObject.optString("rate")).append("%)</p>");
|
||||
}
|
||||
|
||||
pollHtml.append("<hr><p style=\"text-align:center;\">").append(getString("chat_export_poll_voted")).append(" ").append(poll.optString("votes")).append(" ").append(getString("chat_export_users_name")).append("</p>");
|
||||
|
||||
return pollHtml.append("</div>").toString();
|
||||
}
|
||||
|
||||
private static String getVideoHtml(JSONObject files) throws JSONException {
|
||||
if (files == null) return getString("chat_export_video_nolinks");
|
||||
|
||||
Iterator< ? > keys = files.keys();
|
||||
StringBuilder videoHtml = new StringBuilder();
|
||||
|
||||
int qualityIndex = 0;
|
||||
String[] quality = {"144", "240", "360", "480", "720", "1080", "1440", "2160"};
|
||||
|
||||
while (keys.hasNext()) {
|
||||
String key = (String) keys.next();
|
||||
if (key.equals("mp4_" + quality[qualityIndex])) {
|
||||
videoHtml.append("<a class=\"msg-attach-link\" href=\"").append(files.get(key)).append("\">").append(quality[qualityIndex]).append("p</a>").append(" ");
|
||||
|
||||
if (qualityIndex == quality.length - 1) break;
|
||||
++qualityIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return videoHtml.toString();
|
||||
}
|
||||
}
|
||||
@@ -126,12 +126,12 @@ public class VideoDownloader {
|
||||
}
|
||||
|
||||
public static void parseVideoLink(String url, Context ctx) {
|
||||
if (url.contains("vk.com/story") || url.contains("vk.com/story")) {
|
||||
if (url.contains("vk.com/story")) {
|
||||
ToastUtils.a(AndroidUtils.getString("video_dl_stories_not_supported"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!url.contains("vk.com/video") || !url.contains("vk.com/video")) {
|
||||
if (!url.contains("vk.com/video")) {
|
||||
ToastUtils.a(AndroidUtils.getString("video_dl_wrong_link"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,18 +52,20 @@ public class EncryptProvider {
|
||||
public static int getPeerId(Msg msg) {
|
||||
return msg.v1();
|
||||
}
|
||||
|
||||
|
||||
// For message editing
|
||||
public static String decryptMessage(MsgFromUser msg, boolean showEmoji) {
|
||||
var decryptedMessage = decryptMessage(getBody(msg), getPeerId(msg));
|
||||
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(getBody(msg)))) decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(getBody(msg))))
|
||||
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
return decryptedMessage;
|
||||
}
|
||||
|
||||
public static String decryptMessage(String msg, MsgListComponent list) {
|
||||
var peerid = list.G().getId();
|
||||
var decryptedMessage = decryptMessage(msg, peerid);
|
||||
if (!decryptedMessage.equals(injectOwnTextAll(msg))) decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
if (!decryptedMessage.equals(injectOwnTextAll(msg)))
|
||||
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
return decryptedMessage;
|
||||
}
|
||||
|
||||
@@ -91,7 +93,8 @@ public class EncryptProvider {
|
||||
// For MentionsFormatter that requires CharSequence
|
||||
public static CharSequence decryptMessage(String msgBody, int peer, boolean showEmoji) {
|
||||
var decryptedMessage = decryptMessage(msgBody, peer);
|
||||
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(msgBody))) decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
if (!showEmoji && !decryptedMessage.equals(injectOwnTextAll(msgBody)))
|
||||
decryptedMessage = decryptedMessage.replaceAll("^\uD83D\uDD12 ", "");
|
||||
return decryptedMessage;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class FoafBase {
|
||||
|
||||
public static JSONObject getBypassedOnlineInfo(int id) throws JSONException {
|
||||
var request = new okhttp3.Request.a()
|
||||
.b(API_VKNEXT + Integer.toString(id))
|
||||
.b(API_VKNEXT + id)
|
||||
.a();
|
||||
|
||||
String response = null;
|
||||
@@ -151,7 +151,7 @@ public class FoafBase {
|
||||
}
|
||||
}
|
||||
|
||||
private static long daysPassedFromFoafDate(String str) {
|
||||
private static long daysPassedFromFoafDate(String str) {
|
||||
try {
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(str.split(" ")[1]);
|
||||
|
||||
@@ -335,7 +335,7 @@ public class AdBlockHook {
|
||||
id = String.valueOf(list.optInt("source_id"));
|
||||
}
|
||||
|
||||
if (id.equals("-189659924")){
|
||||
if (id.equals("-189659924")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.dnr.DNRInjector.forceInvalidateDialogActions;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getString;
|
||||
@@ -26,8 +27,8 @@ import java.util.Objects;
|
||||
import ru.vtosters.lite.encryption.EncryptProvider;
|
||||
import ru.vtosters.lite.encryption.base.IMProcessor;
|
||||
|
||||
public class CryptImHook{
|
||||
public static boolean isPrivateProcessor(int peerID){
|
||||
public class CryptImHook {
|
||||
public static boolean isPrivateProcessor(int peerID) {
|
||||
for (IMProcessor processor : EncryptProvider.processors) {
|
||||
if (processor.isUsedToEncrypt(peerID)) {
|
||||
return !processor.isPublic();
|
||||
@@ -37,7 +38,7 @@ public class CryptImHook{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void hook(int peerId, Dialog d){
|
||||
public static void hook(int peerId, Dialog d) {
|
||||
List<IMProcessor> processors = EncryptProvider.processors;
|
||||
|
||||
IMProcessor enabled = null;
|
||||
@@ -86,7 +87,7 @@ public class CryptImHook{
|
||||
}).create().show();
|
||||
}
|
||||
|
||||
public static void hookPref(int peerId){
|
||||
public static void hookPref(int peerId) {
|
||||
IMProcessor enabled = null;
|
||||
String key = null;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.MD5;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
@@ -8,7 +9,7 @@ import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
public class DeviceInfoHook{
|
||||
public class DeviceInfoHook {
|
||||
public static String getDeviceInfo(String input) {
|
||||
Log.d("DeviceInfoHook", "getDeviceInfo: " + input);
|
||||
if (getBoolValue("hideDeviceInfo", true)) return "";
|
||||
|
||||
@@ -82,7 +82,8 @@ public class DockBarInjector {
|
||||
} while (acquire.invoke(synchronizedPool) != null);
|
||||
}
|
||||
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException | ClassNotFoundException |
|
||||
NoSuchMethodException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
public class GcmHook {
|
||||
private static final String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL);
|
||||
public static ArrayList<String> langs = new ArrayList<>();
|
||||
private static KeyPair pair;
|
||||
private static int rid = 0;
|
||||
|
||||
@@ -38,12 +37,12 @@ public class GcmHook {
|
||||
}
|
||||
|
||||
public static String requestTokenV2(String orig) {
|
||||
if (musicFixNew()) return "null";
|
||||
if (musicFixNew()) return "null"; //not public
|
||||
return orig;
|
||||
}
|
||||
|
||||
public static String requestToken(String orig) {
|
||||
if (musicFixNew()) return "{null}";
|
||||
if (musicFixNew()) return "{null}"; //not public
|
||||
if (orig.equals("")) return requestToken();
|
||||
return orig;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,8 @@ public class JsonInjectors {
|
||||
var isPicture = pic.endsWith(".png") || pic.endsWith(".jpg") || pic.endsWith(".jpeg") || pic.endsWith(".webp");
|
||||
|
||||
if (isVerified(peerid)) text = AndroidUtils.getString("i_bought") + " VTosters Premium";
|
||||
if (isPrometheus(peerid)) text = AndroidUtils.getString("i_bought") + " VTosters Premium Gold Prime Pro Plus";
|
||||
if (isPrometheus(peerid))
|
||||
text = AndroidUtils.getString("i_bought") + " VTosters Premium Gold Prime Pro Plus";
|
||||
if (isDeveloper(peerid)) text = AndroidUtils.getString("i_created_poop");
|
||||
|
||||
if (!isVerified(peerid) || text.equals("") || peerid == AccountManagerUtils.getUserId() || peerid == 0) {
|
||||
@@ -282,7 +283,7 @@ public class JsonInjectors {
|
||||
if (profiles == null || profiles.length() == 0) return profiles;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var curVkId = AccountManagerUtils.getUserId();
|
||||
for (int i=0; i < profiles.length(); i++) {
|
||||
for (int i = 0; i < profiles.length(); i++) {
|
||||
JSONObject profile = profiles.getJSONObject(i);
|
||||
int id = profile.optInt("id", -1);
|
||||
JSONObject onlinfo = profile.optJSONObject("online_info");
|
||||
@@ -300,7 +301,7 @@ public class JsonInjectors {
|
||||
}
|
||||
|
||||
JSONObject bypassedObj = getBypassedOnlineInfo(ids);
|
||||
for (int i=0; i < profiles.length(); i++) {
|
||||
for (int i = 0; i < profiles.length(); i++) {
|
||||
JSONObject profile = profiles.getJSONObject(i);
|
||||
int id = profile.optInt("id");
|
||||
JSONObject bypassed = bypassedObj.optJSONObject(Integer.toString(id));
|
||||
|
||||
@@ -23,7 +23,7 @@ public class MessagesHook {
|
||||
public static String injectOwnText(String oldText) {
|
||||
if (!autotranslate() || TextUtils.isEmpty(oldText))
|
||||
return oldText;
|
||||
var instance = BaseTranslator.getInstance();
|
||||
var instance = BaseTranslator.getInstance();
|
||||
|
||||
return replaceMentions(oldText, instance);
|
||||
}
|
||||
@@ -46,7 +46,8 @@ public class MessagesHook {
|
||||
var mentions = new ArrayList<String>();
|
||||
while (matcher.find()) {
|
||||
mentions.add(matcher.group());
|
||||
matcher.appendReplacement(textBuff, "vtl_mention" + mentionsCount + ""); ++mentionsCount;
|
||||
matcher.appendReplacement(textBuff, "vtl_mention" + mentionsCount + "");
|
||||
++mentionsCount;
|
||||
}
|
||||
matcher.appendTail(textBuff);
|
||||
|
||||
@@ -61,7 +62,7 @@ public class MessagesHook {
|
||||
matcherMentions.appendTail(retTextBuff);
|
||||
|
||||
return retTextBuff.toString();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return instance.getTranslation(oldText);
|
||||
}
|
||||
@@ -75,7 +76,7 @@ public class MessagesHook {
|
||||
}
|
||||
|
||||
public static Context fixCTX(Context ctx) {
|
||||
if (ctx == null){
|
||||
if (ctx == null) {
|
||||
return LifecycleUtils.getCurrentActivity();
|
||||
} else {
|
||||
return ctx;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class NewsfeedHook {
|
||||
return list;
|
||||
}
|
||||
|
||||
public static String[] feedParams(){
|
||||
public static String[] feedParams() {
|
||||
HashSet<String> params = new HashSet<>();
|
||||
params.add("post");
|
||||
params.add("photo");
|
||||
|
||||
@@ -135,7 +135,7 @@ public class PhotoViewer {
|
||||
if (attachment.J != null) {
|
||||
imageSizes = attachment.J.t1();
|
||||
}
|
||||
return getUrlFromImageSizeList(imageSizes != null ? imageSizes : null);
|
||||
return getUrlFromImageSizeList(imageSizes);
|
||||
}
|
||||
|
||||
private static String getUrlFromPhotoAttachment(PhotoAttachment attachment) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
@@ -12,7 +13,7 @@ import com.facebook.drawee.generic.RoundingParams;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class PicRoundingHook{
|
||||
public class PicRoundingHook {
|
||||
private static final int pref = preferences.getInt("pic_rounding", 0);
|
||||
|
||||
public static RoundingParams inject() {
|
||||
@@ -39,7 +40,7 @@ public class PicRoundingHook{
|
||||
}
|
||||
}
|
||||
|
||||
public static void inject(float orig, Canvas canvas, Paint paint){
|
||||
public static void inject(float orig, Canvas canvas, Paint paint) {
|
||||
if (pref > 0) {
|
||||
canvas.drawRoundRect(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), AndroidUtils.dp2px(pref), AndroidUtils.dp2px(pref), paint);
|
||||
} else {
|
||||
@@ -47,7 +48,7 @@ public class PicRoundingHook{
|
||||
}
|
||||
}
|
||||
|
||||
public static void inject(Canvas canvas, Paint paint, float orig){
|
||||
public static void inject(Canvas canvas, Paint paint, float orig) {
|
||||
if (pref > 0) {
|
||||
canvas.drawRoundRect(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), AndroidUtils.dp2px(pref), AndroidUtils.dp2px(pref), paint);
|
||||
} else {
|
||||
@@ -55,7 +56,7 @@ public class PicRoundingHook{
|
||||
}
|
||||
}
|
||||
|
||||
public static void inject(Canvas canvas, float orig, float orig2, float orig3, Paint paint){
|
||||
public static void inject(Canvas canvas, float orig, float orig2, float orig3, Paint paint) {
|
||||
if (pref > 0) {
|
||||
canvas.drawRoundRect(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), AndroidUtils.dp2px(pref), AndroidUtils.dp2px(pref), paint);
|
||||
} else {
|
||||
@@ -76,7 +77,7 @@ public class PicRoundingHook{
|
||||
}
|
||||
}
|
||||
|
||||
private static RoundingParams customParams(){
|
||||
private static RoundingParams customParams() {
|
||||
return RoundingParams.b(AndroidUtils.dp2px(pref), AndroidUtils.dp2px(pref), AndroidUtils.dp2px(pref), AndroidUtils.dp2px(pref));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ import ru.vtosters.lite.utils.Preferences;
|
||||
public class PostViewHook {
|
||||
|
||||
/**
|
||||
* For displaying child elements with custom direction in rtl container we should remove their, set layout direction and add again */
|
||||
* For displaying child elements with custom direction in rtl container we should remove their, set layout direction and add again
|
||||
*/
|
||||
private static void saveChildDirectionForRlt(ViewGroup container) {
|
||||
var children = new View[container.getChildCount()];
|
||||
for (int i = 0; i < container.getChildCount(); i++) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.dev;
|
||||
|
||||
import android.util.Log;
|
||||
@@ -7,9 +8,9 @@ import com.vk.api.internal.MethodCall;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class RequestDumper{
|
||||
public class RequestDumper {
|
||||
public static void addParams(MethodCall.a paramslist, String method, LinkedHashMap<String, String> params, String apiver) {
|
||||
if (method.contains("execute.getGiftByStickerId") ) {
|
||||
if (method.contains("execute.getGiftByStickerId")) {
|
||||
apiver = "5.186";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.ui.components.DockBarEditorManager.getInstance;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
import static ru.vtosters.lite.utils.Preferences.superapp;
|
||||
import static ru.vtosters.lite.utils.Preferences.useNewSettings;
|
||||
@@ -28,7 +27,6 @@ import com.vtosters.lite.fragments.p2.DocumentsViewFragment;
|
||||
import com.vtosters.lite.fragments.s2.GroupsFragment1;
|
||||
import com.vtosters.lite.fragments.t2.c.DialogsFragment;
|
||||
import com.vtosters.lite.fragments.y2.VideoCatalogFragment;
|
||||
import com.vtosters.lite.fragments.y2.VideosFragment;
|
||||
import com.vtosters.lite.general.fragments.GamesFragment;
|
||||
import com.vtosters.lite.general.fragments.PhotosFragment;
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package ru.vtosters.lite.hooks;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.wbios;
|
||||
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class WritebarHook{
|
||||
public static int getWriteBar(){
|
||||
public class WritebarHook {
|
||||
public static int getWriteBar() {
|
||||
return AndroidUtils.getIdentifier((wbios() ? "write_bar_i" : "write_bar"), "layout");
|
||||
}
|
||||
|
||||
public static int getIconsColors(int def){
|
||||
public static int getIconsColors(int def) {
|
||||
return wbios() ? ThemesUtils.getAccentColor() : def;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ru.vtosters.lite.hooks.ui;
|
||||
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.*;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.asId;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.getInstance;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isIntegrationEnabled;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.isVkxInstalled;
|
||||
import static bruhcollective.itaysonlab.libvkx.client.LibVKXClient.lambdaplay;
|
||||
import static ru.vtosters.lite.music.cache.CacheDatabaseDelegate.isCached;
|
||||
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClient;
|
||||
import bruhcollective.itaysonlab.libvkx.client.LibVKXClientImpl;
|
||||
import ru.vtosters.lite.downloaders.AudioDownloader;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
@@ -40,14 +39,14 @@ public class MusicBottomSheetHook {
|
||||
}
|
||||
|
||||
if (isIntegrationEnabled()) {
|
||||
if (isVkxCached(trackid)){
|
||||
if (isVkxCached(trackid)) {
|
||||
actions.add(getRemoveCacheTrackVkxAction());
|
||||
} else {
|
||||
actions.add(addToCacheTrackVkxAction());
|
||||
}
|
||||
}
|
||||
|
||||
if (isNetworkConnected()){
|
||||
if (isNetworkConnected()) {
|
||||
actions.add(downloadAsMp3Action());
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ public class MusicBottomSheetHook {
|
||||
|
||||
var trackid = asId(musicTrack);
|
||||
|
||||
if (isCached(trackid)){
|
||||
if (isCached(trackid)) {
|
||||
actions.add(new MusicAction(
|
||||
AndroidUtils.getIdentifier("music_action_toggle_download", "id"),
|
||||
milkshake() ? R.drawable.ic_delete_outline_28 : R.drawable.ic_delete_24,
|
||||
@@ -88,8 +87,8 @@ public class MusicBottomSheetHook {
|
||||
|
||||
if (isVkxInstalled()) actions.add(getPlayInVKXAction());
|
||||
|
||||
if (isIntegrationEnabled()){
|
||||
if (isVkxCached(playlist.a, playlist.b)){
|
||||
if (isIntegrationEnabled()) {
|
||||
if (isVkxCached(playlist.a, playlist.b)) {
|
||||
actions.add(getRemoveCacheTrackVkxAction());
|
||||
} else {
|
||||
actions.add(addToCacheTrackVkxAction());
|
||||
@@ -152,7 +151,7 @@ public class MusicBottomSheetHook {
|
||||
|
||||
if (actionId == AndroidUtils.getIdentifier("add_to_cache", "id")) {
|
||||
executor.submit(() -> AudioDownloader.cachePlaylist(playlist));
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (actionId == AndroidUtils.getIdentifier("remove_from_cache_vkx", "id")) {
|
||||
|
||||
@@ -96,7 +96,8 @@ public class M3UDownloader implements ITrackDownloader {
|
||||
IOUtils.writeToFile(tsDump, content);
|
||||
callback.onProgress(10 + Math.round(80.0f * progress.addAndGet(1) / tses.size()));
|
||||
callback.onSizeReceived((long) content.length * tses.size(), parser.getHeapSize());
|
||||
} catch (IOException | NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException e) {
|
||||
} catch (IOException | NoSuchPaddingException | NoSuchAlgorithmException |
|
||||
InvalidAlgorithmParameterException | InvalidKeyException e) {
|
||||
callback.onFailure();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ public class VKM3UParser {
|
||||
init();
|
||||
}
|
||||
|
||||
public static boolean isM3U8(String str) {
|
||||
return str.endsWith(".ts") || str.endsWith(".tp") || str.endsWith(".mpeg-ts") || str.endsWith(".m2ts");
|
||||
}
|
||||
|
||||
private void init() {
|
||||
int i = 0;
|
||||
Scanner scanner = new Scanner(mData);
|
||||
@@ -51,10 +55,6 @@ public class VKM3UParser {
|
||||
return directive.substring(directive.indexOf(":") + 1);
|
||||
}
|
||||
|
||||
public static boolean isM3U8(String str) {
|
||||
return str.endsWith(".ts") || str.endsWith(".tp") || str.endsWith(".mpeg-ts") || str.endsWith(".m2ts");
|
||||
}
|
||||
|
||||
public int getHeapSize() {
|
||||
return mHeapSize;
|
||||
}
|
||||
|
||||
+28
-26
@@ -1,8 +1,10 @@
|
||||
package ru.vtosters.lite.music.cache;
|
||||
|
||||
import static ru.vtosters.lite.music.cache.FileCacheImplementation.getCacheDir;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.*;
|
||||
import static ru.vtosters.lite.utils.IOUtils.*;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getString;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.sendToast;
|
||||
import static ru.vtosters.lite.utils.IOUtils.deleteRecursive;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
@@ -230,31 +232,31 @@ public class CacheDatabaseDelegate {
|
||||
}
|
||||
|
||||
public static boolean isCached(String trackId) {
|
||||
var formula = String.format(
|
||||
"SELECT COUNT(%s) FROM %s WHERE %s = '%s'",
|
||||
COLUMN_ID,
|
||||
TABLE_NAME,
|
||||
COLUMN_TRACK_ID,
|
||||
trackId
|
||||
);
|
||||
try {
|
||||
Cursor size = getHelper().getReadableDatabase().rawQuery(formula, null);
|
||||
if (size != null) {
|
||||
size.moveToFirst();
|
||||
int count = size.getInt(0);
|
||||
size.close();
|
||||
return count != 0;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
var formula = String.format(
|
||||
"SELECT COUNT(%s) FROM %s WHERE %s = '%s'",
|
||||
COLUMN_ID,
|
||||
TABLE_NAME,
|
||||
COLUMN_TRACK_ID,
|
||||
trackId
|
||||
);
|
||||
try {
|
||||
Cursor size = getHelper().getReadableDatabase().rawQuery(formula, null);
|
||||
if (size != null) {
|
||||
size.moveToFirst();
|
||||
int count = size.getInt(0);
|
||||
size.close();
|
||||
return count != 0;
|
||||
}
|
||||
return false;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isVkxCached(int playlist_id, int owner_id) {
|
||||
return LibVKXClient.getInstance().runOnServiceSync(new LibVKXClientImpl.LibVKXActionGeneric<>(){
|
||||
return LibVKXClient.getInstance().runOnServiceSync(new LibVKXClientImpl.LibVKXActionGeneric<>() {
|
||||
@Override
|
||||
public Boolean run(ILibVkxService service){
|
||||
public Boolean run(ILibVkxService service) {
|
||||
try {
|
||||
return service.isPlaylistCached(playlist_id, owner_id);
|
||||
} catch (RemoteException e) {
|
||||
@@ -263,16 +265,16 @@ public class CacheDatabaseDelegate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean defaultValue(){
|
||||
public Boolean defaultValue() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isVkxCached(String trackId) {
|
||||
return LibVKXClient.getInstance().runOnServiceSync(new LibVKXClientImpl.LibVKXActionGeneric<>(){
|
||||
return LibVKXClient.getInstance().runOnServiceSync(new LibVKXClientImpl.LibVKXActionGeneric<>() {
|
||||
@Override
|
||||
public Boolean run(ILibVkxService service){
|
||||
public Boolean run(ILibVkxService service) {
|
||||
try {
|
||||
var splits = trackId.split("_");
|
||||
var id = Integer.parseInt(splits[1]);
|
||||
@@ -284,7 +286,7 @@ public class CacheDatabaseDelegate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean defaultValue(){
|
||||
public Boolean defaultValue() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class FileCacheImplementation {
|
||||
}
|
||||
|
||||
public static File getTrackFile(String trackId) {
|
||||
return new File(getTrackFolder(trackId), "track.mp3");
|
||||
return new File(getTrackFolder(trackId), "track.mp3");
|
||||
}
|
||||
|
||||
public static boolean isTrackExist(String trackId) {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class TracklistHelper {
|
||||
try {
|
||||
addCachedThumbnails(json, folder);
|
||||
} catch (JSONException | MalformedURLException e) {
|
||||
Log.d("TracklistHelper", e+"");
|
||||
Log.d("TracklistHelper", e.getMessage());
|
||||
}
|
||||
arr.put(json);
|
||||
}
|
||||
|
||||
+3
-3
@@ -41,7 +41,7 @@ public class TracklistInjector {
|
||||
try {
|
||||
Log.d("TracklistInjector", "Using vkx cache catalog");
|
||||
observableEmitter.b(parser.c(new JSONObject(service.getCacheCatalog())));
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
List<MusicTrack> tracks = new ArrayList<>();
|
||||
List<String> cache = service.getCache();
|
||||
@@ -59,7 +59,7 @@ public class TracklistInjector {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!hasTracks()){
|
||||
if (!hasTracks()) {
|
||||
observableEmitter.b(parser.c(getEmptyCatalog()));
|
||||
} else {
|
||||
observableEmitter.b(parser.c(createVirtualCatalog(TracklistHelper.getTracks())));
|
||||
@@ -68,7 +68,7 @@ public class TracklistInjector {
|
||||
});
|
||||
}
|
||||
|
||||
private static JSONObject getEmptyCatalog() throws JSONException{
|
||||
private static JSONObject getEmptyCatalog() throws JSONException {
|
||||
return new JSONObject("{\"catalog\":{\"default_section\":\"cache\",\"sections\":[{\"id\":\"cache\",\"title\":\"" + getString("cached_content_title") + "\",\"blocks\":[{\"data_type\":\"placeholder\",\"id\":\"0\",\"layout\":{\"name\":\"placeholder_big\"},\"placeholder_ids\":[\"_synth_trackEmpty\"]}]}]},\"audios\":[],\"playlists\":[],\"placeholders\":[{\"id\":\"_synth_trackEmpty\",\"title\":\"" + getString("cached_content_empty") + "\",\"text\":\"" + getString("cached_content_empty_desc") + "\",\"buttons\":[]}]}");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
|
||||
import ru.vtosters.lite.music.Callback;
|
||||
|
||||
public class MusicCallbackBuilder {
|
||||
private static NotificationManagerCompat notificationManager = NotificationChannels.getNotificationManager();
|
||||
private static final NotificationManagerCompat notificationManager = NotificationChannels.getNotificationManager();
|
||||
|
||||
public static Callback buildOneTrackCallback(int notificationId, NotificationCompat.Builder notification) {
|
||||
return new Callback() {
|
||||
|
||||
@@ -19,6 +19,7 @@ import ru.vtosters.lite.utils.IOUtils;
|
||||
|
||||
public class FFMpeg {
|
||||
private static final int BUFFER_SIZE = 2048;
|
||||
|
||||
/**
|
||||
* @param in Merged .ts file via {@link ru.vtosters.lite.music.converter.ts.TSMerger}
|
||||
* @param out Output .mp3 file
|
||||
|
||||
@@ -14,6 +14,7 @@ import ru.vtosters.lite.utils.IOUtils;
|
||||
public class TSMerger {
|
||||
/**
|
||||
* Merge multiple .ts files into one .ts file
|
||||
*
|
||||
* @param in Directory with .ts files
|
||||
* @return True if success, else false
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.music.downloader;
|
||||
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserId;
|
||||
@@ -25,13 +26,13 @@ import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class AudioGet{
|
||||
public static List<MusicTrack> getAudios(){
|
||||
public class AudioGet {
|
||||
public static List<MusicTrack> getAudios() {
|
||||
var tracks = requestAudios(0);
|
||||
return tracks != null ? tracks.stream().filter(track -> !track.D.isEmpty()).collect(Collectors.toList()) : null;
|
||||
}
|
||||
|
||||
private static List<MusicTrack> requestAudios(int offset){
|
||||
private static List<MusicTrack> requestAudios(int offset) {
|
||||
var audioCount = 1000;
|
||||
var requestUrl = "https://" + getApi() + "/method/audio.get" +
|
||||
"?v=5.119" +
|
||||
|
||||
@@ -2,21 +2,16 @@ package ru.vtosters.lite.music.downloader;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
|
||||
import ru.vtosters.lite.music.Callback;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
|
||||
public class PlaylistDownloader {
|
||||
private static NotificationManagerCompat notificationManager = NotificationChannels.getNotificationManager();
|
||||
|
||||
public static void downloadPlaylist(List<MusicTrack> playlist, String playlistName, String path, Callback callback) {
|
||||
File outDir = new File(path);
|
||||
if (!outDir.exists())
|
||||
@@ -30,7 +25,8 @@ public class PlaylistDownloader {
|
||||
for (MusicTrack musicTrack : playlist) {
|
||||
TrackDownloader.downloadTrack(musicTrack, path, new Callback() {
|
||||
@Override
|
||||
public void onProgress(int progress) {}
|
||||
public void onProgress(int progress) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
@@ -44,7 +40,8 @@ public class PlaylistDownloader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSizeReceived(long size, long header) {}
|
||||
public void onSizeReceived(long size, long header) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -55,7 +52,8 @@ public class PlaylistDownloader {
|
||||
for (MusicTrack musicTrack : playlist) {
|
||||
TrackDownloader.cacheTrack(musicTrack, new Callback() {
|
||||
@Override
|
||||
public void onProgress(int progress) {}
|
||||
public void onProgress(int progress) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
@@ -70,7 +68,8 @@ public class PlaylistDownloader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSizeReceived(long size, long header) {}
|
||||
public void onSizeReceived(long size, long header) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package ru.vtosters.lite.music.downloader;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.vk.dto.music.MusicTrack;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -12,8 +12,9 @@ import ru.vtosters.lite.music.Callback;
|
||||
public interface ITrackDownloader {
|
||||
/**
|
||||
* Download track
|
||||
* @param track Music track
|
||||
* @param outDir Directory where to download the track
|
||||
*
|
||||
* @param track Music track
|
||||
* @param outDir Directory where to download the track
|
||||
* @param callback Callback to call when download status changes
|
||||
*/
|
||||
void downloadTrack(MusicTrack track, File outDir, Callback callback, boolean cache);
|
||||
|
||||
@@ -15,7 +15,7 @@ import ru.vtosters.lite.utils.AccountManagerUtils;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class MusicNotificationBuilder {
|
||||
private static NotificationManagerCompat notificationManager = NotificationChannels.getNotificationManager();
|
||||
private static final NotificationManagerCompat notificationManager = NotificationChannels.getNotificationManager();
|
||||
|
||||
public static NotificationCompat.Builder buildDownloadNotification(MusicTrack track, int id) {
|
||||
var notificationBuilder = new NotificationCompat.Builder(AndroidUtils.getGlobalContext(), NotificationChannels.MUSIC_DOWNLOAD_CHANNEL_ID)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -8,10 +9,10 @@ import java.util.Arrays;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
||||
public class GithubList{
|
||||
public class GithubList {
|
||||
private static final OkHttpClient mClient = new OkHttpClient();
|
||||
|
||||
public static ArrayList<String> getProxy(String url, String proxyname) throws IOException{
|
||||
public static ArrayList<String> getProxy(String url, String proxyname) throws IOException {
|
||||
Request link = new Request.a()
|
||||
.b(url)
|
||||
.a();
|
||||
|
||||
@@ -22,8 +22,8 @@ import ru.vtosters.lite.proxy.https.CustomHttps;
|
||||
import ru.vtosters.lite.proxy.socks.CustomSocks;
|
||||
import ru.vtosters.lite.proxy.socks.Zaborona;
|
||||
|
||||
public class ProxyUtils{
|
||||
public static String getApi(){
|
||||
public class ProxyUtils {
|
||||
public static String getApi() {
|
||||
var proxyapi = getPrefsValue("proxyapi");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
@@ -37,7 +37,7 @@ public class ProxyUtils{
|
||||
return "api.vk.com";
|
||||
}
|
||||
|
||||
public static String getOauth(){
|
||||
public static String getOauth() {
|
||||
var oauth = getPrefsValue("proxyoauth");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
@@ -51,7 +51,7 @@ public class ProxyUtils{
|
||||
return "oauth.vk.com";
|
||||
}
|
||||
|
||||
public static String getStatic(){
|
||||
public static String getStatic() {
|
||||
var staticapi = getPrefsValue("proxystatic");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
@@ -65,27 +65,27 @@ public class ProxyUtils{
|
||||
return "static.vk.com";
|
||||
}
|
||||
|
||||
public static Boolean isAnyProxyEnabled(){
|
||||
public static Boolean isAnyProxyEnabled() {
|
||||
return isApiProxyEnabled() || isVikaProxyEnabled();
|
||||
}
|
||||
|
||||
public static Boolean isZaboronaEnabled(){
|
||||
public static Boolean isZaboronaEnabled() {
|
||||
return getPrefsValue("proxy").equals("zaborona");
|
||||
}
|
||||
|
||||
public static Boolean isRandomProxyEnabled(){
|
||||
public static Boolean isRandomProxyEnabled() {
|
||||
return getPrefsValue("proxy").equals("randomproxy");
|
||||
}
|
||||
|
||||
public static Boolean isApiProxyEnabled(){
|
||||
public static Boolean isApiProxyEnabled() {
|
||||
return getPrefsValue("proxy").equals("apiproxy");
|
||||
}
|
||||
|
||||
public static Boolean isVikaProxyEnabled(){
|
||||
public static Boolean isVikaProxyEnabled() {
|
||||
return getPrefsValue("proxy").equals("vika");
|
||||
}
|
||||
|
||||
public static void forceProxyApplying(){
|
||||
public static void forceProxyApplying() {
|
||||
Log.d("Proxy", "Setting proxy...");
|
||||
try {
|
||||
var context = getGlobalContext().getApplicationContext();
|
||||
@@ -128,12 +128,12 @@ public class ProxyUtils{
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasProxy(String list){
|
||||
public static boolean hasProxy(String list) {
|
||||
return list.contains(":"); // proxy format: ip:port
|
||||
}
|
||||
|
||||
public static void setProxy() throws IOException{
|
||||
switch(getPrefsValue("proxy")) {
|
||||
public static void setProxy() throws IOException {
|
||||
switch (getPrefsValue("proxy")) {
|
||||
case "zaborona":
|
||||
Zaborona.loadProxy();
|
||||
break;
|
||||
@@ -155,7 +155,7 @@ public class ProxyUtils{
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetProxy(){
|
||||
public static void resetProxy() {
|
||||
clearProperty("https.proxyHost");
|
||||
clearProperty("https.proxyPort");
|
||||
clearProperty("https.proxyUser");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.resetProxy;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
@@ -11,19 +12,19 @@ import ru.vtosters.lite.proxy.socks.Jetkai;
|
||||
import ru.vtosters.lite.proxy.socks.Roosterkid;
|
||||
import ru.vtosters.lite.proxy.socks.TheSpeedX;
|
||||
|
||||
public class RandomProxy{
|
||||
public class RandomProxy {
|
||||
public static String type = preferences.getString("random_type", "none");
|
||||
public static String host = preferences.getString("random_host", "");
|
||||
public static boolean showProxyResult = false;
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
if (host.isEmpty()) {
|
||||
getProxy();
|
||||
loadProxy();
|
||||
return;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case "socks":
|
||||
System.setProperty("socksProxyHost", host.split(":")[0]);
|
||||
System.setProperty("socksProxyPort", host.split(":")[1]);
|
||||
@@ -39,7 +40,7 @@ public class RandomProxy{
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupNewProxy() throws IOException{
|
||||
public static void setupNewProxy() throws IOException {
|
||||
edit().putString("random_type", "none").putString("random_host", "").commit();
|
||||
|
||||
resetProxy();
|
||||
@@ -50,10 +51,10 @@ public class RandomProxy{
|
||||
edit().putString("proxy", "randomproxy").commit();
|
||||
}
|
||||
|
||||
public static void getProxy() throws IOException{
|
||||
public static void getProxy() throws IOException {
|
||||
var random = new java.util.Random();
|
||||
var randomInt = random.nextInt(7);
|
||||
switch(randomInt) {
|
||||
switch (randomInt) {
|
||||
case 0:
|
||||
Hookzof.loadProxy();
|
||||
break;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package ru.vtosters.lite.proxy.api;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isAnyProxyEnabled;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.isVikaProxyEnabled;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class ApiProxy{
|
||||
public static String linkReplacer(String link){
|
||||
public class ApiProxy {
|
||||
public static String linkReplacer(String link) {
|
||||
var vkapi = "api.vk.com";
|
||||
var oauth = "oauth.vk.com";
|
||||
var vkstatic = "static.vk.com";
|
||||
@@ -59,7 +60,7 @@ public class ApiProxy{
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String getAwayPhpCom(){
|
||||
public static String getAwayPhpCom() {
|
||||
var proxyapi = getPrefsValue("proxyapi");
|
||||
|
||||
if (isVikaProxyEnabled()) {
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package ru.vtosters.lite.proxy.api;
|
||||
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
|
||||
public class VikaMobile{
|
||||
public static String getApiHost(){
|
||||
public class VikaMobile {
|
||||
public static String getApiHost() {
|
||||
return isAlternativeHost() ? "vk-api-proxy.vikamobile.ru" : "vk-api-proxy.symbian.live";
|
||||
}
|
||||
|
||||
public static String getOauthHost(){
|
||||
public static String getOauthHost() {
|
||||
return isAlternativeHost() ? "vk-oauth-proxy.vikamobile.ru" : "vk-oauth-proxy.symbian.live";
|
||||
}
|
||||
|
||||
public static String getStaticHost(){
|
||||
public static String getStaticHost() {
|
||||
return isAlternativeHost() ? "vk-static-proxy.vikamobile.ru" : "vk-static-proxy.symbian.live";
|
||||
}
|
||||
|
||||
public static Boolean isAlternativeHost(){
|
||||
public static Boolean isAlternativeHost() {
|
||||
return getBoolValue("altervika", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package ru.vtosters.lite.proxy.http;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
|
||||
public class CustomHttp{
|
||||
public static void loadProxy(){
|
||||
public class CustomHttp {
|
||||
public static void loadProxy() {
|
||||
System.setProperty("http.proxyHost", proxyHostHTTP());
|
||||
System.setProperty("http.proxyPort", proxyPortHTTP());
|
||||
System.setProperty("http.proxyUser", proxyUserHTTP());
|
||||
@@ -11,22 +12,22 @@ public class CustomHttp{
|
||||
forceProxyApplying();
|
||||
}
|
||||
|
||||
private static String proxyHostHTTP(){
|
||||
private static String proxyHostHTTP() {
|
||||
var string = getPrefsValue("proxyHostHTTP");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
private static String proxyPortHTTP(){
|
||||
private static String proxyPortHTTP() {
|
||||
var string = getPrefsValue("proxyPortHTTP");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
private static String proxyUserHTTP(){
|
||||
private static String proxyUserHTTP() {
|
||||
var string = getPrefsValue("proxyUserHTTP");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
private static String proxyPassHTTP(){
|
||||
private static String proxyPassHTTP() {
|
||||
var string = getPrefsValue("proxyPassHTTP");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.http;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class Jetkai{
|
||||
public class Jetkai {
|
||||
private static final String TAG = "Jetkai_Http";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies-http.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -38,7 +39,7 @@ public class Jetkai{
|
||||
RandomProxy.showProxyResult = false;
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "http").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("http.proxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.http;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class TheSpeedX{
|
||||
public class TheSpeedX {
|
||||
private static final String TAG = "TheSpeedX_Http";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -37,7 +38,7 @@ public class TheSpeedX{
|
||||
AndroidUtils.sendToast(getString("proxy_setup_success") + " " + proxy);
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "http").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("http.proxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package ru.vtosters.lite.proxy.https;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
|
||||
public class CustomHttps{
|
||||
public static void loadProxy(){
|
||||
public class CustomHttps {
|
||||
public static void loadProxy() {
|
||||
System.setProperty("https.proxyHost", proxyHostHTTPS());
|
||||
System.setProperty("https.proxyPort", proxyPortHTTPS());
|
||||
System.setProperty("https.proxyUser", proxyUserHTTPS());
|
||||
@@ -11,22 +12,22 @@ public class CustomHttps{
|
||||
forceProxyApplying();
|
||||
}
|
||||
|
||||
private static String proxyHostHTTPS(){
|
||||
private static String proxyHostHTTPS() {
|
||||
var string = getPrefsValue("proxyHostHTTPS");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
private static String proxyPortHTTPS(){
|
||||
private static String proxyPortHTTPS() {
|
||||
var string = getPrefsValue("proxyPortHTTPS");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
private static String proxyUserHTTPS(){
|
||||
private static String proxyUserHTTPS() {
|
||||
var string = getPrefsValue("proxyUserHTTPS");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
private static String proxyPassHTTPS(){
|
||||
private static String proxyPassHTTPS() {
|
||||
String string = getPrefsValue("proxyPassHTTPS");
|
||||
return string.isEmpty() ? "" : string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.https;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class Jetkai{
|
||||
public class Jetkai {
|
||||
private static final String TAG = "Jetkai_Https";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies-https.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -37,7 +38,7 @@ public class Jetkai{
|
||||
AndroidUtils.sendToast(getString("proxy_setup_success") + " " + proxy);
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "https").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("https.proxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.https;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class Roosterkid{
|
||||
public class Roosterkid {
|
||||
private static final String TAG = "Roosterkid_Https";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/roosterkid/openproxylist/main/HTTPS_RAW.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -37,7 +38,7 @@ public class Roosterkid{
|
||||
AndroidUtils.sendToast(getString("proxy_setup_success") + " " + proxy);
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "https").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("https.proxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package ru.vtosters.lite.proxy.socks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
|
||||
public class CustomSocks{
|
||||
public static void loadProxy(){
|
||||
public class CustomSocks {
|
||||
public static void loadProxy() {
|
||||
System.setProperty("socksProxyHost", proxyHostSocks());
|
||||
System.setProperty("socksProxyPort", proxyPortSocks());
|
||||
forceProxyApplying();
|
||||
}
|
||||
|
||||
private static String proxyHostSocks(){
|
||||
private static String proxyHostSocks() {
|
||||
var string = getPrefsValue("proxyHostSocks");
|
||||
return string.isEmpty() ? "192.168.0.1" : string;
|
||||
}
|
||||
|
||||
private static String proxyPortSocks(){
|
||||
private static String proxyPortSocks() {
|
||||
var string = getPrefsValue("proxyPortSocks");
|
||||
return string.isEmpty() ? "8888" : string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.socks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class Hookzof{
|
||||
public class Hookzof {
|
||||
private static final String TAG = "Hookzof_Socks";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/hookzof/socks5_list/master/proxy.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -37,7 +38,7 @@ public class Hookzof{
|
||||
AndroidUtils.sendToast(getString("proxy_setup_success") + " " + proxy);
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.socks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class Jetkai{
|
||||
public class Jetkai {
|
||||
private static final String TAG = "Jetkai_Socks";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies-socks5.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -37,7 +38,7 @@ public class Jetkai{
|
||||
AndroidUtils.sendToast(getString("proxy_setup_success") + " " + proxy);
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.socks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class Roosterkid{
|
||||
public class Roosterkid {
|
||||
private static final String TAG = "Roosterkid_Socks";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/roosterkid/openproxylist/main/SOCKS5_RAW.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -37,7 +38,7 @@ public class Roosterkid{
|
||||
AndroidUtils.sendToast(getString("proxy_setup_success") + " " + proxy);
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.proxy.socks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.GithubList.getProxy;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.hasProxy;
|
||||
@@ -13,10 +14,10 @@ import java.util.ArrayList;
|
||||
import ru.vtosters.lite.proxy.RandomProxy;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class TheSpeedX{
|
||||
public class TheSpeedX {
|
||||
private static final String TAG = "TheSpeedX_Socks";
|
||||
|
||||
public static void loadProxy() throws IOException{
|
||||
public static void loadProxy() throws IOException {
|
||||
ArrayList<String> proxyList = getProxy("https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks5.txt", TAG);
|
||||
|
||||
if (proxyList == null) {
|
||||
@@ -37,7 +38,7 @@ public class TheSpeedX{
|
||||
AndroidUtils.sendToast(getString("proxy_setup_success") + " " + proxy);
|
||||
RandomProxy.showProxyResult = false;
|
||||
}
|
||||
|
||||
|
||||
edit().putString("random_type", "socks").putString("random_host", proxy).commit();
|
||||
|
||||
System.setProperty("socksProxyHost", proxy.split(":")[0]);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package ru.vtosters.lite.proxy.socks;
|
||||
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.forceProxyApplying;
|
||||
|
||||
public class Zaborona{
|
||||
public static void loadProxy(){
|
||||
public class Zaborona {
|
||||
public static void loadProxy() {
|
||||
System.setProperty("socksProxyHost", "socks.zaboronahelp.pp.ua");
|
||||
System.setProperty("socksProxyPort", "1488");
|
||||
forceProxyApplying();
|
||||
|
||||
@@ -11,24 +11,10 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public abstract class BaseTranslator {
|
||||
|
||||
private final LruCache<String, String> cache = new LruCache<>(200);
|
||||
|
||||
private static final int YANDEX = 0;
|
||||
private static final int GOOGLE = 1;
|
||||
private static final int DEEPL = 2;
|
||||
|
||||
@NonNull
|
||||
public abstract String translate(String text, String tl);
|
||||
|
||||
@NonNull
|
||||
public final String getTranslation(String text) {
|
||||
var val = cache.get(text);
|
||||
if (val != null)
|
||||
return val;
|
||||
var translation = translate(text, getToLanguage());
|
||||
cache.put(text, translation);
|
||||
return translation;
|
||||
}
|
||||
private final LruCache<String, String> cache = new LruCache<>(200);
|
||||
|
||||
public static String getToLanguage() {
|
||||
var lang = preferences.getString("lang_target", "system");
|
||||
@@ -51,4 +37,17 @@ public abstract class BaseTranslator {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public abstract String translate(String text, String tl);
|
||||
|
||||
@NonNull
|
||||
public final String getTranslation(String text) {
|
||||
var val = cache.get(text);
|
||||
if (val != null)
|
||||
return val;
|
||||
var translation = translate(text, getToLanguage());
|
||||
cache.put(text, translation);
|
||||
return translation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ public class DeepLTranslator extends BaseTranslator {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static Long getTimestamp(int iNumber) {
|
||||
var now = System.currentTimeMillis();
|
||||
return Long.valueOf((((long) iNumber) + now) - (now % ((long) iNumber)));
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String translate(String text, String tl) {
|
||||
@@ -126,9 +131,4 @@ public class DeepLTranslator extends BaseTranslator {
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static Long getTimestamp(int iNumber) {
|
||||
var now = System.currentTimeMillis();
|
||||
return Long.valueOf((((long) iNumber) + now) - (now % ((long) iNumber)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import ru.vtosters.lite.utils.LayoutUtils;
|
||||
|
||||
public class VKAdminTokenActivity extends AppCompatActivity {
|
||||
|
||||
private static final String URL = "https://" + getOauth() +"/authorize?client_id=6121396&scope=1073737727&redirect_uri=https://oauth.vk.com/blank.html&display=page&response_type=token&revoke=1";
|
||||
private static final String URL = "https://" + getOauth() + "/authorize?client_id=6121396&scope=1073737727&redirect_uri=https://oauth.vk.com/blank.html&display=page&response_type=token&revoke=1";
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle bundle) {
|
||||
|
||||
@@ -218,6 +218,10 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
|
||||
return true;
|
||||
}
|
||||
|
||||
public interface IViewHolderBinder {
|
||||
void bind(CategorizedViewHolder holder, int pos);
|
||||
}
|
||||
|
||||
public static class CategorizedViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final LinearLayout mMovingItemContainer;
|
||||
@@ -262,8 +266,4 @@ public class CategorizedAdapter extends RecyclerView.Adapter<CategorizedAdapter.
|
||||
mMovingItemContainer.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IViewHolderBinder {
|
||||
void bind(CategorizedViewHolder holder, int pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import ru.vtosters.lite.utils.LayoutUtils;
|
||||
|
||||
public class ImagineArrayAdapter extends ArrayAdapter<ImagineArrayAdapter.ImagineArrayAdapterItem> {
|
||||
|
||||
private List<ImagineArrayAdapterItem> mItems = new ArrayList<>();
|
||||
private final OnClickListener mListener;
|
||||
private List<ImagineArrayAdapterItem> mItems = new ArrayList<>();
|
||||
private int mSelectedIndex = -1;
|
||||
|
||||
public ImagineArrayAdapter(@NonNull Context context, OnClickListener listener) {
|
||||
@@ -133,6 +133,10 @@ public class ImagineArrayAdapter extends ArrayAdapter<ImagineArrayAdapter.Imagin
|
||||
return container;
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
void onClick(int i);
|
||||
}
|
||||
|
||||
public static class ImagineArrayAdapterItem {
|
||||
private final Drawable mIcon;
|
||||
private final String mText;
|
||||
@@ -165,8 +169,4 @@ public class ImagineArrayAdapter extends ArrayAdapter<ImagineArrayAdapter.Imagin
|
||||
return mText;
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnClickListener {
|
||||
void onClick(int i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ public class MessagesPreviewAdapter extends RecyclerView.Adapter<MessagesPreview
|
||||
|
||||
private final String[] mMessages = AndroidUtils.getArray("wallpaper_change_dialog");
|
||||
|
||||
private static int getColorFromAttribute(Context context, int attrId) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(attrId, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
return i % 2 == 0 ? ANONYMOUS : ME;
|
||||
@@ -70,12 +76,6 @@ public class MessagesPreviewAdapter extends RecyclerView.Adapter<MessagesPreview
|
||||
return mMessages.length;
|
||||
}
|
||||
|
||||
private static int getColorFromAttribute(Context context, int attrId) {
|
||||
TypedValue typedValue = new TypedValue();
|
||||
context.getTheme().resolveAttribute(attrId, typedValue, true);
|
||||
return typedValue.data;
|
||||
}
|
||||
|
||||
protected static class MessagePreviewViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final TextView mMessage;
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.aefyr.tsg.g2.TelegramStickersPack;
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
|
||||
import ru.vtosters.lite.tgs.TGPref;
|
||||
import ru.vtosters.lite.ui.components.IItemMovingListener;
|
||||
|
||||
@@ -37,8 +37,10 @@ public class CrashReporter {
|
||||
Thread.setDefaultUncaughtExceptionHandler((thread, th) -> CrashReporter.start(defaultUncaughtExceptionHandler, thread, th, activity));
|
||||
}
|
||||
|
||||
@SuppressLint("UnspecifiedImmutableFlag")
|
||||
static void start(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th, Activity activity) {
|
||||
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(getGlobalContext()).toDeviceName() + ", commit: " + getBuildNumber();
|
||||
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect().toDeviceName();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
var notificationChannel = new NotificationChannel("crashes", "crash", NotificationManager.IMPORTANCE_DEFAULT);
|
||||
notificationChannel.enableVibration(true);
|
||||
@@ -58,6 +60,7 @@ public class CrashReporter {
|
||||
var saveLogIntent = new Intent(getGlobalContext(), LogWriterService.class);
|
||||
saveLogIntent.putExtra("log", logString);
|
||||
saveLogIntent.putExtra("notificationId", 1);
|
||||
|
||||
@SuppressLint("UnspecifiedImmutableFlag")
|
||||
var psaveLogIntent = PendingIntent.getService(getGlobalContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
@@ -74,9 +77,8 @@ public class CrashReporter {
|
||||
builder.setChannelId("crashes");
|
||||
}
|
||||
|
||||
|
||||
((NotificationManager) getGlobalContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(-2147483548, builder.build());
|
||||
Log.e("VTosters Lite", "crashed: " + th.getLocalizedMessage());
|
||||
Log.e("VLite", "crashed: " + th.getLocalizedMessage());
|
||||
uncaughtExceptionHandler.uncaughtException(thread, th);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package ru.vtosters.lite.ui.components;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
import static ru.vtosters.lite.utils.Preferences.superapp;
|
||||
import static ru.vtosters.lite.utils.Preferences.useNewSettings;
|
||||
@@ -33,7 +32,6 @@ import com.vtosters.lite.fragments.p2.DocumentsViewFragment;
|
||||
import com.vtosters.lite.fragments.s2.GroupsFragment1;
|
||||
import com.vtosters.lite.fragments.t2.c.DialogsFragment;
|
||||
import com.vtosters.lite.fragments.y2.VideoCatalogFragment;
|
||||
import com.vtosters.lite.fragments.y2.VideosFragment;
|
||||
import com.vtosters.lite.general.fragments.GamesFragment;
|
||||
import com.vtosters.lite.general.fragments.PhotosFragment;
|
||||
|
||||
@@ -49,11 +47,13 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
public class DockBarEditorManager {
|
||||
public static final int MIN_SELECTED_TABS = 3;
|
||||
public static final int MAX_SELECTED_TABS = 9;
|
||||
|
||||
private static DockBarEditorManager sInstance;
|
||||
private final List<DockBarTab> mSelectedTabs = new ArrayList<>();
|
||||
private final List<DockBarTab> mDisabledTabs = new ArrayList<>();
|
||||
|
||||
private static DockBarEditorManager sInstance;
|
||||
public DockBarEditorManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
public static DockBarEditorManager getInstance() {
|
||||
return sInstance == null
|
||||
@@ -61,10 +61,6 @@ public class DockBarEditorManager {
|
||||
: sInstance;
|
||||
}
|
||||
|
||||
public DockBarEditorManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (vkme()) {
|
||||
mSelectedTabs.add(getTabByTag("tab_settings"));
|
||||
|
||||
@@ -23,7 +23,7 @@ public class StickerTouchHelperCallback extends ItemTouchHelper.Callback {
|
||||
|
||||
@Override
|
||||
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
|
||||
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN |
|
||||
int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN |
|
||||
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT;
|
||||
|
||||
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
|
||||
|
||||
@@ -14,10 +14,13 @@ import ru.vtosters.lite.utils.AndroidUtils;
|
||||
|
||||
public class SuperAppEditorManager {
|
||||
|
||||
private static SuperAppEditorManager sInstance;
|
||||
private final List<SuperAppItem> mSelectedItems = new ArrayList<>();
|
||||
private final List<SuperAppItem> mDisabledItems = new ArrayList<>();
|
||||
|
||||
private static SuperAppEditorManager sInstance;
|
||||
public SuperAppEditorManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
public static SuperAppEditorManager getInstance() {
|
||||
return sInstance == null
|
||||
@@ -25,10 +28,6 @@ public class SuperAppEditorManager {
|
||||
: sInstance;
|
||||
}
|
||||
|
||||
public SuperAppEditorManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
var tmp = getPreferences().getString("superapp_items", "menu,miniapps,vkpay_slim,greeting,promo,holiday,weather,sport,games,informer,food,event,music,vk_run");
|
||||
var selectedTags = !tmp.isEmpty() ? tmp.split(",") : new String[0];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
@@ -13,7 +14,7 @@ import com.vk.core.dialogs.alert.VkAlertDialog;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LayoutUtils;
|
||||
|
||||
public class RoundingSeekbarDialog{
|
||||
public class RoundingSeekbarDialog {
|
||||
public static void dialog(Context context) {
|
||||
LinearLayout mContainer = new LinearLayout(context);
|
||||
SeekBar seek = new SeekBar(context);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.ui.dialogs;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getString;
|
||||
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
|
||||
@@ -10,8 +11,8 @@ import com.vk.core.ui.themes.VKThemeHelper;
|
||||
|
||||
import ru.vtosters.lite.hooks.VKUIHook;
|
||||
|
||||
public class ThemeChanging{
|
||||
public static void changeTheme(Activity activity, float[] f){
|
||||
public class ThemeChanging {
|
||||
public static void changeTheme(Activity activity, float[] f) {
|
||||
if (getBoolValue("systemtheme", true)) {
|
||||
new VkAlertDialog.Builder(activity)
|
||||
.setTitle(getString("warning"))
|
||||
|
||||
@@ -23,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());
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment{
|
||||
setupFilters();
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
findPreference("sourcenamefilter").setOnPreferenceClickListener(preference -> {
|
||||
setupFilters();
|
||||
return true;
|
||||
@@ -81,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;
|
||||
|
||||
@@ -92,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"));
|
||||
@@ -106,7 +106,7 @@ public class FeedFragment extends MaterialPreferenceToolbarFragment{
|
||||
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) {
|
||||
@@ -126,15 +126,15 @@ 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){
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(NewsfeedSettingsFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
@@ -7,7 +7,6 @@ import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -29,7 +28,7 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
findPreference("swipe").setOnPreferenceClickListener(new restart());
|
||||
findPreference("is_likes_on_right").setOnPreferenceClickListener(new restart());
|
||||
|
||||
if (isTablet()){
|
||||
if (isTablet()) {
|
||||
findPreference("menusett").setVisible(false);
|
||||
findPreference("swipe").setVisible(false);
|
||||
}
|
||||
@@ -39,7 +38,7 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 33){
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
findPreference("anim_rtrn_type").setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ 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.NewsFeedFiltersUtils.setupFilters;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAccentColor;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getAlertStyle;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getSTextAttr;
|
||||
@@ -51,11 +50,28 @@ import ru.vtosters.lite.music.Scrobbler;
|
||||
import ru.vtosters.lite.music.cache.CacheDatabaseDelegate;
|
||||
import ru.vtosters.lite.ui.adapters.ImagineArrayAdapter;
|
||||
import ru.vtosters.lite.utils.AndroidUtils;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
private static final ExecutorService executor = Executors.newCachedThreadPool();
|
||||
|
||||
public static void download(Context ctx) {
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx, getAlertStyle());
|
||||
alertDialog.setTitle(AndroidUtils.getString("video_dl_enter_link"));
|
||||
|
||||
final EditText input = new EditText(ctx);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
input.setLayoutParams(lp);
|
||||
input.setTextColor(getTextAttr());
|
||||
input.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
|
||||
alertDialog.setView(input);
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("download"), (dialog, which) -> VideoDownloader.parseVideoLink(input.getText().toString(), ctx));
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(getAccentColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
@@ -97,7 +113,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
findPreference("cached_tracks").setSummary(String.format(AndroidUtils.getString("cached_tracks_counter"), CacheDatabaseDelegate.getTrackCount()));
|
||||
findPreference("cached_tracks").setOnPreferenceClickListener(preference -> {
|
||||
if (CacheDatabaseDelegate.getTrackCount() == 0){
|
||||
if (CacheDatabaseDelegate.getTrackCount() == 0) {
|
||||
sendToast(AndroidUtils.getString("no_cache_error"));
|
||||
} else {
|
||||
delcache(requireContext());
|
||||
@@ -110,7 +126,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
});
|
||||
|
||||
if (!isVkxInstalled()){
|
||||
if (!isVkxInstalled()) {
|
||||
findPreference("vkx_sett").setVisible(false);
|
||||
}
|
||||
|
||||
@@ -222,7 +238,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(getAccentColor());
|
||||
alert.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(getAccentColor());;
|
||||
alert.getButton(DialogInterface.BUTTON_NEGATIVE).setTextColor(getAccentColor());
|
||||
}
|
||||
|
||||
public void deleteVideoHistory() {
|
||||
@@ -236,7 +252,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
try {
|
||||
var response = new JSONObject(new OkHttpClient().a(request).execute().a().g());
|
||||
|
||||
if (response.optInt("response") == 1){
|
||||
if (response.optInt("response") == 1) {
|
||||
requireActivity().runOnUiThread(() -> sendToast(AndroidUtils.getString("video_history_cleaned")));
|
||||
} else {
|
||||
requireActivity().runOnUiThread(() -> sendToast(AndroidUtils.getString("delete_video_history_error")));
|
||||
@@ -254,7 +270,7 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private void deleteVideoHistoryDialog(Context context){
|
||||
private void deleteVideoHistoryDialog(Context context) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context);
|
||||
builder.setTitle(AndroidUtils.getString("warning"));
|
||||
builder.setMessage(AndroidUtils.getString("delete_video_history_confirm"));
|
||||
@@ -266,22 +282,13 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public static void download(Context ctx) {
|
||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx, getAlertStyle());
|
||||
alertDialog.setTitle(AndroidUtils.getString("video_dl_enter_link"));
|
||||
|
||||
final EditText input = new EditText(ctx);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
input.setLayoutParams(lp);
|
||||
input.setTextColor(getTextAttr());
|
||||
input.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
|
||||
alertDialog.setView(input);
|
||||
alertDialog.setPositiveButton(AndroidUtils.getString("download"), (dialog, which) -> VideoDownloader.parseVideoLink(input.getText().toString(), ctx));
|
||||
var alert = alertDialog.create();
|
||||
alert.show();
|
||||
alert.getButton(DialogInterface.BUTTON_POSITIVE).setTextColor(getAccentColor());
|
||||
private static class restart implements Preference.OnPreferenceChangeListener {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
edit().putString("dateformat", o.toString()).commit();
|
||||
restartApplicationWithTimer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class download implements Preference.OnPreferenceClickListener {
|
||||
@@ -291,13 +298,4 @@ public class MediaFragment extends MaterialPreferenceToolbarFragment {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static class restart implements Preference.OnPreferenceChangeListener {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
edit().putString("dateformat", o.toString()).commit();
|
||||
restartApplicationWithTimer();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class MessagesFragment extends MaterialPreferenceToolbarFragment {
|
||||
findPreference("wallpapers").setIcon(recolorDrawable(getGlobalContext().getDrawable(getIdentifier("ic_media_outline_28", "drawable"))));
|
||||
findPreference("vkme").setIcon(getIdentifier("ic_vkme_28", "drawable"));
|
||||
|
||||
if (isTablet()){
|
||||
if (isTablet()) {
|
||||
findPreference("alteremoji").setVisible(false);
|
||||
findPreference("vkmesett").setVisible(false);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.ContactsUtils.setContactsSync;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
@@ -278,6 +277,19 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void delprefs(Context context) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context);
|
||||
builder.setTitle(AndroidUtils.getString("warning"));
|
||||
builder.setMessage(AndroidUtils.getString("settings_reset_confirm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
|
||||
deletePrefs();
|
||||
restartApplication();
|
||||
});
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss());
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public static class d implements Preference.OnPreferenceClickListener {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
@@ -286,6 +298,25 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
}
|
||||
|
||||
public static class b implements Preference.OnPreferenceClickListener {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
System.exit(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class saveprefs implements Preference.OnPreferenceClickListener {
|
||||
saveprefs() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
backupSettings();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class onlines implements Preference.OnPreferenceClickListener {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
@@ -298,27 +329,6 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
}
|
||||
|
||||
public static class b implements Preference.OnPreferenceClickListener {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
System.exit(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void delprefs(Context context) {
|
||||
VkAlertDialog.Builder builder = new VkAlertDialog.Builder(context);
|
||||
builder.setTitle(AndroidUtils.getString("warning"));
|
||||
builder.setMessage(AndroidUtils.getString("settings_reset_confirm"));
|
||||
builder.setCancelable(false);
|
||||
builder.setPositiveButton(AndroidUtils.getString("yes"), (dialogInterface, i) -> {
|
||||
deletePrefs();
|
||||
restartApplication();
|
||||
});
|
||||
builder.setNegativeButton(AndroidUtils.getString("cancel"), (dialogInterface, i) -> dialogInterface.dismiss());
|
||||
builder.show();
|
||||
}
|
||||
|
||||
class c implements Preference.OnPreferenceClickListener {
|
||||
public void copy(Context context, String str) {
|
||||
((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", str));
|
||||
@@ -349,17 +359,6 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
|
||||
}
|
||||
}
|
||||
|
||||
public static class saveprefs implements Preference.OnPreferenceClickListener {
|
||||
saveprefs() {
|
||||
}
|
||||
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
backupSettings();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class restoreprefs implements Preference.OnPreferenceClickListener {
|
||||
@Override // android.support.v7.preference.Preference.c
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package ru.vtosters.lite.ui.fragments;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPreferences;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.isTablet;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
|
||||
|
||||
@@ -15,8 +14,6 @@ import androidx.preference.Preference;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment;
|
||||
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
|
||||
public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
|
||||
@@ -37,22 +34,11 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
findPreference("dockbar_accent").setOnPreferenceClickListener(new restart());
|
||||
findPreference("dockcounter").setOnPreferenceClickListener(new restart());
|
||||
|
||||
if (isTablet()){
|
||||
if (isTablet()) {
|
||||
findPreference("dockbarsett").setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public class openicons implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(IconsFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class restart implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
@@ -78,4 +64,15 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class openicons implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Context context = requireContext();
|
||||
Intent a2 = new Navigator(IconsFragment.class).b(context);
|
||||
a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(a2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package ru.vtosters.lite.ui.vkui;
|
||||
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
|
||||
|
||||
@@ -10,8 +11,8 @@ import android.widget.LinearLayout;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VBListBuilder{
|
||||
public static ViewGroup buildListOf(Context ctx, List<VBListItem> items){
|
||||
public class VBListBuilder {
|
||||
public static ViewGroup buildListOf(Context ctx, List<VBListItem> items) {
|
||||
LinearLayout mainView = new LinearLayout(ctx);
|
||||
mainView.setOrientation(LinearLayout.VERTICAL);
|
||||
mainView.setPadding(dp2px(8f), 0, dp2px(8f), 0);
|
||||
@@ -36,12 +37,12 @@ public class VBListBuilder{
|
||||
return mainView;
|
||||
}
|
||||
|
||||
public static class VBListItem{
|
||||
public static class VBListItem {
|
||||
public String id;
|
||||
public String title;
|
||||
public boolean checked;
|
||||
|
||||
public VBListItem(String id, String title, boolean checked){
|
||||
public VBListItem(String id, String title, boolean checked) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.checked = checked;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -19,14 +19,10 @@ import com.vk.medianative.MediaNative;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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 class ImageFilters {
|
||||
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;
|
||||
|
||||
@@ -50,7 +46,13 @@ public class ImageFilters{
|
||||
orig = getMonochrome(orig);
|
||||
}
|
||||
|
||||
Bitmap bm = ((BitmapDrawable) orig).getBitmap();
|
||||
Bitmap bm;
|
||||
|
||||
if (orig != null) {
|
||||
bm = ((BitmapDrawable) orig).getBitmap();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
Bitmap instance = bm.copy(Bitmap.Config.ARGB_8888, true);
|
||||
|
||||
@@ -81,9 +83,9 @@ public class ImageFilters{
|
||||
return new BitmapDrawable(getResources(), instance);
|
||||
}
|
||||
|
||||
private static int getRadius(){
|
||||
private static int getRadius() {
|
||||
String radius = getPreferences().getString("msg_blur_radius", "disabled");
|
||||
switch(radius) {
|
||||
switch (radius) {
|
||||
case "low":
|
||||
return 8;
|
||||
case "med":
|
||||
@@ -93,7 +95,7 @@ public class ImageFilters{
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getBlurredWallpaper(Drawable orig, int radius){
|
||||
public static Drawable getBlurredWallpaper(Drawable orig, int radius) {
|
||||
try {
|
||||
if (orig == null) return null;
|
||||
if (!(orig instanceof BitmapDrawable)) return orig; // we need only BitmapDrawable
|
||||
@@ -109,7 +111,7 @@ public class ImageFilters{
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable getMosaic(Drawable orig){
|
||||
public static Drawable getMosaic(Drawable orig) {
|
||||
int scale = 100;
|
||||
|
||||
if (orig == null) return null;
|
||||
@@ -122,7 +124,7 @@ public class ImageFilters{
|
||||
|
||||
String radius = getPreferences().getString("msg_mosaic", "disabled");
|
||||
|
||||
switch(radius) {
|
||||
switch (radius) {
|
||||
case "high":
|
||||
scale = 25;
|
||||
break;
|
||||
@@ -139,7 +141,7 @@ 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();
|
||||
@@ -147,7 +149,7 @@ public class ImageFilters{
|
||||
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":
|
||||
@@ -156,7 +158,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();
|
||||
@@ -179,7 +181,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);
|
||||
@@ -191,7 +193,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);
|
||||
@@ -203,7 +205,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
|
||||
@@ -233,7 +235,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();
|
||||
@@ -270,8 +272,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}
|
||||
@@ -283,7 +285,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;
|
||||
@@ -293,7 +295,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();
|
||||
@@ -303,7 +305,7 @@ public class ImageFilters{
|
||||
// a random object
|
||||
Random random = new Random();
|
||||
|
||||
int index = 0;
|
||||
int index;
|
||||
// iteration through pixels
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
@@ -322,7 +324,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();
|
||||
@@ -332,7 +334,7 @@ public class ImageFilters{
|
||||
// random object
|
||||
Random random = new Random();
|
||||
|
||||
int R, G, B, index = 0, thresHold = 50;
|
||||
int R, G, B, index, thresHold;
|
||||
// iteration through pixels
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
@@ -354,389 +356,4 @@ public class ImageFilters{
|
||||
bmOut.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyDecreaseColorDepthEffect(Bitmap src, int bitOffset){
|
||||
// get image size
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
// create output bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
|
||||
// color information
|
||||
int A, R, G, B;
|
||||
int pixel;
|
||||
|
||||
// scan through all pixels
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
// get pixel color
|
||||
pixel = src.getPixel(x, y);
|
||||
A = Color.alpha(pixel);
|
||||
R = Color.red(pixel);
|
||||
G = Color.green(pixel);
|
||||
B = Color.blue(pixel);
|
||||
|
||||
// round-off color offset
|
||||
R = ((R + (bitOffset / 2)) - ((R + (bitOffset / 2)) % bitOffset) - 1);
|
||||
if (R < 0) {
|
||||
R = 0;
|
||||
}
|
||||
G = ((G + (bitOffset / 2)) - ((G + (bitOffset / 2)) % bitOffset) - 1);
|
||||
if (G < 0) {
|
||||
G = 0;
|
||||
}
|
||||
B = ((B + (bitOffset / 2)) - ((B + (bitOffset / 2)) % bitOffset) - 1);
|
||||
if (B < 0) {
|
||||
B = 0;
|
||||
}
|
||||
|
||||
// set pixel color to output bitmap
|
||||
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
|
||||
}
|
||||
}
|
||||
|
||||
// return final image
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyContrastEffect(Bitmap src, double value){
|
||||
// image size
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
// create output bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
|
||||
// color information
|
||||
int A, R, G, B;
|
||||
int pixel;
|
||||
// get contrast value
|
||||
double contrast = Math.pow((100 + value) / 100, 2);
|
||||
|
||||
// scan through all pixels
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
// get pixel color
|
||||
pixel = src.getPixel(x, y);
|
||||
A = Color.alpha(pixel);
|
||||
// apply filter contrast for every channel R, G, B
|
||||
R = Color.red(pixel);
|
||||
R = (int) (((((R / 255.0) - 0.5) * contrast) + 0.5) * 255.0);
|
||||
if (R < 0) {
|
||||
R = 0;
|
||||
} else if (R > 255) {
|
||||
R = 255;
|
||||
}
|
||||
|
||||
G = Color.red(pixel);
|
||||
G = (int) (((((G / 255.0) - 0.5) * contrast) + 0.5) * 255.0);
|
||||
if (G < 0) {
|
||||
G = 0;
|
||||
} else if (G > 255) {
|
||||
G = 255;
|
||||
}
|
||||
|
||||
B = Color.red(pixel);
|
||||
B = (int) (((((B / 255.0) - 0.5) * contrast) + 0.5) * 255.0);
|
||||
if (B < 0) {
|
||||
B = 0;
|
||||
} else if (B > 255) {
|
||||
B = 255;
|
||||
}
|
||||
|
||||
// set new pixel color to output bitmap
|
||||
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
|
||||
}
|
||||
}
|
||||
|
||||
// return final image
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyBrightnessEffect(Bitmap src, int value){
|
||||
// image size
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
// create output bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
|
||||
// color information
|
||||
int A, R, G, B;
|
||||
int pixel;
|
||||
|
||||
// scan through all pixels
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
// get pixel color
|
||||
pixel = src.getPixel(x, y);
|
||||
A = Color.alpha(pixel);
|
||||
R = Color.red(pixel);
|
||||
G = Color.green(pixel);
|
||||
B = Color.blue(pixel);
|
||||
|
||||
// increase/decrease each channel
|
||||
R += value;
|
||||
if (R > 255) {
|
||||
R = 255;
|
||||
} else if (R < 0) {
|
||||
R = 0;
|
||||
}
|
||||
|
||||
G += value;
|
||||
if (G > 255) {
|
||||
G = 255;
|
||||
} else if (G < 0) {
|
||||
G = 0;
|
||||
}
|
||||
|
||||
B += value;
|
||||
if (B > 255) {
|
||||
B = 255;
|
||||
} else if (B < 0) {
|
||||
B = 0;
|
||||
}
|
||||
|
||||
// apply new pixel color to output bitmap
|
||||
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
|
||||
}
|
||||
}
|
||||
|
||||
// return final image
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyGaussianBlurEffect(Bitmap src){
|
||||
double[][] GaussianBlurConfig = new double[][] {
|
||||
{1, 2, 1},
|
||||
{2, 4, 2},
|
||||
{1, 2, 1}
|
||||
};
|
||||
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
|
||||
convMatrix.applyConfig(GaussianBlurConfig);
|
||||
convMatrix.Factor = 16;
|
||||
convMatrix.Offset = 0;
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public Bitmap applySharpenEffect(Bitmap src, double weight){
|
||||
double[][] SharpConfig = new double[][] {
|
||||
{0, -2, 0},
|
||||
{-2, weight, -2},
|
||||
{0, -2, 0}
|
||||
};
|
||||
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
|
||||
convMatrix.applyConfig(SharpConfig);
|
||||
convMatrix.Factor = weight - 8;
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public Bitmap applyMeanRemovalEffect(Bitmap src){
|
||||
double[][] MeanRemovalConfig = new double[][] {
|
||||
{-1, -1, -1},
|
||||
{-1, 9, -1},
|
||||
{-1, -1, -1}
|
||||
};
|
||||
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
|
||||
convMatrix.applyConfig(MeanRemovalConfig);
|
||||
convMatrix.Factor = 1;
|
||||
convMatrix.Offset = 0;
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
public Bitmap applySmoothEffect(Bitmap src, double value){
|
||||
ConvolutionMatrix convMatrix = new ConvolutionMatrix(3);
|
||||
convMatrix.setAll(1);
|
||||
convMatrix.Matrix[1][1] = value;
|
||||
convMatrix.Factor = value + 8;
|
||||
convMatrix.Offset = 1;
|
||||
return ConvolutionMatrix.computeConvolution3x3(src, convMatrix);
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
int A, R, G, B;
|
||||
int pixel;
|
||||
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
pixel = src.getPixel(x, y);
|
||||
A = Color.alpha(pixel);
|
||||
R = Color.red(pixel);
|
||||
G = Color.green(pixel);
|
||||
B = Color.blue(pixel);
|
||||
if (type == 1) {
|
||||
R = (int) (R * (1 + percent));
|
||||
if (R > 255) R = 255;
|
||||
} else if (type == 2) {
|
||||
G = (int) (G * (1 + percent));
|
||||
if (G > 255) G = 255;
|
||||
} else if (type == 3) {
|
||||
B = (int) (B * (1 + percent));
|
||||
if (B > 255) B = 255;
|
||||
}
|
||||
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
|
||||
}
|
||||
}
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyTintEffect(Bitmap src, int degree){
|
||||
|
||||
int width = src.getWidth();
|
||||
int height = src.getHeight();
|
||||
|
||||
int[] pix = new int[width * height];
|
||||
src.getPixels(pix, 0, width, 0, 0, width, height);
|
||||
|
||||
int RY, GY, BY, RYY, GYY, BYY, R, G, B, Y;
|
||||
double angle = (PI * (double) degree) / HALF_CIRCLE_DEGREE;
|
||||
|
||||
int S = (int) (RANGE * Math.sin(angle));
|
||||
int C = (int) (RANGE * Math.cos(angle));
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
for (int x = 0; x < width; x++) {
|
||||
int index = y * width + x;
|
||||
int r = (pix[index] >> 16) & 0xff;
|
||||
int g = (pix[index] >> 8) & 0xff;
|
||||
int b = pix[index] & 0xff;
|
||||
RY = (70 * r - 59 * g - 11 * b) / 100;
|
||||
GY = (-30 * r + 41 * g - 11 * b) / 100;
|
||||
BY = (-30 * r - 59 * g + 89 * b) / 100;
|
||||
Y = (30 * r + 59 * g + 11 * b) / 100;
|
||||
RYY = (S * BY + C * RY) / 256;
|
||||
BYY = (C * BY - S * RY) / 256;
|
||||
GYY = (-51 * RYY - 19 * BYY) / 100;
|
||||
R = Y + RYY;
|
||||
R = (R < 0) ? 0 : (Math.min(R, 255));
|
||||
G = Y + GYY;
|
||||
G = (G < 0) ? 0 : (Math.min(G, 255));
|
||||
B = Y + BYY;
|
||||
B = (B < 0) ? 0 : (Math.min(B, 255));
|
||||
pix[index] = 0xff000000 | (R << 16) | (G << 8) | B;
|
||||
}
|
||||
|
||||
Bitmap outBitmap = Bitmap.createBitmap(width, height, src.getConfig());
|
||||
outBitmap.setPixels(pix, 0, width, 0, 0, width, height);
|
||||
|
||||
pix = null;
|
||||
|
||||
return outBitmap;
|
||||
}
|
||||
|
||||
public Bitmap applyBlackFilter(Bitmap source){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
int[] pixels = new int[width * height];
|
||||
// get pixel array from source
|
||||
source.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||
// random object
|
||||
Random random = new Random();
|
||||
|
||||
int R, G, B, index = 0, thresHold = 0;
|
||||
// iteration through pixels
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
// get current index in 2D-matrix
|
||||
index = y * width + x;
|
||||
// get color
|
||||
R = Color.red(pixels[index]);
|
||||
G = Color.green(pixels[index]);
|
||||
B = Color.blue(pixels[index]);
|
||||
// generate threshold
|
||||
thresHold = random.nextInt(COLOR_MAX);
|
||||
if (R < thresHold && G < thresHold && B < thresHold) {
|
||||
pixels[index] = Color.rgb(COLOR_MIN, COLOR_MIN, COLOR_MIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
// output bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bmOut.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyShadingFilter(Bitmap source, int shadingColor){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
int[] pixels = new int[width * height];
|
||||
// get pixel array from source
|
||||
source.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||
|
||||
int index = 0;
|
||||
// iteration through pixels
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
// get current index in 2D-matrix
|
||||
index = y * width + x;
|
||||
// AND
|
||||
pixels[index] &= shadingColor;
|
||||
}
|
||||
}
|
||||
// output bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bmOut.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applySaturationFilter(Bitmap source, int level){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
int[] pixels = new int[width * height];
|
||||
float[] HSV = new float[3];
|
||||
// get pixel array from source
|
||||
source.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||
|
||||
int index = 0;
|
||||
// iteration through pixels
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
// get current index in 2D-matrix
|
||||
index = y * width + x;
|
||||
// convert to HSV
|
||||
Color.colorToHSV(pixels[index], HSV);
|
||||
// increase Saturation level
|
||||
HSV[1] *= level;
|
||||
HSV[1] = (float) Math.max(0.0, Math.min(HSV[1], 1.0));
|
||||
// take color back
|
||||
pixels[index] |= Color.HSVToColor(HSV);
|
||||
}
|
||||
}
|
||||
// output bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bmOut.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bmOut;
|
||||
}
|
||||
|
||||
public Bitmap applyHueFilter(Bitmap source, int level){
|
||||
// get image size
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
int[] pixels = new int[width * height];
|
||||
float[] HSV = new float[3];
|
||||
// get pixel array from source
|
||||
source.getPixels(pixels, 0, width, 0, 0, width, height);
|
||||
|
||||
int index = 0;
|
||||
// iteration through pixels
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x) {
|
||||
// get current index in 2D-matrix
|
||||
index = y * width + x;
|
||||
// convert to HSV
|
||||
Color.colorToHSV(pixels[index], HSV);
|
||||
// increase Saturation level
|
||||
HSV[0] *= level;
|
||||
HSV[0] = (float) Math.max(0.0, Math.min(HSV[0], 360.0));
|
||||
// take color back
|
||||
pixels[index] |= Color.HSVToColor(HSV);
|
||||
}
|
||||
}
|
||||
// output bitmap
|
||||
Bitmap bmOut = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
bmOut.setPixels(pixels, 0, width, 0, 0, width, height);
|
||||
return bmOut;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
@@ -81,21 +81,21 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment{
|
||||
|
||||
if (!hasVerification() && !getBoolValue("dialogrecomm", false)) {
|
||||
PreferencesUtil.addPreference(this, "", AndroidUtils.getString("filters_warning"), AndroidUtils.getString("icons_warning_info"), null, preference -> {
|
||||
getContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://vtosters.app/donate/")));
|
||||
requireContext().startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://vtosters.app/donate/")));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
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,7 +199,7 @@ 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)
|
||||
@@ -224,14 +224,14 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment{
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
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,7 +56,7 @@ public class WallpaperPreferences extends Preference{
|
||||
requestBg();
|
||||
}
|
||||
|
||||
private void requestBg(){
|
||||
private void requestBg() {
|
||||
final Drawable drawable = getFilteredFile();
|
||||
|
||||
if (drawable != null && getWallpaperFile() != null)
|
||||
@@ -66,7 +66,7 @@ public class WallpaperPreferences extends Preference{
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
void redraw(){
|
||||
void redraw() {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
requestBg();
|
||||
}
|
||||
|
||||
@@ -18,18 +18,17 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
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 Drawable mWallpaper;
|
||||
private static boolean mUpdateWallpaperRequested = true;
|
||||
private static boolean mUpdateWallpaperFileRequested = true;
|
||||
|
||||
public static File getWallpaperFile(){
|
||||
public static File getWallpaperFile() {
|
||||
if (mWallpaperFile == null) {
|
||||
mWallpaperFile = new File(getGlobalContext().getFilesDir(), "wallpaper.webp");
|
||||
}
|
||||
@@ -37,7 +36,7 @@ public class WallpapersHooks{
|
||||
return mWallpaperFile;
|
||||
}
|
||||
|
||||
public static Drawable getFilteredFile(){
|
||||
public static Drawable getFilteredFile() {
|
||||
File file = null;
|
||||
File wp = mWallpaperFile;
|
||||
String temp = getGlobalContext().getFilesDir() + File.separator + "filteredwp.webp";
|
||||
@@ -66,11 +65,15 @@ public class WallpapersHooks{
|
||||
try {
|
||||
return Drawable.createFromPath(temp);
|
||||
} catch (Exception e) {
|
||||
return Drawable.createFromPath(file.getAbsolutePath());
|
||||
if (file != null) {
|
||||
return Drawable.createFromPath(file.getAbsolutePath());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean eligibleWallpaperFile(File file){
|
||||
private static Boolean eligibleWallpaperFile(File file) {
|
||||
if (file.length() >= 6291456) {
|
||||
sendToast(getString("wallpaper_size_limit"));
|
||||
removeWallpaper();
|
||||
@@ -80,7 +83,7 @@ public class WallpapersHooks{
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBg(View view){
|
||||
public static void setBg(View view) {
|
||||
if (getWallpaper() != null) {
|
||||
((ImageView) view).setImageDrawable(getFilteredFile()); // set picture to background
|
||||
return;
|
||||
@@ -89,7 +92,7 @@ public class WallpapersHooks{
|
||||
view.setBackgroundColor(ThemesUtils.getColorFromAttr(im_bg_chat)); // set default bg color
|
||||
}
|
||||
|
||||
public static String getWallpaperUrl(){
|
||||
public static String getWallpaperUrl() {
|
||||
var file = getWallpaperFile();
|
||||
|
||||
if (file.exists() && eligibleWallpaperFile(file)) {
|
||||
@@ -99,7 +102,7 @@ public class WallpapersHooks{
|
||||
return "default";
|
||||
}
|
||||
|
||||
public static Drawable getWallpaper(){
|
||||
public static Drawable getWallpaper() {
|
||||
if (mWallpaper == null || mUpdateWallpaperRequested) {
|
||||
String url = getWallpaperUrl();
|
||||
|
||||
@@ -123,14 +126,14 @@ public class WallpapersHooks{
|
||||
return mWallpaper;
|
||||
}
|
||||
|
||||
public static void requestUpdateWallpaper(){
|
||||
public static void requestUpdateWallpaper() {
|
||||
mUpdateWallpaperRequested = true;
|
||||
mUpdateWallpaperFileRequested = true;
|
||||
}
|
||||
|
||||
public static String getRadiusSummary(){
|
||||
public static String getRadiusSummary() {
|
||||
String radius = getPreferences().getString("msg_blur_radius", "disabled");
|
||||
switch(radius) {
|
||||
switch (radius) {
|
||||
case "low":
|
||||
return getString("wallpapers_low");
|
||||
case "med":
|
||||
@@ -142,9 +145,9 @@ 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 getString("wallpapers_dim_black");
|
||||
case "dim_white":
|
||||
@@ -154,9 +157,9 @@ public class WallpapersHooks{
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMosaicSummary(){
|
||||
public static String getMosaicSummary() {
|
||||
String radius = getPreferences().getString("msg_mosaic", "disabled");
|
||||
switch(radius) {
|
||||
switch (radius) {
|
||||
case "low":
|
||||
return getString("wallpapers_low");
|
||||
case "med":
|
||||
@@ -169,7 +172,7 @@ public class WallpapersHooks{
|
||||
}
|
||||
|
||||
|
||||
public static void removeWallpaper(){
|
||||
public static void removeWallpaper() {
|
||||
try {
|
||||
new File(getGlobalContext().getFilesDir(), "wallpaper.webp").delete();
|
||||
new File(getGlobalContext().getFilesDir(), "filteredwp.webp").delete();
|
||||
|
||||
@@ -2,7 +2,6 @@ package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.hooks.DateHook.getLocale;
|
||||
import static ru.vtosters.lite.utils.Preferences.preferences;
|
||||
import static ru.vtosters.lite.utils.ThemesUtils.isDarkTheme;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -107,8 +106,6 @@ public class AndroidUtils {
|
||||
configuration.setLayoutDirection(locale);
|
||||
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
|
||||
|
||||
edit().putBoolean("isdark", isDarkTheme()).commit();
|
||||
|
||||
return context;
|
||||
} // Language changer and BaseContext injector
|
||||
|
||||
@@ -136,9 +133,9 @@ public class AndroidUtils {
|
||||
messageDigest.update(s.getBytes());
|
||||
byte[] digest = messageDigest.digest();
|
||||
for (byte b : digest) {
|
||||
String hexString = Integer.toHexString(b & 255);
|
||||
StringBuilder hexString = new StringBuilder(Integer.toHexString(b & 255));
|
||||
while (hexString.length() < 2) {
|
||||
hexString = "0" + hexString;
|
||||
hexString.insert(0, "0");
|
||||
}
|
||||
sb.append(hexString);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ import java.io.IOException;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
public class ContactsUtils{
|
||||
public static void setContactsSync(boolean enabled){
|
||||
public class ContactsUtils {
|
||||
public static void setContactsSync(boolean enabled) {
|
||||
makeRequest("https://" + getApi() + "/method/account.setInfo?" + "name=im_user_name_type&value=" + (enabled ? "contact" : "vk") + "&https=1&v=5.153&access_token=" + getUserToken(),
|
||||
response -> {
|
||||
try {
|
||||
@@ -46,23 +46,23 @@ public class ContactsUtils{
|
||||
});
|
||||
}
|
||||
|
||||
public static void uploadContacts(Activity ctx){
|
||||
public static void uploadContacts(Activity ctx) {
|
||||
try {
|
||||
if (ContextCompat.checkSelfPermission(ctx, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
||||
sendToast(getString("contact_permission_toast"));
|
||||
requestPermissions(LifecycleUtils.getCurrentActivity(), new String[] {Manifest.permission.READ_CONTACTS}, 11111);
|
||||
requestPermissions(LifecycleUtils.getCurrentActivity(), new String[]{Manifest.permission.READ_CONTACTS}, 11111);
|
||||
sendToast(getString("contact_permission_toast"));
|
||||
requestPermissions(ctx, new String[] {Manifest.permission.READ_CONTACTS}, 11111);
|
||||
requestPermissions(ctx, new String[]{Manifest.permission.READ_CONTACTS}, 11111);
|
||||
} else {
|
||||
var account = VKAuthUtils.a.a(VKAccountManager.d().Z());
|
||||
ContactsSyncAdapterService.c(ctx, account, new Bundle(), new SyncResult());
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
Log.d("ContactsUtils", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void getContactsStatus(Context ctx){
|
||||
public static void getContactsStatus(Context ctx) {
|
||||
final ProgressDialog progressDialog = new ProgressDialog(ctx);
|
||||
progressDialog.setMessage(getString("contact_info_loading"));
|
||||
progressDialog.show();
|
||||
|
||||
@@ -4,6 +4,7 @@ import static android.text.TextUtils.isEmpty;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
|
||||
import static ru.vtosters.lite.utils.Preferences.isEnableExternalOpening;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
@@ -63,9 +64,7 @@ public class ExternalLinkParser {
|
||||
} else {
|
||||
String[] titles = qualities.keySet().toArray(new String[0]);
|
||||
new AlertDialog.Builder(context)
|
||||
.setItems(titles, ((dialog, which) -> {
|
||||
startExternalVideo(qualities.get(titles[which]), context);
|
||||
}))
|
||||
.setItems(titles, ((dialog, which) -> startExternalVideo(qualities.get(titles[which]), context)))
|
||||
.show();
|
||||
}
|
||||
}
|
||||
@@ -144,6 +143,7 @@ public class ExternalLinkParser {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("QueryPermissionsNeeded")
|
||||
private static String getMXPlayerPackageName() {
|
||||
for (ApplicationInfo info : getGlobalContext().getPackageManager().getInstalledApplications(0)) {
|
||||
String packName = info.packageName;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class IOUtils {
|
||||
}
|
||||
|
||||
public static String readAllLines(InputStream is) throws IOException {
|
||||
return new String(readAllBytes(is), "utf-8");
|
||||
return new String(readAllBytes(is), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static byte[] readAllBytes(File file) throws IOException {
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vtosters.lite.VKActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,12 +25,12 @@ import java.util.Scanner;
|
||||
|
||||
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,7 +57,7 @@ public class NewsFeedFiltersUtils{
|
||||
}
|
||||
}
|
||||
|
||||
public static void getFilter(String boolname, String filename, List<String> list){
|
||||
public static void getFilter(String boolname, String filename, List<String> list) {
|
||||
var ctx = getGlobalContext();
|
||||
|
||||
if (getBoolValue(boolname, false)) {
|
||||
@@ -66,7 +66,7 @@ public class NewsFeedFiltersUtils{
|
||||
if (ctx != null) {
|
||||
scanner = new Scanner(ctx.getAssets().open(filename));
|
||||
|
||||
while(scanner.hasNextLine()) {
|
||||
while (scanner.hasNextLine()) {
|
||||
var line = scanner.nextLine();
|
||||
if (!line.isEmpty())
|
||||
list.add(line.toLowerCase());
|
||||
@@ -78,7 +78,7 @@ public class NewsFeedFiltersUtils{
|
||||
}
|
||||
} // 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");
|
||||
if (copyHistoryNode != null && copyHistoryNode.length() != 0) {
|
||||
@@ -111,7 +111,7 @@ 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;
|
||||
|
||||
@@ -146,23 +146,23 @@ public class NewsFeedFiltersUtils{
|
||||
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();
|
||||
|
||||
if (mFilters != null) {
|
||||
@@ -179,7 +179,7 @@ public class NewsFeedFiltersUtils{
|
||||
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");
|
||||
@@ -203,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ public class ProfileHider {
|
||||
z2.setAccessible(true);
|
||||
z2.set(extendedUserProfile, response);
|
||||
}
|
||||
} catch (IOException | JSONException | NoSuchFieldException | IllegalAccessException e) {
|
||||
} catch (IOException | JSONException | NoSuchFieldException |
|
||||
IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NullPointerException e) {
|
||||
Log.e("ProfileHide", "null \"profiles\" node\n" + e);
|
||||
|
||||
@@ -203,15 +203,16 @@ public class RenameTool {
|
||||
sendToast(AndroidUtils.getString("rename_error"));
|
||||
}
|
||||
});
|
||||
if (isChangedName(id)) builder.setNeutralButton(AndroidUtils.getString("rename_reset"), (dialog, which) -> {
|
||||
getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME, COLUMN_VKID, id));
|
||||
if (id == AccountManagerUtils.getUserId()) {
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.USER_NAME_CHANGED"));
|
||||
}
|
||||
updateRequested = true;
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.ACTION_PROFILE_UPDATED").putExtra("uid", id));
|
||||
sendToast(AndroidUtils.getString("rename_remove_from_bd_success"));
|
||||
});
|
||||
if (isChangedName(id))
|
||||
builder.setNeutralButton(AndroidUtils.getString("rename_reset"), (dialog, which) -> {
|
||||
getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME, COLUMN_VKID, id));
|
||||
if (id == AccountManagerUtils.getUserId()) {
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.USER_NAME_CHANGED"));
|
||||
}
|
||||
updateRequested = true;
|
||||
ctx.sendBroadcast(new Intent("com.vkontakte.android.ACTION_PROFILE_UPDATED").putExtra("uid", id));
|
||||
sendToast(AndroidUtils.getString("rename_remove_from_bd_success"));
|
||||
});
|
||||
|
||||
var alert = builder.create();
|
||||
|
||||
@@ -263,11 +264,12 @@ public class RenameTool {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
if (isChangedNameGroup(id)) builder.setNeutralButton(AndroidUtils.getString("rename_reset"), (dialog, which) -> {
|
||||
getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME_GROUP, COLUMN_VKID, id));
|
||||
updateRequested = true;
|
||||
sendToast(AndroidUtils.getString("rename_remove_group_from_bd_success"));
|
||||
});
|
||||
if (isChangedNameGroup(id))
|
||||
builder.setNeutralButton(AndroidUtils.getString("rename_reset"), (dialog, which) -> {
|
||||
getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME_GROUP, COLUMN_VKID, id));
|
||||
updateRequested = true;
|
||||
sendToast(AndroidUtils.getString("rename_remove_group_from_bd_success"));
|
||||
});
|
||||
|
||||
var alert = builder.create();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import static ru.vtosters.lite.utils.AndroidUtils.getCenterScreenCoords;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getResources;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.*;
|
||||
import static ru.vtosters.lite.utils.LifecycleUtils.getCurrentActivity;
|
||||
import static ru.vtosters.lite.utils.Preferences.color_grishka;
|
||||
import static ru.vtosters.lite.utils.Preferences.dockbar_accent;
|
||||
import static ru.vtosters.lite.utils.Preferences.milkshake;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static ru.vtosters.lite.net.Request.makeRequest;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getApi;
|
||||
import static ru.vtosters.lite.proxy.ProxyUtils.getOauth;
|
||||
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.edit;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.AndroidUtils.getString;
|
||||
@@ -13,8 +13,8 @@ import android.util.Log;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class VKMeHandler{
|
||||
public static void getVkMeToken(String username, String password){
|
||||
public class VKMeHandler {
|
||||
public static void getVkMeToken(String username, String password) {
|
||||
makeRequest("https://" +
|
||||
getOauth() +
|
||||
"/token?" +
|
||||
@@ -27,12 +27,12 @@ public class VKMeHandler{
|
||||
try {
|
||||
JSONObject mainJson = new JSONObject(response);
|
||||
|
||||
if (mainJson.has("redirect_uri")){
|
||||
if (mainJson.has("redirect_uri")) {
|
||||
String redirect_uri = mainJson.getString("redirect_uri");
|
||||
// TODO open redirect_uri and get token
|
||||
} else if (mainJson.has("access_token")){
|
||||
} else if (mainJson.has("access_token")) {
|
||||
setToken(mainJson.getString("access_token"));
|
||||
} else if (mainJson.has("error_description")){
|
||||
} else if (mainJson.has("error_description")) {
|
||||
Log.d("VKMeHandler", mainJson.getString("error_description"));
|
||||
sendToast(getString("auth_error_vtl") + ": " + mainJson.getString("error_description"));
|
||||
}
|
||||
@@ -43,19 +43,19 @@ public class VKMeHandler{
|
||||
});
|
||||
}
|
||||
|
||||
public static void setToken(String token){
|
||||
edit().putString("vkmetoken", token).commit();
|
||||
}
|
||||
|
||||
public static void removeToken(){
|
||||
public static void removeToken() {
|
||||
edit().remove("vkmetoken").commit();
|
||||
}
|
||||
|
||||
public static String getToken(){
|
||||
public static String getToken() {
|
||||
return getPrefsValue("vkmetoken");
|
||||
}
|
||||
|
||||
public static void setPrivacyStatus(String status){
|
||||
public static void setToken(String token) {
|
||||
edit().putString("vkmetoken", token).commit();
|
||||
}
|
||||
|
||||
public static void setPrivacyStatus(String status) {
|
||||
// all, friends_and_contacts, only_me
|
||||
makeRequest("https://" + getApi() + "/method/account.setPrivacy?" + "v=5.140&key=online&value=" + status + "&https=1&access_token=" + getToken(),
|
||||
response -> {
|
||||
@@ -67,13 +67,13 @@ public class VKMeHandler{
|
||||
});
|
||||
}
|
||||
|
||||
public static void getPrivacyStatus(){
|
||||
public static void getPrivacyStatus() {
|
||||
makeRequest("https://" + getApi() + "/method/execute?v=5.140&code=return API.account.getPrivacySettings().settings[22].value.category;&access_token=" + getToken(),
|
||||
response -> {
|
||||
try {
|
||||
String resp = new JSONObject(response).optString("response");
|
||||
|
||||
switch (resp){ // TODO make support for privacy
|
||||
switch (resp) { // TODO make support for privacy
|
||||
case "all":
|
||||
case "friends_and_contacts":
|
||||
case "friends":
|
||||
|
||||
Reference in New Issue
Block a user