Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b614f786d | ||
|
|
f3fda343d2 | ||
|
|
5c95ae3dd0 | ||
|
|
d1eed0fbd5 | ||
|
|
30886adc62 | ||
|
|
c441823d94 |
@@ -0,0 +1,15 @@
|
||||
package ru.vtosters.lite.feature.music;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.vk.music.fragment.MusicFragment;
|
||||
|
||||
public class MusicArtistSelectorHook {
|
||||
public static void navigateToSearch(Context context, String artist) {
|
||||
var fr = new MusicFragment.f();
|
||||
fr.a(artist);
|
||||
|
||||
// navigate
|
||||
fr.a(context);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import android.preference.PreferenceManager;
|
||||
import com.vk.core.concurrent.VkExecutors;
|
||||
|
||||
import ru.vtosters.lite.downloaders.notifications.NotificationChannels;
|
||||
import ru.vtosters.lite.hooks.ui.SystemThemeChangerHook;
|
||||
import ru.vtosters.lite.ui.dialogs.DisableBattery;
|
||||
import ru.vtosters.lite.ui.dialogs.InstallGMS;
|
||||
import ru.vtosters.lite.ui.dialogs.OTADialog;
|
||||
@@ -22,8 +21,11 @@ import ru.vtosters.lite.ui.dialogs.ServerDialog;
|
||||
import ru.vtosters.lite.ui.dialogs.Start;
|
||||
import ru.vtosters.lite.utils.DeletedMessagesHandler;
|
||||
|
||||
public class MainActivityInjector{
|
||||
public static void inject(Activity activity){
|
||||
/**
|
||||
* @
|
||||
*/
|
||||
public class MainActivityInjector {
|
||||
public static void inject(Activity activity) {
|
||||
setNeededTheme(activity);
|
||||
ServerDialog.activity = activity;
|
||||
sendRequest();
|
||||
@@ -36,7 +38,7 @@ public class MainActivityInjector{
|
||||
.edit()
|
||||
.putBoolean("isdark", isDarkTheme())
|
||||
.commit();
|
||||
SystemThemeChangerHook.onThemeChanged(activity.getResources().getConfiguration());
|
||||
|
||||
|
||||
VkExecutors.x.q().a(() -> {
|
||||
getInstance().autoCleaningCache();
|
||||
|
||||
@@ -7,6 +7,7 @@ import static ru.vtosters.lite.utils.Preferences.autoalltranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.autotranslate;
|
||||
import static ru.vtosters.lite.utils.Preferences.savemsgsett;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
@@ -16,6 +17,7 @@ import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import ru.vtosters.lite.translators.BaseTranslator;
|
||||
import ru.vtosters.lite.utils.LifecycleUtils;
|
||||
|
||||
public class MessagesHook {
|
||||
public static String injectOwnText(String oldText) {
|
||||
@@ -72,6 +74,14 @@ public class MessagesHook {
|
||||
});
|
||||
}
|
||||
|
||||
public static Context fixCTX(Context ctx) {
|
||||
if (ctx == null){
|
||||
return LifecycleUtils.getCurrentActivity();
|
||||
} else {
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
|
||||
public static void injRequest(MethodCall.a req) {
|
||||
var time = expireTime();
|
||||
|
||||
|
||||
@@ -6,17 +6,24 @@ import ru.vtosters.lite.utils.Preferences;
|
||||
import ru.vtosters.lite.utils.ThemesUtils;
|
||||
|
||||
public class SystemThemeChangerHook {
|
||||
private static int latestTheme = 0;
|
||||
|
||||
public static void onThemeChanged(Configuration configuration) {
|
||||
if (Preferences.systemtheme()) {
|
||||
switch (configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK) {
|
||||
var theme = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||
if (theme == latestTheme) return;
|
||||
|
||||
switch (theme) {
|
||||
case Configuration.UI_MODE_NIGHT_YES:
|
||||
// Night mode is active, we're using dark theme
|
||||
ThemesUtils.applyTheme(ThemesUtils.getDarkTheme());
|
||||
latestTheme = theme;
|
||||
break;
|
||||
case Configuration.UI_MODE_NIGHT_NO:
|
||||
case Configuration.UI_MODE_NIGHT_UNDEFINED:
|
||||
// Night mode is not active, we're using light theme
|
||||
ThemesUtils.applyTheme(ThemesUtils.getLightTheme());
|
||||
latestTheme = theme;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,14 @@ public class ThemesUtils {
|
||||
);
|
||||
|
||||
public static void applyTheme(VKTheme theme) {
|
||||
VKThemeHelper.theme(theme, LifecycleUtils.getCurrentActivity(), getCenterScreenCoords());
|
||||
var currentActivity = LifecycleUtils.getCurrentActivity();
|
||||
if (currentActivity != null) {
|
||||
try {
|
||||
VKThemeHelper.theme(theme, currentActivity, getCenterScreenCoords());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
|
||||
|
||||
public static void setTheme(VKTheme theme, Activity activity) {
|
||||
@@ -326,20 +333,21 @@ public class ThemesUtils {
|
||||
}
|
||||
|
||||
public static void setNeededTheme(Activity activity) {
|
||||
var currentTheme = getCurrentTheme();
|
||||
if (milkshake()) {
|
||||
if (getCurrentTheme() == VKTheme.VKAPP_LIGHT) {
|
||||
if (currentTheme == VKTheme.VKAPP_LIGHT) {
|
||||
setTheme(VKTheme.VKAPP_MILK_LIGHT, activity);
|
||||
}
|
||||
|
||||
if (getCurrentTheme() == VKTheme.VKAPP_DARK) {
|
||||
if (currentTheme == VKTheme.VKAPP_DARK) {
|
||||
setTheme(VKTheme.VKAPP_MILK_DARK, activity);
|
||||
}
|
||||
} else {
|
||||
if (getCurrentTheme() == VKTheme.VKAPP_MILK_LIGHT) {
|
||||
if (currentTheme == VKTheme.VKAPP_MILK_LIGHT) {
|
||||
setTheme(VKTheme.VKAPP_LIGHT, activity);
|
||||
}
|
||||
|
||||
if (getCurrentTheme() == VKTheme.VKAPP_MILK_DARK) {
|
||||
if (currentTheme == VKTheme.VKAPP_MILK_DARK) {
|
||||
setTheme(VKTheme.VKAPP_DARK, activity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4409,6 +4409,10 @@
|
||||
|
||||
move-result-object v6
|
||||
|
||||
invoke-static {v6}, Lru/vtosters/lite/hooks/MessagesHook;->fixCTX(Landroid/content/Context;)Landroid/content/Context;
|
||||
|
||||
move-result-object v6
|
||||
|
||||
iput-object v6, p0, Lcom/vk/im/ui/fragments/ChatFragment;->L:Landroid/content/Context;
|
||||
|
||||
.line 8
|
||||
@@ -6119,6 +6123,10 @@
|
||||
.line 1
|
||||
iget-object v0, p0, Lcom/vk/im/ui/fragments/ChatFragment;->L:Landroid/content/Context;
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/hooks/MessagesHook;->fixCTX(Landroid/content/Context;)Landroid/content/Context;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
const/4 v1, 0x0
|
||||
|
||||
if-eqz v0, :cond_1
|
||||
|
||||
+11
-8
@@ -83,15 +83,18 @@
|
||||
.locals 1
|
||||
|
||||
.line 21
|
||||
new-instance v0, Lcom/vk/music/search/MusicSearchFragment$a;
|
||||
# ru.vtosters.lite.feature.music.MusicArtistSelectorHook.navigateToSearch(Context context, String artist)
|
||||
invoke-static {p1, p2}, Lru/vtosters/lite/feature/music/MusicArtistSelectorHook;->navigateToSearch(Landroid/content/Context;Ljava/lang/String;)V
|
||||
|
||||
invoke-direct {v0}, Lcom/vk/music/search/MusicSearchFragment$a;-><init>()V
|
||||
|
||||
.line 22
|
||||
invoke-virtual {v0, p2}, Lcom/vk/music/search/MusicSearchFragment$a;->b(Ljava/lang/String;)Lcom/vk/music/search/MusicSearchFragment$a;
|
||||
|
||||
.line 23
|
||||
invoke-virtual {v0, p1}, Lcom/vk/navigation/Navigator;->a(Landroid/content/Context;)V
|
||||
# new-instance v0, Lcom/vk/music/search/MusicSearchFragment$a;
|
||||
#
|
||||
# invoke-direct {v0}, Lcom/vk/music/search/MusicSearchFragment$a;-><init>()V
|
||||
#
|
||||
# .line 22
|
||||
# invoke-virtual {v0, p2}, Lcom/vk/music/search/MusicSearchFragment$a;->b(Ljava/lang/String;)Lcom/vk/music/search/MusicSearchFragment$a;
|
||||
#
|
||||
# .line 23
|
||||
# invoke-virtual {v0, p1}, Lcom/vk/navigation/Navigator;->a(Landroid/content/Context;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
@@ -5871,12 +5871,14 @@
|
||||
.line 1
|
||||
iget-object v0, p0, Lcom/vk/profile/ui/BaseProfileFragment;->P0:Landroid/view/View;
|
||||
|
||||
if-nez v0, :cond_229
|
||||
|
||||
return-void
|
||||
|
||||
:cond_229
|
||||
invoke-static {v0}, Lcom/vk/core/ui/themes/VKThemeHelper;->a(Landroid/view/View;)V
|
||||
|
||||
.line 2
|
||||
iget-object v0, p0, Lcom/vk/profile/ui/BaseProfileFragment;->P0:Landroid/view/View;
|
||||
|
||||
.line 3
|
||||
invoke-virtual {v0}, Landroid/view/View;->getContext()Landroid/content/Context;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
@@ -561,6 +561,18 @@
|
||||
invoke-virtual {p0, p1, v0}, Landroidx/fragment/app/FragmentActivity;->startActivityForResult(Landroid/content/Intent;I)V
|
||||
|
||||
:goto_1
|
||||
# ru.vtosters.lite.hooks.ui.SystemThemeChangerHook.onThemeChanged(activity.getResources().getConfiguration());
|
||||
|
||||
invoke-virtual {p0}, Lcom/vtosters/lite/MainActivity;->getResources()Landroid/content/res/Resources;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-virtual {v0}, Landroid/content/res/Resources;->getConfiguration()Landroid/content/res/Configuration;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {v0}, Lru/vtosters/lite/hooks/ui/SystemThemeChangerHook;->onThemeChanged(Landroid/content/res/Configuration;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
|
||||
Reference in New Issue
Block a user