From 4d719e4308a9697d37d966daa456dfc793540c77 Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Mon, 11 Jul 2022 21:14:02 +0300 Subject: [PATCH] codesyle cringe --- .../itaysonlab/libvkx/ILibVkxService.java | 18 +-- .../libvkx/client/LibVKXClient.java | 8 +- .../libvkx/client/LibVKXClientImpl.java | 22 +-- .../com/aefyr/tsg/g2/NotificationsHelper.java | 12 +- .../com/aefyr/tsg/g2/PackDeletionTask.java | 2 +- .../aefyr/tsg/g2/TelegramStickersPack.java | 12 +- .../aefyr/tsg/g2/TelegramStickersService.java | 64 ++++----- .../tsg/g2/sql/TelegramStickersDbHelper.java | 10 +- .../TelegramStickersGrabber.java | 50 +++---- .../g2/stickersgrabber/util/GoalCounter.java | 4 +- .../com/arthenica/ffmpegkit/NativeLoader.java | 80 +++++------ .../smartexception/AbstractExceptions.java | 74 +++++----- .../StackTraceElementSerializer.java | 2 +- .../smartexception/java/Exceptions.java | 68 ++++----- app/src/main/java/com/vtosters/lite/R.java | 42 +++--- .../ru/vtosters/lite/audio/gcm/GCMFix.java | 22 +-- .../lite/deviceinfo/DeviceInfoCollector.java | 42 +++--- .../ru/vtosters/lite/dnr/DNRInjector.java | 12 +- .../java/ru/vtosters/lite/dnr/DNRModule.java | 4 +- .../java/ru/vtosters/lite/dnr/DNRPrefs.java | 8 +- .../lite/dnr/helpers/DoNotReadDBHelper.java | 10 +- .../lite/dnr/helpers/DoNotTypeDBHelper.java | 10 +- .../lite/downloaders/AudioDownloader.java | 25 ++-- .../lite/downloaders/OTADownloader.java | 16 +-- .../lite/downloaders/StoryDownloader.java | 4 +- .../lite/downloaders/VideoDownloader.java | 28 ++-- .../lite/encryption/EncryptProvider.java | 20 +-- .../lite/encryption/base/IMProcessor.java | 2 +- .../processors/BeeCryptProcessor.java | 6 +- .../processors/DefaultCoffeeProcessor.java | 6 +- .../processors/MP3InvisibleProcessor.java | 6 +- .../processors/VTostersAESProcessor.java | 4 +- .../ru/vtosters/lite/f0x1d/Crashreporter.java | 8 +- .../vtosters/lite/f0x1d/LogWriterService.java | 2 +- .../vtosters/lite/f0x1d/VTVerifications.java | 20 +-- .../java/ru/vtosters/lite/foaf/FoafBase.java | 6 +- .../java/ru/vtosters/lite/music/FFMpeg.java | 13 +- .../ru/vtosters/lite/music/M3UDownloader.java | 19 ++- .../ru/vtosters/lite/music/VKM3UParser.java | 12 +- .../java/ru/vtosters/lite/net/NetCall.java | 12 +- .../java/ru/vtosters/lite/net/NetRequest.java | 2 +- .../java/ru/vtosters/lite/net/Request.java | 6 +- .../java/ru/vtosters/lite/tgs/TGRoot.java | 20 +-- .../ru/vtosters/lite/ui/PreferencesUtil.java | 17 +-- .../ui/activities/APKInstallActivity.java | 10 +- .../lite/ui/dialogs/DisableBattery.java | 4 +- .../vtosters/lite/ui/dialogs/InstallGMS.java | 4 +- .../ru/vtosters/lite/ui/dialogs/Start.java | 8 +- .../lite/ui/dialogs/VKIDProtection.java | 2 +- .../lite/ui/fragments/MediaFragment.java | 4 +- .../lite/ui/fragments/OtherFragment.java | 34 ++--- .../lite/ui/fragments/VTSettings.java | 45 +++--- .../tgstickers/StickerPackAdapter.java | 8 +- .../tgstickers/StickersFragment.java | 35 +++-- .../StickersPreferencesFragment.java | 4 +- .../ru/vtosters/lite/ui/vkui/MenuBuilder.java | 1 - .../vtosters/lite/ui/vkui/VBListBuilder.java | 2 +- .../ui/wallpapers/WallpaperMenuFragment.java | 12 +- .../ui/wallpapers/WallpaperPreferences.java | 8 +- .../lite/ui/wallpapers/WallpapersHooks.java | 18 +-- .../java/ru/vtosters/lite/utils/About.java | 4 +- .../ru/vtosters/lite/utils/CacheUtils.java | 24 ++-- .../lite/utils/DeletedMessagesHandler.java | 28 ++-- .../lite/utils/ExternalLinkHandler.java | 36 ++--- .../vtosters/lite/utils/FragAnimationKit.java | 2 +- .../java/ru/vtosters/lite/utils/Globals.java | 22 +-- .../ru/vtosters/lite/utils/IconManager.java | 9 +- .../ru/vtosters/lite/utils/JsonInjectors.java | 26 ++-- .../ru/vtosters/lite/utils/LocaleUtils.java | 4 +- .../java/ru/vtosters/lite/utils/Newsfeed.java | 50 +++---- .../ru/vtosters/lite/utils/OTAHelper.java | 2 +- .../vtosters/lite/utils/OnlineFormatter.java | 8 +- .../ru/vtosters/lite/utils/OpusLoader.java | 10 +- .../ru/vtosters/lite/utils/PollUtils.java | 4 +- .../ru/vtosters/lite/utils/Preferences.java | 8 +- .../ru/vtosters/lite/utils/ProfileHide.java | 136 +++++++++--------- .../java/ru/vtosters/lite/utils/Proxy.java | 20 +-- .../ru/vtosters/lite/utils/ProxyHook.java | 37 ++--- .../vtosters/lite/utils/ReflectionUtils.java | 26 ++-- .../ru/vtosters/lite/utils/RenameTool.java | 35 ++--- .../java/ru/vtosters/lite/utils/SSFS.java | 2 +- .../ru/vtosters/lite/utils/ServerDialog.java | 10 +- .../ru/vtosters/lite/utils/SettBackup.java | 30 ++-- .../vtosters/lite/utils/SignatureChecker.java | 4 +- .../ru/vtosters/lite/utils/StreamUtils.java | 22 +-- .../java/ru/vtosters/lite/utils/Themes.java | 60 ++++---- .../ru/vtosters/lite/utils/VKUIInjector.java | 10 +- 87 files changed, 825 insertions(+), 833 deletions(-) diff --git a/app/src/main/java/bruhcollective/itaysonlab/libvkx/ILibVkxService.java b/app/src/main/java/bruhcollective/itaysonlab/libvkx/ILibVkxService.java index 15ddf5329..4950d8704 100644 --- a/app/src/main/java/bruhcollective/itaysonlab/libvkx/ILibVkxService.java +++ b/app/src/main/java/bruhcollective/itaysonlab/libvkx/ILibVkxService.java @@ -90,18 +90,18 @@ public interface ILibVkxService extends android.os.IInterface{ * generating a proxy if needed. */ public static ILibVkxService asInterface(android.os.IBinder obj){ - if((obj == null)){ + if ((obj == null)) { return null; } android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR); - if(((iin != null) && (iin instanceof ILibVkxService))){ + if (((iin != null) && (iin instanceof ILibVkxService))) { return ((ILibVkxService) iin); } return new Proxy(obj); } public static boolean setDefaultImpl(ILibVkxService impl){ - if(Proxy.sDefaultImpl == null && impl != null){ + if (Proxy.sDefaultImpl == null && impl != null) { Proxy.sDefaultImpl = impl; return true; } @@ -219,7 +219,7 @@ public interface ILibVkxService extends android.os.IInterface{ _data.writeInt(index); _data.writeString(playbackContext); boolean _status = mRemote.transact(Stub.TRANSACTION_play, _data, _reply, 0); - if(!_status && getDefaultImpl() != null){ + if (!_status && getDefaultImpl() != null) { getDefaultImpl().play(audio_ids, index, playbackContext); return; } @@ -239,7 +239,7 @@ public interface ILibVkxService extends android.os.IInterface{ try { _data.writeInterfaceToken(DESCRIPTOR); boolean _status = mRemote.transact(Stub.TRANSACTION_getUserId, _data, _reply, 0); - if(!_status && getDefaultImpl() != null){ + if (!_status && getDefaultImpl() != null) { return getDefaultImpl().getUserId(); } _reply.readException(); @@ -261,7 +261,7 @@ public interface ILibVkxService extends android.os.IInterface{ _data.writeInt(owner_id); _data.writeString(access_key); boolean _status = mRemote.transact(Stub.TRANSACTION_addTrackToCache, _data, _reply, 0); - if(!_status && getDefaultImpl() != null){ + if (!_status && getDefaultImpl() != null) { getDefaultImpl().addTrackToCache(track_id, owner_id, access_key); return; } @@ -281,7 +281,7 @@ public interface ILibVkxService extends android.os.IInterface{ _data.writeInt(track_id); _data.writeInt(owner_id); boolean _status = mRemote.transact(Stub.TRANSACTION_deleteTrackFromCache, _data, _reply, 0); - if(!_status && getDefaultImpl() != null){ + if (!_status && getDefaultImpl() != null) { getDefaultImpl().deleteTrackFromCache(track_id, owner_id); return; } @@ -304,7 +304,7 @@ public interface ILibVkxService extends android.os.IInterface{ _data.writeInt(track_id); _data.writeInt(owner_id); boolean _status = mRemote.transact(Stub.TRANSACTION_isTrackCached, _data, _reply, 0); - if(!_status && getDefaultImpl() != null){ + if (!_status && getDefaultImpl() != null) { return getDefaultImpl().isTrackCached(track_id, owner_id); } _reply.readException(); @@ -324,7 +324,7 @@ public interface ILibVkxService extends android.os.IInterface{ try { _data.writeInterfaceToken(DESCRIPTOR); boolean _status = mRemote.transact(Stub.TRANSACTION_getCache, _data, _reply, 0); - if(!_status && getDefaultImpl() != null){ + if (!_status && getDefaultImpl() != null) { return getDefaultImpl().getCache(); } _reply.readException(); diff --git a/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClient.java b/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClient.java index 0272dd609..8d46a36f5 100644 --- a/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClient.java +++ b/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClient.java @@ -20,7 +20,7 @@ public class LibVKXClient{ private static LibVKXClientImpl impl; public static LibVKXClientImpl getInstance(Context context){ - if(impl == null){ + if (impl == null) { impl = new LibVKXClientImpl(context); } return impl; @@ -40,7 +40,7 @@ public class LibVKXClient{ } public static boolean play(MusicTrack musicTrack, List list, MusicPlaybackLaunchContext playerRefer){ - if(!isIntegrationEnabled()){ + if (!isIntegrationEnabled()) { return false; } @@ -56,7 +56,7 @@ public class LibVKXClient{ while(it.hasNext()) { arrayList.add(asId((MusicTrack) it.next())); } - if(indexOf == -1){ + if (indexOf == -1) { indexOf = 0; } try { @@ -68,7 +68,7 @@ public class LibVKXClient{ private static String asId(MusicTrack musicTrack){ String str = musicTrack.d + "_" + musicTrack.e; - if(musicTrack.O == null || musicTrack.O.equals("")){ + if (musicTrack.O == null || musicTrack.O.equals("")) { return str; } return str + "_" + musicTrack.O; diff --git a/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClientImpl.java b/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClientImpl.java index c8ed1be45..09cf56ba8 100644 --- a/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClientImpl.java +++ b/app/src/main/java/bruhcollective/itaysonlab/libvkx/client/LibVKXClientImpl.java @@ -32,7 +32,7 @@ public class LibVKXClientImpl{ } public void finish(){ - if(cn != null){ + if (cn != null) { ctx.unbindService(cn); } @@ -40,7 +40,7 @@ public class LibVKXClientImpl{ } public T runOnServiceSync(LibVKXActionGeneric action){ - if(serviceInstance != null){ + if (serviceInstance != null) { return action.run(serviceInstance); } else { return action.defaultValue(); @@ -50,9 +50,9 @@ public class LibVKXClientImpl{ // true - action is ran // false - action is failed, should fallback to default UI/UX public boolean runOnService(LibVKXAction action){ - if(serviceInstance != null){ + if (serviceInstance != null) { try { - if(serviceInstance.getUserId() != getUserId()) return false; + if (serviceInstance.getUserId() != getUserId()) return false; action.run(serviceInstance); return true; } catch (RemoteException e) { @@ -65,18 +65,18 @@ public class LibVKXClientImpl{ } private boolean requestServiceInit(LibVKXAction runAfterBind){ - if(!verifyBindActuality()) return false; + if (!verifyBindActuality()) return false; cn = new ServiceConnection(){ @Override public void onServiceConnected(ComponentName name, IBinder service){ serviceInstance = ILibVkxService.Stub.asInterface(service); - if(serviceInstance == null){ + if (serviceInstance == null) { // op mycopok... isBindFailed = true; } else { try { - if(serviceInstance.getUserId() != getUserId()) return; + if (serviceInstance.getUserId() != getUserId()) return; runAfterBind.run(serviceInstance); } catch (RemoteException e) { e.printStackTrace(); @@ -95,7 +95,7 @@ public class LibVKXClientImpl{ } private boolean verifyBindActuality(){ - if(!checkIfAppExists()) return false; // no need + if (!checkIfAppExists()) return false; // no need return !isBindFailed; } @@ -105,10 +105,10 @@ public class LibVKXClientImpl{ private boolean checkIfAppExists(){ List resolveInfos = pm.queryIntentServices(getIntent(), 0); - if(resolveInfos == null || resolveInfos.isEmpty()) return false; + if (resolveInfos == null || resolveInfos.isEmpty()) return false; - for(ResolveInfo rs : resolveInfos) { - if(rs.serviceInfo.packageName.equals(ClientConstants.PACKAGE)) return true; + for (ResolveInfo rs : resolveInfos) { + if (rs.serviceInfo.packageName.equals(ClientConstants.PACKAGE)) return true; } return false; diff --git a/app/src/main/java/com/aefyr/tsg/g2/NotificationsHelper.java b/app/src/main/java/com/aefyr/tsg/g2/NotificationsHelper.java index 2fd3d83b3..d1ad5a612 100755 --- a/app/src/main/java/com/aefyr/tsg/g2/NotificationsHelper.java +++ b/app/src/main/java/com/aefyr/tsg/g2/NotificationsHelper.java @@ -38,7 +38,7 @@ public class NotificationsHelper{ downloadingPacksNotificationsIds = new HashMap<>(); - if(oreo()){ + if (oreo()) { NotificationChannel notificationChan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "Сервис стикеров Telegram в VTosters", NotificationManager.IMPORTANCE_HIGH); ((NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(notificationChan); } @@ -57,7 +57,7 @@ public class NotificationsHelper{ } public void packDownloadUpdated(TelegramStickersPack pack, int downloadProgress){ - if(System.currentTimeMillis() - lastNotificationTime.get() < MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS) + if (System.currentTimeMillis() - lastNotificationTime.get() < MIN_TIME_BETWEEN_UPDATE_NOTIFICATIONS) return; lastNotificationTime.set(System.currentTimeMillis()); @@ -69,7 +69,7 @@ public class NotificationsHelper{ builder.setOngoing(true); builder.setOnlyAlertOnce(true); - if(downloadingPacksNotificationsIds.containsKey(pack)) + if (downloadingPacksNotificationsIds.containsKey(pack)) manager.notify(downloadingPacksNotificationsIds.get(pack), builder.build()); } @@ -80,12 +80,12 @@ public class NotificationsHelper{ builder.setContentTitle("Сервис стикеров Telegram в VTosters"); String text; - if(success) + if (success) text = wasUpdate ? pack.title + " успешно обновлен" : pack.title + " успешно загружен"; else text = wasUpdate ? pack.title + ": ошибка при обновлении" : pack.title + ": ошибка при загрузке"; - if(e instanceof TelegramStickersGrabber.TSGException){ + if (e instanceof TelegramStickersGrabber.TSGException) { text = pack.title + ": " + e.getMessage(); } @@ -100,7 +100,7 @@ public class NotificationsHelper{ private Notification.Builder commonBuilder(){ var builder = new Notification.Builder(c).setPriority(Notification.PRIORITY_MAX).setSmallIcon(getIdentifier("ic_download_24", "drawable")); - if(oreo()){ + if (oreo()) { builder.setChannelId(NOTIFICATION_CHANNEL_ID); } diff --git a/app/src/main/java/com/aefyr/tsg/g2/PackDeletionTask.java b/app/src/main/java/com/aefyr/tsg/g2/PackDeletionTask.java index 32feb72fb..4c7e3467d 100755 --- a/app/src/main/java/com/aefyr/tsg/g2/PackDeletionTask.java +++ b/app/src/main/java/com/aefyr/tsg/g2/PackDeletionTask.java @@ -21,7 +21,7 @@ class PackDeletionTask extends AsyncTask{ protected Boolean doInBackground(Void... voids){ boolean success = true; - for(File f : pack.folder.listFiles()) { + for (File f : pack.folder.listFiles()) { success = success && f.delete(); } diff --git a/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersPack.java b/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersPack.java index 76e980c1d..cc32aa983 100755 --- a/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersPack.java +++ b/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersPack.java @@ -42,9 +42,9 @@ public class TelegramStickersPack extends CustomStickersPack{ public JSONObject encodeEmojis() throws JSONException{ JSONObject obj = new JSONObject(); - for(HashMap.Entry> en : emojis.entrySet()) { + for (HashMap.Entry> en : emojis.entrySet()) { JSONArray arr = new JSONArray(); - for(int i : en.getValue()) arr.put(i); + for (int i : en.getValue()) arr.put(i); obj.put(en.getKey(), arr); } @@ -57,16 +57,16 @@ public class TelegramStickersPack extends CustomStickersPack{ String key = it.next(); //emojis.put(key, obj.getInt(key)); List list = emojis.get(key); - if(list == null) list = new ArrayList<>(); + if (list == null) list = new ArrayList<>(); JSONArray arr = obj.getJSONArray(key); - for(int i = 0; i < arr.length(); i++) + for (int i = 0; i < arr.length(); i++) list.add(arr.getInt(i)); emojis.put(key, list); } } public Bitmap getIcon(int targetMaxSideSize){ - if(state != DOWNLOADED && state != UPDATING) + if (state != DOWNLOADED && state != UPDATING) throw new IllegalStateException("Unable to get an icon of a pack that hasn't been downloaded yet"); File icon = new File(folder, "001.png"); @@ -85,7 +85,7 @@ public class TelegramStickersPack extends CustomStickersPack{ int maxSideSize = op.outWidth > op.outHeight ? op.outWidth : op.outHeight; - if(maxSideSize > targetMaxSideSize){ + if (maxSideSize > targetMaxSideSize) { op.inScaled = true; op.inDensity = maxSideSize; op.inTargetDensity = targetMaxSideSize; diff --git a/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersService.java b/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersService.java index 8e6d6c814..4fc52fc8d 100755 --- a/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersService.java +++ b/app/src/main/java/com/aefyr/tsg/g2/TelegramStickersService.java @@ -79,12 +79,12 @@ public class TelegramStickersService{ runOnUiThread(() -> { packs.add(pack); - if(pack.enabled) + if (pack.enabled) activePacks.add(pack); else inactivePacks.add(pack); - if(notify) notifyPackAdded(pack, packs.size() - 1); + if (notify) notifyPackAdded(pack, packs.size() - 1); }); } @@ -92,7 +92,7 @@ public class TelegramStickersService{ public void onAllPacksLoaded(ArrayList packs){ ready = true; - if(notify){ + if (notify) { notifyActivePacksListChanged(); notifyInactivePacksListChanged(); } @@ -114,60 +114,60 @@ public class TelegramStickersService{ private void notifyPackAdded(TelegramStickersPack pack, int atIndex){ getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); - if(listeners.isEmpty()) + if (listeners.isEmpty()) return; - for(StickersEventsListener listener : listeners) { + for (StickersEventsListener listener : listeners) { listener.onPackAdded(pack, atIndex); } } private void notifyPackChanged(TelegramStickersPack pack, int atIndex){ getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); - if(listeners.isEmpty()) + if (listeners.isEmpty()) return; - for(StickersEventsListener listener : listeners) { + for (StickersEventsListener listener : listeners) { listener.onPackChanged(pack, atIndex); } } private void notifyPackRemoved(TelegramStickersPack pack, int atIndex){ getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); - if(listeners.isEmpty()) + if (listeners.isEmpty()) return; - for(StickersEventsListener listener : listeners) { + for (StickersEventsListener listener : listeners) { listener.onPackRemoved(pack, atIndex); } } private void notifyPackDownloadError(TelegramStickersPack pack, Exception error){ getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); - if(listeners.isEmpty()) + if (listeners.isEmpty()) return; - for(StickersEventsListener listener : listeners) { + for (StickersEventsListener listener : listeners) { listener.onPackDownloadError(pack, error); } } private void notifyActivePacksListChanged(){ getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); - if(listeners.isEmpty()) + if (listeners.isEmpty()) return; - for(StickersEventsListener listener : listeners) { + for (StickersEventsListener listener : listeners) { listener.onActivePacksListChanged(); } } private void notifyInactivePacksListChanged(){ getContext().sendBroadcast(new Intent(StickersFragment.ACTION_RELOAD)); - if(listeners.isEmpty()) + if (listeners.isEmpty()) return; - for(StickersEventsListener listener : listeners) { + for (StickersEventsListener listener : listeners) { listener.onInactivePacksListChanged(); } } @@ -193,12 +193,12 @@ public class TelegramStickersService{ } public boolean requestPackDownload(final String id, File packFolder){ - if(currentlyDownloading.contains(id)){ + if (currentlyDownloading.contains(id)) { Log.e(TAG, String.format("Got request to download pack %s which is already downloading", id)); return false; } - if(!ready){ + if (!ready) { final File folder = packFolder; queuedTasks.add(() -> requestPackDownload(id, folder)); return true; @@ -208,7 +208,7 @@ public class TelegramStickersService{ boolean update = false; int index = packs.indexOf(pack); - if(index != -1){ + if (index != -1) { pack = packs.get(index); pack.state = TelegramStickersPack.UPDATING; update = true; @@ -238,8 +238,8 @@ public class TelegramStickersService{ currentlyDownloading.remove(newPack.id.toLowerCase()); syncPack(newPack); - if(isUpdate){ - if(newPack.enabled) + if (isUpdate) { + if (newPack.enabled) notifyActivePacksListChanged(); } else { activePacks.add(newPack); @@ -255,7 +255,7 @@ public class TelegramStickersService{ Log.e(TAG, "Error while downloading pack " + newPack.id); e.printStackTrace(); - if(!isUpdate){ + if (!isUpdate) { int index = packs.indexOf(newPack); packs.remove(index); notifyPackRemoved(newPack, index); @@ -287,7 +287,7 @@ public class TelegramStickersService{ stickerIndex--; List list = newPack.emojis.get(boundEmoji); - if(list == null) list = new ArrayList<>(); + if (list == null) list = new ArrayList<>(); list.add(stickerIndex); newPack.emojis.put(boundEmoji, list); @@ -299,33 +299,33 @@ public class TelegramStickersService{ } public void setPackEnabled(final TelegramStickersPack pack, final boolean enabled, final boolean notify){ - if(!ready){ + if (!ready) { queuedTasks.add(() -> setPackEnabled(pack, enabled, notify)); return; } - if(pack.enabled == enabled) + if (pack.enabled == enabled) return; pack.enabled = enabled; syncPack(pack); - if(notify) notifyPackChanged(pack, packs.indexOf(pack)); + if (notify) notifyPackChanged(pack, packs.indexOf(pack)); - if(pack.enabled){ + if (pack.enabled) { inactivePacks.remove(pack); activePacks.add(pack); } else { activePacks.remove(pack); inactivePacks.add(pack); } - if(notify){ + if (notify) { notifyActivePacksListChanged(); notifyInactivePacksListChanged(); } } public void deletePack(final TelegramStickersPack pack){ - if(!ready){ + if (!ready) { queuedTasks.add(() -> deletePack(pack)); return; } @@ -338,7 +338,7 @@ public class TelegramStickersService{ packs.remove(index); notifyPackRemoved(pack, index); - if(pack.enabled){ + if (pack.enabled) { activePacks.remove(pack); notifyActivePacksListChanged(); } else { @@ -346,7 +346,7 @@ public class TelegramStickersService{ notifyInactivePacksListChanged(); } - if(d) + if (d) new PackDeletionTask(pack).executeOnExecutor(executor); } @@ -355,7 +355,7 @@ public class TelegramStickersService{ } private void syncPack(final TelegramStickersPack pack){ - if(!ready){ + if (!ready) { queuedTasks.add(() -> syncPack(pack)); return; } @@ -371,7 +371,7 @@ public class TelegramStickersService{ syncPack(p1); syncPack(p2); - if(getActivePacksListReference().contains(p1) && getActivePacksListReference().contains(p2) || getInactivePacksListReference().contains(p1) && getInactivePacksListReference().contains(p2)){ + if (getActivePacksListReference().contains(p1) && getActivePacksListReference().contains(p2) || getInactivePacksListReference().contains(p1) && getInactivePacksListReference().contains(p2)) { int li1 = getActivePacksListReference().indexOf(p1); int li2 = getActivePacksListReference().indexOf(p2); getActivePacksListReference().set(li2, p1); diff --git a/app/src/main/java/com/aefyr/tsg/g2/sql/TelegramStickersDbHelper.java b/app/src/main/java/com/aefyr/tsg/g2/sql/TelegramStickersDbHelper.java index 98448773b..6903651ef 100755 --- a/app/src/main/java/com/aefyr/tsg/g2/sql/TelegramStickersDbHelper.java +++ b/app/src/main/java/com/aefyr/tsg/g2/sql/TelegramStickersDbHelper.java @@ -38,7 +38,7 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper{ @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){ - if(oldVersion == 1 && newVersion == 2){ + if (oldVersion == 1 && newVersion == 2) { db.execSQL(String.format("ALTER TABLE %s ADD COLUMN %s TEXT", TelegramStickersContract.StickersTableEntry.TABLE_NAME, TelegramStickersContract.StickersTableEntry.COLUMN_NAME_EMOJIS)); } } @@ -61,12 +61,12 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper{ } catch (JSONException e) { e.printStackTrace(); } - if(pack.index == -1) pack.index = getNewIndex(); + if (pack.index == -1) pack.index = getNewIndex(); sqlPack.put(TelegramStickersContract.StickersTableEntry.COLUMN_NAME_INDEX, pack.index); int s = writableDb.updateWithOnConflict(TelegramStickersContract.StickersTableEntry.TABLE_NAME, sqlPack, TelegramStickersContract.StickersTableEntry.COLUMN_NAME_ID + "='" + pack.id + "'", null, SQLiteDatabase.CONFLICT_IGNORE); - if(s == 0){ + if (s == 0) { sqlPack.put(TelegramStickersContract.StickersTableEntry.COLUMN_NAME_INDEX, getNewIndex()); Log.d("DB", "INSERTED!"); return writableDb.insert(TelegramStickersContract.StickersTableEntry.TABLE_NAME, null, sqlPack) != -1; @@ -115,7 +115,7 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper{ @Override protected ArrayList doInBackground(Void... voids){ - if(readableDb == null) + if (readableDb == null) loadDatabases(); String sortOrder = TelegramStickersContract.StickersTableEntry.COLUMN_NAME_INDEX + " ASC"; @@ -145,7 +145,7 @@ public class TelegramStickersDbHelper extends SQLiteOpenHelper{ pack.version = version; pack.index = index; try { - if(emojisEncoded != null) pack.loadEmojis(new JSONObject(emojisEncoded)); + if (emojisEncoded != null) pack.loadEmojis(new JSONObject(emojisEncoded)); } catch (JSONException e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/TelegramStickersGrabber.java b/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/TelegramStickersGrabber.java index 95d73ce74..828d7c50d 100644 --- a/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/TelegramStickersGrabber.java +++ b/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/TelegramStickersGrabber.java @@ -85,11 +85,11 @@ public class TelegramStickersGrabber{ public static boolean isTelegramBlocked(){ NetClient client = new NetClient.Builder().connectTimeout(5, TimeUnit.SECONDS).build(); try { - if(PROXY_IP != null){ + if (PROXY_IP != null) { Socket socket = new Socket(PROXY_IP, PROXY_PORT); Proxy proxy = new Proxy(Proxy.Type.SOCKS, socket.getRemoteSocketAddress()); NetClient.Builder b = new NetClient.Builder().proxy(proxy); - if(PROXY_USER != null){ + if (PROXY_USER != null) { b = b.proxyAuthenticator(new PasswordAuthentication(PROXY_USER, PROXY_PASS.toCharArray())); } client = b.build(); @@ -104,7 +104,7 @@ public class TelegramStickersGrabber{ NetResponse res = client.newCall(req).execute(); String s = res.getDataString(); - if(!s.equals("{\"ok\":false,\"error_code\":404,\"description\":\"Not Found\"}")) + if (!s.equals("{\"ok\":false,\"error_code\":404,\"description\":\"Not Found\"}")) return true; } catch (Exception e) { return true; @@ -121,12 +121,12 @@ public class TelegramStickersGrabber{ @Override public void run(){ try { - if(PROXY_IP != null){ + if (PROXY_IP != null) { Socket socket = new Socket(PROXY_IP, PROXY_PORT); Proxy proxy = new Proxy(Proxy.Type.SOCKS, socket.getRemoteSocketAddress()); NetClient.Builder b = httpClient.newBuilder().proxy(proxy); - if(PROXY_USER != null){ + if (PROXY_USER != null) { httpClient = b.proxyAuthenticator(new PasswordAuthentication(PROXY_USER, PROXY_PASS.toCharArray())).build(); } @@ -185,8 +185,8 @@ public class TelegramStickersGrabber{ @Override public void onResponse(NetCall call, NetResponse response) throws IOException{ - if(!response.isSuccessful()){ - if(response.getData() != null) + if (!response.isSuccessful()) { + if (response.getData() != null) listener.onPackDownloadError(new TSGException(response.getDataString() + "\nURL: " + call.request().url())); else listener.onPackDownloadError(new TSGException("Unknown Exception, no response body")); @@ -199,19 +199,19 @@ public class TelegramStickersGrabber{ JSONObject jPackInfo = new JSONObject(response.getDataString()).getJSONObject("result"); String packVersion = new String(sha256.digest(jPackInfo.toString().getBytes(StandardCharsets.UTF_8))); - if(packVersion.equals(installedVersion)){ + if (packVersion.equals(installedVersion)) { listener.onPackDownloaded(null, false); return; } JSONArray jStickers = jPackInfo.getJSONArray("stickers"); - if(jStickers.length() == 0){ + if (jStickers.length() == 0) { listener.onPackDownloadError(new TSGException("No stickers in pack")); return; } - if(jPackInfo.optBoolean("is_animated")){ + if (jPackInfo.optBoolean("is_animated")) { listener.onPackDownloadError(new TSGException("Animated stickerpacks are not supported!")); return; } @@ -220,7 +220,7 @@ public class TelegramStickersGrabber{ Log.d(TAG, String.format("Parsing stickers in pack %s", packName)); - for(int i = 0; i < jStickers.length(); i++) { + for (int i = 0; i < jStickers.length(); i++) { JSONObject jSticker = jStickers.getJSONObject(i); stickers.add(new Sticker(jSticker.getString("file_id"), jSticker.getString("emoji"))); } @@ -232,7 +232,7 @@ public class TelegramStickersGrabber{ return; } - if(!packFolder.exists() && !packFolder.mkdirs()){ + if (!packFolder.exists() && !packFolder.mkdirs()) { listener.onPackDownloadError(new IOException("Can't create folder for the pack!")); return; } @@ -255,7 +255,7 @@ public class TelegramStickersGrabber{ final Flag deathFlag = new Flag(); AtomicInteger retryed = new AtomicInteger(); - for(int i = 0; i < set.stickers.size(); i++) { + for (int i = 0; i < set.stickers.size(); i++) { final Sticker sticker = set.stickers.get(i); NetRequest fileInfoRequest = new NetRequest.Builder().get().url(String.format(GET_FILE_URL, botApiKey, sticker.fileId)).build(); @@ -265,7 +265,7 @@ public class TelegramStickersGrabber{ httpClient.newCall(fileInfoRequest).enqueue(new NetCallback(){ @Override public void onFailure(NetCall call, IOException e){ - if(deathFlag.up()) + if (deathFlag.up()) return; deathFlag.raise(); @@ -276,13 +276,13 @@ public class TelegramStickersGrabber{ @Override public void onResponse(NetCall call, NetResponse response) throws IOException{ - if(deathFlag.up()) + if (deathFlag.up()) return; - if(response.code() != 200){ + if (response.code() != 200) { retryed.incrementAndGet(); - if(retryed.get() > 5) + if (retryed.get() > 5) onFailure(call, new IOException()); else httpClient.newCall(fileInfoRequest) .enqueue(this); @@ -301,14 +301,14 @@ public class TelegramStickersGrabber{ return; } - if(botApiKey == null) botApiKey = ""; + if (botApiKey == null) botApiKey = ""; NetRequest fileDownloadRequest = new NetRequest.Builder().get().url(String.format(BOT_API_BASE_FILE_URL, botApiKey, filePath)).build(); httpClient.newCall(fileDownloadRequest).enqueue(new NetCallback(){ @Override public void onFailure(NetCall call, IOException e){ - if(deathFlag.up()) + if (deathFlag.up()) return; deathFlag.raise(); @@ -319,13 +319,13 @@ public class TelegramStickersGrabber{ @Override public void onResponse(NetCall call, NetResponse response) throws IOException{ - if(deathFlag.up()) + if (deathFlag.up()) return; - if(response.code() != 200){ + if (response.code() != 200) { retryed.incrementAndGet(); - if(retryed.get() > 5) + if (retryed.get() > 5) onFailure(call, new IOException()); else httpClient.newCall(fileDownloadRequest) .enqueue(this); @@ -333,7 +333,7 @@ public class TelegramStickersGrabber{ return; } - if(response.getData() == null){ + if (response.getData() == null) { deathFlag.raise(); listener.onPackDownloadError(new TSGException("Response body for a sticker is null :/")); sync.set(true); @@ -355,7 +355,7 @@ public class TelegramStickersGrabber{ return; } - if(stickerImage == null){ + if (stickerImage == null) { deathFlag.raise(); listener.onPackDownloadError(new TSGException("Unable to decode sticker image")); sync.set(true); @@ -376,7 +376,7 @@ public class TelegramStickersGrabber{ return; } - if(!stickerImage.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream)){ + if (!stickerImage.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream)) { stickerImage.recycle(); deathFlag.raise(); listener.onPackDownloadError(new TSGException("Unable to compress sticker to a png file at path: " + stickerFile.getAbsolutePath())); diff --git a/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/util/GoalCounter.java b/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/util/GoalCounter.java index 2856ed391..426a1e49b 100755 --- a/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/util/GoalCounter.java +++ b/app/src/main/java/com/aefyr/tsg/g2/stickersgrabber/util/GoalCounter.java @@ -17,14 +17,14 @@ public class GoalCounter{ } public synchronized void increase(){ - if(++i == goal) + if (++i == goal) listener.onGoalReached(); Log.d("COUNTER", "G=" + goal + ", I=" + i); } public synchronized void increase(int delta){ - if((i += delta) == goal) + if ((i += delta) == goal) listener.onGoalReached(); } diff --git a/app/src/main/java/com/arthenica/ffmpegkit/NativeLoader.java b/app/src/main/java/com/arthenica/ffmpegkit/NativeLoader.java index 96c34163b..aa7c89d0f 100755 --- a/app/src/main/java/com/arthenica/ffmpegkit/NativeLoader.java +++ b/app/src/main/java/com/arthenica/ffmpegkit/NativeLoader.java @@ -1,8 +1,8 @@ package com.arthenica.ffmpegkit; import android.os.Build; -import android.os.Environment; import android.util.Log; + import com.arthenica.smartexception.java.Exceptions; import java.util.Collections; @@ -10,82 +10,82 @@ import java.util.List; import ru.vtosters.lite.utils.Globals; -public class NativeLoader { +public class NativeLoader{ static final String[] FFMPEG_LIBRARIES = {"avutil", "swscale", "swresample", "avcodec", "avformat", "avfilter", "avdevice"}; - private static void loadLibrary(String libraryName) { - String path = Globals.getContext().getFilesDir() + "/lib" + libraryName + ".so"; - System.load(path); + private static void loadLibrary(String libraryName){ + String path = Globals.getContext().getFilesDir() + "/lib" + libraryName + ".so"; + System.load(path); } - private static List loadExternalLibraries() { + private static List loadExternalLibraries(){ // return Packages.getExternalLibraries(); return Collections.emptyList(); } - private static String loadNativeAbi() { - // return AbiDetect.getNativeAbi(); + private static String loadNativeAbi(){ + // return AbiDetect.getNativeAbi(); return Abi.ABI_ARMV7A_NEON.getName(); } - static String loadAbi() { - // return AbiDetect.getAbi(); + static String loadAbi(){ + // return AbiDetect.getAbi(); return Abi.ABI_ARMV7A_NEON.getName(); } - static String loadPackageName() { - return Packages.getPackageName(); + static String loadPackageName(){ + return Packages.getPackageName(); } - static String loadVersion() { - return FFmpegKitConfig.getVersion(); + static String loadVersion(){ + return FFmpegKitConfig.getVersion(); } - static boolean loadIsLTSBuild() { - return AbiDetect.isNativeLTSBuild(); + static boolean loadIsLTSBuild(){ + return AbiDetect.isNativeLTSBuild(); } - static int loadLogLevel() { - return FFmpegKitConfig.getNativeLogLevel(); + static int loadLogLevel(){ + return FFmpegKitConfig.getNativeLogLevel(); } - static String loadBuildDate() { - return FFmpegKitConfig.getBuildDate(); + static String loadBuildDate(){ + return FFmpegKitConfig.getBuildDate(); } - static void enableRedirection() { - FFmpegKitConfig.enableRedirection(); + static void enableRedirection(){ + FFmpegKitConfig.enableRedirection(); } - static void loadFFmpegKitAbiDetect() { + static void loadFFmpegKitAbiDetect(){ loadLibrary("ffmpegkit_abidetect"); } - static boolean loadFFmpeg() { + static boolean loadFFmpeg(){ boolean nativeFFmpegLoaded = false; boolean nativeFFmpegTriedAndFailed = false; - if (AbiDetect.ARM_V7A.equals(loadNativeAbi())) { - try { - for (String ffmpegLibrary : FFMPEG_LIBRARIES) { - loadLibrary(ffmpegLibrary + "_neon"); - } - nativeFFmpegLoaded = true; - } catch (final Error e) { - android.util.Log.i(FFmpegKitConfig.TAG, String.format("NEON supported armeabi-v7a ffmpeg library not found. Loading default armeabi-v7a library.%s", Exceptions.getStackTraceString(e))); - nativeFFmpegTriedAndFailed = true; - } - } - - if (!nativeFFmpegLoaded) { + if (AbiDetect.ARM_V7A.equals(loadNativeAbi())) { + try { for (String ffmpegLibrary : FFMPEG_LIBRARIES) { - loadLibrary(ffmpegLibrary); + loadLibrary(ffmpegLibrary + "_neon"); } + nativeFFmpegLoaded = true; + } catch (final Error e) { + android.util.Log.i(FFmpegKitConfig.TAG, String.format("NEON supported armeabi-v7a ffmpeg library not found. Loading default armeabi-v7a library.%s", Exceptions.getStackTraceString(e))); + nativeFFmpegTriedAndFailed = true; } + } + + if (!nativeFFmpegLoaded) { + for (String ffmpegLibrary : FFMPEG_LIBRARIES) { + loadLibrary(ffmpegLibrary); + } + } return nativeFFmpegTriedAndFailed; } - static void loadFFmpegKit(boolean nativeFFmpegTriedAndFailed) { + static void loadFFmpegKit(boolean nativeFFmpegTriedAndFailed){ boolean nativeFFmpegKitLoaded = false; if (!nativeFFmpegTriedAndFailed && "arm-v7a".equals(loadNativeAbi())) { try { @@ -102,7 +102,7 @@ public class NativeLoader { } - static String getDeviceDebugInformation() { + static String getDeviceDebugInformation(){ StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("brand: "); stringBuilder.append(Build.BRAND); diff --git a/app/src/main/java/com/arthenica/smartexception/AbstractExceptions.java b/app/src/main/java/com/arthenica/smartexception/AbstractExceptions.java index f0759d34d..04049943e 100755 --- a/app/src/main/java/com/arthenica/smartexception/AbstractExceptions.java +++ b/app/src/main/java/com/arthenica/smartexception/AbstractExceptions.java @@ -43,7 +43,7 @@ import java.util.Set; * @author Taner Sener * @since 0.1.0 */ -public abstract class AbstractExceptions { +public abstract class AbstractExceptions{ /** *

Default max depth used in methods which do not have a maxDepth argument. @@ -90,14 +90,14 @@ public abstract class AbstractExceptions { * * @param packageString root package name to register */ - public static void registerRootPackage(final String packageString) { + public static void registerRootPackage(final String packageString){ rootPackageSet.add(packageString); } /** *

Clears previously registered root packages. */ - public static void clearRootPackages() { + public static void clearRootPackages(){ rootPackageSet.clear(); } @@ -106,14 +106,14 @@ public abstract class AbstractExceptions { * * @param packageString group package name to register */ - public static void registerGroupPackage(final String packageString) { + public static void registerGroupPackage(final String packageString){ groupPackageSet.add(packageString); } /** *

Clears previously registered group packages. */ - public static void clearGroupPackages() { + public static void clearGroupPackages(){ groupPackageSet.clear(); } @@ -123,7 +123,7 @@ public abstract class AbstractExceptions { * * @return current stack trace serializer implementation */ - public static StackTraceElementSerializer getStackTraceElementSerializer() { + public static StackTraceElementSerializer getStackTraceElementSerializer(){ return stackTraceElementSerializer; } @@ -133,7 +133,7 @@ public abstract class AbstractExceptions { * * @param stackTraceElementSerializer new stack trace serializer implementation */ - public static void setStackTraceElementSerializer(final StackTraceElementSerializer stackTraceElementSerializer) { + public static void setStackTraceElementSerializer(final StackTraceElementSerializer stackTraceElementSerializer){ AbstractExceptions.stackTraceElementSerializer = stackTraceElementSerializer; } @@ -143,7 +143,7 @@ public abstract class AbstractExceptions { * @param packageString ignore package name to register * @param ignoreCauseClasses ignore cause classes from this package too */ - public static void registerIgnorePackage(final String packageString, final boolean ignoreCauseClasses) { + public static void registerIgnorePackage(final String packageString, final boolean ignoreCauseClasses){ ignorePackageSet.add(packageString); if (ignoreCauseClasses) { ignoreCausePackageSet.add(packageString); @@ -153,7 +153,7 @@ public abstract class AbstractExceptions { /** *

Clears previously registered ignore packages. */ - public static void clearIgnorePackages() { + public static void clearIgnorePackages(){ ignorePackageSet.clear(); ignoreCausePackageSet.clear(); } @@ -165,7 +165,7 @@ public abstract class AbstractExceptions { * converted to string will not include causes. If value is false causes will be appended to the stack trace of * the main throwable. */ - public static boolean getIgnoreAllCauses() { + public static boolean getIgnoreAllCauses(){ return ignoreAllCauses; } @@ -176,7 +176,7 @@ public abstract class AbstractExceptions { * or converted to string will not include causes. If value is false causes will be appended to the stack trace of * the main throwable. */ - public static void setIgnoreAllCauses(final boolean ignoreAllCauses) { + public static void setIgnoreAllCauses(final boolean ignoreAllCauses){ AbstractExceptions.ignoreAllCauses = ignoreAllCauses; } @@ -190,7 +190,7 @@ public abstract class AbstractExceptions { * @param throwable parent throwable * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable) { + public static String getStackTraceString(final Throwable throwable){ return getStackTraceString(throwable, false, rootPackageSet, groupPackageSet, ignorePackageSet, 0, ignoreAllCauses); } @@ -205,7 +205,7 @@ public abstract class AbstractExceptions { * @param ignoreAllCauses ignore all causes in the exception chain * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final boolean ignoreAllCauses) { + public static String getStackTraceString(final Throwable throwable, final boolean ignoreAllCauses){ return getStackTraceString(throwable, false, rootPackageSet, groupPackageSet, ignorePackageSet, 0, ignoreAllCauses); } @@ -218,7 +218,7 @@ public abstract class AbstractExceptions { * @param ignorePackageSet ignore packages to use for building the stack trace * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet) { + public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet){ return getStackTraceString(throwable, false, rootPackageSet, groupPackageSet, ignorePackageSet, 0, ignoreAllCauses); } @@ -232,7 +232,7 @@ public abstract class AbstractExceptions { * @param ignoreAllCauses ignore all causes in the exception chain * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet, final boolean ignoreAllCauses) { + public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet, final boolean ignoreAllCauses){ return getStackTraceString(throwable, false, rootPackageSet, groupPackageSet, ignorePackageSet, 0, ignoreAllCauses); } @@ -243,7 +243,7 @@ public abstract class AbstractExceptions { * @param rootPackage root package to use for building the stack trace * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final String rootPackage) { + public static String getStackTraceString(final Throwable throwable, final String rootPackage){ return getStackTraceString(throwable, false, Collections.singleton(rootPackage), new HashSet(), new HashSet(), 0, ignoreAllCauses); } @@ -255,7 +255,7 @@ public abstract class AbstractExceptions { * @param groupPackage group package to use for building the stack trace * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final String rootPackage, final String groupPackage) { + public static String getStackTraceString(final Throwable throwable, final String rootPackage, final String groupPackage){ return getStackTraceString(throwable, false, Collections.singleton(rootPackage), Collections.singleton(groupPackage), new HashSet(), 0, ignoreAllCauses); } @@ -266,7 +266,7 @@ public abstract class AbstractExceptions { * @param maxDepth max depth in exception chain that will be used * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final int maxDepth) { + public static String getStackTraceString(final Throwable throwable, final int maxDepth){ return getStackTraceString(throwable, false, new HashSet(), new HashSet(), new HashSet(), maxDepth, ignoreAllCauses); } @@ -278,7 +278,7 @@ public abstract class AbstractExceptions { * @param ignoreAllCauses ignore all causes in the exception chain * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final int maxDepth, final boolean ignoreAllCauses) { + public static String getStackTraceString(final Throwable throwable, final int maxDepth, final boolean ignoreAllCauses){ return getStackTraceString(throwable, false, new HashSet(), new HashSet(), new HashSet(), maxDepth, ignoreAllCauses); } @@ -294,7 +294,7 @@ public abstract class AbstractExceptions { * @param ignoreAllCauses ignore all causes in the exception chain * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final boolean isCause, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet, final int maxDepth, final boolean ignoreAllCauses) { + public static String getStackTraceString(final Throwable throwable, final boolean isCause, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet, final int maxDepth, final boolean ignoreAllCauses){ final StringBuilder builder = new StringBuilder(); if (throwable == null) { @@ -386,7 +386,7 @@ public abstract class AbstractExceptions { * @param firstStackTraceElementInTheGroup first stack trace element of this group * @return new value for the group element count */ - public static int appendStackTraceGroupElement(final StringBuilder stringBuilder, final String currentGroupPackage, final int numberOfElementsInTheCurrentGroup, final StackTraceElement firstStackTraceElementInTheGroup) { + public static int appendStackTraceGroupElement(final StringBuilder stringBuilder, final String currentGroupPackage, final int numberOfElementsInTheCurrentGroup, final StackTraceElement firstStackTraceElementInTheGroup){ if (numberOfElementsInTheCurrentGroup > 0) { if (stackTraceElementSerializer == null) { throw new IllegalArgumentException("Stack trace element serializer not initialized."); @@ -407,7 +407,7 @@ public abstract class AbstractExceptions { * @return true if package of the given class name matches one of package names provided in packageSet, * false otherwise */ - public static boolean containsPackage(final String fullClassName, final Set packageSet) { + public static boolean containsPackage(final String fullClassName, final Set packageSet){ return getContainingPackage(fullClassName, packageSet) != null; } @@ -420,7 +420,7 @@ public abstract class AbstractExceptions { * @return one of the package names in the packageSet that matches the package of the given class name * or null if no matching package name is found in the packageSet */ - public static String getContainingPackage(final String fullClassName, final Set packageSet) { + public static String getContainingPackage(final String fullClassName, final Set packageSet){ for (final String parentExceptionPackage : packageSet) { if (fullClassName.startsWith(parentExceptionPackage)) { return parentExceptionPackage; @@ -436,7 +436,7 @@ public abstract class AbstractExceptions { * @param throwable parent throwable * @return a string containing all messages found in the exception chain */ - public static String getAllMessages(final Throwable throwable) { + public static String getAllMessages(final Throwable throwable){ final StringBuilder messageBuilder = new StringBuilder(); getAllMessages(throwable, messageBuilder); return messageBuilder.toString(); @@ -448,7 +448,7 @@ public abstract class AbstractExceptions { * @param throwable parent throwable * @param messageBuilder message builder */ - public static void getAllMessages(final Throwable throwable, final StringBuilder messageBuilder) { + public static void getAllMessages(final Throwable throwable, final StringBuilder messageBuilder){ if (throwable != null) { final String message = throwable.getMessage(); if (!isEmpty(message)) { @@ -470,7 +470,7 @@ public abstract class AbstractExceptions { * @param maxDepth max depth in exception chain that will be returned * @return an array containing stack trace elements */ - public static StackTraceElement[] getStackTrace(final Throwable throwable, final int maxDepth) { + public static StackTraceElement[] getStackTrace(final Throwable throwable, final int maxDepth){ final ArrayList list = new ArrayList(); if (throwable != null) { @@ -492,7 +492,7 @@ public abstract class AbstractExceptions { * @param ignorePackageSet ignore packages to use for building the stack trace * @return an array containing stack trace elements */ - public static StackTraceElement[] getStackTrace(final Throwable throwable, final Set rootPackageSet, final Set ignorePackageSet) { + public static StackTraceElement[] getStackTrace(final Throwable throwable, final Set rootPackageSet, final Set ignorePackageSet){ final ArrayList list = new ArrayList(); final ArrayList partialList = new ArrayList(); @@ -529,7 +529,7 @@ public abstract class AbstractExceptions { * @return true if the given cause class is found in the exception chain of the throwable, false * otherwise */ - public static boolean containsCause(final Throwable throwable, final Class causeClass) { + public static boolean containsCause(final Throwable throwable, final Class causeClass){ return containsCause(throwable, causeClass, null); } @@ -547,7 +547,7 @@ public abstract class AbstractExceptions { * @return true if the given cause class and cause message is found in the exception chain of the * throwable, false otherwise */ - public static boolean containsCause(final Throwable throwable, final Class causeClass, final String causeMessage) { + public static boolean containsCause(final Throwable throwable, final Class causeClass, final String causeMessage){ return (searchCause(throwable, causeClass, causeMessage, DEFAULT_MAX_DEPTH) != null); } @@ -557,7 +557,7 @@ public abstract class AbstractExceptions { * @param throwable parent throwable * @return the cause of the throwable found or null if throwable does not have a cause */ - public static Throwable getCause(final Throwable throwable) { + public static Throwable getCause(final Throwable throwable){ return getCause(throwable, DEFAULT_MAX_DEPTH); } @@ -573,7 +573,7 @@ public abstract class AbstractExceptions { * @return the cause of the throwable found until maxDepth is reached in the exception * chain or null if throwable does not have a cause */ - public static Throwable getCause(final Throwable throwable, final int maxDepth) { + public static Throwable getCause(final Throwable throwable, final int maxDepth){ if (throwable == null) { return null; } @@ -601,7 +601,7 @@ public abstract class AbstractExceptions { * @param causeClass class to search for * @return the throwable found or null if no class in exception chain matches the given cause class */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass){ return searchCause(throwable, causeClass, null, DEFAULT_MAX_DEPTH); } @@ -618,7 +618,7 @@ public abstract class AbstractExceptions { * @return the throwable found or null if no class in exception chain matches the given cause class * and cause message */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage){ return searchCause(throwable, causeClass, causeMessage, DEFAULT_MAX_DEPTH); } @@ -636,7 +636,7 @@ public abstract class AbstractExceptions { * @return the throwable found or null if no class in exception chain matches the given cause class * and cause message */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage, final int maxDepth) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage, final int maxDepth){ if (throwable == null) { return null; } @@ -675,7 +675,7 @@ public abstract class AbstractExceptions { * @param maxDepth max depth in exception chain that will be searched * @return the throwable found or null if no class in exception chain matches the given cause class */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass, final int maxDepth) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass, final int maxDepth){ if (throwable == null) { return null; } @@ -702,7 +702,7 @@ public abstract class AbstractExceptions { * @param value string to check * @return true if given string is null or has zero length after trim(), false otherwise */ - public static boolean isEmpty(final String value) { + public static boolean isEmpty(final String value){ if (value == null) { return true; } @@ -716,7 +716,7 @@ public abstract class AbstractExceptions { * @param className fully qualified class name * @return name of the package */ - public static String packageName(final String className) { + public static String packageName(final String className){ if (className == null) { return ""; } diff --git a/app/src/main/java/com/arthenica/smartexception/StackTraceElementSerializer.java b/app/src/main/java/com/arthenica/smartexception/StackTraceElementSerializer.java index 9e1d548da..9eabec0cd 100755 --- a/app/src/main/java/com/arthenica/smartexception/StackTraceElementSerializer.java +++ b/app/src/main/java/com/arthenica/smartexception/StackTraceElementSerializer.java @@ -38,7 +38,7 @@ package com.arthenica.smartexception; * @author Taner Sener * @since 0.1.0 */ -public interface StackTraceElementSerializer { +public interface StackTraceElementSerializer{ /** *

Converts the given stackTraceElement into a string. diff --git a/app/src/main/java/com/arthenica/smartexception/java/Exceptions.java b/app/src/main/java/com/arthenica/smartexception/java/Exceptions.java index a94458842..1cb9ca897 100755 --- a/app/src/main/java/com/arthenica/smartexception/java/Exceptions.java +++ b/app/src/main/java/com/arthenica/smartexception/java/Exceptions.java @@ -44,13 +44,13 @@ import java.util.Set; * @author Taner Sener * @since 0.1.0 */ -public class Exceptions { +public class Exceptions{ - static { - AbstractExceptions.setStackTraceElementSerializer(new StackTraceElementSerializer() { + static{ + AbstractExceptions.setStackTraceElementSerializer(new StackTraceElementSerializer(){ @Override - public String toString(StackTraceElement stackTraceElement) { + public String toString(StackTraceElement stackTraceElement){ final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(stackTraceElement.getClassName()); @@ -75,17 +75,17 @@ public class Exceptions { } @Override - public String getModuleName(StackTraceElement stackTraceElement) { + public String getModuleName(StackTraceElement stackTraceElement){ return ""; } @Override - public String getNativeMethodDefinition() { + public String getNativeMethodDefinition(){ return "(Native Method)"; } @Override - public String getUnknownSourceDefinition() { + public String getUnknownSourceDefinition(){ return "(Unknown Source)"; } }); @@ -96,14 +96,14 @@ public class Exceptions { * * @param packageString root package name to register */ - public static void registerRootPackage(final String packageString) { + public static void registerRootPackage(final String packageString){ AbstractExceptions.registerRootPackage(packageString); } /** *

Clears previously registered root packages. */ - public static void clearRootPackages() { + public static void clearRootPackages(){ AbstractExceptions.clearRootPackages(); } @@ -112,14 +112,14 @@ public class Exceptions { * * @param packageString group package name to register */ - public static void registerGroupPackage(final String packageString) { + public static void registerGroupPackage(final String packageString){ AbstractExceptions.registerGroupPackage(packageString); } /** *

Clears previously registered group packages. */ - public static void clearGroupPackages() { + public static void clearGroupPackages(){ AbstractExceptions.clearGroupPackages(); } @@ -129,7 +129,7 @@ public class Exceptions { * * @return current stack trace serializer implementation */ - public static StackTraceElementSerializer getStackTraceElementSerializer() { + public static StackTraceElementSerializer getStackTraceElementSerializer(){ return AbstractExceptions.getStackTraceElementSerializer(); } @@ -139,7 +139,7 @@ public class Exceptions { * * @param stackTraceElementSerializer new stack trace serializer implementation */ - public static void setStackTraceElementSerializer(final StackTraceElementSerializer stackTraceElementSerializer) { + public static void setStackTraceElementSerializer(final StackTraceElementSerializer stackTraceElementSerializer){ AbstractExceptions.setStackTraceElementSerializer(stackTraceElementSerializer); } @@ -149,14 +149,14 @@ public class Exceptions { * @param packageString ignore package name to register * @param ignoreCauseClasses ignore cause classes from this package too */ - public static void registerIgnorePackage(final String packageString, final boolean ignoreCauseClasses) { + public static void registerIgnorePackage(final String packageString, final boolean ignoreCauseClasses){ AbstractExceptions.registerIgnorePackage(packageString, ignoreCauseClasses); } /** *

Clears previously registered ignore packages. */ - public static void clearIgnorePackages() { + public static void clearIgnorePackages(){ AbstractExceptions.clearIgnorePackages(); } @@ -167,7 +167,7 @@ public class Exceptions { * converted to string will not include causes. If value is false causes will be appended to the stack trace of * the main throwable. */ - public static boolean getIgnoreAllCauses() { + public static boolean getIgnoreAllCauses(){ return AbstractExceptions.getIgnoreAllCauses(); } @@ -178,7 +178,7 @@ public class Exceptions { * or converted to string will not include causes. If value is false causes will be appended to the stack trace of * the main throwable. */ - public static void setIgnoreAllCauses(final boolean ignoreAllCauses) { + public static void setIgnoreAllCauses(final boolean ignoreAllCauses){ AbstractExceptions.setIgnoreAllCauses(ignoreAllCauses); } @@ -192,7 +192,7 @@ public class Exceptions { * @param throwable parent throwable * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable) { + public static String getStackTraceString(final Throwable throwable){ return AbstractExceptions.getStackTraceString(throwable); } @@ -207,7 +207,7 @@ public class Exceptions { * @param ignoreAllCauses ignore all causes in the exception chain * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final boolean ignoreAllCauses) { + public static String getStackTraceString(final Throwable throwable, final boolean ignoreAllCauses){ return AbstractExceptions.getStackTraceString(throwable, ignoreAllCauses); } @@ -220,7 +220,7 @@ public class Exceptions { * @param ignorePackageSet ignore packages to use for building the stack trace * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet) { + public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet){ return AbstractExceptions.getStackTraceString(throwable, rootPackageSet, groupPackageSet, ignorePackageSet); } @@ -234,7 +234,7 @@ public class Exceptions { * @param ignoreAllCauses ignore all causes in the exception chain * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet, final boolean ignoreAllCauses) { + public static String getStackTraceString(final Throwable throwable, final Set rootPackageSet, final Set groupPackageSet, final Set ignorePackageSet, final boolean ignoreAllCauses){ return AbstractExceptions.getStackTraceString(throwable, rootPackageSet, groupPackageSet, ignorePackageSet, ignoreAllCauses); } @@ -245,7 +245,7 @@ public class Exceptions { * @param rootPackage root package to use for building the stack trace * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final String rootPackage) { + public static String getStackTraceString(final Throwable throwable, final String rootPackage){ return AbstractExceptions.getStackTraceString(throwable, rootPackage); } @@ -257,7 +257,7 @@ public class Exceptions { * @param groupPackage group package to use for building the stack trace * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final String rootPackage, final String groupPackage) { + public static String getStackTraceString(final Throwable throwable, final String rootPackage, final String groupPackage){ return AbstractExceptions.getStackTraceString(throwable, rootPackage, groupPackage); } @@ -268,7 +268,7 @@ public class Exceptions { * @param maxDepth max depth in exception chain that will be used * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final int maxDepth) { + public static String getStackTraceString(final Throwable throwable, final int maxDepth){ return AbstractExceptions.getStackTraceString(throwable, maxDepth); } @@ -280,7 +280,7 @@ public class Exceptions { * @param ignoreAllCauses ignore all causes in the exception chain * @return a string containing the smart stack trace for the given throwable */ - public static String getStackTraceString(final Throwable throwable, final int maxDepth, final boolean ignoreAllCauses) { + public static String getStackTraceString(final Throwable throwable, final int maxDepth, final boolean ignoreAllCauses){ return AbstractExceptions.getStackTraceString(throwable, maxDepth, ignoreAllCauses); } @@ -290,7 +290,7 @@ public class Exceptions { * @param throwable parent throwable * @return a string containing all messages found in the exception chain */ - public static String getAllMessages(final Throwable throwable) { + public static String getAllMessages(final Throwable throwable){ return AbstractExceptions.getAllMessages(throwable); } @@ -306,7 +306,7 @@ public class Exceptions { * @return true if the given cause class is found in the exception chain of the throwable, false * otherwise */ - public static boolean containsCause(final Throwable throwable, final Class causeClass) { + public static boolean containsCause(final Throwable throwable, final Class causeClass){ return AbstractExceptions.containsCause(throwable, causeClass); } @@ -324,7 +324,7 @@ public class Exceptions { * @return true if the given cause class and cause message is found in the exception chain of the * throwable, false otherwise */ - public static boolean containsCause(final Throwable throwable, final Class causeClass, final String causeMessage) { + public static boolean containsCause(final Throwable throwable, final Class causeClass, final String causeMessage){ return AbstractExceptions.containsCause(throwable, causeClass, causeMessage); } @@ -334,7 +334,7 @@ public class Exceptions { * @param throwable parent throwable * @return the cause of the throwable found or null if throwable does not have a cause */ - public static Throwable getCause(final Throwable throwable) { + public static Throwable getCause(final Throwable throwable){ return AbstractExceptions.getCause(throwable); } @@ -350,7 +350,7 @@ public class Exceptions { * @return the cause of the throwable found until maxDepth is reached in the exception * chain or null if throwable does not have a cause */ - public static Throwable getCause(final Throwable throwable, final int maxDepth) { + public static Throwable getCause(final Throwable throwable, final int maxDepth){ return AbstractExceptions.getCause(throwable, maxDepth); } @@ -365,7 +365,7 @@ public class Exceptions { * @param causeClass class to search for * @return the throwable found or null if no class in exception chain matches the given cause class */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass){ return AbstractExceptions.searchCause(throwable, causeClass); } @@ -382,7 +382,7 @@ public class Exceptions { * @return the throwable found or null if no class in exception chain matches the given cause class * and cause message */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage){ return AbstractExceptions.searchCause(throwable, causeClass, causeMessage); } @@ -400,7 +400,7 @@ public class Exceptions { * @return the throwable found or null if no class in exception chain matches the given cause class * and cause message */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage, final int maxDepth) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass, final String causeMessage, final int maxDepth){ return AbstractExceptions.searchCause(throwable, causeClass, causeMessage, maxDepth); } @@ -416,7 +416,7 @@ public class Exceptions { * @param maxDepth max depth in exception chain that will be searched * @return the throwable found or null if no class in exception chain matches the given cause class */ - public static Throwable searchCause(final Throwable throwable, final Class causeClass, final int maxDepth) { + public static Throwable searchCause(final Throwable throwable, final Class causeClass, final int maxDepth){ return AbstractExceptions.searchCause(throwable, causeClass, maxDepth); } diff --git a/app/src/main/java/com/vtosters/lite/R.java b/app/src/main/java/com/vtosters/lite/R.java index 12420af5e..c441732e8 100644 --- a/app/src/main/java/com/vtosters/lite/R.java +++ b/app/src/main/java/com/vtosters/lite/R.java @@ -1,7 +1,7 @@ package com.vtosters.lite; -public class R { - public static final class anim { +public class R{ + public static final class anim{ public static final int abc_fade_in = 0x7f010000; public static final int abc_fade_out = 0x7f010001; public static final int abc_grow_fade_in_from_bottom = 0x7f010002; @@ -75,7 +75,7 @@ public class R { public static final int vkme_exit_noop = 0x7f010046; } - public static final class animator { + public static final class animator{ public static final int design_appbar_state_list_animator = 0x7f020000; public static final int design_fab_hide_motion_spec = 0x7f020001; public static final int design_fab_show_motion_spec = 0x7f020002; @@ -88,7 +88,7 @@ public class R { public static final int mtrl_fab_transformation_sheet_expand_spec = 0x7f020009; } - public static final class array { + public static final class array{ public static final int ad_report_reasons = 0x7f030000; public static final int ad_report_reasons_api = 0x7f030001; public static final int address_will_be_opened = 0x7f030002; @@ -180,7 +180,7 @@ public class R { public static final int when_day_of_week = 0x7f030058; } - public static final class attr { + public static final class attr{ public static final int BMSB_error_text_color = 0x7f040000; public static final int BuyMusicSubscriptionButtonStyle = 0x7f040001; public static final int PIAlphaNormal = 0x7f040002; @@ -2091,7 +2091,7 @@ public class R { public static final int zOrderOnTop = 0x7f040773; } - public static final class bool { + public static final class bool{ public static final int abc_action_bar_embed_tabs = 0x7f050000; public static final int abc_allow_stacked_button_bar = 0x7f050001; public static final int abc_config_actionMenuItemAllCaps = 0x7f050002; @@ -2110,7 +2110,7 @@ public class R { public static final int vk_is_tablet = 0x7f05000f; } - public static final class color { + public static final class color{ public static final int abc_background_cache_hint_selector_material_dark = 0x7f060000; public static final int abc_background_cache_hint_selector_material_light = 0x7f060001; public static final int abc_btn_colored_borderless_text_material = 0x7f060002; @@ -2918,7 +2918,7 @@ public class R { public static final int abc_color_highlight_material = 0x7f060004; } - public static final class dimen { + public static final class dimen{ public static final int _post_side_padding = 0x7f070000; public static final int abc_action_bar_content_inset_material = 0x7f070001; public static final int abc_action_bar_content_inset_with_nav = 0x7f070002; @@ -3783,7 +3783,7 @@ public class R { public static final int camera_target_text_size = 0x7f070074; } - public static final class drawable { + public static final class drawable{ public static final int $$notification_receive_28_60fps__1__0 = 0x7f080000; public static final int $$notification_receive_28_60fps__1__1 = 0x7f080001; public static final int $$notification_receive_28_60fps__1__2 = 0x7f080002; @@ -6801,7 +6801,7 @@ public class R { public static final int promo_qr_2 = 0x7f0809cf; } - public static final class font { + public static final class font{ public static final int fortun_af_led7seg_3 = 0x7f090000; public static final int roboto_black = 0x7f090001; public static final int roboto_black_italic = 0x7f090002; @@ -6824,7 +6824,7 @@ public class R { public static final int vk_tt_commons_demi_bold = 0x7f090013; } - public static final class id { + public static final class id{ public static final int ALT = 0x7f0a0000; public static final int CIRCLE = 0x7f0a0001; public static final int CTRL = 0x7f0a0002; @@ -10931,7 +10931,7 @@ public class R { public static final int choose_btn = 0x7f0a1007; } - public static final class integer { + public static final class integer{ public static final int abc_config_activityDefaultDur = 0x7f0b0000; public static final int abc_config_activityShortDur = 0x7f0b0001; public static final int angle_rtl_180 = 0x7f0b0002; @@ -10980,14 +10980,14 @@ public class R { public static final int s2dip = 0x7f0b0028; } - public static final class interpolator { + public static final class interpolator{ public static final int mtrl_fast_out_linear_in = 0x7f0c0000; public static final int mtrl_fast_out_slow_in = 0x7f0c0001; public static final int mtrl_linear = 0x7f0c0002; public static final int mtrl_linear_out_slow_in = 0x7f0c0003; } - public static final class layout { + public static final class layout{ public static final int ab_done_right = 0x7f0d0000; public static final int abc_action_bar_title_item = 0x7f0d0001; public static final int abc_action_bar_up_container = 0x7f0d0002; @@ -12749,7 +12749,7 @@ public class R { public static final int tgs_entry = 0x7f0d06de; } - public static final class menu { + public static final class menu{ public static final int add = 0x7f0e0000; public static final int attach_item = 0x7f0e0001; public static final int audio = 0x7f0e0002; @@ -12824,7 +12824,7 @@ public class R { public static final int vkim_photo_viewer = 0x7f0e0047; } - public static final class mipmap { + public static final class mipmap{ public static final int adaptive_launcher_background = 0x7f0f0000; public static final int adaptive_launcher_foreground = 0x7f0f0001; public static final int ic_launcher_round = 0x7f0f0002; @@ -12840,7 +12840,7 @@ public class R { public static final int ic_skip_previous_alpha_40_28 = 0x7f0f000b; } - public static final class plurals { + public static final class plurals{ public static final int accessibility_comments = 0x7f100000; public static final int accessibility_likes = 0x7f100001; public static final int accessibility_reposts = 0x7f100002; @@ -13113,7 +13113,7 @@ public class R { public static final int x_stickers = 0x7f10010d; } - public static final class raw { + public static final class raw{ public static final int amu_ballon_gx_prefix = 0x7f110000; public static final int amu_basic_folder = 0x7f110001; public static final int amu_basic_placemark = 0x7f110002; @@ -13153,7 +13153,7 @@ public class R { public static final int vklogo = 0x7f110024; } - public static final class string { + public static final class string{ public static final int abc_action_bar_home_description = 0x7f120000; public static final int abc_action_bar_up_description = 0x7f120001; public static final int abc_action_menu_overflow_description = 0x7f120002; @@ -18525,7 +18525,7 @@ public class R { public static final int your_gender = 0x7f1214f8; } - public static final class style { + public static final class style{ public static final int ActionBarGrayTheme = 0x7f130000; public static final int ActionBarProgress = 0x7f130001; public static final int ActionBarSpinner = 0x7f130002; @@ -19662,7 +19662,7 @@ public class R { public static final int Base_V28_Theme_AppCompat_Light = 0x7f1300a3; } - public static final class xml { + public static final class xml{ public static final int account_preferences = 0x7f150000; public static final int authenticator = 0x7f150001; public static final int contacts_custom_type = 0x7f150002; diff --git a/app/src/main/java/ru/vtosters/lite/audio/gcm/GCMFix.java b/app/src/main/java/ru/vtosters/lite/audio/gcm/GCMFix.java index 3268e92b4..7df4ad8f6 100644 --- a/app/src/main/java/ru/vtosters/lite/audio/gcm/GCMFix.java +++ b/app/src/main/java/ru/vtosters/lite/audio/gcm/GCMFix.java @@ -38,13 +38,13 @@ public class GCMFix{ } public static String requestTokenV2(String orig){ - if(musicFixNew()) return "null"; // TODO FIX TOKENMOD v2 cyz vk shit + if (musicFixNew()) return "null"; // TODO FIX TOKENMOD v2 cyz vk shit return orig; } public static String requestToken(String orig){ - if(musicFixNew()) return "{null}"; // TODO FIX TOKENMOD v2 cyz vk shit - if(orig.equals("")) return requestToken(); + if (musicFixNew()) return "{null}"; // TODO FIX TOKENMOD v2 cyz vk shit + if (orig.equals("")) return requestToken(); return orig; } @@ -53,7 +53,7 @@ public class GCMFix{ try { String[] aidarr = {"3974055026275073921", "4418584909973341826", "4585634953328772978"}; int r = new Random().nextInt(aidarr.length - 1); - String aid = "AidLogin " + aidarr[r] + ":" + new String[]{"1932960345884890854", "6594645578425092292", "1792344590975444730"}[r]; + String aid = "AidLogin " + aidarr[r] + ":" + new String[] {"1932960345884890854", "6594645578425092292", "1792344590975444730"}[r]; String pub2 = genNewKey(); String sig = getSig(pub2); String xappide2 = null; @@ -63,7 +63,7 @@ public class GCMFix{ } catch (NoSuchAlgorithmException e) { xappide2 = ""; } - if(xappide2 == null){ + if (xappide2 == null) { bytes[0] = (byte) (((bytes[0] & 15) + 112) & 255); xappide = Base64.encodeToString(bytes, 2).substring(0, 11); } else { @@ -81,7 +81,7 @@ public class GCMFix{ Thread.sleep(100); } String token = sb.toString(); - if(token.equals("REGISTRATION_ERROR")){ + if (token.equals("REGISTRATION_ERROR")) { return requestToken(); } rid = 0; @@ -109,7 +109,7 @@ public class GCMFix{ private static void fillParams(List params, String sig, String pub2, String xappid, long androidId, boolean del){ rid++; params.add("X-subtype=841415684880"); - if(del){ + if (del) { params.add("X-delete=1"); params.add("X-X-delete=1"); } else { @@ -128,13 +128,13 @@ public class GCMFix{ sb.append("X-appid="); sb.append(xappid); params.add(sb.toString()); - if(del){ + if (del) { params.add("X-scope=GCM"); } else { params.add("X-scope=*"); } params.add("X-subscription=841415684880"); - if(!del){ + if (!del) { params.add("X-gmp_app_id=1:841415684880:android:632f429381141121"); } params.add("X-app_ver_name=" + "5.56.1"); @@ -148,7 +148,7 @@ public class GCMFix{ private static String join(String chr, Iterable arr){ String str = ""; - for(String s : arr) { + for (String s : arr) { str = str.isEmpty() ? s : str + chr + s; } return str; @@ -192,7 +192,7 @@ public class GCMFix{ PrivateKey key = pair.getPrivate(); Signature sign = Signature.getInstance(key instanceof RSAPrivateKey ? "SHA256withRSA" : "SHA256withECDSA"); sign.initSign(key); - sign.update(join("\n", new String[]{"com.vkontakte.android", pub2}).getBytes(StandardCharsets.UTF_8)); + sign.update(join("\n", new String[] {"com.vkontakte.android", pub2}).getBytes(StandardCharsets.UTF_8)); return Base64.encodeToString(sign.sign(), 0); } catch (Exception e) { e.printStackTrace(); diff --git a/app/src/main/java/ru/vtosters/lite/deviceinfo/DeviceInfoCollector.java b/app/src/main/java/ru/vtosters/lite/deviceinfo/DeviceInfoCollector.java index c61283671..4ccab134d 100644 --- a/app/src/main/java/ru/vtosters/lite/deviceinfo/DeviceInfoCollector.java +++ b/app/src/main/java/ru/vtosters/lite/deviceinfo/DeviceInfoCollector.java @@ -31,23 +31,23 @@ public class DeviceInfoCollector{ Class cls = Class.forName("android.os.SystemProperties"); Method method = cls.getMethod("get", String.class); str = (String) method.invoke(cls, "gsm.sn1"); - if(isInvalidSerial(str)){ + if (isInvalidSerial(str)) { str = (String) method.invoke(cls, "ril.serialnumber"); } - if(isInvalidSerial(str)){ + if (isInvalidSerial(str)) { str = (String) method.invoke(cls, "ro.serialno"); } - if(isInvalidSerial(str)){ + if (isInvalidSerial(str)) { str = (String) method.invoke(cls, "sys.serialnumber"); } - if(isInvalidSerial(str)){ + if (isInvalidSerial(str)) { str = Build.SERIAL; } } catch (Exception e) { Log.d(TAG, "Serial ID obtaining failed: ", e); } str = null; - if(str != null){ + if (str != null) { return str.toLowerCase(); } return null; @@ -59,16 +59,16 @@ public class DeviceInfoCollector{ private String wifiMac(Context context){ String wifiMacFromManager = wifiMacFromManager(context); - if(isInvalidMac(wifiMacFromManager)){ + if (isInvalidMac(wifiMacFromManager)) { wifiMacFromManager = wifiMacFromNetworkInterfaces(); } - if(isInvalidMac(wifiMacFromManager)){ + if (isInvalidMac(wifiMacFromManager)) { wifiMacFromManager = wifiMacFromFileSystem(); } - if(isInvalidMac(wifiMacFromManager)){ + if (isInvalidMac(wifiMacFromManager)) { wifiMacFromManager = null; } - if(wifiMacFromManager != null){ + if (wifiMacFromManager != null) { return wifiMacFromManager.toLowerCase(); } return null; @@ -78,7 +78,7 @@ public class DeviceInfoCollector{ WifiInfo connectionInfo; try { WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); - if(wifiManager == null || (connectionInfo = wifiManager.getConnectionInfo()) == null){ + if (wifiManager == null || (connectionInfo = wifiManager.getConnectionInfo()) == null) { return null; } return null; @@ -90,18 +90,18 @@ public class DeviceInfoCollector{ private String wifiMacFromNetworkInterfaces(){ try { - for(NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) { - if("wlan0".equalsIgnoreCase(networkInterface.getName())){ + for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) { + if ("wlan0".equalsIgnoreCase(networkInterface.getName())) { byte[] hardwareAddress = networkInterface.getHardwareAddress(); - if(hardwareAddress == null){ + if (hardwareAddress == null) { return null; } StringBuilder sb = new StringBuilder(); int length = hardwareAddress.length; - for(int i = 0; i < length; i++) { + for (int i = 0; i < length; i++) { sb.append(String.format("%02X:", Byte.valueOf(hardwareAddress[i]))); } - if(sb.length() > 0){ + if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); @@ -139,13 +139,13 @@ public class DeviceInfoCollector{ private String bluetoothMac(Context context){ String bluetoothMacFromAdapter = bluetoothMacFromAdapter(); - if(isInvalidMac(bluetoothMacFromAdapter)){ + if (isInvalidMac(bluetoothMacFromAdapter)) { bluetoothMacFromAdapter = bluetoothMacFromContentResolver(context); } - if(isInvalidMac(bluetoothMacFromAdapter)){ + if (isInvalidMac(bluetoothMacFromAdapter)) { bluetoothMacFromAdapter = null; } - if(bluetoothMacFromAdapter != null){ + if (bluetoothMacFromAdapter != null) { return bluetoothMacFromAdapter.toLowerCase(); } return null; @@ -154,16 +154,16 @@ public class DeviceInfoCollector{ private String bluetoothMacFromAdapter(){ try { BluetoothAdapter defaultAdapter = BluetoothAdapter.getDefaultAdapter(); - if(defaultAdapter == null){ + if (defaultAdapter == null) { return null; } - if(Build.VERSION.SDK_INT < 23){ + if (Build.VERSION.SDK_INT < 23) { return null; } Field declaredField = defaultAdapter.getClass().getDeclaredField("mService"); declaredField.setAccessible(true); Object obj = declaredField.get(defaultAdapter); - if(obj != null){ + if (obj != null) { return (String) obj.getClass().getMethod("getAddress").invoke(obj, new Object[0]); } return null; diff --git a/app/src/main/java/ru/vtosters/lite/dnr/DNRInjector.java b/app/src/main/java/ru/vtosters/lite/dnr/DNRInjector.java index 07db67fa8..1ed701c4c 100644 --- a/app/src/main/java/ru/vtosters/lite/dnr/DNRInjector.java +++ b/app/src/main/java/ru/vtosters/lite/dnr/DNRInjector.java @@ -16,13 +16,13 @@ public class DNRInjector{ public static void inject(Dialog dialog, List list){ int peerId = dialog.getId(); - if(isDnrEnabledFor(peerId)){ + if (isDnrEnabledFor(peerId)) { list.add(DialogAction.valueOf("DNR_OFF")); } else { list.add(DialogAction.valueOf("DNR_ON")); } - if(isDntEnabledFor(peerId)){ + if (isDntEnabledFor(peerId)) { list.add(DialogAction.valueOf("DNT_OFF")); } else { list.add(DialogAction.valueOf("DNT_ON")); @@ -40,18 +40,18 @@ public class DNRInjector{ public static boolean onClick(Dialog dialog, DialogAction action){ var id = dialog.getId(); - if(action == DialogAction.valueOf("DNR_ON")){ + if (action == DialogAction.valueOf("DNR_ON")) { setDnr(dialog, true); return true; - } else if(action == DialogAction.valueOf("DNR_OFF")){ + } else if (action == DialogAction.valueOf("DNR_OFF")) { setDnr(dialog, false); return true; } - if(action == DialogAction.valueOf("DNT_ON")){ + if (action == DialogAction.valueOf("DNT_ON")) { setDnt(dialog, true); return true; - } else if(action == DialogAction.valueOf("DNT_OFF")){ + } else if (action == DialogAction.valueOf("DNT_OFF")) { setDnt(dialog, false); return true; } diff --git a/app/src/main/java/ru/vtosters/lite/dnr/DNRModule.java b/app/src/main/java/ru/vtosters/lite/dnr/DNRModule.java index 1b4c6495e..b7a3c4594 100644 --- a/app/src/main/java/ru/vtosters/lite/dnr/DNRModule.java +++ b/app/src/main/java/ru/vtosters/lite/dnr/DNRModule.java @@ -41,12 +41,12 @@ public class DNRModule{ } public static boolean isDnrEnabledFor(Dialog dialog){ - if(dialog == null) return false; + if (dialog == null) return false; return isDnrEnabledFor(dialog.getId()); } public static boolean isDntEnabledFor(Dialog dialog){ - if(dialog == null) return false; + if (dialog == null) return false; return isDntEnabledFor(dialog.getId()); } diff --git a/app/src/main/java/ru/vtosters/lite/dnr/DNRPrefs.java b/app/src/main/java/ru/vtosters/lite/dnr/DNRPrefs.java index 220f6b6ec..7dd61f7a4 100644 --- a/app/src/main/java/ru/vtosters/lite/dnr/DNRPrefs.java +++ b/app/src/main/java/ru/vtosters/lite/dnr/DNRPrefs.java @@ -8,9 +8,9 @@ public class DNRPrefs{ } public static boolean getMarkAsReadWithoutExceptions(int peerId){ - if(readPM(peerId)) + if (readPM(peerId)) return true; - if(readConversations(peerId)) + if (readConversations(peerId)) return true; return readBots(peerId); } @@ -52,9 +52,9 @@ public class DNRPrefs{ } public static boolean getActivityWithoutExceptions(int peerId){ - if(writePM(peerId)) + if (writePM(peerId)) return true; - if(writeConversations(peerId)) + if (writeConversations(peerId)) return true; return writeBots(peerId); } diff --git a/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotReadDBHelper.java b/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotReadDBHelper.java index e7fe3d20d..221b0bde1 100644 --- a/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotReadDBHelper.java +++ b/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotReadDBHelper.java @@ -29,12 +29,12 @@ public class DoNotReadDBHelper extends SQLiteOpenHelper{ public boolean isEnabledForPeerId(int peerId){ try (Cursor c = getReadableDatabase().query("dnr", null, null, null, null, null, null)) { - if(c.moveToFirst()){ + if (c.moveToFirst()) { int peerIdIndex = c.getColumnIndex("peerId"); int enabledIndex = c.getColumnIndex("enabled"); do { - if(c.getInt(peerIdIndex) == peerId) + if (c.getInt(peerIdIndex) == peerId) return c.getInt(enabledIndex) == 1; } while(c.moveToNext()); } @@ -49,12 +49,12 @@ public class DoNotReadDBHelper extends SQLiteOpenHelper{ ArrayList rs = new ArrayList<>(); try (Cursor c = getReadableDatabase().query("dnr", null, null, null, null, null, null)) { - if(c.moveToFirst()){ + if (c.moveToFirst()) { int peerIdIndex = c.getColumnIndex("peerId"); int enabledIndex = c.getColumnIndex("enabled"); do { - if(c.getInt(enabledIndex) == 1){ + if (c.getInt(enabledIndex) == 1) { rs.add(c.getInt(peerIdIndex)); } } while(c.moveToNext()); @@ -71,7 +71,7 @@ public class DoNotReadDBHelper extends SQLiteOpenHelper{ cv.put("enabled", enabled ? 1 : 0); int i = getWritableDatabase().update("dnr", cv, "peerId = " + peerId, null); - if(i == 0){ + if (i == 0) { cv.put("peerId", peerId); getWritableDatabase().insert("dnr", null, cv); } diff --git a/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotTypeDBHelper.java b/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotTypeDBHelper.java index d7be777a2..8fdea5066 100644 --- a/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotTypeDBHelper.java +++ b/app/src/main/java/ru/vtosters/lite/dnr/helpers/DoNotTypeDBHelper.java @@ -31,12 +31,12 @@ public class DoNotTypeDBHelper extends SQLiteOpenHelper{ ArrayList rs = new ArrayList<>(); try (Cursor c = getReadableDatabase().query("dnt", null, null, null, null, null, null)) { - if(c.moveToFirst()){ + if (c.moveToFirst()) { int peerIdIndex = c.getColumnIndex("peerId"); int enabledIndex = c.getColumnIndex("enabled"); do { - if(c.getInt(enabledIndex) == 1){ + if (c.getInt(enabledIndex) == 1) { rs.add(c.getInt(peerIdIndex)); } } while(c.moveToNext()); @@ -50,12 +50,12 @@ public class DoNotTypeDBHelper extends SQLiteOpenHelper{ public boolean isEnabledForPeerId(int peerId){ try (Cursor c = getReadableDatabase().query("dnt", null, null, null, null, null, null)) { - if(c.moveToFirst()){ + if (c.moveToFirst()) { int peerIdIndex = c.getColumnIndex("peerId"); int enabledIndex = c.getColumnIndex("enabled"); do { - if(c.getInt(peerIdIndex) == peerId) + if (c.getInt(peerIdIndex) == peerId) return c.getInt(enabledIndex) == 1; } while(c.moveToNext()); } @@ -71,7 +71,7 @@ public class DoNotTypeDBHelper extends SQLiteOpenHelper{ cv.put("enabled", enabled ? 1 : 0); int i = getWritableDatabase().update("dnt", cv, "peerId = " + peerId, null); - if(i == 0){ + if (i == 0) { cv.put("peerId", peerId); getWritableDatabase().insert("dnt", null, cv); } diff --git a/app/src/main/java/ru/vtosters/lite/downloaders/AudioDownloader.java b/app/src/main/java/ru/vtosters/lite/downloaders/AudioDownloader.java index 6b269da0b..4649c242d 100644 --- a/app/src/main/java/ru/vtosters/lite/downloaders/AudioDownloader.java +++ b/app/src/main/java/ru/vtosters/lite/downloaders/AudioDownloader.java @@ -1,7 +1,5 @@ package ru.vtosters.lite.downloaders; -import android.app.NotificationChannel; -import android.app.NotificationManager; import android.os.Environment; import android.util.Log; @@ -19,10 +17,10 @@ import ru.vtosters.lite.music.FFMpeg; import ru.vtosters.lite.music.M3UDownloader; import ru.vtosters.lite.utils.Globals; -public class AudioDownloader { +public class AudioDownloader{ private static NotificationManagerCompat notificationManager = NotificationManagerCompat.from(Globals.getContext()); - public static void downloadAudio(MusicTrack track) { + public static void downloadAudio(MusicTrack track){ if (track.D == null) { ToastUtils.a("Не удалось найти ссылку на аудиозапись"); return; @@ -32,15 +30,15 @@ public class AudioDownloader { var downloadPath = musicPath + File.separator + tempId; var notification = buildDownloadNotification(track, tempId); - downloadM3U8(track, downloadPath, new Callback() { + downloadM3U8(track, downloadPath, new Callback(){ @Override - public void onProgress(int progress) { + public void onProgress(int progress){ notification.setProgress(100, progress, false); notificationManager.notify(tempId, notification.build()); } @Override - public void onSuccess() { + public void onSuccess(){ try { var fileName = track.toString(); var success = FFMpeg.convert(downloadPath, musicPath + File.separator + fileName + ".mp3"); @@ -53,28 +51,27 @@ public class AudioDownloader { } else { onFailure(); } - } - catch (UnsatisfiedLinkError e) { - Log.e("AudioDownloader","Опять эти нативные либы"); + } catch (UnsatisfiedLinkError e) { + Log.e("AudioDownloader", "Опять эти нативные либы"); Log.e("AudioDownloader", e.getMessage()); onFailure(); } } @Override - public void onFailure() { + public void onFailure(){ notification.setContentText("Не удалось загрузить аудиозапись").setProgress(0, 0, false); notificationManager.notify(tempId, notification.build()); } @Override - public void onSizeReceived(long size, long header) { + public void onSizeReceived(long size, long header){ } }); } - private static void downloadM3U8(MusicTrack track, String path, Callback callback) { + private static void downloadM3U8(MusicTrack track, String path, Callback callback){ File outDir = new File(path); if (!outDir.exists()) if (outDir.mkdir()) @@ -85,7 +82,7 @@ public class AudioDownloader { new M3UDownloader(track.D, outDir, callback).execute(); } - private static NotificationCompat.Builder buildDownloadNotification(MusicTrack track, int id) { + private static NotificationCompat.Builder buildDownloadNotification(MusicTrack track, int id){ var notificationBuilder = new NotificationCompat.Builder(Globals.getContext(), "music_downloads") .setSmallIcon(android.R.drawable.stat_sys_download) .setContentTitle("Загрузка аудиозаписи") diff --git a/app/src/main/java/ru/vtosters/lite/downloaders/OTADownloader.java b/app/src/main/java/ru/vtosters/lite/downloaders/OTADownloader.java index e77f07b46..76801b376 100644 --- a/app/src/main/java/ru/vtosters/lite/downloaders/OTADownloader.java +++ b/app/src/main/java/ru/vtosters/lite/downloaders/OTADownloader.java @@ -23,7 +23,7 @@ public class OTADownloader{ @Override public void onReceive(Context context, Intent intent){ var extras = intent.getExtras(); - if(extras == null || !intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) + if (extras == null || !intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) return; var query = new DownloadManager.Query(); @@ -31,23 +31,23 @@ public class OTADownloader{ query.setFilterById(id); var manager = (DownloadManager) Globals.getContext().getSystemService(Context.DOWNLOAD_SERVICE); var cursor = manager.query(query); - if(cursor.moveToFirst()){ + if (cursor.moveToFirst()) { @SuppressLint("Range") var status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)); - if(status == DownloadManager.STATUS_SUCCESSFUL){ + if (status == DownloadManager.STATUS_SUCCESSFUL) { var downloadDir = new File(Environment.getExternalStorageDirectory(), "Download"); - if(!downloadDir.exists()) return; + if (!downloadDir.exists()) return; var list = downloadDir.listFiles(); - if(list == null || list.length == 0) return; + if (list == null || list.length == 0) return; var maxIndex = -1; - for(File file : list) { + for (File file : list) { var name = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf("/") + 1); - if(file.isFile() + if (file.isFile() && name.matches("VTLite-\\d+\\.apk")) maxIndex = Math.max(maxIndex, Integer.parseInt(name.replaceFirst(".+-(\\d+).+", "$1"))); } File apk = maxIndex == -1 ? new File(downloadDir, "VTLite.apk") : new File(downloadDir, "VTLite-" + maxIndex + ".apk"); APKInstallActivity.installOta(context, FileUtils.n(apk)); - } else if(status == DownloadManager.STATUS_FAILED){ + } else if (status == DownloadManager.STATUS_FAILED) { Globals.sendToast(getString("downloaderr")); } } diff --git a/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java b/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java index d686a114f..80be9d8c8 100644 --- a/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java +++ b/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java @@ -16,7 +16,7 @@ public class StoryDownloader{ public static Runnable injectButton(StoryEntry story){ return () -> { // if story is a pic - if(story.T1()){ + if (story.T1()) { List imageSizes = story.E.Q.t1(); String url = imageSizes.get(imageSizes.size() - 1).url; DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); @@ -28,7 +28,7 @@ public class StoryDownloader{ } // if story is a video - if(story.F != null){ + if (story.F != null) { downloadVideo(story.F, null); } }; diff --git a/app/src/main/java/ru/vtosters/lite/downloaders/VideoDownloader.java b/app/src/main/java/ru/vtosters/lite/downloaders/VideoDownloader.java index a2f13d0d5..bc9bedcf0 100644 --- a/app/src/main/java/ru/vtosters/lite/downloaders/VideoDownloader.java +++ b/app/src/main/java/ru/vtosters/lite/downloaders/VideoDownloader.java @@ -29,7 +29,7 @@ public class VideoDownloader{ private static final int action_id = 1488; public static boolean onClick(int id, VideoFile video, Context ctx){ - if(id == action_id){ + if (id == action_id) { downloadVideo(video, ctx); return true; } @@ -37,7 +37,7 @@ public class VideoDownloader{ } public static void injectAction(ArrayList list, VideoFile video){ - if(!video.U && !video.I1()){ + if (!video.U && !video.I1()) { MenuBottomSheetAction downloadAction = new MenuBottomSheetAction( action_id, com.vtosters.lite.R.drawable.ic_download_outline_24, @@ -52,47 +52,47 @@ public class VideoDownloader{ final List list = new ArrayList<>(); final List urls = new ArrayList<>(); - if(!Objects.equals(videoFile.e, "")){ + if (!Objects.equals(videoFile.e, "")) { list.add("240p"); urls.add(videoFile.e); } - if(!Objects.equals(videoFile.f, "")){ + if (!Objects.equals(videoFile.f, "")) { list.add("360p"); urls.add(videoFile.f); } - if(!Objects.equals(videoFile.g, "")){ + if (!Objects.equals(videoFile.g, "")) { list.add("480p"); urls.add(videoFile.g); } - if(!Objects.equals(videoFile.h, "")){ + if (!Objects.equals(videoFile.h, "")) { list.add("720p"); urls.add(videoFile.h); } - if(!Objects.equals(videoFile.B, "")){ + if (!Objects.equals(videoFile.B, "")) { list.add("1080p"); urls.add(videoFile.B); } - if(!Objects.equals(videoFile.C, "")){ + if (!Objects.equals(videoFile.C, "")) { list.add("1440p"); urls.add(videoFile.C); } - if(!Objects.equals(videoFile.D, "")){ + if (!Objects.equals(videoFile.D, "")) { list.add("2160p"); urls.add(videoFile.D); } - if(list.isEmpty()){ + if (list.isEmpty()) { ToastUtils.a(getString("videodownloaderr")); return; } var max = new String[list.size()]; - for(int i = 0; i < list.size(); i++) { + for (int i = 0; i < list.size(); i++) { max[i] = list.get(i); } - if(context == null){ + if (context == null) { var url = urls.get(urls.size() - 1); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); @@ -116,12 +116,12 @@ public class VideoDownloader{ } public static void parseVideoLink(String url, Context ctx){ - if(url.contains("vk.com/story")){ + if (url.contains("vk.com/story")) { ToastUtils.a("Не поддерживается загрузка историй"); return; } - if(!url.contains("vk.com/video")){ + if (!url.contains("vk.com/video")) { ToastUtils.a("Неверная ссылка"); return; } diff --git a/app/src/main/java/ru/vtosters/lite/encryption/EncryptProvider.java b/app/src/main/java/ru/vtosters/lite/encryption/EncryptProvider.java index ae6aa1d7f..3b29a562e 100644 --- a/app/src/main/java/ru/vtosters/lite/encryption/EncryptProvider.java +++ b/app/src/main/java/ru/vtosters/lite/encryption/EncryptProvider.java @@ -33,8 +33,8 @@ public class EncryptProvider{ public static IMProcessor getProcessorFor(int peerId){ IMProcessor enabled = null; - for(IMProcessor processor : EncryptProvider.processors) { - if(processor.isUsedToEncrypt(peerId)){ + for (IMProcessor processor : EncryptProvider.processors) { + if (processor.isUsedToEncrypt(peerId)) { enabled = processor; } } @@ -56,8 +56,8 @@ public class EncryptProvider{ public static String decryptMessage(String msgBody, int peer){ try { - for(IMProcessor processor : processors) { - if((processor.isUsed() || !processor.isPublic()) && processor.isEncrypted(msgBody) && (processor.isPublic() || getKeyForProcessor(processor, peer) != null)) + for (IMProcessor processor : processors) { + if ((processor.isUsed() || !processor.isPublic()) && processor.isEncrypted(msgBody) && (processor.isPublic() || getKeyForProcessor(processor, peer) != null)) return "\uD83D\uDD12 " + processor.decode(msgBody, getKeyForProcessor(processor, peer)); } } catch (Exception e) { @@ -67,9 +67,9 @@ public class EncryptProvider{ } private static byte[] getKeyForProcessor(IMProcessor processor, int peer){ - if(processor.isPublic()) return null; + if (processor.isPublic()) return null; String keyString = processor.getEncryptionKeyFor(peer); - if(keyString == null) return null; + if (keyString == null) return null; try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); @@ -93,9 +93,9 @@ public class EncryptProvider{ Log.d("EncryptProvider", "encryptMessage: body = " + msgBody); Log.d("EncryptProvider", "encryptMessage: peerId = " + getPeerId(msg)); - for(IMProcessor processor : processors) { + for (IMProcessor processor : processors) { int peer = getPeerId(msg); - if(processor.isUsedToEncrypt(peer)){ + if (processor.isUsedToEncrypt(peer)) { return processor.encode(msgBody, getKeyForProcessor(processor, peer)); } } @@ -107,8 +107,8 @@ public class EncryptProvider{ public static List> getUserVisibleEncoders(){ List> theList = new ArrayList<>(); - for(IMProcessor processor : processors) { - if(processor.isPublic()) + for (IMProcessor processor : processors) { + if (processor.isPublic()) theList.add(new Pair<>("VT_IMDecode_" + processor.getPrefKey(), processor.getUIName())); } diff --git a/app/src/main/java/ru/vtosters/lite/encryption/base/IMProcessor.java b/app/src/main/java/ru/vtosters/lite/encryption/base/IMProcessor.java index 29b98aded..9f07c3805 100644 --- a/app/src/main/java/ru/vtosters/lite/encryption/base/IMProcessor.java +++ b/app/src/main/java/ru/vtosters/lite/encryption/base/IMProcessor.java @@ -75,7 +75,7 @@ public abstract class IMProcessor{ } public void setEncryptionKeyFor(int id, @Nullable String key){ - if(key == null || key.isEmpty()) key = "VTAesDefault"; + if (key == null || key.isEmpty()) key = "VTAesDefault"; Globals.getDefprefs().edit().putString("VT_IMEncodeKey_" + getPrefKey() + "_" + id, key).apply(); } diff --git a/app/src/main/java/ru/vtosters/lite/encryption/processors/BeeCryptProcessor.java b/app/src/main/java/ru/vtosters/lite/encryption/processors/BeeCryptProcessor.java index 250630c67..b93b7a644 100644 --- a/app/src/main/java/ru/vtosters/lite/encryption/processors/BeeCryptProcessor.java +++ b/app/src/main/java/ru/vtosters/lite/encryption/processors/BeeCryptProcessor.java @@ -18,10 +18,10 @@ public class BeeCryptProcessor extends IMProcessor{ try { String a = Base64.encodeToString(source.getBytes(StandardCharsets.UTF_8), 2); StringBuilder res = new StringBuilder(); - for(int i = 0; i < a.length(); i++) { + for (int i = 0; i < a.length(); i++) { StringBuilder bintxt = new StringBuilder(); int c = a.charAt(i); - for(int j = 0; j < 4; j++) { + for (int j = 0; j < 4; j++) { bintxt.insert(0, BC_CHARSET.charAt(c % 4)); c /= 4; } @@ -48,7 +48,7 @@ public class BeeCryptProcessor extends IMProcessor{ try { String bintxt = source.substring(i, i + 4); int c = 0; - for(int j = 0; j < 4; j++) { + for (int j = 0; j < 4; j++) { c = (c * 4) + Math.max(0, BC_CHARSET.indexOf(bintxt.charAt(j))); } b64.append((char) c); diff --git a/app/src/main/java/ru/vtosters/lite/encryption/processors/DefaultCoffeeProcessor.java b/app/src/main/java/ru/vtosters/lite/encryption/processors/DefaultCoffeeProcessor.java index 7a7fb918f..3f891788b 100644 --- a/app/src/main/java/ru/vtosters/lite/encryption/processors/DefaultCoffeeProcessor.java +++ b/app/src/main/java/ru/vtosters/lite/encryption/processors/DefaultCoffeeProcessor.java @@ -31,9 +31,9 @@ public class DefaultCoffeeProcessor extends IMProcessor{ private String toHex(String text){ char[] chars = text.toCharArray(); StringBuilder str = new StringBuilder(); - for(char aChar : chars) { + for (char aChar : chars) { String s = Integer.toHexString(aChar); - if(s.length() < 2) s = "0" + s; + if (s.length() < 2) s = "0" + s; str.append(s.toUpperCase()).append(" "); } @@ -45,7 +45,7 @@ public class DefaultCoffeeProcessor extends IMProcessor{ text = text.replace(" ", ""); char[] chars = text.toCharArray(); char[] chars2 = new char[chars.length / 2]; - for(int i = 0; i < chars.length; i += 2) { + for (int i = 0; i < chars.length; i += 2) { String c = String.valueOf(chars[i]) + chars[i + 1]; chars2[i / 2] = (char) Integer.parseInt(c, 16); } diff --git a/app/src/main/java/ru/vtosters/lite/encryption/processors/MP3InvisibleProcessor.java b/app/src/main/java/ru/vtosters/lite/encryption/processors/MP3InvisibleProcessor.java index 00e9bb57a..d53b379b9 100644 --- a/app/src/main/java/ru/vtosters/lite/encryption/processors/MP3InvisibleProcessor.java +++ b/app/src/main/java/ru/vtosters/lite/encryption/processors/MP3InvisibleProcessor.java @@ -21,7 +21,7 @@ public class MP3InvisibleProcessor extends IMProcessor{ private static int toNum(String a, String cc){ int n = 0; - for(int i = 0; i < a.length(); i++) { + for (int i = 0; i < a.length(); i++) { int start = (a.length() - i) - 1; n = (int) (((double) n) + (((double) cc.indexOf(a.substring(start, start + 1))) * Math.pow(cc.length(), i))); } @@ -34,7 +34,7 @@ public class MP3InvisibleProcessor extends IMProcessor{ try { byte[] bytes = source.getBytes(StandardCharsets.UTF_8); java.lang.String[] plainText = new String[bytes.length]; - for(int i = 0; i < plainText.length; i++) { + for (int i = 0; i < plainText.length; i++) { plainText[i] = toStr(bytes[i] & 255, " ​‌‏ "); } return "  " + TextUtils.join(" ", plainText); @@ -50,7 +50,7 @@ public class MP3InvisibleProcessor extends IMProcessor{ try { java.lang.String[] t = source.replaceAll("^" + "  ", "").split(" "); byte[] plainText = new byte[t.length]; - for(int i = 0; i < plainText.length; i++) { + for (int i = 0; i < plainText.length; i++) { plainText[i] = (byte) toNum(t[i], " ​‌‏ "); } return new String(plainText, StandardCharsets.UTF_8); diff --git a/app/src/main/java/ru/vtosters/lite/encryption/processors/VTostersAESProcessor.java b/app/src/main/java/ru/vtosters/lite/encryption/processors/VTostersAESProcessor.java index c8c97d209..9d8214ba5 100644 --- a/app/src/main/java/ru/vtosters/lite/encryption/processors/VTostersAESProcessor.java +++ b/app/src/main/java/ru/vtosters/lite/encryption/processors/VTostersAESProcessor.java @@ -33,7 +33,7 @@ public class VTostersAESProcessor extends IMProcessor{ @NonNull private Cipher wrapEncoder(byte[] key) throws InvalidAlgorithmParameterException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException{ - if(encodeMap.containsKey(key)) return encodeMap.get(key); + if (encodeMap.containsKey(key)) return encodeMap.get(key); Triple encodeCipher = getBaseCipher(key); encodeCipher.first.init(Cipher.ENCRYPT_MODE, encodeCipher.second, encodeCipher.third); @@ -44,7 +44,7 @@ public class VTostersAESProcessor extends IMProcessor{ @NonNull private Cipher wrapDecoder(byte[] key) throws InvalidAlgorithmParameterException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException{ - if(decodeMap.containsKey(key)) return decodeMap.get(key); + if (decodeMap.containsKey(key)) return decodeMap.get(key); Triple decodeCipher = getBaseCipher(key); decodeCipher.first.init(Cipher.DECRYPT_MODE, decodeCipher.second, decodeCipher.third); diff --git a/app/src/main/java/ru/vtosters/lite/f0x1d/Crashreporter.java b/app/src/main/java/ru/vtosters/lite/f0x1d/Crashreporter.java index 38a9dea9e..c85bd7faa 100644 --- a/app/src/main/java/ru/vtosters/lite/f0x1d/Crashreporter.java +++ b/app/src/main/java/ru/vtosters/lite/f0x1d/Crashreporter.java @@ -37,7 +37,7 @@ public class Crashreporter{ static void start(Thread.UncaughtExceptionHandler uncaughtExceptionHandler, Thread thread, Throwable th, Activity activity){ logString = getStackTrace(th) + "\n\n" + new DeviceInfoCollector().collect(getContext()).toDeviceName() + ", commit: " + getBuildNumber(); - if(Build.VERSION.SDK_INT >= 26){ + if (Build.VERSION.SDK_INT >= 26) { var notificationChannel = new NotificationChannel("crashes", "crash", NotificationManager.IMPORTANCE_DEFAULT); notificationChannel.enableVibration(true); notificationChannel.enableLights(true); @@ -47,7 +47,7 @@ public class Crashreporter{ var foxbinIntent = new Intent("com.f0x1d.dogbin.ACTION_UPLOAD_TO_FOXBIN"); foxbinIntent.putExtra("android.intent.extra.TEXT", logString); foxbinIntent.setType("text/plain"); - if(!isFoxbinInstalled()){ + if (!isFoxbinInstalled()) { foxbinIntent = new Intent("android.intent.action.VIEW"); foxbinIntent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.f0x1d.dogbin")); foxbinIntent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); @@ -64,14 +64,14 @@ public class Crashreporter{ builder.setContentText(logString); builder.setStyle(new Notification.BigTextStyle().bigText(logString)); 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, getString("vtl_crash_upload"), PendingIntent.getActivity(getContext(), (int) (Math.random() * 100.0d), foxbinIntent, PendingIntent.FLAG_CANCEL_CURRENT))); builder.addAction(new Notification.Action(0, getString("vtl_crash_save"), psaveLogIntent)); } else { builder.setContentIntent(PendingIntent.getActivity(activity, 0, foxbinIntent, PendingIntent.FLAG_ONE_SHOT)); } - if(Build.VERSION.SDK_INT >= 26){ + if (Build.VERSION.SDK_INT >= 26) { builder.setChannelId("crashes"); } diff --git a/app/src/main/java/ru/vtosters/lite/f0x1d/LogWriterService.java b/app/src/main/java/ru/vtosters/lite/f0x1d/LogWriterService.java index 5bec8f0a5..619814e82 100644 --- a/app/src/main/java/ru/vtosters/lite/f0x1d/LogWriterService.java +++ b/app/src/main/java/ru/vtosters/lite/f0x1d/LogWriterService.java @@ -32,7 +32,7 @@ public class LogWriterService extends Service{ try { var exists = file.createNewFile(); - if(!exists){ + if (!exists) { file.delete(); file.createNewFile(); } diff --git a/app/src/main/java/ru/vtosters/lite/f0x1d/VTVerifications.java b/app/src/main/java/ru/vtosters/lite/f0x1d/VTVerifications.java index e39cf31fc..aea7a1e67 100644 --- a/app/src/main/java/ru/vtosters/lite/f0x1d/VTVerifications.java +++ b/app/src/main/java/ru/vtosters/lite/f0x1d/VTVerifications.java @@ -26,16 +26,16 @@ import okhttp3.Response; import ru.vtosters.lite.utils.Globals; public class VTVerifications{ - private static final OkHttpClient sClient = new OkHttpClient(); public static final List sVerifications = new ArrayList<>(); public static final List sPrometheuses = new ArrayList<>(); public static final List sDevelopers = new ArrayList<>(); public static final List sServiceAccounts = new ArrayList<>(); + private static final OkHttpClient sClient = new OkHttpClient(); public static void load(Context context){ var prefs = context.getSharedPreferences("vt_another_data", 0); - if(!Globals.isNetworkConnected() && prefs.contains("ids")){ + if (!Globals.isNetworkConnected() && prefs.contains("ids")) { parseJson(prefs.getString("ids", "[]")); return; } @@ -87,10 +87,10 @@ public class VTVerifications{ } private static void processIds(JSONArray jsonIds, List member){ - if(jsonIds == null || jsonIds.length() == 0) + if (jsonIds == null || jsonIds.length() == 0) return; - for(int i = 0; i < jsonIds.length(); i++) + for (int i = 0; i < jsonIds.length(); i++) member.add(jsonIds.optInt(i)); } @@ -116,7 +116,7 @@ public class VTVerifications{ private static int getId(JSONObject json){ var id = json.optInt("id", 0); - if(!json.optString(NavigatorKeys.e).equals("group") && !json.optString(NavigatorKeys.e).equals("page") + if (!json.optString(NavigatorKeys.e).equals("group") && !json.optString(NavigatorKeys.e).equals("page") || json.optString(NavigatorKeys.e).isEmpty()) return id; else @@ -124,11 +124,11 @@ public class VTVerifications{ } public static boolean isVerified(JSONObject jSONObject){ - if(jSONObject.optInt("verified", 0) == 1){ + if (jSONObject.optInt("verified", 0) == 1) { return true; } - if(!getBoolValue("VT_Verification", true)){ + if (!getBoolValue("VT_Verification", true)) { return false; } @@ -136,11 +136,11 @@ public class VTVerifications{ } public static boolean hasPrometheus(JSONObject jSONObject){ - if(jSONObject.optInt("trending", 0) == 1){ + if (jSONObject.optInt("trending", 0) == 1) { return true; } - if(!getBoolValue("VT_Fire", true)){ + if (!getBoolValue("VT_Fire", true)) { return false; } @@ -148,7 +148,7 @@ public class VTVerifications{ } public static boolean hasDeveloper(JSONObject jSONObject){ - if(!getBoolValue("VT_Dev", true)){ + if (!getBoolValue("VT_Dev", true)) { return false; } diff --git a/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java b/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java index 8f912b122..f2af90bbf 100644 --- a/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java +++ b/app/src/main/java/ru/vtosters/lite/foaf/FoafBase.java @@ -34,13 +34,13 @@ public class FoafBase{ private static final OkHttpClient client = new OkHttpClient(); public static long getLastSeen(long origtime, int id) throws ParseException, IOException{ - if(!Preferences.foaf()) return origtime; + if (!Preferences.foaf()) return origtime; Matcher matcher = FOAF_REGEX_LAST_SEEN.matcher( client.a( new okhttp3.Request.a().a(getLink(id)).b().a() ).execute().a().g()); - if(!matcher.find()){ + if (!matcher.find()) { return origtime; } return new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:ss", Locale.getDefault()).parse(matcher.group(1)).getTime() / 1000; @@ -49,7 +49,7 @@ public class FoafBase{ private static String getLink(int i){ String str; StringBuilder sb; - if(apiproxy()){ + if (apiproxy()) { sb = new StringBuilder(); str = "https://" + getApi() + "/_/vk.com/foaf.php?id="; } else { diff --git a/app/src/main/java/ru/vtosters/lite/music/FFMpeg.java b/app/src/main/java/ru/vtosters/lite/music/FFMpeg.java index 78f311352..4cf957fc7 100644 --- a/app/src/main/java/ru/vtosters/lite/music/FFMpeg.java +++ b/app/src/main/java/ru/vtosters/lite/music/FFMpeg.java @@ -13,9 +13,10 @@ import java.io.InputStream; import ru.vtosters.lite.utils.Globals; -public class FFMpeg { +public class FFMpeg{ private static final int BUFFER_SIZE = 2048; - private static void copyAssets() { + + private static void copyAssets(){ try { String[] files = Globals.getContext().getAssets().list("ffmpeg"); for (String file : files) { @@ -24,7 +25,7 @@ public class FFMpeg { FileOutputStream out = new FileOutputStream(Globals.getContext().getFilesDir() + File.separator + file); byte[] buffer = new byte[BUFFER_SIZE]; int read; - while ((read = in.read(buffer)) != -1) { + while((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } in.close(); @@ -36,7 +37,7 @@ public class FFMpeg { } } - private static void checkFFMpegLibs() { + private static void checkFFMpegLibs(){ var lib = new File(Globals.getContext().getFilesDir(), "libffmpegkit_abidetect.so"); if (!lib.exists()) { ToastUtils.a("Копирование библиотеки ffmpegkit"); @@ -44,7 +45,7 @@ public class FFMpeg { } } - public static boolean convert(String in, String out) { + public static boolean convert(String in, String out){ checkFFMpegLibs(); // write the list of all .ts files to a txt file in "in" directory @@ -81,7 +82,7 @@ public class FFMpeg { } } - private static void deleteRecursively(File fileOrDirectory) { + private static void deleteRecursively(File fileOrDirectory){ if (fileOrDirectory.isDirectory()) for (File child : fileOrDirectory.listFiles()) deleteRecursively(child); fileOrDirectory.delete(); diff --git a/app/src/main/java/ru/vtosters/lite/music/M3UDownloader.java b/app/src/main/java/ru/vtosters/lite/music/M3UDownloader.java index f2ed04527..2c31af0be 100644 --- a/app/src/main/java/ru/vtosters/lite/music/M3UDownloader.java +++ b/app/src/main/java/ru/vtosters/lite/music/M3UDownloader.java @@ -18,14 +18,13 @@ import okhttp3.Request; import okhttp3.Response; import ru.vtosters.lite.utils.StreamUtils; -public class M3UDownloader { - - private OkHttpClient mClient = new OkHttpClient(); - private VKM3UParser mParser; +public class M3UDownloader{ private final String mURL; private final File mOutDir; private final Callback mCallback; + private OkHttpClient mClient = new OkHttpClient(); + private VKM3UParser mParser; public M3UDownloader(String url, File outDir, Callback callback){ mURL = url; @@ -33,24 +32,24 @@ public class M3UDownloader { mCallback = callback; } - public void execute() { + public void execute(){ var request = new Request.a() .b(mURL) .a(); - mClient.a(request).a(new okhttp3.Callback() { + mClient.a(request).a(new okhttp3.Callback(){ @Override - public void a(Call call, IOException e) { + public void a(Call call, IOException e){ } @Override - public void a(Call call, Response response) throws IOException { + public void a(Call call, Response response) throws IOException{ parse(response.a().g()); } }); } - private void parse(String payload) { + private void parse(String payload){ try { VKM3UParser parser = new VKM3UParser(payload); List tses = parser.getTransportStreams(); @@ -71,7 +70,7 @@ public class M3UDownloader { mCallback.onSizeReceived((long) content.length * tses.size(), parser.getHeapSize()); mCallback.onProgress(10 + Math.round(80.0f * tses.indexOf(ts) / tses.size())); } - } catch (IOException | NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException e) { + } catch (IOException | NoSuchPaddingException | NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeyException e) { e.printStackTrace(); mCallback.onFailure(); return; diff --git a/app/src/main/java/ru/vtosters/lite/music/VKM3UParser.java b/app/src/main/java/ru/vtosters/lite/music/VKM3UParser.java index 2857da95b..b9e8c9247 100644 --- a/app/src/main/java/ru/vtosters/lite/music/VKM3UParser.java +++ b/app/src/main/java/ru/vtosters/lite/music/VKM3UParser.java @@ -24,12 +24,12 @@ public class VKM3UParser{ while(scanner.hasNext()) { String line = scanner.nextLine(); mHeapSize += line.getBytes().length; - if(line.startsWith("#EXT-X-TARGETDURATION")){ + if (line.startsWith("#EXT-X-TARGETDURATION")) { mDuration = Integer.parseInt(getDirectiveValue(line)); - } else if(line.startsWith("#EXT-X-KEY")){ + } else if (line.startsWith("#EXT-X-KEY")) { String base = getDirectiveValue(line); final TransportStream ts; - if(!base.startsWith("METHOD=NONE")){ + if (!base.startsWith("METHOD=NONE")) { String keyURL = base.substring(base.indexOf("\"") + 1, base.lastIndexOf("\"")); mBaseURL = keyURL.substring(0, keyURL.lastIndexOf("/") + 1); ts = new TransportStream(TransportStream.METHOD_AES128, keyURL); @@ -37,10 +37,10 @@ public class VKM3UParser{ ts = new TransportStream(); } mTransportStreams.add(ts); - } else if(line.startsWith("#EXTINF")){ - if(mTransportStreams.size() == i) + } else if (line.startsWith("#EXTINF")) { + if (mTransportStreams.size() == i) mTransportStreams.add(new TransportStream()); - } else if(line.endsWith(".ts") || line.endsWith(".tp") || line.endsWith(".mpeg-ts") || line.endsWith(".m2ts")){ + } else if (line.endsWith(".ts") || line.endsWith(".tp") || line.endsWith(".mpeg-ts") || line.endsWith(".m2ts")) { mTransportStreams.get(i).setName(line); ++i; } diff --git a/app/src/main/java/ru/vtosters/lite/net/NetCall.java b/app/src/main/java/ru/vtosters/lite/net/NetCall.java index b0607c355..6ba3f8373 100644 --- a/app/src/main/java/ru/vtosters/lite/net/NetCall.java +++ b/app/src/main/java/ru/vtosters/lite/net/NetCall.java @@ -27,8 +27,8 @@ public final class NetCall{ private static String constructArgs(Map args) throws UnsupportedEncodingException{ args = new TreeMap<>(args); String str = ""; - for(Map.Entry en : args.entrySet()) { - if(!str.isEmpty()) str += "&"; + for (Map.Entry en : args.entrySet()) { + if (!str.isEmpty()) str += "&"; str += URLEncoder.encode(en.getKey(), "UTF-8") + "=" + URLEncoder.encode(en.getValue(), "UTF-8"); } return str; @@ -42,18 +42,18 @@ public final class NetCall{ Proxy proxy = cl.getProxy(); PasswordAuthentication auth = cl.getAuthenticator(); HttpURLConnection con = (HttpURLConnection) new URL(req.url()).openConnection(proxy != null ? proxy : Proxy.NO_PROXY); - if(proxy != null && auth != null){ + if (proxy != null && auth != null) { String authStr = "Basic " + Base64.encodeToString((auth.getUserName() + new String(auth.getPassword())).getBytes(), Base64.NO_WRAP); con.setRequestProperty("Proxy-Connection", "Keep-Alive"); con.setRequestProperty("Proxy-Authorization", authStr); } con.setConnectTimeout((int) cl.getTimeout()); con.setRequestMethod(req.getRequestMethod()); - if(req.getRequestMethod().equals("POST")){ + if (req.getRequestMethod().equals("POST")) { con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); } Map params = req.getRequestParams(); - if(params != null){ + if (params != null) { String strArgs = constructArgs(params); con.setRequestProperty("Content-Length", String.valueOf(strArgs.getBytes(StandardCharsets.UTF_8).length)); con.setDoOutput(true); @@ -62,7 +62,7 @@ public final class NetCall{ } con.connect(); InputStream in; - if(con.getResponseCode() == 200) in = con.getInputStream(); + if (con.getResponseCode() == 200) in = con.getInputStream(); else in = con.getErrorStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024 * 1024]; diff --git a/app/src/main/java/ru/vtosters/lite/net/NetRequest.java b/app/src/main/java/ru/vtosters/lite/net/NetRequest.java index 42e2867d2..b7bfe9e33 100755 --- a/app/src/main/java/ru/vtosters/lite/net/NetRequest.java +++ b/app/src/main/java/ru/vtosters/lite/net/NetRequest.java @@ -56,7 +56,7 @@ public class NetRequest{ } public Builder param(String param, String value){ - if(params == null) params = new TreeMap<>(); + if (params == null) params = new TreeMap<>(); params.put(param, value); return this; } diff --git a/app/src/main/java/ru/vtosters/lite/net/Request.java b/app/src/main/java/ru/vtosters/lite/net/Request.java index 6b6718c0d..84e3decea 100644 --- a/app/src/main/java/ru/vtosters/lite/net/Request.java +++ b/app/src/main/java/ru/vtosters/lite/net/Request.java @@ -42,10 +42,10 @@ public class Request{ HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(new String(url)).openConnection(); httpURLConnection.setRequestMethod(mIsPut ? "PUT" : "GET"); - if(mIsVTostersRequest){ + if (mIsVTostersRequest) { httpURLConnection.setRequestProperty("Token", getUserToken()); } - if(!mIsVTostersRequest){ + if (!mIsVTostersRequest) { httpURLConnection.setRequestProperty("User-Agent", Network.l.c().a()); } @@ -55,7 +55,7 @@ public class Request{ StringBuffer stringBuffer = new StringBuffer(); while(true) { String readLine = bufferedReader.readLine(); - if(readLine != null){ + if (readLine != null) { stringBuffer.append(readLine); } else { bufferedReader.close(); diff --git a/app/src/main/java/ru/vtosters/lite/tgs/TGRoot.java b/app/src/main/java/ru/vtosters/lite/tgs/TGRoot.java index 5ddba6df7..2278ba9b9 100644 --- a/app/src/main/java/ru/vtosters/lite/tgs/TGRoot.java +++ b/app/src/main/java/ru/vtosters/lite/tgs/TGRoot.java @@ -42,14 +42,14 @@ public class TGRoot{ public static Attachment processSticker(StickerItem item){ int id = item.getId(); - if(id < N) return null; + if (id < N) return null; int index = (id - N) / 120; int stickerId = (id - N) % 120; TelegramStickersPack pack = null; - for(TelegramStickersPack p : TelegramStickersService.getInstance(getContext()).getActivePacksListReference()) { - if(p.index == index){ + for (TelegramStickersPack p : TelegramStickersService.getInstance(getContext()).getActivePacksListReference()) { + if (p.index == index) { pack = p; break; } @@ -70,7 +70,7 @@ public class TGRoot{ public static void injectStickers(List list){ try { List 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))); } catch (Exception e) { e.printStackTrace(); @@ -78,18 +78,18 @@ public class TGRoot{ } public static StickerStockItem getPackBySticker(int stickerId){ - if(stickerId < N) return null; + if (stickerId < N) return null; int index = (stickerId - N) / 120; TelegramStickersPack p = null; - for(TelegramStickersPack p_ : TelegramStickersService.getInstance(getContext()) + for (TelegramStickersPack p_ : TelegramStickersService.getInstance(getContext()) .getActivePacksListReference()) { - if(p_.index == index){ + if (p_.index == index) { p = p_; break; } } - if(p == null) return null; + if (p == null) return null; try { return toStickerPack(p); @@ -102,7 +102,7 @@ public class TGRoot{ private static StickerStockItem toStickerPack(TelegramStickersPack p) throws JSONException{ JSONArray arr = new JSONArray(); - for(int j = 0; j < p.stickersCount; j++) + for (int j = 0; j < p.stickersCount; j++) arr.put(new JSONObject().put("sticker_id", N + p.index * 120 + j) .put("images", new JSONArray() .put(new JSONObject() @@ -144,7 +144,7 @@ public class TGRoot{ } public static Attach modifyStickerIM(int i, StickerItem stickerItem, String str){ - if(stickerItem.getId() < 76820000){ + if (stickerItem.getId() < 76820000) { return AppAttachToImAttachConverter.a.a(i, stickerItem, str); } return AppAttachToImAttachConverter.a.a(processSticker(stickerItem)); diff --git a/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java b/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java index 97d3885c7..3bf607d45 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java +++ b/app/src/main/java/ru/vtosters/lite/ui/PreferencesUtil.java @@ -2,7 +2,6 @@ package ru.vtosters.lite.ui; import static ru.vtosters.lite.utils.Globals.convertDpToPixel; import static ru.vtosters.lite.utils.Globals.getContext; -import static ru.vtosters.lite.utils.Themes.*; import static ru.vtosters.lite.utils.Themes.getAccentColor; import static ru.vtosters.lite.utils.Themes.getAlertStyle; import static ru.vtosters.lite.utils.Themes.getSTextAttr; @@ -31,8 +30,6 @@ import com.vtosters.lite.ui.MaterialSwitchPreference; import java.util.Objects; -import ru.vtosters.lite.utils.Themes; - public class PreferencesUtil{ public static Drawable setTint(Context ctx, Drawable d){ @@ -60,7 +57,7 @@ public class PreferencesUtil{ preference.setDialogTitle(title); // setDialogTitle preference.setKey(key); // setKey preference.setDefaultValue(def); // setDefaultValue - if(icon != null) + if (icon != null) preference.setIcon(setTint(getContext(), getDrawable(getContext(), icon))); // preference.setIcon fragment.getPreferenceScreen().addPreference(preference); // fragment.getPreferenceScreen().addPreference(preference) } @@ -83,7 +80,7 @@ public class PreferencesUtil{ materialSwitchPreference.setDefaultValue(defValue); // setDefaultValue materialSwitchPreference.setOnPreferenceChangeListener(listener); // setOnPreferenceClickListener - if(icon != 1) + if (icon != 1) materialSwitchPreference.setIcon(setTint(getContext(), Objects.requireNonNull(ContextCompat.getDrawable(getContext(), icon)))); // preference.setIcon fragment.getPreferenceScreen().addPreference(materialSwitchPreference); // fragment.getPreferenceScreen().addPreference(preference) @@ -97,7 +94,7 @@ public class PreferencesUtil{ materialSwitchPreference.setDefaultValue(defValue); // setDefaultValue fragment.getPreferenceScreen().addPreference(materialSwitchPreference); // materialPreferenceToolbarFragment.getPreferenceScreen().addPreference(preference) - if(icon != null) + if (icon != null) materialSwitchPreference.setIcon(setTint(getContext(), getDrawable(getContext(), icon))); // preference.setIcon materialSwitchPreference.setOnPreferenceChangeListener(listener); // setOnPreferenceClickListener(listener) @@ -118,7 +115,7 @@ public class PreferencesUtil{ preference.setSummary(summary); // setSummary preference.setTitle(title); // setTitle - if(icon != null) + if (icon != null) preference.setIcon(setTint(getContext(), getDrawable(getContext(), icon))); // preference.setIcon preference.setOnPreferenceClickListener(listener); // preference.setOnPreferenceClickListener(listener) @@ -131,7 +128,7 @@ public class PreferencesUtil{ preference.setTitle(title); // setTitle preference.setKey(key); // setKey - if(icon != null) + if (icon != null) preference.setIcon(setTint(getContext(), getDrawable(getContext(), icon))); // preference.setIcon preference.setOnPreferenceClickListener(listener); // preference.setOnPreferenceClickListener(listener) @@ -144,7 +141,7 @@ public class PreferencesUtil{ preference.setTitle(title); // setTitle preference.setKey(key); // setKey - if(icon != null) + if (icon != null) preference.setIcon(icon); // preference.setIcon preference.setOnPreferenceClickListener(listener); // preference.setOnPreferenceClickListener(listener) @@ -190,7 +187,7 @@ public class PreferencesUtil{ builder.setView(linearLayout); builder.setPositiveButton("OK", (dialog, which) -> { boolean change = editTextPrefChangeListener.onChanged(preference, editText.getText().toString()); - if(!change) + if (!change) return; PreferenceManager.getDefaultSharedPreferences(getContext()) diff --git a/app/src/main/java/ru/vtosters/lite/ui/activities/APKInstallActivity.java b/app/src/main/java/ru/vtosters/lite/ui/activities/APKInstallActivity.java index 79a3cc1bb..1932f055d 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/activities/APKInstallActivity.java +++ b/app/src/main/java/ru/vtosters/lite/ui/activities/APKInstallActivity.java @@ -32,14 +32,14 @@ public class APKInstallActivity extends AppCompatActivity{ super.onCreate(savedInstanceState); Intent intent = getIntent(); - if(intent == null){ + if (intent == null) { Toast.makeText(this, "No intent", Toast.LENGTH_SHORT).show(); finish(); return; } mApkUri = intent.getParcelableExtra(EXTRA_APK_URI); - if(mApkUri == null){ + if (mApkUri == null) { Toast.makeText(this, "No apk uri", Toast.LENGTH_SHORT).show(); finish(); return; @@ -49,8 +49,8 @@ public class APKInstallActivity extends AppCompatActivity{ } private void installApk(){ - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ - if(!getPackageManager().canRequestPackageInstalls()){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (!getPackageManager().canRequestPackageInstalls()) { Intent permIntent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:" + getPackageName())); startActivityForResult(permIntent, REQUEST_INSTALL_PERMISSION); return; @@ -76,7 +76,7 @@ public class APKInstallActivity extends AppCompatActivity{ public void onActivityResult(int requestCode, int resultCode, Intent data){ super.onActivityResult(requestCode, resultCode, data); - if(requestCode == REQUEST_INSTALL_PERMISSION) + if (requestCode == REQUEST_INSTALL_PERMISSION) installApk(); } } diff --git a/app/src/main/java/ru/vtosters/lite/ui/dialogs/DisableBattery.java b/app/src/main/java/ru/vtosters/lite/ui/dialogs/DisableBattery.java index 5def6a33e..cb2800c56 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/dialogs/DisableBattery.java +++ b/app/src/main/java/ru/vtosters/lite/ui/dialogs/DisableBattery.java @@ -18,9 +18,9 @@ import ru.vtosters.lite.utils.OEMDetector; public class DisableBattery{ public static void alert(Activity activity){ - if(OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && getBoolValue("showDoze", true)){ + if (OEMDetector.isOEM() && Build.VERSION.SDK_INT >= 23 && getBoolValue("showDoze", true)) { 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); builder.setTitle(getString("batteryissuetitle")); builder.setMessage(getString("batteryissuesumm")); diff --git a/app/src/main/java/ru/vtosters/lite/ui/dialogs/InstallGMS.java b/app/src/main/java/ru/vtosters/lite/ui/dialogs/InstallGMS.java index 8b8f50870..95c2af2fe 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/dialogs/InstallGMS.java +++ b/app/src/main/java/ru/vtosters/lite/ui/dialogs/InstallGMS.java @@ -18,7 +18,7 @@ import ru.vtosters.lite.ui.fragments.InstallGMSFragment; public class InstallGMS{ public static void alert(final Activity activity){ - if(!isGmsInstalled()){ + if (!isGmsInstalled()) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(getString("debug_warning")); builder.setMessage(getString("gmsissuesumm")); @@ -41,7 +41,7 @@ public class InstallGMS{ context.startActivity(a2); } }); - if(getBoolValue("showAlertGms", true)){ + if (getBoolValue("showAlertGms", true)) { builder.show(); } } diff --git a/app/src/main/java/ru/vtosters/lite/ui/dialogs/Start.java b/app/src/main/java/ru/vtosters/lite/ui/dialogs/Start.java index 53c16fc10..86612b847 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/dialogs/Start.java +++ b/app/src/main/java/ru/vtosters/lite/ui/dialogs/Start.java @@ -15,8 +15,8 @@ import ru.vtosters.lite.utils.OEMDetector; public class Start{ public static void alert(final Activity activity){ - if(Build.VERSION.SDK_INT >= 23){ - activity.requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 228); + if (Build.VERSION.SDK_INT >= 23) { + activity.requestPermissions(new String[] {"android.permission.WRITE_EXTERNAL_STORAGE"}, 228); } AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(getString("debug_warning")); @@ -37,7 +37,7 @@ public class Start{ activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse("https://t.me/vtosters"))); } }); - if(getBoolValue("showAlert", true)){ + if (getBoolValue("showAlert", true)) { builder.show(); } } @@ -45,7 +45,7 @@ public class Start{ private static String getWelcome(){ String Default = getString("startsumm1"); - if(OEMDetector.isOEM()){ + if (OEMDetector.isOEM()) { return Default + getString("startsumm2"); } diff --git a/app/src/main/java/ru/vtosters/lite/ui/dialogs/VKIDProtection.java b/app/src/main/java/ru/vtosters/lite/ui/dialogs/VKIDProtection.java index 6dab123ac..17248939b 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/dialogs/VKIDProtection.java +++ b/app/src/main/java/ru/vtosters/lite/ui/dialogs/VKIDProtection.java @@ -28,7 +28,7 @@ public class VKIDProtection{ a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(a2); }); - if(getBoolValue("showAlertVkId", true)){ + if (getBoolValue("showAlertVkId", true)) { builder.show(); } } diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java index 3303907e4..87bcd0e53 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java +++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/MediaFragment.java @@ -1,8 +1,9 @@ package ru.vtosters.lite.ui.fragments; import static ru.vtosters.lite.utils.Globals.getIdentifier; -import static ru.vtosters.lite.utils.Themes.*; +import static ru.vtosters.lite.utils.Themes.getAccentColor; import static ru.vtosters.lite.utils.Themes.getAlertStyle; +import static ru.vtosters.lite.utils.Themes.getTextAttr; import android.content.Context; import android.content.DialogInterface; @@ -17,7 +18,6 @@ import androidx.preference.Preference; import com.vtosters.lite.general.fragments.MaterialPreferenceToolbarFragment; import ru.vtosters.lite.downloaders.VideoDownloader; -import ru.vtosters.lite.utils.Themes; public class MediaFragment extends MaterialPreferenceToolbarFragment{ public static void download(Context ctx){ diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java index bfec27fab..e2a3d2233 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java +++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java @@ -76,6 +76,23 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment{ } } + public static class b implements Preference.OnPreferenceClickListener{ + @Override // android.support.v7.preference.Preference.c + public boolean onPreferenceClick(Preference preference){ + System.exit(0); + return true; + } + } + + public static class deleteprefs implements Preference.OnPreferenceClickListener{ + @Override // android.support.v7.preference.Preference.c + public boolean onPreferenceClick(Preference preference){ + deletePrefs(); + restartApplication(); + return true; + } + } + class c implements Preference.OnPreferenceClickListener{ public void copy(Context context, String str){ ((ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("MBH-ST", str)); @@ -109,14 +126,6 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment{ } } - public static class b implements Preference.OnPreferenceClickListener{ - @Override // android.support.v7.preference.Preference.c - public boolean onPreferenceClick(Preference preference){ - System.exit(0); - return true; - } - } - public class a implements Preference.OnPreferenceClickListener{ @Override // android.support.v7.preference.Preference.c public boolean onPreferenceClick(Preference preference){ @@ -146,15 +155,6 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment{ } } - public static class deleteprefs implements Preference.OnPreferenceClickListener{ - @Override // android.support.v7.preference.Preference.c - public boolean onPreferenceClick(Preference preference){ - deletePrefs(); - restartApplication(); - return true; - } - } - public class saveprefs implements Preference.OnPreferenceClickListener{ saveprefs(){ } diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/VTSettings.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/VTSettings.java index a8fb68aa9..bdf5d6f63 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/fragments/VTSettings.java +++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/VTSettings.java @@ -62,7 +62,6 @@ import ru.vtosters.lite.ui.PreferencesUtil; import ru.vtosters.lite.ui.dialogs.OTADialog; import ru.vtosters.lite.ui.fragments.dockbar.AdapterHelper; import ru.vtosters.lite.ui.fragments.dockbar.DockBarEditorFragment; -import ru.vtosters.lite.ui.fragments.dockbar.DockBarManager; import ru.vtosters.lite.ui.fragments.tgstickers.StickersFragment; import ru.vtosters.lite.ui.vkui.VBottomSheetBuilder; import ru.vtosters.lite.utils.CacheUtils; @@ -74,9 +73,9 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ public static int hideitems = 0; public static String getValAsString(String stringid, Boolean value){ - if(disableSettingsSumms()) return null; + if (disableSettingsSumms()) return null; - if(value){ + if (value) { return Globals.getString(stringid) + ": " + Globals.getString("vtlsettenabled"); } @@ -84,22 +83,22 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ } public static String getSSFSsumm(){ - if(disableSettingsSumms()) return null; + if (disableSettingsSumms()) return null; - if(hasSpecialVerif()) + if (hasSpecialVerif()) return Globals.getString("vtlssfssumm") + ": " + Globals.getString("vtlsettverifyes"); return Globals.getString("vtlssfssumm") + ": " + Globals.getString("vtlsettverifno"); } public static String getDocksumm(){ - if(disableSettingsSumms()) return null; + if (disableSettingsSumms()) return null; return Globals.getString("vtldocksumm") + ": " + (AdapterHelper.getItemCount() - 2); } public static String getTGSsumm(){ - if(disableSettingsSumms()) return null; + if (disableSettingsSumms()) return null; return Globals.getString("vtltgssumm") + ": " + TelegramStickersService.getInstance(Globals.getContext()).getPacksListReference().size(); } @@ -107,9 +106,9 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ public static String getProxysumm(){ var type = getPrefsValue("proxy"); - if(disableSettingsSumms()) return null; + if (disableSettingsSumms()) return null; - if(type.equals("noproxy") || type.isEmpty()) type = Globals.getString("vtlsettdisabled"); + if (type.equals("noproxy") || type.isEmpty()) type = Globals.getString("vtlsettdisabled"); return Globals.getString("vtlproxysumm") + ": " + type; } @@ -119,13 +118,13 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ } public static String getSuperappsumm(){ - if(disableSettingsSumms()) return null; + if (disableSettingsSumms()) return null; return "Скрыто элементов" + ": " + preferences.getInt("superappitems", 0); } public static String getCachesumm(){ - if(disableSettingsSumms()) return null; + if (disableSettingsSumms()) return null; return Globals.getString("autoclearcachesumm") + " " + humanReadableByteCountBin(CacheUtils.getInstance().size); } @@ -162,7 +161,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ PreferencesUtil.addMaterialSwitchPreference(this, "isdark", Globals.getString("vtsettdarktheme"), "", !DoNotUseOldIcons() ? "ic_palette_24" : "ic_palette_outline_28", false, (preference, o) -> { boolean value = (boolean) o; - if(!value){ // inverted + if (!value) { // inverted setTheme(getLightTheme(), this.getActivity()); } else { setTheme(getDarkTheme(), this.getActivity()); @@ -172,7 +171,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ return true; }); - if(Build.VERSION.SDK_INT >= 28 && false){ // TODO refactoring system theme + if (Build.VERSION.SDK_INT >= 28 && false) { // TODO refactoring system theme PreferencesUtil.addMaterialSwitchPreference(this, "systemtheme", Globals.getString("appearance_theme_use_system"), Globals.getString("appearance_theme_use_system_summary"), !DoNotUseOldIcons() ? "ic_recent_24" : "ic_recent_outline_28", true, (preference, o) -> { boolean value = (boolean) o; @@ -181,7 +180,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ }); } - if(!isGmsInstalled()){ + if (!isGmsInstalled()) { PreferencesUtil.addPreference(this, "", Globals.getString("installgms"), "", "ic_warning_24", preference -> { Context context = getContext(); Intent a2 = new Navigator(InstallGMSFragment.class).b(context); @@ -191,7 +190,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ }); } - if(devmenu()){ + if (devmenu()) { PreferencesUtil.addPreferenceCategory(this, Globals.getString("sett_debug")); PreferencesUtil.addPreference(this, "", Globals.getString("sett_debug"), "", !DoNotUseOldIcons() ? "ic_bug_24" : "ic_bug_outline_28", preference -> { @@ -280,7 +279,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ return false; }); - if(VKAccountManager.d().isMusicSubs()){ + if (VKAccountManager.d().isMusicSubs()) { PreferencesUtil.addPreference(this, "", Globals.getString("subscription_music"), "", !DoNotUseOldIcons() ? "ic_music_24" : "ic_music_outline_28", preference -> { Context context = getContext(); Intent a2 = new Navigator(MusicSubscriptionControlFragment.class).b(context); @@ -300,7 +299,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ PreferencesUtil.addPreferenceCategory(this, Globals.getString("vtsettmod")); - if(!vkme()){ + if (!vkme()) { PreferencesUtil.addPreference(this, "", Globals.getString("vtlfeed"), feedsumm, !DoNotUseOldIcons() ? "ic_newsfeed_24" : "ic_newsfeed_outline_28", preference -> { Context context = getContext(); Intent a2 = new Navigator(FeedFragment.class).b(context); @@ -366,7 +365,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ return false; }); - if(milkshake()){ + if (milkshake()) { PreferencesUtil.addPreference(this, "", "Настроить Superapp", superapp, "ic_explore_outline_28", (preference) -> { callEditorPopup(); return true; @@ -381,9 +380,9 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ return false; }); - PreferencesUtil.addListPreferenceIcon(this, "clearcache", "Default", Globals.getString("autoclearcache"), !DoNotUseOldIcons() ? "ic_delete_24" : "ic_delete_outline_28", getCachesumm(), new CharSequence[]{ + PreferencesUtil.addListPreferenceIcon(this, "clearcache", "Default", Globals.getString("autoclearcache"), !DoNotUseOldIcons() ? "ic_delete_24" : "ic_delete_outline_28", getCachesumm(), new CharSequence[] { Globals.getString("autoclearcachedisabled"), "100 MB", "500 MB", "1 GB", "2 GB", "5 GB" - }, new String[]{ + }, new String[] { "Default", "100mb", "500mb", "1gb", "2gb", "5gb" }); @@ -421,7 +420,7 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ return false; }); - if(isValidSignature()){ + if (isValidSignature()) { PreferencesUtil.addPreferenceCategory(this, Globals.getString("updates")); PreferencesUtil.addPreference(this, "", Globals.getString("checkforupdates"), "", "ic_download_outline_24", preference -> { @@ -466,9 +465,9 @@ public class VTSettings extends MaterialPreferenceToolbarFragment{ new VBSContent.VBSButton( "Сохранить", () -> { - for(VBListItem item : list) { + for (VBListItem item : list) { edit().putBoolean("superapp_" + item.id, item.checked).commit(); - if(item.checked){ + if (item.checked) { hideitems++; edit().putInt("superappitems", hideitems).commit(); } diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickerPackAdapter.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickerPackAdapter.java index e79a7367f..d5f843d14 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickerPackAdapter.java +++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickerPackAdapter.java @@ -56,11 +56,11 @@ public class StickerPackAdapter extends RecyclerView.Adapter= Build.VERSION_CODES.LOLLIPOP){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { editText.setBackgroundTintList(ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext()))); } else { ViewCompat.setBackgroundTintList(editText, ColorStateList.valueOf(PreferencesUtil.getTextColor(getContext()))); @@ -206,11 +203,11 @@ public class StickersFragment extends MaterialPreferenceToolbarFragment { TelegramStickersGrabber.USE_PROXY = false; mGrabber.resetProxy(); } else if (method == TYPE_SOCKS) { - if(TGPref.getTGProxyIP() != null){ + if (TGPref.getTGProxyIP() != null) { TelegramStickersGrabber.USE_PROXY = true; TelegramStickersGrabber.PROXY_IP = TGPref.getTGProxyIP(); TelegramStickersGrabber.PROXY_PORT = TGPref.getTGProxyPort(); - if(TGPref.isTGProxyPassEnabled()){ + if (TGPref.isTGProxyPassEnabled()) { TelegramStickersGrabber.HAS_PASS = true; TelegramStickersGrabber.PROXY_USER = TGPref.getTGProxyUser(); TelegramStickersGrabber.PROXY_PASS = TGPref.getTGProxyPass(); @@ -247,7 +244,7 @@ public class StickersFragment extends MaterialPreferenceToolbarFragment { .setView(linearLayout) .setPositiveButton(android.R.string.ok, (dialog, which) -> { TGPref.setTGBotKey(editText.getText().toString()); - if(r != null) r.run(); + if (r != null) r.run(); }) .setNegativeButton(android.R.string.cancel, null) .setNeutralButton(Globals.getString("stickersapi7"), @@ -270,13 +267,13 @@ public class StickersFragment extends MaterialPreferenceToolbarFragment { @Override public void onKeyChecked(boolean ok){ progressDialog.dismiss(); - if(!ok){ + if (!ok) { makeText(context, Globals.getString("stickersapi2"), LENGTH_SHORT).show(); return; } mService.setBotKey(TGPref.getTGBotKey()); - if(callback != null) callback.run(); + if (callback != null) callback.run(); } @Override @@ -293,9 +290,9 @@ public class StickersFragment extends MaterialPreferenceToolbarFragment { } private String parsePack(String pack){ - if(pack.startsWith("https://t.me/addstickers/")){ + if (pack.startsWith("https://t.me/addstickers/")) { pack = pack.substring(25); - } else if(pack.startsWith("https://telegram.me/addstickers/")){ + } else if (pack.startsWith("https://telegram.me/addstickers/")) { pack = pack.substring(32); } return pack; diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickersPreferencesFragment.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickersPreferencesFragment.java index 427e023ab..0365409d9 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickersPreferencesFragment.java +++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/tgstickers/StickersPreferencesFragment.java @@ -30,9 +30,9 @@ public class StickersPreferencesFragment extends MaterialPreferenceToolbarFragme }); PreferencesUtil.addPreferenceCategory(this, Globals.getString("sprefsnetwork")); - PreferencesUtil.addListPreference(this, "VTGS:CM", "0", Globals.getString("sprefsctype"), new CharSequence[]{ + PreferencesUtil.addListPreference(this, "VTGS:CM", "0", Globals.getString("sprefsctype"), new CharSequence[] { Globals.getString("ctypedirect"), Globals.getString("ctypesocks") - }, new String[]{ + }, new String[] { "0", "2" }); diff --git a/app/src/main/java/ru/vtosters/lite/ui/vkui/MenuBuilder.java b/app/src/main/java/ru/vtosters/lite/ui/vkui/MenuBuilder.java index 07072fc5c..ef1078915 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/vkui/MenuBuilder.java +++ b/app/src/main/java/ru/vtosters/lite/ui/vkui/MenuBuilder.java @@ -10,7 +10,6 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; -import android.widget.Toast; import com.vk.core.dialogs.actionspopup.ActionsPopup; import com.vk.profile.ui.components.CommunityFragmentActionsMenuBuilder; diff --git a/app/src/main/java/ru/vtosters/lite/ui/vkui/VBListBuilder.java b/app/src/main/java/ru/vtosters/lite/ui/vkui/VBListBuilder.java index ab1a79c3f..8d714d013 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/vkui/VBListBuilder.java +++ b/app/src/main/java/ru/vtosters/lite/ui/vkui/VBListBuilder.java @@ -18,7 +18,7 @@ public class VBListBuilder{ mainView.setOrientation(LinearLayout.VERTICAL); mainView.setPadding(convertDpToPixel(8f), 0, convertDpToPixel(8f), 0); - for(VBListItem item : items) { + for (VBListItem item : items) { AppCompatCheckBox mcb = new AppCompatCheckBox(ctx, null); mcb.setPadding(0, convertDpToPixel(8f), 0, convertDpToPixel(8f)); diff --git a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperMenuFragment.java b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperMenuFragment.java index 8f04a456c..4cc4ad1f4 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperMenuFragment.java +++ b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperMenuFragment.java @@ -74,15 +74,15 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment{ PreferencesUtil.addPreferenceCategory(this, "Параметры"); - PreferencesUtil.addListPreference(this, "msg_blur_radius", "disabled", "Размытие фона сообщений", new CharSequence[]{ + PreferencesUtil.addListPreference(this, "msg_blur_radius", "disabled", "Размытие фона сообщений", new CharSequence[] { "Отключено", "Низкое (15px)", "Среднее (25px)", "Высокое (50px)" - }, new String[]{ + }, new String[] { "disabled", "low", "med", "high" }); - PreferencesUtil.addListPreference(this, "msg_dim", "off", "Затемнение изображения", new CharSequence[]{ + PreferencesUtil.addListPreference(this, "msg_dim", "off", "Затемнение изображения", new CharSequence[] { "Отключено", "Затемнить", "Осветлить" - }, new String[]{ + }, new String[] { "off", "dim_black", "dim_white" }); @@ -113,7 +113,7 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment{ public void onActivityResult(int i, int i1, @Nullable Intent intent){ super.onActivityResult(i, i1, intent); - if(intent == null || intent.getData() == null) + if (intent == null || intent.getData() == null) return; try { @@ -124,7 +124,7 @@ public class WallpaperMenuFragment extends MaterialPreferenceToolbarFragment{ requestUpdateWallpaper(); - if(i == 1488){ + if (i == 1488) { mWPPreviewPref.redraw(); } } catch (Exception e) { diff --git a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperPreferences.java b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperPreferences.java index 3381812a7..5970e5d6b 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperPreferences.java +++ b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpaperPreferences.java @@ -91,7 +91,7 @@ public class WallpaperPreferences extends Preference{ final Drawable drawable = getWallpaper(); mUIHandler.post(() -> { - if(drawable != null && getWallpaperFile().exists()) + if (drawable != null && getWallpaperFile().exists()) bg.setImageDrawable(drawable); else bg.setImageDrawable(null); @@ -105,11 +105,11 @@ public class WallpaperPreferences extends Preference{ } private static class PreviewAdapter extends RecyclerView.Adapter{ - private final CharSequence[] previews = new CharSequence[]{ + private final CharSequence[] previews = new CharSequence[] { " Привет ", " Привет ", " Ты кто? " }; - private final boolean[] isOut = new boolean[]{ + private final boolean[] isOut = new boolean[] { false, true, false }; @@ -125,7 +125,7 @@ public class WallpaperPreferences extends Preference{ bubble.setText(previews[previewVH.getAdapterPosition()]); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); - if(isOut[previewVH.getAdapterPosition()]){ + if (isOut[previewVH.getAdapterPosition()]) { params.addRule(RelativeLayout.ALIGN_PARENT_END); bubble.setPadding(convertDpToPixel(16), convertDpToPixel(16), convertDpToPixel(24), 0); bubble.setBackgroundResource(com.vtosters.lite.R.drawable.vkim_msg_new_out_light_full); diff --git a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java index a4376a8cb..357098824 100644 --- a/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java +++ b/app/src/main/java/ru/vtosters/lite/ui/wallpapers/WallpapersHooks.java @@ -31,7 +31,7 @@ public class WallpapersHooks{ } public static void setBg(View view){ - if(getWallpaper() != null){ + if (getWallpaper() != null) { ((ImageView) view).setImageDrawable(getWallpaper()); // set picture to background return; } @@ -40,20 +40,20 @@ public class WallpapersHooks{ } public static String getWallpaperUrl(){ - if(getWallpaperFile().exists()) + if (getWallpaperFile().exists()) return getWallpaperFile().getAbsolutePath(); else return "default"; } public static Drawable getWallpaper(){ - if(mWallpaper == null || mUpdateWallpaperRequested){ - if(!getPreferences().getString("msg_blur_radius", "disabled").equals("disabled")){ + if (mWallpaper == null || mUpdateWallpaperRequested) { + if (!getPreferences().getString("msg_blur_radius", "disabled").equals("disabled")) { mWallpaper = getBlurredWallpaper(Drawable.createFromPath(getWallpaperUrl()), getRadius()); } else { mWallpaper = Drawable.createFromPath(getWallpaperUrl()); } - if(!getPreferences().getString("msg_dim", "off").equals("off")){ + if (!getPreferences().getString("msg_dim", "off").equals("off")) { mWallpaper = getDimmed(mWallpaper); } @@ -109,8 +109,8 @@ public class WallpapersHooks{ public static Drawable getBlurredWallpaper(Drawable orig, int radius){ try { - if(orig == null) return null; - if(!(orig instanceof BitmapDrawable)) return orig; // we need only BitmapDrawable + if (orig == null) return null; + if (!(orig instanceof BitmapDrawable)) return orig; // we need only BitmapDrawable Bitmap instance = ((BitmapDrawable) orig).getBitmap().copy(Bitmap.Config.ARGB_8888, true); MediaNative.blurBitmap(instance, radius); return new BitmapDrawable(getResources(), instance); @@ -121,8 +121,8 @@ public class WallpapersHooks{ } public static Drawable getDimmed(Drawable orig){ - if(orig == null) return null; - if(!(orig instanceof BitmapDrawable)) return orig; + if (orig == null) return null; + if (!(orig instanceof BitmapDrawable)) return orig; Bitmap instance = ((BitmapDrawable) orig).getBitmap().copy(Bitmap.Config.ARGB_8888, true); String radius = getPreferences().getString("msg_dim", "disabled"); switch(radius) { diff --git a/app/src/main/java/ru/vtosters/lite/utils/About.java b/app/src/main/java/ru/vtosters/lite/utils/About.java index cb2d3b6e4..8239eb79f 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/About.java +++ b/app/src/main/java/ru/vtosters/lite/utils/About.java @@ -22,7 +22,7 @@ public class About{ list.clear(); list.add(new Items1()); - if(!oldabout()){ + if (!oldabout()) { list.add(new Items(21, getIdentifier("opencommit", "string"))); list.add(new Items(8, getIdentifier("tgchannel", "string"))); list.add(new Items(9, getIdentifier("tgchat", "string"))); @@ -57,7 +57,7 @@ public class About{ Scanner scanner = new Scanner(context.getAssets().open(name)); while(scanner.hasNextLine()) { String line = scanner.findInLine("VERSION_BUILD=.+"); - if(line != null) + if (line != null) return line.replace("VERSION_BUILD=", ""); return "0000000"; } diff --git a/app/src/main/java/ru/vtosters/lite/utils/CacheUtils.java b/app/src/main/java/ru/vtosters/lite/utils/CacheUtils.java index ea0004d37..d427673bd 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/CacheUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/CacheUtils.java @@ -17,7 +17,7 @@ public class CacheUtils{ public long size = 0; public static CacheUtils getInstance(){ - if(sInstance == null) + if (sInstance == null) sInstance = new CacheUtils(); return sInstance; } @@ -32,16 +32,16 @@ public class CacheUtils{ } public static boolean deleteDir(File dir){ - if(dir != null && dir.isDirectory()){ + if (dir != null && dir.isDirectory()) { String[] children = dir.list(); - for(int i = 0; i < Objects.requireNonNull(children).length; i++) { + for (int i = 0; i < Objects.requireNonNull(children).length; i++) { boolean success = deleteDir(new File(dir, children[i])); - if(!success){ + if (!success) { return false; } } return dir.delete(); - } else if(dir != null && dir.isFile()){ + } else if (dir != null && dir.isFile()) { return dir.delete(); } else { return false; @@ -51,12 +51,12 @@ public class CacheUtils{ @SuppressLint("DefaultLocale") public static String humanReadableByteCountBin(long bytes){ long absB = bytes == Long.MIN_VALUE ? Long.MAX_VALUE : Math.abs(bytes); - if(absB < 1024){ + if (absB < 1024) { return bytes + " B"; } long value = absB; CharacterIterator ci = new StringCharacterIterator("KMGTPE"); - for(int i = 40; i >= 0 && absB > 0xfffccccccccccccL >> i; i -= 10) { + for (int i = 40; i >= 0 && absB > 0xfffccccccccccccL >> i; i -= 10) { value >>= 10; ci.next(); } @@ -67,8 +67,8 @@ public class CacheUtils{ public void autoCleaningCache(){ size = getDirSize(getContext().getCacheDir()); - if(size >= getSizeForDelete()){ - if(dev()) sendToast("Кэш очищен"); + if (size >= getSizeForDelete()) { + if (dev()) sendToast("Кэш очищен"); deleteCache(); size = 0; } @@ -76,10 +76,10 @@ public class CacheUtils{ public long getDirSize(File dir){ long size = 0; - for(File file : Objects.requireNonNull(dir.listFiles())) { - if(file != null && file.isDirectory()){ + for (File file : Objects.requireNonNull(dir.listFiles())) { + if (file != null && file.isDirectory()) { size += getDirSize(file); - } else if(file != null && file.isFile()){ + } else if (file != null && file.isFile()) { size += file.length(); } } diff --git a/app/src/main/java/ru/vtosters/lite/utils/DeletedMessagesHandler.java b/app/src/main/java/ru/vtosters/lite/utils/DeletedMessagesHandler.java index b6eaadb45..a50018f21 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/DeletedMessagesHandler.java +++ b/app/src/main/java/ru/vtosters/lite/utils/DeletedMessagesHandler.java @@ -33,7 +33,7 @@ public class DeletedMessagesHandler{ private static DeletedMessagesDBHelper sVTDatabase; public static void reloadMessagesList(){ - if(sVTDatabase == null){ + if (sVTDatabase == null) { sVTDatabase = new DeletedMessagesDBHelper(); } sDeletedMessagesList = new ArrayList<>(sVTDatabase.loadAllMessages()); @@ -48,12 +48,12 @@ public class DeletedMessagesHandler{ } public static void setBodyDBParser(Msg msg){ - if(!(msg instanceof MsgFromUser)) return; + if (!(msg instanceof MsgFromUser)) return; - for(Integer integer : sDeletedMessagesList) { + for (Integer integer : sDeletedMessagesList) { MsgFromUser msgFromUser = (MsgFromUser) msg; checkForNestedMsg(msgFromUser.w0()); - if(integer == msg.C1()){ + if (integer == msg.C1()) { editTextOfMsg((MsgFromUser) msg); break; } @@ -61,15 +61,15 @@ public class DeletedMessagesHandler{ } private static void checkForNestedMsg(List nestedMsgs){ - for(NestedMsg nestedMsg : nestedMsgs) { - if(!nestedMsg.w0().isEmpty()) checkForNestedMsg(nestedMsg.w0()); + for (NestedMsg nestedMsg : nestedMsgs) { + if (!nestedMsg.w0().isEmpty()) checkForNestedMsg(nestedMsg.w0()); nestedMsg.d(EncryptProvider.decryptMessage(nestedMsg.f(), nestedMsg.getFrom().getId())); } } private static void editTextOfMsg(MsgFromUser msgFromUser){ - if(!msgFromUser.f().startsWith(getPrefixUndelete())){ + if (!msgFromUser.f().startsWith(getPrefixUndelete())) { msgFromUser.d(getPrefixUndelete() + EncryptProvider.decryptMessage(msgFromUser)); } } @@ -80,7 +80,7 @@ public class DeletedMessagesHandler{ public static void updateDialog(MsgDeleteLpTask msgDeleteLpTask) throws NoSuchFieldException, IllegalAccessException{ Cursor c = getMessageFromDatabaseById(ReflectionUtils.getObjectField(msgDeleteLpTask.getClass(), "d", msgDeleteLpTask)); - if(c == null) return; + if (c == null) return; @SuppressLint("Range") int localId = c.getInt(c.getColumnIndex("local_id")); @@ -92,16 +92,16 @@ public class DeletedMessagesHandler{ } public static void hookDeletedMessageId(MsgDeleteLpTask msgDeleteLpTask) throws NoSuchFieldException, IllegalAccessException{ - if(!hook()) return; + if (!hook()) return; var field = msgDeleteLpTask.getClass().getDeclaredField("c"); field.setAccessible(true); var messageId = (int) field.get(msgDeleteLpTask); Cursor c = getMessageFromDatabaseById(messageId); - if(c == null) return; - if(sBodyIndex == -1) sBodyIndex = c.getColumnIndex("body"); - if(TextUtils.isEmpty(c.getString(sBodyIndex))){ + if (c == null) return; + if (sBodyIndex == -1) sBodyIndex = c.getColumnIndex("body"); + if (TextUtils.isEmpty(c.getString(sBodyIndex))) { deleteMessageFromDB(messageId); return; } @@ -113,7 +113,7 @@ public class DeletedMessagesHandler{ public static Cursor getMessageFromDatabaseById(int messageId){ String query = "SELECT * FROM messages WHERE vk_id = " + messageId; Cursor c = CustomSqliteExtensionsKt.a(sVKSQLiteDatabase, query); - if(!c.moveToFirst()) return null; + if (!c.moveToFirst()) return null; return c; } @@ -150,7 +150,7 @@ public class DeletedMessagesHandler{ List msgIdsList = new ArrayList<>(); Cursor cursor = getReadableDatabase().query("deleted_msgs", null, null, null, null, null, null); - if(cursor.moveToFirst()){ + if (cursor.moveToFirst()) { int msgIdIndex = cursor.getColumnIndex("msgId"); do { diff --git a/app/src/main/java/ru/vtosters/lite/utils/ExternalLinkHandler.java b/app/src/main/java/ru/vtosters/lite/utils/ExternalLinkHandler.java index 2fe7e3e63..23f141225 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ExternalLinkHandler.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ExternalLinkHandler.java @@ -30,7 +30,7 @@ public class ExternalLinkHandler{ private static final Map qualities = new HashMap<>(); public static boolean parseVideoFile(VideoFile file, Context context){ - if(checkYoutubeLink(file)){ + if (checkYoutubeLink(file)) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(file.G)); @@ -41,10 +41,10 @@ public class ExternalLinkHandler{ } } - if(!isEnableExternalOpening()) return false; + if (!isEnableExternalOpening()) return false; - if(checkVkVideo(file)){ - if(qualities.size() == 1){ + if (checkVkVideo(file)) { + if (qualities.size() == 1) { startExternalVideo((String) qualities.values().toArray()[0]); } else { String[] titles = qualities.keySet().toArray(new String[0]); @@ -59,9 +59,9 @@ public class ExternalLinkHandler{ } private static boolean checkYoutubeLink(VideoFile file){ - if(!isEmpty(file.G)){ - for(String filter : filters) { - if(file.G.contains(filter)) + if (!isEmpty(file.G)) { + for (String filter : filters) { + if (file.G.contains(filter)) return true; } } @@ -78,25 +78,25 @@ public class ExternalLinkHandler{ * this.D = var66.optString("mp4_2160"); */ public static boolean checkVkVideo(VideoFile videoFile){ - if(!isEmpty(videoFile.e)){ + if (!isEmpty(videoFile.e)) { qualities.put("240", videoFile.e); } - if(!isEmpty(videoFile.f)){ + if (!isEmpty(videoFile.f)) { qualities.put("360", videoFile.f); } - if(!isEmpty(videoFile.g)){ + if (!isEmpty(videoFile.g)) { qualities.put("480", videoFile.g); } - if(!isEmpty(videoFile.h)){ + if (!isEmpty(videoFile.h)) { qualities.put("720", videoFile.h); } - if(!isEmpty(videoFile.B)){ + if (!isEmpty(videoFile.B)) { qualities.put("1080", videoFile.B); } - if(!isEmpty(videoFile.C)){ + if (!isEmpty(videoFile.C)) { qualities.put("1440", videoFile.C); } - if(!isEmpty(videoFile.D)){ + if (!isEmpty(videoFile.D)) { qualities.put("2160", videoFile.D); } @@ -111,7 +111,7 @@ public class ExternalLinkHandler{ Intent intent = new Intent(); String packageName = getMXPlayerPackageName(); - if(!isEmpty(packageName)){ + if (!isEmpty(packageName)) { intent.setPackage(packageName); intent.setDataAndType(uri, "application/mp4"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); @@ -119,7 +119,7 @@ public class ExternalLinkHandler{ intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(uri, "video/mp4"); - 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); } getContext().startActivity(intent); @@ -131,9 +131,9 @@ public class ExternalLinkHandler{ } private static String getMXPlayerPackageName(){ - for(ApplicationInfo info : getContext().getPackageManager().getInstalledApplications(0)) { + for (ApplicationInfo info : getContext().getPackageManager().getInstalledApplications(0)) { 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 null; diff --git a/app/src/main/java/ru/vtosters/lite/utils/FragAnimationKit.java b/app/src/main/java/ru/vtosters/lite/utils/FragAnimationKit.java index 49caf5e67..a4382ab03 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/FragAnimationKit.java +++ b/app/src/main/java/ru/vtosters/lite/utils/FragAnimationKit.java @@ -42,7 +42,7 @@ public class FragAnimationKit{ } public static void setAnimations(FragmentTransaction transaction){ - if(transaction != null && !getPrefsValue("anim_rtrn_type").equals("noanim")){ + if (transaction != null && !getPrefsValue("anim_rtrn_type").equals("noanim")) { switch(getPrefsValue("anim_rtrn_type")) { case "q": transaction.setCustomAnimations( diff --git a/app/src/main/java/ru/vtosters/lite/utils/Globals.java b/app/src/main/java/ru/vtosters/lite/utils/Globals.java index 8ea7a9959..6274353e4 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Globals.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Globals.java @@ -75,7 +75,7 @@ public class Globals{ private static final List activities = new ArrayList<>(); public static SharedPreferences getDefprefs(){ - if(preferences == null) + if (preferences == null) preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); return preferences; } @@ -83,7 +83,7 @@ public class Globals{ public static void MainActivityInit(Activity activity){ ServerDialog.activity = activity; sendRequest(); - if(checkupdates()) OTADialog.checkUpdates(activity); + if (checkupdates()) OTADialog.checkUpdates(activity); Start.alert(activity); InstallGMS.alert(activity); DisableBattery.alert(activity); @@ -159,7 +159,7 @@ public class Globals{ return userProfile.b; } // UserId Profile via userProfile - public static Bitmap scaleCenterCrop(Bitmap source, int newHeight, int newWidth) { + public static Bitmap scaleCenterCrop(Bitmap source, int newHeight, int newWidth){ int sourceWidth = source.getWidth(); int sourceHeight = source.getHeight(); @@ -218,7 +218,7 @@ public class Globals{ return new BitmapDrawable(getResources(), bmp); // return our drawable } catch (Exception e) { - if(def == null) return null; // default pic can be null + if (def == null) return null; // default pic can be null return getDrawable(getContext(), getIdentifier(def, "drawable")); // get default drawable via res } @@ -345,10 +345,10 @@ public class Globals{ } // Network check public static void fixGapps(){ - if(Build.VERSION.SDK_INT >= 26 && !isGmsInstalled()){ + if (Build.VERSION.SDK_INT >= 26 && !isGmsInstalled()) { NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); - if(notificationManager.getNotificationChannel("audio_playback_channel") == null){ + if (notificationManager.getNotificationChannel("audio_playback_channel") == null) { notificationManager.createNotificationChannel(new NotificationChannel("audio_playback_channel", getResources().getString(getIdentifier("audio_message_play_error", "string")), NotificationManager.IMPORTANCE_LOW)); } } @@ -378,7 +378,7 @@ public class Globals{ @Override // android.app.Application.ActivityLifecycleCallbacks public void onActivityCreated(Activity activity, Bundle bundle){ - if(activity instanceof VKActivity){ + if (activity instanceof VKActivity) { activities.add(activity); } } @@ -391,7 +391,7 @@ public class Globals{ } public static Activity getCurrentActivity(){ - if(activities.size() == 0) return null; + if (activities.size() == 0) return null; else return activities.get(0); } @@ -406,7 +406,7 @@ public class Globals{ var resources = context.getResources(); var configuration = resources.getConfiguration(); - if(Build.VERSION.SDK_INT >= 24){ + if (Build.VERSION.SDK_INT >= 24) { configuration.setLocale(locale); configuration.setLayoutDirection(locale); return context.createConfigurationContext(configuration); @@ -427,13 +427,13 @@ public class Globals{ int centerWidth = width / 2; int centerHeight = height / 2; - return new float[]{centerWidth, centerHeight}; + return new float[] {centerWidth, centerHeight}; } int[] toIntArray(List list){ int[] ret = new int[list.size()]; int i = 0; - for(Integer e : list) { + for (Integer e : list) { /*if (e < 2000000000)*/ ret[i++] = e; } diff --git a/app/src/main/java/ru/vtosters/lite/utils/IconManager.java b/app/src/main/java/ru/vtosters/lite/utils/IconManager.java index c9483af4a..b30a30a07 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/IconManager.java +++ b/app/src/main/java/ru/vtosters/lite/utils/IconManager.java @@ -43,21 +43,22 @@ public class IconManager{ var getCurrComponent = getPreferences().getInt("component_enabled", 11); // get current component value - if(hasVerification() && isValidSignature()){ + if (hasVerification() && isValidSignature()) { iconsList = iconsPlus; appnamesList = appnamesPlus; availablecomponentsList = availablecomponentsPlus; } - if(iconsList.contains(icon)){ // check if icon is exist + if (iconsList.contains(icon)) { // check if icon is exist iconComponent = iconsList.indexOf(icon); // get icon index } - if(appnamesList.contains(appname)){ // check if appname is exist + if (appnamesList.contains(appname)) { // check if appname is exist appNameComponent = appnamesList.indexOf(appname); // get appname index } - if(getCurrComponent == iconComponent + appNameComponent || availablecomponentsList.get(iconComponent + appNameComponent) == null) return; // check if current component is equal to custom value or if custom value is not exist + if (getCurrComponent == iconComponent + appNameComponent || availablecomponentsList.get(iconComponent + appNameComponent) == null) + return; // check if current component is equal to custom value or if custom value is not exist componentSwitcher("id" + getCurrComponent, false); // disable current component to prevent conflict with custom value diff --git a/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java b/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java index 05dd14ab7..5b438d18d 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java +++ b/app/src/main/java/ru/vtosters/lite/utils/JsonInjectors.java @@ -17,7 +17,7 @@ import java.util.Random; public class JsonInjectors{ public static JSONObject profileButton(JSONObject orig) throws JSONException{ - if(haveDonateButton()) return orig; + if (haveDonateButton()) return orig; var pic = "https://sun1-18.userapi.com/NLd_rNpGuSaBnPV6O-j5mqCGZk8BK8drAMd2LQ/5R-DEF37PFs.png"; var title = "Помоги проекту донатом и получи бонус!"; @@ -36,7 +36,7 @@ public class JsonInjectors{ } public static JSONObject convBar(JSONObject orig) throws JSONException{ - if(!dev()) return orig.optJSONObject("conversation_bar"); // TODO Make it server-side + if (!dev()) return orig.optJSONObject("conversation_bar"); // TODO Make it server-side var peerid = Objects.requireNonNull(orig.optJSONObject("peer")).optInt("id"); var pic = "https://image.pngaaa.com/641/326641-middle.png"; // can be null @@ -53,14 +53,14 @@ public class JsonInjectors{ var hasButton = !buttons.isEmpty(); var isPicture = pic.endsWith(".png") || pic.endsWith(".jpg") || pic.endsWith(".jpeg") || pic.endsWith(".webp"); - if(!isPicture) hasIcon = false; - if(!hasIcon) icon = ""; - if(!hasButton) buttons = ""; + if (!isPicture) hasIcon = false; + if (!hasIcon) icon = ""; + if (!hasButton) buttons = ""; - if(isVerified(peerid)) text = "Я купил VTosters Premium"; - if(isPrometheus(peerid)) text = "Я купил VTosters Premium Gold Prime Pro Plus"; - if(isDeveloper(peerid)) text = "Я создал говно"; - if(!isVerified(peerid) || text.equals("")) return orig.optJSONObject("conversation_bar"); + if (isVerified(peerid)) text = "Я купил VTosters Premium"; + if (isPrometheus(peerid)) text = "Я купил VTosters Premium Gold Prime Pro Plus"; + if (isDeveloper(peerid)) text = "Я создал говно"; + if (!isVerified(peerid) || text.equals("")) return orig.optJSONObject("conversation_bar"); // JSONObject("{\"name\":\"group_admin_welcome\",\"text\":\"" + textverif + "\",\"buttons\":[],\"icon\":\"" + pic + "\"}"); return new JSONObject(decode("eyJuYW1lIjoiZ3JvdXBfYWRtaW5fd2VsY29tZSIsInRleHQiOiI=") @@ -75,7 +75,7 @@ public class JsonInjectors{ var Main = orig.getJSONArray("main"); var Other = orig.optJSONArray("other"); - if(Special != null){ + if (Special != null) { orig.remove("special"); } @@ -85,11 +85,11 @@ public class JsonInjectors{ public static JSONObject superapp(JSONObject json) throws JSONException{ var oldItems = json.optJSONArray("items"); var newItems = new JSONArray(); - if(oldItems != null){ - for(int i = 0; i < oldItems.length(); i++) { + if (oldItems != null) { + for (int i = 0; i < oldItems.length(); i++) { var item = oldItems.optJSONObject(i); var type = item.optString("type"); - if(!getBoolValue("superapp_" + type, false)) + if (!getBoolValue("superapp_" + type, false)) newItems.put(item); } } diff --git a/app/src/main/java/ru/vtosters/lite/utils/LocaleUtils.java b/app/src/main/java/ru/vtosters/lite/utils/LocaleUtils.java index 3d2e98cc0..4001065a3 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/LocaleUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/LocaleUtils.java @@ -14,7 +14,7 @@ public class LocaleUtils{ public static String getLocale(){ String string = getPrefsValue("lang_value"); - if(string.equals("system")){ + if (string.equals("system")) { return Locale.getDefault().getLanguage(); } @@ -44,7 +44,7 @@ public class LocaleUtils{ public static String getFormattedDate(boolean isFemale, long time){ SimpleDateFormat date = new SimpleDateFormat(getDateFormat(), Locale.getDefault()); - if(!fulltime()) return null; + if (!fulltime()) return null; try { return getStringDate(isFemale ? getIdentifier("last_seen_profile_f", "string") : getIdentifier("last_seen_profile_m", "string"), date.format(new Date(time))); diff --git a/app/src/main/java/ru/vtosters/lite/utils/Newsfeed.java b/app/src/main/java/ru/vtosters/lite/utils/Newsfeed.java index be229b9e7..cfa4ca2bf 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Newsfeed.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Newsfeed.java @@ -66,23 +66,23 @@ public class Newsfeed{ getFilter("cringecopyright", "CopyrightAds.txt", mFiltersLinks); var customfilters = getPrefsValue("spamfilters"); - if(!customfilters.isEmpty()){ + if (!customfilters.isEmpty()) { mFilters.addAll(Arrays.asList(customfilters.split(", "))); } var linkfilter = getPrefsValue("linkfilter"); - if(!linkfilter.isEmpty()){ + if (!linkfilter.isEmpty()) { mFiltersLinks.addAll(Arrays.asList(linkfilter.split(", "))); } } public static void getFilter(String boolname, String filename, List list){ - if(getBoolValue(boolname, true)){ + if (getBoolValue(boolname, true)) { try { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getContext().getAssets().open(filename))); while(true) { String readLine = bufferedReader.readLine(); - if(readLine != null){ + if (readLine != null) { list.add(readLine); } else { bufferedReader.close(); @@ -97,39 +97,39 @@ public class Newsfeed{ public static boolean injectFilters(JSONObject obj) throws JSONException{ var optString = obj.optString("type", ""); - if(isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString) || isRecomsGroup(optString) || isMusicBlock(optString) || isNewsBlock(optString)){ + if (isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString) || isRecomsGroup(optString) || isMusicBlock(optString) || isNewsBlock(optString)) { return false; } optString = obj.optString("post_type", ""); - if(isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString) || isMusicBlock(optString) || isNewsBlock(optString)){ + if (isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString) || isMusicBlock(optString) || isNewsBlock(optString)) { return false; } optString = obj.optString("filters", ""); - if(isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString)){ + if (isAds(optString) || isAuthorRecommendations(optString) || isPostRecommendations(optString) || isFriendsRecommendations(optString)) { return false; } - if(checkCopyright(obj)) return false; + if (checkCopyright(obj)) return false; - if(isBadNew(obj.optString("text", ""))) return false; + if (isBadNew(obj.optString("text", ""))) return false; - if(checkCaption(obj)) return false; + if (checkCaption(obj)) return false; - if(isGroupAds(obj)) return false; + if (isGroupAds(obj)) return false; return !injectFiltersReposts(obj); } // inject our filters to newsfeed, getpost and discover public static boolean injectFiltersReposts(JSONObject obj){ - if(obj.optJSONArray("copy_history") == null) return false; + if (obj.optJSONArray("copy_history") == null) return false; var Array = Objects.requireNonNull(obj.optJSONArray("copy_history")).toString(); - if(Array.isEmpty()) return false; + if (Array.isEmpty()) return false; - if(getBoolValue("cringerepost", false)){ - for(String linkfilters : mFiltersLinks) { - if(Array.toLowerCase().contains(linkfilters.toLowerCase())){ + if (getBoolValue("cringerepost", false)) { + for (String linkfilters : mFiltersLinks) { + if (Array.toLowerCase().contains(linkfilters.toLowerCase())) { return true; } } @@ -139,12 +139,12 @@ public class Newsfeed{ } // get repost information and inject our text filters private static boolean checkCopyright(JSONObject json) throws JSONException{ - if(json.opt("copyright") != null){ + if (json.opt("copyright") != null) { var copyright = json.getJSONObject("copyright"); var copyrightlink = copyright.getString("link"); - for(String linkfilters : mFiltersLinks) { - if(copyrightlink.toLowerCase().contains(linkfilters.toLowerCase())){ + for (String linkfilters : mFiltersLinks) { + if (copyrightlink.toLowerCase().contains(linkfilters.toLowerCase())) { return true; } } @@ -170,9 +170,9 @@ public class Newsfeed{ } public static boolean isBadNew(String text){ - for(String filter : mFilters) { - if(text.toLowerCase().contains(filter.toLowerCase())){ - if(dev()) Log.d("VTLite", text.toLowerCase()); + for (String filter : mFilters) { + if (text.toLowerCase().contains(filter.toLowerCase())) { + if (dev()) Log.d("VTLite", text.toLowerCase()); return true; } } @@ -182,7 +182,7 @@ public class Newsfeed{ public static boolean checkCaption(JSONObject postJson){ try { var captionJson = postJson.getJSONObject("caption"); - if(Preferences.captions()) + if (Preferences.captions()) return true; boolean postAds = postsrecomm(); @@ -228,7 +228,7 @@ public class Newsfeed{ } public static long getUpdateNewsfeed(boolean refresh_timeout){ - if(vkme()){ + if (vkme()) { return MAX_VALUE; } switch(getPrefsValue("newsupdate")) { @@ -242,7 +242,7 @@ public class Newsfeed{ } public static Class getStartFragment(){ - if(vkme()){ + if (vkme()) { return DialogsFragment.class; } switch(getPrefsValue("start_values")) { diff --git a/app/src/main/java/ru/vtosters/lite/utils/OTAHelper.java b/app/src/main/java/ru/vtosters/lite/utils/OTAHelper.java index 984b2d0c3..364a64113 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/OTAHelper.java +++ b/app/src/main/java/ru/vtosters/lite/utils/OTAHelper.java @@ -69,7 +69,7 @@ public class OTAHelper{ public void a(Call call, Response response) throws IOException{ try { mCommitJson = new JSONObject(response.a().g()); - if(isNewVersion()) + if (isNewVersion()) mListener.onUpdateApplied(); else mListener.onUpdateCanceled(); } catch (NullPointerException | JSONException e) { diff --git a/app/src/main/java/ru/vtosters/lite/utils/OnlineFormatter.java b/app/src/main/java/ru/vtosters/lite/utils/OnlineFormatter.java index 597a82d14..a951625e7 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/OnlineFormatter.java +++ b/app/src/main/java/ru/vtosters/lite/utils/OnlineFormatter.java @@ -16,7 +16,7 @@ public class OnlineFormatter{ private static String AppName; public static String getAppName(int appid){ // thanks to egormetlitsky (vk mp3 mod) for helping with online ids - if(appid <= 3) return null; + if (appid <= 3) return null; switch(appid) { case 2274003: @@ -130,7 +130,7 @@ public class OnlineFormatter{ var prefs = getPrefsFromFile("onlines"); var appname = prefs.getString(String.valueOf(appid), null); - if(appname != null) return appname; + if (appname != null) return appname; makeRequest("https://" + getApi() + "/method/apps.get?app_id=" + appid + "&v=5.99&access_token=" + getUserToken(), response -> { @@ -143,7 +143,7 @@ public class OnlineFormatter{ prefs.edit().putString(String.valueOf(appid), AppName).apply(); - if(dev()) sendToast("AppName: " + AppName + " for appid: " + appid); + if (dev()) sendToast("AppName: " + AppName + " for appid: " + appid); } catch (JSONException e) { e.printStackTrace(); } @@ -155,7 +155,7 @@ public class OnlineFormatter{ public static String getOnline(int appid){ var appname = getAppName(appid); - if(appname == null) return null; + if (appname == null) return null; return getString("custom_online") + " " + appname; } diff --git a/app/src/main/java/ru/vtosters/lite/utils/OpusLoader.java b/app/src/main/java/ru/vtosters/lite/utils/OpusLoader.java index 96b61e612..9cd61d189 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/OpusLoader.java +++ b/app/src/main/java/ru/vtosters/lite/utils/OpusLoader.java @@ -18,13 +18,13 @@ public class OpusLoader{ System.loadLibrary(libname); inited = true; } catch (UnsatisfiedLinkError unused2) { - if(dev()) Log.d("VTLite", "Failed to load " + libname); + if (dev()) Log.d("VTLite", "Failed to load " + libname); inited = false; } } public static long getLength(){ - if(isReadyToUse()){ + if (isReadyToUse()) { long length = System.currentTimeMillis() - timetracker; timetracker = System.currentTimeMillis(); return length; @@ -33,7 +33,7 @@ public class OpusLoader{ } public static int AudioStartRecordBridge(String str){ - if(isReadyToUse()){ + if (isReadyToUse()) { // Init custom AudioStartRecord timetracker = System.currentTimeMillis(); return 1; @@ -42,14 +42,14 @@ public class OpusLoader{ } public static int AudioWriteFrameBridge(ByteBuffer buffer, int length){ - if(isReadyToUse()){ + if (isReadyToUse()) { // Init custom AudioWriteFrame } return MediaNative.audioWriteFrame(buffer, length); } public static void AudioStopRecordBridge(){ - if(isReadyToUse()){ + if (isReadyToUse()) { // Init custom AudioStopRecord } MediaNative.audioStopRecord(); diff --git a/app/src/main/java/ru/vtosters/lite/utils/PollUtils.java b/app/src/main/java/ru/vtosters/lite/utils/PollUtils.java index 3ba439536..b62fdfbba 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/PollUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/PollUtils.java @@ -10,8 +10,8 @@ import com.vk.dto.polls.PollOption; import com.vk.polls.ui.views.PollOptionView; public class PollUtils{ - public static void show(PollOptionView view) { - if(!getBoolValue("pollresults", false)) return; + public static void show(PollOptionView view){ + if (!getBoolValue("pollresults", false)) return; TextView resultsView = view.c; diff --git a/app/src/main/java/ru/vtosters/lite/utils/Preferences.java b/app/src/main/java/ru/vtosters/lite/utils/Preferences.java index 3bcf8d356..549dc08dc 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Preferences.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Preferences.java @@ -49,13 +49,13 @@ public class Preferences{ getInstance().autoCleaningCache(); edit().putBoolean("isdark", isDarkTheme()).commit(); - if(setoffline() && offline()){ + if (setoffline() && offline()) { Users.a(); } } public static boolean getBoolValue(String key, Boolean value){ - if(preferences == null){ + if (preferences == null) { preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); } return preferences.getBoolean(key, value); @@ -346,8 +346,8 @@ public class Preferences{ } public static int compress(int origquality){ - if(getBoolValue("shakal", false)) return 5; - if(!getBoolValue("compressPhotos", true)) return 100; + if (getBoolValue("shakal", false)) return 5; + if (!getBoolValue("compressPhotos", true)) return 100; return origquality; } } diff --git a/app/src/main/java/ru/vtosters/lite/utils/ProfileHide.java b/app/src/main/java/ru/vtosters/lite/utils/ProfileHide.java index e6a2027bc..bf57501d0 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ProfileHide.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ProfileHide.java @@ -23,76 +23,76 @@ import okhttp3.Request; import ru.vtosters.lite.f0x1d.VTVerifications; // Jesus cries -public class ProfileHide { - private static final OkHttpClient mClient = new OkHttpClient(); +public class ProfileHide{ + private static final OkHttpClient mClient = new OkHttpClient(); - public static void injectMap(HashMap hashMap) { - if (VTVerifications.isServiceAccount(getUserId())) { - hashMap.put(100, makeSecond( - "service_account_admin_100_info", - "service_account_admin_100", - "ic_custom_avatar_id100") - ); - hashMap.put(101, makeSecond( - "service_account_admin_101_info", - "service_account_admin_101", - "ic_custom_avatar_id101") - ); - hashMap.put(333, makeSecond( - "service_account_mobile_info", - "service_account_admin_333", - "ic_custom_avatar_id333") - ); - } - } + public static void injectMap(HashMap hashMap){ + if (VTVerifications.isServiceAccount(getUserId())) { + hashMap.put(100, makeSecond( + "service_account_admin_100_info", + "service_account_admin_100", + "ic_custom_avatar_id100") + ); + hashMap.put(101, makeSecond( + "service_account_admin_101_info", + "service_account_admin_101", + "ic_custom_avatar_id101") + ); + hashMap.put(333, makeSecond( + "service_account_mobile_info", + "service_account_admin_333", + "ic_custom_avatar_id333") + ); + } + } - private static UserPresenter.a.a makeSecond(String stringRes, String colorRes, String drawableRes) { - return new UserPresenter.a.a( - getIdentifier(stringRes, "string"), - getIdentifier(colorRes, "color"), - getIdentifier(drawableRes, "drawable") - ); - } + private static UserPresenter.a.a makeSecond(String stringRes, String colorRes, String drawableRes){ + return new UserPresenter.a.a( + getIdentifier(stringRes, "string"), + getIdentifier(colorRes, "color"), + getIdentifier(drawableRes, "drawable") + ); + } - public static void fetchInfo(ExtendedUserProfile extendedUserProfile) { - int userID = getUserID(extendedUserProfile.a); - if (VTVerifications.isServiceAccount(userID)) { - Request request = new Request.a() - .b("https://sf.vknext.net/block_text?user_id=" + userID) - .a(); - try { - JSONObject payload = new JSONObject(mClient.a(request) - .execute() - .c() - .a() - .g()); - String response = payload.optJSONObject(MsgSendVc.d0).optString("response"); - if (!response.isEmpty()) { - Field z2 = ExtendedUserProfile.class.getDeclaredField("z2"); - z2.setAccessible(true); - z2.set(extendedUserProfile, response); - } - } catch (IOException | JSONException | NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } catch (NullPointerException e) { - Log.e("ProfileHide", "null \"profiles\" node\n" + e); - } - } - } + public static void fetchInfo(ExtendedUserProfile extendedUserProfile){ + int userID = getUserID(extendedUserProfile.a); + if (VTVerifications.isServiceAccount(userID)) { + Request request = new Request.a() + .b("https://sf.vknext.net/block_text?user_id=" + userID) + .a(); + try { + JSONObject payload = new JSONObject(mClient.a(request) + .execute() + .c() + .a() + .g()); + String response = payload.optJSONObject(MsgSendVc.d0).optString("response"); + if (!response.isEmpty()) { + Field z2 = ExtendedUserProfile.class.getDeclaredField("z2"); + z2.setAccessible(true); + z2.set(extendedUserProfile, response); + } + } catch (IOException | JSONException | NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } catch (NullPointerException e) { + Log.e("ProfileHide", "null \"profiles\" node\n" + e); + } + } + } - public static String getInfo(ExtendedUserProfile extendedUserProfile) { - int userID = getUserID(extendedUserProfile); - if (VTVerifications.isServiceAccount(userID)) { - try { - Field z2 = ExtendedUserProfile.class.getDeclaredField("z2"); - z2.setAccessible(true); - String val = (String) z2.get(extendedUserProfile); - if (val != null && !val.isEmpty()) - return val; - } catch (NoSuchFieldException | IllegalAccessException e) { - e.printStackTrace(); - } - } - return getContext().getString(UserPresenter.q0.a(userID)); - } + public static String getInfo(ExtendedUserProfile extendedUserProfile){ + int userID = getUserID(extendedUserProfile); + if (VTVerifications.isServiceAccount(userID)) { + try { + Field z2 = ExtendedUserProfile.class.getDeclaredField("z2"); + z2.setAccessible(true); + String val = (String) z2.get(extendedUserProfile); + if (val != null && !val.isEmpty()) + return val; + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + } + return getContext().getString(UserPresenter.q0.a(userID)); + } } diff --git a/app/src/main/java/ru/vtosters/lite/utils/Proxy.java b/app/src/main/java/ru/vtosters/lite/utils/Proxy.java index 53ad383a5..a4bd26090 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Proxy.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Proxy.java @@ -16,24 +16,24 @@ public class Proxy{ var proxyoauth = getPrefsValue("proxyoauth"); var proxystatic = getPrefsValue("proxystatic"); - if(!apiproxy() || link.isEmpty()){ + if (!apiproxy() || link.isEmpty()) { return link; } - if(proxyapi.isEmpty() || proxyoauth.isEmpty() || proxystatic.isEmpty()){ + if (proxyapi.isEmpty() || proxyoauth.isEmpty() || proxystatic.isEmpty()) { Log.d("VTLite", "Proxy is not set" + " " + proxyapi + " " + proxyoauth + " " + proxystatic); return link; } - if(link.contains(vkapi)){ + if (link.contains(vkapi)) { return link.replace(proxyapi, vkapi); } - if(link.contains(oauth)){ + if (link.contains(oauth)) { return link.replace(proxyoauth, oauth); } - if(link.contains(vkstatic)){ + if (link.contains(vkstatic)) { return link.replace(proxystatic, vkstatic); } @@ -43,7 +43,7 @@ public class Proxy{ public static String getApi(){ var proxyapi = getPrefsValue("proxyapi"); - if(apiproxy() & !proxyapi.isEmpty()){ + if (apiproxy() & !proxyapi.isEmpty()) { return proxyapi; } @@ -53,7 +53,7 @@ public class Proxy{ public static String getAwayPhpCom(){ var proxyapi = getPrefsValue("proxyapi"); - if(apiproxy() & !proxyapi.isEmpty()){ + if (apiproxy() & !proxyapi.isEmpty()) { return proxyapi; } @@ -97,21 +97,21 @@ public class Proxy{ } public static void resetProxy(String except){ - if(!except.equals("https")){ + if (!except.equals("https")) { clearProperty("https.proxyHost"); clearProperty("https.proxyPort"); clearProperty("https.proxyUser"); clearProperty("https.proxyPassword"); } - if(!except.equals("http")){ + if (!except.equals("http")) { clearProperty("http.proxyHost"); clearProperty("http.proxyPort"); clearProperty("http.proxyUser"); clearProperty("http.proxyPassword"); } - if(except.equals("socks") || except.equals("zaborona")){ + if (except.equals("socks") || except.equals("zaborona")) { return; } diff --git a/app/src/main/java/ru/vtosters/lite/utils/ProxyHook.java b/app/src/main/java/ru/vtosters/lite/utils/ProxyHook.java index c47c88312..3f3247553 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ProxyHook.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ProxyHook.java @@ -3,8 +3,9 @@ import static ru.vtosters.lite.utils.Globals.convertDpToPixel; import static ru.vtosters.lite.utils.Globals.edit; import static ru.vtosters.lite.utils.Globals.restartApplication; import static ru.vtosters.lite.utils.Proxy.isZaboronaEnabled; -import static ru.vtosters.lite.utils.Themes.*; +import static ru.vtosters.lite.utils.Themes.getAccentColor; import static ru.vtosters.lite.utils.Themes.getAlertStyle; +import static ru.vtosters.lite.utils.Themes.getTextAttr; import android.annotation.SuppressLint; import android.content.Context; @@ -24,14 +25,14 @@ import com.vk.navigation.Navigator; import ru.vtosters.lite.ui.fragments.ProxySettingsFragment; public class ProxyHook{ - public static void hookAuth(View v) { + public static void hookAuth(View v){ VkAuthTextView button = (VkAuthTextView) v; button.setText("Настроить прокси"); button.setOnClickListener(v1 -> callProxyDialog(v1.getContext())); } @SuppressLint("SetTextI18n") - public static void callProxyDialog(Context ctx) { + public static void callProxyDialog(Context ctx){ RadioGroup rg = new RadioGroup(ctx); RadioButton rgDefault = new RadioButton(new ContextThemeWrapper(ctx, com.vtosters.lite.R.style.Widget_AppCompat_CompoundButton_RadioButton)); @@ -59,24 +60,24 @@ public class ProxyHook{ builder.setMessage("Zaborona никак не связана с ВТостерс и мы не можем гарантировать её работу и безопасность"); builder.setView(rg); builder.setPositiveButton("Применить", ((dialog, which) -> { - if (rgProxy.isChecked()){ - edit().putString("proxy", "zaborona").commit(); - restartApplication(); - } else { - if(isZaboronaEnabled()){ - edit().putString("proxy", "noproxy").commit(); - restartApplication(); - } + if (rgProxy.isChecked()) { + edit().putString("proxy", "zaborona").commit(); + restartApplication(); + } else { + if (isZaboronaEnabled()) { + edit().putString("proxy", "noproxy").commit(); + restartApplication(); + } - edit().putString("proxy", "noproxy").commit(); - } - })); + edit().putString("proxy", "noproxy").commit(); + } + })); builder.setNeutralButton("Настройки прокси", ((dialog, which) -> { - Intent a2 = new Navigator(ProxySettingsFragment.class).b(ctx); - a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - ctx.startActivity(a2); - })); + Intent a2 = new Navigator(ProxySettingsFragment.class).b(ctx); + a2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + ctx.startActivity(a2); + })); var alert = builder.create(); diff --git a/app/src/main/java/ru/vtosters/lite/utils/ReflectionUtils.java b/app/src/main/java/ru/vtosters/lite/utils/ReflectionUtils.java index 2c9fc824d..458b38025 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ReflectionUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ReflectionUtils.java @@ -12,7 +12,7 @@ public class ReflectionUtils{ * Supports smali type (Lpackage/Class;) */ public static Class getClass(String name) throws ClassNotFoundException{ - if(name.contains(";")) + if (name.contains(";")) name = name.substring(1, name.length() - 1).replace("/", "."); return Class.forName(name); } @@ -117,7 +117,7 @@ public class ReflectionUtils{ field = clz.getDeclaredField(fieldName); } - if(!Modifier.isFinal(field.getModifiers())) return; + if (!Modifier.isFinal(field.getModifiers())) return; unlockField(field); field.set(instance, value); @@ -131,7 +131,7 @@ public class ReflectionUtils{ field = getDeclaredField(className, fieldName); } - if(!Modifier.isFinal(field.getModifiers())) return; + if (!Modifier.isFinal(field.getModifiers())) return; unlockField(field); field.set(instance, value); @@ -171,7 +171,7 @@ public class ReflectionUtils{ field = clz.getDeclaredField(fieldName); } - if(!Modifier.isFinal(field.getModifiers())) return; + if (!Modifier.isFinal(field.getModifiers())) return; unlockField(field); field.set(null, value); @@ -185,7 +185,7 @@ public class ReflectionUtils{ field = getDeclaredField(className, fieldName); } - if(!Modifier.isFinal(field.getModifiers())) return; + if (!Modifier.isFinal(field.getModifiers())) return; unlockField(field); field.set(null, value); @@ -221,7 +221,7 @@ public class ReflectionUtils{ public static Method getMethod(Class clz, String methodName, Object... parameters) throws NoSuchMethodException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method = getMethod(clz, methodName, parameterTypes); @@ -231,7 +231,7 @@ public class ReflectionUtils{ public static Method getMethod(String className, String methodName, Object... parameters) throws ClassNotFoundException, NoSuchMethodException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method = getMethod(className, methodName, parameterTypes); @@ -256,7 +256,7 @@ public class ReflectionUtils{ public static Method getDeclaredMethod(Class clz, String methodName, Object... parameters) throws NoSuchMethodException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method = getDeclaredMethod(clz, methodName, parameterTypes); @@ -266,7 +266,7 @@ public class ReflectionUtils{ public static Method getDeclaredMethod(String className, String methodName, Object... parameters) throws ClassNotFoundException, NoSuchMethodException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method = getDeclaredMethod(className, methodName, parameterTypes); @@ -299,7 +299,7 @@ public class ReflectionUtils{ public static T invokeMethod(Class clz, String methodName, Object instance, Object... parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method; @@ -313,7 +313,7 @@ public class ReflectionUtils{ public static T invokeMethod(String className, String methodName, Object instance, Object... parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method; @@ -350,7 +350,7 @@ public class ReflectionUtils{ public static T invokeStaticMethod(Class clz, String methodName, Object... parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method; @@ -364,7 +364,7 @@ public class ReflectionUtils{ public static T invokeStaticMethod(String className, String methodName, Object... parameters) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, ClassNotFoundException{ Class[] parameterTypes = new Class[parameters.length]; - for(int i = 0; i < parameters.length; i++) { + for (int i = 0; i < parameters.length; i++) { parameterTypes[i] = parameters[i].getClass(); } Method method; diff --git a/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java b/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java index bc5add6fc..ca833020e 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java +++ b/app/src/main/java/ru/vtosters/lite/utils/RenameTool.java @@ -10,8 +10,9 @@ import static ru.vtosters.lite.utils.Globals.getUserID; import static ru.vtosters.lite.utils.Globals.getUserId; import static ru.vtosters.lite.utils.Globals.getUserLastName; import static ru.vtosters.lite.utils.Globals.sendToast; -import static ru.vtosters.lite.utils.Themes.*; +import static ru.vtosters.lite.utils.Themes.getAccentColor; import static ru.vtosters.lite.utils.Themes.getAlertStyle; +import static ru.vtosters.lite.utils.Themes.getTextAttr; import android.content.Context; import android.content.DialogInterface; @@ -56,7 +57,7 @@ public class RenameTool{ private static boolean updateRequested = true; protected static RenameTool.DbHelper getHelper(){ - if(helperInstance == null){ + if (helperInstance == null) { helperInstance = new RenameTool.DbHelper(getContext()); } return helperInstance; @@ -64,7 +65,7 @@ public class RenameTool{ public static String getCurrentModifiedUser(){ Cursor rawQuery = getHelper().getReadableDatabase().rawQuery(String.format("SELECT * FROM %s WHERE %s=%s", TABLE_NAME, COLUMN_VKID, getCurrentUserID()), new String[0]); - if(rawQuery.moveToFirst()){ + if (rawQuery.moveToFirst()) { try { String decode = URLDecoder.decode(rawQuery.getString(rawQuery.getColumnIndexOrThrow(COLUMN_FIRSTNAME)), "UTF-8"); return decode + " " + URLDecoder.decode(rawQuery.getString(rawQuery.getColumnIndexOrThrow(COLUMN_LASTNAME)), "UTF-8"); @@ -83,24 +84,24 @@ public class RenameTool{ public static void injectIntoJson(JSONObject obj) throws JSONException{ int i = obj.getInt("id"); - if(updateRequested){ + if (updateRequested) { reloadDB(); } Pair user = renamedUsers.get(i); - if(user == null) return; + if (user == null) return; obj.put(COLUMN_FIRSTNAME, user.first).put(COLUMN_LASTNAME, user.second); } public static void injectIntoJsonGroup(JSONObject obj) throws JSONException{ int i = obj.getInt("id"); - if(updateRequested){ + if (updateRequested) { reloadDB(); } String user = renamedGroups.get(i); - if(user == null) return; + if (user == null) return; obj.put("name", user); } @@ -134,12 +135,12 @@ public class RenameTool{ public static void injectIntoChat(User u){ int id = u.getId(); - if(updateRequested){ + if (updateRequested) { reloadDB(); } Pair user = renamedUsers.get(id); - if(user == null) return; + if (user == null) return; setObject(u, "I", user.first); setObject(u, "J", user.second); @@ -194,13 +195,13 @@ public class RenameTool{ String lastName = ln.getText().toString(); SQLiteDatabase writableDatabase = getHelper().getWritableDatabase(); try { - if(isChangedName(id)){ + if (isChangedName(id)) { writableDatabase.execSQL(String.format("UPDATE %s SET %s='%s', %s='%s' WHERE %s='%s'", TABLE_NAME, COLUMN_FIRSTNAME, URLEncoder.encode(firstName, "UTF-8"), COLUMN_LASTNAME, URLEncoder.encode(lastName, "UTF-8"), COLUMN_VKID, id)); } else { writableDatabase.execSQL(String.format("INSERT INTO %s (%s, %s, %s) VALUES (%s, '%s', '%s')", TABLE_NAME, COLUMN_VKID, COLUMN_FIRSTNAME, COLUMN_LASTNAME, id, URLEncoder.encode(firstName, "UTF-8"), URLEncoder.encode(lastName, "UTF-8"))); } updateRequested = true; - if(id == getCurrentUserID()){ + if (id == getCurrentUserID()) { ctx.sendBroadcast(new Intent("com.vkontakte.android.USER_NAME_CHANGED")); } ctx.sendBroadcast(new Intent("com.vkontakte.android.ACTION_PROFILE_UPDATED").putExtra("uid", id)); @@ -210,9 +211,9 @@ public class RenameTool{ e.printStackTrace(); } }); - if(isChangedName(id)) builder.setNeutralButton("Сбросить", (dialog, which) -> { + if (isChangedName(id)) builder.setNeutralButton("Сбросить", (dialog, which) -> { getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME, COLUMN_VKID, id)); - if(id == getCurrentUserID()){ + if (id == getCurrentUserID()) { ctx.sendBroadcast(new Intent("com.vkontakte.android.USER_NAME_CHANGED")); } updateRequested = true; @@ -247,7 +248,7 @@ public class RenameTool{ fn.setText(getGroupName(profile)); int fid = getUserID(profile); - if(fid < 0) fid = -fid; + if (fid < 0) fid = -fid; final int id = fid; @@ -259,7 +260,7 @@ public class RenameTool{ String firstName = fn.getText().toString(); SQLiteDatabase writableDatabase = getHelper().getWritableDatabase(); try { - if(isChangedNameGroup(id)){ + if (isChangedNameGroup(id)) { writableDatabase.execSQL(String.format("UPDATE %s SET %s='%s' WHERE %s='%s'", TABLE_NAME_GROUP, COLUMN_NAME, URLEncoder.encode(firstName, "UTF-8"), COLUMN_VKID, id)); } else { writableDatabase.execSQL(String.format("INSERT INTO %s (%s, %s) VALUES (%s, '%s')", TABLE_NAME_GROUP, COLUMN_VKID, COLUMN_NAME, id, URLEncoder.encode(firstName, "UTF-8"))); @@ -270,7 +271,7 @@ public class RenameTool{ e.printStackTrace(); } }); - if(isChangedNameGroup(id)) builder.setNeutralButton("Сбросить", (dialog, which) -> { + if (isChangedNameGroup(id)) builder.setNeutralButton("Сбросить", (dialog, which) -> { getHelper().getWritableDatabase().execSQL(String.format("DELETE FROM %s WHERE %s='%s'", TABLE_NAME_GROUP, COLUMN_VKID, id)); updateRequested = true; sendToast("Сообщество успешно удалено из базы данных!"); @@ -307,7 +308,7 @@ public class RenameTool{ } public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){ - if(newVersion == 2){ + if (newVersion == 2) { db.execSQL(String.format("CREATE TABLE %s (%s INTEGER PRIMARY KEY AUTOINCREMENT, %s INTEGER, %s TEXT)", TABLE_NAME_GROUP, "_id", COLUMN_VKID, COLUMN_NAME)); } } diff --git a/app/src/main/java/ru/vtosters/lite/utils/SSFS.java b/app/src/main/java/ru/vtosters/lite/utils/SSFS.java index 747fbfa48..4be431ff2 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/SSFS.java +++ b/app/src/main/java/ru/vtosters/lite/utils/SSFS.java @@ -18,7 +18,7 @@ public class SSFS{ public static String SSFSDomain(){ String string = getPrefsValue("ssfscustom"); - if(!string.isEmpty()) return string; + if (!string.isEmpty()) return string; return "https://vtsf.vknext.net"; } diff --git a/app/src/main/java/ru/vtosters/lite/utils/ServerDialog.java b/app/src/main/java/ru/vtosters/lite/utils/ServerDialog.java index 3e4180a8e..8f8411c4b 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/ServerDialog.java +++ b/app/src/main/java/ru/vtosters/lite/utils/ServerDialog.java @@ -35,7 +35,7 @@ public class ServerDialog{ private static Boolean isNotForVerified; public static void sendRequest(){ - if(getBoolValue("dialogrecomm", false)) return; + if (getBoolValue("dialogrecomm", false)) return; Request request = new Request.a() .b("https://vtosters.app/dialog.json") @@ -62,7 +62,7 @@ public class ServerDialog{ private static Boolean showForNotVerified(){ int random = new Random().nextInt(6); - if(isNotForVerified){ + if (isNotForVerified) { return !hasVerification() && random != 0; } @@ -74,7 +74,7 @@ public class ServerDialog{ Log.d("VTLOG", "getResponse: " + jSONObject); - if(jSONObject.getString("title").equals("")){ + if (jSONObject.getString("title").equals("")) { showAlert = false; return; } @@ -90,7 +90,7 @@ public class ServerDialog{ showAlert = true; - if(activity != null){ + if (activity != null) { activity.runOnUiThread(() -> { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(title); @@ -101,7 +101,7 @@ public class ServerDialog{ edit().putBoolean(key, false).apply(); activity.startActivity(new Intent("android.intent.action.VIEW").setData(Uri.parse(link))); }); - if(getBoolValue(key, true) && showForNotVerified() && showAlert){ + if (getBoolValue(key, true) && showForNotVerified() && showAlert) { builder.show(); } }); diff --git a/app/src/main/java/ru/vtosters/lite/utils/SettBackup.java b/app/src/main/java/ru/vtosters/lite/utils/SettBackup.java index 9e942704a..0460be47e 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/SettBackup.java +++ b/app/src/main/java/ru/vtosters/lite/utils/SettBackup.java @@ -75,7 +75,7 @@ public class SettBackup{ public static String getPrefContent(String filename) throws IOException{ File prefsDir = new File(getContext().getFilesDir().getParentFile(), "shared_prefs"); - if(!prefsDir.exists()) + if (!prefsDir.exists()) return null; File pref = new File(prefsDir, filename); return new String(readFileFully(pref)); @@ -88,12 +88,12 @@ public class SettBackup{ Scanner scanner = new Scanner(new String(readFileFully(pref))); while(scanner.hasNextLine()) { String line = scanner.nextLine().trim(); - if(line.contains("") || line.contains("")) + if (line.contains("") || line.contains("")) continue; - if(line.startsWith(""); Matcher matcher = pattern.matcher(line); - if(!matcher.find()) continue; + if (!matcher.find()) continue; String name = matcher.group(1); Set set = new HashSet<>(); String _line; @@ -102,50 +102,50 @@ public class SettBackup{ } editor.putStringSet(name, set) .commit(); - if(!Preferences.dev()) continue; + if (!Preferences.dev()) continue; Log.d("Prefs", "Append " + name + " : " + set); - } else if(line.startsWith("<")){ + } else if (line.startsWith("<")) { Pattern pattern = Pattern.compile("^<(.+) name=\"(.+)\">(.+)$"); Matcher matcher = pattern.matcher(line); String type = "", name = "", value = ""; - if(!matcher.find()){ + if (!matcher.find()) { pattern = Pattern.compile("^<(.+) name=\"(.+?)\" value=\"(.+?)\" />$"); matcher = pattern.matcher(line); - if(!matcher.find()) continue; + if (!matcher.find()) continue; } type = matcher.group(1); name = matcher.group(2); value = matcher.group(3); - if(type.equals("string")) + if (type.equals("string")) editor.putString( name, value ).commit(); - else if(type.equals("boolean")) + else if (type.equals("boolean")) editor.putBoolean( name, Boolean.parseBoolean(value) ).commit(); - else if(type.equals("float")) + else if (type.equals("float")) editor.putFloat( name, Float.parseFloat(value) ).commit(); - else if(type.equals("int")) + else if (type.equals("int")) editor.putInt( name, Integer.parseInt(value) ).commit(); - else if(type.equals("long")) + else if (type.equals("long")) editor.putLong( name, Long.parseLong(value) ).commit(); - if(!Preferences.dev()) continue; + if (!Preferences.dev()) continue; Log.d("Prefs", "Append " + name + " : " + value); } } - if(!Preferences.dev()) return; + if (!Preferences.dev()) return; File prefsDir = new File(getContext().getFilesDir().getParentFile(), "shared_prefs"); File file = new File(prefsDir, "com.vtosters.lite_preferences.xml"); Log.d("TAG", new String(readFileFully(file))); diff --git a/app/src/main/java/ru/vtosters/lite/utils/SignatureChecker.java b/app/src/main/java/ru/vtosters/lite/utils/SignatureChecker.java index e613798c9..51c41d5f4 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/SignatureChecker.java +++ b/app/src/main/java/ru/vtosters/lite/utils/SignatureChecker.java @@ -27,7 +27,7 @@ public class SignatureChecker{ '9', 'A', 'B', 'C', 'D', 'E', 'F'}; char[] hexChars = new char[bytes.length * 2]; int v; - for(int j = 0; j < bytes.length; j++) { + for (int j = 0; j < bytes.length; j++) { v = bytes[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2 + 1] = hexArray[v & 0x0F]; @@ -37,7 +37,7 @@ public class SignatureChecker{ public static boolean validateAppSignature() throws NameNotFoundException, NoSuchAlgorithmException{ @SuppressLint("PackageManagerGetSignatures") PackageInfo packageInfo = getContext().getPackageManager().getPackageInfo(getPackageName(), GET_SIGNATURES); - for(Signature signature : packageInfo.signatures) { + for (Signature signature : packageInfo.signatures) { String sha1 = getSHA1(signature.toByteArray()); return Base64Utils.decode(APP_SIGNATURE).equals(sha1); } diff --git a/app/src/main/java/ru/vtosters/lite/utils/StreamUtils.java b/app/src/main/java/ru/vtosters/lite/utils/StreamUtils.java index 67e370a17..8fe14d169 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/StreamUtils.java +++ b/app/src/main/java/ru/vtosters/lite/utils/StreamUtils.java @@ -21,15 +21,15 @@ import javax.crypto.NoSuchPaddingException; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -public class StreamUtils { +public class StreamUtils{ public static final int BUFFER_SIZE = 0x800; - public static byte[] decodeStream(InputStream encIs, String keyURL) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IOException { + public static byte[] decodeStream(InputStream encIs, String keyURL) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IOException{ CipherInputStream cip = new CipherInputStream(encIs, getCipher(keyURL)); return readAllBytes(cip); } - public static Cipher getCipher(String key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IOException { + public static Cipher getCipher(String key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IOException{ Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); Key keySpec = new SecretKeySpec(key.getBytes(), "AES"); // bypassing ecb @@ -40,37 +40,37 @@ public class StreamUtils { return cipher; } - public static InputStream openStream(String url) throws IOException { + public static InputStream openStream(String url) throws IOException{ URLConnection connection = new URL(url).openConnection(); return connection.getInputStream(); } - public static String readAllLines(File file) throws IOException { + public static String readAllLines(File file) throws IOException{ return readAllLines(new FileInputStream(file)); } - public static String readAllLines(InputStream is) throws IOException { + public static String readAllLines(InputStream is) throws IOException{ return new String(readAllBytes(is), "utf-8"); } - public static byte[] readAllBytes(File file) throws IOException { + public static byte[] readAllBytes(File file) throws IOException{ return readAllBytes(new FileInputStream(file)); } - public static byte[] readAllBytes(InputStream is) throws IOException { + public static byte[] readAllBytes(InputStream is) throws IOException{ ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int len; - while ((len = is.read(buffer)) > 0) + while((len = is.read(buffer)) > 0) bos.write(buffer, 0, len); return bos.toByteArray(); } - public static void writeToFile(File file, String content) throws IOException { + public static void writeToFile(File file, String content) throws IOException{ writeToFile(file, content.getBytes(StandardCharsets.UTF_8)); } - public static void writeToFile(File file, byte[] content) throws IOException { + public static void writeToFile(File file, byte[] content) throws IOException{ FileOutputStream fos = new FileOutputStream(file); fos.write(content); } diff --git a/app/src/main/java/ru/vtosters/lite/utils/Themes.java b/app/src/main/java/ru/vtosters/lite/utils/Themes.java index e27e69d2d..5944b879b 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/Themes.java +++ b/app/src/main/java/ru/vtosters/lite/utils/Themes.java @@ -52,7 +52,7 @@ public class Themes{ } // Apply VKTheme and ImTheme (hard applying without dynamic theme changing) public static void setTheme(VKTheme theme, Activity activity){ - if(activity == null) activity = getCurrentActivity(); + if (activity == null) activity = getCurrentActivity(); VKThemeHelper.theme(theme, activity, getCenterScreenCoords()); ThemeTracker.a(); isLoaded = false; @@ -117,7 +117,7 @@ public class Themes{ } public static void setBarTheme(View getview){ - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { getview.setSystemUiVisibility(getNeededColorNavbar() | getNeededColorStatusbar()); } } // Set white/dark statusbar/navbar icons @@ -131,7 +131,7 @@ public class Themes{ } public static int getDarkThemeRes(){ - if(getPrefsValue("darktheme").equals("amoled")){ + if (getPrefsValue("darktheme").equals("amoled")) { return isMilkshake() ? getIdentifier("VkMilkAmoledStyle", "style") : getIdentifier("VkAmoledStyle", "style"); } return isMilkshake() ? R.style.VkMilkDarkStyle : R.style.VkDarkStyle; @@ -154,7 +154,7 @@ public class Themes{ } public static void colorWriteBar(View view){ - if(!navbar()) return; + if (!navbar()) return; view.setBackgroundColor(getTabbarBackground()); } @@ -163,8 +163,8 @@ public class Themes{ } public static boolean isColorRefAccented(int color){ - for(int accent : new int[]{R.color.accent_blue, R.color.azure_A400, R.color.blue, R.color.blue_200, R.color.blue_200_muted, R.color.blue_300, R.color.blue_400, R.color.cool_blue, R.color.cornflower_blue, R.color.cornflower_blue_two, R.color.dot_unread, R.color.fave_promo_btn_pressed, R.color.header_blue, R.color.vkim_ripple_dark, R.color.colorAccent, R.color.light_blue, R.color.light_blue_gray, R.color.live_emoji_butt_hide, R.color.music_action_button_blue, R.color.name, R.color.picker_blue, R.color.picker_blue_pressed, R.color.picker_tab_bg_selected, R.color.picker_tab_text_selected, R.color.sharing_blue_btn_normal, R.color.sharing_blue_btn_pressed, R.color.sky_300, R.color.text_blue, R.color.tip_background, R.color.tw__blue_default, R.color.tw__blue_pressed, R.color.vkim_msg_sending_ic, R.color.vkim_playing_drawable_rect, R.color.white_blue32}) { - if(color == accent) return true; + for (int accent : new int[] {R.color.accent_blue, R.color.azure_A400, R.color.blue, R.color.blue_200, R.color.blue_200_muted, R.color.blue_300, R.color.blue_400, R.color.cool_blue, R.color.cornflower_blue, R.color.cornflower_blue_two, R.color.dot_unread, R.color.fave_promo_btn_pressed, R.color.header_blue, R.color.vkim_ripple_dark, R.color.colorAccent, R.color.light_blue, R.color.light_blue_gray, R.color.live_emoji_butt_hide, R.color.music_action_button_blue, R.color.name, R.color.picker_blue, R.color.picker_blue_pressed, R.color.picker_tab_bg_selected, R.color.picker_tab_text_selected, R.color.sharing_blue_btn_normal, R.color.sharing_blue_btn_pressed, R.color.sky_300, R.color.text_blue, R.color.tip_background, R.color.tw__blue_default, R.color.tw__blue_pressed, R.color.vkim_msg_sending_ic, R.color.vkim_playing_drawable_rect, R.color.white_blue32}) { + if (color == accent) return true; } return false; } // Accent colors @@ -175,71 +175,71 @@ public class Themes{ } public static Drawable recolorDrawable(Drawable drawable){ - if(drawable == null) return null; + if (drawable == null) return null; return new RecoloredDrawable(drawable, getAccentColor()); } // Recolor drawable to accent color public static Drawable recolorVKIconMenu(Drawable drawable){ int accent = getHeaderText(); - if(drawable == null) return null; + if (drawable == null) return null; - if(isAndroidMonet() || isDarkTheme()) accent = getAccentColor(); + if (isAndroidMonet() || isDarkTheme()) accent = getAccentColor(); return new RecoloredDrawable(drawable, accent); } // Recolor vk icon to accent color public static Drawable recolorDrawableToolbar(Drawable drawable){ - if(drawable == null) return null; + if (drawable == null) return null; - if(!isAndroidMonet()) return drawable; + if (!isAndroidMonet()) return drawable; return new RecoloredDrawable(drawable, getHeaderText()); } // Recolor toolbar drawable to accent color @SuppressLint("UseCompatLoadingForDrawables") public static Drawable recolorDrawableInt(int drawable){ - if(!isAndroidMonet()) return getResources().getDrawable(drawable); + if (!isAndroidMonet()) return getResources().getDrawable(drawable); @SuppressLint("UseCompatLoadingForDrawables") Drawable res = getResources().getDrawable(drawable); return new RecoloredDrawable(res, getAccentColor()); } // Get res drawable via id and coloring to accent public static ColorStateList recolorCSL(ColorStateList colorStateList){ - if(colorStateList == null) return null; + if (colorStateList == null) return null; - if(!isAndroidMonet()) return colorStateList; + if (!isAndroidMonet()) return colorStateList; return ColorStateList.valueOf(getAccentColor()); } // Recolor ColorStateList to accent color @SuppressLint("UseCompatLoadingForColorStateLists") public static ColorStateList themeCSL(Context context, int color){ - if(isColorRefAccented(color) && isAndroidMonet()){ + if (isColorRefAccented(color) && isAndroidMonet()) { return ColorStateList.valueOf(getAccentColor()); } ColorStateList csl; - if(Build.VERSION.SDK_INT >= 23){ + if (Build.VERSION.SDK_INT >= 23) { csl = context.getColorStateList(color); } else { csl = context.getResources().getColorStateList(color); } try { - int unsel = csl.getColorForState(new int[]{-android.R.attr.state_selected}, Color.BLACK); - int sel = csl.getColorForState(new int[]{android.R.attr.state_selected}, Color.BLACK); + int unsel = csl.getColorForState(new int[] {-android.R.attr.state_selected}, Color.BLACK); + int sel = csl.getColorForState(new int[] {android.R.attr.state_selected}, Color.BLACK); boolean isUnselAccent = isAccentedColor(unsel); boolean isSelAccent = isAccentedColor(sel); - if(isUnselAccent || isSelAccent){ + if (isUnselAccent || isSelAccent) { - return new ColorStateList(new int[][]{ - new int[]{android.R.attr.state_selected}, new int[]{-android.R.attr.state_selected} - }, new int[]{isSelAccent ? getAccentColor() : sel, isUnselAccent ? getAccentColor() : unsel}); + return new ColorStateList(new int[][] { + new int[] {android.R.attr.state_selected}, new int[] {-android.R.attr.state_selected} + }, new int[] {isSelAccent ? getAccentColor() : sel, isUnselAccent ? getAccentColor() : unsel}); } return csl; @@ -266,7 +266,7 @@ public class Themes{ } public static int fixTextColor(int resid){ - if(resid == R.color.music_action_button_gray || resid == R.color.cool_grey || resid == R.color.accent_blue){ + if (resid == R.color.music_action_button_gray || resid == R.color.cool_grey || resid == R.color.accent_blue) { return isDarkTheme() ? R.color.white : R.color.cool_grey; } return resid; @@ -285,25 +285,25 @@ public class Themes{ } public static int getColor(Context context, int i){ - if(isColorRefAccented(i) && isAndroidMonet()){ + if (isColorRefAccented(i) && isAndroidMonet()) { return getAccentColor(); } return context.getColor(i); } // Android Support color injector + accent color checker public static int getColor2(int i){ - if(isColorRefAccented(i) && isAndroidMonet()){ + if (isColorRefAccented(i) && isAndroidMonet()) { return getAccentColor(); } return getResources().getColor(i); } // Android Support color injector + accent color checker public static int getAlertStyle(){ - if(isDarkTheme()) return R.style.Theme_MaterialComponents_Dialog_Alert; + if (isDarkTheme()) return R.style.Theme_MaterialComponents_Dialog_Alert; return R.style.Theme_MaterialComponents_Light_Dialog_Alert; } // Android Support color injector + accent color checker - public static String getBackgroundStickers() { + public static String getBackgroundStickers(){ if (getWallpaper() != null) { return "images_with_background"; } @@ -311,7 +311,7 @@ public class Themes{ } public static void setNavbarColor(Window window, int i){ - if(navbar()){ + if (navbar()) { window.setNavigationBarColor(getTabbarBackground()); window.getDecorView().setSystemUiVisibility(getNeededColorNavbar()); } @@ -336,13 +336,13 @@ public class Themes{ public static void systemThemeChanger(Activity activity){ // ded boolean isDarkTheme = isDarkTheme(); - if(!isDarkTheme){ + if (!isDarkTheme) { applyTheme(getDarkTheme()); } else { applyTheme(getLightTheme()); } - if(!systemtheme()){ + if (!systemtheme()) { edit().putBoolean("isdark", isDarkTheme).commit(); return; } diff --git a/app/src/main/java/ru/vtosters/lite/utils/VKUIInjector.java b/app/src/main/java/ru/vtosters/lite/utils/VKUIInjector.java index 7ff9db119..515400985 100644 --- a/app/src/main/java/ru/vtosters/lite/utils/VKUIInjector.java +++ b/app/src/main/java/ru/vtosters/lite/utils/VKUIInjector.java @@ -34,7 +34,7 @@ public class VKUIInjector{ while(true) { String readLine = bufferedReader.readLine(); - if(readLine != null){ + if (readLine != null) { sb.append(readLine); } else { bufferedReader.close(); @@ -69,20 +69,20 @@ public class VKUIInjector{ public static void inject(WebView webView){ String string = getPrefsValue("darktheme"); - if(getBoolValue("VKUI_INJ", true)){ + if (getBoolValue("VKUI_INJ", true)) { - if(!isLoaded){ + if (!isLoaded) { load(); } StringBuilder sb = new StringBuilder(); - if(true/*Themes.isAccentedCache()*/){ + if (true/*Themes.isAccentedCache()*/) { sb.append("\n\n"); sb.append(loadedCSS); } - if(string.equals("amoled")){ + if (string.equals("amoled")) { sb.append("\n\n"); sb.append(loadedCSSAmoled); }