mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-04-28 16:49:09 +02:00
implement launcher renaming
This commit is contained in:
parent
8a4f190f52
commit
0f2315f39d
@ -115,6 +115,10 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface, Recyc
|
|||||||
remainingLaunchers.sortBy { it.name }
|
remainingLaunchers.sortBy { it.name }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun launcherRenamed() {
|
||||||
|
setupLaunchers()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
preferences.isFirstRun = false
|
preferences.isFirstRun = false
|
||||||
|
@ -85,9 +85,15 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
|||||||
val alertDialog = builder.create()
|
val alertDialog = builder.create()
|
||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val newName = editView.edit_launcher_edittext.text.toString()
|
val newName = editView.edit_launcher_edittext.text.toString().trim()
|
||||||
if (isValidName(newName)) {
|
if (isValidName(newName)) {
|
||||||
|
if (DbHelper(act).updateLauncherName(selectedLauncher.id, newName) > 0) {
|
||||||
|
(act as EditLaunchersInterface).launcherRenamed()
|
||||||
|
actMode?.finish()
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(act, act.resources.getString(R.string.unknown_error), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(act, act.resources.getString(R.string.invalid_characters), Toast.LENGTH_SHORT).show()
|
Toast.makeText(act, act.resources.getString(R.string.invalid_characters), Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
@ -167,5 +173,7 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
|||||||
|
|
||||||
interface EditLaunchersInterface {
|
interface EditLaunchersInterface {
|
||||||
fun launchersDeleted(indexes: List<Int>, deletedLaunchers: List<AppLauncher>)
|
fun launchersDeleted(indexes: List<Int>, deletedLaunchers: List<AppLauncher>)
|
||||||
|
|
||||||
|
fun launcherRenamed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,14 @@ class DbHelper(context: Context) : SQLiteOpenHelper(context, "launchers.db", nul
|
|||||||
writableDatabase.delete(TABLE, "$ID IN ($args)", null)
|
writableDatabase.delete(TABLE, "$ID IN ($args)", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateLauncherName(id: Int, newName: String): Int {
|
||||||
|
val values = ContentValues()
|
||||||
|
values.put(NAME, newName)
|
||||||
|
val selection = ID + " = ?"
|
||||||
|
val selectionArgs = Array(1) { id.toString() }
|
||||||
|
return writableDatabase.update(TABLE, values, selection, selectionArgs)
|
||||||
|
}
|
||||||
|
|
||||||
fun getLaunchers(): ArrayList<AppLauncher> {
|
fun getLaunchers(): ArrayList<AppLauncher> {
|
||||||
val launchers = ArrayList<AppLauncher>()
|
val launchers = ArrayList<AppLauncher>()
|
||||||
val cursor = readableDatabase.query(TABLE, arrayOf(ID, NAME, PKG_NAME, ICON_ID), null, null, null, null, NAME)
|
val cursor = readableDatabase.query(TABLE, arrayOf(ID, NAME, PKG_NAME, ICON_ID), null, null, null, null, NAME)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Cancel</string>
|
<string name="cancel">Cancel</string>
|
||||||
<string name="invalid_characters">New launcher name contains invalid characters</string>
|
<string name="invalid_characters">New launcher name contains invalid characters</string>
|
||||||
|
<string name="unknown_error">An unknown error occurred</string>
|
||||||
|
|
||||||
<!-- About -->
|
<!-- About -->
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user