Merge pull request #12 from alrajdev/empty_string_rename

Don't allow empty name in app rename
This commit is contained in:
ottop 2024-11-02 02:36:14 +02:00 committed by GitHub
commit 103c8692f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 0 deletions

View file

@ -15,6 +15,7 @@ import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.widget.AppCompatButton
import androidx.core.view.ViewCompat
import androidx.lifecycle.lifecycleScope
@ -157,6 +158,10 @@ class AppActionMenu(private val activity: MainActivity, private val binding: Act
// Once the new name is confirmed, close the keyboard, save the new app name and update the apps on screen
if (actionId == EditorInfo.IME_ACTION_DONE) {
if (editText.text.isNullOrBlank()) {
Toast.makeText(activity, activity.getString(R.string.empty_rename), Toast.LENGTH_SHORT).show()
return@setOnEditorActionListener true
}
val imm =
activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(editText.windowToken, 0)

View file

@ -33,6 +33,7 @@
<string name="launch_error">Sovelluksen avaaminen epäonnistui</string>
<!--Action Menu Items-->
<string name="empty_rename">Tyhjää sovelluksen nimeä ei voi määrittää</string>
<string name="info">Tiedot</string>
<string name="uninstall">Poista</string>
<string name="rename">Nimeä</string>

View file

@ -33,6 +33,8 @@
<string name="launch_error">Cannot launch app</string>
<string name="empty_rename">Cannot set empty app name</string>
<!--Action Menu Items-->
<string name="info">Info</string>
<string name="uninstall">Uninstall</string>