Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9e95045
add support for OBB files
mortenjust Jan 21, 2016
b625e11
Update README.md
mortenjust Jan 21, 2016
c12cba3
fix bug in obb installer script
mortenjust Jan 22, 2016
51a16ce
fix bug in obb install script
mortenjust Jan 22, 2016
b5ed903
Merge branch 'master' of https://github.com/mortenjust/androidtool-mac
mortenjust Jan 22, 2016
118bcc6
adjust obb script for use from cocoa
mortenjust Jan 22, 2016
afb0746
add shortcut to open the terminal outputs window
mortenjust Jan 22, 2016
51a17aa
fix bug
mortenjust Jan 23, 2016
33ba792
Delete .DS_Store
dandv Apr 15, 2016
09d1a23
Fix screenRecFolder var
mriddle Jun 14, 2016
b3df3fa
unwrap optional gifUrl
mriddle Jun 14, 2016
58f1367
Merge pull request #92 from mriddle/convert-movie-file-to-gif-script-…
mortenjust Jul 27, 2016
269476c
Merge pull request #88 from dandv/patch-1
mortenjust Jul 27, 2016
3351b5d
Merge pull request #93 from mriddle/resolve-optional-bug-in-ios-recor…
mortenjust Jul 27, 2016
0006705
adjustment
mortenjust Jul 27, 2016
b3906d0
Change version code
mortenjust Jul 27, 2016
9714a18
Clean up Task class
muandrew Dec 18, 2017
aab7c1f
Clean up warnings
muandrew Dec 26, 2017
06cceb9
Automated Swift 2 to 3 Conversion by XCode 8.3.3
muandrew Dec 26, 2017
5264870
Add @escaping when needed.
muandrew Jan 10, 2018
5377794
Fix compilation warning/errors from Swift 2 to 3 automated migration.
muandrew Jan 10, 2018
d7f8f93
Use Recommended Project Configurations
muandrew Jan 10, 2018
1b8c694
Fix deprecation Warning
muandrew Jan 10, 2018
b727c76
Fix Crash when there is no device brand.
muandrew Jan 10, 2018
9fc699b
Merge pull request #137 from muandrew/twotothree
mortenjust Oct 1, 2018
d6a50e6
Delete README.md
K402601 Nov 19, 2020
beed1bb
Delete ShellTasker.swift
K402601 Nov 19, 2020
08f02f3
Delete project.pbxproj
K402601 Nov 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
762 changes: 0 additions & 762 deletions AndroidTool.xcodeproj/project.pbxproj

This file was deleted.

Binary file not shown.
Binary file modified AndroidTool/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion AndroidTool/Apk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Apk: NSObject {
parseRawInfo(rawAaptBadgingData)
}

