From d8f066dec47f63d57d0a669731d9b98efc23b063 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Mon, 21 Jan 2019 00:33:03 +0100 Subject: [PATCH] Minor restructuring of TermuxPreferences --- .../java/com/termux/app/TermuxActivity.java | 2 +- .../com/termux/app/TermuxPreferences.java | 50 +++++++++---------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/com/termux/app/TermuxActivity.java b/app/src/main/java/com/termux/app/TermuxActivity.java index 18dbcb8d..9ab2c655 100644 --- a/app/src/main/java/com/termux/app/TermuxActivity.java +++ b/app/src/main/java/com/termux/app/TermuxActivity.java @@ -215,7 +215,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection mTerminalView.requestFocus(); final ViewPager viewPager = findViewById(R.id.viewpager); - if (mSettings.isShowExtraKeys()) viewPager.setVisibility(View.VISIBLE); + if (mSettings.mShowExtraKeys) viewPager.setVisibility(View.VISIBLE); ViewGroup.LayoutParams layoutParams = viewPager.getLayoutParams(); diff --git a/app/src/main/java/com/termux/app/TermuxPreferences.java b/app/src/main/java/com/termux/app/TermuxPreferences.java index b98d9741..2dd16525 100644 --- a/app/src/main/java/com/termux/app/TermuxPreferences.java +++ b/app/src/main/java/com/termux/app/TermuxPreferences.java @@ -27,9 +27,25 @@ final class TermuxPreferences { @IntDef({BELL_VIBRATE, BELL_BEEP, BELL_IGNORE}) @Retention(RetentionPolicy.SOURCE) - public @interface AsciiBellBehaviour { + @interface AsciiBellBehaviour { } + final static class KeyboardShortcut { + + KeyboardShortcut(int codePoint, int shortcutAction) { + this.codePoint = codePoint; + this.shortcutAction = shortcutAction; + } + + final int codePoint; + final int shortcutAction; + } + + static final int SHORTCUT_ACTION_CREATE_SESSION = 1; + static final int SHORTCUT_ACTION_NEXT_SESSION = 2; + static final int SHORTCUT_ACTION_PREVIOUS_SESSION = 3; + static final int SHORTCUT_ACTION_RENAME_SESSION = 4; + static final int BELL_VIBRATE = 1; static final int BELL_BEEP = 2; static final int BELL_IGNORE = 3; @@ -50,7 +66,11 @@ final class TermuxPreferences { boolean mBackIsEscape; boolean mShowExtraKeys; - + + String[][] mExtraKeys; + + final List shortcuts = new ArrayList<>(); + /** * If value is not in the range [min, max], set it to either min or max. */ @@ -84,10 +104,6 @@ final class TermuxPreferences { mFontSize = clamp(mFontSize, MIN_FONTSIZE, MAX_FONTSIZE); } - boolean isShowExtraKeys() { - return mShowExtraKeys; - } - boolean toggleShowExtraKeys(Context context) { mShowExtraKeys = !mShowExtraKeys; PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(SHOW_EXTRA_KEYS_KEY, mShowExtraKeys).apply(); @@ -128,9 +144,7 @@ final class TermuxPreferences { return null; } - public String[][] mExtraKeys; - - public void reloadFromProperties(Context context) { + void reloadFromProperties(Context context) { File propsFile = new File(TermuxService.HOME_PATH + "/.termux/termux.properties"); if (!propsFile.exists()) propsFile = new File(TermuxService.HOME_PATH + "/.config/termux/termux.properties"); @@ -185,24 +199,6 @@ final class TermuxPreferences { parseAction("shortcut.rename-session", SHORTCUT_ACTION_RENAME_SESSION, props); } - public static final int SHORTCUT_ACTION_CREATE_SESSION = 1; - public static final int SHORTCUT_ACTION_NEXT_SESSION = 2; - public static final int SHORTCUT_ACTION_PREVIOUS_SESSION = 3; - public static final int SHORTCUT_ACTION_RENAME_SESSION = 4; - - public final static class KeyboardShortcut { - - public KeyboardShortcut(int codePoint, int shortcutAction) { - this.codePoint = codePoint; - this.shortcutAction = shortcutAction; - } - - final int codePoint; - final int shortcutAction; - } - - final List shortcuts = new ArrayList<>(); - private void parseAction(String name, int shortcutAction, Properties props) { String value = props.getProperty(name); if (value == null) return;