mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-04 17:20:16 +01:00
try to fix status bar
This commit is contained in:
parent
ff45bdac1e
commit
9969037be2
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user