Merge remote-tracking branch 'origin/vtl-remaster' into vtl-remaster
This commit is contained in:
@@ -7,6 +7,7 @@ import static ru.vtosters.lite.utils.About.getCommitLink;
|
||||
import static ru.vtosters.lite.utils.CacheUtils.humanReadableByteCountBin;
|
||||
import static ru.vtosters.lite.utils.Globals.drawableFromUrl;
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getCenterScreenCoords;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Globals.getUserId;
|
||||
@@ -30,17 +31,21 @@ import static ru.vtosters.lite.utils.Themes.setTheme;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.aefyr.tsg.g2.TelegramStickersService;
|
||||
import com.vk.about.AboutAppFragment;
|
||||
import com.vk.articles.preload.WebCachePreloader;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vk.identity.fragments.IdentityListFragment;
|
||||
import com.vk.navigation.Navigator;
|
||||
import com.vk.notifications.settings.NotificationsSettingsFragment;
|
||||
import com.vk.webapp.fragments.PrivacyFragment;
|
||||
import com.vtosters.lite.auth.VKAccountManager;
|
||||
import com.vtosters.lite.data.ThemeTracker;
|
||||
import com.vtosters.lite.fragments.MaterialPreferenceToolbarFragment;
|
||||
import com.vtosters.lite.fragments.SettingsAccountFragment;
|
||||
import com.vtosters.lite.fragments.SettingsGeneralFragment;
|
||||
@@ -48,6 +53,9 @@ import com.vtosters.lite.fragments.money.music.control.subscription.MusicSubscri
|
||||
import com.vtosters.lite.fragments.n2.SettingsDebugFragment;
|
||||
import com.vtosters.lite.fragments.w2.BlacklistFragment;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import ru.vtosters.lite.ui.PreferencesUtil;
|
||||
import ru.vtosters.lite.ui.dialogs.OTADialog;
|
||||
import ru.vtosters.lite.ui.fragments.dockbar.DockBarFragment;
|
||||
@@ -98,16 +106,15 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
boolean value = (boolean) o;
|
||||
|
||||
if(value){
|
||||
applyTheme(getLightTheme(), getImLightTheme());
|
||||
applyTheme(getLightTheme());
|
||||
} else {
|
||||
applyTheme(getDarkTheme(), getImDarkTheme());
|
||||
applyTheme(getDarkTheme());
|
||||
}
|
||||
|
||||
edit().putBoolean("isdark", value).commit();
|
||||
|
||||
setTheme(this.getActivity());
|
||||
|
||||
restartApplicationWithTimer();
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -379,6 +386,19 @@ public class VTSettings extends MaterialPreferenceToolbarFragment {
|
||||
return Globals.getString("vtltgssumm") + ": " + TelegramStickersService.getInstance(Globals.getContext()).getPacksListReference().size();
|
||||
}
|
||||
|
||||
public static SharedPreferences getCurrentAccount() {
|
||||
return Globals.getContext().getSharedPreferences("pref_account_manager", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
public static String withRegex(String base, String regex, String def) {
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(base);
|
||||
if (matcher.find()) {
|
||||
return matcher.group(1);
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int T4() {
|
||||
return getIdentifier("notification_settings", "string");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package ru.vtosters.lite.utils;
|
||||
|
||||
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||
import static com.vk.core.ui.themes.VKThemeHelper.k;
|
||||
import static com.vk.core.ui.themes.VKThemeHelper.l;
|
||||
import static com.vk.im.ui.themes.ImTheme.VKAPP_AMOLED;
|
||||
import static com.vk.im.ui.themes.ImTheme.VKAPP_DARK;
|
||||
import static com.vk.im.ui.themes.ImTheme.VKAPP_LIGHT;
|
||||
@@ -8,6 +10,7 @@ import static com.vk.im.ui.themes.ImTheme.VKME_AMOLED;
|
||||
import static com.vk.im.ui.themes.ImTheme.VKME_DARK;
|
||||
import static com.vk.im.ui.themes.ImTheme.VKME_LIGHT;
|
||||
import static ru.vtosters.lite.utils.Globals.edit;
|
||||
import static ru.vtosters.lite.utils.Globals.getCenterScreenCoords;
|
||||
import static ru.vtosters.lite.utils.Globals.getIdentifier;
|
||||
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
|
||||
import static ru.vtosters.lite.utils.Globals.getResources;
|
||||
@@ -33,11 +36,14 @@ import android.widget.ImageButton;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import com.vk.articles.preload.WebCachePreloader;
|
||||
import com.vk.core.drawable.RecoloredDrawable;
|
||||
import com.vk.core.ui.themes.MilkshakeHelper;
|
||||
import com.vk.core.ui.themes.VKTheme;
|
||||
import com.vk.core.ui.themes.VKThemeHelper;
|
||||
import com.vk.im.ui.themes.ImTheme;
|
||||
import com.vtosters.lite.R;
|
||||
import com.vtosters.lite.data.ThemeTracker;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -47,39 +53,42 @@ public class Themes {
|
||||
"5692d7", "528bcc", "7aa0cc", "518bcc", "6296d0", "2f68aa", "638ebf", "5181b8", "71aaeb", "4774a8", "5baaf4", "4186c8", "add3ff", "4774a8", "718198", "5a9eff", "99a2ad", "74a2d6", "e9eef3", "dfe3e7", "eff1f3", "5c9ce6", "4986cc", "4680c2"
|
||||
);
|
||||
|
||||
public static void applyTheme(VKTheme theme, ImTheme imtheme) {
|
||||
public static void applyTheme(VKTheme theme) {
|
||||
// TODO
|
||||
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
|
||||
|
||||
public static void setTheme(Activity activity) {
|
||||
VKThemeHelper.a(activity); // apply changed theme
|
||||
VKThemeHelper.b(activity, getCenterScreenCoords());
|
||||
ThemeTracker.a();
|
||||
WebCachePreloader.e(); // apply changed theme
|
||||
}
|
||||
|
||||
public static boolean isDarkTheme() {
|
||||
return !VKThemeHelper.d();
|
||||
return VKThemeHelper.r();
|
||||
}
|
||||
|
||||
public static int getAccentColor() {
|
||||
return VKThemeHelper.a(R.attr.accent);
|
||||
return getColorFromAttr(R.attr.accent);
|
||||
} // Color accent
|
||||
|
||||
public static int getTextAttr() {
|
||||
return VKThemeHelper.a(R.attr.text_primary);
|
||||
return getColorFromAttr(R.attr.text_primary);
|
||||
} // Text Primary color
|
||||
|
||||
public static int getSTextAttr() {
|
||||
return VKThemeHelper.a(R.attr.text_secondary);
|
||||
return getColorFromAttr(R.attr.text_secondary);
|
||||
} // Text Secondary color
|
||||
|
||||
public static int getTabbarBackground() {
|
||||
return VKThemeHelper.a(R.attr.tabbar_background);
|
||||
return getColorFromAttr(R.attr.tabbar_background);
|
||||
} // Tabbar/Navbar background
|
||||
|
||||
public static int getBackgroundContent() {
|
||||
return VKThemeHelper.a(R.attr.background_content);
|
||||
return getColorFromAttr(R.attr.background_content);
|
||||
} // Background color in app
|
||||
|
||||
public static int getHeaderBackground() {
|
||||
return VKThemeHelper.a(R.attr.header_background);
|
||||
return getColorFromAttr(R.attr.header_background);
|
||||
} // Toolbar/Header background
|
||||
|
||||
public static int getHeaderText() {
|
||||
@@ -113,57 +122,59 @@ public class Themes {
|
||||
} // Set white/dark statusbar/navbar icons
|
||||
|
||||
public static int getNeededColorStatusbar() {
|
||||
return VKThemeHelper.d() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? 8192 : 0;
|
||||
return !isDarkTheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S ? 8192 : 0;
|
||||
}
|
||||
|
||||
public static int getNeededColorNavbar() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? VKThemeHelper.d() ? SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? isDarkTheme() ? SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR : 0 : 0;
|
||||
}
|
||||
|
||||
public static int getNeededColorStatusbarFix() {
|
||||
return VKThemeHelper.d() ? 8192 : 0;
|
||||
return VKThemeHelper.r() ? 8192 : 0;
|
||||
}
|
||||
|
||||
public static VKTheme getDarkTheme() {
|
||||
switch (getPrefsValue("darktheme")) {
|
||||
case "amoled":
|
||||
return VKTheme.AMOLED;
|
||||
//case "amoled":
|
||||
//return VKTheme.AMOLED;
|
||||
default:
|
||||
return VKTheme.DARK;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static ImTheme getImDarkTheme() {
|
||||
switch (getPrefsValue("darktheme")) {
|
||||
case "amoled":
|
||||
return roundedmsgs() ? VKME_AMOLED : VKAPP_AMOLED;
|
||||
default:
|
||||
return roundedmsgs() ? VKME_DARK : VKAPP_DARK;
|
||||
return VKTheme.VKAPP_DARK;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static VKTheme getLightTheme() {
|
||||
switch (getPrefsValue("lighttheme")) {
|
||||
default:
|
||||
return VKTheme.DEFAULT_LIGHT;
|
||||
return VKTheme.VKAPP_LIGHT;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static ImTheme getImLightTheme() {
|
||||
public static VKTheme getDarkMilkTheme() {
|
||||
switch (getPrefsValue("darktheme")) {
|
||||
default:
|
||||
return VKTheme.VKAPP_MILK_DARK;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static VKTheme getLightMilkTheme() {
|
||||
switch (getPrefsValue("lighttheme")) {
|
||||
default:
|
||||
return roundedmsgs() ? VKME_LIGHT : VKAPP_LIGHT;
|
||||
return VKTheme.VKAPP_MILK_LIGHT;
|
||||
}
|
||||
} // Return needed theme for theme changer
|
||||
|
||||
public static int getColorFromAttr(int attr) {
|
||||
return VKThemeHelper.a(attr);
|
||||
return VKThemeHelper.d(attr);
|
||||
} // Get needed attr color
|
||||
|
||||
public static boolean isAndroidMonet() {
|
||||
return color_grishka() && Build.VERSION.SDK_INT >= 31;
|
||||
}
|
||||
|
||||
public static boolean isMilkshake() {
|
||||
return MilkshakeHelper.e();
|
||||
}
|
||||
|
||||
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.im_back_to_vk_gradient_start, R.color.im_dark_accent, R.color.im_dark_accent_muted, R.color.im_old_accent, R.color.im_old_accent_muted, 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;
|
||||
|
||||
Reference in New Issue
Block a user