func parseRawInfo(rawdata:String) {
func parseRawInfo(_ rawdata:String) {
print(">>apkparskeapkinfo")
let u = Util()
let apk = self
Expand Down
19 changes: 10 additions & 9 deletions AndroidTool/ApkHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Cocoa

protocol ApkHandlerDelegate {
func apkHandlerDidStart()
func apkHandlerDidGetInfo(apk:Apk)
func apkHandlerDidUpdate(update:String)
func apkHandlerDidGetInfo(_ apk:Apk)
func apkHandlerDidUpdate(_ update:String)
func apkHandlerDidFinish()
}

Expand All @@ -33,7 +33,7 @@ class ApkHandler: NSObject {
self.device = device
}

func installAndLaunch(complete:()->Void){
func installAndLaunch(_ complete:@escaping ()->Void){
delegate?.apkHandlerDidStart()
print(">>apkhandle")

Expand All @@ -46,19 +46,20 @@ class ApkHandler: NSObject {
}
}

func install(completion:()->Void){
func install(_ completion:@escaping ()->Void){
print(">>apkinstall")
delegate?.apkHandlerDidUpdate("Installing...")

if device.adbIdentifier == nil { print("no adbIdentifier, aborting"); return }
let s = ShellTasker(scriptFile: "installApkOnDevice")

s.run(arguments: [device.adbIdentifier!, filepath]) { (output) -> Void in
self.delegate?.apkHandlerDidUpdate("Installed")
completion()
}
}

func uninstallPackageWithName(packageName:String, completion:()->Void){
func uninstallPackageWithName(_ packageName:String, completion:@escaping ()->Void){
print(">>Uninstall")
delegate?.apkHandlerDidUpdate("Uninstalling app")
let s = ShellTasker(scriptFile: "uninstallPackageOnDevice")
Expand All @@ -70,7 +71,7 @@ class ApkHandler: NSObject {

}

func getInfoFromApk(complete:(Apk) -> Void){
func getInfoFromApk(_ complete:@escaping (Apk) -> Void){
print(">>apkgetinfofromapk")
delegate?.apkHandlerDidUpdate("Getting info...")

Expand All @@ -85,7 +86,7 @@ class ApkHandler: NSObject {
iconShell.run(arguments: [self.filepath]) { (output) -> Void in
print("Ready to add nsurl path to apk object: \(output)")

apk.localIconPath = (output as String).stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
apk.localIconPath = (output as String).trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)


complete(apk)
Expand All @@ -95,11 +96,11 @@ class ApkHandler: NSObject {
}


func launch(apk:Apk){
func launch(_ apk:Apk){
print(">>apklaunch")
delegate?.apkHandlerDidUpdate("Launching...")

if let packageName = apk.packageName, launcherActivity = apk.launcherActivity {
if let packageName = apk.packageName, let launcherActivity = apk.launcherActivity {

let ac = "\(packageName)/\(launcherActivity)"

Expand Down
94 changes: 54 additions & 40 deletions AndroidTool/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {

var masterViewController: MasterViewController!

func applicationDidFinishLaunching(aNotification: NSNotification) {
func applicationDidFinishLaunching(_ aNotification: Notification) {
updateScriptFilesInMenu()
checkForPreferences()


if #available(OSX 10.10, *) {
window.titlebarAppearsTransparent = true
window.styleMask = window.styleMask | NSFullSizeContentViewWindowMask;
window.styleMask.update(with: .fullSizeContentView);
} else {
// Fallback on earlier versions
}
window.movableByWindowBackground = true
window.isMovableByWindowBackground = true
window.title = ""

masterViewController = MasterViewController(nibName: "MasterViewController", bundle: nil)
Expand All @@ -40,18 +40,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
//masterViewController.view.frame = window.contentView.bounds

let insertedView = masterViewController.view
let containerView = window.contentView as NSView!
let containerView = window.contentView!

insertedView.translatesAutoresizingMaskIntoConstraints = false

let viewDict = ["inserted":insertedView, "container":containerView]
let viewConstraintH = NSLayoutConstraint.constraintsWithVisualFormat(
"H:|[inserted]|",
let viewDict: [String: Any] = ["inserted":insertedView, "container":containerView]
let viewConstraintH = NSLayoutConstraint.constraints(
withVisualFormat: "H:|[inserted]|",
options: NSLayoutFormatOptions(rawValue: 0),
metrics: nil,
views: viewDict)
let viewConstraintV = NSLayoutConstraint.constraintsWithVisualFormat(
"V:|[inserted]|",
let viewConstraintV = NSLayoutConstraint.constraints(
withVisualFormat: "V:|[inserted]|",
options: NSLayoutFormatOptions(rawValue: 0),
metrics: nil,
views: viewDict)
Expand All @@ -61,46 +61,51 @@ class AppDelegate: NSObject, NSApplicationDelegate {

}

func application(sender: NSApplication, openFile filename: String) -> Bool {
func application(_ sender: NSApplication, openFile filename: String) -> Bool {
print("opening \(filename). If it's an APK we'll show a list of devices")
masterViewController.installApk(filename)
return true
}

@IBAction func revealFolderClicked(sender: NSMenuItem) {
@IBAction func revealFolderClicked(_ sender: NSMenuItem) {
Util().revealScriptsFolder()

}


func checkForPreferences(){
let ud = NSUserDefaults.standardUserDefaults()
ud.registerDefaults(Constants.defaultPrefValues)
let ud = UserDefaults.standard
ud.register(defaults: Constants.defaultPrefValues)

if ud.string(forKey: C.PREF_SCREENSHOTFOLDER) == "" {
ud.set(NSString(string: "~/Desktop/AndroidTool").expandingTildeInPath, forKey: C.PREF_SCREENSHOTFOLDER)
}
if ud.string(forKey: C.PREF_SCREENRECORDINGSFOLDER) == "" {
ud.set(NSString(string: "~/Desktop/AndroidTool").expandingTildeInPath, forKey: C.PREF_SCREENRECORDINGSFOLDER)
}


let bitratePref = ud.doubleForKey("bitratePref")
let scalePref = ud.doubleForKey("scalePref")
let timeValuePref = ud.stringForKey("timeValue")
let dataTypePref = ud.stringForKey("dataType")

let bitratePref = ud.double(forKey: "bitratePref")
let scalePref = ud.double(forKey: "scalePref")
let timeValuePref = ud.string(forKey: "timeValue")
let dataTypePref = ud.string(forKey: "dataType")


print("bit: \(bitratePref)")

if timeValuePref == "" {
ud.setObject(Constants.defaultPrefValues["timeValue"], forKey: "timeValue")
ud.set(Constants.defaultPrefValues["timeValue"], forKey: "timeValue")
}

if dataTypePref == "" {
ud.setObject(Constants.defaultPrefValues["dataType"], forKey: "dataType")
ud.set(Constants.defaultPrefValues["dataType"], forKey: "dataType")
}

if bitratePref == 0.0 {
ud.setDouble(Double(3025000), forKey: "bitratePref")
ud.set(Double(3025000), forKey: "bitratePref")
}

if scalePref == 0.0 {
ud.setDouble(1, forKey: "scalePref")
ud.set(1, forKey: "scalePref")
}

}
Expand All @@ -112,10 +117,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func updateScriptFilesInMenu(){
scriptsMenu.removeAllItems()

let screenshotItem = NSMenuItem(title: "Screenshots", action: "screenshotsOfAllTapped:", keyEquivalent: "S")
let sepItem = NSMenuItem.separatorItem()
let sepItem2 = NSMenuItem.separatorItem()
let revealFolderItem = NSMenuItem(title: "Reveal Scripts Folder", action: "revealFolderClicked:", keyEquivalent: "F")
let screenshotItem = NSMenuItem(
title: "Screenshots",
action: #selector(screenshotsOfAllTapped),
keyEquivalent: "S")
let sepItem = NSMenuItem.separator()
let sepItem2 = NSMenuItem.separator()
let revealFolderItem = NSMenuItem(
title: "Reveal Scripts Folder",
action: #selector(revealFolderClicked),
keyEquivalent: "F")

scriptsMenu.addItem(screenshotItem)
scriptsMenu.addItem(sepItem)
Expand All @@ -131,23 +142,26 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if i<10 {
keyEq = "\(i)"
}
let scriptItem = NSMenuItem(title: scriptFile.stringByReplacingOccurrencesOfString(".sh", withString: ""), action: "runScript:", keyEquivalent: keyEq)
let scriptItem = NSMenuItem(
title: scriptFile.replacingOccurrences(of: ".sh", with: ""),
action: #selector(runScript),
keyEquivalent: keyEq)
scriptsMenu.addItem(scriptItem)
i++
}
i += 1
}

scriptsMenu.addItem(sepItem2)
scriptsMenu.addItem(revealFolderItem)
}

func runScript(sender:NSMenuItem){
func runScript(_ sender:NSMenuItem){
Util().stopRefreshingDeviceList()
let scriptPath = "\(Util().getSupportFolderScriptPath())/\(sender.title).sh"
print("ready to run \(scriptPath) on all Android devices")

let deviceVCs = masterViewController.deviceVCs
for deviceVC in deviceVCs {
if deviceVC.device.deviceOS == DeviceOS.Android {
if deviceVC.device.deviceOS == DeviceOS.android {
let adbIdentifier = deviceVC.device.adbIdentifier!
deviceVC.startProgressIndication()
ShellTasker(scriptFile: scriptPath).run(arguments: ["\(adbIdentifier)"], isUserScript: true) { (output) -> Void in
Expand All @@ -159,7 +173,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Util().restartRefreshingDeviceList()
}

@IBAction func screenshotsOfAllTapped(sender: NSMenuItem) { // TODO:clicked, not tapped
@IBAction func screenshotsOfAllTapped(_ sender: NSMenuItem) { // TODO:clicked, not tapped
Util().stopRefreshingDeviceList()
let deviceVCs = masterViewController.deviceVCs
for deviceVC in deviceVCs {
Expand All @@ -168,24 +182,24 @@ class AppDelegate: NSObject, NSApplicationDelegate {
Util().restartRefreshingDeviceList()
}

func applicationWillResignActive(notification: NSNotification) {
func applicationWillResignActive(_ notification: Notification) {
masterViewController.discoverer.updateInterval = 120
}

@IBAction func rawWindowClicked(sender: AnyObject) {
@IBAction func rawWindowClicked(_ sender: AnyObject) {
rawOutputWindowController = RawOutputWindowController(windowNibName: "RawOutputWindowController")
rawOutputWindowController.showWindow(sender)
}

@IBAction func refreshDeviceListClicked(sender: NSMenuItem) {
@IBAction func refreshDeviceListClicked(_ sender: NSMenuItem) {
masterViewController.discoverer.pollDevices()
}

@IBAction func showLogFileClicked(sender: NSMenuItem) {
@IBAction func showLogFileClicked(_ sender: NSMenuItem) {

}

@IBAction func preferencesClicked(sender: NSMenuItem) {
@IBAction func preferencesClicked(_ sender: NSMenuItem) {
print("pref")
preferencesWindowController = PreferencesWindowController(windowNibName: "PreferencesWindowController")
preferencesWindowController.showWindow(sender)
Expand All @@ -194,7 +208,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {



func applicationDidBecomeActive(notification: NSNotification) {
func applicationDidBecomeActive(_ notification: Notification) {
// Util().restartRefreshingDeviceList()

if masterViewController == nil {
Expand All @@ -207,7 +221,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {

}

func applicationWillTerminate(aNotification: NSNotification) {
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

Expand Down
8 changes: 3 additions & 5 deletions AndroidTool/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="15B42" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment version="1090" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand Down Expand Up @@ -301,8 +301,7 @@
<action selector="refreshDeviceListClicked:" target="Voe-Tx-rLC" id="XNy-ci-Wkz"/>
</connections>
</menuItem>
<menuItem title="Terminal output" id="kyM-1r-6aa">
<modifierMask key="keyEquivalentModifierMask"/>
<menuItem title="Terminal output" keyEquivalent="O" id="kyM-1r-6aa">
<connections>
<action selector="rawWindowClicked:" target="Voe-Tx-rLC" id="SEy-2p-8z2"/>
</connections>
Expand Down Expand Up @@ -352,7 +351,6 @@
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="373" height="147"/>
<autoresizingMask key="autoresizingMask"/>
<animations/>
</view>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
Expand Down
12 changes: 6 additions & 6 deletions AndroidTool/CameraButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class CameraButton: NSButton {
unregisterDraggedTypes()
}

override func draggingEntered(sender: NSDraggingInfo) -> NSDragOperation {
return NSDragOperation.Copy
override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
return NSDragOperation.copy
}

override func draggingUpdated(sender: NSDraggingInfo) -> NSDragOperation {
return NSDragOperation.Copy
override func draggingUpdated(_ sender: NSDraggingInfo) -> NSDragOperation {
return NSDragOperation.copy
}

override func drawRect(dirtyRect: NSRect) {
super.drawRect(dirtyRect)
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)

// Drawing code here.
}
Expand Down
12 changes: 7 additions & 5 deletions AndroidTool/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ class Constants {
static let NOTIF_COMMANDVERBOSE = "mj.commandVerbose"
static let DROP_INVITE = "Drop a ZIP or APK prototype"
static let PREF_SCREENSHOTFOLDER = "screenshotsFolder"
static let PREF_SRCEENRECORDINGSFOLDER = "screenRecordingsFolder"
static let PREF_SCREENRECORDINGSFOLDER = "screenRecordingsFolder"
static let PREF_USEACTIVITYINFILENAME = "useActivityInFilename"
static let PREF_LAUNCHINSTALLEDAPP = "launchInstalledApp"
static let PREF_FLASHIMAGESINZIPFILES = "flashImagesInZipFiles"
static let PREF_GENERATEGIF = "generateGif"


static let defaultPrefValues = [
Expand All @@ -29,13 +30,14 @@ class Constants {
,"batteryLevel": "100%"
,"mobileLevel" : "4 bars"
,"verboseOutput" : false
,"screenRecordingsFolder": "~/Desktop/AndroidTool"
,"screenshotsFolder": "~/Desktop/AndroidTool"
,"screenRecordingsFolder": ""
,"screenshotsFolder": ""
,"createGIF": true
,"useActivityInFilename":true
,"launchInstalledApp":true
,"flashImagesInZipFiles":true
]
,"flashImagesInZipFiles":false
,"generateGif":false
] as [String : Any]

static let tweakProperties = ["bluetooth", "clock", "alarm", "sync", "wifi", "location", "volume", "mute", "notifications", "mobile", "mobileDatatype", "mobileLevel", "batteryLevel", "batteryCharging", "airplane", "nosim", "speakerphone"]

Expand Down
Loading