mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
Use LayoutType from searchuilib
This commit is contained in:
@@ -264,7 +264,8 @@ dependencies {
|
||||
implementation "androidx.dynamicanimation:dynamicanimation:${ANDROID_X_VERSION}"
|
||||
implementation "androidx.recyclerview:recyclerview:${ANDROID_X_VERSION}"
|
||||
implementation "androidx.preference:preference-ktx:${ANDROID_X_VERSION}"
|
||||
implementation project(':IconLoader')
|
||||
implementation project(':iconloaderlib')
|
||||
implementation project(':searchuilib')
|
||||
implementation fileTree(dir: "${FRAMEWORK_PREBUILTS_DIR}/libs", include: 'sysui_statslog.jar')
|
||||
|
||||
// Recents lib dependency
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.core.util.containsKey
|
||||
import app.lawnchair.LawnchairLauncher
|
||||
import app.lawnchair.allapps.SearchItemDecorator
|
||||
import app.lawnchair.allapps.SearchResultView
|
||||
import com.android.app.search.LayoutType
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.allapps.AllAppsContainerView
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter
|
||||
@@ -68,12 +69,14 @@ class LawnchairSearchAdapterProvider(
|
||||
companion object {
|
||||
private const val SEARCH_RESULT_ICON = (1 shl 8) or AllAppsGridAdapter.VIEW_TYPE_ICON
|
||||
private const val SEARCH_RESULT_ICON_ROW = 1 shl 9
|
||||
const val SEARCH_RESULT_DIVIDER = 1 shl 10
|
||||
const val SEARCH_RESULT_TOP_DIVIDER = (1 shl 11) or SEARCH_RESULT_DIVIDER
|
||||
private const val SEARCH_RESULT_DIVIDER = 1 shl 10
|
||||
private const val SEARCH_RESULT_TOP_DIVIDER = (1 shl 11) or SEARCH_RESULT_DIVIDER
|
||||
|
||||
val viewTypeMap = mapOf(
|
||||
SearchTargetCompat.LAYOUT_TYPE_ICON to SEARCH_RESULT_ICON,
|
||||
SearchTargetCompat.LAYOUT_TYPE_ICON_ROW to SEARCH_RESULT_ICON_ROW,
|
||||
LayoutType.ICON_SINGLE_VERTICAL_TEXT to SEARCH_RESULT_ICON,
|
||||
LayoutType.ICON_HORIZONTAL_TEXT to SEARCH_RESULT_ICON_ROW,
|
||||
LayoutType.DIVIDER to SEARCH_RESULT_DIVIDER,
|
||||
LayoutType.EMPTY_DIVIDER to SEARCH_RESULT_TOP_DIVIDER,
|
||||
)
|
||||
|
||||
fun decorateSearchResults(items: List<SearchAdapterItem>): List<SearchAdapterItem> {
|
||||
|
||||
@@ -3,6 +3,7 @@ package app.lawnchair.search
|
||||
import android.os.Bundle
|
||||
import android.os.Process
|
||||
import app.lawnchair.allapps.SearchItemBackground
|
||||
import com.android.app.search.LayoutType
|
||||
import com.android.launcher3.BuildConfig
|
||||
import com.android.launcher3.allapps.AllAppsGridAdapter
|
||||
import com.android.launcher3.model.data.AppInfo
|
||||
@@ -24,7 +25,7 @@ data class SearchAdapterItem(
|
||||
val user = appInfo.user
|
||||
val target = SearchTargetCompat.Builder(
|
||||
SearchTargetCompat.RESULT_TYPE_APPLICATION,
|
||||
SearchTargetCompat.LAYOUT_TYPE_ICON,
|
||||
LayoutType.ICON_SINGLE_VERTICAL_TEXT,
|
||||
ComponentKey(componentName, user).toString()
|
||||
)
|
||||
.setPackageName(componentName.packageName)
|
||||
@@ -33,10 +34,7 @@ data class SearchAdapterItem(
|
||||
putString("class", componentName.className)
|
||||
})
|
||||
.build()
|
||||
return SearchAdapterItem(target, background).apply {
|
||||
viewType = LawnchairSearchAdapterProvider.viewTypeMap[target.layoutType]!!
|
||||
position = pos
|
||||
}
|
||||
return createAdapterItem(pos, target, background)
|
||||
}
|
||||
|
||||
fun fromAction(
|
||||
@@ -48,7 +46,7 @@ data class SearchAdapterItem(
|
||||
): SearchAdapterItem {
|
||||
val target = SearchTargetCompat.Builder(
|
||||
SearchTargetCompat.RESULT_TYPE_SHORTCUT,
|
||||
SearchTargetCompat.LAYOUT_TYPE_ICON_ROW,
|
||||
LayoutType.ICON_HORIZONTAL_TEXT,
|
||||
id
|
||||
)
|
||||
.setPackageName(BuildConfig.APPLICATION_ID)
|
||||
@@ -56,24 +54,29 @@ data class SearchAdapterItem(
|
||||
.setSearchAction(action)
|
||||
.setExtras(extras)
|
||||
.build()
|
||||
return SearchAdapterItem(target, background).apply {
|
||||
viewType = LawnchairSearchAdapterProvider.viewTypeMap[target.layoutType]!!
|
||||
position = pos
|
||||
}
|
||||
return createAdapterItem(pos, target, background)
|
||||
}
|
||||
|
||||
val topDivider by lazy {
|
||||
val target = SearchTargetCompat.Builder(
|
||||
SearchTargetCompat.RESULT_TYPE_SHORTCUT,
|
||||
SearchTargetCompat.LAYOUT_TYPE_ICON_ROW,
|
||||
LayoutType.EMPTY_DIVIDER,
|
||||
"top_divider"
|
||||
)
|
||||
.setPackageName(BuildConfig.APPLICATION_ID)
|
||||
.setUserHandle(Process.myUserHandle())
|
||||
.build()
|
||||
SearchAdapterItem(target, null).apply {
|
||||
viewType = LawnchairSearchAdapterProvider.SEARCH_RESULT_TOP_DIVIDER
|
||||
position = 0
|
||||
createAdapterItem(0, target, null)
|
||||
}
|
||||
|
||||
private fun createAdapterItem(
|
||||
pos: Int,
|
||||
target: SearchTargetCompat,
|
||||
background: SearchItemBackground?
|
||||
): SearchAdapterItem {
|
||||
return SearchAdapterItem(target, background).apply {
|
||||
viewType = LawnchairSearchAdapterProvider.viewTypeMap[target.layoutType]!!
|
||||
position = pos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringDef;
|
||||
|
||||
import com.android.app.search.LayoutType;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Objects;
|
||||
@@ -98,17 +100,6 @@ public final class SearchTargetCompat implements Parcelable {
|
||||
public @interface SearchResultType {}
|
||||
private final int mResultType;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@StringDef(value = {
|
||||
LAYOUT_TYPE_ICON,
|
||||
LAYOUT_TYPE_ICON_ROW,
|
||||
LAYOUT_TYPE_SHORT_ICON_ROW,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SearchLayoutType {}
|
||||
|
||||
/**
|
||||
* Constant to express how the group of {@link SearchTargetCompat} should be rendered on
|
||||
* the client side. (e.g., "icon", "icon_row", "short_icon_row")
|
||||
@@ -208,7 +199,7 @@ public final class SearchTargetCompat implements Parcelable {
|
||||
* Retrieves the layout type.
|
||||
*/
|
||||
@NonNull
|
||||
public @SearchLayoutType String getLayoutType() {
|
||||
public @LayoutType.SearchLayoutType String getLayoutType() {
|
||||
return mLayoutType;
|
||||
}
|
||||
|
||||
@@ -377,7 +368,7 @@ public final class SearchTargetCompat implements Parcelable {
|
||||
private Bundle mExtras;
|
||||
|
||||
public Builder(@SearchResultType int resultType,
|
||||
@SearchLayoutType @NonNull String layoutType,
|
||||
@LayoutType.SearchLayoutType @NonNull String layoutType,
|
||||
@NonNull String id) {
|
||||
mId = id;
|
||||
mLayoutType = Objects.requireNonNull(layoutType);
|
||||
|
||||
Submodule platform_frameworks_libs_systemui updated: 4cf15b2801...355f582efd
@@ -1,8 +1,9 @@
|
||||
include ':IconLoader'
|
||||
project(':IconLoader').projectDir = new File(rootDir, 'platform_frameworks_libs_systemui/iconloaderlib')
|
||||
include ':iconloaderlib'
|
||||
project(':iconloaderlib').projectDir = new File(rootDir, 'platform_frameworks_libs_systemui/iconloaderlib')
|
||||
|
||||
include ':searchuilib'
|
||||
project(':searchuilib').projectDir = new File(rootDir, 'platform_frameworks_libs_systemui/searchuilib')
|
||||
|
||||
include ':SharedLibWrapper'
|
||||
project(':SharedLibWrapper').projectDir = new File(rootDir, 'SharedLibWrapper')
|
||||
include ':SystemUIShared'
|
||||
include ':CompatLib'
|
||||
include ':CompatLibVR'
|
||||
|
||||
Reference in New Issue
Block a user