Skip to content

Commit ac8fda0

Browse files
committed
Displace the touch in openNotification() to support tablets
1 parent beeadb4 commit ac8fda0

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/com/dtmilano/android/viewclient.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
'''
3-
Copyright (C) 2012-2014 Diego Torres Milano
3+
Copyright (C) 2012-2015 Diego Torres Milano
44
Created on Feb 2, 2012
55
66
Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,7 @@
1818
@author: Diego Torres Milano
1919
'''
2020

21-
__version__ = '10.0.5'
21+
__version__ = '10.0.6'
2222

2323
import sys
2424
import warnings
@@ -1107,9 +1107,10 @@ def openNotification(self):
11071107
Opens the notification shade.
11081108
'''
11091109

1110-
w2 = self.device.display['width'] / 2
1111-
s = (w2, 0)
1112-
e = (w2, self.device.display['height']/2)
1110+
# the tablets has a different Notification bar depending on x
1111+
w23 = 2 * self.device.display['width'] / 3
1112+
s = (w23, 0)
1113+
e = (w23, self.device.display['height']/2)
11131114
self.device.drag(s, e, 500, 20, -1)
11141115
self.vc.sleep(1)
11151116
self.vc.dump(-1)
@@ -1120,7 +1121,18 @@ def openQuickSettings(self):
11201121
'''
11211122

11221123
self.openNotification()
1123-
self.vc.findViewWithContentDescriptionOrRaise(u'''System settings''').touch()
1124+
# this works on API >= 20
1125+
view = self.vc.findViewWithContentDescription(u'''System settings''')
1126+
if view:
1127+
view.touch()
1128+
else:
1129+
# for previous APIs, let's find the text
1130+
view = self.vc.findViewWithText(u'''Settings''')
1131+
if view:
1132+
view.touch()
1133+
else:
1134+
raise ViewNotFoundException("content-description", "'System settings' or 'Settings'", "ROOT")
1135+
11241136
self.vc.sleep(1)
11251137
self.vc.dump(window=-1)
11261138

0 commit comments

Comments
 (0)