mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-02-07 23:38:54 +01:00
lets allow any launcher name
This commit is contained in:
parent
3fd432f53f
commit
a8d186aa57
@ -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<AppLauncher>, val itemClick: (AppLauncher) -> Unit) :
|
||||
RecyclerView.Adapter<RecyclerAdapter.ViewHolder>() {
|
||||
@ -88,7 +87,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, 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<AppLauncher>, 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<AppLauncher>, 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<String>(positions.size)
|
||||
|
@ -5,7 +5,7 @@
|
||||
<string name="rename_launcher">Rename launcher</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="invalid_characters">New launcher name contains invalid characters</string>
|
||||
<string name="enter_launcher_name">Please enter a launcher name</string>
|
||||
<string name="unknown_error">An unknown error occurred</string>
|
||||
|
||||
<!-- About -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user