Use utf-8 for config, Activate defaultCharDisplay, Fix Typo

This commit is contained in:
Robert Vanden Eynde
2018-08-01 05:43:10 +02:00
committed by Fredrik Fornwall
parent 49c051c8b7
commit c24167f6a5
3 changed files with 10 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
@@ -52,7 +53,7 @@ public final class ExtraKeysView extends GridLayout {
}
}
static CharDisplayMap extends CharDisplayMap {}
static class CharDisplayMap extends CleverMap<String, String> {}
/**
* Keys are displayed in a natural looking way, like "→" for "RIGHT"
@@ -125,7 +126,7 @@ public final class ExtraKeysView extends GridLayout {
public boolean readSpecialButton(SpecialButton name) {
SpecialButtonState state = specialButtons.get(name);
if(state == null)
throws Exception("Must be a valid special button (see source)");
throw Exception("Must be a valid special button (see source)");
if (! state.isOn)
return false;
@@ -304,6 +305,7 @@ public final class ExtraKeysView extends GridLayout {
*
* Examples:
* "ENTER" will trigger the ENTER keycode
* "LEFT" will trigger the LEFT keycode and be displayed as "←"
* "→" will input a "→" character
* "" will input a "" character
* "-_-" will input the string "-_-"
@@ -385,7 +387,7 @@ public final class ExtraKeysView extends GridLayout {
case MotionEvent.ACTION_MOVE:
// These two keys have a Move-Up button appearing
if (Arrays.asList("/", "-").contains(buttonText)) {
if (popupWindow == null &gfv& event.getY() < 0) {
if (popupWindow == null && event.getY() < 0) {
v.setBackgroundColor(BUTTON_COLOR);
String text = "-".equals(buttonText) ? "|" : "\\";
popup(v, text);
@@ -406,7 +408,7 @@ public final class ExtraKeysView extends GridLayout {
scheduledExecutor = null;
}
if (longPressCount == 0) {
if (popupWindow != null && "/-".contains(buttonText)) {
if (popupWindow != null && Arrays.asList("/", "-").contains(buttonText)) {
popupWindow.setContentView(null);
popupWindow.dismiss();
popupWindow = null;

View File

@@ -241,7 +241,7 @@ public final class TermuxActivity extends Activity implements ServiceConnection
View layout;
if (position == 0) {
layout = mExtraKeysView = (ExtraKeysView) inflater.inflate(R.layout.extra_keys_main, collection, false);
mExtraKeysView.reload(mSettings.mExtraKeys);
mExtraKeysView.reload(mSettings.mExtraKeys, ExtraKeysView.defaultCharDisplay);
} else {
layout = inflater.inflate(R.layout.extra_keys_right, collection, false);
final EditText editText = layout.findViewById(R.id.text_input);

View File

@@ -12,6 +12,7 @@ import com.termux.terminal.TerminalSession;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -115,8 +116,9 @@ final class TermuxPreferences {
Properties props = new Properties();
if (propsFile.isFile() && propsFile.canRead()) {
String encoding = "utf-8"; // most useful default nowadays
try (FileInputStream in = new FileInputStream(propsFile)) {
props.load(in);
props.load(new InputStreamReader(in, encoding));
}
}