mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
use badged labels in text layout
This commit is contained in:
parent
89bf02fc06
commit
7ee39ba3b8
3 changed files with 22 additions and 11 deletions
|
@ -1,8 +1,6 @@
|
|||
package de.jrpie.android.launcher.preferences.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.DisplayMetrics
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -16,28 +14,30 @@ enum class AppListLayout(
|
|||
val layoutManager: (context: Context) -> RecyclerView.LayoutManager,
|
||||
val layoutResource: Int,
|
||||
val prepareView: (viewHolder: AppsRecyclerAdapter.ViewHolder) -> Unit,
|
||||
val useBadgedText: Boolean
|
||||
|
||||
) {
|
||||
DEFAULT(
|
||||
{ c -> LinearLayoutManager(c) },
|
||||
R.layout.list_apps_row,
|
||||
{ v -> }
|
||||
{ v -> },
|
||||
false
|
||||
),
|
||||
|
||||
// TODO work profile indicator
|
||||
TEXT(
|
||||
{ c -> LinearLayoutManager(c) },
|
||||
R.layout.list_apps_row_variant_text,
|
||||
{ v ->
|
||||
}
|
||||
{ v -> },
|
||||
true
|
||||
),
|
||||
GRID(
|
||||
{ c ->
|
||||
val displayMetrics = c.resources.displayMetrics
|
||||
val width_sp = displayMetrics.widthPixels / displayMetrics.scaledDensity
|
||||
GridLayoutManager(c, (width_sp / 90).toInt()) },
|
||||
val widthSp = displayMetrics.widthPixels / displayMetrics.scaledDensity
|
||||
GridLayoutManager(c, (widthSp / 90).toInt()) },
|
||||
R.layout.list_apps_row_variant_grid,
|
||||
{ v ->
|
||||
}
|
||||
},
|
||||
false
|
||||
),
|
||||
}
|
|
@ -26,6 +26,7 @@ import de.jrpie.android.launcher.apps.AppFilter
|
|||
import de.jrpie.android.launcher.apps.AppInfo
|
||||
import de.jrpie.android.launcher.apps.DetailedAppInfo
|
||||
import de.jrpie.android.launcher.appsList
|
||||
import de.jrpie.android.launcher.getUserFromId
|
||||
import de.jrpie.android.launcher.loadApps
|
||||
import de.jrpie.android.launcher.openAppSettings
|
||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||
|
@ -50,6 +51,7 @@ class AppsRecyclerAdapter(
|
|||
= ListActivity.ListActivityIntention.VIEW,
|
||||
private val forGesture: String? = "",
|
||||
private var appFilter: AppFilter = AppFilter(activity, "")
|
||||
private val layout: AppListLayout
|
||||
) :
|
||||
RecyclerView.Adapter<AppsRecyclerAdapter.ViewHolder>() {
|
||||
|
||||
|
@ -76,7 +78,15 @@ class AppsRecyclerAdapter(
|
|||
|
||||
|
||||
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
||||
val appLabel = appsListDisplayed[i].getCustomLabel(activity).toString()
|
||||
var appLabel = appsListDisplayed[i].label.toString()
|
||||
|
||||
if (layout.useBadgedText) {
|
||||
appLabel = activity.packageManager.getUserBadgedLabel(
|
||||
appLabel,
|
||||
getUserFromId(appsListDisplayed[i].app.user, activity)
|
||||
).toString()
|
||||
}
|
||||
|
||||
val appIcon = appsListDisplayed[i].icon
|
||||
|
||||
viewHolder.textView.text = appLabel
|
||||
|
|
|
@ -70,7 +70,8 @@ class ListFragmentApps : Fragment(), UIObject {
|
|||
"",
|
||||
favoritesVisibility = favoritesVisibility,
|
||||
hiddenVisibility = hiddenVisibility
|
||||
)
|
||||
),
|
||||
layout = LauncherPreferences.list_apps().layout()
|
||||
)
|
||||
|
||||
// set up the list / recycler
|
||||
|
|
Loading…
Add table
Reference in a new issue