From a8d186aa57ae7de823b9e876d1a025ea5fe6d3d6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 18 Aug 2016 21:28:55 +0200 Subject: [PATCH] lets allow any launcher name --- .../applauncher/adapters/RecyclerAdapter.kt | 10 ++-------- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt index 6c01e32..38bffcf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt @@ -18,7 +18,6 @@ import com.simplemobiletools.applauncher.models.AppLauncher import kotlinx.android.synthetic.main.app_launcher_dialog_item.view.* import kotlinx.android.synthetic.main.edit_launcher.view.* import java.util.* -import java.util.regex.Pattern class RecyclerAdapter(val act: Activity, val launchers: List, val itemClick: (AppLauncher) -> Unit) : RecyclerView.Adapter() { @@ -88,7 +87,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List, val i alertDialog.show() alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { val newName = editView.edit_launcher_edittext.text.toString().trim() - if (isValidName(newName)) { + if (!newName.isEmpty()) { if (DbHelper(act).updateLauncherName(selectedLauncher.id, newName) > 0) { (act as EditLaunchersInterface).launcherRenamed() finishActionMode() @@ -97,7 +96,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List, val i Toast.makeText(act, act.resources.getString(R.string.unknown_error), Toast.LENGTH_SHORT).show() } } else { - Toast.makeText(act, act.resources.getString(R.string.invalid_characters), Toast.LENGTH_SHORT).show() + Toast.makeText(act, act.resources.getString(R.string.enter_launcher_name), Toast.LENGTH_SHORT).show() } } } @@ -106,11 +105,6 @@ class RecyclerAdapter(val act: Activity, val launchers: List, val i actMode?.finish() } - private fun isValidName(newName: String): Boolean { - val pattern = Pattern.compile("[0-9a-zA-Z-_. ]+") - return pattern.matcher(newName).matches() - } - private fun deleteSelectedItems() { val positions = multiSelector.selectedPositions val deleteIds = ArrayList(positions.size) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e57ce1b..e864c57 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5,7 +5,7 @@ Rename launcher OK Cancel - New launcher name contains invalid characters + Please enter a launcher name An unknown error occurred