Skip to content

Commit

Permalink
Merge pull request #207 from IntergalacticPenguin/version/1.1.0
Browse files Browse the repository at this point in the history
Version 1.1.0 - irecord, aemulator start fix
  • Loading branch information
IGPenguin authored Nov 3, 2020
2 parents b3cbb8a + f7206ab commit 9fc0458
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
🤔 **Check all before merging!**
- [ ] 📈[Project board](https://github.com/IntergalacticPenguin/mobile-toolkit/projects/1) up to date
🚨 **Check all before merging!**
- [ ] 🏗 Everything implemented thoroughly
- [ ] 🔨 All changes tested
- [ ] Change #1
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ _Note: This repository is mainly focused on macOS compatibility, but majority of
* Reboot the device

### 📱 aemulator
**Required**: Make terminal use Android Studio Java
* **Edit .bash_profile** (or .zshrc if you have zsh shell) `open -e ~/.bash_profile` or `open -e ~/.zshrc`
* **Add the following line at the end of the file** `export JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home'`

* Android emulator supports all listed scripts by default + extra actions listed below
* `aeimulator <option>` Handle various Android emulator activites
* `start` - choose and launch installed emulator
Expand All @@ -220,8 +224,11 @@ _Note: This repository is mainly focused on macOS compatibility, but majority of
* `iscreenshot -a` Take screenshot on all connected devices

### 🎥 irecord
* Run QuickTime and open video source picker (so you can choose a device right away)
* You may have to allow some system permission, so the script can access the picker
**Required**: Install [videosnap](https://github.com/matthutchinson/videosnap/releases "videosnap") -> download and run `videosnap-0.0.6.pkg`

1. `irecord` Record screen
2. End recording using `ctrl + c`
3. Save screen video footage to ~/Desktop

### 🖼 igif
**Required**: Install [ffmpeg](https://www.ffmpeg.org/ "ffmpeg") `brew install ffmpeg`
Expand Down
12 changes: 11 additions & 1 deletion android/aemulator
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ help(){
echo -e "Use one of the following options:\\n start - choose and launch installed emulator\\n gprs | edge | 3g - set network latency\\n call <number> - receive fake call\\n sms <number> <text> - recieve fake sms\\n gps <lat> <long> - set manual gps location\\n battery <0-100> - set manual battery level\\n telnet <command> - call telnet command (see README.md)"
}

check_java_dependency(){
if ! java -version &> /dev/null; then
echo "❌ Java not available, edit your .bash_profile or .zshrc to use Android Studio version"
echo "📝 Add the following line: export JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home'"
echo "🔌 Restart terminal afterwards"
exit 1
fi
}

check_running_emulator(){
if ! adb devices | grep emulator &> /dev/null; then
echo "❌ No running emulators"
Expand Down Expand Up @@ -64,7 +73,7 @@ launch_emulator(){
launch_emulator
else
echo "🚀 Launching emulator..."
nohup "$ANDROID_HOME"/tools/emulator -avd "$EMULATOR_NAME" -no-snapshot &> /dev/null &
nohup "$ANDROID_HOME"/emulator/emulator -avd "$EMULATOR_NAME" -no-snapshot &> /dev/null &
rm "$LOCAL_EMULATOR_LIST"
fi
}
Expand Down Expand Up @@ -163,6 +172,7 @@ disable_network_delay(){
}

check_for_update
check_java_dependency

case $1 in
'start')
Expand Down
7 changes: 5 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
🩹 fix iOS device pairing
🩹 fix Android emulator telnet authentication
✨ irecord now works using terminal only!
👏 special thanks to matthutchinson for his videosnap project
👀 see https://github.com/matthutchinson/videosnap
🩹 fix aemulator start for API 29+
🩹 check Java dependency while using aemulator
86 changes: 74 additions & 12 deletions ios/irecord
Original file line number Diff line number Diff line change
@@ -1,14 +1,76 @@
#!/bin/bash
echo "📹 Opening QuickTime..."

osascript <<EOD
tell application "QuickTime Player"
activate
set newMovieRecording to new movie recording
end tell
tell application "System Events" to tell process "QuickTime Player"
click button 3 of window 1
end tell
return
LOCATION=$(dirname "$0")
source "$LOCATION"/../common_tools
IOS_DEVICES_LIST=$LOCATION/../data/toolkit_recordable_ios_devices.txt
trap 'ctrlc $@' 1 2 3 6 15

RECORDING=false
cd ~/Desktop || exit

ctrlc(){
if $RECORDING ; then
echo "✅ Saved into ~/Desktop/$FILENAME"
fi
osascript -e 'quit app "QuickTime Player"'
exit
}

check_videosnap_dependency(){ #TODO refactor when videosnap available via Homberew
if ! [ -x "$(command -v "videosnap")" ]; then
echo "💥 \"videosnap\" command required!"
should_proceed "🛒 Install via GitHub? (download and run \"videosnap-0.0.6.pkg\")"
open "https://github.com/matthutchinson/videosnap/releases"
exit 1
fi
}

start_quicktime(){
echo "💡 Starting QuickTime to enable recording (webcam light might turn on)..."
osascript <<EOD
tell application "QuickTime Player"
set newMovieRecording to new movie recording
set miniaturized of window 1 to true
end tell
EOD
}

pick_recording_device(){
echo "⏳ Detecting iOS devices..."
rm -f "$IOS_DEVICES_LIST"
videosnap -l >> "$IOS_DEVICES_LIST"
grep -E -v "Found|FaceTime" "$IOS_DEVICES_LIST" > "$IOS_DEVICES_LIST.tmp" #remove info line and webcam
mv "$IOS_DEVICES_LIST.tmp" "$IOS_DEVICES_LIST"
sed 's/^* //g' "$IOS_DEVICES_LIST" > "$IOS_DEVICES_LIST.tmp" #remove "* " line prefixes
mv "$IOS_DEVICES_LIST.tmp" "$IOS_DEVICES_LIST"

if [ "$(nl "$IOS_DEVICES_LIST")" == "" ]; then
echo "❌ iOS device not detected, reconnect it and try again"
ctrlc
fi

if [ "$(wc -l "$IOS_DEVICES_LIST" | awk '{print $1}')" == "1" ]; then
DEVICE_NAME="$(cat "$IOS_DEVICES_LIST")"
else
echo "📱 Available:"
nl "$IOS_DEVICES_LIST"
read -r -p "📝 Choose: " DEVICE_INDEX

DEVICE_NAME=$(sed "$DEVICE_INDEX"!d "$IOS_DEVICES_LIST")
if [[ $DEVICE_INDEX == "" || $DEVICE_NAME == "" ]]; then
delete_lastline
pick_recording_device
fi
fi
}

start_recording(){
RECORDING=true
FILENAME="$DEVICE_NAME-$(date +%Y-%m-%d-%H-%M-%S).mp4"
echo "📹 Recording screen on $DEVICE_NAME, stop it with ctrl^c"
videosnap -w 0 -p High -d "$DEVICE_NAME" "$FILENAME" &> /dev/null
}

check_videosnap_dependency
start_quicktime
pick_recording_device
start_recording

0 comments on commit 9fc0458

Please sign in to comment.