forked from mmcc007/screenshots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mmcc007#88 from mmcc007/#66_landscape_mode
Added landscape feature
- Loading branch information
Showing
17 changed files
with
515 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
on run argv | ||
my do_submenu("Simulator", "Hardware", "Orientation", item 1 of argv) | ||
return item 1 of argv | ||
end run | ||
|
||
on do_submenu(app_name, menu_name, menu_item, submenu_item) | ||
try | ||
-- bring the target application to the front | ||
tell application app_name | ||
activate | ||
end tell | ||
tell application "System Events" | ||
tell process app_name | ||
tell menu bar 1 | ||
tell menu bar item menu_name | ||
tell menu menu_name | ||
tell menu item menu_item | ||
tell menu menu_item | ||
click menu item submenu_item | ||
end tell | ||
end tell | ||
end tell | ||
end tell | ||
end tell | ||
end tell | ||
end tell | ||
return true | ||
on error error_message | ||
return false | ||
end try | ||
end do_submenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'globals.dart'; | ||
import 'utils.dart' as utils; | ||
import 'run.dart' as run; | ||
|
||
enum Orientation { Portrait, LandscapeRight, PortraitUpsideDown, LandscapeLeft } | ||
|
||
/// Change orientation of a running emulator or simulator. | ||
/// (No known way of supporting real devices.) | ||
void changeDeviceOrientation(DeviceType deviceType, Orientation orientation, | ||
{String deviceId, String scriptDir}) { | ||
final androidOrientations = { | ||
'Portrait': '0', | ||
'LandscapeRight': '1', | ||
'PortraitUpsideDown': '2', | ||
'LandscapeLeft': '3' | ||
}; | ||
final iosOrientations = { | ||
'Portrait': 'Portrait', | ||
'LandscapeRight': 'Landscape Right', | ||
'PortraitUpsideDown': 'Portrait Upside Down', | ||
'LandscapeLeft': 'Landscape Left' | ||
}; | ||
const sim_orientation_script = 'sim_orientation.scpt'; | ||
final _orientation = utils.getStringFromEnum(orientation); | ||
print('Setting orientation to $_orientation'); | ||
switch (deviceType) { | ||
case DeviceType.android: | ||
run.cmd('adb', [ | ||
'-s', | ||
deviceId, | ||
'shell', | ||
'settings', | ||
'put', | ||
'system', | ||
'user_rotation', | ||
androidOrientations[_orientation] | ||
]); | ||
break; | ||
case DeviceType.ios: | ||
// requires permission when run for first time | ||
run.cmd( | ||
'osascript', | ||
['$scriptDir/$sim_orientation_script', iosOrientations[_orientation]], | ||
'.', | ||
true); | ||
break; | ||
} | ||
} | ||
|
||
Orientation getOrientationEnum(String orientation) { | ||
final _orientation = | ||
utils.getEnumFromString<Orientation>(Orientation.values, orientation); | ||
_orientation == null | ||
? throw 'Error: orientation \'$orientation\' not found' | ||
: null; | ||
return _orientation; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.