diff --git a/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java b/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java index d59f5dba21..c6a042f576 100644 --- a/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java +++ b/app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java @@ -75,6 +75,10 @@ public TermuxTerminalViewClient(TermuxActivity activity, TermuxTerminalSessionCl this.mTermuxTerminalSessionClient = termuxTerminalSessionClient; } + public TermuxActivity getActivity() { + return mActivity; + } + /** * Should be called when mActivity.onCreate() is called */ diff --git a/app/src/main/java/com/termux/app/terminal/io/TermuxTerminalExtraKeys.java b/app/src/main/java/com/termux/app/terminal/io/TermuxTerminalExtraKeys.java index 483e6c0f2e..8eed51797b 100644 --- a/app/src/main/java/com/termux/app/terminal/io/TermuxTerminalExtraKeys.java +++ b/app/src/main/java/com/termux/app/terminal/io/TermuxTerminalExtraKeys.java @@ -7,7 +7,6 @@ import androidx.annotation.NonNull; import androidx.drawerlayout.widget.DrawerLayout; -import com.termux.R; import com.termux.app.terminal.TermuxTerminalSessionClient; import com.termux.app.terminal.TermuxTerminalViewClient; import com.termux.shared.terminal.io.TerminalExtraKeys; @@ -34,8 +33,11 @@ public void onTerminalExtraKeyButtonClick(View view, String key, boolean ctrlDow if(mTermuxTerminalViewClient != null) mTermuxTerminalViewClient.onToggleSoftKeyboardRequest(); } else if ("DRAWER".equals(key)) { - DrawerLayout drawer = view.findViewById(R.id.drawer_layout); - drawer.openDrawer(Gravity.LEFT); + DrawerLayout drawerLayout = mTermuxTerminalViewClient.getActivity().getDrawer(); + if (drawerLayout.isDrawerOpen(Gravity.LEFT)) + drawerLayout.closeDrawer(Gravity.LEFT); + else + drawerLayout.openDrawer(Gravity.LEFT); } else if ("PASTE".equals(key)) { if(mTermuxTerminalSessionClient != null) mTermuxTerminalSessionClient.onPasteTextFromClipboard(null);