|
34 | 34 | from com.dtmilano.android.keyevent import KEY_EVENT |
35 | 35 | from com.dtmilano.android.viewclient import ViewClient, View |
36 | 36 |
|
37 | | -__version__ = '21.11.1' |
| 37 | +__version__ = '21.11.2' |
38 | 38 |
|
39 | 39 | import sys |
40 | 40 | import threading |
@@ -142,6 +142,7 @@ class Operation: |
142 | 142 | SAY_TEXT = 'say_text' |
143 | 143 | SET_TEXT = 'set_text' |
144 | 144 | SNAPSHOT = 'snapshot' |
| 145 | + SNAPSHOT_UI_AUTOMATOR_HELPER = 'snapshot_ui_automator_helper' |
145 | 146 | START_ACTIVITY = 'start_activity' |
146 | 147 | START_ACTIVITY_UI_AUTOMATOR_HELPER = 'start_activity_ui_automator__helper' |
147 | 148 | SLEEP = 'sleep' |
@@ -1167,14 +1168,26 @@ def saveSnapshot(self): |
1167 | 1168 | Current snapshot is the image being displayed on the main window. |
1168 | 1169 | ''' |
1169 | 1170 |
|
1170 | | - filename = self.snapshotDir + os.sep + '${serialno}-${focusedwindowname}-${timestamp}' + '.' + self.snapshotFormat.lower() |
| 1171 | + filename = self.snapshotDir + os.sep + '${serialno}-${screenshot_number}-${focusedwindowname}-${timestamp}' + '.' + self.snapshotFormat.lower() |
1171 | 1172 | # We have the snapshot already taken, no need to retake |
1172 | 1173 | d = FileDialog(self, self.device.substituteDeviceTemplate(filename)) |
1173 | 1174 | saveAsFilename = d.askSaveAsFilename() |
1174 | 1175 | if saveAsFilename: |
1175 | 1176 | _format = os.path.splitext(saveAsFilename)[1][1:].upper() |
1176 | | - self.printOperation(None, Operation.SNAPSHOT, filename, _format, self.deviceArt, self.dropShadow, |
| 1177 | + if self.vc.uiAutomatorHelper: |
| 1178 | + # FIXME: we should use fields in this class instead of relying on device |
| 1179 | + # FIXME: the screenshot name is generated here and then no re-evaluation of variables take place |
| 1180 | + # when the generated script runs (i.e. if the serialno changes then the filenames will be wrong) |
| 1181 | + # Note that in the other case (no helper), the template is re-evaluated. |
| 1182 | + # Then, it may make more sense to have the template evaluation in ui_device.take_screenshot(). |
| 1183 | + _filename = self.device.substituteDeviceTemplate(filename) |
| 1184 | + self.printOperation(None, Operation.SNAPSHOT_UI_AUTOMATOR_HELPER, _filename, _format) |
| 1185 | + # FIXME: we increment here as we dont use device.takeSnapshot() which increments the count |
| 1186 | + self.device.screenshot_number += 1 |
| 1187 | + else: |
| 1188 | + self.printOperation(None, Operation.SNAPSHOT, filename, _format, self.deviceArt, self.dropShadow, |
1177 | 1189 | self.screenGlare) |
| 1190 | + |
1178 | 1191 | # FIXME: we should add deviceArt, dropShadow and screenGlare to the saved image |
1179 | 1192 | # self.unscaledScreenshot.save(saveAsFilename, _format, self.deviceArt, self.dropShadow, self.screenGlare) |
1180 | 1193 | self.unscaledScreenshot.save(saveAsFilename, _format) |
|
0 commit comments