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 0aef39f..be19839 100644 --- a/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.applauncher.adapters import android.app.Activity +import android.app.AlertDialog import android.support.v7.app.AppCompatActivity import android.support.v7.view.ActionMode import android.support.v7.widget.RecyclerView @@ -14,6 +15,7 @@ import com.simplemobiletools.applauncher.extensions.hide import com.simplemobiletools.applauncher.extensions.show 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.* class RecyclerAdapter(val act: Activity, val launchers: List, val itemClick: (AppLauncher) -> Unit) : @@ -29,7 +31,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List, val i override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean { when (item?.itemId) { R.id.cab_edit -> { - + showEditDialog() } R.id.cab_delete -> { deleteSelectedItems() @@ -66,6 +68,25 @@ class RecyclerAdapter(val act: Activity, val launchers: List, val i return launchers.count() } + private fun showEditDialog() { + val selectedLauncher = launchers[multiSelector.selectedPositions[0]] + val editView = act.layoutInflater.inflate(R.layout.edit_launcher, null) + editView.edit_launcher_edittext.setText(selectedLauncher.name) + + val builder = AlertDialog.Builder(act) + builder.setTitle(act.getString(R.string.rename_launcher)) + builder.setView(editView) + + builder.setPositiveButton(R.string.ok, null) + builder.setNegativeButton(R.string.cancel, null) + + val alertDialog = builder.create() + alertDialog.show() + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + alertDialog.dismiss() + } + } + private fun deleteSelectedItems() { val positions = multiSelector.selectedPositions val deleteIds = ArrayList(positions.size) diff --git a/app/src/main/res/layout/edit_launcher.xml b/app/src/main/res/layout/edit_launcher.xml new file mode 100644 index 0000000..63ff1d4 --- /dev/null +++ b/app/src/main/res/layout/edit_launcher.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cdf8905..53a80fc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,6 +2,9 @@ Simple App Launcher Delete Edit + Rename launcher + OK + Cancel About