这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
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
16 changes: 7 additions & 9 deletions app/src/main/java/com/termux/app/ExtraKeysView.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public final class ExtraKeysView extends GridLayout {

public ExtraKeysView(Context context, AttributeSet attrs) {
super(context, attrs);

reload();
}

static void sendKey(View view, String keyName) {
Expand Down Expand Up @@ -101,23 +99,23 @@ public boolean readFnButton() {
return result;
}

void reload() {
void reload(final String[][] buttons) {
altButton = controlButton = null;
removeAllViews();

String[][] buttons = {
{"ESC", "CTRL", "ALT", "TAB", "―", "/", "|"}
};

final int rows = buttons.length;
final int cols = buttons[0].length;
int mx = 0;
for (int row = 0; row < rows; row++) {
if(buttons[row].length > mx) mx = buttons[row].length;
}
final int cols = mx;

setRowCount(rows);
setColumnCount(cols);

for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
final String buttonText = buttons[row][col];
final String buttonText = (buttons[row][col] == null ? " " : buttons[row][col]);

Button button;
switch (buttonText) {
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ public void onCreate(Bundle bundle) {

final ViewPager viewPager = findViewById(R.id.viewpager);
if (mSettings.isShowExtraKeys()) viewPager.setVisibility(View.VISIBLE);


ViewGroup.LayoutParams layoutParams = viewPager.getLayoutParams();
layoutParams.height = layoutParams.height * mSettings.mExtraKeys.length;
viewPager.setLayoutParams(layoutParams);

viewPager.setAdapter(new PagerAdapter() {
@Override
Expand All @@ -236,6 +241,7 @@ public Object instantiateItem(@NonNull ViewGroup collection, int position) {
View layout;
if (position == 0) {
layout = mExtraKeysView = (ExtraKeysView) inflater.inflate(R.layout.extra_keys_main, collection, false);
mExtraKeysView.reload(mSettings.mExtraKeys);
} else {
layout = inflater.inflate(R.layout.extra_keys_right, collection, false);
final EditText editText = layout.findViewById(R.id.text_input);
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/termux/app/TermuxPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.json.JSONArray;

final class TermuxPreferences {

Expand Down Expand Up @@ -103,6 +104,8 @@ static TerminalSession getCurrentSession(TermuxActivity context) {
}
return null;
}

public String[][] mExtraKeys;

public void reloadFromProperties(Context context) {
try {
Expand All @@ -128,6 +131,16 @@ public void reloadFromProperties(Context context) {
mBellBehaviour = BELL_VIBRATE;
break;
}

JSONArray arr = new JSONArray(props.getProperty("extrakeys", "[[\"ESC\",\"CTRL\",\"ALT\",\"TAB\",\"―\",\"/\",\"|\"]]"));
mExtraKeys = new String[arr.length()][];
for(int i = 0; i < arr.length(); i++) {
JSONArray line = arr.getJSONArray(i);
mExtraKeys[i] = new String[line.length()];
for(int j = 0; j < line.length(); j++) {
mExtraKeys[i][j] = line.getString(j);
}
}

mBackIsEscape = "escape".equals(props.getProperty("back-key", "back"));

Expand Down