mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-07 11:09:49 +08:00
Updated TermuxPreferenceConstants
The `TermuxPreferenceConstants` classes has been updated to `v0.3.0`. Check its Changelog sections for info on changes.
This commit is contained in:
@@ -1,16 +1,22 @@
|
|||||||
package com.termux.app.settings.preferences;
|
package com.termux.app.settings.preferences;
|
||||||
|
|
||||||
import com.termux.app.TermuxConstants;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Version: v0.2.0
|
* Version: v0.3.0
|
||||||
*
|
*
|
||||||
* Changelog
|
* Changelog
|
||||||
*
|
*
|
||||||
* - 0.1.0 (2021-03-12)
|
* - 0.1.0 (2021-03-12)
|
||||||
* - Initial Release.
|
* - Initial Release.
|
||||||
|
*
|
||||||
* - 0.2.0 (2021-03-13)
|
* - 0.2.0 (2021-03-13)
|
||||||
* - Added `KEY_LOG_LEVEL` and `KEY_TERMINAL_VIEW_LOGGING_ENABLED`
|
* - Added `KEY_LOG_LEVEL` and `KEY_TERMINAL_VIEW_LOGGING_ENABLED`
|
||||||
|
*
|
||||||
|
* - 0.3.0 (2021-03-16)
|
||||||
|
* - Changed to per app scoping of variables so that the same file can store all constants of
|
||||||
|
* Termux app and its plugins. This will allow {@link com.termux.app.TermuxSettings} to
|
||||||
|
* manage preferences of plugins as well if they don't have launcher activity themselves
|
||||||
|
* and also allow plugin apps to make changes to preferences from background.
|
||||||
|
* - Added `KEY_LOG_LEVEL` to `TERMUX_TASKER_APP` scope.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,42 +25,64 @@ import com.termux.app.TermuxConstants;
|
|||||||
* instead of copying constants to random classes. The 3rd party apps can also import it for
|
* instead of copying constants to random classes. The 3rd party apps can also import it for
|
||||||
* interacting with termux apps. If changes are made to this file, increment the version number
|
* interacting with termux apps. If changes are made to this file, increment the version number
|
||||||
* and add an entry in the Changelog section above.
|
* and add an entry in the Changelog section above.
|
||||||
*
|
|
||||||
* The properties are loaded from the first file found at
|
|
||||||
* {@link TermuxConstants#TERMUX_PROPERTIES_PRIMARY_FILE_PATH} or
|
|
||||||
* {@link TermuxConstants#TERMUX_PROPERTIES_SECONDARY_FILE_PATH}
|
|
||||||
*/
|
*/
|
||||||
public final class TermuxPreferenceConstants {
|
public final class TermuxPreferenceConstants {
|
||||||
|
|
||||||
/** Defines the key for whether to show terminal toolbar containing extra keys and text input field */
|
/**
|
||||||
|
* Termux app constants.
|
||||||
|
*/
|
||||||
|
public static final class TERMUX_APP {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the key for whether to show terminal toolbar containing extra keys and text input field
|
||||||
|
*/
|
||||||
public static final String KEY_SHOW_TERMINAL_TOOLBAR = "show_extra_keys";
|
public static final String KEY_SHOW_TERMINAL_TOOLBAR = "show_extra_keys";
|
||||||
public static final boolean DEFAULT_VALUE_SHOW_TERMINAL_TOOLBAR = true;
|
public static final boolean DEFAULT_VALUE_SHOW_TERMINAL_TOOLBAR = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/** Defines the key for whether to always keep screen on */
|
* Defines the key for whether to always keep screen on
|
||||||
|
*/
|
||||||
public static final String KEY_KEEP_SCREEN_ON = "screen_always_on";
|
public static final String KEY_KEEP_SCREEN_ON = "screen_always_on";
|
||||||
public static final boolean DEFAULT_VALUE_KEEP_SCREEN_ON = true;
|
public static final boolean DEFAULT_VALUE_KEEP_SCREEN_ON = true;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/** Defines the key for font size of termux terminal view */
|
* Defines the key for font size of termux terminal view
|
||||||
|
*/
|
||||||
public static final String KEY_FONTSIZE = "fontsize";
|
public static final String KEY_FONTSIZE = "fontsize";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/** Defines the key for current termux terminal session */
|
* Defines the key for current termux terminal session
|
||||||
|
*/
|
||||||
public static final String KEY_CURRENT_SESSION = "current_session";
|
public static final String KEY_CURRENT_SESSION = "current_session";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/** Defines the key for current termux log level */
|
* Defines the key for current termux log level
|
||||||
|
*/
|
||||||
public static final String KEY_LOG_LEVEL = "log_level";
|
public static final String KEY_LOG_LEVEL = "log_level";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/** Defines the key for whether termux terminal view key logging is enabled or not */
|
* Defines the key for whether termux terminal view key logging is enabled or not
|
||||||
|
*/
|
||||||
public static final String KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED = "terminal_view_key_logging_enabled";
|
public static final String KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED = "terminal_view_key_logging_enabled";
|
||||||
public static final boolean DEFAULT_VALUE_TERMINAL_VIEW_KEY_LOGGING_ENABLED = false;
|
public static final boolean DEFAULT_VALUE_TERMINAL_VIEW_KEY_LOGGING_ENABLED = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Termux Tasker app constants.
|
||||||
|
*/
|
||||||
|
public static final class TERMUX_TASKER_APP {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the key for current termux log level
|
||||||
|
*/
|
||||||
|
public static final String KEY_LOG_LEVEL = "log_level";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -8,6 +8,7 @@ import com.termux.app.TermuxConstants;
|
|||||||
import com.termux.app.utils.Logger;
|
import com.termux.app.utils.Logger;
|
||||||
import com.termux.app.utils.TermuxUtils;
|
import com.termux.app.utils.TermuxUtils;
|
||||||
import com.termux.app.utils.TextDataUtils;
|
import com.termux.app.utils.TextDataUtils;
|
||||||
|
import com.termux.app.settings.preferences.TermuxPreferenceConstants.TERMUX_APP;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@@ -35,11 +36,11 @@ public class TermuxSharedPreferences {
|
|||||||
|
|
||||||
|
|
||||||
public boolean getShowTerminalToolbar() {
|
public boolean getShowTerminalToolbar() {
|
||||||
return mSharedPreferences.getBoolean(TermuxPreferenceConstants.KEY_SHOW_TERMINAL_TOOLBAR, TermuxPreferenceConstants.DEFAULT_VALUE_SHOW_TERMINAL_TOOLBAR);
|
return mSharedPreferences.getBoolean(TERMUX_APP.KEY_SHOW_TERMINAL_TOOLBAR, TERMUX_APP.DEFAULT_VALUE_SHOW_TERMINAL_TOOLBAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowTerminalToolbar(boolean value) {
|
public void setShowTerminalToolbar(boolean value) {
|
||||||
mSharedPreferences.edit().putBoolean(TermuxPreferenceConstants.KEY_SHOW_TERMINAL_TOOLBAR, value).apply();
|
mSharedPreferences.edit().putBoolean(TERMUX_APP.KEY_SHOW_TERMINAL_TOOLBAR, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean toogleShowTerminalToolbar() {
|
public boolean toogleShowTerminalToolbar() {
|
||||||
@@ -51,11 +52,11 @@ public class TermuxSharedPreferences {
|
|||||||
|
|
||||||
|
|
||||||
public boolean getKeepScreenOn() {
|
public boolean getKeepScreenOn() {
|
||||||
return mSharedPreferences.getBoolean(TermuxPreferenceConstants.KEY_KEEP_SCREEN_ON, TermuxPreferenceConstants.DEFAULT_VALUE_KEEP_SCREEN_ON);
|
return mSharedPreferences.getBoolean(TERMUX_APP.KEY_KEEP_SCREEN_ON, TERMUX_APP.DEFAULT_VALUE_KEEP_SCREEN_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeepScreenOn(boolean value) {
|
public void setKeepScreenOn(boolean value) {
|
||||||
mSharedPreferences.edit().putBoolean(TermuxPreferenceConstants.KEY_KEEP_SCREEN_ON, value).apply();
|
mSharedPreferences.edit().putBoolean(TERMUX_APP.KEY_KEEP_SCREEN_ON, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ public class TermuxSharedPreferences {
|
|||||||
String fontString;
|
String fontString;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fontString = mSharedPreferences.getString(TermuxPreferenceConstants.KEY_FONTSIZE, Integer.toString(DEFAULT_FONTSIZE));
|
fontString = mSharedPreferences.getString(TERMUX_APP.KEY_FONTSIZE, Integer.toString(DEFAULT_FONTSIZE));
|
||||||
if(fontString != null)
|
if(fontString != null)
|
||||||
fontSize = Integer.parseInt(fontString);
|
fontSize = Integer.parseInt(fontString);
|
||||||
else
|
else
|
||||||
@@ -96,7 +97,7 @@ public class TermuxSharedPreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setFontSize(String value) {
|
public void setFontSize(String value) {
|
||||||
mSharedPreferences.edit().putString(TermuxPreferenceConstants.KEY_FONTSIZE, value).apply();
|
mSharedPreferences.edit().putString(TERMUX_APP.KEY_FONTSIZE, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeFontSize(Context context, boolean increase) {
|
public void changeFontSize(Context context, boolean increase) {
|
||||||
@@ -112,42 +113,38 @@ public class TermuxSharedPreferences {
|
|||||||
|
|
||||||
|
|
||||||
public String getCurrentSession() {
|
public String getCurrentSession() {
|
||||||
return mSharedPreferences.getString(TermuxPreferenceConstants.KEY_CURRENT_SESSION, "");
|
return mSharedPreferences.getString(TERMUX_APP.KEY_CURRENT_SESSION, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentSession(String value) {
|
public void setCurrentSession(String value) {
|
||||||
mSharedPreferences.edit().putString(TermuxPreferenceConstants.KEY_CURRENT_SESSION, value).apply();
|
mSharedPreferences.edit().putString(TERMUX_APP.KEY_CURRENT_SESSION, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getLogLevel() {
|
public int getLogLevel() {
|
||||||
try {
|
try {
|
||||||
return mSharedPreferences.getInt(TermuxPreferenceConstants.KEY_LOG_LEVEL, Logger.DEFAULT_LOG_LEVEL);
|
return mSharedPreferences.getInt(TERMUX_APP.KEY_LOG_LEVEL, Logger.DEFAULT_LOG_LEVEL);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Logger.logStackTraceWithMessage("Error getting \"" + TermuxPreferenceConstants.KEY_LOG_LEVEL + "\" from shared preferences", e);
|
Logger.logStackTraceWithMessage("Error getting \"" + TERMUX_APP.KEY_LOG_LEVEL + "\" from shared preferences", e);
|
||||||
return Logger.DEFAULT_LOG_LEVEL;
|
return Logger.DEFAULT_LOG_LEVEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLogLevel(Context context, int logLevel) {
|
public void setLogLevel(Context context, int logLevel) {
|
||||||
logLevel = Logger.setLogLevel(context, logLevel);
|
logLevel = Logger.setLogLevel(context, logLevel);
|
||||||
mSharedPreferences.edit().putInt(TermuxPreferenceConstants.KEY_LOG_LEVEL, logLevel).apply();
|
mSharedPreferences.edit().putInt(TERMUX_APP.KEY_LOG_LEVEL, logLevel).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean getTerminalViewKeyLoggingEnabled() {
|
public boolean getTerminalViewKeyLoggingEnabled() {
|
||||||
return mSharedPreferences.getBoolean(TermuxPreferenceConstants.KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED, TermuxPreferenceConstants.DEFAULT_VALUE_TERMINAL_VIEW_KEY_LOGGING_ENABLED);
|
return mSharedPreferences.getBoolean(TERMUX_APP.KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED, TERMUX_APP.DEFAULT_VALUE_TERMINAL_VIEW_KEY_LOGGING_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTerminalViewKeyLoggingEnabled(boolean value) {
|
public void setTerminalViewKeyLoggingEnabled(boolean value) {
|
||||||
mSharedPreferences.edit().putBoolean(TermuxPreferenceConstants.KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED, value).apply();
|
mSharedPreferences.edit().putBoolean(TERMUX_APP.KEY_TERMINAL_VIEW_KEY_LOGGING_ENABLED, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user