|
@@ -9,6 +9,7 @@ import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
import android.view.ViewGroup
|
|
|
import android.widget.ImageView
|
|
import android.widget.ImageView
|
|
|
|
|
+import android.widget.LinearLayout
|
|
|
import android.widget.TextView
|
|
import android.widget.TextView
|
|
|
import androidx.lifecycle.LifecycleOwner
|
|
import androidx.lifecycle.LifecycleOwner
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
@@ -114,6 +115,13 @@ class AppDrawerAdapter(
|
|
|
updateFilteredApps()
|
|
updateFilteredApps()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ fun collapseAllFolders() {
|
|
|
|
|
+ if (expandedFolderIds.isNotEmpty()) {
|
|
|
|
|
+ expandedFolderIds.clear()
|
|
|
|
|
+ updateFilteredApps()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private fun buildFolderRows(): List<AppDrawerRow> {
|
|
private fun buildFolderRows(): List<AppDrawerRow> {
|
|
|
val rows = mutableListOf<AppDrawerRow>()
|
|
val rows = mutableListOf<AppDrawerRow>()
|
|
|
for (folder in folders.foldersList) {
|
|
for (folder in folders.foldersList) {
|
|
@@ -147,10 +155,15 @@ class AppDrawerAdapter(
|
|
|
val corePreferences = unlauncherDataSource.corePreferencesRepo.get()
|
|
val corePreferences = unlauncherDataSource.corePreferencesRepo.get()
|
|
|
val showDrawerHeadings = corePreferences.showDrawerHeadings
|
|
val showDrawerHeadings = corePreferences.showDrawerHeadings
|
|
|
val searchAllApps = corePreferences.searchAllAppsInDrawer && filterQuery != ""
|
|
val searchAllApps = corePreferences.searchAllAppsInDrawer && filterQuery != ""
|
|
|
|
|
+ val folderAppKeys = if (filterQuery.isNotEmpty()) {
|
|
|
|
|
+ folders.foldersList.flatMap { folder ->
|
|
|
|
|
+ folder.appsList.map { "${it.packageName}/${it.className}" }
|
|
|
|
|
+ }.toSet()
|
|
|
|
|
+ } else emptySet()
|
|
|
val displayableApps = apps
|
|
val displayableApps = apps
|
|
|
.filter { app ->
|
|
.filter { app ->
|
|
|
- (app.displayInDrawer || searchAllApps) && regex.replace(app.displayName, "")
|
|
|
|
|
- .contains(filterQuery, ignoreCase = true)
|
|
|
|
|
|
|
+ (app.displayInDrawer || searchAllApps || "${app.packageName}/${app.className}" in folderAppKeys) &&
|
|
|
|
|
+ regex.replace(app.displayName, "").contains(filterQuery, ignoreCase = true)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
val includeHeadings = !showDrawerHeadings || filterQuery != ""
|
|
val includeHeadings = !showDrawerHeadings || filterQuery != ""
|
|
@@ -220,6 +233,7 @@ class AppDrawerAdapter(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
inner class FolderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
inner class FolderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
|
|
|
+ private val container: LinearLayout = itemView as LinearLayout
|
|
|
private val name: TextView = itemView.findViewById(R.id.folder_item_name)
|
|
private val name: TextView = itemView.findViewById(R.id.folder_item_name)
|
|
|
private val arrowLeft: ImageView = itemView.findViewById(R.id.folder_item_arrow_left)
|
|
private val arrowLeft: ImageView = itemView.findViewById(R.id.folder_item_arrow_left)
|
|
|
private val arrowRight: ImageView = itemView.findViewById(R.id.folder_item_arrow_right)
|
|
private val arrowRight: ImageView = itemView.findViewById(R.id.folder_item_arrow_right)
|
|
@@ -228,25 +242,36 @@ class AppDrawerAdapter(
|
|
|
name.text = folder.name
|
|
name.text = folder.name
|
|
|
name.gravity = gravity
|
|
name.gravity = gravity
|
|
|
|
|
|
|
|
|
|
+ val nameParams = name.layoutParams as LinearLayout.LayoutParams
|
|
|
val expandedRotation = 0f // points down
|
|
val expandedRotation = 0f // points down
|
|
|
when (gravity) {
|
|
when (gravity) {
|
|
|
Gravity.LEFT, Gravity.START -> {
|
|
Gravity.LEFT, Gravity.START -> {
|
|
|
|
|
+ container.gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ nameParams.weight = 1f
|
|
|
|
|
+ nameParams.width = 0
|
|
|
arrowLeft.visibility = View.VISIBLE
|
|
arrowLeft.visibility = View.VISIBLE
|
|
|
arrowRight.visibility = View.GONE
|
|
arrowRight.visibility = View.GONE
|
|
|
arrowLeft.animate().rotation(if (isExpanded) expandedRotation else -90f).setDuration(200).start()
|
|
arrowLeft.animate().rotation(if (isExpanded) expandedRotation else -90f).setDuration(200).start()
|
|
|
}
|
|
}
|
|
|
Gravity.RIGHT, Gravity.END -> {
|
|
Gravity.RIGHT, Gravity.END -> {
|
|
|
|
|
+ container.gravity = Gravity.CENTER_VERTICAL
|
|
|
|
|
+ nameParams.weight = 1f
|
|
|
|
|
+ nameParams.width = 0
|
|
|
arrowLeft.visibility = View.GONE
|
|
arrowLeft.visibility = View.GONE
|
|
|
arrowRight.visibility = View.VISIBLE
|
|
arrowRight.visibility = View.VISIBLE
|
|
|
arrowRight.animate().rotation(if (isExpanded) expandedRotation else 90f).setDuration(200).start()
|
|
arrowRight.animate().rotation(if (isExpanded) expandedRotation else 90f).setDuration(200).start()
|
|
|
}
|
|
}
|
|
|
else -> { // CENTER_HORIZONTAL (1)
|
|
else -> { // CENTER_HORIZONTAL (1)
|
|
|
|
|
+ container.gravity = Gravity.CENTER
|
|
|
|
|
+ nameParams.weight = 0f
|
|
|
|
|
+ nameParams.width = LinearLayout.LayoutParams.WRAP_CONTENT
|
|
|
arrowLeft.visibility = View.VISIBLE
|
|
arrowLeft.visibility = View.VISIBLE
|
|
|
arrowRight.visibility = View.VISIBLE
|
|
arrowRight.visibility = View.VISIBLE
|
|
|
arrowLeft.animate().rotation(if (isExpanded) expandedRotation else -90f).setDuration(200).start()
|
|
arrowLeft.animate().rotation(if (isExpanded) expandedRotation else -90f).setDuration(200).start()
|
|
|
arrowRight.animate().rotation(if (isExpanded) expandedRotation else 90f).setDuration(200).start()
|
|
arrowRight.animate().rotation(if (isExpanded) expandedRotation else 90f).setDuration(200).start()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ name.layoutParams = nameParams
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -256,13 +281,14 @@ class AppDrawerAdapter(
|
|
|
fun bind(app: UnlauncherApp, gravity: Int, isLastInFolder: Boolean) {
|
|
fun bind(app: UnlauncherApp, gravity: Int, isLastInFolder: Boolean) {
|
|
|
item.text = app.displayName
|
|
item.text = app.displayName
|
|
|
item.gravity = gravity
|
|
item.gravity = gravity
|
|
|
- val indentPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48f, item.resources.displayMetrics).toInt()
|
|
|
|
|
- val bottomPadPx = if (isLastInFolder) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, item.resources.displayMetrics).toInt() else 0
|
|
|
|
|
- val basePad = item.paddingTop
|
|
|
|
|
|
|
+ val res = item.resources
|
|
|
|
|
+ val basePad = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8f, res.displayMetrics).toInt()
|
|
|
|
|
+ val indentPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48f, res.displayMetrics).toInt()
|
|
|
|
|
+ val bottomPadPx = if (isLastInFolder) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24f, res.displayMetrics).toInt() else basePad
|
|
|
when (gravity) {
|
|
when (gravity) {
|
|
|
- Gravity.LEFT, Gravity.START -> item.setPadding(indentPx, basePad, item.paddingRight, bottomPadPx)
|
|
|
|
|
- Gravity.RIGHT, Gravity.END -> item.setPadding(item.paddingLeft, basePad, indentPx, bottomPadPx)
|
|
|
|
|
- else -> item.setPadding(item.paddingLeft, basePad, item.paddingRight, bottomPadPx)
|
|
|
|
|
|
|
+ Gravity.LEFT, Gravity.START -> item.setPadding(indentPx, basePad, basePad, bottomPadPx)
|
|
|
|
|
+ Gravity.RIGHT, Gravity.END -> item.setPadding(basePad, basePad, indentPx, bottomPadPx)
|
|
|
|
|
+ else -> item.setPadding(basePad, basePad, basePad, bottomPadPx)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|