2024-11-26 08:38:12 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2024 Meshtastic LLC
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-09-04 22:52:40 -03:00
|
|
|
package com.geeksville.mesh.android
|
|
|
|
|
|
|
|
|
|
import android.app.Activity
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.view.inputmethod.InputMethodManager
|
|
|
|
|
import android.widget.Toast
|
|
|
|
|
|
|
|
|
|
/// show a toast
|
|
|
|
|
fun Context.toast(message: CharSequence) =
|
|
|
|
|
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
|
|
|
|
|
|
|
|
|
|
/// Utility function to hide the soft keyboard per stack overflow
|
|
|
|
|
fun Activity.hideKeyboard() {
|
|
|
|
|
// Check if no view has focus:
|
|
|
|
|
currentFocus?.let { v ->
|
|
|
|
|
val imm =
|
|
|
|
|
getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
|
|
|
|
|
imm?.hideSoftInputFromWindow(v.windowToken, 0)
|
|
|
|
|
}
|
|
|
|
|
}
|