Skip to content

Commit

Permalink
Support quick launch for all search results
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperDragonXD committed Dec 20, 2024
1 parent d9f030d commit 0c0c25d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,6 @@ import app.lawnchair.search.model.SearchResultActionCallBack
import app.lawnchair.util.copyToClipboard
import com.android.app.search.LayoutType
import com.android.launcher3.R
import com.android.launcher3.touch.ItemClickHandler
import com.android.launcher3.views.BubbleTextHolder

class SearchResultIconRow(context: Context, attrs: AttributeSet?) :
Expand Down Expand Up @@ -69,11 68,11 @@ class SearchResultIconRow(context: Context, attrs: AttributeSet?) :
}
}

override val isQuickLaunch get() = icon.isQuickLaunch
override val titleText get() = icon.titleText
override val isQuickLaunch get() = icon.isQuickLaunch || hasFlag(flags, SearchResultView.FLAG_QUICK_LAUNCH)
override val titleText get() = if (icon.titleText != "") icon.titleText else title.text

override fun launch(): Boolean {
ItemClickHandler.INSTANCE.onClick(this)
performClick()
return true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.AttributeSet
import android.util.Log
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
Expand Down Expand Up @@ -34,6 35,8 @@ class SearchResultRightLeftIcon(context: Context, attrs: AttributeSet?) :
private var defSmsAppInfo: AppInfo? = null
private var isSmall = false

private var flags = 0

override fun onFinishInflate() {
super.onFinishInflate()
isSmall = id == R.id.search_result_small_icon_row_left_right
Expand Down Expand Up @@ -79,11 82,16 @@ class SearchResultRightLeftIcon(context: Context, attrs: AttributeSet?) :
this.layoutParams = layoutParams
}

override val isQuickLaunch: Boolean get() = false
override val isQuickLaunch: Boolean get() = hasFlag(flags, SearchResultView.FLAG_QUICK_LAUNCH)

override val titleText: CharSequence? get() = title.text

override fun launch(): Boolean = false
override fun launch(): Boolean {
val logTag = "Contact or files"
Log.d(logTag, "in launch")
Log.d(logTag, performClick().toString())
return true
}

override fun bind(
target: SearchTargetCompat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 273,6 @@ class SearchTargetFactory(
LayoutType.PEOPLE_TILE,
SearchTargetCompat.RESULT_TYPE_CONTACT_TILE,
CONTACT,
Bundle(),
)
}

Expand Down Expand Up @@ -307,7 306,6 @@ class SearchTargetFactory(
LayoutType.THUMBNAIL,
SearchTargetCompat.RESULT_TYPE_FILE_TILE,
FILES,
Bundle(),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 115,12 @@ sealed class LawnchairSearchAlgorithm(
protected fun setFirstItemQuickLaunch(searchTargets: List<SearchTargetCompat>) {
val hasQuickLaunch = searchTargets.any { it.extras.getBoolean(EXTRA_QUICK_LAUNCH, false) }
if (!hasQuickLaunch) {
searchTargets.firstOrNull()?.extras?.apply {
// check if we have a header or spacer item. if so, we skip as there isn't any relevant
// action to be applied
val target = searchTargets.getOrNull(
searchTargets.indexOfFirst { it.layoutType != TEXT_HEADER },
)
target?.extras?.apply {
putBoolean(EXTRA_QUICK_LAUNCH, true)
}
}
Expand Down

0 comments on commit 0c0c25d

Please sign in to comment.