From 3896bd8943eae570fc3d3391f34dabe965dce4b9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 12 Nov 2017 17:23:39 +0100 Subject: [PATCH] fetch launcher names in an incasesensitive way --- .../applauncher/adapters/RecyclerAdapter.kt | 8 ++------ .../applauncher/adapters/RecyclerDialogAdapter.kt | 8 ++------ .../com/simplemobiletools/applauncher/helpers/DBHelper.kt | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) 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 8701c8b..873e615 100644 --- a/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerAdapter.kt @@ -1,7 +1,5 @@ package com.simplemobiletools.applauncher.adapters -import android.content.pm.PackageManager -import android.content.res.Resources import android.support.v7.view.ActionMode import android.support.v7.widget.RecyclerView import android.util.SparseArray @@ -34,8 +32,6 @@ class RecyclerAdapter(val activity: SimpleActivity, val launchers: MutableList() private val selectedPositions = HashSet() private var textColor = config.textColor - private var resources = activity.resources - private var packageManager = activity.packageManager fun toggleItemSelection(select: Boolean, pos: Int) { if (select) { @@ -103,7 +99,7 @@ class RecyclerAdapter(val activity: SimpleActivity, val launchers: MutableList (Unit)) : SwappingHolder(view, MultiSelector()) { - fun bindView(launcher: AppLauncher, textColor: Int, resources: Resources, packageManager: PackageManager): View { + fun bindView(launcher: AppLauncher, textColor: Int): View { itemView.apply { launcher_label.text = launcher.name launcher_label.setTextColor(textColor) diff --git a/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerDialogAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerDialogAdapter.kt index f7d0693..02c63de 100644 --- a/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerDialogAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/applauncher/adapters/RecyclerDialogAdapter.kt @@ -1,8 +1,6 @@ package com.simplemobiletools.applauncher.adapters import android.app.Activity -import android.content.pm.PackageManager -import android.content.res.Resources import android.support.v7.widget.RecyclerView import android.util.SparseArray import android.view.LayoutInflater @@ -23,8 +21,6 @@ class RecyclerDialogAdapter(activity: Activity, val launchers: List private var itemViews = SparseArray() private val selectedPositions = HashSet() private var textColor = config.textColor - private var resources = activity.resources - private var packageManager = activity.packageManager fun toggleItemSelection(select: Boolean, pos: Int) { if (select) { @@ -56,7 +52,7 @@ class RecyclerDialogAdapter(activity: Activity, val launchers: List } override fun onBindViewHolder(holder: ViewHolder, position: Int) { - itemViews.put(position, holder.bindView(launchers[position], textColor, resources, packageManager)) + itemViews.put(position, holder.bindView(launchers[position], textColor)) toggleItemSelection(selectedPositions.contains(position), position) } @@ -68,7 +64,7 @@ class RecyclerDialogAdapter(activity: Activity, val launchers: List override fun getItemCount() = launchers.count() class ViewHolder(view: View, val adapterListener: MyAdapterListener) : RecyclerView.ViewHolder(view) { - fun bindView(launcher: AppLauncher, textColor: Int, resources: Resources, packageManager: PackageManager): View { + fun bindView(launcher: AppLauncher, textColor: Int): View { itemView.apply { launcher_label.text = launcher.name launcher_label.setTextColor(textColor) diff --git a/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt index a4509eb..380ba2e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/applauncher/helpers/DBHelper.kt @@ -101,7 +101,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont val packageManager = context.packageManager val launchers = ArrayList() val cols = arrayOf(COL_ID, COL_NAME, COL_PKG_NAME) - val cursor = mDb.query(MAIN_TABLE_NAME, cols, null, null, null, null, COL_NAME) + val cursor = mDb.query(MAIN_TABLE_NAME, cols, null, null, null, null, "$COL_NAME COLLATE NOCASE") cursor.use { while (cursor.moveToNext()) { val id = cursor.getIntValue(COL_ID)