这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 36 additions & 14 deletions terminal-view/src/main/java/com/termux/view/TerminalView.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,7 @@ public boolean attachSession(TerminalSession session) {

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
File propsFile = new File(getContext().getFilesDir() + "/home/.termux/termux.properties");
if (!propsFile.exists())
propsFile = new File(getContext().getFilesDir() + "/home/.config/termux/termux.properties");

Properties props = new Properties();
try {
if (propsFile.isFile() && propsFile.canRead()) {
try (FileInputStream in = new FileInputStream(propsFile)) {
props.load(new InputStreamReader(in, StandardCharsets.UTF_8));
}
}
} catch (Exception e) {
Log.e("termux", "Error loading props", e);
}
Properties props = getProperties();

if (props.getProperty("enforce-char-based-input", "false").equals("true")) {
// Some keyboards seems do not reset the internal state on TYPE_NULL.
Expand Down Expand Up @@ -552,6 +539,8 @@ public boolean onTouchEvent(MotionEvent ev) {

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
Properties props = getProperties();

if (LOG_KEY_EVENTS)
Log.i(EmulatorDebug.LOG_TAG, "onKeyPreIme(keyCode=" + keyCode + ", event=" + event + ")");
if (keyCode == KeyEvent.KEYCODE_BACK) {
Expand All @@ -567,6 +556,11 @@ public boolean onKeyPreIme(int keyCode, KeyEvent event) {
return onKeyUp(keyCode, event);
}
}
} else if (props.getProperty("ctrl-space-workaround", "false").equals("true") &&
keyCode == KeyEvent.KEYCODE_SPACE && event.isCtrlPressed()) {
/* ctrl + space does not work on some ROMs without this workaround.
However, this breaks it on devices where it works out of the box. */
return onKeyDown(keyCode, event);
}
return super.onKeyPreIme(keyCode, event);
}
Expand Down Expand Up @@ -1544,6 +1538,34 @@ private void updateFloatingToolbarVisibility(MotionEvent event) {
}
}

private Properties getProperties() {
File propsFile;
Properties props = new Properties();
String possiblePropLocations[] = {
getContext().getFilesDir() + "/home/.termux/termux.properties",
getContext().getFilesDir() + "/home/.config/termux/termux.properties"
};

propsFile = new File(possiblePropLocations[0]);
int i = 1;
while (!propsFile.exists() && i <= possiblePropLocations.length) {
propsFile = new File(possiblePropLocations[i]);
i += 1;
}

try {
if (propsFile.isFile() && propsFile.canRead()) {
try (FileInputStream in = new FileInputStream(propsFile)) {
props.load(new InputStreamReader(in, StandardCharsets.UTF_8));
}
}
} catch (Exception e) {
Log.e("termux", "Error loading props", e);
}

return props;
}

@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void autofill(AutofillValue value) {
Expand Down