mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-02-01 09:56:47 +01:00
add ID to launchers
This commit is contained in:
parent
bad094482a
commit
223fcffee9
@ -67,7 +67,7 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface {
|
||||
}
|
||||
|
||||
private fun getNotDisplayedLaunchers(): ArrayList<AppLauncher> {
|
||||
val apps = ArrayList<AppLauncher>()
|
||||
val allApps = ArrayList<AppLauncher>()
|
||||
val intent = Intent(Intent.ACTION_MAIN, null)
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER)
|
||||
val list = packageManager.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED)
|
||||
@ -75,17 +75,17 @@ class MainActivity : SimpleActivity(), AddAppDialog.AddLaunchersInterface {
|
||||
val componentInfo = info.activityInfo.applicationInfo
|
||||
val label = componentInfo.loadLabel(packageManager).toString()
|
||||
val pkgName = componentInfo.packageName
|
||||
apps.add(AppLauncher(label, pkgName, 0))
|
||||
allApps.add(AppLauncher(0, label, pkgName, 0))
|
||||
}
|
||||
|
||||
val sorted = apps.sortedWith(compareBy { it.name.toLowerCase() })
|
||||
val sorted = allApps.sortedWith(compareBy { it.name.toLowerCase() })
|
||||
val unique = sorted.distinctBy { it.pkgName }
|
||||
val filtered = unique.filter { !launchers.contains(it) }
|
||||
return filtered as ArrayList<AppLauncher>
|
||||
}
|
||||
|
||||
override fun selectedLaunchers(launchers: ArrayList<AppLauncher>) {
|
||||
for ((name, pkgName) in launchers) {
|
||||
for ((id, name, pkgName) in launchers) {
|
||||
dbHelper.addLauncher(name, pkgName)
|
||||
}
|
||||
setupLaunchers()
|
||||
|
@ -25,6 +25,11 @@ class RecyclerAdapter(val act: Activity, val launchers: List<AppLauncher>, val i
|
||||
|
||||
val deleteMode = object : ModalMultiSelectorCallback(multiSelector) {
|
||||
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
|
||||
when (item?.itemId) {
|
||||
R.id.cab_delete -> {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -46,13 +46,14 @@ class DbHelper(context: Context) : SQLiteOpenHelper(context, "launchers.db", nul
|
||||
|
||||
fun getLaunchers(): ArrayList<AppLauncher> {
|
||||
val launchers = ArrayList<AppLauncher>()
|
||||
val cursor = readableDatabase.query(TABLE, arrayOf(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)
|
||||
try {
|
||||
while (cursor.moveToNext()) {
|
||||
val id = cursor.getInt(cursor.getColumnIndex(DbHelper.ID))
|
||||
val name = cursor.getString(cursor.getColumnIndex(DbHelper.NAME))
|
||||
val pkgName = cursor.getString(cursor.getColumnIndex(DbHelper.PKG_NAME))
|
||||
val icon = cursor.getInt(cursor.getColumnIndex(DbHelper.ICON_ID))
|
||||
launchers.add(AppLauncher(name, pkgName, icon))
|
||||
launchers.add(AppLauncher(id, name, pkgName, icon))
|
||||
}
|
||||
} finally {
|
||||
cursor.close()
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.simplemobiletools.applauncher.models
|
||||
|
||||
data class AppLauncher(val name: String, val pkgName: String, val iconId: Int, var isChecked: Boolean = false) {
|
||||
data class AppLauncher(val id: Int, val name: String, val pkgName: String, val iconId: Int, var isChecked: Boolean = false) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return pkgName.equals((other as AppLauncher).pkgName)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user