if [ ! -e "/var/mobile/Media/FFaac-Settings" ];
then
mkdir "/var/mobile/Media/FFaac-Settings"
chown mobile:mobile "/var/mobile/Media/FFaac-Settings"
fi

echo "
88888 88888                  
88    88    eeeee eeeee eeee 
8eeee 8eeee 8   8 8   8 8  8 
88    88    8eee8 8eee8 8   
88    88    88  8 88  8 8   
88    88    88  8 88  8 88e8 

###	   #   #  #
#          #   # 
###  #### ### ### # ### ### ####
  #  # #   #   #  # # # # #   #
###  ####  ##  ## # # # ### ####
			  #
			###
"
sleep 2


while true
do
read -p "
FIX - Type \"FIX\" (all capital letters) to fix FFaac if errors occurr
0 - Exit Settings
1 - Turn on/off Twitter Dialogue
2 - Turn on/off asking for MP3 conversion
3 - Turn on/off asking for mail
4 - Turn on/off asking for other software
5 - Turn on/off asking to cut
6 - More programs by me in Cydia
7 - Donate (so I have music and food for more coding)
8 - Exit and run FFaac
9 - Reset all settings to default
m - ---More options---

Choice: " choice

if [ "$choice" = "m" ];
then
clear
read -p "
10 - Turn on/off asking for MP3-quality and set a default
11 - Turn on/off asking for AAC-deletion
12 - Always make all AACs MP3 when MP3-conversion is chosen
13 - Reset \"Don't Ask Me Again\"-list
14 - Put converted files on the \"Don't Ask Me Again\"-list
15 - Toggle taking the title from filename
16 - Turn on/off creation of folders for albums
17 - Turn on/off the sound at the end of MP3-conversion
m  - ---More options---
b  - ---Back to first option menu---

Choice: " choice
fi

if [ "$choice" = "m" ];
then
clear
read -p "
18 - Turn on/off the MxTube safety feature
19 - Turn on/off the downloading of lyrics and covers
20 - Set a default genre (FFaac/Empty)
21 - Reset your self-created YourTube-List
22 - Always take the title from database for YourTube-conversions
23 - Toggle popups when processing MP3s
24 - Turn MxTube/YourTube importing off
CR - Display credits
b  - ---Back to first option menu---

Choice: " choice
fi
if [ "$choice" = "FIX" ];
then
choice=9
fi

if [ "$choice" = "exit" ];
then
exit
fi

if [ "$choice" = "21" ];
then
clear
read -p "Really reset this list? (y/n): " resetyourtubelist
	if [ "$resetyourtubelist" = "y" ];
	then
	rm -f /var/mobile/Media/YourTubeFileNames
	fi
fi

if [ "$choice" = "CR" ];
then
clear
echo "Thanks to:
-Erica Sadun for EricaUtils
-@marqueedragon for his idea of cutting songendings
-Dylan Parrish for YourTube import help and beta-testing
-Yonas Yanfa for compiling FFmpeg for the iPhone
-Saurik for Cydia, Core Utilities, gawk, sget and sed
-Sherif_hashim and planetbeing for their constant work on the baseband
-My friends and family, who are constantly testing for bugs
-mxweas for creating MxTube
-poetic_folly for creating YourTube
-Optimo from BigBoss for constantly keeping up with my updates

Huge props to The iPhone Dev Team, Chronic-Dev Team, @comex and ih8sn0w 
for constantly showing what your 600€ device is capable of.

This will be displayed for 15 seconds and return to the main menu"


sleep 15
fi



