mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-03-05 20:07:49 +01:00
use the real app icons
This commit is contained in:
parent
a876ac9970
commit
ac3492880d
app/src/main/kotlin/com/simplemobiletools/applauncher
@ -24,9 +24,9 @@ class MyCursorAdapter(cxt: Context, dataCursor: Cursor, val itemClick: (AppLaunc
|
||||
cursor.moveToPosition(position)
|
||||
val name = cursor.getString(cursor.getColumnIndex(DbHelper.NAME))
|
||||
val pkgName = cursor.getString(cursor.getColumnIndex(DbHelper.PKG_NAME))
|
||||
val icon = context.resources.getDrawable(R.mipmap.launcher)
|
||||
val icon = cursor.getInt(cursor.getColumnIndex(DbHelper.ICON_ID))
|
||||
val launcher = AppLauncher(name, icon, pkgName)
|
||||
holder.bindView(launcher)
|
||||
holder.bindView(context, launcher)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
@ -34,10 +34,10 @@ class MyCursorAdapter(cxt: Context, dataCursor: Cursor, val itemClick: (AppLaunc
|
||||
}
|
||||
|
||||
class ViewHolder(view: View, val itemClick: (AppLauncher) -> Unit) : RecyclerView.ViewHolder(view) {
|
||||
fun bindView(launcher: AppLauncher) {
|
||||
fun bindView(context: Context, launcher: AppLauncher) {
|
||||
with(launcher) {
|
||||
itemView.launcher_label.text = launcher.name
|
||||
itemView.launcher_icon.setImageDrawable(launcher.icon)
|
||||
itemView.launcher_icon.setImageDrawable(context.resources.getDrawable(launcher.icon))
|
||||
itemView.setOnClickListener { itemClick(this) }
|
||||
}
|
||||
}
|
||||
|
@ -5,42 +5,46 @@ import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.database.sqlite.SQLiteDatabase
|
||||
import android.database.sqlite.SQLiteOpenHelper
|
||||
import com.simplemobiletools.applauncher.R
|
||||
|
||||
class DbHelper(context: Context) : SQLiteOpenHelper(context, "launchers.db", null, 1) {
|
||||
val TABLE = "launchers"
|
||||
val CREATE_DB = "CREATE TABLE $TABLE (" +
|
||||
"$ID integer PRIMARY KEY autoincrement," +
|
||||
"$ID INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||
"$NAME TEXT," +
|
||||
"$PKG_NAME TEXT UNIQUE" +
|
||||
"$PKG_NAME TEXT UNIQUE," +
|
||||
"$ICON_ID INTEGER " +
|
||||
")"
|
||||
|
||||
companion object {
|
||||
val ID: String = "_id"
|
||||
val NAME: String = "name"
|
||||
val PKG_NAME: String = "pkgName"
|
||||
val ICON_ID: String = "icon"
|
||||
}
|
||||
|
||||
fun addInitialLaunchers(db:SQLiteDatabase) {
|
||||
addLauncher("Simple Calculator", "com.simplemobiletools.calculator", db)
|
||||
addLauncher("Simple Calendar", "com.simplemobiletools.calendar", db)
|
||||
addLauncher("Simple Camera", "com.simplemobiletools.camera", db)
|
||||
addLauncher("Simple Draw", "com.simplemobiletools.draw", db)
|
||||
addLauncher("Simple File Manager", "com.simplemobiletools.filemanager", db)
|
||||
addLauncher("Simple Flashlight", "com.simplemobiletools.flashlight", db)
|
||||
addLauncher("Simple Gallery", "com.simplemobiletools.gallery", db)
|
||||
addLauncher("Simple Music Player", "com.simplemobiletools.musicplayer", db)
|
||||
addLauncher("Simple Notes", "com.simplemobiletools.notes", db)
|
||||
fun addInitialLaunchers(db: SQLiteDatabase) {
|
||||
addLauncher("Simple Calculator", "com.simplemobiletools.calculator", R.mipmap.calculator, db)
|
||||
addLauncher("Simple Calendar", "com.simplemobiletools.calendar", R.mipmap.calendar, db)
|
||||
addLauncher("Simple Camera", "com.simplemobiletools.camera", R.mipmap.camera, db)
|
||||
addLauncher("Simple Draw", "com.simplemobiletools.draw", R.mipmap.draw, db)
|
||||
addLauncher("Simple File Manager", "com.simplemobiletools.filemanager", R.mipmap.filemanager, db)
|
||||
addLauncher("Simple Flashlight", "com.simplemobiletools.flashlight", R.mipmap.flashlight, db)
|
||||
addLauncher("Simple Gallery", "com.simplemobiletools.gallery", R.mipmap.gallery, db)
|
||||
addLauncher("Simple Music Player", "com.simplemobiletools.musicplayer", R.mipmap.musicplayer, db)
|
||||
addLauncher("Simple Notes", "com.simplemobiletools.notes", R.mipmap.notes, db)
|
||||
}
|
||||
|
||||
fun addLauncher(name: String, pkgName: String, db: SQLiteDatabase = writableDatabase) {
|
||||
fun addLauncher(name: String, pkgName: String, iconId: Int, db: SQLiteDatabase = writableDatabase) {
|
||||
val contentValues = ContentValues()
|
||||
contentValues.put(NAME, name)
|
||||
contentValues.put(PKG_NAME, pkgName)
|
||||
contentValues.put(ICON_ID, iconId)
|
||||
db.insert(TABLE, null, contentValues)
|
||||
}
|
||||
|
||||
fun getLaunchers(): Cursor {
|
||||
return readableDatabase.query(TABLE, arrayOf(NAME, PKG_NAME), null, null, null, null, NAME)
|
||||
return readableDatabase.query(TABLE, arrayOf(NAME, PKG_NAME, ICON_ID), null, null, null, null, NAME)
|
||||
}
|
||||
|
||||
override fun onCreate(db: SQLiteDatabase) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
package com.simplemobiletools.applauncher.models
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
|
||||
data class AppLauncher(val name: String, val icon: Drawable, val pkgName: String) {}
|
||||
data class AppLauncher(val name: String, val icon: Int, val pkgName: String)
|
||||
|
Loading…
x
Reference in New Issue
Block a user