Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus improvements #63

Merged
merged 2 commits into from
Jan 18, 2025
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
8 changes: 4 additions & 4 deletions termux-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -164,11 +164,11 @@ tasks {

task("downloadPrebuilt") {
doLast {
val bootstrapVersion = "2025.01.15-r1"
val bootstrapVersion = "2025.01.18-r1"
val arches = mapOf(
"aarch64" to "3a2471d6fa0b4271e688c95ef196b7345948847138732c813fb0cdb950ccc022",
"arm" to "7005424285073d8f6462f07a701c10670faad9d2c0a1dacfc1b650467e5685ff",
"x86_64" to "9baa587b0973dfd0ed48b4b3d8aa74196494a74da4f3a518501c56abd4d49cc8"
"aarch64" to "ce08316c5ab0610551c6b4a2c0d256073c0f47ec5d72a94f3895e3bd911f7aff",
"arm" to "ee54ef84c34da2084d388ee4132de357f8d514467339b69d56d78bbab0d0eb04",
"x86_64" to "dfc6d9d7e5b8dee126ab95a8fc528b53e4044588c3f5eacf428fe1e0aa0bf4e3"
)
arches.forEach { (arch, checksum) ->
val downloadTo = "src/main/cpp/bootstrap-${arch}.zip"
12 changes: 12 additions & 0 deletions termux-app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
@@ -243,6 +243,18 @@ public void handleOnBackPressed() {
TermuxFullscreen.updatePadding(this, insets);
return insets;
});

getDrawer().addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
@Override
public void onDrawerOpened(@NonNull View drawerView) {
findViewById(R.id.terminal_sessions_list).requestFocus();
}

@Override
public void onDrawerClosed(@NonNull View drawerView) {
mTerminalView.requestFocus();
}
});
}

@Override
Original file line number Diff line number Diff line change
@@ -468,6 +468,9 @@ public void checkAndScrollToSession(TerminalSession session) {
// TODO: Can this be null? if (termuxSessionsListView == null) return;

termuxSessionsListView.setItemChecked(indexOfSession, true);
termuxSessionsListView.setSelection(indexOfSession);
termuxSessionListNotifyUpdated();

// Delay is necessary otherwise sometimes scroll to newly added session does not happen
termuxSessionsListView.postDelayed(() -> termuxSessionsListView.smoothScrollToPosition(indexOfSession), 1000);
}
Original file line number Diff line number Diff line change
@@ -103,7 +103,10 @@ public boolean onKeyDown(int keyCode, KeyEvent e, TerminalSession currentSession
return true;
}

if (keyCode == KeyEvent.KEYCODE_ENTER && !currentSession.isRunning()) {
if (e.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
onToggleSoftKeyboardRequest();
return true;
} else if (keyCode == KeyEvent.KEYCODE_ENTER && !currentSession.isRunning()) {
mTermuxTerminalSessionActivityClient.removeFinishedSession(currentSession);
return true;
} else if (e.isCtrlPressed() && e.isAltPressed()) {
4 changes: 4 additions & 0 deletions termux-app/src/main/res/drawable/selected_session.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#A0A0A0" />
</shape>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@drawable/selected_session"/>
<item android:state_activated="true" android:drawable="@drawable/current_session"/>
<item android:state_activated="false" android:drawable="@drawable/session_ripple"/>
</selector>
</selector>
15 changes: 12 additions & 3 deletions termux-app/src/main/res/layout/activity_termux.xml
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_layout"

android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/terminal_toolbar_view_pager"
@@ -33,7 +34,6 @@
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical"
android:background="?attr/termuxActivityDrawerBackground">

@@ -44,7 +44,11 @@
android:layout_gravity="top"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:longClickable="true" />
android:longClickable="true"
android:nextFocusUp="@id/terminal_sessions_list"
android:nextFocusRight="@id/terminal_sessions_list"
android:nextFocusLeft="@id/terminal_sessions_list"
/>

<LinearLayout
android:layout_width="match_parent"
@@ -63,7 +67,10 @@
app:iconPadding="0dp"
app:iconGravity="textStart"
app:iconTint="@color/black"
app:icon="@drawable/icon_keyboard" />
app:icon="@drawable/icon_keyboard"
android:nextFocusLeft="@id/toggle_keyboard_button"
android:nextFocusDown="@id/toggle_keyboard_button"
/>

<com.google.android.material.button.MaterialButton
android:id="@+id/new_session_button"
@@ -78,6 +85,8 @@
app:iconGravity="textStart"
app:iconTint="@color/black"
app:icon="@drawable/icon_add"
android:nextFocusDown="@id/new_session_button"
android:nextFocusRight="@id/new_session_button"
/>
</LinearLayout>
</LinearLayout>