Repository: NativeScript/NativeScript
File: packages/core/utils/android/index.ts (TypeScript)

Code before:
export function getInputMethodManager(): android.view.inputmethod.InputMethodManager {
	if (!inputMethodManager) {
		inputMethodManager = <android.view.inputmethod.InputMethodManager>getApplicationContext().getSystemService(android.content.Context.INPUT_METHOD_SERVICE);
	}

	return inputMethodManager;
}

export function showSoftInput(nativeView: android.view.View): void {
	const inputManager = getInputMethodManager();
	if (inputManager && nativeView instanceof android.view.View) {
		inputManager.showSoftInput(nativeView, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT);
	}
}

export function dismissSoftInput(nativeView?: android.view.View): void {
	const inputManager = getInputMethodManager();
	let windowToken: android.os.IBinder;

	if (nativeView instanceof android.view.View) {
		if (!nativeView.hasFocus()) {
			return;
		}
		windowToken = nativeView.getWindowToken();
	} else if (getCurrentActivity() instanceof androidx.appcompat.app.AppCompatActivity) {
		const decorView = (topmost().modal?.getClosestWindow() ?? getCurrentActivity().getWindow()).getDecorView();
		if (decorView) {
			windowToken = decorView.getWindowToken();
			decorView.requestFocus();
		} else {
			windowToken = null;
		}
	}

	if (inputManager && windowToken) {
		inputManager.hideSoftInputFromWindow(windowToken, 0);
	}
}

export namespace collections {
	export function stringArrayToStringSet(str: string[]): java.util.HashSet<string> {
		const hashSet = new java.util.HashSet<string>();
		if (str !== undefined) {
			for (const element in str) {
				hashSet.add('' + str[element]);
			}
		}

		return hashSet;
	}


Review comment (suggestion):
```suggestion
		const decorView = (topmost()?.modal?.getClosestWindow() ?? getCurrentActivity().getWindow()).getDecorView();
```

Code after:
export function getInputMethodManager(): android.view.inputmethod.InputMethodManager {
	if (!inputMethodManager) {
		inputMethodManager = <android.view.inputmethod.InputMethodManager>getApplicationContext().getSystemService(android.content.Context.INPUT_METHOD_SERVICE);
	}

	return inputMethodManager;
}

export function showSoftInput(nativeView: android.view.View): void {
	const inputManager = getInputMethodManager();
	if (inputManager && nativeView instanceof android.view.View) {
		inputManager.showSoftInput(nativeView, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT);
	}
}

export function dismissSoftInput(nativeView?: android.view.View): void {
	const inputManager = getInputMethodManager();
	let windowToken: android.os.IBinder;

	if (nativeView instanceof android.view.View) {
		if (!nativeView.hasFocus()) {
			return;
		}
		windowToken = nativeView.getWindowToken();
	} else if (getCurrentActivity() instanceof androidx.appcompat.app.AppCompatActivity) {
		const modalDialog = (topmost()?._modalParent ?? topmost())?.modal?._dialogFragment?.getDialog();
		const window = (modalDialog ?? getCurrentActivity()).getWindow();
		const decorView = window.getDecorView();
		if (decorView) {
			windowToken = decorView.getWindowToken();
			decorView.requestFocus();
		} else {
			windowToken = null;
		}
	}

	if (inputManager && windowToken) {
		inputManager.hideSoftInputFromWindow(windowToken, 0);
	}
}

export namespace collections {
	export function stringArrayToStringSet(str: string[]): java.util.HashSet<string> {
		const hashSet = new java.util.HashSet<string>();
		if (str !== undefined) {
			for (const element in str) {
				hashSet.add('' + str[element]);
			}
		}

		return hashSet;