if [ "$choice" = "23" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/dontalertme ];
	then
	read -p "Currently FFaac will not ask you for popup hints. Turn it on? (y/n) " dontalertme
		if [ "$dontalertme" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/dontalertme
		clear
		echo "
Turned on."
		fi
	else
		if [ -e /var/mobile/Media/FFaac-Settings/alwaysalertme ];
		then
		read -p "Currently FFaac will always show popup hints. Turn it off? (y/n) " alwaysalertme
			if [ "$alwaysalertme" = "y" ];
			then
			rm -f /var/mobile/Media/FFaac-Settings/alwaysalertme
			clear
			echo "
Turned off."
			fi
		else
		read -p "Currently FFaac asks you for popup hints. Turn it off? (y/n) " dontalertme
			if [ "$dontalertme" = "y" ];
			then
			while true
			do
			read -p "Always show popups or never? ([a]lways/[n]ever): " alwaysnever
				if [ "$alwaysnever" = "n" ];
				then
				touch /var/mobile/Media/FFaac-Settings/dontalertme
				chown mobile:mobile /var/mobile/Media/FFaac-Settings/dontalertme
				clear
				echo "
Turned off."
				break
				fi
				if [ "$alwaysnever" = "a" ];
				then
				touch /var/mobile/Media/FFaac-Settings/alwaysalertme
				chown mobile:mobile /var/mobile/Media/FFaac-Settings/alwaysalertme
				clear
				echo "
Turned on."
				break
				fi
				if [ "$alwaysnever" != "a" ] && [ "$alwaysnever" != "n" ];
				then
				echo "
Please use either a or n
"
				fi
			done
			fi
		fi
	fi
fi

if [ "$choice" = "22" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/yourtitlenames ];
	then
	read -p "Currently FFaac's YourTube-conversion will always take it's MP3-filenames from the database. Turn it off? (y/n) " yourtitlenames
		if [ "$yourtitlenames" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/yourtitlenames
		clear
		echo "
Turned off."
		fi
	else
	read -p "Currently FFaac's YourTube-conversion will always take it's MP3-filenames from your input. Tell it to take titles from database? (y/n) " yourtitlenames
		if [ "$yourtitlenames" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/yourtitlenames
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/yourtitlenames
		clear
		echo "
Taking titles from database."
		fi
	fi
fi

if [ "$choice" = "24" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/disableanimport ];
	then
	read -p "Currently FFaac's $(cat /var/mobile/Media/FFaac-Settings/disableanimport)-Import is turned off. Turn it on? (y/n) " disableanimport
		if [ "$disableanimport" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/disableanimport
		clear
		echo "
Turned on both imports."
		fi
	else
	read -p "Currently FFaac will check for both MxTube and YourTube. Disable either? (y/n) " disableanimport
		if [ "$disableanimport" = "y" ];
		then
		read -p "Which one to disable? ([m]xTube/[y]ourTube) " disableanimport
			if [ "$disableanimport" = "m" ];
			then
			echo MxTube > /var/mobile/Media/FFaac-Settings/disableanimport
			chown mobile:mobile /var/mobile/Media/FFaac-Settings/disableanimport
			clear
			echo "
Disabled importing from MxTube"
			fi
			if [ "$disableanimport" = "y" ];
			then
			echo YourTube > /var/mobile/Media/FFaac-Settings/disableanimport
			chown mobile:mobile /var/mobile/Media/FFaac-Settings/disableanimport
			clear
			echo "
Disabled importing from YourTube"
			fi
		fi
	fi
fi


if [ "$choice" = "19" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/nolyrics ];
	then
	read -p "Downloading of lyrics and covers is currently turned to \"never\". Turn it to \"asking\"? (y/n) " nolyrics
		if [ "$nolyrics" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/nolyrics
		clear
		echo "
Turned to \"asking\"."
		fi
	else
		if [ -e /var/mobile/Media/FFaac-Settings/alwayslyrics ];
		then
		read -p "Downloading of lyrics and covers is currently turned to \"always\". Turn it to \"asking\"? (y/n) " nolyrics
				if [ "$nolyrics" = "y" ];
				then
				rm -f /var/mobile/Media/FFaac-Settings/alwayslyrics
				clear
				echo "
Turned to \"asking\"."
				fi
		else
			if [ ! -e /var/mobile/Media/FFaac-Settings/nolyrics ] && [ ! -e /var/mobile/Media/FFaac-Settings/alwayslyrics ];
			then
			read -p "Downloading of lyrics and covers is currently turned to \"asking\".Turn it to \"always\"/\"never\"? (a/n) " nolyrics
				if [ "$nolyrics" = "n" ];
				then
				touch /var/mobile/Media/FFaac-Settings/nolyrics
				chown mobile:mobile /var/mobile/Media/FFaac-Settings/nolyrics
				clear
				echo "
Turned to \"never\"."
				fi
				if [ "$nolyrics" = "a" ];
				then
				touch /var/mobile/Media/FFaac-Settings/alwayslyrics
				chown mobile:mobile /var/mobile/Media/FFaac-Settings/alwayslyrics
				clear
				echo "
Turned to \"always\"."
				fi
			fi
		fi
	fi
fi

if [ "$choice" = "18" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/mxtubesafety ];
	then
	read -p "The MxTube safety feature makes sure your MxTube imported files go back to it's original folder, even if your conversion ended early because of a terminal crash or you pressing \"ctrl+c\". It's currently turned off. Turn it on? (y/n) " mxtubesafety
		if [ "$mxtubesafety" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/mxtubesafety
		clear
		echo "
Turned on."
		fi
	else
	read -p "The MxTube safety feature makes sure your MxTube imported files go back to it's original folder, even if your conversion ended early because of a terminal crash or you pressing \"ctrl+c\". It's currently turned on. Turn it off? (y/n) " mxtubesafety
		if [ "$mxtubesafety" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/mxtubesafety
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/mxtubesafety
		clear
		echo "
Turned off."
		fi
	fi
fi

if [ "$choice" = "20" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/genre ];
	then
	read -p "The current default genre is \"FFaac\". This option will turn the default genre to empty. Toggle? (y/n) " genre
		if [ "$genre" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/genre
		clear
		echo "
Default genre: Empty."
		fi
	else
	read -p "The current default genre is empty. This option will turn the default genre to \"FFaac\". Toggle? (y/n) " genre
		if [ "$genre" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/genre
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/genre
		clear
		echo "
Default genre: FFaac."
		fi
	fi
fi



if [ "$choice" = "17" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/sound ];
	then
	read -p "The conversion-complete-sound is currently turned off. Turn it on? (y/n) " sound
		if [ "$sound" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/sound
		clear
		echo "
Turned on."
		fi
	else
	read -p "The conversion-complete-sound is currently turned on. Turn it off? (y/n) " sound
		if [ "$sound" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/sound
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/sound
		clear
		echo "
Turned off."
		fi
	fi
fi

if [ "$choice" = "16" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/createfolders ];
	then
	read -p "Creating folders for albums is currently turned off. Turn it on? (y/n) " createfolders
		if [ "$createfolders" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/createfolders
		clear
		echo "
Turned on."
		fi
	else
	read -p "Creating folders for albums is currently turned on. Turn it off? (y/n) " createfolders
		if [ "$createfolders" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/createfolders
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/createfolders
		clear
		echo "
Turned off."
		fi
	fi
fi


if [ "$choice" = "14" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/dontaskmeputtage ];
	then
	read -p "Putting converted files on the \"Don't Ask Me Again\"-list is currently turned on. Turn it off? (y/n) " dontaskmeputtage
		if [ "$dontaskmeputtage" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/dontaskmeputtage
		clear
		echo "
Turned off."
		fi
	else
	read -p "Putting converted files on the \"Don't Ask Me Again\"-list is currently turned off. Turn it on? (y/n) " dontaskmeputtage
		if [ "$dontaskmeputtage" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/dontaskmeputtage
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/dontaskmeputtage
		clear
		echo "
Turned on."
		fi
	fi
fi

if [ "$choice" = "15" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/titlefromnameoff ];
	then
	read -p "Querying for taking MP3 titles from filenames is currently turned off. Turn it on? (y/n) " titlefromnameoff
		if [ "$titlefromnameoff" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/titlefromnameoff
		clear
		echo "
Turned on."
		fi
	else
	read -p "Querying for taking MP3 titles from filenames is currently turned on. Turn it off? (y/n) " titlefromnameoff
		if [ "$titlefromnameoff" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/titlefromnameoff
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/titlefromnameoff
		clear
		echo "
Turned off."
		fi
	fi
fi

if [ "$choice" = "12" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/makeallmp3 ];
	then
	read -p "Making all AACs MP3s is currently turned on. Turn it off? (y/n) " makeallmp3
		if [ "$makeallmp3" = "y" ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/makeallmp3
		clear
		echo "
Turned off."
		fi
	else
	read -p "Making all AACs MP3s is currently turned off. Turn it on? (y/n) " makeallmp3
		if [ "$makeallmp3" = "y" ];
		then
		touch /var/mobile/Media/FFaac-Settings/makeallmp3
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/makeallmp3
		clear
		echo "
Turned on."
		fi
	fi
fi

if [ "$choice" = "13" ];
then
	if [ -e /var/mobile/Media/DontAskMe ];
	then
	read -p "ARE YOU SURE YOU WANT TO DO THIS? THIS WILL REMOVE THE LIST !!IRRECOVERABLY!! (y/n) " remdontask
		if [ "$remdontask" = "y" ];
		then
		rm -f /var/mobile/Media/DontAskMe
		clear
		echo "\"Don't Ask Me Again\"-list removed."
		else
		echo "\"Don't Ask Me Again\"-list not removed."
		fi
	else
	clear
	echo "There is not such list for you, yet."
	sleep 1
	fi
fi	

if [ "$choice" = "11" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/deleteaac ];
	then
	read -p "Asking for AAC-deletion upon converting to MP3 is currently turned off. Turn it on? (y/n) " delaac
		if [ $delaac = y ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/deleteaac
		clear
		echo "
Turned on."
		fi
	else
	read -p "Asking for AAC-deletion upon converting to MP3 is currently turned on. Turn it off? (y/n) " delaac
		if [ $delaac = y ];
		then
		touch /var/mobile/Media/FFaac-Settings/deleteaac
		clear
		echo "
Turned off."
		fi
	fi
fi

if [ "$choice" = "10" ];
then
	if [ -e /var/mobile/Media/FFaac-Settings/quality ];
	then
	read -p "Asking for MP3-Quality is currently turned off, turn it on? (y/n) " qual
		if [ $qual = y ];
		then
		rm -f /var/mobile/Media/FFaac-Settings/quality
		clear
		echo "
Turned on."
		else
		echo "
Turned off."
		fi
	else
	read -p "Asking for MP3-Quality is currently turned on, turn it off? (y/n) " qual
		if [ $qual = y ];
		then
		read -p "Which should be standard quality, normal or high? (n/h) " standqual
			if [ $standqual != n ] && [ $standqual != h ];
			then
			clear
			echo "Please enter \"n\" or \"h\", exiting."
			else
				if [ $standqual = n ];
				then
				echo "normal" > /var/mobile/Media/FFaac-Settings/quality
				chown mobile:mobile /var/mobile/Media/FFaac-Settings/quality
				clear
				echo "
Turned off. Default quality: Normal"
				sleep 1
				fi
				if [ $standqual = h ];
				then
				echo "high" > /var/mobile/Media/FFaac-Settings/quality
				chown mobile:mobile /var/mobile/Media/FFaac-Settings/quality
				clear
				echo "
Turned off. Default quality: High"
				sleep 1
				fi
			fi
		fi
	fi
fi


if [ "$choice" = "0" ];
then
clear
echo "
Bye."
exit
fi

if [ "$choice" = "8" ];
then
clear
echo "
Bye."
break
fi

if [ "$choice" = "9" ];
then
	if [ "$(whoami)" != "root" ];
	then
	read -p "You're not root, it could be possible, that some files can't be removed in this process. Are you sure you want to continue? (y/n) " sureroot
		if [ "$sureroot" = "y" ];
		then
		read -p "
--------WARNING--------
YOU'RE ABOUT TO RESET
ALL YOUR PRECIOUS FFAAC
       SETTINGS
-----------------------

Are you sure you want to reset all your settings? (y/n) " reset
			if [ "$reset" = "y" ];
			then
			find /var/mobile/Media/FFaac-Settings/ -type f | while read i
			do
			rm -f "$i"
			done
				if [ -e /var/mobile/Media/FFaac.sureidontwannatweet ];
				then
				rm -f /var/mobile/Media/FFaac.sureidontwannatweet
				fi
			rm -f /var/mobile/Media/YourTubeFileNames
			read -p "Also delete your \"Don't Ask Me\"-list? (STRONGLY RECOMMENDED IF ERRORS OCCURR) (y/n) " remdontask
				if [ "$remdontask" = "y" ];
				then
				rm -f /var/mobile/Media/DontAskMe
				clear
				echo "\"Don't Ask Me Again\"-list removed."
				else
				echo "\"Don't Ask Me Again\"-list not removed."
				fi
			clear
			exit
			fi
		fi
	else
		read -p "
--------WARNING--------
YOU'RE ABOUT TO RESET
ALL YOUR PRECIOUS FFAAC
       SETTINGS
-----------------------

Are you sure you want to reset all your settings? (y/n) " reset
			if [ "$reset" = "y" ];
			then
			find /var/mobile/Media/FFaac-Settings/ -type f | while read i
			do
			rm -f "$i"
			done
				if [ -e /var/mobile/Media/FFaac.sureidontwannatweet ];
				then
				rm -f /var/mobile/Media/FFaac.sureidontwannatweet
				fi
			rm -f /var/mobile/Media/YourTubeFileNames
			read -p "Also delete your \"Don't Ask Me\"-list? (STRONGLY RECOMMENDED IF ERRORS OCCURR) (y/n) " remdontask
				if [ "$remdontask" = "y" ];
				then
				rm -f /var/mobile/Media/DontAskMe
				clear
				echo "\"Don't Ask Me Again\"-list removed."
				else
				echo "\"Don't Ask Me Again\"-list not removed."
				fi
			clear
			exit
			fi
	fi
fi

if [ "$choice" = "1" ];
then
	if [ -e /var/mobile/Media/FFaac.sureidontwannatweet ];
	then
	read -p "The Twitter dialogue is currently turned off. Turn it on? (y/n) " twiton
		if [ "$twiton" = "y" ];
		then
		clear
		echo "
Turned on."
		sleep 1
		rm -f /var/mobile/Media/FFaac.sureidontwannatweet
		fi
	else
	read -p "The Twitter dialogue is currently turned on. Turn it off? (y/n) " twitoff
		if [ "$twitoff" = "y" ];
		then
		clear
		echo "
Turned off."
		sleep 1
		echo "Turned off by settings." > /var/mobile/Media/FFaac.sureidontwannatweet
		chown mobile:mobile /var/mobile/Media/FFaac.sureidontwannatweet
		fi
	fi
fi

if [ "$choice" = "2" ];
then
	if [ -e "/var/mobile/Media/FFaac-Settings/mp3off" ];
	then
	read -p "Asking for MP3 conversion is currently turned off. Turn it on? (y/n) " mp3on
		if [ "$mp3on" = "y" ];
		then
		clear
		echo "
Turned on."
		sleep 1
		rm -f /var/mobile/Media/FFaac-Settings/mp3off
		fi
	else
	read -p "Asking for MP3 conversion is currently turned on. Turn it off? (y/n) " mp3off
		if [ "$mp3off" = "y" ];
		then
		clear
		echo "
Turned off."
		sleep 1
		touch /var/mobile/Media/FFaac-Settings/mp3off
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/mp3off
		fi
	fi
fi

if [ "$choice" = "3" ];
then
	if [ -e "/var/mobile/Media/FFaac-Settings/mailoff" ];
	then
	read -p "Asking for mail is currently turned off. Turn it on? (y/n) " mailon
		if [ "$mailon" = "y" ];
		then
		clear
		echo "
Turned on."
		sleep 1
		rm -f /var/mobile/Media/FFaac-Settings/mailoff
		fi
	else
	read -p "Asking for mail is currently turned on. Turn it off? (y/n) " mailoff
		if [ "$mailoff" = "y" ];
		then
		clear
		echo "
Turned off."
		sleep 1
		touch /var/mobile/Media/FFaac-Settings/mailoff
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/mailoff
		fi
	fi
fi


if [ "$choice" = "4" ];
then
	if [ ! -e "/usr/bin/ringring" ];
	then
		if [ -e "/var/mobile/Media/FFaac-Settings/otheroff" ];
		then
		read -p "Asking for other software (RingRing) is currently turned off. Turn it on? (y/n) " otheron
			if [ "$otheron" = "y" ];
			then
			clear
			echo "
Turned on."
			sleep 1
			rm -f /var/mobile/Media/FFaac-Settings/otheroff
			fi
		else
		read -p "Asking for other software (RingRing) is currently turned on. Turn it off? (y/n) " otheroff
			if [ "$otheroff" = "y" ];
			then
			clear
			echo "
Turned off."
			sleep 1
			touch /var/mobile/Media/FFaac-Settings/otheroff
			chown mobile:mobile /var/mobile/Media/FFaac-Settings/otheroff
			fi
		fi
	else
	echo "This doesn't affect you at all."
	fi
fi


if [ "$choice" = "7" ];
then
clear
echo "Thanks bro."
sleep 1
uiopen "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=679V7DHFCR8V6"
echo "Donated" > /var/mobile/Donation
chown mobile:mobile /var/mobile/Donation
exit
fi

if [ "$choice" = "6" ];
then
uiopen http://apt.thebigboss.org/packagesfordev.php?name=ffaac
exit
fi

if [ "$choice" = "5" ];
then
	if [ -e "/var/mobile/Media/FFaac-Settings/cuttingoff" ];
	then
	read -p "Asking for cutting audio is currently turned off. Turn it on? (y/n) " cuton
		if [ "$cuton" = "y" ];
		then
		clear
		echo "
Turned on."
		sleep 1
		rm -f /var/mobile/Media/FFaac-Settings/cuttingoff
		fi
	else
	read -p "Asking for cutting audio is currently turned on. Turn it off? (y/n) " cutoff
		if [ "$cutoff" = "y" ];
		then
		clear
		echo "
Turned off."
		sleep 1
		touch /var/mobile/Media/FFaac-Settings/cuttingoff
		chown mobile:mobile /var/mobile/Media/FFaac-Settings/cuttingoff
		fi
	fi
fi



echo "Returning to main menu."
sleep 1
clear
done

ffaac
