fix(terminal): cancel last toast when TermuxActivity is destroyed

This commit is contained in:
Akash Yadav
2023-11-13 18:23:01 +05:30
parent b03f708534
commit 0c18890930
2 changed files with 6 additions and 5 deletions
@@ -333,7 +333,11 @@ public class TermuxActivity extends BaseIDEActivity implements ServiceConnection
if (mIsInvalidState) return;
this.binding = null;
this.mLastToast = null;
if (mLastToast != null) {
mLastToast.cancel();
}
mLastToast = null;
if (mTermuxService != null) {
// Do not leave service and session clients with references to activity.
@@ -580,9 +584,7 @@ public class TermuxActivity extends BaseIDEActivity implements ServiceConnection
@SuppressLint("RtlHardcoded")
@Override
public void onBackPressed() {
if (KeyboardUtils.isSoftKeyboardVisible(this)) {
KeyboardUtils.showSoftKeyboard(this, getTerminalView());
} else if (getDrawer().isDrawerOpen(Gravity.LEFT)) {
if (getDrawer().isDrawerOpen(Gravity.LEFT)) {
getDrawer().closeDrawers();
} else {
finishActivityIfNotFinishing();
@@ -120,7 +120,6 @@ public class KeyboardUtils {
* @param activity The Activity of the root view for which the visibility should be checked.
* @return Returns {@code true} if soft keyboard is visible, otherwise {@code false}.
*/
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean isSoftKeyboardVisible(final Activity activity) {
if (activity != null && activity.getWindow() != null) {
WindowInsets insets = activity.getWindow().getDecorView().getRootWindowInsets();