This commit is contained in:
2025-08-13 10:17:00 +09:00
parent 81e4c77644
commit b8b088c1ab
16 changed files with 1052 additions and 46 deletions
+2
View File
@@ -39,6 +39,8 @@
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:hardwareAccelerated="true"
android:requestLegacyExternalStorage="true"
android:resizeableActivity="true"
android:supportsRtl="true"
+1
View File
@@ -15,6 +15,7 @@
android:stateNotNeeded="true"
android:theme="@style/LauncherTheme"
android:enableOnBackInvokedCallback="true"
android:configChanges="keyboard|keyboardHidden|screenLayout|layoutDirection|navigation|orientation|uiMode"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -1,6 +1,8 @@
package de.mm20.launcher2.ui.launcher
import android.content.Intent
import android.content.res.Configuration
import android.util.Log
import com.android.launcher3.GestureNavContract
import de.mm20.launcher2.ui.launcher.scaffold.ScaffoldPage
@@ -19,6 +21,12 @@ class LauncherActivity: SharedLauncherActivity(LauncherActivityMode.Launcher) {
}
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
Log.e("LauncherActivity","newConfig.keyboard ${newConfig.keyboard}")
Log.e("LauncherActivity","newConfig.keyboardHidden ${newConfig.keyboardHidden}")
Log.e("LauncherActivity","newConfig.hardKeyboardHidden ${newConfig.hardKeyboardHidden}")
}
override fun onPause() {
super.onPause()
enterHomeTransitionManager.clear()
@@ -250,10 +250,10 @@ class SearchVM : ViewModel(), KoinComponent {
previousResults = SearchResults(apps = apps)
searchActionResults.clear()
appResults.mergeWith(apps)
workAppResults.mergeWith(workApps)
privateSpaceAppResults.mergeWith(privateApps)
hiddenResults.mergeWith(hiddenItems)
appResults.updateItems(apps)
workAppResults.updateItems(workApps)
privateSpaceAppResults.updateItems(privateApps)
hiddenResults.updateItems(hiddenItems)
}
} else {
@@ -273,19 +273,31 @@ class SearchVM : ViewModel(), KoinComponent {
workAppResults.clear()
privateSpaceAppResults.clear()
appResults.mergeWith(results.apps, hiddenKeys, query)
appShortcutResults.mergeWith(results.shortcuts, hiddenKeys, query)
fileResults.mergeWith(results.files, hiddenKeys, query)
appResults.updateItems(
results.apps
?.filterNot { hiddenKeys.contains(it.key) }
?.applyRanking(query)
)
appShortcutResults.updateItems(
results.shortcuts
?.filterNot { hiddenKeys.contains(it.key) }
?.applyRanking(query)
)
fileResults.updateItems(
results.files
?.filterNot { hiddenKeys.contains(it.key) }
?.applyRanking(query)
)
contactResults.mergeWith(
contactResults.updateItems(
results.contacts?.filterNot { hiddenKeys.contains(it.key) }
?.applyRanking(query)
)
calendarResults.mergeWith(
calendarResults.updateItems(
results.calendars?.filterNot { hiddenKeys.contains(it.key) }
?.applyRanking(query)
)
locationResults.mergeWith(
locationResults.updateItems(
results.locations?.filterNot { hiddenKeys.contains(it.key) }
?.let { locations ->
devicePoseProvider.lastCachedLocation?.let {
@@ -298,17 +310,17 @@ class SearchVM : ViewModel(), KoinComponent {
} ?: locations.applyRanking(query)
}
)
articleResults.mergeWith(
articleResults.updateItems(
results.wikipedia?.applyRanking(query)
)
websiteResults.mergeWith(
websiteResults.updateItems(
results.websites?.applyRanking(query)
)
calculatorResults.mergeWith(results.calculators)
unitConverterResults.mergeWith(results.unitConverters)
calculatorResults.updateItems(results.calculators)
unitConverterResults.updateItems(results.unitConverters)
if (results.searchActions != null) {
searchActionResults.mergeWith(results.searchActions!!)
searchActionResults.updateItems(results.searchActions!!)
}
if (launchOnEnter.value) {
@@ -429,24 +441,18 @@ class SearchVM : ViewModel(), KoinComponent {
return sorted.distinctBy { it.key }.toList()
}
private fun <T> SnapshotStateList<T>.mergeWith(newItems: List<T>?) {
val items = newItems ?: emptyList()
val diff = toSet() subtract items.toSet()
removeAll(diff)
for ((i, item) in items.withIndex()) {
if (i < size)
set(i, item)
else
add(item)
}
/**
* Merges a list of new items into the current SnapshotStateList.
* It removes items that are in the current list but not in the new list.
* Then, it updates existing items or adds new items from the new list.
*
* @param T The type of items in the list.
* @param newItems The list of new items to merge with. If null, an empty list is used.
*/
private fun <T> SnapshotStateList<T>.updateItems(newItems: List<T>?) {
clear()
addAll(newItems ?: emptyList())
}
private suspend fun <T : SavableSearchable> SnapshotStateList<T>.mergeWith(
newItems: List<T>?,
hiddenKeys: List<String>,
query: String
) = this.mergeWith((newItems ?: emptyList()).filterNot { hiddenKeys.contains(it.key) }
.applyRanking(query))
}
@@ -226,11 +226,19 @@ fun LocationItem(
this@AnimatedContent
)
)
// val rateing =
val formattedDistance =
distance?.metersToLocalizedString(context, imperialUnits)
val sublabel = listOf(location.category, formattedDistance)
.fastFilterNotNull()
.joinToString("")
val sublabel = if (location.category?.contains("|") == true) {
listOf(location.category!!.split("|")!!.first(), formattedDistance,location.userRating)
.fastFilterNotNull()
.joinToString("")
} else {
listOf(location.category, formattedDistance,location.userRating)
.fastFilterNotNull()
.joinToString("")
}
val isOpenString = location.openingSchedule?.isOpen()
?.let { stringResource(if (it) R.string.location_open else R.string.location_closed) }
@@ -66,7 +66,7 @@ fun WidgetColumn(
Column(
modifier = modifier
modifier = modifier.fillMaxWidth()
) {
val scope = rememberCoroutineScope()
Column {
@@ -693,4 +693,4 @@ fun ConfigureClockWidgetSheet(
}
}
}
}
}