mirror of
https://github.com/fankes/termux-app.git
synced 2025-10-22 03:39:21 +08:00
Changed|Deprecated: Deprecate use-black-ui
termux property and replace it with night-mode
This will not break existing `use-black-ui` settings for users and it will automatically be converted to `night-mode` when properties are loaded from disk but a deprecation message will be logged. This `night-mode` key can be used to set the day/night theme variant for activities used by termux app and its plugin. The user can set a string value to `true` to force use dark variant of theme, `false` to force use light variant of theme or `system` to automatically set theme based on current system settings. The default value is still `system`. The app must be restarted for changes to take effect for existing activities, including main terminal `TermuxActivity`. This is required since "theme != night mode". In future custom theme or color support may be provided that will have both dark and night modes for the same theme.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.termux.shared.models.theme;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
/** The modes used by to decide night mode for themes. */
|
||||
public enum NightMode {
|
||||
|
||||
/** Night theme should be enabled. */
|
||||
TRUE("true", AppCompatDelegate.MODE_NIGHT_YES),
|
||||
|
||||
/** Dark theme should be enabled. */
|
||||
FALSE("false", AppCompatDelegate.MODE_NIGHT_NO),
|
||||
|
||||
/**
|
||||
* Use night or dark theme depending on system night mode.
|
||||
* https://developer.android.com/guide/topics/resources/providing-resources#NightQualifier
|
||||
*/
|
||||
SYSTEM("system", AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
|
||||
|
||||
private final String name;
|
||||
private final int mode;
|
||||
|
||||
NightMode(final String name, int mode) {
|
||||
this.name = name;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public static Integer modeOf(String name) {
|
||||
if (TRUE.name.equals(name))
|
||||
return TRUE.mode;
|
||||
else if (FALSE.name.equals(name))
|
||||
return FALSE.mode;
|
||||
else if (SYSTEM.name.equals(name)) {
|
||||
return SYSTEM.mode;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user