diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index 44e2ae348..03768512a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -4526,15 +4526,12 @@ public class AndroidUtilities { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { final View decorView = window.getDecorView(); int flags = decorView.getSystemUiVisibility(); - if (!SharedConfig.noStatusBar && NekoConfig.transparentStatusBar.Bool()) { - window.setStatusBarColor(Color.TRANSPARENT); - } if (enable) { if ((flags & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) == 0) { flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; decorView.setSystemUiVisibility(flags); } - if (!SharedConfig.noStatusBar && !forceTransparentStatusbar && !NekoConfig.transparentStatusBar.Bool()) { + if (!SharedConfig.noStatusBar && !forceTransparentStatusbar) { window.setStatusBarColor(LIGHT_STATUS_BAR_OVERLAY); } else { window.setStatusBarColor(Color.TRANSPARENT); @@ -4544,7 +4541,7 @@ public class AndroidUtilities { flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; decorView.setSystemUiVisibility(flags); } - if (!SharedConfig.noStatusBar && !forceTransparentStatusbar && !NekoConfig.transparentStatusBar.Bool()) { + if (!SharedConfig.noStatusBar && !forceTransparentStatusbar) { window.setStatusBarColor(DARK_STATUS_BAR_OVERLAY); } else { window.setStatusBarColor(Color.TRANSPARENT); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index d8d809925..b655e240f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -321,7 +321,6 @@ public class ApplicationLoader extends Application { MessagesController.getInstance(account).putUser(user, true); } Utilities.stageQueue.postRunnable(() -> { - Theme.init(account); SendMessagesHelper.getInstance(account).checkUnsentMessages(); ContactsController.getInstance(account).checkAppAccount(); DownloadController.getInstance(account); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java index 63e0af24f..6c0e0b55b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java @@ -1242,7 +1242,7 @@ public class SharedConfig { devicePerformanceClass = preferences.getInt("devicePerformanceClass", -1); loopStickers = preferences.getBoolean("loopStickers", true); keepMedia = preferences.getInt("keep_media", 2); - noStatusBar = preferences.getBoolean("noStatusBar", true); + noStatusBar = NekoConfig.transparentStatusBar.Bool(); forceRtmpStream = preferences.getBoolean("forceRtmpStream", false); lastKeepMediaCheckTime = preferences.getInt("lastKeepMediaCheckTime", 0); lastLogsCheckTime = preferences.getInt("lastLogsCheckTime", 0); @@ -1627,13 +1627,14 @@ public class SharedConfig { editor.apply(); } - public static void toggleNoStatusBar() { - noStatusBar = !noStatusBar; - SharedPreferences preferences = MessagesController.getGlobalMainSettings(); - SharedPreferences.Editor editor = preferences.edit(); - editor.putBoolean("noStatusBar", noStatusBar); - editor.commit(); - } +// public static void toggleNoStatusBar() { +// noStatusBar = !noStatusBar; +// noStatusBar |= NekoConfig.transparentStatusBar.Bool(); +// SharedPreferences preferences = MessagesController.getGlobalMainSettings(); +// SharedPreferences.Editor editor = preferences.edit(); +// editor.putBoolean("noStatusBar", noStatusBar); +// editor.apply(); +// } public static void toggleLoopStickers() { loopStickers = !loopStickers; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index a5a5f560a..7f5114e02 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -260,6 +260,7 @@ public class ActionBar extends FrameLayout { int y = titleView.getTextStartY() + Theme.getCurrentHolidayDrawableYOffset() + (int) Math.ceil((titleView.getTextHeight() - rect.height()) / 2.0f); drawable.setBounds(x, y - drawable.getIntrinsicHeight(), x + drawable.getIntrinsicWidth(), y); drawable.setAlpha((int) (255 * titleView.getAlpha())); + drawable.setColorFilter(textPaint.getColor(), PorterDuff.Mode.MULTIPLY); drawable.draw(canvas); if (overlayTitleAnimationInProgress) { child.invalidate(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java index 22c3e5b6e..1fc5b4424 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -428,7 +428,7 @@ public class ActionBarLayout extends FrameLayout { } } if (currFragment != null && !currFragment.inPreviewMode && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !SharedConfig.noStatusBar) { - int overlayColor = Theme.getColor(Theme.key_actionBarDefault) == Color.WHITE ? AndroidUtilities.LIGHT_STATUS_BAR_OVERLAY : AndroidUtilities.DARK_STATUS_BAR_OVERLAY; + int overlayColor = ColorUtils.calculateLuminance(Theme.getColor(Theme.key_actionBarDefault)) > 0.7f ? AndroidUtilities.LIGHT_STATUS_BAR_OVERLAY : AndroidUtilities.DARK_STATUS_BAR_OVERLAY; int oldStatusBarColor = prevFragment != null && prevFragment.hasForceLightStatusBar() ? Color.TRANSPARENT : overlayColor; int newStatusBarColor = currFragment != null && currFragment.hasForceLightStatusBar() ? Color.TRANSPARENT : overlayColor; parentActivity.getWindow().setStatusBarColor(ColorUtils.blendARGB(newStatusBarColor, oldStatusBarColor, ratio)); @@ -1510,7 +1510,7 @@ public class ActionBarLayout extends FrameLayout { } if (previousFragment != null) { - AndroidUtilities.setLightStatusBar(parentActivity.getWindow(), Theme.getColor(Theme.key_actionBarDefault) == Color.WHITE || (previousFragment.hasForceLightStatusBar() && !Theme.getCurrentTheme().isDark()), previousFragment.hasForceLightStatusBar()); + AndroidUtilities.setLightStatusBar(parentActivity.getWindow(), ColorUtils.calculateLuminance(Theme.getColor(Theme.key_actionBarDefault)) > 0.7f || (previousFragment.hasForceLightStatusBar() && !Theme.getCurrentTheme().isDark()), previousFragment.hasForceLightStatusBar()); LayoutContainer temp = containerView; containerView = containerViewBack; containerViewBack = temp; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java index 9c1918c41..bf6ce6717 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java @@ -308,7 +308,7 @@ public abstract class BaseFragment { } if (hasForceLightStatusBar() && !AndroidUtilities.isTablet() && getParentLayout().getLastFragment() == this && getParentActivity() != null && !finishing) { - AndroidUtilities.setLightStatusBar(getParentActivity().getWindow(), Theme.getColor(Theme.key_actionBarDefault) == Color.WHITE); + AndroidUtilities.setLightStatusBar(getParentActivity().getWindow(), ColorUtils.calculateLuminance(Theme.getColor(Theme.key_actionBarDefault)) > 0.7f); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java index a3f9ea822..7c4a15e36 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java @@ -874,7 +874,7 @@ public class BottomSheet extends Dialog { if (useLightStatusBar && Build.VERSION.SDK_INT >= 23) { int color = Theme.getColor(Theme.key_actionBarDefault, null, true); - if (color == 0xffffffff) { + if (AndroidUtilities.computePerceivedBrightness(color) >= 0.721f) { int flags = container.getSystemUiVisibility(); flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; container.setSystemUiVisibility(flags); @@ -990,7 +990,7 @@ public class BottomSheet extends Dialog { if (Build.VERSION.SDK_INT >= 23) { int color = Theme.getColor(Theme.key_actionBarDefault, null, true); int flags = container.getSystemUiVisibility(); - if (useLightStatusBar && color == 0xffffffff) { + if (useLightStatusBar && AndroidUtilities.computePerceivedBrightness(color) >= 0.721f) { flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } else { flags &=~ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java index 72745f8f1..a66f8a1e6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -1836,7 +1836,6 @@ public class Theme { } } - public static class ThemeInfo implements NotificationCenter.NotificationCenterDelegate { public String name; public String pathToFile; @@ -2609,7 +2608,6 @@ public class Theme { } } - public interface ResourcesProvider { Integer getColor(String key); @@ -3873,7 +3871,6 @@ public class Theme { private static FragmentContextViewWavesDrawable fragmentContextViewWavesDrawable; private static RoundVideoProgressShadow roundPlayDrawable; - static { defaultColors.put(key_dialogBackground, 0xffffffff); defaultColors.put(key_dialogBackgroundGray, 0xfff0f0f0); @@ -4972,10 +4969,9 @@ public class Theme { themeInfo.previewBackgroundColor = 0xff95beec; themeInfo.previewInColor = 0xffffffff; themeInfo.previewOutColor = 0xffd0e6ff; - themeInfo.sortIndex = 1; themeInfo.firstAccentIsDefault = true; - if (NekoConfig.useDefaultTheme.Bool()) - themeInfo.currentAccentId = DEFALT_THEME_ACCENT_ID; + themeInfo.currentAccentId = DEFALT_THEME_ACCENT_ID; + themeInfo.sortIndex = 1; themeInfo.setAccentColorOptions( new int[] { 0xFF5890C5, 0xFF239853, 0xFFCE5E82, 0xFF7F63C3, 0xFF2491AD, 0xFF299C2F, 0xFF8854B4, 0xFF328ACF, 0xFF43ACC7, 0xFF52AC44, 0xFFCD5F93, 0xFFD28036, 0xFF8366CC, 0xFFCE4E57, 0xFFD3AE40, 0xFF7B88AB }, new int[] { 0xFFB8E18D, 0xFFFAFBCC, 0xFFFFF9DC, 0xFFC14F6E, 0xFFD1BD1B, 0xFFFFFAC9, 0xFFFCF6D8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, @@ -5000,8 +4996,6 @@ public class Theme { themeInfo.previewInColor = Color.parseColor("#c0ffffff"); themeInfo.previewOutColor = Color.parseColor("#3f51b5"); themeInfo.sortIndex = 0; - if (!NekoConfig.useDefaultTheme.Bool()) - themeInfo.currentAccentId = DEFALT_THEME_ACCENT_ID; themes.add(themeInfo); themesDict.put("NekoX", themeInfo); @@ -5167,7 +5161,7 @@ public class Theme { } } - theme = preferences.getString("nighttheme", "Night"); + theme = preferences.getString("nighttheme", null); if ("Default".equals(theme)) { applyingTheme = themesDict.get("Blue"); applyingTheme.currentAccentId = DEFALT_THEME_ACCENT_ID; @@ -5476,12 +5470,6 @@ public class Theme { }); } - public static void init(int a) { - SharedPreferences themeConfig = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE); - remoteThemesHash.put(a, themeConfig.getLong("2remoteThemesHash" + (a != 0 ? a : ""), 0)); - lastLoadingThemesTime.put(a, themeConfig.getInt("lastLoadingThemesTime" + (a != 0 ? a : ""), 0)); - } - private static Method StateListDrawable_getStateDrawableMethod; private static Field BitmapDrawable_mColorFilter; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 384f6f341..98a47bbdb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -2631,7 +2631,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific d.getWindow().setNavigationBarColor(0); int color = Theme.getColor(Theme.key_actionBarDefault, null, true); - AndroidUtilities.setLightStatusBar(d.getWindow(), color == Color.WHITE); + AndroidUtilities.setLightStatusBar(d.getWindow(), ColorUtils.calculateLuminance(color) > 0.7f); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { int color2 = Theme.getColor(Theme.key_windowBackgroundGray, null, true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index c7305b877..522056cf4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -999,7 +999,7 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar if (checkStatusBar) { boolean enable; if (currentFragment != null) { - enable = currentFragment.isLightStatusBar(); + enable = currentFragment.isLightStatusBar() || currentFragment.hasForceLightStatusBar() && !Theme.getCurrentTheme().isDark(); } else { int color = Theme.getColor(Theme.key_actionBarDefault, null, true); enable = ColorUtils.calculateLuminance(color) > 0.7f; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index e69f873d4..fe2a4c17f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -68,6 +68,7 @@ import android.widget.Toast; import androidx.annotation.Keep; import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; import androidx.collection.LongSparseArray; import androidx.core.content.ContextCompat; import androidx.core.graphics.ColorUtils; @@ -3160,7 +3161,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. SharedConfig.pauseMusicOnRecord ? LocaleController.getString("DebugMenuDisablePauseMusic", R.string.DebugMenuDisablePauseMusic) : LocaleController.getString("DebugMenuEnablePauseMusic", R.string.DebugMenuEnablePauseMusic), BuildVars.DEBUG_VERSION && !AndroidUtilities.isTablet() && Build.VERSION.SDK_INT >= 23 ? (SharedConfig.smoothKeyboard ? LocaleController.getString("DebugMenuDisableSmoothKeyboard", R.string.DebugMenuDisableSmoothKeyboard) : LocaleController.getString("DebugMenuEnableSmoothKeyboard", R.string.DebugMenuEnableSmoothKeyboard)) : null, BuildVars.DEBUG_PRIVATE_VERSION ? (SharedConfig.disableVoiceAudioEffects ? "Enable voip audio effects" : "Disable voip audio effects") : null, - Build.VERSION.SDK_INT >= 21 ? (SharedConfig.noStatusBar ? "Show status bar background" : "Hide status bar background") : null, +// Build.VERSION.SDK_INT >= 21 ? (SharedConfig.noStatusBar ? "Show status bar background" : "Hide status bar background") : null, + null, "Scan accounts", BuildVars.DEBUG_PRIVATE_VERSION ? "Clean app update" : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Reset suggestions" : null, @@ -3205,6 +3207,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else if (which == 8) { SharedConfig.toggleRoundCamera16to9(); } else if (which == 9) { + ((LaunchActivity) getParentActivity()).checkAppUpdate(true); } else if (which == 10) { getMessagesStorage().readAllDialogs(-1); } else if (which == 11) { @@ -3217,14 +3220,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else if (which == 13) { SharedConfig.toggleDisableVoiceAudioEffects(); } else if (which == 14) { - SharedConfig.toggleNoStatusBar(); - if (getParentActivity() != null && Build.VERSION.SDK_INT >= 21) { - if (SharedConfig.noStatusBar) { - getParentActivity().getWindow().setStatusBarColor(0); - } else { - getParentActivity().getWindow().setStatusBarColor(0x33000000); - } - } +// SharedConfig.toggleNoStatusBar(); +// if (getParentActivity() != null && Build.VERSION.SDK_INT >= 21) { +// if (SharedConfig.noStatusBar) { +// getParentActivity().getWindow().setStatusBarColor(0); +// } else { +// getParentActivity().getWindow().setStatusBarColor(0x33000000); +// } +// } } else if (which == 15) { SharedConfig.activeAccounts.clear(); int maxAccounts; @@ -3821,7 +3824,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. pinchToZoomHelper = new PinchToZoomHelper(decorView, frameLayout) { Paint statusBarPaint; - @Override protected void invalidateViews() { super.invalidateViews(); @@ -3845,7 +3847,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (actionBar.getOccupyStatusBar() && !SharedConfig.noStatusBar) { if (statusBarPaint == null) { statusBarPaint = new Paint(); - statusBarPaint.setColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (255 * 0.2f))); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + statusBarPaint.setColor(getParentActivity().getWindow().getStatusBarColor()); + } else { + statusBarPaint.setColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (255 * 0.2f))); + } } canvas.drawRect(actionBar.getX(), actionBar.getY(), actionBar.getX() + actionBar.getMeasuredWidth(), actionBar.getY() + AndroidUtilities.statusBarHeight, statusBarPaint); } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java index eca00904a..af36fe0d8 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java @@ -113,7 +113,7 @@ public class NekoConfig { public static ConfigItem skipOpenLinkConfirm = addConfig("SkipOpenLinkConfirm", configTypeBool, false); public static ConfigItem ignoreMutedCount = addConfig("IgnoreMutedCount", configTypeBool, true); - public static ConfigItem useDefaultTheme = addConfig("UseDefaultTheme", configTypeBool, false); +// public static ConfigItem useDefaultTheme = addConfig("UseDefaultTheme", configTypeBool, false); public static ConfigItem showIdAndDc = addConfig("ShowIdAndDc", configTypeBool, false); public static ConfigItem googleCloudTranslateKey = addConfig("GoogleCloudTransKey", configTypeString, ""); @@ -370,8 +370,8 @@ public class NekoConfig { if (preferences.contains("ignore_muted_count")) ignoreMutedCount.setConfigBool(preferences.getBoolean("ignore_muted_count", true)); - if (preferences.contains("use_default_theme")) - useDefaultTheme.setConfigBool(preferences.getBoolean("use_default_theme", false)); +// if (preferences.contains("use_default_theme")) +// useDefaultTheme.setConfigBool(preferences.getBoolean("use_default_theme", false)); if (preferences.contains("show_id_and_dc")) showIdAndDc.setConfigBool(preferences.getBoolean("show_id_and_dc", false)); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java index fe12c7564..e12a597e5 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java @@ -131,7 +131,7 @@ public class NekoGeneralSettingsActivity extends BaseFragment { private final AbstractConfigCell header5 = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Appearance"))); private final AbstractConfigCell typefaceRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.typeface)); - private final AbstractConfigCell useDefaultThemeRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useDefaultTheme)); +// private final AbstractConfigCell useDefaultThemeRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.useDefaultTheme)); private final AbstractConfigCell transparentStatusBarRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.transparentStatusBar)); private final AbstractConfigCell appBarShadowRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAppBarShadow)); private final AbstractConfigCell newYearRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.newYear));