Skip to content
Snippets Groups Projects
Commit e943b15a authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Duncan McNamara
Browse files

Warn the user if the widget type is too large for the in-home size

parent 5711f759
No related branches found
No related tags found
1 merge request!1703Display the widget using the custom type if needed
Pipeline #343228 passed with stage
in 20 minutes and 7 seconds
......@@ -1047,6 +1047,7 @@
<string name="widget_type_normal">Normal</string>
<string name="widget_type_circle">Circle</string>
<string name="widget_type_large">Large</string>
<string name="widget_type_error">This widget type is too large for the widget size. It can lead to visual issues</string>
<string name="opacity">Opacity</string>
<string name="widget_background">Background</string>
<string name="widget_foreground">Foreground</string>
......
......@@ -45,11 +45,14 @@ import org.videolan.tools.WIDGETS_BACKGROUND_LAST_COLORS
import org.videolan.tools.WIDGETS_FOREGROUND_LAST_COLORS
import org.videolan.tools.putSingle
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.UiTools
import org.videolan.vlc.gui.preferences.BasePreferenceFragment
import org.videolan.vlc.gui.view.NumberPickerPreference
import org.videolan.vlc.repository.WidgetRepository
import org.videolan.vlc.widget.WidgetViewModel
import org.videolan.vlc.widget.utils.WidgetSizeUtil
import org.videolan.vlc.widget.utils.WidgetType
import org.videolan.vlc.widget.utils.WidgetUtils
import org.videolan.vlc.widget.utils.WidgetUtils.getWidgetType
import org.videolan.vlc.widget.utils.WidgetUtils.hasEnoughSpaceForSeek
......@@ -165,7 +168,14 @@ class PreferencesWidgets : BasePreferenceFragment(), SharedPreferences.OnSharedP
"widget_type" -> {
val newValue = sharedPreferences.getString(key, "0")?.toInt() ?: 0
model.widget.value?.type = newValue
model.widget.value?.let {
val size = WidgetSizeUtil.getWidgetsSize(requireActivity(), it.widgetId)
val minimalSize = WidgetUtils.getMinimalWidgetSize(WidgetUtils.getWidgetType(it))
if (size.first < minimalSize.first || size.second < minimalSize.second) {
UiTools.snackerConfirm(requireActivity(), getString(R.string.widget_type_error)) { }
}
}
}
"widget_light_theme" -> {
val newValue = sharedPreferences.getBoolean(key, true)
......
......@@ -295,6 +295,19 @@ object WidgetUtils {
else -> WidgetType.PILL
}
/**
* Minimal size for this widget type
*
* @param type the widget type to check
* @return the minimal size
*/
fun getMinimalWidgetSize(type: WidgetType):Pair<Int, Int> = when(type){
WidgetType.MACRO -> Pair(220,200)
WidgetType.MINI -> Pair(220,72)
WidgetType.MICRO -> Pair(128,148)
else -> Pair(0,0)
}
/**
* Check if the widget has enough space to display the seek icons
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment