-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathdeviceAuthDialog.py
More file actions
62 lines (48 loc) · 1.74 KB
/
deviceAuthDialog.py
File metadata and controls
62 lines (48 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import xbmcgui
import time
import xbmcaddon
from resources.lib.kodiUtilities import notification, setSetting, getString
import logging
__addon__ = xbmcaddon.Addon("script.trakt")
LATER_BUTTON = 201
NEVER_BUTTON = 202
ACTION_PREVIOUS_MENU = 10
ACTION_BACK = 92
INSTRUCTION_LABEL = 203
AUTHCODE_LABEL = 204
WARNING_LABEL = 205
CENTER_Y = 6
CENTER_X = 2
logger = logging.getLogger(__name__)
class DeviceAuthDialog(xbmcgui.WindowXMLDialog):
code: str
url: str
def __init__(self, xmlFile: str, resourcePath: str, code: str, url: str) -> None:
self.code = code
self.url = url
def onInit(self) -> None:
instuction = self.getControl(INSTRUCTION_LABEL)
authcode = self.getControl(AUTHCODE_LABEL)
warning = self.getControl(WARNING_LABEL)
instuction.setLabel(
getString(32159).format("[COLOR red]" + self.url + "[/COLOR]")
)
authcode.setLabel(self.code)
warning.setLabel(getString(32162))
def onAction(self, action: xbmcgui.Action) -> None:
if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK:
self.close()
def onControl(self, control: xbmcgui.Control) -> None:
pass
def onFocus(self, control: xbmcgui.Control) -> None:
pass
def onClick(self, control: xbmcgui.Control) -> None:
logger.debug("onClick: %s" % (control))
if control == LATER_BUTTON:
notification(getString(32157), getString(32150), 5000)
setSetting("last_reminder", str(int(time.time())))
if control == NEVER_BUTTON:
notification(getString(32157), getString(32151), 5000)
setSetting("last_reminder", "-1")
if control in [LATER_BUTTON, NEVER_BUTTON]:
self.close()