diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/extension/Extensions.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/extension/Extensions.kt index b157b08ce..b347ed5ce 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/extension/Extensions.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/extension/Extensions.kt @@ -1,10 +1,12 @@ package io.casey.musikcube.remote.ui.shared.extension +import android.app.Activity import android.app.SearchManager import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.content.res.Resources +import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper @@ -397,9 +399,16 @@ fun AppCompatActivity.getColorCompat(resourceId: Int): Int = * */ -fun showKeyboard(context: Context) { +@Suppress("deprecation") +fun showKeyboard(context: Activity) { val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY) + if (Build.VERSION.SDK_INT >= 31) { + val view = context.currentFocus ?: context.findViewById(android.R.id.content) + imm.showSoftInput(view , 0) + } + else { + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY) + } } fun hideKeyboard(context: Context, view: View) { @@ -413,10 +422,10 @@ fun AppCompatActivity.hideKeyboard(view: View? = null) { } fun DialogFragment.showKeyboard() = - showKeyboard(activity!!) + showKeyboard(requireActivity()) fun DialogFragment.hideKeyboard() { - val fragmentActivity = activity!! /* keep it in the closure so it doesn't get gc'd */ + val fragmentActivity = requireActivity() /* keep it in the closure so it doesn't get gc'd */ Handler(Looper.getMainLooper()).postDelayed({ hideKeyboard( fragmentActivity, diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/util/UpdateCheck.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/util/UpdateCheck.kt index a6690c1ea..d302eeba9 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/util/UpdateCheck.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/util/UpdateCheck.kt @@ -3,8 +3,8 @@ package io.casey.musikcube.remote.ui.shared.util import android.annotation.SuppressLint import android.util.Log import io.casey.musikcube.remote.Application +import io.casey.musikcube.remote.ui.shared.extension.getPackageInfoCompat import io.casey.musikcube.remote.util.Preconditions -import io.casey.musikcube.remote.util.getPackageInfoCompat import io.reactivex.Single import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.schedulers.Schedulers