removed old color engine prefs

This commit is contained in:
gdlbo
2023-07-01 17:33:45 +03:00
parent 3b556b81a1
commit 48479dd064
10 changed files with 39 additions and 63 deletions
@@ -46,7 +46,7 @@ public class MainActivityInjector {
NotificationChannels.createChannels();
}
if (Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent() && ThemesUtils.useNewColorEngine()) {
if (Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && ThemesManager.canApplyCustomAccent()) {
Preferences.updateBuildNumber();
updateBinsAndTmpArchive(activity);
}
@@ -46,10 +46,6 @@ public class ThemesUtils {
}
} // Apply VKTheme and ImTheme (hard applying without dynamic theme changing)
public static boolean isCustomAccentEnabled() {
return ThemesUtils.isMonetTheme() || !useNewColorEngine();
}
public static ColorStateList getAccenedColorStateList() {
return ColorStateList.valueOf(getAccentColor());
}
@@ -83,13 +79,8 @@ public class ThemesUtils {
return getBoolValue("amoledtheme", false);
}
public static boolean useNewColorEngine() {
return getBoolValue("useNewColorEngine", false);
}
public static int getAccentColor() {
var color = Preferences.getPreferences().getInt("accent_color", getColorFromAttr(R.attr.accent));
return color == 0 || useNewColorEngine() || isMonetTheme() ? getColorFromAttr(R.attr.accent) : color;
return getColorFromAttr(R.attr.accent);
} // Color accent
//region Used for migrating accent color to new version
@@ -307,7 +298,7 @@ public class ThemesUtils {
} // Recolor drawable to accent color
public static Drawable recolorToolbarDrawable(Drawable drawable) {
if (!ThemesUtils.isCustomAccentEnabled()) return drawable;
if (!ThemesUtils.isMonetTheme()) return drawable;
if (drawable == null) return null;
return new RecoloredDrawable(drawable, (ThemesUtils.isMilkshake() && !ThemesUtils.isDarkTheme()) ? ThemesUtils.getAccentColor() : ThemesUtils.getHeaderText());
}
@@ -166,7 +166,7 @@ public class ThemesCore {
}
public static boolean hasThemedAttr(Context context, int attrID) {
if (ThemesUtils.isCustomAccentEnabled()) {
if (ThemesUtils.isMonetTheme()) {
if (Preferences.getBoolValue("logColors", false)) {
try {
Log.d(TAG, "Requesting color by attr " + context.getResources().getResourceName(attrID));
@@ -23,7 +23,7 @@ public class ThemesHacks {
}
public static int getHackedColor(@NonNull Context context, @ColorRes int color) {
if (ThemesUtils.isCustomAccentEnabled()) {
if (ThemesUtils.isMonetTheme()) {
if (Preferences.getBoolValue("logColors", false)) {
try {
Log.d("ThemesCore", "Requesting color by color " + context.getResources().getResourceName(color));
@@ -119,7 +119,7 @@ public class ThemesManager {
initPaths(app);
validateModApk();
if (!Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && canApplyCustomAccent() && ThemesUtils.useNewColorEngine()) {
if (!Preferences.isNewBuild() && !ThemesUtils.isMonetTheme() && canApplyCustomAccent()) {
ResourcesLoader.init(app);
ResourcesLoader.load(app, modApk.getAbsolutePath(), false);
}
@@ -21,7 +21,7 @@ public class ViewInjector {
}
public static View inject(View view, int i, boolean z) {
if (ThemesUtils.isCustomAccentEnabled()) {
if (ThemesUtils.isMonetTheme()) {
for (BaseHook hook : hooks) {
hook.inject(view, i, z);
}
@@ -43,7 +43,7 @@ public class RecolorUtils {
}
public static int recolorHexColor(int i) {
if (!ThemesUtils.isCustomAccentEnabled()) return i;
if (!ThemesUtils.isMonetTheme()) return i;
var accented = ColorReferences.isAccentedColor(i);
var mutedaccented = ColorReferences.isMutedAccentedColor(i);
return (accented || mutedaccented) ? (accented ? ThemesUtils.getAccentColor() : ThemesUtils.getMutedAccentColor()) : i;
@@ -57,7 +57,7 @@ public class RecolorUtils {
@SuppressLint("UseCompatLoadingForColorStateLists")
public static ColorStateList themeCSL(Context context, int color) {
if (!ThemesUtils.isCustomAccentEnabled()) {
if (!ThemesUtils.isMonetTheme()) {
if (Build.VERSION.SDK_INT >= 23) {
return context.getColorStateList(color);
} else {
@@ -83,7 +83,7 @@ public class RecolorUtils {
} // Recolor ColorStateList
public static ColorStateList themeCSL(ColorStateList csl) {
if (!ThemesUtils.isCustomAccentEnabled()) return csl;
if (!ThemesUtils.isMonetTheme()) return csl;
try {
int unsel = csl.getColorForState(new int[]{-android.R.attr.state_selected}, Color.BLACK);
@@ -43,15 +43,15 @@ public class ThemesFragment extends TrackedMaterialPreferenceToolbarFragment {
findPreference("systememoji").setSummary(AndroidUtils.getGlobalContext().getString(R.string.systememojisum) + " \uD83D\uDE00\uD83D\uDE01\uD83E\uDD11\uD83E\uDD75\uD83D\uDC4D");
findPreference("useNewColorEngine").setVisible(Preferences.dev());
var invalidateThemeCache = findPreference("invalidate_theme_cache");
if (ThemesUtils.getReservedAccent() != Color.TRANSPARENT && Preferences.dev() && ThemesUtils.useNewColorEngine())
if (ThemesUtils.getReservedAccent() != Color.TRANSPARENT && Preferences.dev()) {
invalidateThemeCache.setOnPreferenceClickListener(preference -> {
setAccentColor(ThemesUtils.getReservedAccent());
return true;
});
else invalidateThemeCache.setVisible(false);
} else {
invalidateThemeCache.setVisible(false);
}
var navBarPreference = findPreference("navbar");
navBarPreference.setOnPreferenceClickListener(preference -> {
@@ -156,12 +156,8 @@ public class ThemesFragment extends TrackedMaterialPreferenceToolbarFragment {
}
})
.setNegativeButton(R.string.reset, (dialog, which) -> {
if (ThemesUtils.useNewColorEngine()) {
ThemesManager.deleteModification();
ThemesUtils.reserveAccentColor(Color.TRANSPARENT, false);
} else {
ThemesUtils.setCustomAccentColor(0, false);
}
ThemesManager.deleteModification();
ThemesUtils.reserveAccentColor(Color.TRANSPARENT, false);
restart();
})
.setPositiveButton(R.string.cancel, null)
@@ -207,35 +203,29 @@ public class ThemesFragment extends TrackedMaterialPreferenceToolbarFragment {
}
void setAccentColor(int color) {
if (ThemesUtils.useNewColorEngine()) {
final VKProgressDialog dialog = new VKProgressDialog(requireContext());
dialog.setCancelable(false);
dialog.setMessage(AndroidUtils.getString("applying_accent") + "...");
dialog.show();
final VKProgressDialog dialog = new VKProgressDialog(requireContext());
dialog.setCancelable(false);
dialog.setMessage(AndroidUtils.getString("applying_accent") + "...");
dialog.show();
VTExecutors.getIoExecutor().execute(() -> {
try {
ThemesUtils.reserveAccentColor(color, true);
ThemesManager.generateModApk(color);
requireActivity().runOnUiThread(this::restart);
} catch (Throwable e) {
Log.e("ThemesFragment", e.getMessage());
ThemesManager.deleteModification();
requireActivity().runOnUiThread(() -> {
dialog.dismiss();
new VkAlertDialog.Builder(requireContext())
.setTitle(AndroidUtils.getString("error"))
.setMessage(AndroidUtils.getString("error_applying_accent") + ":\n" + e)
.setPositiveButton("OK", null)
.show();
});
}
});
} else {
ThemesUtils.setCustomAccentColor(color, false);
ThemesCore.setThemedColors(color);
restart();
}
VTExecutors.getIoExecutor().execute(() -> {
try {
ThemesUtils.reserveAccentColor(color, true);
ThemesManager.generateModApk(color);
requireActivity().runOnUiThread(this::restart);
} catch (Throwable e) {
Log.e("ThemesFragment", e.getMessage());
ThemesManager.deleteModification();
requireActivity().runOnUiThread(() -> {
dialog.dismiss();
new VkAlertDialog.Builder(requireContext())
.setTitle(AndroidUtils.getString("error"))
.setMessage(AndroidUtils.getString("error_applying_accent") + ":\n" + e)
.setPositiveButton("OK", null)
.show();
});
}
});
}
void restart() {