From 6b055447163ac14e99036230ef3b8d60e2c0265c Mon Sep 17 00:00:00 2001
From: gdlbo <41114720+gdlbo@users.noreply.github.com>
Date: Tue, 31 May 2022 16:43:58 +0300
Subject: [PATCH] added more documentations
---
.../java/ru/vtosters/lite/utils/Globals.java | 7 ++
.../java/ru/vtosters/lite/utils/Newsfeed.java | 5 +-
.../ru/vtosters/lite/utils/Preferences.java | 16 +++--
.../java/ru/vtosters/lite/utils/Proxy.java | 12 ++--
.../java/ru/vtosters/lite/utils/Themes.java | 67 ++++++++++---------
build.gradle | 2 +-
smali/res/xml/preferences_feed.xml | 12 ++--
.../com/vk/api/wall/WallGetComments.smali | 4 --
8 files changed, 66 insertions(+), 59 deletions(-)
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 f42361909..30783e4ab 100644
--- a/app/src/main/java/ru/vtosters/lite/utils/Globals.java
+++ b/app/src/main/java/ru/vtosters/lite/utils/Globals.java
@@ -41,6 +41,7 @@ public class Globals {
return prefs;
}
+ // Get pref value as string
public static String getPrefsValue(String pref) {
return getPreferences().getString(pref, "");
}
@@ -58,6 +59,7 @@ public class Globals {
return VKAccountManager.b().b();
}
+ // Edit SharedPreferences
public static SharedPreferences.Editor edit() {
return PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
}
@@ -127,10 +129,14 @@ public class Globals {
return getContext().getResources();
}
+ // Get res id
+ // "res name", "res type"
public static int getIdentifier(String str, String str2) {
return getResources().getIdentifier(str, str2, getContext().getPackageName());
}
+ // Get string via getIdentifier
+ // "string name in res"
public static String getString(String str) {
return getContext().getString(Integer.parseInt(String.valueOf(getContext().getResources().getIdentifier(str, "string", getContext().getPackageName()))));
}
@@ -155,6 +161,7 @@ public class Globals {
return str == null || str.isEmpty();
}
+ // Network check
public static boolean isNetworkConnected() {
ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
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 602283375..12f8e502b 100644
--- a/app/src/main/java/ru/vtosters/lite/utils/Newsfeed.java
+++ b/app/src/main/java/ru/vtosters/lite/utils/Newsfeed.java
@@ -4,6 +4,7 @@ import static java.lang.Long.MAX_VALUE;
import static ru.vtosters.lite.ui.fragments.dockbar.DockBarManager.getInstance;
import static ru.vtosters.lite.utils.Globals.getContext;
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
+import static ru.vtosters.lite.utils.Preferences.BooleanFalse;
import static ru.vtosters.lite.utils.Preferences.BooleanTrue;
import static ru.vtosters.lite.utils.Preferences.adsgroup;
import static ru.vtosters.lite.utils.Preferences.adsstories;
@@ -90,7 +91,7 @@ public class Newsfeed {
e.printStackTrace();
}
}
- }
+ } // Get needed filter list from assets
public static boolean injectFilters(JSONObject jSONObject) {
String optString = jSONObject.optString(NavigatorKeys.j, "");
@@ -105,7 +106,7 @@ public class Newsfeed {
}
}
return false;
- }
+ } // json newsfeed/posts injector to detect and delete posts
public static boolean authors_rec(String str) {
return str.equals("authors_rec") && !authorsrecomm();
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 6c68ae6d4..085f88cf0 100644
--- a/app/src/main/java/ru/vtosters/lite/utils/Preferences.java
+++ b/app/src/main/java/ru/vtosters/lite/utils/Preferences.java
@@ -37,18 +37,18 @@ public class Preferences {
registerActivities(application);
LoadLibrary("vkopustest");
systemThemeChanger();
- }
+ } // VK Init
public static boolean BooleanFalse(String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
return prefs.getBoolean(key, false);
- }
+ } // Make bool false by default + get current value
public static boolean BooleanTrue(String key) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
return prefs.getBoolean(key, true);
- }
+ } // Make bool true by default + get current value
public static boolean opusmodule() {
return BooleanTrue("opusmodule");
@@ -170,6 +170,10 @@ public class Preferences {
return BooleanTrue("feedcache");
}
+ public static boolean getCommentsSort() {
+ return BooleanFalse("commentssorting");
+ }
+
public static void forceOffline() {
if (setoffline()) {
Users.b();
@@ -308,15 +312,15 @@ public class Preferences {
public static String MediacontentFix() {
return Build.VERSION.SDK_INT >= 29 ? "date_modified DESC" : "datetaken DESC";
- }
+ } // Fix photo picker for sdk 29+
public static String MediacontentFix2() {
return Build.VERSION.SDK_INT >= 29 ? "date_modified" : "datetaken";
- }
+ } // Fix photo picker for sdk 29+
public static String MediacontentFix3() {
return Build.VERSION.SDK_INT >= 29 ? ", date_modified=" : ", dateTaken=";
- }
+ } // Fix photo picker for sdk 29+
public static boolean color_grishka() {
return BooleanTrue("color_grishka");
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 eb8797f1d..700335f6d 100644
--- a/app/src/main/java/ru/vtosters/lite/utils/Proxy.java
+++ b/app/src/main/java/ru/vtosters/lite/utils/Proxy.java
@@ -122,7 +122,7 @@ public class Proxy {
clearProperty("http.proxyPassword");
clearProperty("socksProxyHost");
clearProperty("socksPortHost");
- }
+ } // Reset all proxies
public static void resetProxySocks() {
clearProperty("https.proxyHost");
@@ -133,7 +133,7 @@ public class Proxy {
clearProperty("http.proxyPort");
clearProperty("http.proxyUser");
clearProperty("http.proxyPassword");
- }
+ } // Reset all except socks
public static void resetProxyHttp() {
clearProperty("https.proxyHost");
@@ -142,7 +142,7 @@ public class Proxy {
clearProperty("https.proxyPassword");
clearProperty("socksProxyHost");
clearProperty("socksPortHost");
- }
+ } // Reset all except http
public static void resetProxyHttps() {
clearProperty("http.proxyHost");
@@ -151,7 +151,7 @@ public class Proxy {
clearProperty("http.proxyPassword");
clearProperty("socksProxyHost");
clearProperty("socksPortHost");
- }
+ } // Reset all except https
public static String proxyHostHTTP() {
String string = getPrefsValue("proxyHostHTTP");
@@ -207,8 +207,8 @@ public class Proxy {
return getPrefsValue("proxy").equals("apiproxy");
}
- // Official vk proxy enforcer
+
public static boolean proxyvk() {
return BooleanFalse("proxyvk");
- }
+ } // Official vk proxy enforcer
}
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 7cf86af7d..67efc80e3 100644
--- a/app/src/main/java/ru/vtosters/lite/utils/Themes.java
+++ b/app/src/main/java/ru/vtosters/lite/utils/Themes.java
@@ -29,49 +29,49 @@ import com.vtosters.lite.R;
public class Themes {
public static int getAccentColor() {
return VKThemeHelper.a(R.attr.accent);
- }
+ } // Color accent
public static int getTextAttr() {
return VKThemeHelper.a(R.attr.text_primary);
- }
+ } // Text Primary color
public static int getSTextAttr() {
return VKThemeHelper.a(R.attr.text_secondary);
- }
+ } // Text Secondary color
public static int getTabbarBackground() {
return VKThemeHelper.a(R.attr.tabbar_background);
- }
+ } // Tabbar/Navbar background
public static int getBackgroundContent() {
return VKThemeHelper.a(R.attr.background_content);
- }
+ } // Background color in app
public static int getHeaderBackground() {
return VKThemeHelper.a(R.attr.header_background);
- }
-
- public static int getAmoledTheme() {
- return getContext().getResources().getIdentifier("BaseAmoledStyle", "style", getContext().getPackageName());
- }
-
- public static int picFix() {
- return getContext().getResources().getIdentifier("ActionBarThemeFix", "style", getContext().getPackageName());
- }
-
- public static int getAmoledImTheme() {
- return getContext().getResources().getIdentifier("VkIm.Theme.VkApp.Amoled", "style", getContext().getPackageName());
- }
+ } // Toolbar/Header background
public static int getHeaderText() {
return VKThemeHelper.a(R.attr.header_text);
- }
+ } // Header/Toolbar color text
+
+ public static int getAmoledTheme() {
+ return getContext().getResources().getIdentifier("BaseAmoledStyle", "style", getContext().getPackageName());
+ } // Get Amoled theme id
+
+ public static int picFix() {
+ return getContext().getResources().getIdentifier("ActionBarThemeFix", "style", getContext().getPackageName());
+ } // Fix tabbar color in photo viewer
+
+ public static int getAmoledImTheme() {
+ return getContext().getResources().getIdentifier("VkIm.Theme.VkApp.Amoled", "style", getContext().getPackageName());
+ } // Get Amoled theme id for messages
public static void setBarTheme(View getview) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getview.setSystemUiVisibility(getNeededColorNavbar() | getNeededColorStatusbar());
}
- }
+ } // Set white/dark statusbar/navbar icons
public static int getNeededColorStatusbar() {
return VKThemeHelper.d() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? 8192 : 0;
@@ -92,7 +92,7 @@ public class Themes {
default:
return VKTheme.DARK;
}
- }
+ } // Return needed theme for theme changer
public static ImTheme getImDarkTheme() {
switch (getPrefsValue("darktheme")) {
@@ -101,25 +101,25 @@ public class Themes {
default:
return ImTheme.VKAPP_DARK;
}
- }
+ } // Return needed theme for theme changer
public static VKTheme getLightTheme() {
switch (getPrefsValue("lighttheme")) {
default:
return VKTheme.DEFAULT_LIGHT;
}
- }
+ } // Return needed theme for theme changer
public static ImTheme getImLightTheme() {
switch (getPrefsValue("lighttheme")) {
default:
return ImTheme.VKAPP_LIGHT;
}
- }
+ } // Return needed theme for theme changer
public static int getColorFromAttr(int attr) {
return VKThemeHelper.a(attr);
- }
+ } // Get needed attr color
public static boolean isAndroidMonet() {
return color_grishka() && Build.VERSION.SDK_INT >= 31;
@@ -127,7 +127,7 @@ public class Themes {
public static boolean isColorRefAccented(int i) {
return i == R.color.cornflower_blue || i == R.color.cornflower_blue_two || i == R.color.dot_unread || i == R.color.fave_promo_btn_pressed || i == R.color.im_back_to_vk_gradient_start || i == R.color.live_emoji_butt_hide || i == R.color.picker_tab_bg_selected || i == R.color.sky_300 || i == R.color.text_blue || i == R.color.tw__blue_default || i == R.color.tw__blue_pressed || i == R.color.white_blue32 || i == R.color.name || i == R.color.picker_blue || i == R.color.picker_blue_pressed || i == R.color.picker_tab_text_selected || i == R.color.sharing_blue_btn_pressed || i == R.color.sharing_blue_btn_normal || i == R.color.tip_background || i == R.color.vkim_msg_sending_ic || i == R.color.vkim_playing_drawable_rect || i == R.color.accent_blue || i == R.color.light_blue_gray || i == R.color.light_blue || i == R.color.blue_200 || i == R.color.header_blue || i == R.color.blue_200_muted || i == R.color.im_old_accent || i == R.color.im_old_accent_muted || i == R.color.im_dark_accent || i == R.color.im_dark_accent_muted || i == R.color.azure_A400 || i == R.color.blue || i == R.color.blue_400 || i == R.color.blue_300 || i == R.color.cool_blue;
- }
+ } // Accent colors
public static void themeMonetToolbar(ImageButton imageButton, Toolbar toolbar) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -141,14 +141,14 @@ public class Themes {
return null;
}
return new RecoloredDrawable(drawable, getAccentColor());
- }
+ } // Recolor drawable to accent color
public static Drawable recolorDrawableToolbar(Drawable drawable) {
if (drawable == null) {
return null;
}
return new RecoloredDrawable(drawable, getHeaderText());
- }
+ } // Recolor toolbar drawable to accent color
public static ColorStateList recolorCSL(ColorStateList colorStateList) {
if (colorStateList == null) {
@@ -165,14 +165,14 @@ public class Themes {
return context.getColor(i);
}
return context.getResources().getColor(i);
- }
+ } // Android Support color injector + accent color checker
public static int getColor2(int i) {
if (isColorRefAccented(i) && isAndroidMonet()) {
return getAccentColor();
}
return getContext().getResources().getColor(i);
- }
+ } // Android Support color injector + accent color checker
public static void setNavbarColor(Window window, int i) {
if (navbar() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -183,7 +183,8 @@ public class Themes {
public static String hex(int i) {
return String.format("#%06X", Integer.valueOf(i & 16777215));
- }
+ } // Get color as hex string
+
public static int vk_sans_display_demibold() {
return vksans() ? R.font.vk_sans_display_demibold : R.font.tt_commons_demi_bold;
}
@@ -237,7 +238,7 @@ public class Themes {
}
public static void changeTheme(VKTheme theme, ImTheme imtheme) {
- VKThemeHelper.b.a(theme);
- ImThemeHelper.b.a(imtheme);
+ VKThemeHelper.b.a(theme); // VKThemeHelper.b.a(VKTheme value) VK Theme apply
+ ImThemeHelper.b.a(imtheme); // ImThemeHelper.b.a(ImTheme value) VK Theme Msg apply
}
}
diff --git a/build.gradle b/build.gradle
index 06ebc3e25..f75f1768f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.2.0'
+ classpath 'com.android.tools.build:gradle:7.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/smali/res/xml/preferences_feed.xml b/smali/res/xml/preferences_feed.xml
index 27d35dfb5..3187012a2 100644
--- a/smali/res/xml/preferences_feed.xml
+++ b/smali/res/xml/preferences_feed.xml
@@ -83,13 +83,6 @@
-
+
getCommentsSort(Ljava/lang/String;)Ljava/lang/String;
-
- move-result-object p2
-
invoke-virtual {p0, p1, p2}, Lcom/vk/api/wall/WallGetComments;->a(Ljava/lang/String;Ljava/lang/String;)Lcom/vk/api/base/ApiRequest;
.line 66