Compare commits

..
Author SHA1 Message Date
gdlbo 727201ece9 Some fixes 2022-04-28 21:21:20 +03:00
gdlbo c711c3126e Clean up code 2022-04-28 21:11:04 +03:00
gdlbo cdcf218160 Fixes 2022-04-28 20:57:57 +03:00
gdlbo ee652593c0 Backup system fixes 2022-04-28 19:07:11 +03:00
gdlbo 90773529e6 Reset/Save prefs system init 2022-04-28 18:29:31 +03:00
gdlbo 0134a7c82c Reset/Save prefs system init 2022-04-28 18:29:21 +03:00
gdlbo fec3d40d7d fixes 2022-04-27 23:06:43 +03:00
gdlbo bdf36f42d3 fixes for music popup 2022-04-27 21:34:14 +03:00
gdlbo 23967490e9 https://github.com/vtosters/lite/issues/181 + color fixes for tabs 2022-04-27 21:09:29 +03:00
gdlbo 3bcd197618 Fixed crash
https://github.com/vtosters/lite/issues/192
2022-04-27 20:29:18 +03:00
gdlbo ac3eba5654 Deleted exit button :) 2022-04-27 20:25:29 +03:00
gdlbo 9576856b0b Added debug feature for clear all sticks cache 2022-04-27 20:15:47 +03:00
gdlbo f17975c92f Fixed pic theme 2022-04-27 20:08:23 +03:00
gdlbo 07a24eab2f Fixed header coloring 2022-04-27 19:37:48 +03:00
gdlbo edc9276fac Max tabs updated 2022-04-26 14:28:37 +03:00
78 changed files with 945 additions and 740 deletions
@@ -3,11 +3,28 @@
*/ */
package bruhcollective.itaysonlab.libvkx; package bruhcollective.itaysonlab.libvkx;
// Works only with original signature of VT
public interface ILibVkxService extends android.os.IInterface { public interface ILibVkxService extends android.os.IInterface {
void play(java.util.List<String> audio_ids, int index, String playbackContext) throws android.os.RemoteException;
int getUserId() throws android.os.RemoteException;
// Starts playback. playbackContext can be "other" if you don't sure what it is
void addTrackToCache(int track_id, int owner_id, String access_key) throws android.os.RemoteException;
// A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE!
void deleteTrackFromCache(int track_id, int owner_id) throws android.os.RemoteException;
// Cache add/remove
boolean isTrackCached(int track_id, int owner_id) throws android.os.RemoteException;
java.util.List<String> getCache() throws android.os.RemoteException;
/** /**
* Default implementation for ILibVkxService. * Default implementation for ILibVkxService.
*/ */
public static class Default implements ILibVkxService { class Default implements ILibVkxService {
// Starts playback. playbackContext can be "other" if you don't sure what it is // Starts playback. playbackContext can be "other" if you don't sure what it is
@Override @Override
@@ -46,13 +63,20 @@ public interface ILibVkxService extends android.os.IInterface {
return null; return null;
} }
} }
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
// Also, the items in the list are JSON ones.
/** /**
* Local-side IPC implementation stub class. * Local-side IPC implementation stub class.
*/ */
public static abstract class Stub extends android.os.Binder implements ILibVkxService { abstract class Stub extends android.os.Binder implements ILibVkxService {
static final int TRANSACTION_play = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
static final int TRANSACTION_getUserId = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
static final int TRANSACTION_addTrackToCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
static final int TRANSACTION_deleteTrackFromCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
static final int TRANSACTION_isTrackCached = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
static final int TRANSACTION_getCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
private static final String DESCRIPTOR = "bruhcollective.itaysonlab.libvkx.ILibVkxService"; private static final String DESCRIPTOR = "bruhcollective.itaysonlab.libvkx.ILibVkxService";
/** /**
* Construct the stub at attach it to the interface. * Construct the stub at attach it to the interface.
*/ */
@@ -75,6 +99,18 @@ public interface ILibVkxService extends android.os.IInterface {
return new Proxy(obj); return new Proxy(obj);
} }
public static boolean setDefaultImpl(ILibVkxService impl) {
if (Proxy.sDefaultImpl == null && impl != null) {
Proxy.sDefaultImpl = impl;
return true;
}
return false;
}
public static ILibVkxService getDefaultImpl() {
return Proxy.sDefaultImpl;
}
@Override @Override
public android.os.IBinder asBinder() { public android.os.IBinder asBinder() {
return this; return this;
@@ -154,7 +190,8 @@ public interface ILibVkxService extends android.os.IInterface {
} }
private static class Proxy implements ILibVkxService { private static class Proxy implements ILibVkxService {
private android.os.IBinder mRemote; public static ILibVkxService sDefaultImpl;
private final android.os.IBinder mRemote;
Proxy(android.os.IBinder remote) { Proxy(android.os.IBinder remote) {
mRemote = remote; mRemote = remote;
@@ -164,11 +201,12 @@ public interface ILibVkxService extends android.os.IInterface {
public android.os.IBinder asBinder() { public android.os.IBinder asBinder() {
return mRemote; return mRemote;
} }
// Starts playback. playbackContext can be "other" if you don't sure what it is
public String getInterfaceDescriptor() { public String getInterfaceDescriptor() {
return DESCRIPTOR; return DESCRIPTOR;
} }
// Starts playback. playbackContext can be "other" if you don't sure what it is // A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE!
@Override @Override
public void play(java.util.List<String> audio_ids, int index, String playbackContext) throws android.os.RemoteException { public void play(java.util.List<String> audio_ids, int index, String playbackContext) throws android.os.RemoteException {
@@ -190,7 +228,7 @@ public interface ILibVkxService extends android.os.IInterface {
_data.recycle(); _data.recycle();
} }
} }
// A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE! // Cache add/remove
@Override @Override
public int getUserId() throws android.os.RemoteException { public int getUserId() throws android.os.RemoteException {
@@ -211,7 +249,6 @@ public interface ILibVkxService extends android.os.IInterface {
} }
return _result; return _result;
} }
// Cache add/remove
@Override @Override
public void addTrackToCache(int track_id, int owner_id, String access_key) throws android.os.RemoteException { public void addTrackToCache(int track_id, int owner_id, String access_key) throws android.os.RemoteException {
@@ -253,6 +290,8 @@ public interface ILibVkxService extends android.os.IInterface {
_data.recycle(); _data.recycle();
} }
} }
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
// Also, the items in the list are JSON ones.
@Override @Override
public boolean isTrackCached(int track_id, int owner_id) throws android.os.RemoteException { public boolean isTrackCached(int track_id, int owner_id) throws android.os.RemoteException {
@@ -275,8 +314,6 @@ public interface ILibVkxService extends android.os.IInterface {
} }
return _result; return _result;
} }
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
// Also, the items in the list are JSON ones.
@Override @Override
public java.util.List<String> getCache() throws android.os.RemoteException { public java.util.List<String> getCache() throws android.os.RemoteException {
@@ -297,44 +334,6 @@ public interface ILibVkxService extends android.os.IInterface {
} }
return _result; return _result;
} }
public static ILibVkxService sDefaultImpl;
}
static final int TRANSACTION_play = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
static final int TRANSACTION_getUserId = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
static final int TRANSACTION_addTrackToCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
static final int TRANSACTION_deleteTrackFromCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 4);
static final int TRANSACTION_isTrackCached = (android.os.IBinder.FIRST_CALL_TRANSACTION + 5);
static final int TRANSACTION_getCache = (android.os.IBinder.FIRST_CALL_TRANSACTION + 6);
public static boolean setDefaultImpl(ILibVkxService impl) {
if (Proxy.sDefaultImpl == null && impl != null) {
Proxy.sDefaultImpl = impl;
return true;
}
return false;
}
public static ILibVkxService getDefaultImpl() {
return Proxy.sDefaultImpl;
} }
} }
// Starts playback. playbackContext can be "other" if you don't sure what it is
public void play(java.util.List<String> audio_ids, int index, String playbackContext) throws android.os.RemoteException;
// A UserID. CHECK FOR THIS TO BE EQUAL BEFORE SENDING ANYTHING TO SERVICE!
public int getUserId() throws android.os.RemoteException;
// Cache add/remove
public void addTrackToCache(int track_id, int owner_id, String access_key) throws android.os.RemoteException;
public void deleteTrackFromCache(int track_id, int owner_id) throws android.os.RemoteException;
public boolean isTrackCached(int track_id, int owner_id) throws android.os.RemoteException;
// Get a list of cached tracks. The response is close to VK's original response (an audio list)
// Also, the items in the list are JSON ones.
public java.util.List<String> getCache() throws android.os.RemoteException;
} }
@@ -1,5 +1,7 @@
package bruhcollective.itaysonlab.libvkx.client; package bruhcollective.itaysonlab.libvkx.client;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.Context; import android.content.Context;
import android.os.RemoteException; import android.os.RemoteException;
@@ -27,7 +29,7 @@ public class LibVKXClient {
public static LibVKXClientImpl getInstance() { public static LibVKXClientImpl getInstance() {
LibVKXClientImpl libVKXClientImpl = impl; LibVKXClientImpl libVKXClientImpl = impl;
return libVKXClientImpl == null ? getInstance(Helper.GetContext()) : libVKXClientImpl; return libVKXClientImpl == null ? getInstance(GetContext()) : libVKXClientImpl;
} }
public static boolean isVkxInstalled() { public static boolean isVkxInstalled() {
@@ -1,5 +1,7 @@
package bruhcollective.itaysonlab.libvkx.client; package bruhcollective.itaysonlab.libvkx.client;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -51,7 +53,7 @@ public class LibVKXClientImpl {
public boolean runOnService(LibVKXAction action) { public boolean runOnService(LibVKXAction action) {
if (serviceInstance != null) { if (serviceInstance != null) {
try { try {
if (serviceInstance.getUserId() != Helper.GetUserId()) return false; if (serviceInstance.getUserId() != GetUserId()) return false;
action.run(serviceInstance); action.run(serviceInstance);
return true; return true;
} catch (RemoteException e) { } catch (RemoteException e) {
@@ -75,7 +77,7 @@ public class LibVKXClientImpl {
isBindFailed = true; isBindFailed = true;
} else { } else {
try { try {
if (serviceInstance.getUserId() != Helper.GetUserId()) return; if (serviceInstance.getUserId() != GetUserId()) return;
runAfterBind.run(serviceInstance); runAfterBind.run(serviceInstance);
} catch (RemoteException e) { } catch (RemoteException e) {
e.printStackTrace(); e.printStackTrace();
@@ -95,8 +97,7 @@ public class LibVKXClientImpl {
private boolean verifyBindActuality() { private boolean verifyBindActuality() {
if (!checkIfAppExists()) return false; // no need if (!checkIfAppExists()) return false; // no need
if (isBindFailed) return false; return !isBindFailed;
return true;
} }
private Intent getIntent() { private Intent getIntent() {
@@ -21,17 +21,13 @@ import java.util.concurrent.atomic.AtomicLong;
public class NotificationsHelper { public class NotificationsHelper {
private static final int NOTIFICATION_ID_BASE = 3921337; private static final int NOTIFICATION_ID_BASE = 3921337;
private static final String NOTIFICATION_CHANNEL_ID = "tgss_chan_v5"; private static final String NOTIFICATION_CHANNEL_ID = "tgss_chan_v5";
private HashMap<TelegramStickersPack, Integer> downloadingPacksNotificationsIds;
private Context c;
private NotificationManagerCompat manager;
private int currentNotificationN = 0;
private static final int MAX_UPDATE_NOTIFICATIONS_PER_SECOND = 3; private static final int MAX_UPDATE_NOTIFICATIONS_PER_SECOND = 3;
private static final int MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS = 1000 / MAX_UPDATE_NOTIFICATIONS_PER_SECOND; private static final int MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS = 1000 / MAX_UPDATE_NOTIFICATIONS_PER_SECOND;
private final HashMap<TelegramStickersPack, Integer> downloadingPacksNotificationsIds;
private AtomicLong lastNotificationTime = new AtomicLong(0); private final Context c;
private final NotificationManagerCompat manager;
private int currentNotificationN = 0;
private final AtomicLong lastNotificationTime = new AtomicLong(0);
public NotificationsHelper(Context c) { public NotificationsHelper(Context c) {
this.c = c; this.c = c;
@@ -11,7 +11,7 @@ import java.io.File;
class PackDeletionTask extends AsyncTask<Void, Void, Boolean> { class PackDeletionTask extends AsyncTask<Void, Void, Boolean> {
private static final String TAG = "TGSSAnnihilator"; private static final String TAG = "TGSSAnnihilator";
private TelegramStickersPack pack; private final TelegramStickersPack pack;
PackDeletionTask(TelegramStickersPack pack) { PackDeletionTask(TelegramStickersPack pack) {
this.pack = pack; this.pack = pack;
@@ -101,7 +101,7 @@ public class TelegramStickersPack extends CustomStickersPack {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.toLowerCase().equals(id.toLowerCase()); return obj instanceof TelegramStickersPack && ((TelegramStickersPack) obj).id.equalsIgnoreCase(id);
} }
@Override @Override
@@ -1,5 +1,7 @@
package com.aefyr.tsg.g2; package com.aefyr.tsg.g2;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Handler; import android.os.Handler;
@@ -27,29 +29,25 @@ public class TelegramStickersService {
private static final String TAG = "TGStickersService"; private static final String TAG = "TGStickersService";
private static TelegramStickersService instance; private static TelegramStickersService instance;
private Context c; private final Context c;
private ArrayList<TelegramStickersPack> packs; private final ArrayList<TelegramStickersPack> packs;
private ArrayList<TelegramStickersPack> activePacks; private final ArrayList<TelegramStickersPack> activePacks;
private ArrayList<TelegramStickersPack> inactivePacks; private final ArrayList<TelegramStickersPack> inactivePacks;
private ArrayList<StickersEventsListener> listeners; private final ArrayList<StickersEventsListener> listeners;
private HashSet<String> currentlyDownloading; private final HashSet<String> currentlyDownloading;
private Handler uiThreadHandler; private final Handler uiThreadHandler;
private TelegramStickersGrabber grabber; private final TelegramStickersGrabber grabber;
private TelegramStickersDbHelper dbHelper; private final TelegramStickersDbHelper dbHelper;
private boolean ready = false; private boolean ready = false;
private ArrayList<Runnable> queuedTasks; private final ArrayList<Runnable> queuedTasks;
private ThreadPoolExecutor executor; private final ThreadPoolExecutor executor;
private NotificationsHelper notificationsHelper; private final NotificationsHelper notificationsHelper;
public static TelegramStickersService getInstance(Context c) {
return instance == null ? new TelegramStickersService(c) : instance;
}
private TelegramStickersService(Context context) { private TelegramStickersService(Context context) {
instance = this; instance = this;
@@ -72,6 +70,10 @@ public class TelegramStickersService {
updatePacks(true); updatePacks(true);
} }
public static TelegramStickersService getInstance(Context c) {
return instance == null ? new TelegramStickersService(c) : instance;
}
private void updatePacks(final boolean notify) { private void updatePacks(final boolean notify) {
packs.clear(); packs.clear();
dbHelper.getAllPacks(new TelegramStickersDbHelper.PacksLoadingListener() { dbHelper.getAllPacks(new TelegramStickersDbHelper.PacksLoadingListener() {
@@ -105,20 +107,6 @@ public class TelegramStickersService {
}); });
} }
interface StickersEventsListener {
void onPackAdded(TelegramStickersPack pack, int atIndex);
void onPackRemoved(TelegramStickersPack pack, int atIndex);
void onPackChanged(TelegramStickersPack pack, int atIndex);
void onPackDownloadError(TelegramStickersPack pack, Exception error);
void onActivePacksListChanged();
void onInactivePacksListChanged();
}
public void addStickersEventsListener(StickersEventsListener listener) { public void addStickersEventsListener(StickersEventsListener listener) {
listeners.add(listener); listeners.add(listener);
} }
@@ -128,7 +116,7 @@ public class TelegramStickersService {
} }
private void notifyPackAdded(TelegramStickersPack pack, int atIndex) { private void notifyPackAdded(TelegramStickersPack pack, int atIndex) {
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
if (listeners.isEmpty()) if (listeners.isEmpty())
return; return;
@@ -138,7 +126,7 @@ public class TelegramStickersService {
} }
private void notifyPackChanged(TelegramStickersPack pack, int atIndex) { private void notifyPackChanged(TelegramStickersPack pack, int atIndex) {
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
if (listeners.isEmpty()) if (listeners.isEmpty())
return; return;
@@ -148,7 +136,7 @@ public class TelegramStickersService {
} }
private void notifyPackRemoved(TelegramStickersPack pack, int atIndex) { private void notifyPackRemoved(TelegramStickersPack pack, int atIndex) {
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
if (listeners.isEmpty()) if (listeners.isEmpty())
return; return;
@@ -158,7 +146,7 @@ public class TelegramStickersService {
} }
private void notifyPackDownloadError(TelegramStickersPack pack, Exception error) { private void notifyPackDownloadError(TelegramStickersPack pack, Exception error) {
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
if (listeners.isEmpty()) if (listeners.isEmpty())
return; return;
@@ -168,7 +156,7 @@ public class TelegramStickersService {
} }
private void notifyActivePacksListChanged() { private void notifyActivePacksListChanged() {
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
if (listeners.isEmpty()) if (listeners.isEmpty())
return; return;
@@ -178,7 +166,7 @@ public class TelegramStickersService {
} }
private void notifyInactivePacksListChanged() { private void notifyInactivePacksListChanged() {
Helper.GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); GetContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD));
if (listeners.isEmpty()) if (listeners.isEmpty())
return; return;
@@ -398,5 +386,19 @@ public class TelegramStickersService {
getPacksListReference().set(li1, p2); getPacksListReference().set(li1, p2);
} }
interface StickersEventsListener {
void onPackAdded(TelegramStickersPack pack, int atIndex);
void onPackRemoved(TelegramStickersPack pack, int atIndex);
void onPackChanged(TelegramStickersPack pack, int atIndex);
void onPackDownloadError(TelegramStickersPack pack, Exception error);
void onActivePacksListChanged();
void onInactivePacksListChanged();
}
} }
@@ -7,6 +7,10 @@ import android.provider.BaseColumns;
*/ */
public final class TelegramStickersContract { public final class TelegramStickersContract {
public static final String SQL_CREATE_ENTRIES = String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s INTEGER AUTO_INCREMENT, %s TEXT, %s TEXT, %s TEXT, %s INTEGER, %s INTEGER, %s TEXT, %s TEXT)",
StickersTableEntry.TABLE_NAME, StickersTableEntry._ID, StickersTableEntry.COLUMN_NAME_INDEX, StickersTableEntry.COLUMN_NAME_ID, StickersTableEntry.COLUMN_NAME_NAME,
StickersTableEntry.COLUMN_NAME_FOLDER, StickersTableEntry.COLUMN_NAME_STICKERS_COUNT, StickersTableEntry.COLUMN_NAME_ENABLED, StickersTableEntry.COLUMN_NAME_VERSION, StickersTableEntry.COLUMN_NAME_EMOJIS);
private TelegramStickersContract() { private TelegramStickersContract() {
} }
@@ -23,9 +27,5 @@ public final class TelegramStickersContract {
public static final String COLUMN_NAME_EMOJIS = "emojis"; public static final String COLUMN_NAME_EMOJIS = "emojis";
} }
public static final String SQL_CREATE_ENTRIES = String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY, %s INTEGER AUTO_INCREMENT, %s TEXT, %s TEXT, %s TEXT, %s INTEGER, %s INTEGER, %s TEXT, %s TEXT)",
StickersTableEntry.TABLE_NAME, StickersTableEntry._ID, StickersTableEntry.COLUMN_NAME_INDEX, StickersTableEntry.COLUMN_NAME_ID, StickersTableEntry.COLUMN_NAME_NAME,
StickersTableEntry.COLUMN_NAME_FOLDER, StickersTableEntry.COLUMN_NAME_STICKERS_COUNT, StickersTableEntry.COLUMN_NAME_ENABLED, StickersTableEntry.COLUMN_NAME_VERSION, StickersTableEntry.COLUMN_NAME_EMOJIS);
} }
@@ -27,12 +27,6 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper {
private SQLiteDatabase writableDb; private SQLiteDatabase writableDb;
private SQLiteDatabase readableDb; private SQLiteDatabase readableDb;
public interface PacksLoadingListener {
void onPackLoaded(TelegramStickersPack pack);
void onAllPacksLoaded(ArrayList<TelegramStickersPack> packs);
}
public TelegramStickersDbHelper(Context context) { public TelegramStickersDbHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION); super(context, DB_NAME, null, DB_VERSION);
} }
@@ -105,6 +99,12 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper {
new PacksLoadingTask(listener).execute(); new PacksLoadingTask(listener).execute();
} }
public interface PacksLoadingListener {
void onPackLoaded(TelegramStickersPack pack);
void onAllPacksLoaded(ArrayList<TelegramStickersPack> packs);
}
private class PacksLoadingTask extends AsyncTask<Void, Void, ArrayList<TelegramStickersPack>> { private class PacksLoadingTask extends AsyncTask<Void, Void, ArrayList<TelegramStickersPack>> {
PacksLoadingListener listener; PacksLoadingListener listener;
@@ -38,12 +38,6 @@ import ru.f0x1d.net.NetResponse;
*/ */
public class TelegramStickersGrabber { public class TelegramStickersGrabber {
private static final String TAG = "TSG"; private static final String TAG = "TSG";
private static String BOT_API_BASE_URL;
private static String GET_STICKER_SET_URL;
private static String GET_FILE_URL;
private static String BOT_API_BASE_FILE_URL;
public static String REAL_TG_IP = null; public static String REAL_TG_IP = null;
public static String PROXY_IP = null; public static String PROXY_IP = null;
public static int PROXY_PORT = -1; public static int PROXY_PORT = -1;
@@ -52,11 +46,32 @@ public class TelegramStickersGrabber {
public static boolean PROXY_SOCKS = true; public static boolean PROXY_SOCKS = true;
public static boolean HAS_PASS = false; public static boolean HAS_PASS = false;
public static boolean USE_PROXY = false; public static boolean USE_PROXY = false;
private static String BOT_API_BASE_URL;
private static String GET_STICKER_SET_URL;
private static String GET_FILE_URL;
private static String BOT_API_BASE_FILE_URL;
static { static {
updateURLs(); updateURLs();
} }
private final MessageDigest sha256;
private final Handler uiThreadHandler;
private String botApiKey = "";
private NetClient httpClient;
public TelegramStickersGrabber(String botApiKey) {
this.botApiKey = botApiKey;
httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
uiThreadHandler = new Handler(Looper.getMainLooper());
try {
sha256 = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
Log.wtf(TAG, "No support for SHA-256");
e.printStackTrace();
throw new RuntimeException(e);
}
}
public static void updateURLs() { public static void updateURLs() {
BOT_API_BASE_FILE_URL = "https://api.telegram.org/file/bot%s/%s"; BOT_API_BASE_FILE_URL = "https://api.telegram.org/file/bot%s/%s";
@@ -66,11 +81,6 @@ public class TelegramStickersGrabber {
GET_FILE_URL = BOT_API_BASE_URL + "getFile?file_id=%s"; GET_FILE_URL = BOT_API_BASE_URL + "getFile?file_id=%s";
} }
private String botApiKey = "";
private NetClient httpClient;
private final MessageDigest sha256;
private final Handler uiThreadHandler;
public static boolean isTelegramBlocked() { public static boolean isTelegramBlocked() {
NetClient client = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build(); NetClient client = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
try { try {
@@ -101,43 +111,6 @@ public class TelegramStickersGrabber {
return false; return false;
} }
public interface PackDownloadListener {
void onPackDownloaded(TelegramStickersPackInfo pack, boolean newVersionFound);
void onPackDownloadError(Exception e);
void onGotPackInfo(TelegramStickersPackInfo packInfo);
void onStickerDownloaded(String pack, File sticker, String boundEmoji, int stickerIndex, int downloadedStickersCount, int totalStickerCount);
}
public interface KeyCheckListener {
void onKeyChecked(boolean ok);
void onNetError();
}
public class TSGException extends Exception {
private static final long serialVersionUID = 7866915509988422944L;
private TSGException(String message) {
super(message);
}
}
public TelegramStickersGrabber(String botApiKey) {
this.botApiKey = botApiKey;
httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
uiThreadHandler = new Handler(Looper.getMainLooper());
try {
sha256 = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
Log.wtf(TAG, "No support for SHA-256");
e.printStackTrace();
throw new RuntimeException(e);
}
}
public void resetProxy() { public void resetProxy() {
httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build(); httpClient = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build();
} }
@@ -201,40 +174,6 @@ public class TelegramStickersGrabber {
}); });
} }
private class StickerSet {
String id;
String name;
String version;
ArrayList<Sticker> stickers;
StickerSet(String id, String name, String version, ArrayList<Sticker> stickers) {
this.name = name;
this.stickers = stickers;
this.id = id;
this.version = version;
}
}
private class Sticker {
String emoji;
String fileId;
Sticker(String fileId, String emoji) {
this.fileId = fileId;
this.emoji = emoji;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Sticker && ((Sticker) obj).fileId.equals(fileId);
}
@Override
public int hashCode() {
return (17 * emoji.hashCode()) << 32 + fileId.hashCode();
}
}
private void getPackInfo(final String packName, final File packFolder, final String installedVersion, final PackDownloadListener listener) { private void getPackInfo(final String packName, final File packFolder, final String installedVersion, final PackDownloadListener listener) {
NetRequest packInfoRequest = new NetRequest.Builder().get().url(String.format(GET_STICKER_SET_URL, botApiKey, packName)).build(); NetRequest packInfoRequest = new NetRequest.Builder().get().url(String.format(GET_STICKER_SET_URL, botApiKey, packName)).build();
httpClient.newCall(packInfoRequest).enqueue(new NetCallback() { httpClient.newCall(packInfoRequest).enqueue(new NetCallback() {
@@ -478,4 +417,62 @@ public class TelegramStickersGrabber {
private void runOnUiThread(Runnable r) { private void runOnUiThread(Runnable r) {
uiThreadHandler.post(r); uiThreadHandler.post(r);
} }
public interface PackDownloadListener {
void onPackDownloaded(TelegramStickersPackInfo pack, boolean newVersionFound);
void onPackDownloadError(Exception e);
void onGotPackInfo(TelegramStickersPackInfo packInfo);
void onStickerDownloaded(String pack, File sticker, String boundEmoji, int stickerIndex, int downloadedStickersCount, int totalStickerCount);
}
public interface KeyCheckListener {
void onKeyChecked(boolean ok);
void onNetError();
}
public class TSGException extends Exception {
private static final long serialVersionUID = 7866915509988422944L;
private TSGException(String message) {
super(message);
}
}
private class StickerSet {
String id;
String name;
String version;
ArrayList<Sticker> stickers;
StickerSet(String id, String name, String version, ArrayList<Sticker> stickers) {
this.name = name;
this.stickers = stickers;
this.id = id;
this.version = version;
}
}
private class Sticker {
String emoji;
String fileId;
Sticker(String fileId, String emoji) {
this.fileId = fileId;
this.emoji = emoji;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Sticker && ((Sticker) obj).fileId.equals(fileId);
}
@Override
public int hashCode() {
return (17 * emoji.hashCode()) << 32 + fileId.hashCode();
}
}
} }
@@ -7,14 +7,9 @@ import android.util.Log;
*/ */
public class GoalCounter { public class GoalCounter {
public interface OnGoalReachListener { private final int goal;
void onGoalReached();
}
private int goal;
private int i = 0; private int i = 0;
private final OnGoalReachListener listener;
private OnGoalReachListener listener;
public GoalCounter(int goal, OnGoalReachListener listener) { public GoalCounter(int goal, OnGoalReachListener listener) {
this.goal = goal; this.goal = goal;
@@ -36,4 +31,8 @@ public class GoalCounter {
public synchronized int value() { public synchronized int value() {
return i; return i;
} }
public interface OnGoalReachListener {
void onGoalReached();
}
} }
+2 -2
View File
@@ -15,9 +15,9 @@ public final class Request {
final String b; final String b;
final Headers c; final Headers c;
final Map<Class<?>, Object> e; final Map<Class<?>, Object> e;
private volatile CacheControl f;
@Nullable @Nullable
final RequestBody requestBody; final RequestBody requestBody;
private volatile CacheControl f;
Request(Builder builder) { Request(Builder builder) {
this.a = builder.a; this.a = builder.a;
@@ -55,7 +55,7 @@ public final class Request {
@Nullable @Nullable
public <T> T a(Class<? extends T> cls) { public <T> T a(Class<? extends T> cls) {
return (T) cls.cast(this.e.get(cls)); return cls.cast(this.e.get(cls));
} }
public Builder e() { public Builder e() {
@@ -1,5 +1,7 @@
package ru.f0x1d.net; package ru.f0x1d.net;
import static ru.vtosters.lite.utils.Helper.*;
import android.os.AsyncTask; import android.os.AsyncTask;
import com.vk.core.network.Network; import com.vk.core.network.Network;
@@ -13,10 +15,6 @@ import ru.vtosters.lite.utils.Helper;
public class F0x1dRequest { public class F0x1dRequest {
public interface F0x1dRequestCallback {
void onResponse(String str);
}
public static void makeRequest(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) { public static void makeRequest(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) {
new MakeRequestTask(bArr, f0x1dRequestCallback).execute(); new MakeRequestTask(bArr, f0x1dRequestCallback).execute();
} }
@@ -29,11 +27,15 @@ public class F0x1dRequest {
new MakeRequestTask(str.getBytes(), f0x1dRequestCallback, true, !z).execute(); new MakeRequestTask(str.getBytes(), f0x1dRequestCallback, true, !z).execute();
} }
public interface F0x1dRequestCallback {
void onResponse(String str);
}
private static class MakeRequestTask extends AsyncTask<Void, Void, String> { private static class MakeRequestTask extends AsyncTask<Void, Void, String> {
private F0x1dRequestCallback callback; private final F0x1dRequestCallback callback;
private boolean mIsPut; private boolean mIsPut;
private boolean mIsVkToasterRequest; private boolean mIsVkToasterRequest;
private byte[] url; private final byte[] url;
public MakeRequestTask(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) { public MakeRequestTask(byte[] bArr, F0x1dRequestCallback f0x1dRequestCallback) {
this.mIsVkToasterRequest = false; this.mIsVkToasterRequest = false;
@@ -56,7 +58,7 @@ public class F0x1dRequest {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(new String(this.url)).openConnection(); HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(new String(this.url)).openConnection();
httpURLConnection.setRequestMethod(this.mIsPut ? "PUT" : "GET"); httpURLConnection.setRequestMethod(this.mIsPut ? "PUT" : "GET");
if (this.mIsVkToasterRequest) { if (this.mIsVkToasterRequest) {
httpURLConnection.setRequestProperty("Token", Helper.GetUserToken()); httpURLConnection.setRequestProperty("Token", GetUserToken());
} }
if (!this.mIsVkToasterRequest) { if (!this.mIsVkToasterRequest) {
httpURLConnection.setRequestProperty("User-Agent", Network.a.a().a()); httpURLConnection.setRequestProperty("User-Agent", Network.a.a().a());
+12 -12
View File
@@ -16,14 +16,24 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
public final class NetCall { public final class NetCall {
private NetRequest req; private final NetRequest req;
private NetClient cl; private final NetClient cl;
protected NetCall(NetClient cl, NetRequest req) { protected NetCall(NetClient cl, NetRequest req) {
this.req = req; this.req = req;
this.cl = cl; this.cl = cl;
} }
private static String constructArgs(Map<String, String> args) throws UnsupportedEncodingException {
args = new TreeMap<>(args);
String str = "";
for (Map.Entry<String, String> en : args.entrySet()) {
if (!str.isEmpty()) str += "&";
str += URLEncoder.encode(en.getKey(), "UTF-8") + "=" + URLEncoder.encode(en.getValue(), "UTF-8");
}
return str;
}
public NetRequest request() { public NetRequest request() {
return req; return req;
} }
@@ -65,16 +75,6 @@ public final class NetCall {
return r; return r;
} }
private static String constructArgs(Map<String, String> args) throws UnsupportedEncodingException {
args = new TreeMap<>(args);
String str = "";
for (Map.Entry<String, String> en : args.entrySet()) {
if (!str.isEmpty()) str += "&";
str += URLEncoder.encode(en.getKey(), "UTF-8") + "=" + URLEncoder.encode(en.getValue(), "UTF-8");
}
return str;
}
public void enqueue(NetCallback cb) { public void enqueue(NetCallback cb) {
new Thread() { new Thread() {
@Override @Override
+33 -33
View File
@@ -5,9 +5,39 @@ import java.net.Proxy;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class NetClient { public class NetClient {
private long timeout; private final long timeout;
private Proxy proxy; private final Proxy proxy;
private PasswordAuthentication authenticator; private final PasswordAuthentication authenticator;
protected NetClient(Builder b) {
timeout = b.timeout;
proxy = b.proxy;
authenticator = b.auth;
}
public Builder newBuilder() {
Builder b = new Builder();
b.timeout = timeout;
b.proxy = proxy;
b.auth = authenticator;
return b;
}
public NetCall newCall(NetRequest req) {
return new NetCall(this, req);
}
public PasswordAuthentication getAuthenticator() {
return authenticator;
}
public Proxy getProxy() {
return proxy;
}
public long getTimeout() {
return timeout;
}
public static final class Builder { public static final class Builder {
private long timeout; private long timeout;
@@ -54,34 +84,4 @@ public class NetClient {
return new NetClient(this); return new NetClient(this);
} }
} }
public Builder newBuilder() {
Builder b = new Builder();
b.timeout = timeout;
b.proxy = proxy;
b.auth = authenticator;
return b;
}
protected NetClient(Builder b) {
timeout = b.timeout;
proxy = b.proxy;
authenticator = b.auth;
}
public NetCall newCall(NetRequest req) {
return new NetCall(this, req);
}
public PasswordAuthentication getAuthenticator() {
return authenticator;
}
public Proxy getProxy() {
return proxy;
}
public long getTimeout() {
return timeout;
}
} }
+21 -21
View File
@@ -4,9 +4,27 @@ import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
public class NetRequest { public class NetRequest {
private String url; private final String url;
private String requestMethod; private final String requestMethod;
private Map<String, String> params; private final Map<String, String> params;
protected NetRequest(Builder b) {
url = b.url;
requestMethod = b.req;
params = b.params;
}
public Map<String, String> getRequestParams() {
return params;
}
public String url() {
return url;
}
public String getRequestMethod() {
return requestMethod;
}
public static final class Builder { public static final class Builder {
private String url; private String url;
@@ -43,22 +61,4 @@ public class NetRequest {
return this; return this;
} }
} }
protected NetRequest(Builder b) {
url = b.url;
requestMethod = b.req;
params = b.params;
}
public Map<String, String> getRequestParams() {
return params;
}
public String url() {
return url;
}
public String getRequestMethod() {
return requestMethod;
}
} }
@@ -5,7 +5,7 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
public final class NetResponse { public final class NetResponse {
private byte[] data; private final byte[] data;
private int code; private int code;
protected NetResponse(byte[] data) { protected NetResponse(byte[] data) {
@@ -26,15 +26,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
public class GCMFix { public class GCMFix {
private static String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL);
public static ArrayList<String> langs = new ArrayList<>(); public static ArrayList<String> langs = new ArrayList<>();
private static final String agent = String.format("Android-GCM/1.5 (%s %s)", Build.MODEL, Build.MODEL);
private static KeyPair pair; private static KeyPair pair;
private static int rid = 0; private static int rid = 0;
public interface Callback {
void doCallback(String str);
}
static { static {
genNewKey(); genNewKey();
} }
@@ -195,4 +191,8 @@ public class GCMFix {
return null; return null;
} }
} }
public interface Callback {
void doCallback(String str);
}
} }
@@ -164,7 +164,7 @@ public class DeviceInfoCollector {
declaredField.setAccessible(true); declaredField.setAccessible(true);
Object obj = declaredField.get(defaultAdapter); Object obj = declaredField.get(defaultAdapter);
if (obj != null) { if (obj != null) {
return (String) obj.getClass().getMethod("getAddress", new Class[0]).invoke(obj, new Object[0]); return (String) obj.getClass().getMethod("getAddress").invoke(obj, new Object[0]);
} }
return null; return null;
} catch (Exception e) { } catch (Exception e) {
@@ -1,5 +1,8 @@
package ru.vtosters.lite.dnr; package ru.vtosters.lite.dnr;
import static ru.vtosters.lite.dnr.DNRModule.*;
import static ru.vtosters.lite.utils.Helper.*;
import com.vk.im.engine.models.dialogs.Dialog; import com.vk.im.engine.models.dialogs.Dialog;
import com.vk.im.ui.components.common.DialogAction; import com.vk.im.ui.components.common.DialogAction;
@@ -12,13 +15,13 @@ public class DNRInjector {
public static void inject(Dialog dialog, List<DialogAction> list) { public static void inject(Dialog dialog, List<DialogAction> list) {
int peerId = dialog.a(); int peerId = dialog.a();
if (DNRModule.isDnrEnabledFor(peerId)) { if (isDnrEnabledFor(peerId)) {
list.add(DialogAction.valueOf("DNR_OFF")); list.add(DialogAction.valueOf("DNR_OFF"));
} else { } else {
list.add(DialogAction.valueOf("DNR_ON")); list.add(DialogAction.valueOf("DNR_ON"));
} }
if (DNRModule.isDntEnabledFor(peerId)) { if (isDntEnabledFor(peerId)) {
list.add(DialogAction.valueOf("DNT_OFF")); list.add(DialogAction.valueOf("DNT_OFF"));
} else { } else {
list.add(DialogAction.valueOf("DNT_ON")); list.add(DialogAction.valueOf("DNT_ON"));
@@ -26,10 +29,10 @@ public class DNRInjector {
} }
public static LinkedHashMap<DialogAction, Integer> injectToHashMap(LinkedHashMap<DialogAction, Integer> hashMap) { public static LinkedHashMap<DialogAction, Integer> injectToHashMap(LinkedHashMap<DialogAction, Integer> hashMap) {
hashMap.put(DialogAction.valueOf("DNR_ON"), Helper.getIdentifier("DNR_ON", "string")); hashMap.put(DialogAction.valueOf("DNR_ON"), getIdentifier("DNR_ON", "string"));
hashMap.put(DialogAction.valueOf("DNR_OFF"), Helper.getIdentifier("DNR_OFF", "string")); hashMap.put(DialogAction.valueOf("DNR_OFF"), getIdentifier("DNR_OFF", "string"));
hashMap.put(DialogAction.valueOf("DNT_ON"), Helper.getIdentifier("DNT_ON", "string")); hashMap.put(DialogAction.valueOf("DNT_ON"), getIdentifier("DNT_ON", "string"));
hashMap.put(DialogAction.valueOf("DNT_OFF"), Helper.getIdentifier("DNT_OFF", "string")); hashMap.put(DialogAction.valueOf("DNT_OFF"), getIdentifier("DNT_OFF", "string"));
return hashMap; return hashMap;
} }
@@ -56,11 +59,11 @@ public class DNRInjector {
} }
public static void setDnr(Dialog dialog, boolean value) { public static void setDnr(Dialog dialog, boolean value) {
DNRModule.hookDNR(dialog.a()); hookDNR(dialog.a());
} }
public static void setDnt(Dialog dialog, boolean value) { public static void setDnt(Dialog dialog, boolean value) {
DNRModule.hookDNT(dialog.a()); hookDNT(dialog.a());
} }
} }
@@ -1,5 +1,9 @@
package ru.vtosters.lite.dnr; package ru.vtosters.lite.dnr;
import static ru.f0x1d.net.F0x1dRequest.*;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Proxy.*;
import com.vk.core.util.ToastUtils; import com.vk.core.util.ToastUtils;
import com.vk.im.engine.commands.messages.SetUserActivityCmd; import com.vk.im.engine.commands.messages.SetUserActivityCmd;
import com.vk.im.engine.models.dialogs.Dialog; import com.vk.im.engine.models.dialogs.Dialog;
@@ -15,6 +19,7 @@ import ru.vtosters.lite.utils.Proxy;
public class DNRModule { public class DNRModule {
public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper(); public static DoNotReadDBHelper mDoNotReadDBHelper = new DoNotReadDBHelper();
public static DoNotTypeDBHelper mDoNotTypeDBHelper = new DoNotTypeDBHelper(); public static DoNotTypeDBHelper mDoNotTypeDBHelper = new DoNotTypeDBHelper();
public static Dialog mDialog;
public static boolean isDnrEnabledFor(int id) { public static boolean isDnrEnabledFor(int id) {
var isEnabled = mDoNotReadDBHelper.isEnabledForPeerId(id); var isEnabled = mDoNotReadDBHelper.isEnabledForPeerId(id);
@@ -49,13 +54,11 @@ public class DNRModule {
} }
public static void hookRead(Dialog dialog) { public static void hookRead(Dialog dialog) {
F0x1dRequest.makeRequest("https://" + Proxy.getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.lastMsgVkId + "&peer_id=" + dialog.a() + "&v=5.91&access_token=" + Helper.GetUserToken(), response -> { makeRequest("https://" + getApiCom() + "/method/messages.markAsRead?start_message_id=" + dialog.lastMsgVkId + "&peer_id=" + dialog.a() + "&v=5.91&access_token=" + GetUserToken(), response -> {
ToastUtils.a("Чат помечен как прочитанный!"); ToastUtils.a("Чат помечен как прочитанный!");
}); });
} }
public static Dialog mDialog;
public static void hookDNR(int peerId) { public static void hookDNR(int peerId) {
mDoNotReadDBHelper.setEnabledForPeerId(peerId, !mDoNotReadDBHelper.isEnabledForPeerId(peerId)); mDoNotReadDBHelper.setEnabledForPeerId(peerId, !mDoNotReadDBHelper.isEnabledForPeerId(peerId));
} }
@@ -1,5 +1,7 @@
package ru.vtosters.lite.dnr.helpers; package ru.vtosters.lite.dnr.helpers;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.ContentValues; import android.content.ContentValues;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
@@ -13,7 +15,7 @@ import ru.vtosters.lite.utils.Helper;
public class DoNotReadDBHelper extends SQLiteOpenHelper { public class DoNotReadDBHelper extends SQLiteOpenHelper {
public DoNotReadDBHelper() { public DoNotReadDBHelper() {
super(Helper.GetContext(), "dnr", null, 1); super(GetContext(), "dnr", null, 1);
} }
@Override @Override
@@ -64,7 +64,7 @@ public class VideoDownloader {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setTitle(videoFile.toString()); request.setTitle(videoFile.toString());
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile.toString() + ".mp4"); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, videoFile + ".mp4");
((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request); ((DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request);
})); }));
builder.show(); builder.show();
@@ -1,5 +1,7 @@
package ru.vtosters.lite.f0x1d; package ru.vtosters.lite.f0x1d;
import static ru.vtosters.lite.utils.Helper.*;
import android.app.Activity; import android.app.Activity;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel; import android.app.NotificationChannel;
@@ -35,12 +37,12 @@ public class Crashreporter {
} }
static void start(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th, Activity activity) { static void start(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th, Activity activity) {
logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(Helper.GetContext()).toDeviceName() + "\n VTL Version: " + Prefs.VERSIONNAME + ", build: " + Prefs.getBuildNumber(); logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(GetContext()).toDeviceName() + "\n VTL Version: " + Prefs.VERSIONNAME + ", build: " + Prefs.getBuildNumber();
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= 26) {
var notificationChannel = new NotificationChannel("crashes", "crash", NotificationManager.IMPORTANCE_DEFAULT); var notificationChannel = new NotificationChannel("crashes", "crash", NotificationManager.IMPORTANCE_DEFAULT);
notificationChannel.enableVibration(true); notificationChannel.enableVibration(true);
notificationChannel.enableLights(true); notificationChannel.enableLights(true);
((NotificationManager) Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel); ((NotificationManager) GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChannel);
} }
var foxbinIntent = new Intent("com.f0x1d.dogbin.ACTION_UPLOAD_TO_FOXBIN"); var foxbinIntent = new Intent("com.f0x1d.dogbin.ACTION_UPLOAD_TO_FOXBIN");
@@ -52,19 +54,19 @@ public class Crashreporter {
foxbinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); foxbinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
} }
var saveLogIntent = new Intent(Helper.GetContext(), LogWriterService.class); var saveLogIntent = new Intent(GetContext(), LogWriterService.class);
saveLogIntent.putExtra("log", logString); saveLogIntent.putExtra("log", logString);
saveLogIntent.putExtra("notificationId", 1); saveLogIntent.putExtra("notificationId", 1);
var psaveLogIntent = PendingIntent.getService(Helper.GetContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT); var psaveLogIntent = PendingIntent.getService(GetContext(), 0, saveLogIntent, PendingIntent.FLAG_CANCEL_CURRENT);
var builder = new Notification.Builder(Helper.GetContext()); var builder = new Notification.Builder(GetContext());
builder.setSmallIcon(R.drawable.ic_bug_24); builder.setSmallIcon(R.drawable.ic_bug_24);
builder.setContentTitle("VTL Крашнулся!"); builder.setContentTitle("VTL Крашнулся!");
builder.setContentText(logString); builder.setContentText(logString);
builder.setStyle(new Notification.BigTextStyle().bigText(logString)); builder.setStyle(new Notification.BigTextStyle().bigText(logString));
builder.setAutoCancel(true); builder.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
builder.addAction(new Notification.Action(0, "Загрузить логи", PendingIntent.getActivity(Helper.GetContext(), (int) (Math.random() * 100.0d), foxbinIntent, PendingIntent.FLAG_CANCEL_CURRENT))); builder.addAction(new Notification.Action(0, "Загрузить логи", PendingIntent.getActivity(GetContext(), (int) (Math.random() * 100.0d), foxbinIntent, PendingIntent.FLAG_CANCEL_CURRENT)));
builder.addAction(new Notification.Action(0, "Сохранить в файл", psaveLogIntent)); builder.addAction(new Notification.Action(0, "Сохранить в файл", psaveLogIntent));
} else { } else {
builder.setContentIntent(PendingIntent.getActivity(activity, 0, foxbinIntent, PendingIntent.FLAG_ONE_SHOT)); builder.setContentIntent(PendingIntent.getActivity(activity, 0, foxbinIntent, PendingIntent.FLAG_ONE_SHOT));
@@ -75,13 +77,13 @@ public class Crashreporter {
} }
((NotificationManager) Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(-2147483548, builder.build()); ((NotificationManager) GetContext().getSystemService(Context.NOTIFICATION_SERVICE)).notify(-2147483548, builder.build());
Log.e("VTosters Lite", "crashed: " + th.getLocalizedMessage()); Log.e("VTosters Lite", "crashed: " + th.getLocalizedMessage());
uncaughtExceptionHandler.uncaughtException(thread, th); uncaughtExceptionHandler.uncaughtException(thread, th);
} }
private static boolean isFoxbinInstalled() { private static boolean isFoxbinInstalled() {
var pm = Helper.GetContext().getPackageManager(); var pm = GetContext().getPackageManager();
try { try {
pm.getPackageInfo("com.f0x1d.dogbin", 0); pm.getPackageInfo("com.f0x1d.dogbin", 0);
return true; return true;
@@ -1,5 +1,8 @@
package ru.vtosters.lite.f0x1d; package ru.vtosters.lite.f0x1d;
import static android.widget.Toast.*;
import static ru.vtosters.lite.utils.Helper.*;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
@@ -38,12 +41,12 @@ public class LogWriterService extends Service {
writeLog(intent, file); writeLog(intent, file);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Toast.makeText(Helper.GetContext(), "Не удалось сохранить лог-файл", Toast.LENGTH_SHORT).show(); makeText(GetContext(), "Не удалось сохранить лог-файл", LENGTH_SHORT).show();
} }
var notificationId = intent.getIntExtra("notificationId", 1); var notificationId = intent.getIntExtra("notificationId", 1);
var manager = (NotificationManager) Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE); var manager = (NotificationManager) GetContext().getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(notificationId); manager.cancel(notificationId);
Toast.makeText(Helper.GetContext(), "Лог-файл был сохранен", Toast.LENGTH_SHORT).show(); makeText(GetContext(), "Лог-файл был сохранен", LENGTH_SHORT).show();
stopSelf(); stopSelf();
return START_NOT_STICKY; return START_NOT_STICKY;
@@ -27,18 +27,17 @@ import okhttp3.Response;
import ru.vtosters.lite.utils.Prefs; import ru.vtosters.lite.utils.Prefs;
public class VTVerifications { public class VTVerifications {
public static final HashMap<Integer, Boolean> sServiceAccountsMap = new HashMap<>();
private static final String TAG = "VTVerifications"; private static final String TAG = "VTVerifications";
private static final String DEVELOPERS_KEY = "VTNRS3"; private static final String DEVELOPERS_KEY = "VTNRS3";
private static final String PROMETHEUS_KEY = "VTNRS1"; private static final String PROMETHEUS_KEY = "VTNRS1";
private static final String SERVICE_ACCOUNTS_KEY = "VTNRS4"; private static final String SERVICE_ACCOUNTS_KEY = "VTNRS4";
private static final String VERIFICATIONS_KEY = "VTNRS0"; private static final String VERIFICATIONS_KEY = "VTNRS0";
private static SharedPreferences mVerificationsCache;
private static final HashMap<Integer, Boolean> sDevelopersMap = new HashMap<>(); private static final HashMap<Integer, Boolean> sDevelopersMap = new HashMap<>();
private static final HashMap<Integer, Boolean> sPrometheusMap = new HashMap<>(); private static final HashMap<Integer, Boolean> sPrometheusMap = new HashMap<>();
public static final HashMap<Integer, Boolean> sServiceAccountsMap = new HashMap<>();
private static final HashMap<Integer, Boolean> sVerificationsMap = new HashMap<>(); private static final HashMap<Integer, Boolean> sVerificationsMap = new HashMap<>();
private static SharedPreferences mVerificationsCache;
private static OkHttpClient client = new OkHttpClient(); private static final OkHttpClient client = new OkHttpClient();
public static void load(Context context) { public static void load(Context context) {
mVerificationsCache = context.getSharedPreferences("vt_another_data", 0); mVerificationsCache = context.getSharedPreferences("vt_another_data", 0);
@@ -139,10 +138,7 @@ public class VTVerifications {
if (!Prefs.BooleanTrue("VT_Verification")) { if (!Prefs.BooleanTrue("VT_Verification")) {
return false; return false;
} }
if (isVerified((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0))) { return isVerified((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0));
return true;
}
return false;
} }
public static boolean hasPrometheus(JSONObject jSONObject) { public static boolean hasPrometheus(JSONObject jSONObject) {
@@ -152,10 +148,7 @@ public class VTVerifications {
if (!Prefs.BooleanTrue("VT_Fire")) { if (!Prefs.BooleanTrue("VT_Fire")) {
return false; return false;
} }
if (hasPrometheus((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0))) { return hasPrometheus((jSONObject.optString(NavigatorKeys.j) == null || (!jSONObject.optString(NavigatorKeys.j).equals("group") && !jSONObject.optString(NavigatorKeys.j).equals("page"))) ? jSONObject.optInt("id", 0) : -jSONObject.optInt("id", 0));
return true;
}
return false;
} }
public static boolean hasDeveloper(JSONObject jSONObject) { public static boolean hasDeveloper(JSONObject jSONObject) {
@@ -1,5 +1,7 @@
package ru.vtosters.lite.foaf; package ru.vtosters.lite.foaf;
import static android.widget.Toast.*;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Proxy.getApiCom; import static ru.vtosters.lite.utils.Proxy.getApiCom;
import android.app.ProgressDialog; import android.app.ProgressDialog;
@@ -32,7 +34,7 @@ public class FoafBase {
private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>"); private static final Pattern FOAF_REGEX = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>");
private static final Pattern FOAF_REGEX_LAST_SEEN = Pattern.compile("<ya:lastLoggedIn dc:date=\"(.*)(((\\+|-)\\d\\d):(\\d\\d))\"\\/>"); private static final Pattern FOAF_REGEX_LAST_SEEN = Pattern.compile("<ya:lastLoggedIn dc:date=\"(.*)(((\\+|-)\\d\\d):(\\d\\d))\"\\/>");
private static final Pattern FOAF_REGEX_LOGIN = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>"); private static final Pattern FOAF_REGEX_LOGIN = Pattern.compile("<ya:created dc:date=\"(.+?)\"\\/>");
private static OkHttpClient client = new OkHttpClient(); private static final OkHttpClient client = new OkHttpClient();
public static int GetLastSeenInt(int i) throws ParseException, IOException { public static int GetLastSeenInt(int i) throws ParseException, IOException {
Matcher matcher = FOAF_REGEX_LAST_SEEN.matcher(client.newCall(new Request.Builder().url(getLink(i)).build()).b().body().string()); Matcher matcher = FOAF_REGEX_LAST_SEEN.matcher(client.newCall(new Request.Builder().url(getLink(i)).build()).b().body().string());
@@ -81,10 +83,10 @@ public class FoafBase {
String normalHumanDate = getNormalHumanDate(matcher.group(1)); String normalHumanDate = getNormalHumanDate(matcher.group(1));
getNormalHumanDate(matcher2.group(1)); getNormalHumanDate(matcher2.group(1));
AlertDialog.a a2 = new VkAlertDialog.a(context).a(R.string.addinf); AlertDialog.a a2 = new VkAlertDialog.a(context).a(R.string.addinf);
a2.b(Helper.getString("foafid") + " " + i + Helper.getString("foafregdate") + " " + normalHumanDate + Helper.getString("foafdate") + " " + daysPassedFromFoafDate(normalHumanDate)).b(17039370, (DialogInterface.OnClickListener) null).b().show(); a2.b(getString("foafid") + " " + i + getString("foafregdate") + " " + normalHumanDate + getString("foafdate") + " " + daysPassedFromFoafDate(normalHumanDate)).b(17039370, null).b().show();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Toast.makeText(context, Helper.getString("foaferr"), Toast.LENGTH_SHORT).show(); makeText(context, getString("foaferr"), LENGTH_SHORT).show();
} }
} }
@@ -6,16 +6,15 @@ import android.preference.PreferenceManager;
import ru.vtosters.lite.utils.Helper; import ru.vtosters.lite.utils.Helper;
public class TGPref { public class TGPref {
private static SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()); private static final SharedPreferences Prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext());
private static String private static final String CNCT_METHOD = "VTGS:CM";
CNCT_METHOD = "VTGS:CM", private static final String TG_BOTKEY = "VTGS:BKey";
TG_BOTKEY = "VTGS:BKey", private static final String TG_PROXYIP = "VTGS:PIP";
TG_PROXYIP = "VTGS:PIP", private static final String TG_PROXYPORT = "VTGS:PPT";
TG_PROXYPORT = "VTGS:PPT", private static final String TG_PROXYPASS = "VTGS:PPS";
TG_PROXYPASS = "VTGS:PPS", private static final String TG_PROXYUSER = "VTGS:PUS";
TG_PROXYUSER = "VTGS:PUS", private static final String TG_PROXYUSEPASS = "VTGS:PUsePassword";
TG_PROXYUSEPASS = "VTGS:PUsePassword";
public static int getTGConnectMethod() { public static int getTGConnectMethod() {
return Integer.parseInt(Prefs.getString(CNCT_METHOD, "0")); return Integer.parseInt(Prefs.getString(CNCT_METHOD, "0"));
@@ -37,6 +36,10 @@ public class TGPref {
return Prefs.getString(TG_PROXYIP, null); return Prefs.getString(TG_PROXYIP, null);
} }
public static void setTGProxyIP(String ip) {
Prefs.edit().putString(TG_PROXYIP, ip).apply();
}
public static int getTGProxyPort() { public static int getTGProxyPort() {
return Prefs.getInt(TG_PROXYPORT, 0); return Prefs.getInt(TG_PROXYPORT, 0);
} }
@@ -53,10 +56,6 @@ public class TGPref {
return Prefs.getString(TG_PROXYUSER, ""); return Prefs.getString(TG_PROXYUSER, "");
} }
public static void setTGProxyIP(String ip) {
Prefs.edit().putString(TG_PROXYIP, ip).apply();
}
public static void setTGProxyUserPass(String user, String pass) { public static void setTGProxyUserPass(String user, String pass) {
Prefs.edit().putString(TG_PROXYUSER, user).putString(TG_PROXYPASS, pass) Prefs.edit().putString(TG_PROXYUSER, user).putString(TG_PROXYPASS, pass)
.apply(); .apply();
@@ -1,5 +1,7 @@
package ru.vtosters.lite.tgs; package ru.vtosters.lite.tgs;
import static ru.vtosters.lite.utils.Helper.*;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
@@ -23,21 +25,19 @@ import java.util.Stack;
import ru.vtosters.lite.utils.Helper; import ru.vtosters.lite.utils.Helper;
public class TGRoot { public class TGRoot {
private final static Stack<Integer> pendingStickers = new Stack<>();
public static final int N = 76820000; public static final int N = 76820000;
public static final int X = 976820000; public static final int X = 976820000;
private final static Stack<Integer> pendingStickers = new Stack<>();
private static String TAG = "TGRoot"; private static final String TAG = "TGRoot";
public static String getSummary() { public static String getSummary() {
switch (TGPref.getTGConnectMethod()) { switch (TGPref.getTGConnectMethod()) {
case 0: case 0:
return Helper.getString("ctypedirect"); return getString("ctypedirect");
case 2: case 2:
return Helper.getString("ctypesocks"); return getString("ctypesocks");
default: default:
return Helper.getString("ctypedisabled"); return getString("ctypedisabled");
} }
} }
@@ -49,7 +49,7 @@ public class TGRoot {
int stickerId = (id - N) % 120; int stickerId = (id - N) % 120;
TelegramStickersPack pack = null; TelegramStickersPack pack = null;
for (TelegramStickersPack p : TelegramStickersService.getInstance(Helper.GetContext()).getActivePacksListReference()) { for (TelegramStickersPack p : TelegramStickersService.getInstance(GetContext()).getActivePacksListReference()) {
if (p.index == index) { if (p.index == index) {
pack = p; pack = p;
break; break;
@@ -70,7 +70,7 @@ public class TGRoot {
public static void injectStickers(List<StickerStockItem> list) { public static void injectStickers(List<StickerStockItem> list) {
try { try {
List<TelegramStickersPack> packs = TelegramStickersService.getInstance(Helper.GetContext()).getActivePacksListReference(); List<TelegramStickersPack> packs = TelegramStickersService.getInstance(GetContext()).getActivePacksListReference();
for (int i = packs.size() - 1; i >= 0; i--) for (int i = packs.size() - 1; i >= 0; i--)
list.add(0, toStickerPack(packs.get(i))); list.add(0, toStickerPack(packs.get(i)));
} catch (Exception e) { } catch (Exception e) {
@@ -83,7 +83,7 @@ public class TGRoot {
int index = (stickerId - N) / 120; int index = (stickerId - N) / 120;
TelegramStickersPack p = null; TelegramStickersPack p = null;
for (TelegramStickersPack p_ : TelegramStickersService.getInstance(Helper.GetContext()) for (TelegramStickersPack p_ : TelegramStickersService.getInstance(GetContext())
.getActivePacksListReference()) { .getActivePacksListReference()) {
if (p_.index == index) { if (p_.index == index) {
p = p_; p = p_;
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui; package ru.vtosters.lite.ui;
import static ru.vtosters.lite.utils.Helper.*;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
@@ -27,17 +29,13 @@ import ru.vtosters.lite.utils.Themes;
public class PreferencesUtil { public class PreferencesUtil {
public interface EditTextPrefChangeListener {
boolean onChanged(Preference preference, Object obj);
}
public static Drawable setTint(Context ctx, Drawable d) { public static Drawable setTint(Context ctx, Drawable d) {
d.setColorFilter(Themes.getAccentColor(), PorterDuff.Mode.SRC_ATOP); d.setColorFilter(Themes.getAccentColor(), PorterDuff.Mode.SRC_ATOP);
return d; return d;
} }
public static void addListPreference(MaterialPreferenceToolbarFragment fragment, String key, String def, CharSequence title, CharSequence[] entries, CharSequence[] entriesValue) { public static void addListPreference(MaterialPreferenceToolbarFragment fragment, String key, String def, CharSequence title, CharSequence[] entries, CharSequence[] entriesValue) {
ListPreference preference = new ListPreference(Helper.GetContext()); ListPreference preference = new ListPreference(GetContext());
preference.a(entries); preference.a(entries);
preference.b(entriesValue); preference.b(entriesValue);
preference.c(title); // setTitle preference.c(title); // setTitle
@@ -48,7 +46,7 @@ public class PreferencesUtil {
} }
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment materialPreferenceToolbarFragment, String key, CharSequence title, CharSequence summary, boolean defValue) { public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment materialPreferenceToolbarFragment, String key, CharSequence title, CharSequence summary, boolean defValue) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(Helper.GetContext()); MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(GetContext());
materialSwitchPreference.c(title); // setTitle materialSwitchPreference.c(title); // setTitle
materialSwitchPreference.b(summary); // setSummary materialSwitchPreference.b(summary); // setSummary
materialSwitchPreference.d(key); // setKey materialSwitchPreference.d(key); // setKey
@@ -58,7 +56,7 @@ public class PreferencesUtil {
} }
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, int icon, boolean defValue, Preference.b listener) { public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, int icon, boolean defValue, Preference.b listener) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(Helper.GetContext()); MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(GetContext());
materialSwitchPreference.c(title); // setTitle materialSwitchPreference.c(title); // setTitle
materialSwitchPreference.b(summary); // setSummary materialSwitchPreference.b(summary); // setSummary
materialSwitchPreference.d(key); // setKey materialSwitchPreference.d(key); // setKey
@@ -66,13 +64,13 @@ public class PreferencesUtil {
materialSwitchPreference.a(listener); // setOnPreferenceClickListener materialSwitchPreference.a(listener); // setOnPreferenceClickListener
if (icon != 1) if (icon != 1)
materialSwitchPreference.a(setTint(Helper.GetContext(), ContextCompat.getDrawable(Helper.GetContext(), icon))); // preference.setIcon materialSwitchPreference.a(setTint(GetContext(), ContextCompat.getDrawable(GetContext(), icon))); // preference.setIcon
fragment.ay().d(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference) fragment.ay().d(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference)
} }
public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, String icon, boolean defValue, Preference.b listener) { public static void addMaterialSwitchPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, String icon, boolean defValue, Preference.b listener) {
MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(Helper.GetContext()); MaterialSwitchPreference materialSwitchPreference = new MaterialSwitchPreference(GetContext());
materialSwitchPreference.c(title); // setTitle materialSwitchPreference.c(title); // setTitle
materialSwitchPreference.b(summary); // setSummary materialSwitchPreference.b(summary); // setSummary
materialSwitchPreference.d(key); // setKey materialSwitchPreference.d(key); // setKey
@@ -80,14 +78,14 @@ public class PreferencesUtil {
fragment.ay().d(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference) fragment.ay().d(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference)
if (icon != null) if (icon != null)
materialSwitchPreference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon materialSwitchPreference.a(setTint(GetContext(), getDrawable(GetContext(), icon))); // preference.setIcon
materialSwitchPreference.a(listener); // setOnPreferenceClickListener(listener) materialSwitchPreference.a(listener); // setOnPreferenceClickListener(listener)
fragment.ay().d(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference) fragment.ay().d(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference)
} }
public static void addPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary) { public static void addPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary) {
Preference preference = new Preference(Helper.GetContext()); Preference preference = new Preference(GetContext());
preference.b(summary); // setSummary preference.b(summary); // setSummary
preference.c(title); // setTitle preference.c(title); // setTitle
preference.d(key); // setKey preference.d(key); // setKey
@@ -96,64 +94,64 @@ public class PreferencesUtil {
} }
public static void addPreference(MaterialPreferenceToolbarFragment fragment, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) { public static void addPreference(MaterialPreferenceToolbarFragment fragment, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) {
Preference preference = new Preference(Helper.GetContext()); Preference preference = new Preference(GetContext());
preference.b(summary); // setSummary preference.b(summary); // setSummary
preference.c(title); // setTitle preference.c(title); // setTitle
if (icon != null) if (icon != null)
preference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon preference.a(setTint(GetContext(), getDrawable(GetContext(), icon))); // preference.setIcon
preference.a(listener); // preference.setOnPreferenceClickListener(listener) preference.a(listener); // preference.setOnPreferenceClickListener(listener)
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference) fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
} }
public static void addPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) { public static void addPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, CharSequence summary, @Nullable String icon, Preference.c listener) {
Preference preference = new Preference(Helper.GetContext()); Preference preference = new Preference(GetContext());
preference.b(summary); // setSummary preference.b(summary); // setSummary
preference.c(title); // setTitle preference.c(title); // setTitle
preference.d(key); // setKey preference.d(key); // setKey
if (icon != null) if (icon != null)
preference.a(setTint(Helper.GetContext(), getDrawable(Helper.GetContext(), icon))); // preference.setIcon preference.a(setTint(GetContext(), getDrawable(GetContext(), icon))); // preference.setIcon
preference.a(listener); // preference.setOnPreferenceClickListener(listener) preference.a(listener); // preference.setOnPreferenceClickListener(listener)
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference) fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
} }
public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title) { public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title) {
PreferenceCategory preference = new PreferenceCategory(Helper.GetContext(), null); PreferenceCategory preference = new PreferenceCategory(GetContext(), null);
preference.c(title); // setTitle preference.c(title); // setTitle
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference) fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
} }
public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title, int collapsedSize) { public static void addPreferenceCategory(MaterialPreferenceToolbarFragment fragment, CharSequence title, int collapsedSize) {
PreferenceCategory preference = new PreferenceCategory(Helper.GetContext(), null); PreferenceCategory preference = new PreferenceCategory(GetContext(), null);
preference.c(title); // setTitle preference.c(title); // setTitle
fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference) fragment.ay().d(preference); // fragment.getPreferenceScreen().addPreference(preference)
} }
public static void addEditTextPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, EditTextPrefChangeListener editTextPrefChangeListener) { public static void addEditTextPreference(MaterialPreferenceToolbarFragment fragment, String key, CharSequence title, EditTextPrefChangeListener editTextPrefChangeListener) {
Preference preference = new Preference(Helper.GetContext()); Preference preference = new Preference(GetContext());
preference.c(title); // setTitle preference.c(title); // setTitle
preference.d(key); // setKey preference.d(key); // setKey
preference.a(preference1 -> { preference.a(preference1 -> {
LinearLayout linearLayout = new LinearLayout(Helper.GetContext()); LinearLayout linearLayout = new LinearLayout(GetContext());
final EditText editText = new EditText(Helper.GetContext()); final EditText editText = new EditText(GetContext());
editText.setText(PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()).getString(key, "")); editText.setText(PreferenceManager.getDefaultSharedPreferences(GetContext()).getString(key, ""));
editText.setHint(title); editText.setHint(title);
editText.setHintTextColor(PreferencesUtil.getSTextColor(Helper.GetContext())); editText.setHintTextColor(PreferencesUtil.getSTextColor(GetContext()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext()))); editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
} else { } else {
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext()))); ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
} }
linearLayout.addView(editText); linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams()); ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0); margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0);
editText.setLayoutParams(margin); editText.setLayoutParams(margin);
AlertDialog.Builder builder = new AlertDialog.Builder(fragment.p()); AlertDialog.Builder builder = new AlertDialog.Builder(fragment.p());
@@ -164,7 +162,7 @@ public class PreferencesUtil {
if (!change) if (!change)
return; return;
PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()) PreferenceManager.getDefaultSharedPreferences(GetContext())
.edit() .edit()
.putString(key, editText.getText().toString()) .putString(key, editText.getText().toString())
.apply(); .apply();
@@ -192,4 +190,8 @@ public class PreferencesUtil {
var id = ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName()); var id = ctx.getResources().getIdentifier(name, "drawable", ctx.getPackageName());
return ContextCompat.getDrawable(ctx, id); return ContextCompat.getDrawable(ctx, id);
} }
public interface EditTextPrefChangeListener {
boolean onChanged(Preference preference, Object obj);
}
} }
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui.dialogs; package ru.vtosters.lite.ui.dialogs;
import static ru.vtosters.lite.utils.Helper.*;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@@ -16,7 +18,7 @@ import ru.vtosters.lite.utils.Prefs;
public class DisableBattery { public class DisableBattery {
public static void alert(Activity activity) { public static void alert(Activity activity) {
if (OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && Prefs.BooleanTrue("showDoze")) { if (OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && Prefs.BooleanTrue("showDoze")) {
final Context context = Helper.GetContext(); final Context context = GetContext();
if (!((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) { if (!((PowerManager) context.getSystemService(Context.POWER_SERVICE)).isIgnoringBatteryOptimizations(context.getPackageName())) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Выключите оптимизацию батареи!"); builder.setTitle("Выключите оптимизацию батареи!");
@@ -36,7 +38,7 @@ public class DisableBattery {
builder.setNeutralButton("Игнорировать", new DialogInterface.OnClickListener() { builder.setNeutralButton("Игнорировать", new DialogInterface.OnClickListener() {
@Override // android.content.DialogInterface.OnClickListener @Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showDoze", false).apply(); edit().putBoolean("showDoze", false).apply();
} }
}); });
builder.show(); builder.show();
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui.dialogs; package ru.vtosters.lite.ui.dialogs;
import static ru.vtosters.lite.utils.Helper.*;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
@@ -14,7 +16,7 @@ import ru.vtosters.lite.utils.Prefs;
public class InstallGMS { public class InstallGMS {
public static void alert(final Activity activity) { public static void alert(final Activity activity) {
if (!Helper.IsGmsInstalled()) { if (!IsGmsInstalled()) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Внимание!"); builder.setTitle("Внимание!");
builder.setMessage(Text()); builder.setMessage(Text());
@@ -23,15 +25,15 @@ public class InstallGMS {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlertGms", false).apply(); edit().putBoolean("showAlertGms", false).apply();
} }
}); });
builder.setNeutralButton("Установить GMS", new DialogInterface.OnClickListener() { builder.setNeutralButton("Установить GMS", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlertGms", false).apply(); edit().putBoolean("showAlertGms", false).apply();
Context context = Helper.GetContext(); Context context = GetContext();
Intent a2 = new Navigator(InstallGMSFragment.class).a(context); Intent a2 = new Navigator(InstallGMSFragment.class).a(context);
context.startActivity(a2); context.startActivity(a2);
} }
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui.dialogs; package ru.vtosters.lite.ui.dialogs;
import static ru.vtosters.lite.utils.Helper.*;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
@@ -24,14 +26,14 @@ public class Start {
@Override // android.content.DialogInterface.OnClickListener @Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlert", false).apply(); edit().putBoolean("showAlert", false).apply();
} }
}); });
builder.setNeutralButton("Новости", new DialogInterface.OnClickListener() { builder.setNeutralButton("Новости", new DialogInterface.OnClickListener() {
@Override // android.content.DialogInterface.OnClickListener @Override // android.content.DialogInterface.OnClickListener
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
Helper.edit().putBoolean("showAlert", false).apply(); edit().putBoolean("showAlert", false).apply();
activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters"))); activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters")));
} }
}); });
@@ -17,22 +17,22 @@ public class InterfaceFragment extends MaterialPreferenceToolbarFragment {
prefs(); prefs();
} }
public class a implements Preference.b {
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
return InterfaceFragment.this.restart(preference, obj);
}
a() {
}
}
private void prefs() { private void prefs() {
a("newfeed").a((Preference.b) new a()); a("newfeed").a(new a());
} }
public boolean restart(Preference preference, Object obj) { public boolean restart(Preference preference, Object obj) {
ToastUtils.a(Helper.getString("restartapp")); ToastUtils.a(Helper.getString("restartapp"));
return true; return true;
} }
public class a implements Preference.b {
a() {
}
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
return InterfaceFragment.this.restart(preference, obj);
}
}
} }
@@ -1,8 +1,15 @@
package ru.vtosters.lite.ui.fragments; package ru.vtosters.lite.ui.fragments;
import static android.widget.Toast.*;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.SettBackup.backupSettings;
import static ru.vtosters.lite.utils.SettBackup.deletePrefs;
import static ru.vtosters.lite.utils.SettBackup.restoreBackup;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.widget.Toast; import android.widget.Toast;
@@ -23,23 +30,6 @@ import ru.vtosters.lite.utils.Helper;
public class OtherFragment extends MaterialPreferenceToolbarFragment { public class OtherFragment extends MaterialPreferenceToolbarFragment {
static class c implements Preference.c {
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
copy(Helper.GetContext(), Helper.GetUserToken());
return true;
}
public static void copy(Context context, String str) {
((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", str));
Toast.makeText(context, Helper.getString("copybtn"), Toast.LENGTH_SHORT).show();
ToastUtils.a(Helper.getString("tokenwarning"));
}
c() {
}
}
@Override @Override
public void b(Bundle bundle) { public void b(Bundle bundle) {
super.b(bundle); super.b(bundle);
@@ -47,19 +37,49 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
prefs(); prefs();
} }
private void prefs() {
a("firebasefix").a(new a());
a("applicationstop").a(new b());
a("tokencopy").a(new c());
a("applicationrestart").a(new d());
a("clearcache").a(new e());
a("stickfix").a(new f());
a("deleteprefs").a(new deleteprefs());
// a("saveprefs").a((Preference.c) new saveprefs());
// a("restoreprefs").a((Preference.c) new restoreprefs());
}
static class c implements Preference.c {
c() {
}
public static void copy(Context context, String str) {
((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", str));
makeText(context, getString("copybtn"), LENGTH_SHORT).show();
ToastUtils.a(getString("tokenwarning"));
}
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
copy(GetContext(), GetUserToken());
return true;
}
}
public class e implements Preference.c { public class e implements Preference.c {
e() {
}
@Override // android.support.v7.preference.Preference.c @Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) { public boolean a(Preference preference) {
VKImageLoader.b(); VKImageLoader.b();
ImEngineProvider.a().h(); ImEngineProvider.a().h();
AudioMessageUtils.j(); AudioMessageUtils.j();
FileUtils.l(); FileUtils.l();
ToastUtils.a(Helper.getString("cachecleaned")); ToastUtils.a(getString("cachecleaned"));
return true; return true;
} }
e() {
}
} }
public class b implements Preference.c { public class b implements Preference.c {
@@ -74,13 +94,13 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
} }
public class d implements Preference.c { public class d implements Preference.c {
@Override // android.support.v7.preference.Preference.c d() {
public boolean a(Preference preference) {
Helper.restarting();
return true;
} }
d() { @Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
restarting();
return true;
} }
} }
@@ -92,22 +112,61 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
public boolean a(Preference preference) { public boolean a(Preference preference) {
VKAccount b = VKAccountManager.b(); VKAccount b = VKAccountManager.b();
PushSubscriber.a.a(b.b(), b.c()); PushSubscriber.a.a(b.b(), b.c());
ToastUtils.a(Helper.getString("fcmtokenrem")); ToastUtils.a(getString("fcmtokenrem"));
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply(); AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
OtherFragment.this.aB().postDelayed(() -> { OtherFragment.this.aB().postDelayed(() -> {
PushSubscriber.a.a(true); PushSubscriber.a.a(true);
ToastUtils.a(Helper.getString("fcmtokenget")); ToastUtils.a(getString("fcmtokenget"));
ToastUtils.a(Helper.getString("fcmtokenfixed")); ToastUtils.a(getString("fcmtokenfixed"));
}, 1000); }, 1000);
return true; return true;
} }
} }
private void prefs() { public class f implements Preference.c {
a("firebasefix").a((Preference.c) new a()); f() {
a("applicationstop").a((Preference.c) new b()); }
a("tokencopy").a((Preference.c) new c());
a("applicationrestart").a((Preference.c) new d()); @Override // android.support.v7.preference.Preference.c
a("clearcache").a((Preference.c) new e()); public boolean a(Preference preference) {
SharedPreferences prefs = GetContext().getSharedPreferences("stickers", Context.MODE_PRIVATE);
prefs.edit().clear().commit();
restarting();
return true;
}
}
public class deleteprefs implements Preference.c {
deleteprefs() {
}
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
deletePrefs();
restarting();
return true;
}
}
public class saveprefs implements Preference.c {
saveprefs() {
}
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
backupSettings();
return true;
}
}
public class restoreprefs implements Preference.c {
restoreprefs() {
}
@Override // android.support.v7.preference.Preference.c
public boolean a(Preference preference) {
restoreBackup();
return true;
}
} }
} }
@@ -12,21 +12,6 @@ import ru.vtosters.lite.utils.IconHelper;
public class ThemesFragment extends MaterialPreferenceToolbarFragment { public class ThemesFragment extends MaterialPreferenceToolbarFragment {
public class a implements Preference.b {
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
return ThemesFragment.this.apply(preference, obj);
}
}
public static class b implements Preference.b {
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
ToastUtils.a(Helper.getString("restartapp"));
return true;
}
}
@Override @Override
public void b(Bundle bundle) { public void b(Bundle bundle) {
super.b(bundle); super.b(bundle);
@@ -45,8 +30,23 @@ public class ThemesFragment extends MaterialPreferenceToolbarFragment {
} }
private void prefs() { private void prefs() {
a("iconvk").a((Preference.b) new a()); a("iconvk").a(new a());
a("darktheme").a((Preference.b) new b()); a("darktheme").a(new b());
a("lighttheme").a((Preference.b) new b()); a("lighttheme").a(new b());
}
public static class b implements Preference.b {
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
ToastUtils.a(Helper.getString("restartapp"));
return true;
}
}
public class a implements Preference.b {
@Override // android.support.v7.preference.Preference.b
public boolean a(Preference preference, Object obj) {
return ThemesFragment.this.apply(preference, obj);
}
} }
} }
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui.fragments.dockbar; package ru.vtosters.lite.ui.fragments.dockbar;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@@ -40,51 +42,51 @@ public class DockBarAdapter extends RecyclerView.a
} }
private View createTabItem() { private View createTabItem() {
LinearLayout container = new LinearLayout(Helper.GetContext()); LinearLayout container = new LinearLayout(GetContext());
container.setTag("tab_item_container"); container.setTag("tab_item_container");
container.setGravity(Gravity.CENTER_VERTICAL); container.setGravity(Gravity.CENTER_VERTICAL);
container.setOrientation(LinearLayout.HORIZONTAL); container.setOrientation(LinearLayout.HORIZONTAL);
container.setPadding( container.setPadding(
Helper.convertDpToPixel(12), convertDpToPixel(12),
Helper.convertDpToPixel(12), convertDpToPixel(12),
Helper.convertDpToPixel(12), convertDpToPixel(12),
Helper.convertDpToPixel(12) convertDpToPixel(12)
); );
container.setLayoutParams(new LinearLayout.LayoutParams(-1, Helper.convertDpToPixel(48))); container.setLayoutParams(new LinearLayout.LayoutParams(-1, convertDpToPixel(48)));
ImageView icon = new ImageView(Helper.GetContext()); ImageView icon = new ImageView(GetContext());
icon.setTag("icon"); icon.setTag("icon");
icon.setImageTintList(ColorStateList.valueOf(Themes.getAccentColor())); icon.setImageTintList(ColorStateList.valueOf(Themes.getAccentColor()));
icon.setLayoutParams(new LinearLayout.LayoutParams( icon.setLayoutParams(new LinearLayout.LayoutParams(
Helper.convertDpToPixel(24), convertDpToPixel(24),
Helper.convertDpToPixel(24))); convertDpToPixel(24)));
container.addView(icon); container.addView(icon);
TextView title = new TextView(Helper.GetContext()); TextView title = new TextView(GetContext());
title.setTag("title"); title.setTag("title");
title.setTextSize(16.0f); title.setTextSize(16.0f);
title.setTypeface(Typeface.DEFAULT_BOLD); title.setTypeface(Typeface.DEFAULT_BOLD);
title.setTextColor(Themes.getTextAttr()); title.setTextColor(Themes.getTextAttr());
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -2);
params.weight = 1; params.weight = 1;
params.leftMargin = Helper.convertDpToPixel(16); params.leftMargin = convertDpToPixel(16);
container.addView(title, params); container.addView(title, params);
return container; return container;
} }
private View createGroupTitle() { private View createGroupTitle() {
LinearLayout layout = new LinearLayout(Helper.GetContext()); LinearLayout layout = new LinearLayout(GetContext());
layout.setLayoutParams(new LinearLayout.LayoutParams(-1, -2)); layout.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
TextView title = new TextView(Helper.GetContext()); TextView title = new TextView(GetContext());
title.setTag("group_title"); title.setTag("group_title");
title.setTextSize(13.0f); title.setTextSize(13.0f);
title.setPadding( title.setPadding(
Helper.convertDpToPixel(16), convertDpToPixel(16),
Helper.convertDpToPixel(13), convertDpToPixel(13),
Helper.convertDpToPixel(16), convertDpToPixel(16),
Helper.convertDpToPixel(13) convertDpToPixel(13)
); );
title.setAllCaps(true); title.setAllCaps(true);
title.setTextColor(Themes.getTextAttr()); title.setTextColor(Themes.getTextAttr());
@@ -155,8 +157,8 @@ public class DockBarAdapter extends RecyclerView.a
static class DockBarEditViewHolder extends RecyclerView.x { static class DockBarEditViewHolder extends RecyclerView.x {
private ImageView mIcon; private final ImageView mIcon;
private TextView mTitle; private final TextView mTitle;
public DockBarEditViewHolder(View itemView) { public DockBarEditViewHolder(View itemView) {
super(itemView); super(itemView);
@@ -173,7 +175,7 @@ public class DockBarAdapter extends RecyclerView.a
static class GroupViewHolder extends RecyclerView.x { static class GroupViewHolder extends RecyclerView.x {
private TextView mGroupTitle; private final TextView mGroupTitle;
public GroupViewHolder(View view) { public GroupViewHolder(View view) {
super(view); super(view);
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui.fragments.dockbar; package ru.vtosters.lite.ui.fragments.dockbar;
import static ru.vtosters.lite.utils.Helper.*;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@@ -30,10 +32,10 @@ public class DockBarFragment extends ToolbarFragment {
LinearLayout buttonsContainer = new LinearLayout(n()); LinearLayout buttonsContainer = new LinearLayout(n());
buttonsContainer.setPadding( buttonsContainer.setPadding(
Helper.convertDpToPixel(13), convertDpToPixel(13),
Helper.convertDpToPixel(10), convertDpToPixel(10),
Helper.convertDpToPixel(13), convertDpToPixel(13),
Helper.convertDpToPixel(10) convertDpToPixel(10)
); );
container.addView(buttonsContainer, new LinearLayout.LayoutParams(-1, -2)); container.addView(buttonsContainer, new LinearLayout.LayoutParams(-1, -2));
@@ -41,7 +43,7 @@ public class DockBarFragment extends ToolbarFragment {
save.setText("Сохранить"); save.setText("Сохранить");
save.setOnClickListener(v -> { save.setOnClickListener(v -> {
DockBarManager.getInstance().save(); DockBarManager.getInstance().save();
Helper.restarting(); restarting();
}); });
LinearLayout.LayoutParams saveParams = new LinearLayout.LayoutParams(0, -2); LinearLayout.LayoutParams saveParams = new LinearLayout.LayoutParams(0, -2);
@@ -49,13 +51,13 @@ public class DockBarFragment extends ToolbarFragment {
buttonsContainer.addView(save, saveParams); buttonsContainer.addView(save, saveParams);
View divider = new View(n()); View divider = new View(n());
buttonsContainer.addView(divider, new LinearLayout.LayoutParams(Helper.convertDpToPixel(10), 0)); buttonsContainer.addView(divider, new LinearLayout.LayoutParams(convertDpToPixel(10), 0));
Button reset = new Button(n()); Button reset = new Button(n());
reset.setText("Сбросить"); reset.setText("Сбросить");
reset.setOnClickListener(v -> { reset.setOnClickListener(v -> {
DockBarManager.getInstance().delete(); DockBarManager.getInstance().delete();
Helper.restarting(); restarting();
}); });
LinearLayout.LayoutParams resetParams = new LinearLayout.LayoutParams(0, -2); LinearLayout.LayoutParams resetParams = new LinearLayout.LayoutParams(0, -2);
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui.fragments.dockbar; package ru.vtosters.lite.ui.fragments.dockbar;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.Menu; import android.view.Menu;
@@ -61,12 +63,12 @@ public class DockBarInjector {
for (DockBarTab tab : sManager.getSelectedTabs()) { for (DockBarTab tab : sManager.getSelectedTabs()) {
MenuItem add = menu.add(0, tab.id, 0, tab.titleID); MenuItem add = menu.add(0, tab.id, 0, tab.titleID);
Drawable drawable = Helper.GetContext().getResources().getDrawable(tab.iconID); Drawable drawable = GetContext().getResources().getDrawable(tab.iconID);
ColorStateList colorStateList = Helper.GetContext().getResources().getColorStateList(com.vtosters.lite.R.color.bottom_navigation_item); ColorStateList colorStateList = GetContext().getResources().getColorStateList(com.vtosters.lite.R.color.bottom_navigation_item);
// if (isAndroidMonet()) { // if (isAndroidMonet()) {
// colorStateList = ColorStateList.valueOf(Themes.getAccentColor()); // colorStateList = ColorStateList.valueOf(Themes.getAccentColor());
// } // }
add.setIcon((Drawable) new RecoloredDrawable(drawable, colorStateList)); add.setIcon(new RecoloredDrawable(drawable, colorStateList));
add.setShowAsAction(1); add.setShowAsAction(1);
add.setCheckable(true); add.setCheckable(true);
} }
@@ -45,9 +45,18 @@ import ru.vtosters.lite.utils.Prefs;
public class DockBarManager { public class DockBarManager {
public static final int MIN_SELECTED_TABS_LIMIT = 3; public static final int MIN_SELECTED_TABS_LIMIT = 3;
public static final int MAX_SELECTED_TABS_LIMIT = 8; public static final int MAX_SELECTED_TABS_LIMIT = 9;
private static DockBarManager sInstance = new DockBarManager(); private static DockBarManager sInstance = new DockBarManager();
private final List<DockBarTab> mSelectedTabs = new ArrayList<>();
private final List<DockBarTab> mDisabledTabs = new ArrayList<>();
private final List<String> mGroups = Arrays.asList(
"Выбранные элементы докбара",
"Невыбранные элементы"
);
public DockBarManager() {
load();
}
public static DockBarManager getInstance() { public static DockBarManager getInstance() {
if (sInstance == null) if (sInstance == null)
@@ -55,15 +64,14 @@ public class DockBarManager {
return sInstance; return sInstance;
} }
private List<DockBarTab> mSelectedTabs = new ArrayList<>(); private static String readFully(InputStream is) throws IOException {
private List<DockBarTab> mDisabledTabs = new ArrayList<>(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
private List<String> mGroups = Arrays.asList( byte[] buffer = new byte[2048];
"Выбранные элементы докбара", int len;
"Невыбранные элементы" while ((len = is.read(buffer)) > 0) {
); bos.write(buffer, 0, len);
}
public DockBarManager() { return bos.toString();
load();
} }
private void load() { private void load() {
@@ -154,16 +162,6 @@ public class DockBarManager {
} }
} }
private static String readFully(InputStream is) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buffer = new byte[2048];
int len;
while ((len = is.read(buffer)) > 0) {
bos.write(buffer, 0, len);
}
return bos.toString();
}
public void delete() { public void delete() {
File dockbar = new File(Helper.GetContext().getFilesDir(), "dockbar.json"); File dockbar = new File(Helper.GetContext().getFilesDir(), "dockbar.json");
if (dockbar.exists()) dockbar.delete(); if (dockbar.exists()) dockbar.delete();
@@ -7,7 +7,7 @@ import android.support.v7.widget.a.ItemTouchHelper;
public class ItemTouchHelperCallback extends ItemTouchHelper.a { public class ItemTouchHelperCallback extends ItemTouchHelper.a {
private DockBarAdapter mAdapter; private final DockBarAdapter mAdapter;
public ItemTouchHelperCallback(DockBarAdapter mAdapter) { public ItemTouchHelperCallback(DockBarAdapter mAdapter) {
this.mAdapter = mAdapter; this.mAdapter = mAdapter;
@@ -1,5 +1,8 @@
package ru.vtosters.lite.ui.fragments.multiaccount; package ru.vtosters.lite.ui.fragments.multiaccount;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Themes.*;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@@ -34,17 +37,17 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
public MultiAccountViewHolder b(ViewGroup parent, int viewType) { public MultiAccountViewHolder b(ViewGroup parent, int viewType) {
RelativeLayout layout = new RelativeLayout(parent.getContext()); RelativeLayout layout = new RelativeLayout(parent.getContext());
layout.setPadding( layout.setPadding(
Helper.convertDpToPixel(12), convertDpToPixel(12),
Helper.convertDpToPixel(6), convertDpToPixel(6),
Helper.convertDpToPixel(6), convertDpToPixel(6),
Helper.convertDpToPixel(6) convertDpToPixel(6)
); );
VKCircleImageView avatar = new VKCircleImageView(parent.getContext()); VKCircleImageView avatar = new VKCircleImageView(parent.getContext());
avatar.setId(1); avatar.setId(1);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
Helper.convertDpToPixel(48), convertDpToPixel(48),
Helper.convertDpToPixel(48) convertDpToPixel(48)
); );
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params.addRule(RelativeLayout.CENTER_VERTICAL); params.addRule(RelativeLayout.CENTER_VERTICAL);
@@ -53,7 +56,7 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
TextView nickname = new TextView(parent.getContext()); TextView nickname = new TextView(parent.getContext());
nickname.setId(2); nickname.setId(2);
nickname.setPaddingRelative( nickname.setPaddingRelative(
Helper.convertDpToPixel(12), convertDpToPixel(12),
0, 0,
0, 0,
0 0
@@ -61,7 +64,7 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
nickname.setEllipsize(TextUtils.TruncateAt.END); nickname.setEllipsize(TextUtils.TruncateAt.END);
nickname.setSingleLine(true); nickname.setSingleLine(true);
nickname.setTextSize(15.0f); nickname.setTextSize(15.0f);
nickname.setTextColor(Themes.getTextAttr()); nickname.setTextColor(getTextAttr());
nickname.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL)); nickname.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(-2, -2); RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(-2, -2);
params1.addRule(RelativeLayout.CENTER_VERTICAL); params1.addRule(RelativeLayout.CENTER_VERTICAL);
@@ -71,11 +74,11 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
ImageButton action = new ImageButton(parent.getContext()); ImageButton action = new ImageButton(parent.getContext());
action.setId(3); action.setId(3);
action.setBackgroundResource(com.vtosters.lite.R.drawable.rounded_list_selector); action.setBackgroundResource(com.vtosters.lite.R.drawable.rounded_list_selector);
Drawable drawable = Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.ic_list_remove)); Drawable drawable = recolorDrawable(getResources().getDrawable(R.drawable.ic_list_remove));
action.setImageDrawable(drawable); action.setImageDrawable(drawable);
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(
Helper.convertDpToPixel(48), convertDpToPixel(48),
Helper.convertDpToPixel(48) convertDpToPixel(48)
); );
params2.addRule(RelativeLayout.CENTER_VERTICAL); params2.addRule(RelativeLayout.CENTER_VERTICAL);
params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
@@ -105,9 +108,9 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
super(view); super(view);
mContainer = (RelativeLayout) view; mContainer = (RelativeLayout) view;
mAvatar = (VKCircleImageView) view.findViewById(1); mAvatar = view.findViewById(1);
mNickname = (TextView) view.findViewById(2); mNickname = view.findViewById(2);
mAction = (ImageButton) view.findViewById(3); mAction = view.findViewById(3);
} }
public void bind(MultiAccountItem item, int pos) { public void bind(MultiAccountItem item, int pos) {
@@ -123,9 +126,9 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
VKAccount b = VKAccountManager.b(); VKAccount b = VKAccountManager.b();
PushSubscriber.a.a(b.b(), b.c()); PushSubscriber.a.a(b.b(), b.c());
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply(); AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
Helper.restarting(); restarting();
}); });
Drawable drawable = Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.ic_list_add)); Drawable drawable = recolorDrawable(getResources().getDrawable(R.drawable.ic_list_add));
mAction.setImageDrawable(drawable); mAction.setImageDrawable(drawable);
mAction.setClickable(false); mAction.setClickable(false);
} else { } else {
@@ -139,11 +142,11 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
VKAccount b = VKAccountManager.b(); VKAccount b = VKAccountManager.b();
PushSubscriber.a.a(b.b(), b.c()); PushSubscriber.a.a(b.b(), b.c());
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply(); AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
Helper.restarting(); restarting();
}); });
if (Helper.isNetworkConnected()) if (isNetworkConnected())
mAvatar.a(item.imageUrl); mAvatar.a(item.imageUrl);
else else
mAvatar.a(R.drawable.vkim_ic_placeholder_user_square_64dp); mAvatar.a(R.drawable.vkim_ic_placeholder_user_square_64dp);
@@ -160,7 +163,7 @@ public class MultiAccountAdapter extends RecyclerView.a<MultiAccountAdapter.Mult
VKAccount b = VKAccountManager.b(); VKAccount b = VKAccountManager.b();
PushSubscriber.a.a(b.b(), b.c()); PushSubscriber.a.a(b.b(), b.c());
AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply(); AppContextHolder.a.getSharedPreferences("gcm", 0).edit().clear().apply();
Helper.restarting(); restarting();
}); });
} }
} }
@@ -1,5 +1,6 @@
package ru.vtosters.lite.ui.fragments.multiaccount; package ru.vtosters.lite.ui.fragments.multiaccount;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Helper.GetContext; import static ru.vtosters.lite.utils.Helper.GetContext;
import android.content.Context; import android.content.Context;
@@ -16,7 +17,7 @@ import ru.vtosters.lite.utils.Helper;
public class MultiAccountManager { public class MultiAccountManager {
public static void migrate() { public static void migrate() {
SharedPreferences OldPrefs = Helper.GetContext().getSharedPreferences("pref_account_manager", Context.MODE_PRIVATE); SharedPreferences OldPrefs = GetContext().getSharedPreferences("pref_account_manager", Context.MODE_PRIVATE);
String OldPrefsValue = OldPrefs.getString("key_vk_account", ""); String OldPrefsValue = OldPrefs.getString("key_vk_account", "");
SharedPreferences NewPrefs = GetContext().getSharedPreferences("pref_account_manager0", Context.MODE_PRIVATE); SharedPreferences NewPrefs = GetContext().getSharedPreferences("pref_account_manager0", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = NewPrefs.edit(); SharedPreferences.Editor editor = NewPrefs.edit();
@@ -25,12 +26,12 @@ public class MultiAccountManager {
} }
public static SharedPreferences getCurrentAccount() { public static SharedPreferences getCurrentAccount() {
int account = Helper.GetPreferences().getInt("account", 0); int account = GetPreferences().getInt("account", 0);
return Helper.GetContext().getSharedPreferences("pref_account_manager" + (account != 0 ? account : ""), Context.MODE_PRIVATE); return GetContext().getSharedPreferences("pref_account_manager" + (account != 0 ? account : ""), Context.MODE_PRIVATE);
} }
private static int getAccountPrefsCount() { private static int getAccountPrefsCount() {
File[] prefs = new File(Helper.GetContext().getFilesDir().getParent(), "shared_prefs") File[] prefs = new File(GetContext().getFilesDir().getParent(), "shared_prefs")
.listFiles((dir, name) -> { .listFiles((dir, name) -> {
return name.matches("pref_account_manager\\d+\\.xml"); return name.matches("pref_account_manager\\d+\\.xml");
}); });
@@ -49,7 +50,7 @@ public class MultiAccountManager {
public static List<MultiAccountItem> buildList() { public static List<MultiAccountItem> buildList() {
List<MultiAccountItem> list = new ArrayList<>(); List<MultiAccountItem> list = new ArrayList<>();
for (int i = 0; i <= getAccountPrefsCount(); i++) { for (int i = 0; i <= getAccountPrefsCount(); i++) {
SharedPreferences prefs = Helper.GetContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE); SharedPreferences prefs = GetContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
String keyVKAccount = prefs.getString("key_vk_account", ""); String keyVKAccount = prefs.getString("key_vk_account", "");
if (!keyVKAccount.isEmpty()) { if (!keyVKAccount.isEmpty()) {
String name = withRegex(keyVKAccount, ".*\"name\":\\{.*?:\"(.*?)\"\\}.*", ""); String name = withRegex(keyVKAccount, ".*\"name\":\\{.*?:\"(.*?)\"\\}.*", "");
@@ -64,22 +65,22 @@ public class MultiAccountManager {
} }
public static boolean switchAccount(int i) { public static boolean switchAccount(int i) {
int account = Helper.GetPreferences().getInt("account", 0); int account = GetPreferences().getInt("account", 0);
if (account == i) return false; if (account == i) return false;
Helper.GetPreferences().edit().putInt("account", i).commit(); GetPreferences().edit().putInt("account", i).commit();
return true; return true;
} }
public static void addAccount() { public static void addAccount() {
Helper.GetPreferences().edit().putInt("account", getAccountPrefsCount()).commit(); GetPreferences().edit().putInt("account", getAccountPrefsCount()).commit();
} }
public static void deleteAccount(int i) { public static void deleteAccount(int i) {
int account = Helper.GetPreferences().getInt("account", 0); int account = GetPreferences().getInt("account", 0);
SharedPreferences prefs = Helper.GetContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE); SharedPreferences prefs = GetContext().getSharedPreferences("pref_account_manager" + i, Context.MODE_PRIVATE);
prefs.edit().clear().commit(); prefs.edit().clear().commit();
File file = new File(new File(Helper.GetContext().getFilesDir().getParent(), "shared_prefs"), "pref_account_manager" + i); File file = new File(new File(GetContext().getFilesDir().getParent(), "shared_prefs"), "pref_account_manager" + i);
if (file.exists()) file.delete(); if (file.exists()) file.delete();
if (account == i && getAccountPrefsCount() > 0) if (account == i && getAccountPrefsCount() > 0)
switchAccount(buildList().get(0).index); switchAccount(buildList().get(0).index);
@@ -1,5 +1,9 @@
package ru.vtosters.lite.ui.fragments.tgstickers; package ru.vtosters.lite.ui.fragments.tgstickers;
import static android.widget.Toast.*;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Themes.*;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@@ -52,23 +56,15 @@ public class StickersFragment extends ToolbarFragment {
public final static String ACTION_RELOAD = "com.vtosters.lite.action.RELOAD_TGS_LIST"; public final static String ACTION_RELOAD = "com.vtosters.lite.action.RELOAD_TGS_LIST";
private final static int TYPE_DIRECT = 0, TYPE_SOCKS = 2, TYPE_TOASTER_SERVER = 3; private final static int TYPE_DIRECT = 0, TYPE_SOCKS = 2, TYPE_TOASTER_SERVER = 3;
private static final String TAG = "StickersFragment";
public int from;
public int to;
private TelegramStickersGrabber grabber; private TelegramStickersGrabber grabber;
private TelegramStickersService stickersService; private TelegramStickersService stickersService;
private FloatingActionButton fab; private FloatingActionButton fab;
private static final String TAG = "StickersFragment";
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private RecyclerView.Adapter adapter; private RecyclerView.Adapter adapter;
private boolean movePending = false; private boolean movePending = false;
public int from;
public int to;
private int editPadding;
private RecyclerView recycler;
private final BroadcastReceiver receiver = new BroadcastReceiver() { private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@@ -90,6 +86,8 @@ public class StickersFragment extends ToolbarFragment {
} }
} }
}; };
private int editPadding;
private RecyclerView recycler;
private void initGrabber() { private void initGrabber() {
int method = TGPref.getTGConnectMethod(); int method = TGPref.getTGConnectMethod();
@@ -118,7 +116,7 @@ public class StickersFragment extends ToolbarFragment {
private void openMenu(String toast) { private void openMenu(String toast) {
if (toast != null) { if (toast != null) {
Toast.makeText(super.n(), toast, Toast.LENGTH_SHORT).show(); makeText(super.n(), toast, LENGTH_SHORT).show();
} }
var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).a(super.n()); var intent = new Navigator(StickersPreferencesFragment.class, new Bundle()).a(super.n());
super.n().startActivity(intent); super.n().startActivity(intent);
@@ -130,7 +128,7 @@ public class StickersFragment extends ToolbarFragment {
super.a(menu, menuInflater); super.a(menu, menuInflater);
MenuItem add = menu.add(0, 0, 0, ""); MenuItem add = menu.add(0, 0, 0, "");
add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); add.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
add.setIcon(Helper.getResources().getDrawable(com.vtosters.lite.R.drawable.ic_settings_24)); add.setIcon(getResources().getDrawable(com.vtosters.lite.R.drawable.ic_settings_24));
} }
@Override @Override
@@ -155,20 +153,20 @@ public class StickersFragment extends ToolbarFragment {
linearLayout.addView(editText); linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams()); ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0); margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0);
editText.setLayoutParams(margin); editText.setLayoutParams(margin);
new AlertDialog.Builder(super.n()) new AlertDialog.Builder(super.n())
.setTitle(Helper.getString("stickersapi5")) .setTitle(getString("stickersapi5"))
.setMessage(Helper.getString("stickersapi6")) .setMessage(getString("stickersapi6"))
.setView(linearLayout) .setView(linearLayout)
.setPositiveButton(android.R.string.ok, (dialog, which) -> { .setPositiveButton(android.R.string.ok, (dialog, which) -> {
TGPref.setTGBotKey(editText.getText().toString()); TGPref.setTGBotKey(editText.getText().toString());
if (r != null) r.run(); if (r != null) r.run();
}).setNegativeButton(android.R.string.cancel, null).setNeutralButton(Helper.getString("stickersapi7"), (dialog, which) -> new AlertDialog.Builder(super.n()) }).setNegativeButton(android.R.string.cancel, null).setNeutralButton(getString("stickersapi7"), (dialog, which) -> new AlertDialog.Builder(super.n())
.setTitle(Helper.getString("stickersapi8")) .setTitle(getString("stickersapi8"))
.setMessage(Helper.getString("stickersapi9") + .setMessage(getString("stickersapi9") +
Helper.getString("stickersapi10")).setPositiveButton(android.R.string.ok, null) getString("stickersapi10")).setPositiveButton(android.R.string.ok, null)
.create().show()).create().show(); .create().show()).create().show();
} }
@@ -179,7 +177,7 @@ public class StickersFragment extends ToolbarFragment {
final ProgressDialog progressDialog = new ProgressDialog(context); final ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage(Helper.getString("stickersapi1")); progressDialog.setMessage(getString("stickersapi1"));
progressDialog.show(); progressDialog.show();
grabber.checkKey(new TelegramStickersGrabber.KeyCheckListener() { grabber.checkKey(new TelegramStickersGrabber.KeyCheckListener() {
@@ -187,7 +185,7 @@ public class StickersFragment extends ToolbarFragment {
public void onKeyChecked(boolean ok) { public void onKeyChecked(boolean ok) {
progressDialog.dismiss(); progressDialog.dismiss();
if (!ok) { if (!ok) {
Toast.makeText(context, Helper.getString("stickersapi2"), Toast.LENGTH_SHORT).show(); makeText(context, getString("stickersapi2"), LENGTH_SHORT).show();
return; return;
} }
stickersService.setBotKey(TGPref.getTGBotKey()); stickersService.setBotKey(TGPref.getTGBotKey());
@@ -199,9 +197,9 @@ public class StickersFragment extends ToolbarFragment {
public void onNetError() { public void onNetError() {
progressDialog.dismiss(); progressDialog.dismiss();
new AlertDialog.Builder(context) new AlertDialog.Builder(context)
.setMessage(Helper.getString("stickersapi3")) .setMessage(getString("stickersapi3"))
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(Helper.getString("stickersapi4"), (arg0, arg1) -> checkApiKey(r)).create().show(); .setPositiveButton(getString("stickersapi4"), (arg0, arg1) -> checkApiKey(r)).create().show();
} }
}); });
} }
@@ -211,9 +209,9 @@ public class StickersFragment extends ToolbarFragment {
@Override @Override
public View d(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View d(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
grabber = new TelegramStickersGrabber(TGPref.getTGBotKey()); grabber = new TelegramStickersGrabber(TGPref.getTGBotKey());
stickersService = TelegramStickersService.getInstance(Helper.GetContext()); stickersService = TelegramStickersService.getInstance(GetContext());
editPadding = Helper.convertDpToPixel(24f); editPadding = convertDpToPixel(24f);
FrameLayout v = new FrameLayout(container.getContext()); FrameLayout v = new FrameLayout(container.getContext());
@@ -222,11 +220,11 @@ public class StickersFragment extends ToolbarFragment {
fab = new FloatingActionButton(container.getContext()); fab = new FloatingActionButton(container.getContext());
fab.setImageResource(R.drawable.ic_add_24); fab.setImageResource(R.drawable.ic_add_24);
fab.setBackgroundTintList(ColorStateList.valueOf(Themes.getAccentColor())); fab.setBackgroundTintList(ColorStateList.valueOf(getAccentColor()));
fab.setOnClickListener(v2 -> fabClick()); fab.setOnClickListener(v2 -> fabClick());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
params.setMargins(0, 0, 0, Helper.convertDpToPixel(12f)); params.setMargins(0, 0, 0, convertDpToPixel(12f));
fab.setLayoutParams(params); fab.setLayoutParams(params);
v.addView(recycler); v.addView(recycler);
@@ -245,7 +243,7 @@ public class StickersFragment extends ToolbarFragment {
switch (method) { switch (method) {
case TYPE_SOCKS: case TYPE_SOCKS:
if (TGPref.getTGProxyIP() == null) { if (TGPref.getTGProxyIP() == null) {
openMenu(Helper.getString("stickersproxy1")); openMenu(getString("stickersproxy1"));
return; return;
} }
case TYPE_TOASTER_SERVER: case TYPE_TOASTER_SERVER:
@@ -254,27 +252,27 @@ public class StickersFragment extends ToolbarFragment {
LinearLayout linearLayout = new LinearLayout(super.n()); LinearLayout linearLayout = new LinearLayout(super.n());
final EditText editText = new EditText(super.n()); final EditText editText = new EditText(super.n());
editText.setHintTextColor(PreferencesUtil.getSTextColor(Helper.GetContext())); editText.setHintTextColor(PreferencesUtil.getSTextColor(GetContext()));
// Костыль для китката // Костыль для китката
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext()))); editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
} else { } else {
ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(Helper.GetContext()))); ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(GetContext())));
} }
linearLayout.addView(editText); linearLayout.addView(editText);
editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; editText.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams()); ViewGroup.MarginLayoutParams margin = ((ViewGroup.MarginLayoutParams) editText.getLayoutParams());
margin.setMargins(Helper.convertDpToPixel(24f), 0, Helper.convertDpToPixel(24f), 0); margin.setMargins(convertDpToPixel(24f), 0, convertDpToPixel(24f), 0);
editText.setLayoutParams(margin); editText.setLayoutParams(margin);
new AlertDialog.Builder(super.n()).setTitle(Helper.getString("stickershelp1")) new AlertDialog.Builder(super.n()).setTitle(getString("stickershelp1"))
.setMessage(Helper.getString("stickershelp2")) .setMessage(getString("stickershelp2"))
.setView(linearLayout) .setView(linearLayout)
.setPositiveButton(android.R.string.ok, (dialog, which) -> { .setPositiveButton(android.R.string.ok, (dialog, which) -> {
String pack = editText.getText().toString(); String pack = editText.getText().toString();
pack = parsePack(pack); pack = parsePack(pack);
stickersService.requestPackDownload(pack, new File(Helper.GetContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath())); stickersService.requestPackDownload(pack, new File(GetContext().getFilesDir(), new File("VT-Stickers", pack).getAbsolutePath()));
}).setNeutralButton(android.R.string.cancel, null).create().show(); }).setNeutralButton(android.R.string.cancel, null).create().show();
}; };
if (TGPref.getTGBotKey() == null) enterBotKey(() -> checkApiKey(work)); if (TGPref.getTGBotKey() == null) enterBotKey(() -> checkApiKey(work));
@@ -284,7 +282,7 @@ public class StickersFragment extends ToolbarFragment {
}; };
if (method == -1) { if (method == -1) {
openMenu(Helper.getString("stickersconnection")); openMenu(getString("stickersconnection"));
} else { } else {
r.run(); r.run();
} }
@@ -293,7 +291,7 @@ public class StickersFragment extends ToolbarFragment {
@Override @Override
public void b(@Nullable Bundle savedInstanceState) { public void b(@Nullable Bundle savedInstanceState) {
super.b(savedInstanceState); super.b(savedInstanceState);
Helper.GetContext().registerReceiver(receiver, new IntentFilter(ACTION_RELOAD)); GetContext().registerReceiver(receiver, new IntentFilter(ACTION_RELOAD));
} }
@Override @Override
@@ -302,13 +300,13 @@ public class StickersFragment extends ToolbarFragment {
super.a(arg0, arg1); super.a(arg0, arg1);
a(Helper.getString("vtltgs")); a(getString("vtltgs"));
} }
@Override @Override
public void A_() { public void A_() {
super.A_(); super.A_();
Helper.GetContext().unregisterReceiver(receiver); GetContext().unregisterReceiver(receiver);
} }
private String parsePack(String pack) { private String parsePack(String pack) {
@@ -321,31 +319,12 @@ public class StickersFragment extends ToolbarFragment {
} }
public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.StickerPackViewHolder> { public class StickerPackAdapter extends RecyclerView.Adapter<StickerPackAdapter.StickerPackViewHolder> {
private String TAG = "StickerPackAdapter"; private final String TAG = "StickerPackAdapter";
public class StickerPackViewHolder extends RecyclerView.ViewHolder {
private SwitchCompat switchCompat;
private ImageView stickerImage, updateButton, deleteButton;
private TextView name, count;
private LinearLayout layout;
StickerPackViewHolder(@NonNull View view) {
super(view);
switchCompat = (SwitchCompat) view.findViewById(R.id.choose_btn);
stickerImage = (ImageView) view.findViewById(R.id.photo);
updateButton = (ImageView) view.findViewById(R.id.button_update);
deleteButton = (ImageView) view.findViewById(R.id.action_delete);
name = (TextView) view.findViewById(R.id.vkim_cancel);
count = (TextView) view.findViewById(R.id.vkim_cancel_label_text);
layout = (LinearLayout) view.findViewById(R.id.linearLayout5);
}
}
@NonNull @NonNull
@Override @Override
public StickerPackViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public StickerPackViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
var view = LayoutInflater.from(parent.getContext()).inflate(Helper.getIdentifier("tgs_entry", "layout"), parent, false); var view = LayoutInflater.from(parent.getContext()).inflate(getIdentifier("tgs_entry", "layout"), parent, false);
return new StickerPackViewHolder(view); return new StickerPackViewHolder(view);
} }
@@ -365,19 +344,19 @@ public class StickersFragment extends ToolbarFragment {
if (f.exists()) { if (f.exists()) {
holder.stickerImage.setImageURI(Uri.parse("file://" + f.getAbsolutePath())); holder.stickerImage.setImageURI(Uri.parse("file://" + f.getAbsolutePath()));
} else { } else {
holder.stickerImage.setImageDrawable(Helper.getResources().getDrawable(R.drawable.icon_vk_104)); holder.stickerImage.setImageDrawable(getResources().getDrawable(R.drawable.icon_vk_104));
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
holder.updateButton.setImageDrawable(Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.ic_camera_switch_48))); holder.updateButton.setImageDrawable(recolorDrawable(getResources().getDrawable(R.drawable.ic_camera_switch_48)));
holder.updateButton.setOnClickListener(listener -> { holder.updateButton.setOnClickListener(listener -> {
stickersService.setBotKey(TGPref.getTGBotKey()); stickersService.setBotKey(TGPref.getTGBotKey());
stickersService.requestPackDownload(pack.id, new File(Helper.GetContext().getFilesDir(), new File("VT-Stickers", pack.id).getAbsolutePath())); stickersService.requestPackDownload(pack.id, new File(GetContext().getFilesDir(), new File("VT-Stickers", pack.id).getAbsolutePath()));
}); });
holder.deleteButton.setImageDrawable(Themes.recolorDrawable(Helper.getResources().getDrawable(R.drawable.vkim_ic_msg_delete))); holder.deleteButton.setImageDrawable(recolorDrawable(getResources().getDrawable(R.drawable.vkim_ic_msg_delete)));
holder.deleteButton.setOnClickListener(listener -> { holder.deleteButton.setOnClickListener(listener -> {
stickersService.deletePack(pack); stickersService.deletePack(pack);
notifyItemRemoved(position); notifyItemRemoved(position);
@@ -386,13 +365,13 @@ public class StickersFragment extends ToolbarFragment {
holder.name.setText(pack.title); holder.name.setText(pack.title);
holder.switchCompat.setChecked(pack.enabled); holder.switchCompat.setChecked(pack.enabled);
holder.switchCompat.setOnCheckedChangeListener((buttonView, isChecked) -> stickersService.setPackEnabled(pack, isChecked, false)); holder.switchCompat.setOnCheckedChangeListener((buttonView, isChecked) -> stickersService.setPackEnabled(pack, isChecked, false));
holder.count.setText(pack.stickersCount + " " + Helper.getString("stickerscount")); holder.count.setText(pack.stickersCount + " " + getString("stickerscount"));
holder.layout.setBackgroundColor(Prefs.getNavbarColor()); holder.layout.setBackgroundColor(Prefs.getNavbarColor());
// Color костыль // Color костыль
int color = Themes.getTextAttr(); int color = getTextAttr();
int secondary = Themes.getSTextAttr(); int secondary = getSTextAttr();
holder.name.setTextColor(color); holder.name.setTextColor(color);
holder.count.setTextColor(secondary); holder.count.setTextColor(secondary);
@@ -402,6 +381,28 @@ public class StickersFragment extends ToolbarFragment {
public int getItemCount() { public int getItemCount() {
return stickersService.getPacksListReference().size(); return stickersService.getPacksListReference().size();
} }
public class StickerPackViewHolder extends RecyclerView.ViewHolder {
private final SwitchCompat switchCompat;
private final ImageView stickerImage;
private final ImageView updateButton;
private final ImageView deleteButton;
private final TextView name;
private final TextView count;
private final LinearLayout layout;
StickerPackViewHolder(@NonNull View view) {
super(view);
switchCompat = view.findViewById(R.id.choose_btn);
stickerImage = view.findViewById(R.id.photo);
updateButton = view.findViewById(R.id.button_update);
deleteButton = view.findViewById(R.id.action_delete);
name = view.findViewById(R.id.vkim_cancel);
count = view.findViewById(R.id.vkim_cancel_label_text);
layout = view.findViewById(R.id.linearLayout5);
}
}
} }
} }
@@ -1,5 +1,7 @@
package ru.vtosters.lite.ui.fragments.tgstickers; package ru.vtosters.lite.ui.fragments.tgstickers;
import static ru.vtosters.lite.utils.Helper.*;
import android.os.Bundle; import android.os.Bundle;
import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber; import com.aefyr.tsg.g2.stickersgrabber.TelegramStickersGrabber;
@@ -17,19 +19,19 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
public void b(Bundle bundle) { public void b(Bundle bundle) {
super.b(bundle); super.b(bundle);
int vtosterXml = Helper.GetContext().getResources().getIdentifier("empty", "xml", Helper.GetContext().getPackageName()); int vtosterXml = GetContext().getResources().getIdentifier("empty", "xml", GetContext().getPackageName());
this.a(vtosterXml); this.a(vtosterXml);
PreferencesUtil.addPreferenceCategory(this, Helper.getString("sprefsstickers")); PreferencesUtil.addPreferenceCategory(this, getString("sprefsstickers"));
PreferencesUtil.addPreference(this, "", Helper.getString("sprefsdelkey"), "", null, preference -> { PreferencesUtil.addPreference(this, "", getString("sprefsdelkey"), "", null, preference -> {
TGPref.setTGBotKey(null); TGPref.setTGBotKey(null);
ToastUtils.a(Helper.getString("sprefsdelkey2")); ToastUtils.a(getString("sprefsdelkey2"));
return false; return false;
}); });
PreferencesUtil.addPreferenceCategory(this, Helper.getString("sprefsnetwork")); PreferencesUtil.addPreferenceCategory(this, getString("sprefsnetwork"));
PreferencesUtil.addListPreference(this, "VTGS:CM", "0", Helper.getString("sprefsctype"), new CharSequence[]{ PreferencesUtil.addListPreference(this, "VTGS:CM", "0", getString("sprefsctype"), new CharSequence[]{
Helper.getString("ctypedirect"), Helper.getString("ctypesocks") getString("ctypedirect"), getString("ctypesocks")
}, new String[]{ }, new String[]{
"0", "2" "0", "2"
}); });
@@ -44,22 +46,22 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
return true; return true;
}); });
PreferencesUtil.addPreferenceCategory(this, Helper.getString("ssocks")); PreferencesUtil.addPreferenceCategory(this, getString("ssocks"));
PreferencesUtil.addEditTextPreference(this, "tg_proxy_host", Helper.getString("ssockshost"), (preference, o) -> { PreferencesUtil.addEditTextPreference(this, "tg_proxy_host", getString("ssockshost"), (preference, o) -> {
TGPref.setTGProxyIP((String) o); TGPref.setTGProxyIP((String) o);
return true; return true;
}); });
PreferencesUtil.addEditTextPreference(this, "tg_proxy_port", Helper.getString("ssocksport"), (preference, o) -> { PreferencesUtil.addEditTextPreference(this, "tg_proxy_port", getString("ssocksport"), (preference, o) -> {
try { try {
TGPref.setTGProxyPort(Integer.parseInt((String) o)); TGPref.setTGProxyPort(Integer.parseInt((String) o));
return true; return true;
} catch (Exception e) { } catch (Exception e) {
ToastUtils.a(Helper.getString("ssockswport")); ToastUtils.a(getString("ssockswport"));
return false; return false;
} }
}); });
PreferencesUtil.addMaterialSwitchPreference(this, "tg_proxy_auth", Helper.getString("ssocksauth"), "", null, false, (preference, o) -> { PreferencesUtil.addMaterialSwitchPreference(this, "tg_proxy_auth", getString("ssocksauth"), "", null, false, (preference, o) -> {
boolean value = (boolean) o; boolean value = (boolean) o;
a("tg_proxy_login").a(value); // findPreference("tg_proxy_login").setEnabled(value); a("tg_proxy_login").a(value); // findPreference("tg_proxy_login").setEnabled(value);
@@ -68,11 +70,11 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
TGPref.setTGProxyPassEnabled(value); TGPref.setTGProxyPassEnabled(value);
return true; return true;
}); });
PreferencesUtil.addEditTextPreference(this, "tg_proxy_login", Helper.getString("ssockslogin"), (preference, o) -> { PreferencesUtil.addEditTextPreference(this, "tg_proxy_login", getString("ssockslogin"), (preference, o) -> {
TGPref.setTGProxyUserPass((String) o, TGPref.getTGProxyPass()); TGPref.setTGProxyUserPass((String) o, TGPref.getTGProxyPass());
return true; return true;
}); });
PreferencesUtil.addEditTextPreference(this, "tg_proxy_pass", Helper.getString("ssockspass"), (preference, o) -> { PreferencesUtil.addEditTextPreference(this, "tg_proxy_pass", getString("ssockspass"), (preference, o) -> {
TGPref.setTGProxyUserPass(TGPref.getTGProxyUser(), (String) o); TGPref.setTGProxyUserPass(TGPref.getTGProxyUser(), (String) o);
return true; return true;
}); });
@@ -83,7 +85,7 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme
@Override @Override
public int aq() { public int aq() {
return Helper.GetContext().getResources().getIdentifier("vtltgs", "string", Helper.GetContext().getPackageName()); return GetContext().getResources().getIdentifier("vtltgs", "string", GetContext().getPackageName());
} }
} }
@@ -1,5 +1,7 @@
package ru.vtosters.lite.utils; package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Helper.*;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -55,7 +57,7 @@ public class ExternalLinkHandler {
} }
private static boolean checkYoutubeLink(VideoFile file) { private static boolean checkYoutubeLink(VideoFile file) {
if (!Helper.isEmpty(file.n)) { if (!isEmpty(file.n)) {
for (String filter : filters) { for (String filter : filters) {
if (file.n.contains(filter)) if (file.n.contains(filter))
return true; return true;
@@ -74,25 +76,25 @@ public class ExternalLinkHandler {
* this.k = var3.optString("mp4_2160"); * this.k = var3.optString("mp4_2160");
*/ */
public static boolean checkVkVideo(VideoFile videoFile) { public static boolean checkVkVideo(VideoFile videoFile) {
if (!Helper.isEmpty(videoFile.e)) { if (!isEmpty(videoFile.e)) {
qualities.put("240", videoFile.e); qualities.put("240", videoFile.e);
} }
if (!Helper.isEmpty(videoFile.f)) { if (!isEmpty(videoFile.f)) {
qualities.put("360", videoFile.f); qualities.put("360", videoFile.f);
} }
if (!Helper.isEmpty(videoFile.g)) { if (!isEmpty(videoFile.g)) {
qualities.put("480", videoFile.g); qualities.put("480", videoFile.g);
} }
if (!Helper.isEmpty(videoFile.h)) { if (!isEmpty(videoFile.h)) {
qualities.put("720", videoFile.h); qualities.put("720", videoFile.h);
} }
if (!Helper.isEmpty(videoFile.i)) { if (!isEmpty(videoFile.i)) {
qualities.put("1080", videoFile.i); qualities.put("1080", videoFile.i);
} }
if (!Helper.isEmpty(videoFile.j)) { if (!isEmpty(videoFile.j)) {
qualities.put("1440", videoFile.j); qualities.put("1440", videoFile.j);
} }
if (!Helper.isEmpty(videoFile.k)) { if (!isEmpty(videoFile.k)) {
qualities.put("2160", videoFile.k); qualities.put("2160", videoFile.k);
} }
@@ -107,7 +109,7 @@ public class ExternalLinkHandler {
Intent intent = new Intent(); Intent intent = new Intent();
String packageName = getMXPlayerPackageName(); String packageName = getMXPlayerPackageName();
if (!Helper.isEmpty(packageName)) { if (!isEmpty(packageName)) {
intent.setPackage(packageName); intent.setPackage(packageName);
intent.setDataAndType(uri, "application/mp4"); intent.setDataAndType(uri, "application/mp4");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -118,7 +120,7 @@ public class ExternalLinkHandler {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} }
Helper.GetContext().startActivity(intent); GetContext().startActivity(intent);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -127,7 +129,7 @@ public class ExternalLinkHandler {
} }
private static String getMXPlayerPackageName() { private static String getMXPlayerPackageName() {
for (ApplicationInfo info : Helper.GetContext().getPackageManager().getInstalledApplications(0)) { for (ApplicationInfo info : GetContext().getPackageManager().getInstalledApplications(0)) {
String packName = info.packageName; String packName = info.packageName;
if (packName.equals("com.mxtech.videoplayer.ad") || packName.equals("com.mxtech.videoplayer.pro")) if (packName.equals("com.mxtech.videoplayer.ad") || packName.equals("com.mxtech.videoplayer.pro"))
return packName; return packName;
@@ -1,5 +1,7 @@
package ru.vtosters.lite.utils; package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Proxy.*;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@@ -38,7 +40,7 @@ public class Helper {
} }
public static String getConnectorDomain(String str) { public static String getConnectorDomain(String str) {
return Proxy.GetConnector(str); return GetConnector(str);
} }
public static void reloadMSG() { public static void reloadMSG() {
@@ -107,7 +109,7 @@ public class Helper {
} }
public static String getString(String str) { public static String getString(String str) {
return Helper.GetContext().getString(Integer.parseInt(String.valueOf(Helper.GetContext().getResources().getIdentifier(str, "string", Helper.GetContext().getPackageName())))); return GetContext().getString(Integer.parseInt(String.valueOf(GetContext().getResources().getIdentifier(str, "string", GetContext().getPackageName()))));
} }
public static String getPackageName() { public static String getPackageName() {
@@ -141,6 +143,6 @@ public class Helper {
public static boolean isNetworkConnected() { public static boolean isNetworkConnected() {
ConnectivityManager cm = (ConnectivityManager) GetContext().getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) GetContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return activeNetwork != null ? activeNetwork.isConnectedOrConnecting() : false; return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
} }
} }
@@ -1,20 +1,22 @@
package ru.vtosters.lite.utils; package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
public class IconHelper { public class IconHelper {
public static void switchToVK() { public static void switchToVK() {
var packageManager = Helper.GetContext().getPackageManager(); var packageManager = GetContext().getPackageManager();
var packageName = Helper.getPackageName(); var packageName = getPackageName();
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
} }
public static void switchToDefault() { public static void switchToDefault() {
var packageManager = Helper.GetContext().getPackageManager(); var packageManager = GetContext().getPackageManager();
var packageName = Helper.getPackageName(); var packageName = getPackageName();
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconDefault"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
packageManager.setComponentEnabledSetting(new ComponentName(packageName, Helper.getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); packageManager.setComponentEnabledSetting(new ComponentName(packageName, getPackageName() + ".VTIconVK"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
} }
} }
@@ -1,5 +1,6 @@
package ru.vtosters.lite.utils; package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Proxy.setProxy; import static ru.vtosters.lite.utils.Proxy.setProxy;
import android.app.Activity; import android.app.Activity;
@@ -57,17 +58,17 @@ import ru.vtosters.lite.ui.fragments.dockbar.DockBarManager;
import ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager; import ru.vtosters.lite.ui.fragments.multiaccount.MultiAccountManager;
public class Prefs { public class Prefs {
private static final List<Activity> activities = new ArrayList<>();
public static String VERSIONNAME = "2.0 Beta"; public static String VERSIONNAME = "2.0 Beta";
private static List<String> mFilters; private static List<String> mFilters;
private static final List<Activity> activities = new ArrayList<>();
public static boolean BooleanFalse(String key) { public static boolean BooleanFalse(String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GetContext());
return prefs.getBoolean(key, false); return prefs.getBoolean(key, false);
} }
public static boolean BooleanTrue(String key) { public static boolean BooleanTrue(String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GetContext());
return prefs.getBoolean(key, true); return prefs.getBoolean(key, true);
} }
@@ -241,11 +242,11 @@ public class Prefs {
} }
public static String getBuildNumber() { public static String getBuildNumber() {
return Prefs.getBuild(Helper.GetContext(), "version.properties"); return Prefs.getBuild(GetContext(), "version.properties");
} }
public static String getCommitLink() { public static String getCommitLink() {
return "https://github.com/vtosters/lite/commit/" + Prefs.getBuild(Helper.GetContext(), "version.properties"); return "https://github.com/vtosters/lite/commit/" + Prefs.getBuild(GetContext(), "version.properties");
} }
public static String getBuild(Context context, String name) { public static String getBuild(Context context, String name) {
@@ -265,7 +266,7 @@ public class Prefs {
} }
public static String getBranch() { public static String getBranch() {
return Helper.GetPreferences().getString("ota_branches", "Stable"); return GetPreferences().getString("ota_branches", "Stable");
} }
public static String getDarkVKUI() { public static String getDarkVKUI() {
@@ -273,12 +274,12 @@ public class Prefs {
} }
public static String getAmoledVKUI() { public static String getAmoledVKUI() {
String string = Helper.GetPreferences().getString("darktheme", ""); String string = GetPreferences().getString("darktheme", "");
return string.equals("amoled") ? "1" : "0"; return string.equals("amoled") ? "1" : "0";
} }
public static String getCommentsSort(String def) { public static String getCommentsSort(String def) {
String string = Helper.GetPreferences().getString("commentssort", ""); String string = GetPreferences().getString("commentssort", "");
if (string.isEmpty()) { if (string.isEmpty()) {
return def; return def;
} }
@@ -292,23 +293,23 @@ public class Prefs {
} }
public static String getMeToken() { public static String getMeToken() {
return Helper.GetPreferences().getString("me_token", ""); return GetPreferences().getString("me_token", "");
} }
public static void setMeToken(String str) { public static void setMeToken(String str) {
ru.vtosters.lite.utils.Helper.GetPreferences().edit().putString("me_token", str).apply(); GetPreferences().edit().putString("me_token", str).apply();
} }
public static int getNavbarColor() { public static int getNavbarColor() {
return VKThemeHelper.a((int) R.attr.tabbar_background); return VKThemeHelper.a(R.attr.tabbar_background);
} }
public static String getSSFSLink() { public static String getSSFSLink() {
return SSFSDomain() + "?token=" + ru.vtosters.lite.utils.Helper.GetUserToken() + "&vt_dark=" + getDarkVKUI() + "&vt_amoled=" + getAmoledVKUI() + "&secret=" + ru.vtosters.lite.utils.Helper.GetUserSecret() + "&proxy=" + getUserProxy() + "&lang=" + getLocale() + "&vt=1&vtl=1&vksans=" + isVKSansEnabled() + "&vt_version=" + getBuildNumber() + "&vt_debug=" + isDEVModEnabled(); return SSFSDomain() + "?token=" + GetUserToken() + "&vt_dark=" + getDarkVKUI() + "&vt_amoled=" + getAmoledVKUI() + "&secret=" + GetUserSecret() + "&proxy=" + getUserProxy() + "&lang=" + getLocale() + "&vt=1&vtl=1&vksans=" + isVKSansEnabled() + "&vt_version=" + getBuildNumber() + "&vt_debug=" + isDEVModEnabled();
} }
public static String getString(String key, String defValue) { public static String getString(String key, String defValue) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(Helper.GetContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(GetContext());
return prefs.getString(key, defValue); return prefs.getString(key, defValue);
} }
@@ -381,32 +382,32 @@ public class Prefs {
} }
public static String proxyHostHTTP() { public static String proxyHostHTTP() {
String string = Helper.GetPreferences().getString("proxyHostHTTP", ""); String string = GetPreferences().getString("proxyHostHTTP", "");
return string.isEmpty() ? "192.168.0.1" : string; return string.isEmpty() ? "192.168.0.1" : string;
} }
public static String proxyHostHTTPS() { public static String proxyHostHTTPS() {
String string = Helper.GetPreferences().getString("proxyHostHTTPS", ""); String string = GetPreferences().getString("proxyHostHTTPS", "");
return string.isEmpty() ? "192.168.0.1" : string; return string.isEmpty() ? "192.168.0.1" : string;
} }
public static String proxyHostSocks() { public static String proxyHostSocks() {
String string = Helper.GetPreferences().getString("proxyHostSocks", ""); String string = GetPreferences().getString("proxyHostSocks", "");
return string.isEmpty() ? "192.168.0.1" : string; return string.isEmpty() ? "192.168.0.1" : string;
} }
public static String proxyPortHTTP() { public static String proxyPortHTTP() {
String string = Helper.GetPreferences().getString("proxyPortHTTP", ""); String string = GetPreferences().getString("proxyPortHTTP", "");
return string.isEmpty() ? "8888" : string; return string.isEmpty() ? "8888" : string;
} }
public static String proxyPortHTTPS() { public static String proxyPortHTTPS() {
String string = ru.vtosters.lite.utils.Helper.GetPreferences().getString("proxyPortHTTPS", ""); String string = GetPreferences().getString("proxyPortHTTPS", "");
return string.isEmpty() ? "8888" : string; return string.isEmpty() ? "8888" : string;
} }
public static String proxyPortSocks() { public static String proxyPortSocks() {
String string = Helper.GetPreferences().getString("proxyPortSocks", ""); String string = GetPreferences().getString("proxyPortSocks", "");
return string.isEmpty() ? "8888" : string; return string.isEmpty() ? "8888" : string;
} }
@@ -491,7 +492,7 @@ public class Prefs {
} }
public static int getMsgCount() { public static int getMsgCount() {
String customvalue = Helper.GetPreferences().getString("msgcount", ""); String customvalue = GetPreferences().getString("msgcount", "");
return customvalue.isEmpty() ? 30 : Integer.parseInt(customvalue); return customvalue.isEmpty() ? 30 : Integer.parseInt(customvalue);
} }
@@ -534,7 +535,7 @@ public class Prefs {
StandardFilterPut(); StandardFilterPut();
ShortLinkPut(); ShortLinkPut();
IDontWantToReadIt(); IDontWantToReadIt();
String string = Helper.GetPreferences().getString("spamfilters", ""); String string = GetPreferences().getString("spamfilters", "");
if (!string.isEmpty()) { if (!string.isEmpty()) {
mFilters.addAll(Arrays.asList(string.split(", "))); mFilters.addAll(Arrays.asList(string.split(", ")));
} }
@@ -543,7 +544,7 @@ public class Prefs {
public static void ReferalsPut() { public static void ReferalsPut() {
if (BooleanTrue("refsfilter")) { if (BooleanTrue("refsfilter")) {
try { try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("Referals.txt"))); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(GetContext().getAssets().open("Referals.txt")));
while (true) { while (true) {
String readLine = bufferedReader.readLine(); String readLine = bufferedReader.readLine();
if (readLine != null) { if (readLine != null) {
@@ -562,7 +563,7 @@ public class Prefs {
public static void ShortLinkPut() { public static void ShortLinkPut() {
if (BooleanTrue("shortlinkfilter")) { if (BooleanTrue("shortlinkfilter")) {
try { try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("LinkShorter.txt"))); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(GetContext().getAssets().open("LinkShorter.txt")));
while (true) { while (true) {
String readLine = bufferedReader.readLine(); String readLine = bufferedReader.readLine();
if (readLine != null) { if (readLine != null) {
@@ -581,7 +582,7 @@ public class Prefs {
public static void StandardFilterPut() { public static void StandardFilterPut() {
if (BooleanTrue("default_ad_list")) { if (BooleanTrue("default_ad_list")) {
try { try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("StandartFilter.txt"))); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(GetContext().getAssets().open("StandartFilter.txt")));
while (true) { while (true) {
String readLine = bufferedReader.readLine(); String readLine = bufferedReader.readLine();
if (readLine != null) { if (readLine != null) {
@@ -600,7 +601,7 @@ public class Prefs {
public static void IDontWantToReadIt() { public static void IDontWantToReadIt() {
if (BooleanTrue("shitposting")) { if (BooleanTrue("shitposting")) {
try { try {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Helper.GetContext().getAssets().open("IDontWantToReadIt.txt"))); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(GetContext().getAssets().open("IDontWantToReadIt.txt")));
while (true) { while (true) {
String readLine = bufferedReader.readLine(); String readLine = bufferedReader.readLine();
if (readLine != null) { if (readLine != null) {
@@ -617,7 +618,7 @@ public class Prefs {
} }
public static String SSFSDomain() { public static String SSFSDomain() {
String string = Helper.GetPreferences().getString("ssfscustom", ""); String string = GetPreferences().getString("ssfscustom", "");
if (!string.isEmpty()) { if (!string.isEmpty()) {
return string; return string;
} }
@@ -625,7 +626,7 @@ public class Prefs {
} }
public static String VKVersion() { public static String VKVersion() {
String string = Helper.GetPreferences().getString("vkversion", ""); String string = GetPreferences().getString("vkversion", "");
if (!string.isEmpty()) { if (!string.isEmpty()) {
return string; return string;
} }
@@ -673,7 +674,7 @@ public class Prefs {
} }
public static String getLocale() { public static String getLocale() {
String string = Helper.GetPreferences().getString("lang_value", ""); String string = GetPreferences().getString("lang_value", "");
if (string.equals("system")) { if (string.equals("system")) {
return Locale.getDefault().getLanguage(); return Locale.getDefault().getLanguage();
} }
@@ -681,7 +682,7 @@ public class Prefs {
} }
public static boolean proxy() { public static boolean proxy() {
return ru.vtosters.lite.utils.Helper.GetPreferences().getString("proxy", "").equals("apiproxy"); return GetPreferences().getString("proxy", "").equals("apiproxy");
} }
public static boolean authors_rec(String str) { public static boolean authors_rec(String str) {
@@ -773,7 +774,7 @@ public class Prefs {
} }
public static Class getStartFragment() { public static Class getStartFragment() {
String string = ru.vtosters.lite.utils.Helper.GetPreferences().getString("start_values", ""); String string = GetPreferences().getString("start_values", "");
if (string.equals("default")) { if (string.equals("default")) {
return DockBarManager.getInstance().getSelectedTabs().get(0).fragmentClass; return DockBarManager.getInstance().getSelectedTabs().get(0).fragmentClass;
} }
@@ -881,7 +882,7 @@ public class Prefs {
public static void fixGapps() { public static void fixGapps() {
try { try {
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= 26) {
NotificationManager notificationManager = (NotificationManager) ru.vtosters.lite.utils.Helper.GetContext().getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager notificationManager = (NotificationManager) GetContext().getSystemService(Context.NOTIFICATION_SERVICE);
boolean z = false; boolean z = false;
try { try {
if (notificationManager.getNotificationChannel("audio_playback_channel") != null) { if (notificationManager.getNotificationChannel("audio_playback_channel") != null) {
@@ -890,7 +891,7 @@ public class Prefs {
} catch (Exception ignored) { } catch (Exception ignored) {
} }
if (!z) { if (!z) {
notificationManager.createNotificationChannel(new NotificationChannel("audio_playback_channel", ru.vtosters.lite.utils.Helper.getResources().getString(R.string.audio_message_play_error), NotificationManager.IMPORTANCE_LOW)); notificationManager.createNotificationChannel(new NotificationChannel("audio_playback_channel", getResources().getString(R.string.audio_message_play_error), NotificationManager.IMPORTANCE_LOW));
} }
} }
} catch (Exception ignored) { } catch (Exception ignored) {
@@ -1,5 +1,6 @@
package ru.vtosters.lite.utils; package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Prefs.proxyHostHTTP; import static ru.vtosters.lite.utils.Prefs.proxyHostHTTP;
import static ru.vtosters.lite.utils.Prefs.proxyHostHTTPS; import static ru.vtosters.lite.utils.Prefs.proxyHostHTTPS;
import static ru.vtosters.lite.utils.Prefs.proxyHostSocks; import static ru.vtosters.lite.utils.Prefs.proxyHostSocks;
@@ -43,7 +44,7 @@ public class Proxy {
} }
public static String getApiCom() { public static String getApiCom() {
String string = Helper.GetPreferences().getString("proxyapi", ""); String string = GetPreferences().getString("proxyapi", "");
if (!Prefs.proxy() & string.isEmpty()) { if (!Prefs.proxy() & string.isEmpty()) {
return "api.vk.com"; return "api.vk.com";
} }
@@ -51,7 +52,7 @@ public class Proxy {
} }
public static String getAwayPhpCom() { public static String getAwayPhpCom() {
String string = Helper.GetPreferences().getString("proxyapi", ""); String string = GetPreferences().getString("proxyapi", "");
if (!Prefs.proxy() & string.isEmpty()) { if (!Prefs.proxy() & string.isEmpty()) {
return "m.vk.com"; return "m.vk.com";
} }
@@ -59,7 +60,7 @@ public class Proxy {
} }
public static String getOauthCom() { public static String getOauthCom() {
String string = Helper.GetPreferences().getString("proxyoauth", ""); String string = GetPreferences().getString("proxyoauth", "");
if (!Prefs.proxy() & string.isEmpty()) { if (!Prefs.proxy() & string.isEmpty()) {
return "oauth.vk.com"; return "oauth.vk.com";
} }
@@ -67,7 +68,7 @@ public class Proxy {
} }
public static String getStaticCom() { public static String getStaticCom() {
String string = Helper.GetPreferences().getString("proxystatic", ""); String string = GetPreferences().getString("proxystatic", "");
if (!Prefs.proxy() & string.isEmpty()) { if (!Prefs.proxy() & string.isEmpty()) {
return "static.vk.com"; return "static.vk.com";
} }
@@ -76,7 +77,7 @@ public class Proxy {
public static String staticFix(String str) { public static String staticFix(String str) {
String str2; String str2;
String string = Helper.GetPreferences().getString("proxystatic", ""); String string = GetPreferences().getString("proxystatic", "");
if (!Prefs.proxy() & string.isEmpty()) { if (!Prefs.proxy() & string.isEmpty()) {
return str; return str;
} }
@@ -100,7 +101,7 @@ public class Proxy {
} }
public static void setProxy() { public static void setProxy() {
switch (Helper.GetPreferences().getString("proxy", "")) { switch (GetPreferences().getString("proxy", "")) {
case "zaborona": case "zaborona":
Properties properties = System.getProperties(); Properties properties = System.getProperties();
properties.setProperty("socksProxyHost", "socks.zaboronahelp.pp.ua"); properties.setProperty("socksProxyHost", "socks.zaboronahelp.pp.ua");
@@ -0,0 +1,71 @@
package ru.vtosters.lite.utils;
import static android.os.Environment.DIRECTORY_DOWNLOADS;
import static android.os.Environment.getExternalStoragePublicDirectory;
import static android.widget.Toast.LENGTH_LONG;
import static android.widget.Toast.LENGTH_SHORT;
import static android.widget.Toast.makeText;
import static ru.vtosters.lite.utils.Helper.GetContext;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Base64;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
public class SettBackup {
static SharedPreferences prefs = GetContext().getSharedPreferences("com.vtosters.lite_preferences", Context.MODE_PRIVATE);
public static void deletePrefs() {
prefs.edit().clear().commit();
File file = new File(new File(GetContext().getFilesDir().getParent(), "shared_prefs"), "com.vtosters.lite_preferences");
if (file.exists()) file.delete();
}
public static void backupSettings() {
SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault());
String currentDateandTime = date.format(new Date());
var directory = getExternalStoragePublicDirectory(DIRECTORY_DOWNLOADS) + "/VTLBackup_" + currentDateandTime + ".txt";
var file = new File(directory);
try {
var exists = file.createNewFile();
if (!exists) {
file.delete();
file.createNewFile();
}
try {
FileWriter out = new FileWriter(file);
out.write(getAllPrefs());
out.close();
makeText(GetContext(), "Сохранено в файл " + directory, LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
makeText(GetContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
makeText(GetContext(), "Не удалось сохранить файл", LENGTH_SHORT).show();
}
}
public static String getAllPrefs() {
Map<String, ?> allPrefs = prefs.getAll();
return Base64.encodeToString(allPrefs.toString().getBytes(), 1);
}
public static void restoreBackup() {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("text/plain");
GetContext().startActivity(intent);
}
}
@@ -1,5 +1,7 @@
package ru.vtosters.lite.utils; package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Helper.*;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@@ -15,35 +17,39 @@ import com.vtosters.lite.R;
public class Themes { public class Themes {
public static int getAccentColor() { public static int getAccentColor() {
return VKThemeHelper.a((int) R.attr.accent); return VKThemeHelper.a(R.attr.accent);
} }
public static int getTextAttr() { public static int getTextAttr() {
return VKThemeHelper.a((int) R.attr.text_primary); return VKThemeHelper.a(R.attr.text_primary);
} }
public static int getSTextAttr() { public static int getSTextAttr() {
return VKThemeHelper.a((int) R.attr.text_secondary); return VKThemeHelper.a(R.attr.text_secondary);
} }
public static int getTabbarBackground() { public static int getTabbarBackground() {
return VKThemeHelper.a((int) R.attr.tabbar_background); return VKThemeHelper.a(R.attr.tabbar_background);
} }
public static int getHeaderBackground() { public static int getHeaderBackground() {
return VKThemeHelper.a((int) R.attr.header_background); return VKThemeHelper.a(R.attr.header_background);
} }
public static int getAmoledTheme() { public static int getAmoledTheme() {
return Helper.GetContext().getResources().getIdentifier("BaseAmoledStyle", "style", Helper.GetContext().getPackageName()); return GetContext().getResources().getIdentifier("BaseAmoledStyle", "style", GetContext().getPackageName());
}
public static int picFix() {
return GetContext().getResources().getIdentifier("ActionBarThemeFix", "style", GetContext().getPackageName());
} }
public static int getAmoledImTheme() { public static int getAmoledImTheme() {
return Helper.GetContext().getResources().getIdentifier("VkIm.Theme.VkApp.Amoled", "style", Helper.GetContext().getPackageName()); return GetContext().getResources().getIdentifier("VkIm.Theme.VkApp.Amoled", "style", GetContext().getPackageName());
} }
public static VKTheme getDarkTheme() { public static VKTheme getDarkTheme() {
String string = Helper.GetPreferences().getString("darktheme", ""); String string = GetPreferences().getString("darktheme", "");
if (string.isEmpty()) { if (string.isEmpty()) {
return VKTheme.DARK; return VKTheme.DARK;
} }
@@ -54,7 +60,7 @@ public class Themes {
} }
public static ImTheme getImDarkTheme() { public static ImTheme getImDarkTheme() {
String string = Helper.GetPreferences().getString("darktheme", ""); String string = GetPreferences().getString("darktheme", "");
if (string.isEmpty()) { if (string.isEmpty()) {
return ImTheme.VKAPP_DARK; return ImTheme.VKAPP_DARK;
} }
@@ -65,7 +71,7 @@ public class Themes {
} }
public static VKTheme getLightTheme() { public static VKTheme getLightTheme() {
String string = Helper.GetPreferences().getString("lighttheme", ""); String string = GetPreferences().getString("lighttheme", "");
if (string.isEmpty()) { if (string.isEmpty()) {
return VKTheme.DEFAULT_LIGHT; return VKTheme.DEFAULT_LIGHT;
} }
@@ -73,7 +79,7 @@ public class Themes {
} }
public static ImTheme getImLightTheme() { public static ImTheme getImLightTheme() {
String string = Helper.GetPreferences().getString("lighttheme", ""); String string = GetPreferences().getString("lighttheme", "");
if (string.isEmpty()) { if (string.isEmpty()) {
return ImTheme.VKAPP_LIGHT; return ImTheme.VKAPP_LIGHT;
} }
@@ -85,7 +91,7 @@ public class Themes {
} }
public static int getHeaderText() { public static int getHeaderText() {
return VKThemeHelper.a((int) R.attr.header_text); return VKThemeHelper.a(R.attr.header_text);
} }
public static boolean isAndroidMonet() { public static boolean isAndroidMonet() {
@@ -158,10 +164,10 @@ public class Themes {
if (isColorRefAccented(i) && isAndroidMonet()) { if (isColorRefAccented(i) && isAndroidMonet()) {
return getAccentColor(); return getAccentColor();
} }
return Helper.GetContext().getResources().getColor(i); return GetContext().getResources().getColor(i);
} }
public static String hex(int i) { public static String hex(int i) {
return String.format("#%06X", new Object[]{Integer.valueOf(i & 16777215)}); return String.format("#%06X", Integer.valueOf(i & 16777215));
} }
} }
@@ -1,5 +1,8 @@
package ru.vtosters.lite.utils; package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Helper.*;
import static ru.vtosters.lite.utils.Themes.*;
import android.util.Base64; import android.util.Base64;
import android.webkit.WebView; import android.webkit.WebView;
@@ -24,7 +27,7 @@ public class VKUIInjector {
private static String load(String str) { private static String load(String str) {
try { try {
InputStream open = Helper.GetContext().getAssets().open(str); InputStream open = GetContext().getAssets().open(str);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open, StandardCharsets.UTF_8)); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(open, StandardCharsets.UTF_8));
while (true) { while (true) {
@@ -44,13 +47,13 @@ public class VKUIInjector {
public static void load() { public static void load() {
loadedCSS = load("vt_ui_accent.css") loadedCSS = load("vt_ui_accent.css")
.replace("%header_background%", Themes.hex(Themes.getColorFromAttr(R.attr.header_background))) .replace("%header_background%", hex(getColorFromAttr(R.attr.header_background)))
.replace("%background_content%", Themes.hex(Themes.getColorFromAttr(R.attr.background_content))) .replace("%background_content%", hex(getColorFromAttr(R.attr.background_content)))
.replace("%header_text%", Themes.hex(Themes.getColorFromAttr(R.attr.header_text))) .replace("%header_text%", hex(getColorFromAttr(R.attr.header_text)))
.replace("%accent%", Themes.hex(Themes.getColorFromAttr(R.attr.accent))) .replace("%accent%", hex(getColorFromAttr(R.attr.accent)))
.replace("%background_page%", Themes.hex(Themes.getColorFromAttr(R.attr.background_page))) .replace("%background_page%", hex(getColorFromAttr(R.attr.background_page)))
.replace("%background_content%", Themes.hex(Themes.getColorFromAttr(R.attr.background_content))) .replace("%background_content%", hex(getColorFromAttr(R.attr.background_content)))
.replace("%text_primary%", Themes.hex(Themes.getColorFromAttr(R.attr.text_primary))); .replace("%text_primary%", hex(getColorFromAttr(R.attr.text_primary)));
loadedCSSAmoled = load("vt_ui_oled.css"); loadedCSSAmoled = load("vt_ui_oled.css");
isLoaded = true; isLoaded = true;
@@ -61,7 +64,7 @@ public class VKUIInjector {
} }
public static void inject(WebView webView) { public static void inject(WebView webView) {
String string = Helper.GetPreferences().getString("darktheme", ""); String string = GetPreferences().getString("darktheme", "");
if (Prefs.BooleanTrue("VKUI_INJ")) { if (Prefs.BooleanTrue("VKUI_INJ")) {
if (!isLoaded) { if (!isLoaded) {
load(); load();
@@ -4,7 +4,7 @@
<ripple android:color="@color/overlay"> <ripple android:color="@color/overlay">
<item> <item>
<shape> <shape>
<solid android:color="?accent" /> <solid android:color="?header_text" />
<corners android:radius="@dimen/vkui_button_corner_big_radius" /> <corners android:radius="@dimen/vkui_button_corner_big_radius" />
</shape> </shape>
</item> </item>
@@ -12,7 +12,7 @@
</item> </item>
<item> <item>
<shape> <shape>
<solid android:color="?accent" /> <solid android:color="?header_text" />
<corners android:radius="@dimen/vkui_button_corner_big_radius" /> <corners android:radius="@dimen/vkui_button_corner_big_radius" />
</shape> </shape>
</item> </item>
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<bitmap android:src="@drawable/ic_cancel_24" <bitmap android:src="@drawable/ic_cancel_24"
android:tint="?im_app_icon_toolbar" android:tint="?header_text"
xmlns:android="http://schemas.android.com/apk/res/android" /> xmlns:android="http://schemas.android.com/apk/res/android" />
+2 -2
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false"> <item android:state_enabled="false">
<bitmap android:src="@drawable/ic_done_24" android:tint="?im_app_icon_toolbar" android:alpha="0.5" /> <bitmap android:src="@drawable/ic_done_24" android:tint="?header_text" android:alpha="0.5" />
</item> </item>
<item android:state_enabled="true"> <item android:state_enabled="true">
<bitmap android:src="@drawable/ic_done_24" android:tint="?im_app_icon_toolbar" /> <bitmap android:src="@drawable/ic_done_24" android:tint="?header_text" />
</item> </item>
</selector> </selector>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<bitmap android:src="@drawable/ic_phone_outline_28" <bitmap android:src="@drawable/ic_phone_outline_28"
android:tint="?im_app_icon_toolbar" android:tint="?header_text"
android:alpha="0.4" android:alpha="0.4"
xmlns:android="http://schemas.android.com/apk/res/android" /> xmlns:android="http://schemas.android.com/apk/res/android" />
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<bitmap android:src="@drawable/ic_phone_outline_28" <bitmap android:src="@drawable/ic_phone_outline_28"
android:tint="?im_app_icon_toolbar" android:tint="?header_text"
xmlns:android="http://schemas.android.com/apk/res/android" /> xmlns:android="http://schemas.android.com/apk/res/android" />
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<bitmap android:src="@drawable/ic_search_24" <bitmap android:src="@drawable/ic_search_24"
android:tint="?im_app_icon_toolbar" android:tint="?header_text"
xmlns:android="http://schemas.android.com/apk/res/android" /> xmlns:android="http://schemas.android.com/apk/res/android" />
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?header_background" /> <solid android:color="?tabbar_background" />
<corners <corners
android:topLeftRadius="8.0dip" android:topLeftRadius="8.0dip"
android:topRightRadius="8.0dip" /> android:topRightRadius="8.0dip" />
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<bitmap android:src="@drawable/ic_back_24" <bitmap android:src="@drawable/ic_back_24"
android:tint="?im_app_icon_toolbar" android:tint="?header_text"
xmlns:android="http://schemas.android.com/apk/res/android" /> xmlns:android="http://schemas.android.com/apk/res/android" />
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<bitmap android:src="@drawable/ic_cancel_24" <bitmap android:src="@drawable/ic_cancel_24"
android:tint="?im_app_icon_toolbar" android:tint="?header_text"
xmlns:android="http://schemas.android.com/apk/res/android" /> xmlns:android="http://schemas.android.com/apk/res/android" />
+1 -1
View File
@@ -14,7 +14,7 @@
</item> </item>
<item> <item>
<shape> <shape>
<solid android:color="?accent" /> <solid android:color="?header_text" />
<corners android:radius="@dimen/vkui_button_corner_big_radius" /> <corners android:radius="@dimen/vkui_button_corner_big_radius" />
</shape> </shape>
</item> </item>
@@ -35,9 +35,9 @@
android:background="?header_alternate_background" android:background="?header_alternate_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:tabIndicatorColor="?accent" app:tabIndicatorColor="?header_tab_active_indicator"
app:tabSelectedTextColor="?accent" app:tabSelectedTextColor="?header_tab_active_text"
app:tabTextColor="@color/azure_100_muted" /> app:tabTextColor="?header_tab_inactive_text" />
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager
+3 -3
View File
@@ -24,11 +24,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48.0dip" android:layout_height="48.0dip"
app:tabGravity="fill" app:tabGravity="fill"
app:tabIndicatorColor="?accent" app:tabIndicatorColor="?header_tab_active_indicator"
app:tabMaxWidth="0.0dip" app:tabMaxWidth="0.0dip"
app:tabMode="scrollable" app:tabMode="scrollable"
app:tabSelectedTextColor="?text_primary" app:tabSelectedTextColor="?header_tab_active_text"
app:tabTextColor="?text_secondary" app:tabTextColor="?header_tab_inactive_text"
style="@style/CatalogTabLayout" /> style="@style/CatalogTabLayout" />
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
+5 -5
View File
@@ -29,7 +29,7 @@
<TextView <TextView
android:textSize="20.0sp" android:textSize="20.0sp"
android:textColor="?text_primary" android:textColor="?header_text"
android:id="@id/title" android:id="@id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@@ -37,7 +37,7 @@
<TextView <TextView
android:textSize="14.0sp" android:textSize="14.0sp"
android:textColor="?text_secondary" android:textColor="?header_text"
android:ellipsize="end" android:ellipsize="end"
android:id="@id/subtitle" android:id="@id/subtitle"
android:visibility="gone" android:visibility="gone"
@@ -55,11 +55,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="48.0dip" android:layout_height="48.0dip"
app:tabGravity="fill" app:tabGravity="fill"
app:tabIndicatorColor="?accent" app:tabIndicatorColor="?header_tab_active_indicator"
app:tabMaxWidth="0.0dip" app:tabMaxWidth="0.0dip"
app:tabMode="scrollable" app:tabMode="scrollable"
app:tabSelectedTextColor="?text_primary" app:tabSelectedTextColor="?header_tab_active_text"
app:tabTextColor="?text_secondary" /> app:tabTextColor="?header_tab_inactive_text" />
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<ProgressBar <ProgressBar
+5 -5
View File
@@ -5,7 +5,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.TabLayout <android.support.design.widget.TabLayout
android:background="?background_content" android:background="?header_background"
android:id="@id/feed_likes_tablayout" android:id="@id/feed_likes_tablayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/feed_likes_filter_height" android:layout_height="@dimen/feed_likes_filter_height"
@@ -14,12 +14,12 @@
app:layout_constraintHorizontal_bias="0.0" app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:tabBackground="?background_content" app:tabBackground="?header_background"
app:tabGravity="fill" app:tabGravity="fill"
app:tabIndicatorColor="?accent" app:tabIndicatorColor="?header_tab_active_indicator"
app:tabMaxWidth="0.0dip" app:tabMaxWidth="0.0dip"
app:tabMode="scrollable" app:tabMode="scrollable"
app:tabSelectedTextColor="?accent" app:tabSelectedTextColor="?header_tab_active_text"
app:tabTextAppearance="@style/FeedLikesTabStyle" app:tabTextAppearance="@style/FeedLikesTabStyle"
app:tabTextColor="?text_primary" /> app:tabTextColor="?header_tab_inactive_text" />
</merge> </merge>
+4 -4
View File
@@ -26,7 +26,7 @@
<FrameLayout <FrameLayout
android:id="@id/fl_tabs_container" android:id="@id/fl_tabs_container"
android:background="#ffffffff" android:background="?tabbar_background"
android:visibility="invisible" android:visibility="invisible"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/picker_tab_panel_height"> android:layout_height="@dimen/picker_tab_panel_height">
@@ -42,7 +42,7 @@
<View <View
android:id="@id/tabs_overlay" android:id="@id/tabs_overlay"
android:background="#ffffffff" android:background="?tabbar_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" /> android:layout_height="fill_parent" />
@@ -73,11 +73,11 @@
<TextView <TextView
android:textSize="16.0sp" android:textSize="16.0sp"
android:textColor="?accent" android:textColor="@color/picker_blue"
android:gravity="center" android:gravity="center"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:id="@id/tv_bottom_panel_cancel" android:id="@id/tv_bottom_panel_cancel"
android:background="#ffffffff" android:background="?tabbar_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/picker_viewer_bottom_padding" android:layout_height="@dimen/picker_viewer_bottom_padding"
android:text="@string/picker_cancel" android:text="@string/picker_cancel"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.vk.attachpicker.widget.TopShadowLinearLayout android:orientation="vertical" <com.vk.attachpicker.widget.TopShadowLinearLayout android:orientation="vertical"
android:background="#ffffffff" android:background="?tabbar_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
@@ -43,7 +43,7 @@
android:gravity="center" android:gravity="center"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:id="@id/tv_bottom_panel_cancel" android:id="@id/tv_bottom_panel_cancel"
android:background="@drawable/picker_btn_white" android:background="?tabbar_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/picker_viewer_bottom_padding" android:layout_height="@dimen/picker_viewer_bottom_padding"
android:text="@string/picker_cancel" android:text="@string/picker_cancel"
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal" <LinearLayout android:orientation="horizontal"
android:id="@id/picker_attach_gallery_camera_layout" android:id="@id/picker_attach_gallery_camera_layout"
android:background="#ffffffff" android:background="?tabbar_background"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="56.0dip" android:layout_height="56.0dip"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
+1 -1
View File
@@ -138,7 +138,7 @@
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:src="@drawable/ic_done_24" android:src="@drawable/ic_done_24"
android:scaleType="centerInside" android:scaleType="centerInside"
android:tint="?accent" /> android:tint="@color/accent_blue" />
<View <View
android:background="@color/picker_grey_divider" android:background="@color/picker_grey_divider"
@@ -6,29 +6,29 @@
android:id="@id/action_reply" android:id="@id/action_reply"
android:title="@string/vkim_msg_action_reply" android:title="@string/vkim_msg_action_reply"
android:showAsAction="always" android:showAsAction="always"
app:iconTint="?im_app_icon_toolbar" /> app:iconTint="?header_text" />
<item <item
android:icon="@drawable/vkim_ic_msg_delete" android:icon="@drawable/vkim_ic_msg_delete"
android:id="@id/action_delete" android:id="@id/action_delete"
android:title="@string/vkim_msg_action_delete" android:title="@string/vkim_msg_action_delete"
android:showAsAction="always" android:showAsAction="always"
app:iconTint="?im_app_icon_toolbar" /> app:iconTint="?header_text" />
<item <item
android:icon="@drawable/vkim_ic_msg_forward" android:icon="@drawable/vkim_ic_msg_forward"
android:id="@id/action_forward" android:id="@id/action_forward"
android:title="@string/vkim_msg_action_forward" android:title="@string/vkim_msg_action_forward"
android:showAsAction="always" android:showAsAction="always"
app:iconTint="?im_app_icon_toolbar" /> app:iconTint="?header_text" />
<item <item
android:icon="@drawable/vkim_ic_msg_copy" android:icon="@drawable/vkim_ic_msg_copy"
android:id="@id/action_copy" android:id="@id/action_copy"
android:title="@string/vkim_msg_action_copy" android:title="@string/vkim_msg_action_copy"
android:showAsAction="always" android:showAsAction="always"
app:iconTint="?im_app_icon_toolbar" /> app:iconTint="?header_text" />
<item <item
android:icon="@drawable/vkim_ic_msg_spam_24dp" android:icon="@drawable/vkim_ic_msg_spam_24dp"
android:id="@id/action_spam" android:id="@id/action_spam"
android:title="@string/vkim_msg_action_spam" android:title="@string/vkim_msg_action_spam"
android:showAsAction="always" android:showAsAction="always"
app:iconTint="?im_app_icon_toolbar" /> app:iconTint="?header_text" />
</menu> </menu>
+1 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<bool name="picker_transparent_status_bar">true</bool> <bool name="picker_transparent_status_bar">false</bool>
</resources> </resources>
+14 -2
View File
@@ -36,6 +36,18 @@
<item name="toolbarIconsColor">?header_text</item> <item name="toolbarIconsColor">?header_text</item>
</style> </style>
<style name="ActionBarThemeFix" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">@color/white</item>
<item name="android:textColorSecondary">?header_tint</item>
<item name="android:selectableItemBackground">@drawable/highlight_toolbar</item>
<item name="android:actionBarItemBackground">@drawable/highlight_icon_white_unbounded</item>
<item name="colorAccent">@color/white</item>
<item name="colorPrimary">@color/toolbar_blue_background</item>
<item name="layout_scrollFlags">enterAlways|scroll|snap</item>
<item name="titleTextAppearance">@style/ToolbarTitle</item>
<item name="toolbarIconsColor">?header_text</item>
</style>
<style name="ActionBarTheme.ItemsFull" parent="@style/ActionBarTheme" /> <style name="ActionBarTheme.ItemsFull" parent="@style/ActionBarTheme" />
<style name="ActionBarTheme.Milk" parent="@style/ThemeOverlay.AppCompat.ActionBar"> <style name="ActionBarTheme.Milk" parent="@style/ThemeOverlay.AppCompat.ActionBar">
@@ -3645,7 +3657,7 @@
<item name="android:layout_width">fill_parent</item> <item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">48.0dip</item> <item name="android:layout_height">48.0dip</item>
<item name="tabGravity">fill</item> <item name="tabGravity">fill</item>
<item name="tabIndicatorColor">?header_tab_active_text</item> <item name="tabIndicatorColor">?header_tab_active_indicator</item>
<item name="tabIndicatorHeight">2.5dip</item> <item name="tabIndicatorHeight">2.5dip</item>
<item name="tabMaxWidth">0.0dip</item> <item name="tabMaxWidth">0.0dip</item>
<item name="tabMode">fixed</item> <item name="tabMode">fixed</item>
@@ -4045,7 +4057,7 @@
<style name="ToolbarTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"> <style name="ToolbarTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textSize">20.0dip</item> <item name="android:textSize">20.0dip</item>
<item name="android:textColor">?android:textColorPrimary</item> <item name="android:textColor">?header_text</item>
</style> </style>
<style name="TooltipFullScreenDialog" parent="@style/Theme.AppCompat.Light.Dialog"> <style name="TooltipFullScreenDialog" parent="@style/Theme.AppCompat.Light.Dialog">
+1
View File
@@ -4,6 +4,7 @@
<com.vtosters.lite.ui.MaterialSwitchPreference <com.vtosters.lite.ui.MaterialSwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="calls" android:key="calls"
android:summary="Иконка звонков в сообщениях"
android:title="@string/vtlcalls" /> android:title="@string/vtlcalls" />
<com.vtosters.lite.ui.MaterialSwitchPreference <com.vtosters.lite.ui.MaterialSwitchPreference
android:defaultValue="true" android:defaultValue="true"
+19
View File
@@ -12,6 +12,13 @@
<Preference <Preference
android:key="tokencopy" android:key="tokencopy"
android:title="@string/copytokenbtn" /> android:title="@string/copytokenbtn" />
<Preference
android:key="stickfix"
android:title="Очистить кэш стикеров"
android:summary="Исправление загрузки стикеров при их полном отсутствии" />
<Preference
android:key="deleteprefs"
android:title="Сбросить настройки" />
<Preference <Preference
android:key="applicationrestart" android:key="applicationrestart"
android:title="@string/applicationrestart" /> android:title="@string/applicationrestart" />
@@ -20,6 +27,18 @@
android:title="@string/killappbtn" /> android:title="@string/killappbtn" />
<com.vtosters.lite.ui.MaterialSectionDividerPreference /> <com.vtosters.lite.ui.MaterialSectionDividerPreference />
</PreferenceCategory> </PreferenceCategory>
<!-- <PreferenceCategory android:title="Backup system">
<Preference
android:key="deleteprefs"
android:title="Reset prefs" />
<Preference
android:key="saveprefs"
android:title="Save prefs to file" />
<Preference
android:key="restoreprefs"
android:title="Restore prefs" />
<com.vtosters.lite.ui.MaterialSectionDividerPreference />
</PreferenceCategory> -->
<PreferenceCategory android:title="@string/vtverify"> <PreferenceCategory android:title="@string/vtverify">
<Preference <Preference
android:enabled="false" android:enabled="false"
@@ -1183,20 +1183,20 @@
invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
const/4 v1, 0x3 # const/4 v1, 0x3
const v2, 0x7f1105c9 # const v2, 0x7f1105c9
.line 253 # .line 253
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer; # invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v2 # move-result-object v2
invoke-static {v1, v2}, Lcom/vtosters/lite/ui/holder/RecyclerSectionAdapter$a;->e(ILjava/lang/Object;)Lcom/vtosters/lite/ui/holder/RecyclerSectionAdapter$a; # invoke-static {v1, v2}, Lcom/vtosters/lite/ui/holder/RecyclerSectionAdapter$a;->e(ILjava/lang/Object;)Lcom/vtosters/lite/ui/holder/RecyclerSectionAdapter$a;
move-result-object v1 # move-result-object v1
invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z # invoke-virtual {v0, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
return-object v0 return-object v0
.end method .end method
@@ -819,7 +819,9 @@
iget-object v5, p0, Lcom/vtosters/lite/PhotoViewer;->b:Landroid/app/Activity; iget-object v5, p0, Lcom/vtosters/lite/PhotoViewer;->b:Landroid/app/Activity;
const v6, 0x7f120004 invoke-static {}, Lru/vtosters/lite/utils/Themes;->picFix()I
move-result v6
invoke-direct {v4, v5, v6}, Landroid/view/ContextThemeWrapper;-><init>(Landroid/content/Context;I)V invoke-direct {v4, v5, v6}, Landroid/view/ContextThemeWrapper;-><init>(Landroid/content/Context;I)V