Add Kodi 17 backwards compat to #308

This commit is contained in:
Odd Stråbø 2020-05-31 01:07:16 +02:00
parent c4ea4271ea
commit db51abd786
2 changed files with 18 additions and 9 deletions

View File

@ -8,6 +8,7 @@ from kodi_six import xbmcgui
from helper import translate from helper import translate
from helper import LazyLogger from helper import LazyLogger
from helper import kodi_version
################################################################################################## ##################################################################################################
@ -97,13 +98,20 @@ class LoginManual(xbmcgui.WindowXMLDialog):
def _add_editcontrol(self, x, y, height, width, password=False): def _add_editcontrol(self, x, y, height, width, password=False):
control = xbmcgui.ControlEdit(0, 0, 0, 0, kwargs = dict(
label="User", label="User",
font="font13", font="font13",
textColor="FF00A4DC", textColor="FF00A4DC",
disabledColor="FF888888", disabledColor="FF888888",
focusTexture="-", focusTexture="-",
noFocusTexture="-") noFocusTexture="-"
)
# TODO: Kodi 17 compat removal cleanup
if kodi_version() < 18:
kwargs['isPassword'] = password
control = xbmcgui.ControlEdit(0, 0, 0, 0, **kwargs)
control.setPosition(x, y) control.setPosition(x, y)
control.setHeight(height) control.setHeight(height)
@ -112,7 +120,8 @@ class LoginManual(xbmcgui.WindowXMLDialog):
self.addControl(control) self.addControl(control)
# setType has no effect before the control is added to a window # setType has no effect before the control is added to a window
if password: # TODO: Kodi 17 compat removal cleanup
if password and not kodi_version() < 18:
control.setType(xbmcgui.INPUT_TYPE_PASSWORD, "Please enter password") control.setType(xbmcgui.INPUT_TYPE_PASSWORD, "Please enter password")
return control return control

View File

@ -33,7 +33,7 @@ def addon_id():
def kodi_version(): def kodi_version():
return xbmc.getInfoLabel('System.BuildVersion')[:2] return int(xbmc.getInfoLabel('System.BuildVersion').split('.')[0])
def window(key, value=None, clear=False, window_id=10000): def window(key, value=None, clear=False, window_id=10000):