From db51abd786516b4106c609140ace181a1e653ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Sun, 31 May 2020 01:07:16 +0200 Subject: [PATCH] Add Kodi 17 backwards compat to #308 --- jellyfin_kodi/dialogs/loginmanual.py | 25 +++++++++++++++++-------- jellyfin_kodi/helper/utils.py | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/jellyfin_kodi/dialogs/loginmanual.py b/jellyfin_kodi/dialogs/loginmanual.py index c449a092..9f708cfd 100644 --- a/jellyfin_kodi/dialogs/loginmanual.py +++ b/jellyfin_kodi/dialogs/loginmanual.py @@ -8,6 +8,7 @@ from kodi_six import xbmcgui from helper import translate 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): - control = xbmcgui.ControlEdit(0, 0, 0, 0, - label="User", - font="font13", - textColor="FF00A4DC", - disabledColor="FF888888", - focusTexture="-", - noFocusTexture="-") + kwargs = dict( + label="User", + font="font13", + textColor="FF00A4DC", + disabledColor="FF888888", + focusTexture="-", + 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.setHeight(height) @@ -112,7 +120,8 @@ class LoginManual(xbmcgui.WindowXMLDialog): self.addControl(control) # 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") return control diff --git a/jellyfin_kodi/helper/utils.py b/jellyfin_kodi/helper/utils.py index 4b49a95d..9423d4cc 100644 --- a/jellyfin_kodi/helper/utils.py +++ b/jellyfin_kodi/helper/utils.py @@ -33,7 +33,7 @@ def addon_id(): 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):