Remove (once again) apparently useless code I don't understand anymore
This commit is contained in:
parent
cb49908bdc
commit
93a3bd3b15
@ -397,7 +397,6 @@ class LauncherActivity : AppCompatActivity() {
|
||||
binding.widgetList.setOnViewSwapListener { _, firstPosition, _, secondPosition ->
|
||||
Collections.swap(widgets, firstPosition, secondPosition)
|
||||
}
|
||||
updateWidgets()
|
||||
}
|
||||
|
||||
private fun addWidget() {
|
||||
@ -559,7 +558,6 @@ class LauncherActivity : AppCompatActivity() {
|
||||
val widgetViewModel by viewModels<WidgetViewModel>()
|
||||
widgetViewModel.requestCalendarUpdate()
|
||||
search(binding.searchBar.getSearchQuery())
|
||||
updateWidgets()
|
||||
|
||||
updateSystemBarAppearance()
|
||||
|
||||
@ -653,17 +651,6 @@ class LauncherActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateWidgets() {
|
||||
var topWidget: LauncherWidget? = null
|
||||
var topWidgetRanking = 0
|
||||
var topWidgetView: WidgetView? = null
|
||||
for (widget in binding.widgetList.iterator()) {
|
||||
if (widget is WidgetView) {
|
||||
widget.update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (data == null) return
|
||||
|
||||
@ -95,7 +95,6 @@ class WidgetView : LauncherCardView {
|
||||
|
||||
TooltipCompat.setTooltipText(binding.widgetActionResize, context.getString(R.string.widget_action_adjust_height))
|
||||
TooltipCompat.setTooltipText(binding.widgetActionRemove, context.getString(R.string.widget_action_remove))
|
||||
TooltipCompat.setTooltipText(binding.widgetActionSettings, context.getString(R.string.widget_action_settings))
|
||||
}
|
||||
|
||||
var onResizeModeChange: ((Boolean) -> Unit)? = null
|
||||
@ -109,18 +108,10 @@ class WidgetView : LauncherCardView {
|
||||
else -> return false
|
||||
}
|
||||
binding.widgetActionResize.visibility = View.GONE
|
||||
binding.widgetActionSettings.visibility = if (widgetView?.hasSettings == true) View.VISIBLE else View.GONE
|
||||
binding.widgetResizeDragHandle.resizeView = widgetView
|
||||
binding.widgetWrapper.addView(widgetView, 2)
|
||||
binding.widgetName.text = widgetView?.name
|
||||
visibility = if (widgetView?.show == true) View.VISIBLE else View.GONE
|
||||
binding.widgetActionSettings.setOnClickListener {
|
||||
widgetView?.openSettings()
|
||||
/*(context as? Activity)?.finish()
|
||||
context.startActivity(Intent(context, SettingsActivity::class.java).apply {
|
||||
putExtra(SettingsActivity.FRAGMENT, widgetView?.settingsFragment)
|
||||
})*/
|
||||
}
|
||||
} else {
|
||||
widgetView = ExternalWidget(context, widget, widgetHost)
|
||||
binding.widgetResizeDragHandle.resizeView = widgetView
|
||||
@ -130,7 +121,6 @@ class WidgetView : LauncherCardView {
|
||||
binding.widgetWrapper.addView(widgetView, 2)
|
||||
binding.widgetName.text = widgetView?.name
|
||||
binding.widgetActionResize.visibility = View.VISIBLE
|
||||
binding.widgetActionSettings.visibility = View.GONE
|
||||
visibility = if (widgetView?.show == true) View.VISIBLE else View.GONE
|
||||
}
|
||||
widgetView?.onVisibilityChanged = {
|
||||
@ -147,10 +137,4 @@ class WidgetView : LauncherCardView {
|
||||
return binding.widgetDragHandle
|
||||
}
|
||||
|
||||
fun update() {
|
||||
val widget = binding.widgetWrapper[2] as? LauncherWidget ?: return
|
||||
widget.update()
|
||||
visibility = if (widget.show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
}
|
||||
@ -32,14 +32,6 @@ class CalendarWidget : LauncherWidget {
|
||||
|
||||
override val canResize: Boolean
|
||||
get() = false
|
||||
override val settingsFragment: String?
|
||||
get() = "calendar"
|
||||
override val compactView: CompactView?
|
||||
get() = null
|
||||
override val compactViewRanking: Int
|
||||
get() {
|
||||
return -1
|
||||
}
|
||||
|
||||
private val calendarEvents: LiveData<List<CalendarEvent>>
|
||||
private val pinnedCalendarEvents: LiveData<List<CalendarEvent>>
|
||||
@ -62,9 +54,6 @@ class CalendarWidget : LauncherWidget {
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleRes: Int) : super(context, attrs, defStyleRes)
|
||||
|
||||
override fun update() {
|
||||
}
|
||||
|
||||
private fun formatDay(day: Long): String {
|
||||
return when (day) {
|
||||
0L -> context.getString(R.string.date_today)
|
||||
|
||||
@ -50,14 +50,6 @@ class ExternalWidget(
|
||||
if (view is ListView || view is ScrollView) view.isNestedScrollingEnabled = true
|
||||
}
|
||||
|
||||
override fun update() {}
|
||||
|
||||
override val compactViewRanking: Int
|
||||
get() = -1
|
||||
override val compactView: CompactView?
|
||||
get() = null
|
||||
override val settingsFragment: String?
|
||||
get() = null
|
||||
override val canResize: Boolean
|
||||
get() = true
|
||||
override val name: String
|
||||
|
||||
@ -16,16 +16,6 @@ abstract class LauncherWidget : FrameLayout {
|
||||
enableTransitionType(LayoutTransition.CHANGING)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun update()
|
||||
fun updateCompactView() {
|
||||
compactView?.update()
|
||||
}
|
||||
|
||||
abstract val compactViewRanking: Int
|
||||
abstract val compactView: CompactView?
|
||||
abstract val settingsFragment: String?
|
||||
open val hasSettings = false
|
||||
abstract val canResize: Boolean
|
||||
abstract val name: String
|
||||
var show: Boolean = true
|
||||
@ -36,8 +26,4 @@ abstract class LauncherWidget : FrameLayout {
|
||||
|
||||
var onVisibilityChanged: ((Boolean) -> Unit)? = null
|
||||
|
||||
open fun startResize() {}
|
||||
open fun endResize() {}
|
||||
|
||||
open fun openSettings() {}
|
||||
}
|
||||
@ -28,15 +28,6 @@ import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class MusicWidget : LauncherWidget {
|
||||
|
||||
override val compactViewRanking: Int
|
||||
get() = if (viewModel.hasActiveSession) 1 else -1
|
||||
|
||||
override val compactView: CompactView?
|
||||
get() {
|
||||
return MusicCompactView(context)
|
||||
}
|
||||
override val settingsFragment: String?
|
||||
get() = null
|
||||
override val canResize: Boolean
|
||||
get() = false
|
||||
override val name: String
|
||||
@ -65,10 +56,6 @@ class MusicWidget : LauncherWidget {
|
||||
addView(composeView)
|
||||
}
|
||||
|
||||
|
||||
override fun update() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ID = "music"
|
||||
}
|
||||
|
||||
@ -16,19 +16,8 @@ import de.mm20.launcher2.ui.widget.WeatherWidget
|
||||
class WeatherWidget : LauncherWidget {
|
||||
|
||||
|
||||
override fun update() {
|
||||
}
|
||||
|
||||
override val canResize: Boolean
|
||||
get() = false
|
||||
override val settingsFragment: String?
|
||||
get() = "weather"
|
||||
override val compactView: CompactView?
|
||||
get() = WeatherCompactView(context)
|
||||
override val compactViewRanking: Int
|
||||
get() = -1
|
||||
override val hasSettings = true
|
||||
|
||||
override val name: String
|
||||
get() = resources.getString(R.string.widget_name_weather)
|
||||
|
||||
|
||||
@ -43,20 +43,6 @@
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/ic_widget_resize"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widgetActionSettings"
|
||||
style="?iconStyle"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="56dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:foreground="?selectableItemBackgroundBorderless"
|
||||
android:padding="12dp"
|
||||
android:src="@drawable/ic_settings"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/widgetActionRemove"
|
||||
style="?iconStyle"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user