forked from razzeee/script.trakt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
deviceAuthDialog.py
59 lines (45 loc) · 1.56 KB
/
deviceAuthDialog.py
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
import xbmcgui
import time
import xbmcaddon
from 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):
def __init__(self, xmlFile, resourcePath, code, url):
self.code = code
self.url = url
def onInit(self):
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):
if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK:
self.close()
def onControl(self, control):
pass
def onFocus(self, control):
pass
def onClick(self, control):
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()