Remove unused code
This commit is contained in:
parent
d221a6b178
commit
386083ede9
@ -1,4 +1,4 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
package de.mm20.launcher2.ui.launcher.search
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
@ -24,7 +24,7 @@ import kotlinx.coroutines.flow.map
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
class SearchBar @JvmOverloads constructor(
|
||||
class SearchBarView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = R.attr.materialCardViewStyle
|
||||
@ -1,37 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.*
|
||||
import de.mm20.launcher2.search.data.Application
|
||||
import de.mm20.launcher2.ui.databinding.ViewApplicationBinding
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
|
||||
class ApplicationView : FrameLayout {
|
||||
|
||||
private val applications: LiveData<List<Application>>
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(context, attrs, defStyleRes)
|
||||
|
||||
private val binding = ViewApplicationBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
init {
|
||||
layoutTransition = LayoutTransition()
|
||||
layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
binding.applicationCard.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
applications = viewModel.appResults
|
||||
applications.observe(context as AppCompatActivity, Observer<List<Application>> {
|
||||
visibility = if (it.isEmpty()) View.GONE else View.VISIBLE
|
||||
binding.applicationGrid.submitItems(it)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import de.mm20.launcher2.search.data.Calculator
|
||||
import de.mm20.launcher2.ui.MdcLauncherTheme
|
||||
import de.mm20.launcher2.ui.databinding.ViewCalculatorBinding
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.search.CalculatorItem
|
||||
|
||||
class CalculatorView : FrameLayout {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
private val calculator: LiveData<Calculator?>
|
||||
|
||||
private val binding = ViewCalculatorBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
init {
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
calculator = viewModel.calculatorResult
|
||||
calculator.observe(context as AppCompatActivity, Observer {
|
||||
if (it == null) visibility = View.GONE
|
||||
else {
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
})
|
||||
|
||||
binding.composeView.setContent {
|
||||
val converter by calculator.observeAsState()
|
||||
MdcLauncherTheme {
|
||||
// TODO: Temporary solution until parent widget card is rewritten in Compose
|
||||
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
|
||||
Column {
|
||||
converter?.let {
|
||||
CalculatorItem(
|
||||
calculator = it,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,117 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.asLiveData
|
||||
import de.mm20.launcher2.ktx.lifecycleScope
|
||||
import de.mm20.launcher2.permissions.PermissionGroup
|
||||
import de.mm20.launcher2.permissions.PermissionsManager
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import de.mm20.launcher2.search.data.MissingPermission
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.legacy.search.SearchListView
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
|
||||
class CalendarView : FrameLayout, KoinComponent {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
init {
|
||||
val permissionsManager: PermissionsManager = get()
|
||||
val dataStore: LauncherDataStore = get()
|
||||
View.inflate(context, R.layout.view_search_category_list, this)
|
||||
layoutTransition = LayoutTransition()
|
||||
layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
val card = findViewById<ViewGroup>(R.id.card)
|
||||
card.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
|
||||
val showMissingPermissionBanner = combine(
|
||||
dataStore.data.map { it.calendarSearch.enabled },
|
||||
permissionsManager.hasPermission(PermissionGroup.Calendar)
|
||||
) { calendarSearchEnabled, hasPermission ->
|
||||
!hasPermission && calendarSearchEnabled
|
||||
}.asLiveData()
|
||||
|
||||
val searchQuery = viewModel.searchQuery
|
||||
val calendarResults = viewModel.calendarResults
|
||||
|
||||
val show = MediatorLiveData<Boolean>()
|
||||
show.addSource(showMissingPermissionBanner) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !calendarResults.value.isNullOrEmpty())
|
||||
}
|
||||
show.addSource(calendarResults) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !calendarResults.value.isNullOrEmpty())
|
||||
}
|
||||
show.addSource(searchQuery) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !calendarResults.value.isNullOrEmpty())
|
||||
}
|
||||
|
||||
show.observe(context as AppCompatActivity) {
|
||||
visibility = if (it) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
val list = findViewById<SearchListView>(R.id.list)
|
||||
calendarResults.observe(context as AppCompatActivity) {
|
||||
if (showMissingPermissionBanner.value == true) {
|
||||
list.submitItems(listOf(
|
||||
MissingPermission(
|
||||
context.getString(R.string.permission_calendar_search),
|
||||
PermissionGroup.Calendar,
|
||||
secondaryActionLabel = context.getString(R.string.turn_off),
|
||||
secondaryAction = {
|
||||
lifecycleScope.launch {
|
||||
dataStore.updateData {
|
||||
it.toBuilder()
|
||||
.setCalendarSearch(it.calendarSearch.toBuilder().setEnabled(false))
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
) + it)
|
||||
} else {
|
||||
list.submitItems(it)
|
||||
}
|
||||
}
|
||||
|
||||
showMissingPermissionBanner.observe(context as AppCompatActivity) {
|
||||
if (it == true) {
|
||||
list.submitItems(listOf(
|
||||
MissingPermission(
|
||||
context.getString(R.string.permission_calendar_search),
|
||||
PermissionGroup.Calendar,
|
||||
secondaryActionLabel = context.getString(R.string.turn_off)
|
||||
)
|
||||
) + calendarResults.value!!)
|
||||
} else {
|
||||
list.submitItems(calendarResults.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,117 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.asLiveData
|
||||
import de.mm20.launcher2.ktx.lifecycleScope
|
||||
import de.mm20.launcher2.permissions.PermissionGroup
|
||||
import de.mm20.launcher2.permissions.PermissionsManager
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import de.mm20.launcher2.search.data.MissingPermission
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.legacy.search.SearchListView
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
|
||||
class ContactView : FrameLayout, KoinComponent {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
init {
|
||||
val permissionsManager: PermissionsManager = get()
|
||||
val dataStore: LauncherDataStore = get()
|
||||
View.inflate(context, R.layout.view_search_category_list, this)
|
||||
layoutTransition = LayoutTransition()
|
||||
layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
val card = findViewById<ViewGroup>(R.id.card)
|
||||
card.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
|
||||
val showMissingPermissionBanner = combine(
|
||||
dataStore.data.map { it.contactsSearch.enabled },
|
||||
permissionsManager.hasPermission(PermissionGroup.Contacts)
|
||||
) { contactSearchEnabled, hasPermission ->
|
||||
!hasPermission && contactSearchEnabled
|
||||
}.asLiveData()
|
||||
|
||||
val searchQuery = viewModel.searchQuery
|
||||
val contactResults = viewModel.contactResults
|
||||
|
||||
val show = MediatorLiveData<Boolean>()
|
||||
show.addSource(showMissingPermissionBanner) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !contactResults.value.isNullOrEmpty())
|
||||
}
|
||||
show.addSource(contactResults) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !contactResults.value.isNullOrEmpty())
|
||||
}
|
||||
show.addSource(searchQuery) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !contactResults.value.isNullOrEmpty())
|
||||
}
|
||||
|
||||
show.observe(context as AppCompatActivity) {
|
||||
visibility = if (it) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
val list = findViewById<SearchListView>(R.id.list)
|
||||
contactResults.observe(context as AppCompatActivity) {
|
||||
if (showMissingPermissionBanner.value == true) {
|
||||
list.submitItems(listOf(
|
||||
MissingPermission(
|
||||
context.getString(R.string.permission_contact_search),
|
||||
PermissionGroup.Contacts,
|
||||
secondaryActionLabel = context.getString(R.string.turn_off),
|
||||
secondaryAction = {
|
||||
lifecycleScope.launch {
|
||||
dataStore.updateData {
|
||||
it.toBuilder()
|
||||
.setContactsSearch(it.contactsSearch.toBuilder().setEnabled(false))
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
) + it)
|
||||
} else {
|
||||
list.submitItems(it)
|
||||
}
|
||||
}
|
||||
|
||||
showMissingPermissionBanner.observe(context as AppCompatActivity) {
|
||||
if (it == true) {
|
||||
list.submitItems(listOf(
|
||||
MissingPermission(
|
||||
context.getString(R.string.permission_contact_search),
|
||||
PermissionGroup.Contacts,
|
||||
secondaryActionLabel = context.getString(R.string.turn_off)
|
||||
)
|
||||
) + contactResults.value!!)
|
||||
} else {
|
||||
list.submitItems(contactResults.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import de.mm20.launcher2.ui.databinding.ViewFavoritesBinding
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
|
||||
class FavoritesView : FrameLayout {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(context, attrs, defStyleRes)
|
||||
|
||||
private val binding = ViewFavoritesBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
|
||||
init {
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
val favorites = viewModel.favorites
|
||||
val hide = viewModel.hideFavorites
|
||||
favorites.observe(context as AppCompatActivity) {
|
||||
visibility = if (it?.isEmpty() == true || hide.value == true) View.GONE else View.VISIBLE
|
||||
binding.favoritesGrid.submitItems(it)
|
||||
}
|
||||
|
||||
hide.observe(context as AppCompatActivity) {
|
||||
visibility = if(it == true || favorites.value?.isEmpty() == true) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
layoutTransition = LayoutTransition().apply { enableTransitionType(LayoutTransition.CHANGING) }
|
||||
binding.favoritesCard.layoutTransition = LayoutTransition().apply { enableTransitionType(LayoutTransition.CHANGING) }
|
||||
}
|
||||
}
|
||||
@ -1,119 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.animation.LayoutTransition
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.asLiveData
|
||||
import de.mm20.launcher2.ktx.lifecycleScope
|
||||
import de.mm20.launcher2.permissions.PermissionGroup
|
||||
import de.mm20.launcher2.permissions.PermissionsManager
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import de.mm20.launcher2.search.data.File
|
||||
import de.mm20.launcher2.search.data.MissingPermission
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.legacy.search.SearchListView
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
|
||||
class FileView : FrameLayout, KoinComponent {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
init {
|
||||
val permissionsManager: PermissionsManager = get()
|
||||
val dataStore: LauncherDataStore = get()
|
||||
View.inflate(context, R.layout.view_search_category_list, this)
|
||||
layoutTransition = LayoutTransition()
|
||||
layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
val card = findViewById<ViewGroup>(R.id.card)
|
||||
card.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
|
||||
val showMissingPermissionBanner = combine(
|
||||
dataStore.data.map { it.fileSearch.localFiles },
|
||||
permissionsManager.hasPermission(PermissionGroup.ExternalStorage)
|
||||
) { localFileSearchEnabled, hasPermission ->
|
||||
!hasPermission && localFileSearchEnabled
|
||||
}.asLiveData()
|
||||
|
||||
val searchQuery = viewModel.searchQuery
|
||||
val fileResults = viewModel.fileResults
|
||||
|
||||
val show = MediatorLiveData<Boolean>()
|
||||
show.addSource(showMissingPermissionBanner) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !fileResults.value.isNullOrEmpty())
|
||||
}
|
||||
show.addSource(fileResults) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !fileResults.value.isNullOrEmpty())
|
||||
}
|
||||
show.addSource(searchQuery) {
|
||||
show.value = !searchQuery.value.isNullOrBlank() &&
|
||||
(showMissingPermissionBanner.value == true || !fileResults.value.isNullOrEmpty())
|
||||
}
|
||||
|
||||
show.observe(context as AppCompatActivity) {
|
||||
visibility = if (it) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
val list = findViewById<SearchListView>(R.id.list)
|
||||
fileResults.observe(context as AppCompatActivity) {
|
||||
if (showMissingPermissionBanner.value == true) {
|
||||
list.submitItems(listOf(
|
||||
MissingPermission(
|
||||
context.getString(R.string.permission_files_search),
|
||||
PermissionGroup.ExternalStorage,
|
||||
secondaryActionLabel = context.getString(R.string.turn_off),
|
||||
secondaryAction = {
|
||||
lifecycleScope.launch {
|
||||
dataStore.updateData {
|
||||
it.toBuilder()
|
||||
.setFileSearch(it.fileSearch.toBuilder().setLocalFiles(false))
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
) + it)
|
||||
} else {
|
||||
list.submitItems(it)
|
||||
}
|
||||
}
|
||||
|
||||
showMissingPermissionBanner.observe(context as AppCompatActivity) {
|
||||
if (it == true) {
|
||||
list.submitItems(listOf(
|
||||
MissingPermission(
|
||||
context.getString(R.string.permission_files_search),
|
||||
PermissionGroup.ExternalStorage,
|
||||
secondaryActionLabel = context.getString(R.string.turn_off)
|
||||
)
|
||||
) + fileResults.value!!)
|
||||
} else {
|
||||
list.submitItems(fileResults.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import de.mm20.launcher2.search.data.UnitConverter
|
||||
import de.mm20.launcher2.ui.MdcLauncherTheme
|
||||
import de.mm20.launcher2.ui.databinding.ViewUnitconverterBinding
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.search.UnitConverterItem
|
||||
|
||||
class UnitConverterView : FrameLayout {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
private val unitConverter: LiveData<UnitConverter?>
|
||||
|
||||
private val binding = ViewUnitconverterBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
init {
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
unitConverter = viewModel.unitConverterResult
|
||||
unitConverter.observe(context as AppCompatActivity, Observer {
|
||||
if (it == null) visibility = View.GONE
|
||||
else {
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
})
|
||||
|
||||
binding.composeView.setContent {
|
||||
val converter by unitConverter.observeAsState()
|
||||
MdcLauncherTheme {
|
||||
// TODO: Temporary solution until parent widget card is rewritten in Compose
|
||||
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
|
||||
Column {
|
||||
converter?.let {
|
||||
UnitConverterItem(
|
||||
unitConverter = it,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,87 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import coil.imageLoader
|
||||
import coil.request.ImageRequest
|
||||
import coil.size.Scale
|
||||
import com.google.android.material.chip.Chip
|
||||
import de.mm20.launcher2.ktx.dp
|
||||
import de.mm20.launcher2.ktx.lifecycleScope
|
||||
import de.mm20.launcher2.ui.legacy.helper.ActivityStarter
|
||||
import de.mm20.launcher2.search.data.Websearch
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.databinding.ViewWebsearchBinding
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
|
||||
class WebSearchView : FrameLayout {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
private val websearches: LiveData<List<Websearch>>
|
||||
|
||||
private val binding = ViewWebsearchBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
|
||||
init {
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
websearches = viewModel.websearchResults
|
||||
websearches.observe(context as AppCompatActivity, Observer {
|
||||
updateWebsearches(it)
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateWebsearches(websearches: List<Websearch>) {
|
||||
visibility = if (websearches.isEmpty()) View.GONE else View.VISIBLE
|
||||
binding.webSearchList.removeAllViews()
|
||||
for (search in websearches) {
|
||||
val chip = Chip(context)
|
||||
chip.text = search.label
|
||||
val icon = search.icon
|
||||
if (icon != null) {
|
||||
val imageRequest = ImageRequest.Builder(context)
|
||||
.data(File(icon))
|
||||
.size((32*dp).toInt())
|
||||
.scale(Scale.FIT)
|
||||
.target {
|
||||
chip.chipIcon = it
|
||||
}
|
||||
.build()
|
||||
lifecycleScope.launch {
|
||||
context.imageLoader.execute(imageRequest)
|
||||
}
|
||||
chip.chipIconTint = null
|
||||
} else {
|
||||
chip.chipIcon = ContextCompat.getDrawable(context, R.drawable.ic_search)
|
||||
chip.chipIconTint = ColorStateList.valueOf(search.color)
|
||||
|
||||
}
|
||||
chip.chipStrokeWidth = 1 * dp
|
||||
chip.chipStrokeColor = ContextCompat.getColorStateList(context, R.color.chip_stroke)
|
||||
chip.chipBackgroundColor =
|
||||
ContextCompat.getColorStateList(context, R.color.chip_background)
|
||||
chip.setTextAppearanceResource(R.style.ChipTextAppearance)
|
||||
chip.setOnClickListener {
|
||||
ActivityStarter.start(context, chip, intent = search.getLaunchIntent())
|
||||
}
|
||||
|
||||
binding.webSearchList.addView(chip)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,48 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import de.mm20.launcher2.ui.legacy.helper.ActivityStarter
|
||||
import de.mm20.launcher2.search.data.Website
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.legacy.searchable.SearchableView
|
||||
|
||||
class WebsiteView : FrameLayout {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
private val website: LiveData<Website?>
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.view_search_category_single_item, this)
|
||||
val websiteView = SearchableView(context, SearchableView.REPRESENTATION_LIST)
|
||||
val params =
|
||||
ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
val card = findViewById<ViewGroup>(R.id.card)
|
||||
websiteView.layoutParams = params
|
||||
card.addView(websiteView)
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
website = viewModel.websiteResult
|
||||
website.observe(context as AppCompatActivity, Observer {
|
||||
visibility = if (it == null) View.GONE else View.VISIBLE
|
||||
card.setOnClickListener { _ ->
|
||||
ActivityStarter.start(context, websiteView, item = it)
|
||||
}
|
||||
websiteView.searchable = it
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
package de.mm20.launcher2.ui.legacy.component
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.LiveData
|
||||
import de.mm20.launcher2.ui.legacy.helper.ActivityStarter
|
||||
import de.mm20.launcher2.search.data.Wikipedia
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||
import de.mm20.launcher2.ui.legacy.searchable.SearchableView
|
||||
|
||||
class WikipediaView : FrameLayout {
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
val wikipedia: LiveData<Wikipedia?>
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.view_search_category_single_item, this)
|
||||
val websiteView = SearchableView(context, SearchableView.REPRESENTATION_LIST)
|
||||
val params =
|
||||
ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
val card = findViewById<ViewGroup>(R.id.card)
|
||||
websiteView.layoutParams = params
|
||||
card.addView(websiteView)
|
||||
val viewModel: SearchVM by (context as AppCompatActivity).viewModels()
|
||||
wikipedia = viewModel.wikipediaResult
|
||||
wikipedia.observe(context as AppCompatActivity, {
|
||||
visibility = if (it == null) View.GONE else View.VISIBLE
|
||||
card.setOnClickListener { _ ->
|
||||
ActivityStarter.start(context, websiteView, item = it)
|
||||
}
|
||||
websiteView.searchable = it
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</LinearLayout>
|
||||
@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40sp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/value"
|
||||
android:layout_width="58sp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
tools:text="6.07" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp"
|
||||
tools:text="metres" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/symbol"
|
||||
android:layout_width="36sp"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical|end"
|
||||
android:textStyle="bold"
|
||||
tools:text="kg" />
|
||||
</LinearLayout>
|
||||
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:layout_height="40dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:text="Show all" />
|
||||
</LinearLayout>
|
||||
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<de.mm20.launcher2.ui.legacy.view.LauncherCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/applicationCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:clipChildren="false"
|
||||
android:elevation="@dimen/card_elevation"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.search.SearchGridView
|
||||
android:id="@+id/applicationGrid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="8dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"/>
|
||||
</de.mm20.launcher2.ui.legacy.view.LauncherCardView>
|
||||
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<de.mm20.launcher2.ui.legacy.view.LauncherCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/websiteCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="@dimen/card_elevation">
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/composeView"/>
|
||||
</de.mm20.launcher2.ui.legacy.view.LauncherCardView>
|
||||
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<de.mm20.launcher2.ui.legacy.view.LauncherCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/favoritesCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="@dimen/card_elevation">
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.search.SearchGridView
|
||||
android:id="@+id/favoritesGrid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:padding="8dp" />
|
||||
</de.mm20.launcher2.ui.legacy.view.LauncherCardView>
|
||||
@ -43,7 +43,7 @@
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.SearchBar
|
||||
<de.mm20.launcher2.ui.launcher.search.SearchBarView
|
||||
android:id="@+id/searchBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="112dp"
|
||||
|
||||
@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="android.widget.LinearLayout"
|
||||
tools:layout_width="match_parent"
|
||||
tools:layout_height="wrap_content">
|
||||
|
||||
|
||||
<View
|
||||
android:id="@+id/webSearchViewSpacer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.FavoritesView
|
||||
android:id="@+id/favoritesView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.ApplicationView
|
||||
android:id="@+id/applicationView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.CalculatorView
|
||||
android:id="@+id/calculatorView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.ContactView
|
||||
android:id="@+id/contactView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.CalendarView
|
||||
android:id="@+id/calendarView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.UnitConverterView
|
||||
android:id="@+id/unitConverterView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.FileView
|
||||
android:id="@+id/fileView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.WebsiteView
|
||||
android:id="@+id/websiteView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.component.WikipediaView
|
||||
android:id="@+id/wikipediaView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
</merge>
|
||||
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<de.mm20.launcher2.ui.legacy.view.LauncherCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:clipChildren="false"
|
||||
android:elevation="@dimen/card_elevation"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<de.mm20.launcher2.ui.legacy.search.SearchListView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"/>
|
||||
</de.mm20.launcher2.ui.legacy.view.LauncherCardView>
|
||||
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<de.mm20.launcher2.ui.legacy.view.LauncherCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:animateLayoutChanges="true"
|
||||
android:clickable="true"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="@dimen/card_elevation"
|
||||
android:focusable="true"
|
||||
android:foreground="?selectableItemBackground"
|
||||
android:stateListAnimator="@animator/card_raise_animator">
|
||||
|
||||
</de.mm20.launcher2.ui.legacy.view.LauncherCardView>
|
||||
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<de.mm20.launcher2.ui.legacy.view.LauncherCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/websiteCard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
android:elevation="@dimen/card_elevation">
|
||||
|
||||
<androidx.compose.ui.platform.ComposeView
|
||||
android:id="@+id/composeView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</de.mm20.launcher2.ui.legacy.view.LauncherCardView>
|
||||
@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:background="@color/color_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"/>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:overScrollMode="never"
|
||||
android:scrollbars="none">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:clipChildren="false"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp">
|
||||
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/webSearchList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:singleLine="true"/>
|
||||
</LinearLayout>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
Loading…
x
Reference in New Issue
Block a user