|
|
|
@@ -66,7 +66,7 @@ public final class MainActivity extends Activity {
|
|
|
|
|
private static final int MAX_TERMINAL_COLS = 140;
|
|
|
|
|
private static final int MIN_TERMINAL_ROWS = 8;
|
|
|
|
|
private static final int MAX_TERMINAL_ROWS = 80;
|
|
|
|
|
private static final int TERMINAL_KEYS_HEIGHT_DP = 44;
|
|
|
|
|
private static final int TERMINAL_KEYS_HEIGHT_DP = 34;
|
|
|
|
|
private static final int STATUS_NORMAL = 0;
|
|
|
|
|
private static final int STATUS_BUSY = 1;
|
|
|
|
|
private static final int STATUS_SUCCESS = 2;
|
|
|
|
@@ -126,7 +126,8 @@ public final class MainActivity extends Activity {
|
|
|
|
|
private TextView terminalMetaText;
|
|
|
|
|
private ScrollView terminalScroll;
|
|
|
|
|
private EditText inputField;
|
|
|
|
|
private Button terminalKeyPageButton;
|
|
|
|
|
private final Button[] terminalAccessoryTabButtons = new Button[4];
|
|
|
|
|
private View terminalAccessoryBar;
|
|
|
|
|
private View terminalComposerBar;
|
|
|
|
|
private LinearLayout terminalGroupRow;
|
|
|
|
|
private String activeSessionName;
|
|
|
|
@@ -1634,12 +1635,13 @@ public final class MainActivity extends Activity {
|
|
|
|
|
0,
|
|
|
|
|
1
|
|
|
|
|
));
|
|
|
|
|
terminalComposerBar = createComposerBar();
|
|
|
|
|
root.addView(terminalComposerBar, matchWrap());
|
|
|
|
|
root.addView(createAccessoryBar(), new LinearLayout.LayoutParams(
|
|
|
|
|
terminalAccessoryBar = createAccessoryBar();
|
|
|
|
|
root.addView(terminalAccessoryBar, new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
dp(TERMINAL_KEYS_HEIGHT_DP)
|
|
|
|
|
));
|
|
|
|
|
terminalComposerBar = createComposerBar();
|
|
|
|
|
root.addView(terminalComposerBar, matchWrap());
|
|
|
|
|
terminalScroll.post(() -> {
|
|
|
|
|
resizeTerminalToViewport(false);
|
|
|
|
|
connectTerminal(sessionName);
|
|
|
|
@@ -2061,20 +2063,45 @@ public final class MainActivity extends Activity {
|
|
|
|
|
private LinearLayout createComposerBar() {
|
|
|
|
|
LinearLayout bar = new LinearLayout(this);
|
|
|
|
|
bar.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
bar.setPadding(dp(9), dp(7), dp(9), dp(8));
|
|
|
|
|
bar.setPadding(dp(8), dp(5), dp(8), dp(7));
|
|
|
|
|
bar.setBackgroundColor(COLOR_BAR);
|
|
|
|
|
|
|
|
|
|
LinearLayout row = new LinearLayout(this);
|
|
|
|
|
row.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
|
row.setGravity(Gravity.BOTTOM);
|
|
|
|
|
row.setGravity(Gravity.CENTER_VERTICAL);
|
|
|
|
|
|
|
|
|
|
LinearLayout tabGrid = new LinearLayout(this);
|
|
|
|
|
tabGrid.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
LinearLayout firstTabRow = terminalKeyRow();
|
|
|
|
|
LinearLayout secondTabRow = terminalKeyRow();
|
|
|
|
|
addAccessoryTab(firstTabRow, "Edit", 0);
|
|
|
|
|
addAccessoryTab(firstTabRow, "Ctrl", 1);
|
|
|
|
|
addAccessoryTab(secondTabRow, "Nav", 2);
|
|
|
|
|
addAccessoryTab(secondTabRow, "Sym", 3);
|
|
|
|
|
tabGrid.addView(firstTabRow, new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
0,
|
|
|
|
|
1
|
|
|
|
|
));
|
|
|
|
|
LinearLayout.LayoutParams secondTabParams = new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
0,
|
|
|
|
|
1
|
|
|
|
|
);
|
|
|
|
|
secondTabParams.topMargin = dp(3);
|
|
|
|
|
tabGrid.addView(secondTabRow, secondTabParams);
|
|
|
|
|
row.addView(tabGrid, new LinearLayout.LayoutParams(
|
|
|
|
|
dp(72),
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
inputField = new EditText(this);
|
|
|
|
|
inputField.setTextColor(COLOR_TEXT);
|
|
|
|
|
inputField.setHintTextColor(COLOR_TEXT_DIM);
|
|
|
|
|
inputField.setHint("type a command…");
|
|
|
|
|
inputField.setHint("type command or text");
|
|
|
|
|
inputField.setSingleLine(false);
|
|
|
|
|
inputField.setMinLines(1);
|
|
|
|
|
inputField.setMaxLines(2);
|
|
|
|
|
inputField.setMinLines(3);
|
|
|
|
|
inputField.setMaxLines(5);
|
|
|
|
|
inputField.setCursorVisible(true);
|
|
|
|
|
inputField.setFocusableInTouchMode(true);
|
|
|
|
|
inputField.setGravity(Gravity.TOP | Gravity.START);
|
|
|
|
@@ -2099,21 +2126,37 @@ public final class MainActivity extends Activity {
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
Button image = terminalToolButton("▧", view -> pickImageForSession(activeSessionName));
|
|
|
|
|
image.setContentDescription("Upload image");
|
|
|
|
|
row.addView(image, new LinearLayout.LayoutParams(dp(40), dp(40)));
|
|
|
|
|
LinearLayout.LayoutParams inputParams = new LinearLayout.LayoutParams(
|
|
|
|
|
0,
|
|
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
|
|
1
|
|
|
|
|
);
|
|
|
|
|
inputParams.leftMargin = dp(6);
|
|
|
|
|
inputParams.rightMargin = dp(6);
|
|
|
|
|
inputParams.leftMargin = dp(5);
|
|
|
|
|
inputParams.rightMargin = dp(5);
|
|
|
|
|
row.addView(inputField, inputParams);
|
|
|
|
|
Button send = primaryButton("↵", view -> sendLine());
|
|
|
|
|
send.setTextSize(18);
|
|
|
|
|
|
|
|
|
|
LinearLayout actions = new LinearLayout(this);
|
|
|
|
|
actions.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
Button send = composerPrimaryButton("Send", view -> sendLine());
|
|
|
|
|
send.setContentDescription("Send input");
|
|
|
|
|
row.addView(send, new LinearLayout.LayoutParams(dp(40), dp(40)));
|
|
|
|
|
actions.addView(send, new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
0,
|
|
|
|
|
1
|
|
|
|
|
));
|
|
|
|
|
Button image = composerButton("Img", view -> pickImageForSession(activeSessionName));
|
|
|
|
|
image.setContentDescription("Upload image");
|
|
|
|
|
LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
0,
|
|
|
|
|
1
|
|
|
|
|
);
|
|
|
|
|
imageParams.topMargin = dp(3);
|
|
|
|
|
actions.addView(image, imageParams);
|
|
|
|
|
row.addView(actions, new LinearLayout.LayoutParams(
|
|
|
|
|
dp(48),
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
|
|
));
|
|
|
|
|
bar.addView(row, matchWrap());
|
|
|
|
|
return bar;
|
|
|
|
|
}
|
|
|
|
@@ -2676,19 +2719,26 @@ public final class MainActivity extends Activity {
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private HorizontalScrollView createAccessoryBar() {
|
|
|
|
|
HorizontalScrollView scroller = new HorizontalScrollView(this);
|
|
|
|
|
scroller.setHorizontalScrollBarEnabled(false);
|
|
|
|
|
scroller.setBackgroundColor(COLOR_PANEL);
|
|
|
|
|
private LinearLayout createAccessoryBar() {
|
|
|
|
|
LinearLayout panel = new LinearLayout(this);
|
|
|
|
|
panel.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
panel.setPadding(dp(4), dp(3), dp(4), dp(3));
|
|
|
|
|
panel.setBackgroundColor(COLOR_PANEL);
|
|
|
|
|
|
|
|
|
|
LinearLayout row = terminalKeyRow();
|
|
|
|
|
row.setPadding(dp(8), dp(5), dp(8), dp(5));
|
|
|
|
|
addAccessoryPageKeys(row);
|
|
|
|
|
scroller.addView(row, new HorizontalScrollView.LayoutParams(
|
|
|
|
|
HorizontalScrollView keyScroller = new HorizontalScrollView(this);
|
|
|
|
|
keyScroller.setHorizontalScrollBarEnabled(false);
|
|
|
|
|
keyScroller.setFillViewport(true);
|
|
|
|
|
LinearLayout keyRow = terminalKeyRow();
|
|
|
|
|
addAccessoryPageKeys(keyRow);
|
|
|
|
|
keyScroller.addView(keyRow, new HorizontalScrollView.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
|
|
));
|
|
|
|
|
return scroller;
|
|
|
|
|
panel.addView(keyScroller, new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
|
|
));
|
|
|
|
|
return panel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LinearLayout terminalKeyRow() {
|
|
|
|
@@ -2699,35 +2749,68 @@ public final class MainActivity extends Activity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addAccessoryPageKeys(LinearLayout row) {
|
|
|
|
|
addAccessoryButton(row, "ctrl", view -> sendTerminalInput("\u0002"));
|
|
|
|
|
addSoftKey(row, "esc", "\u001b");
|
|
|
|
|
addSoftKey(row, "tab", "\t");
|
|
|
|
|
addTextKey(row, "~", "~");
|
|
|
|
|
addTextKey(row, "/", "/");
|
|
|
|
|
addTextKey(row, "-", "-");
|
|
|
|
|
addTextKey(row, "|", "|");
|
|
|
|
|
addSoftKey(row, "C-c", "\u0003");
|
|
|
|
|
addSoftKey(row, "C-d", "\u0004");
|
|
|
|
|
addSoftKey(row, "C-z", "\u001a");
|
|
|
|
|
addSoftKey(row, "C-l", "\u000c");
|
|
|
|
|
addComposerButton(row, "←", () -> moveComposerCursor(-1));
|
|
|
|
|
addComposerButton(row, "→", () -> moveComposerCursor(1));
|
|
|
|
|
addSoftKey(row, "↑", "\u001b[A");
|
|
|
|
|
addSoftKey(row, "↓", "\u001b[B");
|
|
|
|
|
addSoftButton(row, "Paste", view -> pasteClipboard());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String accessoryPageName() {
|
|
|
|
|
switch (terminalKeyPage) {
|
|
|
|
|
case 1:
|
|
|
|
|
return "CTRL";
|
|
|
|
|
addSoftKey(row, "Esc", "\u001b");
|
|
|
|
|
addSoftKey(row, "Tab", "\t");
|
|
|
|
|
addSoftKey(row, "C-c", "\u0003");
|
|
|
|
|
addSoftKey(row, "C-d", "\u0004");
|
|
|
|
|
addSoftKey(row, "C-z", "\u001a");
|
|
|
|
|
addSoftKey(row, "C-l", "\u000c");
|
|
|
|
|
addSoftKey(row, "C-r", "\u0012");
|
|
|
|
|
addSoftKey(row, "C-a", "\u0001");
|
|
|
|
|
addSoftKey(row, "C-e", "\u0005");
|
|
|
|
|
addSoftKey(row, "C-u", "\u0015");
|
|
|
|
|
addSoftKey(row, "C-k", "\u000b");
|
|
|
|
|
addSoftKey(row, "C-b", "\u0002");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
return "NAV";
|
|
|
|
|
addSoftKey(row, "←", "\u001b[D");
|
|
|
|
|
addSoftKey(row, "→", "\u001b[C");
|
|
|
|
|
addSoftKey(row, "↑", "\u001b[A");
|
|
|
|
|
addSoftKey(row, "↓", "\u001b[B");
|
|
|
|
|
addSoftKey(row, "Home", "\u001b[H");
|
|
|
|
|
addSoftKey(row, "End", "\u001b[F");
|
|
|
|
|
addSoftKey(row, "Pg↑", "\u001b[5~");
|
|
|
|
|
addSoftKey(row, "Pg↓", "\u001b[6~");
|
|
|
|
|
addSoftKey(row, "Clear", "\u000c");
|
|
|
|
|
addSoftKey(row, "Detach", "\u0002d");
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
return "SYM";
|
|
|
|
|
addTextKey(row, "~", "~");
|
|
|
|
|
addTextKey(row, "/", "/");
|
|
|
|
|
addTextKey(row, "-", "-");
|
|
|
|
|
addTextKey(row, "_", "_");
|
|
|
|
|
addTextKey(row, ".", ".");
|
|
|
|
|
addTextKey(row, "|", "|");
|
|
|
|
|
addTextKey(row, "&", "&");
|
|
|
|
|
addTextKey(row, ";", ";");
|
|
|
|
|
addTextKey(row, "$", "$");
|
|
|
|
|
addTextKey(row, "\"", "\"");
|
|
|
|
|
addTextKey(row, "'", "'");
|
|
|
|
|
addTextKey(row, "Space", " ");
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
default:
|
|
|
|
|
return "EDIT";
|
|
|
|
|
addComposerButton(row, "←", () -> moveComposerCursor(-1));
|
|
|
|
|
addComposerButton(row, "→", () -> moveComposerCursor(1));
|
|
|
|
|
addSoftKey(row, "↑", "\u001b[A");
|
|
|
|
|
addSoftKey(row, "↓", "\u001b[B");
|
|
|
|
|
addSoftKey(row, "Esc", "\u001b");
|
|
|
|
|
addSoftKey(row, "Tab", "\t");
|
|
|
|
|
addSoftKey(row, "↵", TERMINAL_ENTER);
|
|
|
|
|
addSoftButton(row, "Paste", view -> pasteClipboard());
|
|
|
|
|
addComposerButton(row, "⌫", this::backspaceComposerText);
|
|
|
|
|
addTextKey(row, "NL", "\n");
|
|
|
|
|
addComposerButton(row, "Bot", this::scrollTerminalBottom);
|
|
|
|
|
addComposerButton(row, "Sel", () -> {
|
|
|
|
|
terminalSelectionEnabled = !terminalSelectionEnabled;
|
|
|
|
|
if (terminalText != null) {
|
|
|
|
|
terminalText.setTextIsSelectable(terminalSelectionEnabled);
|
|
|
|
|
}
|
|
|
|
|
setStatus(terminalSelectionEnabled ? "Terminal selection on" : "Terminal selection off");
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2997,19 +3080,20 @@ public final class MainActivity extends Activity {
|
|
|
|
|
|
|
|
|
|
private void setTerminalKeyPage(int page) {
|
|
|
|
|
terminalKeyPage = (page + 4) % 4;
|
|
|
|
|
updateTerminalPageButton();
|
|
|
|
|
updateAccessoryTabs();
|
|
|
|
|
if (activeSessionName != null) {
|
|
|
|
|
renderTerminalControlsOnly();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void renderTerminalControlsOnly() {
|
|
|
|
|
int composerIndex = terminalComposerBar == null ? -1 : root.indexOfChild(terminalComposerBar);
|
|
|
|
|
if (composerIndex < 0 || composerIndex + 1 >= root.getChildCount()) {
|
|
|
|
|
int accessoryIndex = terminalAccessoryBar == null ? -1 : root.indexOfChild(terminalAccessoryBar);
|
|
|
|
|
if (accessoryIndex < 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
root.removeViewAt(composerIndex + 1);
|
|
|
|
|
root.addView(createAccessoryBar(), composerIndex + 1, new LinearLayout.LayoutParams(
|
|
|
|
|
root.removeViewAt(accessoryIndex);
|
|
|
|
|
terminalAccessoryBar = createAccessoryBar();
|
|
|
|
|
root.addView(terminalAccessoryBar, accessoryIndex, new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
dp(TERMINAL_KEYS_HEIGHT_DP)
|
|
|
|
|
));
|
|
|
|
@@ -3162,29 +3246,23 @@ public final class MainActivity extends Activity {
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Button terminalPageButton() {
|
|
|
|
|
Button button = toolbarButton("", view -> setTerminalKeyPage(terminalKeyPage + 1));
|
|
|
|
|
button.setTextSize(9);
|
|
|
|
|
button.setPadding(dp(4), 0, dp(4), 0);
|
|
|
|
|
button.setMinWidth(dp(42));
|
|
|
|
|
button.setMinimumWidth(dp(42));
|
|
|
|
|
button.setOnLongClickListener(view -> {
|
|
|
|
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
|
|
|
|
setTerminalKeyPage(terminalKeyPage - 1);
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
updateTerminalPageButton(button);
|
|
|
|
|
private Button composerButton(String label, View.OnClickListener listener) {
|
|
|
|
|
Button button = toolbarButton(label, listener);
|
|
|
|
|
button.setTextSize(10);
|
|
|
|
|
button.setPadding(dp(5), 0, dp(5), 0);
|
|
|
|
|
button.setMinWidth(dp(38));
|
|
|
|
|
button.setMinimumWidth(dp(38));
|
|
|
|
|
button.setMinHeight(0);
|
|
|
|
|
button.setMinimumHeight(0);
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateTerminalPageButton() {
|
|
|
|
|
updateTerminalPageButton(terminalKeyPageButton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateTerminalPageButton(Button button) {
|
|
|
|
|
if (button != null) {
|
|
|
|
|
button.setText(accessoryPageName());
|
|
|
|
|
}
|
|
|
|
|
private Button composerPrimaryButton(String label, View.OnClickListener listener) {
|
|
|
|
|
Button button = composerButton(label, listener);
|
|
|
|
|
button.setTextColor(Color.rgb(14, 38, 24));
|
|
|
|
|
button.setTextSize(11);
|
|
|
|
|
button.setBackground(rounded(COLOR_ACCENT, 7, COLOR_ACCENT, 1));
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void styleInput(EditText input) {
|
|
|
|
@@ -3199,8 +3277,8 @@ public final class MainActivity extends Activity {
|
|
|
|
|
private void styleComposerInput(EditText input) {
|
|
|
|
|
input.setTextColor(COLOR_TEXT);
|
|
|
|
|
input.setHintTextColor(COLOR_TEXT_DIM);
|
|
|
|
|
input.setTextSize(14);
|
|
|
|
|
input.setPadding(dp(9), dp(6), dp(9), dp(6));
|
|
|
|
|
input.setTextSize(13);
|
|
|
|
|
input.setPadding(dp(8), dp(5), dp(8), dp(5));
|
|
|
|
|
input.setBackground(inputBackground());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -3252,32 +3330,64 @@ public final class MainActivity extends Activity {
|
|
|
|
|
addSoftButton(row, label, view -> insertComposerText(text));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addAccessoryButton(LinearLayout row, String label, View.OnClickListener listener) {
|
|
|
|
|
addSoftButton(row, label, listener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addComposerButton(LinearLayout row, String label, Runnable action) {
|
|
|
|
|
addSoftButton(row, label, view -> action.run());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addSoftButton(LinearLayout row, String label, View.OnClickListener listener) {
|
|
|
|
|
Button button = toolbarButton(label, listener);
|
|
|
|
|
button.setTextSize(isArrowLabel(label) ? 15 : 9);
|
|
|
|
|
button.setPadding(dp(4), 0, dp(4), 0);
|
|
|
|
|
int width = "Space".equals(label) ? 56 : (isArrowLabel(label) ? 32 : 38);
|
|
|
|
|
button.setMinWidth(dp(width));
|
|
|
|
|
button.setMinimumWidth(dp(width));
|
|
|
|
|
button.setTextSize(isArrowLabel(label) ? 14 : 9);
|
|
|
|
|
button.setPadding(dp(2), 0, dp(2), 0);
|
|
|
|
|
button.setMinWidth(dp(24));
|
|
|
|
|
button.setMinimumWidth(dp(24));
|
|
|
|
|
button.setMinHeight(0);
|
|
|
|
|
button.setMinimumHeight(0);
|
|
|
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
|
|
dp(27)
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
0
|
|
|
|
|
);
|
|
|
|
|
params.leftMargin = dp(1);
|
|
|
|
|
params.rightMargin = dp(1);
|
|
|
|
|
params.topMargin = dp(2);
|
|
|
|
|
params.bottomMargin = dp(1);
|
|
|
|
|
row.addView(button, params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addAccessoryTab(LinearLayout row, String label, int page) {
|
|
|
|
|
Button button = toolbarButton(label, view -> setTerminalKeyPage(page));
|
|
|
|
|
button.setTextSize(8);
|
|
|
|
|
button.setPadding(dp(3), 0, dp(3), 0);
|
|
|
|
|
button.setMinWidth(0);
|
|
|
|
|
button.setMinimumWidth(0);
|
|
|
|
|
button.setMinHeight(0);
|
|
|
|
|
button.setMinimumHeight(0);
|
|
|
|
|
terminalAccessoryTabButtons[page] = button;
|
|
|
|
|
styleAccessoryTab(button, terminalKeyPage == page);
|
|
|
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
|
|
|
|
0,
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
|
1
|
|
|
|
|
);
|
|
|
|
|
if (row.getChildCount() > 0) {
|
|
|
|
|
params.leftMargin = dp(3);
|
|
|
|
|
}
|
|
|
|
|
row.addView(button, params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateAccessoryTabs() {
|
|
|
|
|
for (int page = 0; page < terminalAccessoryTabButtons.length; page++) {
|
|
|
|
|
Button button = terminalAccessoryTabButtons[page];
|
|
|
|
|
if (button != null) {
|
|
|
|
|
styleAccessoryTab(button, terminalKeyPage == page);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void styleAccessoryTab(Button button, boolean selected) {
|
|
|
|
|
button.setTextColor(selected ? Color.rgb(14, 38, 24) : COLOR_TEXT_MUTED);
|
|
|
|
|
button.setBackground(selected
|
|
|
|
|
? rounded(COLOR_ACCENT, 6, COLOR_ACCENT, 1)
|
|
|
|
|
: rounded(COLOR_CARD_ALT, 6, COLOR_BORDER_SOFT, 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isArrowLabel(String label) {
|
|
|
|
|
return "←".equals(label) || "→".equals(label) || "↑".equals(label) || "↓".equals(label);
|
|
|
|
|
}
|
|
|
|
|