main.py 141 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324
  1. import os
  2. import random
  3. import string
  4. import traceback
  5. import shutil
  6. import uuid
  7. from flask import Flask, request
  8. base_directory = "/Users/maronakins/Documents"
  9. app = Flask(__name__)
  10. app.base_project = {
  11. "android": base_directory + "/EmbedFeatures/NexilisSampleCode",
  12. "android_flutter": base_directory + "/EmbedFeatures/NexilisSampleCodeFlutter-Android",
  13. "android_ionic": base_directory + "/EmbedFeatures/NexilisSampleCodeIonic-Android",
  14. "android_react": base_directory + "/EmbedFeatures/NexilisSampleCodeReact-Android",
  15. "ios": base_directory + "/EmbedFeatures/NexilisSampleCode-iOS",
  16. "ios_flutter": base_directory + "/EmbedFeatures/NexilisSampleCodeFlutter-iOS",
  17. "ios_ionic": base_directory + "/EmbedFeatures/NexilisSampleCodeIonic-iOS",
  18. "ios_react": base_directory + "/EmbedFeatures/NexilisSampleCodeReact-iOS"
  19. }
  20. app.temp_folder = base_directory + "/EmbedFeatures/BuildExample"
  21. app.zip_folder = base_directory + "/EmbedFeatures/uploads"
  22. # app.ssl = ('/usr/src/app/ssl/STAR_newuniverse_io.crt', '/usr/src/app/ssl/STAR_nexilis.key')
  23. app.ssl = None
  24. app.verbose = True
  25. def vprint(*data):
  26. if app.verbose:
  27. print(*data)
  28. def indented_str(n, s, line=True, spaces=4) -> str:
  29. return " " * n * spaces + s + os.linesep if line else ""
  30. def create_folder(platform, uid):
  31. path = os.path.join(app.temp_folder, uid)
  32. if not os.path.exists(path):
  33. os.mkdir(path)
  34. else:
  35. shutil.rmtree(path)
  36. os.mkdir(path)
  37. vprint(path)
  38. base_project = app.base_project[platform]
  39. base_project_name = os.path.basename(base_project)
  40. path_dest = os.path.join(path, base_project_name)
  41. if not os.path.exists(path_dest):
  42. shutil.copytree(base_project, path_dest)
  43. return path_dest
  44. def write_android_manifest(manifest_path: str, features: dict, security: dict):
  45. with open(manifest_path, "r") as f:
  46. lines = f.readlines()
  47. with open(manifest_path, "w") as f:
  48. for line in lines:
  49. if "<!-- FEATURES -->" in line:
  50. if features["sms"]["status"]:
  51. f.write(indented_str(1, '<!-- use SMS permission -->'))
  52. f.write(indented_str(1, '<uses-permission android:name="android.permission.RECEIVE_SMS" />'))
  53. f.write(indented_str(1, '<uses-permission android:name="android.permission.SEND_SMS" />'))
  54. f.write(indented_str(1, '<uses-permission android:name="android.permission.READ_SMS" />'))
  55. f.write(indented_str(1, '<uses-permission android:name="android.permission.WRITE_SMS" />'))
  56. else:
  57. f.write(indented_str(1, '<!-- use SMS permission -->'))
  58. f.write(
  59. indented_str(1, '<!-- <uses-permission android:name="android.permission.RECEIVE_SMS" /> -->'))
  60. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.SEND_SMS" /> -->'))
  61. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.READ_SMS" /> -->'))
  62. f.write(indented_str(1, '<!-- <uses-permission android:name="android.permission.WRITE_SMS" /> -->'))
  63. elif "<!-- SECURITY -->" in line:
  64. if security["malware"] or security["side_load"]:
  65. f.write(indented_str(1, '<!-- use Malware Detection & Sideload App permission -->'))
  66. f.write(indented_str(1, '<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />'))
  67. else:
  68. f.write(indented_str(1, '<!-- use Malware Detection & Sideload App permission -->'))
  69. f.write(indented_str(1,
  70. '<!-- <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> -->'))
  71. else:
  72. f.write(line)
  73. def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict, security: dict):
  74. if platform == "android":
  75. main_act_path = os.path.join(path_dest,
  76. "app/src/main/java/com/example/nexilissamplecodeburger/MainActivity.java")
  77. xml_menu_path = os.path.join(path_dest, "app/src/main/res/menu/menu_main.xml")
  78. manifest_path = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
  79. layout_grid_path = os.path.join(path_dest, "app/src/main/res/layout/activity_main_grid.xml")
  80. with open(main_act_path, "r") as f:
  81. lines = f.readlines()
  82. with open(main_act_path, "w") as f:
  83. for line in lines:
  84. if "//FEATURES" in line:
  85. f.write(indented_str(2, "if (id == R.id.action_settings) {"))
  86. f.write(indented_str(3, "API.openSettings();"))
  87. f.write(indented_str(3, "return true;"))
  88. f.write(indented_str(2, "}"))
  89. f.write(indented_str(2, "if (id == R.id.action_profile) {"))
  90. f.write(indented_str(3, "API.openProfile();"))
  91. f.write(indented_str(3, "return true;"))
  92. f.write(indented_str(2, "}"))
  93. if features["cc"]["status"]:
  94. f.write(indented_str(2, "if (id == R.id.action_cc) {"))
  95. f.write(indented_str(3, "API.openContactCenter();"))
  96. f.write(indented_str(3, "return true;"))
  97. f.write(indented_str(2, "}"))
  98. else:
  99. f.write(indented_str(2, "// if (id == R.id.action_cc) {"))
  100. f.write(indented_str(3, "// API.openContactCenter();"))
  101. f.write(indented_str(3, "// return true;"))
  102. f.write(indented_str(2, "// }"))
  103. if features["nc"]["status"]:
  104. f.write(indented_str(2, "if (id == R.id.action_nc) {"))
  105. f.write(indented_str(3, "API.openNotificationCenter();"))
  106. f.write(indented_str(3, "return true;"))
  107. f.write(indented_str(2, "}"))
  108. else:
  109. f.write(indented_str(2, "// if (id == R.id.action_nc) {"))
  110. f.write(indented_str(3, "// API.openNotificationCenter();"))
  111. f.write(indented_str(3, "// return true;"))
  112. f.write(indented_str(2, "// }"))
  113. if features["im"]["status"]:
  114. f.write(indented_str(2, "if (id == R.id.action_chats) {"))
  115. f.write(indented_str(3, "API.openChat();"))
  116. f.write(indented_str(3, "return true;"))
  117. f.write(indented_str(2, "}"))
  118. else:
  119. f.write(indented_str(2, "// if (id == R.id.action_chats) {"))
  120. f.write(indented_str(3, "// API.openChat();"))
  121. f.write(indented_str(3, "// return true;"))
  122. f.write(indented_str(2, "// }"))
  123. if features["call"]["status"]:
  124. f.write(indented_str(2, "if (id == R.id.action_call) {"))
  125. f.write(indented_str(3, "API.openCall();"))
  126. f.write(indented_str(3, "return true;"))
  127. f.write(indented_str(2, "}"))
  128. else:
  129. f.write(indented_str(2, "// if (id == R.id.action_call) {"))
  130. f.write(indented_str(3, "// API.openCall();"))
  131. f.write(indented_str(3, "// return true;"))
  132. f.write(indented_str(2, "// }"))
  133. if features["ls"]["status"]:
  134. f.write(indented_str(2, "if (id == R.id.action_ls) {"))
  135. f.write(indented_str(3, "API.openOptionsStreaming();"))
  136. f.write(indented_str(3, "return true;"))
  137. f.write(indented_str(2, "}"))
  138. else:
  139. f.write(indented_str(2, "// if (id == R.id.action_ls) {"))
  140. f.write(indented_str(3, "// API.openOptionsStreaming();"))
  141. f.write(indented_str(3, "// return true;"))
  142. f.write(indented_str(2, "// }"))
  143. if security["secure_folder"]:
  144. f.write(indented_str(2, "if (id == R.id.action_sf) {"))
  145. f.write(indented_str(3, "API.openSecureFolder();"))
  146. f.write(indented_str(3, "return true;"))
  147. f.write(indented_str(2, "}"))
  148. else:
  149. f.write(indented_str(2, "// if (id == R.id.action_sf) {"))
  150. f.write(indented_str(3, "// API.openSecureFolder();"))
  151. f.write(indented_str(3, "// return true;"))
  152. f.write(indented_str(2, "// }"))
  153. elif "//SECURITY" in line:
  154. if security["show_security"]:
  155. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);"))
  156. f.write(os.linesep)
  157. else:
  158. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);"))
  159. f.write(os.linesep)
  160. if security["emulator"]:
  161. f.write(indented_str(2, "API.setCheckEmulator(true);"))
  162. f.write(os.linesep)
  163. else:
  164. f.write(indented_str(2, "// API.setCheckEmulator(true);"))
  165. f.write(os.linesep)
  166. if security["debug"]:
  167. f.write(indented_str(2, "API.setCheckAdb(true);"))
  168. f.write(os.linesep)
  169. else:
  170. f.write(indented_str(2, "// API.setCheckAdb(true);"))
  171. f.write(os.linesep)
  172. if security["sim_swap"]:
  173. f.write(indented_str(2, "API.setCheckSimSwap(true);"))
  174. f.write(os.linesep)
  175. else:
  176. f.write(indented_str(2, "// API.setCheckSimSwap(true);"))
  177. f.write(os.linesep)
  178. if security["malware"]:
  179. f.write(indented_str(2, "API.setCheckMalware(true);"))
  180. f.write(os.linesep)
  181. else:
  182. f.write(indented_str(2, "// API.setCheckMalware(true);"))
  183. f.write(os.linesep)
  184. if security["capture"]:
  185. f.write(indented_str(2, "API.setPreventScreenCapture(true);"))
  186. f.write(os.linesep)
  187. else:
  188. f.write(indented_str(2, "// API.setPreventScreenCapture(true);"))
  189. f.write(os.linesep)
  190. if security["call_forwarding"]:
  191. f.write(indented_str(2, "API.setCheckCallForwarding(true);"))
  192. f.write(os.linesep)
  193. else:
  194. f.write(indented_str(2, "// API.setCheckCallForwarding(true);"))
  195. f.write(os.linesep)
  196. if security["screen_share"]:
  197. f.write(indented_str(2, "API.setCheckScreenCasting(true);"))
  198. f.write(os.linesep)
  199. else:
  200. f.write(indented_str(2, "// API.setCheckScreenCasting(true);"))
  201. f.write(os.linesep)
  202. if security["side_load"]:
  203. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);"))
  204. f.write(os.linesep)
  205. else:
  206. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);"))
  207. f.write(os.linesep)
  208. if security["key_logger"]:
  209. f.write(indented_str(2, "API.setPreventKeylogger(true);"))
  210. f.write(os.linesep)
  211. else:
  212. f.write(indented_str(2, "// API.setPreventKeylogger(true);"))
  213. f.write(os.linesep)
  214. elif "//SMS" in line:
  215. if features["sms"]["status"]:
  216. f.write(indented_str(2, "API.setEnabledSMS(true);"))
  217. else:
  218. f.write(indented_str(2, "// API.setEnabledSMS(true);"))
  219. elif "//EMAIL" in line:
  220. if features["email"]["status"]:
  221. f.write(indented_str(2, "API.setEnabledEmail(true);"))
  222. else:
  223. f.write(indented_str(2, "// API.setEnabledEmail(true);"))
  224. elif "//SMARTBOT" in line:
  225. if features["smartbot"]["status"]:
  226. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  227. else:
  228. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  229. elif "//GRID" in line:
  230. f.write(indented_str(2, "API.setGeneralCallback(new GeneralCallback() {"))
  231. f.write(indented_str(3, "@Override"))
  232. f.write(
  233. indented_str(3, "public void onAddJavasript(WebView webView, WebSettings webSettings) {"))
  234. f.write(indented_str(4, "webSettings.setJavaScriptEnabled(true);"))
  235. f.write(indented_str(3, "}"))
  236. f.write(indented_str(0, ""))
  237. f.write(indented_str(3, "@Override"))
  238. f.write(
  239. indented_str(3,
  240. "public void onAddJavascriptGeneral(WebView webView, WebSettings webSettings) {"))
  241. f.write(indented_str(4, "webSettings.setJavaScriptEnabled(true);"))
  242. f.write(indented_str(3, "}"))
  243. f.write(indented_str(0, ""))
  244. f.write(indented_str(3, "@Override"))
  245. f.write(
  246. indented_str(3,
  247. "public void onAddJavascriptOpenLink(WebView webView, WebSettings webSettings) {"))
  248. f.write(indented_str(4, "webSettings.setJavaScriptEnabled(true);"))
  249. f.write(indented_str(3, "}"))
  250. f.write(indented_str(0, ""))
  251. f.write(indented_str(3, "@Override"))
  252. f.write(
  253. indented_str(3,
  254. "public void onAddJavascriptWebRTC(AppCompatActivity appCompatActivity, WebSettings webSettings) {"))
  255. f.write(indented_str(4, ""))
  256. f.write(indented_str(3, "}"))
  257. f.write(indented_str(2, "});"))
  258. f.write(indented_str(0, ""))
  259. f.write(indented_str(2, "ImageView imageViewSetting = findViewById(R.id.btn_setting);"))
  260. f.write(indented_str(2, "ImageView imageViewProfile = findViewById(R.id.btn_person);"))
  261. if features["cc"]["status"]:
  262. f.write(indented_str(2, "ImageView imageViewCC = findViewById(R.id.btn_cc);"))
  263. else:
  264. f.write(indented_str(2, "// ImageView imageViewCC = findViewById(R.id.btn_cc);"))
  265. if features["nc"]["status"]:
  266. f.write(indented_str(2, "ImageView imageViewNC = findViewById(R.id.btn_nc);"))
  267. else:
  268. f.write(indented_str(2, "// ImageView imageViewNC = findViewById(R.id.btn_nc);"))
  269. if features["im"]["status"]:
  270. f.write(indented_str(2, "ImageView imageViewChat = findViewById(R.id.btn_chat);"))
  271. else:
  272. f.write(indented_str(2, "// ImageView imageViewChat = findViewById(R.id.btn_chat);"))
  273. if features["call"]["status"]:
  274. f.write(indented_str(2, "ImageView imageViewCall = findViewById(R.id.btn_call);"))
  275. else:
  276. f.write(indented_str(2, "// ImageView imageViewCall = findViewById(R.id.btn_call);"))
  277. if features["ls"]["status"]:
  278. f.write(indented_str(2, "ImageView imageViewStream = findViewById(R.id.btn_stream);"))
  279. else:
  280. f.write(indented_str(2, "// ImageView imageViewStream = findViewById(R.id.btn_stream);"))
  281. if security["secure_folder"]:
  282. f.write(indented_str(2, "ImageView imageViewSF = findViewById(R.id.btn_sf);"))
  283. else:
  284. f.write(indented_str(2, "// ImageView imageViewSF = findViewById(R.id.btn_sf);"))
  285. f.write(indented_str(0, ""))
  286. f.write(indented_str(2, "imageViewSetting.setOnClickListener(v -> {"))
  287. f.write(indented_str(3, "API.openSettings();"))
  288. f.write(indented_str(2, "});"))
  289. f.write(indented_str(2, "imageViewProfile.setOnClickListener(v -> {"))
  290. f.write(indented_str(3, "API.openProfile();"))
  291. f.write(indented_str(2, "});"))
  292. if features["cc"]["status"]:
  293. f.write(indented_str(2, "imageViewCC.setOnClickListener(v -> {"))
  294. f.write(indented_str(3, "API.openContactCenter();"))
  295. f.write(indented_str(2, "});"))
  296. else:
  297. f.write(indented_str(2, "// imageViewCC.setOnClickListener(v -> {"))
  298. f.write(indented_str(3, "// API.openContactCenter();"))
  299. f.write(indented_str(2, "// });"))
  300. if features["nc"]["status"]:
  301. f.write(indented_str(2, "imageViewNC.setOnClickListener(v -> {"))
  302. f.write(indented_str(3, "API.openNotificationCenter();"))
  303. f.write(indented_str(2, "});"))
  304. else:
  305. f.write(indented_str(2, "// imageViewNC.setOnClickListener(v -> {"))
  306. f.write(indented_str(3, "// API.openNotificationCenter();"))
  307. f.write(indented_str(2, "// });"))
  308. if features["nc"]["status"]:
  309. f.write(indented_str(2, "imageViewChat.setOnClickListener(v -> {"))
  310. f.write(indented_str(3, "API.openChat();"))
  311. f.write(indented_str(2, "});"))
  312. else:
  313. f.write(indented_str(2, "// imageViewChat.setOnClickListener(v -> {"))
  314. f.write(indented_str(3, "// API.openChat();"))
  315. f.write(indented_str(2, "// });"))
  316. if features["call"]["status"]:
  317. f.write(indented_str(2, "imageViewCall.setOnClickListener(v -> {"))
  318. f.write(indented_str(3, "API.openCall();"))
  319. f.write(indented_str(2, "});"))
  320. else:
  321. f.write(indented_str(2, "// imageViewCall.setOnClickListener(v -> {"))
  322. f.write(indented_str(3, "// API.openCall();"))
  323. f.write(indented_str(2, "// });"))
  324. if features["ls"]["status"]:
  325. f.write(indented_str(2, "imageViewStream.setOnClickListener(v -> {"))
  326. f.write(indented_str(3, "API.openLiveStreaming();"))
  327. f.write(indented_str(2, "});"))
  328. else:
  329. f.write(indented_str(2, "// imageViewStream.setOnClickListener(v -> {"))
  330. f.write(indented_str(3, "// API.openLiveStreaming();"))
  331. f.write(indented_str(2, "// });"))
  332. if security["secure_folder"]:
  333. f.write(indented_str(2, "imageViewSF.setOnClickListener(v -> {"))
  334. f.write(indented_str(3, "API.openSecureFolder();"))
  335. f.write(indented_str(2, "});"))
  336. else:
  337. f.write(indented_str(2, "// imageViewSF.setOnClickListener(v -> {"))
  338. f.write(indented_str(3, "// API.openSecureFolder();"))
  339. f.write(indented_str(2, "// });"))
  340. elif "//BREAK" in line:
  341. if mode == "floating" or mode == "grid":
  342. f.write("}")
  343. break
  344. else:
  345. f.write(indented_str(0, ""))
  346. elif "//FLOATING" in line:
  347. if mode == "floating":
  348. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();"))
  349. if features["cc"]["status"]:
  350. f.write(indented_str(6,
  351. 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  352. else:
  353. f.write(indented_str(6,
  354. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  355. if features["nc"]["status"]:
  356. f.write(
  357. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  358. else:
  359. f.write(indented_str(6,
  360. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  361. if features["im"]["status"]:
  362. f.write(
  363. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  364. else:
  365. f.write(indented_str(6,
  366. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  367. if features["call"]["status"]:
  368. f.write(
  369. indented_str(6,
  370. 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  371. else:
  372. f.write(indented_str(6,
  373. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  374. if features["ls"]["status"]:
  375. f.write(
  376. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  377. else:
  378. f.write(indented_str(6,
  379. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  380. if security["secure_folder"]:
  381. f.write(
  382. indented_str(6,
  383. 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  384. else:
  385. f.write(indented_str(6,
  386. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  387. f.write(indented_str(6,
  388. 'API.configureFloating(fb);'))
  389. else:
  390. f.write(indented_str(0, ""))
  391. elif "API.connect" in line:
  392. replaced = line
  393. if app_id:
  394. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  395. if mode == "floating":
  396. replaced = replaced.replace("0", "1")
  397. f.write(replaced)
  398. elif "R.layout.activity_main" in line:
  399. replaced = line
  400. if mode == "grid":
  401. replaced = replaced.replace("activity_main", "activity_main_grid")
  402. f.write(replaced)
  403. else:
  404. f.write(line)
  405. with open(xml_menu_path, "r") as f:
  406. lines = f.readlines()
  407. with open(xml_menu_path, "w") as f:
  408. for line in lines:
  409. if "<!-- FEATURES -->" in line:
  410. n = 100
  411. f.write(indented_str(1, "<item"))
  412. f.write(indented_str(2, 'android:id="@+id/action_settings"'))
  413. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  414. f.write(indented_str(2, 'android:title="Settings"'))
  415. f.write(indented_str(2, 'app:showAsAction="never" />'))
  416. n = n + 1
  417. f.write(indented_str(1, "<item"))
  418. f.write(indented_str(2, 'android:id="@+id/action_profile"'))
  419. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  420. f.write(indented_str(2, 'android:title="Profile"'))
  421. f.write(indented_str(2, 'app:showAsAction="never" />'))
  422. n = n + 1
  423. if features["cc"]["status"]:
  424. f.write(indented_str(1, "<item"))
  425. f.write(indented_str(2, 'android:id="@+id/action_cc"'))
  426. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  427. f.write(indented_str(2, 'android:title="Contact Center"'))
  428. f.write(indented_str(2, 'app:showAsAction="never" />'))
  429. n = n + 1
  430. else:
  431. f.write(indented_str(1, "<!-- <item"))
  432. f.write(indented_str(2, 'android:id="@+id/action_cc"'))
  433. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  434. f.write(indented_str(2, 'android:title="Contact Center"'))
  435. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  436. n = n + 1
  437. if features["nc"]["status"]:
  438. f.write(indented_str(1, "<item"))
  439. f.write(indented_str(2, 'android:id="@+id/action_nc"'))
  440. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  441. f.write(indented_str(2, 'android:title="Notification Center"'))
  442. f.write(indented_str(2, 'app:showAsAction="never" />'))
  443. n = n + 1
  444. else:
  445. f.write(indented_str(1, "<!-- <item"))
  446. f.write(indented_str(2, 'android:id="@+id/action_nc"'))
  447. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  448. f.write(indented_str(2, 'android:title="Notification Center"'))
  449. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  450. n = n + 1
  451. if features["im"]["status"]:
  452. f.write(indented_str(1, "<item"))
  453. f.write(indented_str(2, 'android:id="@+id/action_chats"'))
  454. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  455. f.write(indented_str(2, 'android:title="Instant Messaging"'))
  456. f.write(indented_str(2, 'app:showAsAction="never" />'))
  457. n = n + 1
  458. else:
  459. f.write(indented_str(1, "<!-- <item"))
  460. f.write(indented_str(2, 'android:id="@+id/action_chats"'))
  461. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  462. f.write(indented_str(2, 'android:title="Instant Messaging"'))
  463. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  464. n = n + 1
  465. if features["call"]["status"]:
  466. f.write(indented_str(1, "<item"))
  467. f.write(indented_str(2, 'android:id="@+id/action_call"'))
  468. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  469. f.write(indented_str(2, 'android:title="Call"'))
  470. f.write(indented_str(2, 'app:showAsAction="never" />'))
  471. n = n + 1
  472. else:
  473. f.write(indented_str(1, "<!-- <item"))
  474. f.write(indented_str(2, 'android:id="@+id/action_call"'))
  475. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  476. f.write(indented_str(2, 'android:title="Call"'))
  477. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  478. n = n + 1
  479. if features["ls"]["status"]:
  480. f.write(indented_str(1, "<item"))
  481. f.write(indented_str(2, 'android:id="@+id/action_ls"'))
  482. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  483. f.write(indented_str(2, 'android:title="Streaming"'))
  484. f.write(indented_str(2, 'app:showAsAction="never" />'))
  485. n = n + 1
  486. else:
  487. f.write(indented_str(1, "<!-- <item"))
  488. f.write(indented_str(2, 'android:id="@+id/action_ls"'))
  489. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  490. f.write(indented_str(2, 'android:title="Streaming"'))
  491. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  492. n = n + 1
  493. if security["secure_folder"]:
  494. f.write(indented_str(1, "<item"))
  495. f.write(indented_str(2, 'android:id="@+id/action_sf"'))
  496. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  497. f.write(indented_str(2, 'android:title="Secure Folder"'))
  498. f.write(indented_str(2, 'app:showAsAction="never" />'))
  499. n = n + 1
  500. else:
  501. f.write(indented_str(1, "<!-- <item"))
  502. f.write(indented_str(2, 'android:id="@+id/action_sf"'))
  503. f.write(indented_str(2, f'android:orderInCategory="{n}"'))
  504. f.write(indented_str(2, 'android:title="Secure Folder"'))
  505. f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
  506. n = n + 1
  507. else:
  508. f.write(line)
  509. l_features = [x for x in list(features.keys()) if features[x]["status"] and x != "smartbot" and x != "sms" and x != "email"]
  510. if security["secure_folder"]:
  511. l_features.append("secure_folder")
  512. n_features = len(l_features) + 2
  513. row_count = -(n_features // -3) # ceiling div
  514. column_count = 3
  515. with open(layout_grid_path, "r") as f:
  516. lines = f.readlines()
  517. with open(layout_grid_path, "w") as f:
  518. for line in lines:
  519. if "rowCount" in line:
  520. f.write(indented_str(1, f'android:rowCount="{row_count}"'))
  521. elif "columnCount" in line:
  522. f.write(indented_str(1,f'android:columnCount="{column_count}"'))
  523. elif "<!-- FEATURES -->" in line:
  524. f.write(indented_str(1, "<ImageView"))
  525. f.write(indented_str(2, 'android:id="@+id/btn_setting"'))
  526. f.write(indented_str(2, 'android:layout_height="100dp"'))
  527. f.write(indented_str(2, 'android:layout_width="100dp"'))
  528. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  529. f.write(indented_str(2, 'android:src="@drawable/pb_cuc_menu_item_setting"/>'))
  530. f.write(indented_str(1, "<ImageView"))
  531. f.write(indented_str(2, 'android:id="@+id/btn_person"'))
  532. f.write(indented_str(2, 'android:layout_height="100dp"'))
  533. f.write(indented_str(2, 'android:layout_width="100dp"'))
  534. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  535. f.write(indented_str(2, 'android:src="@drawable/pb_ic_person_boy"/>'))
  536. if "cc" in l_features:
  537. f.write(indented_str(1, "<ImageView"))
  538. f.write(indented_str(2, 'android:id="@+id/btn_cc"'))
  539. f.write(indented_str(2, 'android:layout_height="100dp"'))
  540. f.write(indented_str(2, 'android:layout_width="100dp"'))
  541. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  542. f.write(indented_str(2, 'android:src="@drawable/pb_button_cc"/>'))
  543. else:
  544. f.write(indented_str(1, "<!--<ImageView-->"))
  545. f.write(indented_str(2, '<!--android:id="@+id/btn_cc"-->'))
  546. f.write(indented_str(2, '<!--android:layout_height="100dp"-->'))
  547. f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
  548. f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
  549. f.write(indented_str(2, '<!--android:src="@drawable/pb_button_cc"/>-->'))
  550. if "nc" in l_features:
  551. f.write(indented_str(1, "<ImageView"))
  552. f.write(indented_str(2, 'android:id="@+id/btn_nc"'))
  553. f.write(indented_str(2, 'android:layout_height="100dp"'))
  554. f.write(indented_str(2, 'android:layout_width="100dp"'))
  555. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  556. f.write(indented_str(2, 'android:src="@drawable/pb_button_notif_center"/>'))
  557. else:
  558. f.write(indented_str(1, "<!--<ImageView-->"))
  559. f.write(indented_str(2, '<!--android:id="@+id/btn_nc"-->'))
  560. f.write(indented_str(2, '<!--android:layout_height="100dp"-->'))
  561. f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
  562. f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
  563. f.write(indented_str(2, '<!--android:src="@drawable/pb_button_notif_center"/>-->'))
  564. if "im" in l_features:
  565. f.write(indented_str(1, "<ImageView"))
  566. f.write(indented_str(2, 'android:id="@+id/btn_chat"'))
  567. f.write(indented_str(2, 'android:layout_height="100dp"'))
  568. f.write(indented_str(2, 'android:layout_width="100dp"'))
  569. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  570. f.write(indented_str(2, 'android:src="@drawable/pb_button_chat"/>'))
  571. else:
  572. f.write(indented_str(1, "<!--<ImageView-->"))
  573. f.write(indented_str(2, '<!--android:id="@+id/btn_chat"-->'))
  574. f.write(indented_str(2, '<!--android:layout_height="100dp"-->'))
  575. f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
  576. f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
  577. f.write(indented_str(2, '<!--android:src="@drawable/pb_button_chat"/>-->'))
  578. if "call" in l_features:
  579. f.write(indented_str(1, "<ImageView"))
  580. f.write(indented_str(2, 'android:id="@+id/btn_call"'))
  581. f.write(indented_str(2, 'android:layout_height="100dp"'))
  582. f.write(indented_str(2, 'android:layout_width="100dp"'))
  583. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  584. f.write(indented_str(2, 'android:src="@drawable/pb_button_call"/>'))
  585. else:
  586. f.write(indented_str(1, "<!--<ImageView-->"))
  587. f.write(indented_str(2, '<!--android:id="@+id/btn_call"-->'))
  588. f.write(indented_str(2, '<!--android:layout_height="100dp"-->'))
  589. f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
  590. f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
  591. f.write(indented_str(2, '<!--android:src="@drawable/pb_button_call"/>-->'))
  592. if "ls" in l_features:
  593. f.write(indented_str(1, "<ImageView"))
  594. f.write(indented_str(2, 'android:id="@+id/btn_stream"'))
  595. f.write(indented_str(2, 'android:layout_height="100dp"'))
  596. f.write(indented_str(2, 'android:layout_width="100dp"'))
  597. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  598. f.write(indented_str(2, 'android:src="@drawable/pb_button_stream"/>'))
  599. else:
  600. f.write(indented_str(1, "<!--<ImageView-->"))
  601. f.write(indented_str(2, '<!--android:id="@+id/btn_stream"-->'))
  602. f.write(indented_str(2, '<!--android:layout_height="100dp"-->'))
  603. f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
  604. f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
  605. f.write(indented_str(2, '<!--android:src="@drawable/pb_button_stream"/>-->'))
  606. if "secure_folder" in l_features:
  607. f.write(indented_str(1, "<ImageView"))
  608. f.write(indented_str(2, 'android:id="@+id/btn_sf"'))
  609. f.write(indented_str(2, 'android:layout_height="100dp"'))
  610. f.write(indented_str(2, 'android:layout_width="100dp"'))
  611. f.write(indented_str(2, 'android:layout_margin="10dp"'))
  612. f.write(indented_str(2, 'android:src="@drawable/pb_button_secure_folder"/>'))
  613. else:
  614. f.write(indented_str(1, "<!--<ImageView-->"))
  615. f.write(indented_str(2, '<!--android:id="@+id/btn_sf"-->'))
  616. f.write(indented_str(2, '<!--android:layout_height="100dp"-->'))
  617. f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
  618. f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
  619. f.write(indented_str(2, '<!--android:src="@drawable/pb_button_secure_folder"/>-->'))
  620. else:
  621. f.write(line)
  622. write_android_manifest(manifest_path, features, security)
  623. elif platform == "android_flutter":
  624. main_act_path = os.path.join(path_dest, "lib/main.dart")
  625. main_act_android = os.path.join(path_dest,
  626. "android/app/src/main/java/com/example/paliolitesamplecodeflutter/MainActivity.java")
  627. manifest_path = os.path.join(path_dest, "android/app/src/main/AndroidManifest.xml")
  628. with open(main_act_path, "r") as f:
  629. lines = f.readlines()
  630. with open(main_act_path, "w") as f:
  631. features_str = []
  632. for line in lines:
  633. if "'Features List'" in line:
  634. features_str.append("'Settings'")
  635. features_str.append("'Profile'")
  636. if features["cc"]["status"]:
  637. features_str.append("'Contact Center'")
  638. else:
  639. features_str.append("// 'Contact Center'")
  640. if features["nc"]["status"]:
  641. features_str.append("'Notification Center'")
  642. else:
  643. features_str.append("// 'Notification Center'")
  644. if features["im"]["status"]:
  645. features_str.append("'Instant Messaging'")
  646. else:
  647. features_str.append("// 'Instant Messaging'")
  648. if features["call"]["status"]:
  649. features_str.append("'Call'")
  650. else:
  651. features_str.append("// 'Call'")
  652. if features["ls"]["status"]:
  653. features_str.append("'Streaming'")
  654. else:
  655. features_str.append("// 'Streaming'")
  656. if security["secure_folder"]:
  657. features_str.append("'Secure Folder'")
  658. else:
  659. features_str.append("// 'Secure Folder'")
  660. for feature_str in features_str:
  661. f.write(indented_str(8, f"{feature_str},", spaces=2))
  662. elif "//FEATURES" in line:
  663. f.write(indented_str(3, 'case "Settings":', spaces=2))
  664. f.write(indented_str(4, 'nativeChannel.invokeMethod("openSettings");', spaces=2))
  665. f.write(indented_str(4, "break;", spaces=2))
  666. f.write(indented_str(3, 'case "Profile":', spaces=2))
  667. f.write(indented_str(4, 'nativeChannel.invokeMethod("openProfile");', spaces=2))
  668. f.write(indented_str(4, "break;", spaces=2))
  669. if features["cc"]["status"]:
  670. f.write(indented_str(3, 'case "Contact Center":', spaces=2))
  671. f.write(indented_str(4, 'nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  672. f.write(indented_str(4, "break;", spaces=2))
  673. else:
  674. f.write(indented_str(3, '// case "Contact Center":', spaces=2))
  675. f.write(indented_str(4, '// nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  676. f.write(indented_str(4, "// break;", spaces=2))
  677. if features["nc"]["status"]:
  678. f.write(indented_str(3, 'case "Notification Center":', spaces=2))
  679. f.write(indented_str(4, 'nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  680. f.write(indented_str(4, "break;", spaces=2))
  681. else:
  682. f.write(indented_str(3, '// case "Notification Center":', spaces=2))
  683. f.write(indented_str(4, '// nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  684. f.write(indented_str(4, "// break;", spaces=2))
  685. if features["im"]["status"]:
  686. f.write(indented_str(3, 'case "Instant Messaging":', spaces=2))
  687. f.write(indented_str(4, 'nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  688. f.write(indented_str(4, "break;", spaces=2))
  689. else:
  690. f.write(indented_str(3, '// case "Instant Messaging":', spaces=2))
  691. f.write(indented_str(4, '// nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  692. f.write(indented_str(4, "// break;", spaces=2))
  693. if features["call"]["status"]:
  694. f.write(indented_str(3, 'case "Call":', spaces=2))
  695. f.write(indented_str(4, 'nativeChannel.invokeMethod("openCall");', spaces=2))
  696. f.write(indented_str(4, "break;", spaces=2))
  697. else:
  698. f.write(indented_str(3, '// case "Call":', spaces=2))
  699. f.write(indented_str(4, '// nativeChannel.invokeMethod("openCall");', spaces=2))
  700. f.write(indented_str(4, "// break;", spaces=2))
  701. if features["ls"]["status"]:
  702. f.write(indented_str(3, 'case "Streaming":', spaces=2))
  703. f.write(indented_str(4, 'nativeChannel.invokeMethod("openStreaming");', spaces=2))
  704. f.write(indented_str(4, "break;", spaces=2))
  705. else:
  706. f.write(indented_str(3, '// case "Streaming":', spaces=2))
  707. f.write(indented_str(4, '// nativeChannel.invokeMethod("openStreaming");', spaces=2))
  708. f.write(indented_str(4, "// break;", spaces=2))
  709. if security["secure_folder"]:
  710. f.write(indented_str(3, 'case "Secure Folder":', spaces=2))
  711. f.write(indented_str(4, 'nativeChannel.invokeMethod("openSecureFolder");', spaces=2))
  712. f.write(indented_str(4, "break;", spaces=2))
  713. else:
  714. f.write(indented_str(3, '// case "Secure Folder":', spaces=2))
  715. f.write(indented_str(4, '// nativeChannel.invokeMethod("openSecureFolder");', spaces=2))
  716. f.write(indented_str(4, "// break;", spaces=2))
  717. else:
  718. f.write(line)
  719. with open(main_act_android, "r") as f:
  720. lines = f.readlines()
  721. with open(main_act_android, "w") as f:
  722. for line in lines:
  723. if "//SECURITY" in line:
  724. if security["show_security"]:
  725. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);"))
  726. f.write(os.linesep)
  727. else:
  728. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);"))
  729. f.write(os.linesep)
  730. if security["emulator"]:
  731. f.write(indented_str(2, "API.setCheckEmulator(true);"))
  732. f.write(os.linesep)
  733. else:
  734. f.write(indented_str(2, "// API.setCheckEmulator(true);"))
  735. f.write(os.linesep)
  736. if security["debug"]:
  737. f.write(indented_str(2, "API.setCheckAdb(true);"))
  738. f.write(os.linesep)
  739. else:
  740. f.write(indented_str(2, "// API.setCheckAdb(true);"))
  741. f.write(os.linesep)
  742. if security["sim_swap"]:
  743. f.write(indented_str(2, "API.setCheckSimSwap(true);"))
  744. f.write(os.linesep)
  745. else:
  746. f.write(indented_str(2, "// API.setCheckSimSwap(true);"))
  747. f.write(os.linesep)
  748. if security["malware"]:
  749. f.write(indented_str(2, "API.setCheckMalware(true);"))
  750. f.write(os.linesep)
  751. else:
  752. f.write(indented_str(2, "// API.setCheckMalware(true);"))
  753. f.write(os.linesep)
  754. if security["capture"]:
  755. f.write(indented_str(2, "API.setPreventScreenCapture(true);"))
  756. f.write(os.linesep)
  757. else:
  758. f.write(indented_str(2, "// API.setPreventScreenCapture(true);"))
  759. f.write(os.linesep)
  760. if security["call_forwarding"]:
  761. f.write(indented_str(2, "API.setCheckCallForwarding(true);"))
  762. f.write(os.linesep)
  763. else:
  764. f.write(indented_str(2, "// API.setCheckCallForwarding(true);"))
  765. f.write(os.linesep)
  766. if security["screen_share"]:
  767. f.write(indented_str(2, "API.setCheckScreenCasting(true);"))
  768. f.write(os.linesep)
  769. else:
  770. f.write(indented_str(2, "// API.setCheckScreenCasting(true);"))
  771. f.write(os.linesep)
  772. if security["side_load"]:
  773. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);"))
  774. f.write(os.linesep)
  775. else:
  776. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);"))
  777. f.write(os.linesep)
  778. if security["key_logger"]:
  779. f.write(indented_str(2, "API.setPreventKeylogger(true);"))
  780. f.write(os.linesep)
  781. else:
  782. f.write(indented_str(2, "// API.setPreventKeylogger(true);"))
  783. f.write(os.linesep)
  784. elif "//SMS" in line:
  785. if features["sms"]["status"]:
  786. f.write(indented_str(2, "API.setEnabledSMS(true);"))
  787. else:
  788. f.write(indented_str(2, "// API.setEnabledSMS(true);"))
  789. elif "//EMAIL" in line:
  790. if features["email"]["status"]:
  791. f.write(indented_str(2, "API.setEnabledEmail(true);"))
  792. else:
  793. f.write(indented_str(2, "// API.setEnabledEmail(true);"))
  794. elif "//SMARTBOT" in line:
  795. if features["smartbot"]["status"]:
  796. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  797. else:
  798. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  799. elif "//FLOATING" in line:
  800. if mode == "floating":
  801. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();"))
  802. if features["cc"]["status"]:
  803. f.write(indented_str(6,
  804. 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  805. else:
  806. f.write(indented_str(6,
  807. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  808. if features["nc"]["status"]:
  809. f.write(
  810. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  811. else:
  812. f.write(indented_str(6,
  813. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  814. if features["im"]["status"]:
  815. f.write(
  816. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  817. else:
  818. f.write(indented_str(6,
  819. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  820. if features["call"]["status"]:
  821. f.write(
  822. indented_str(6,
  823. 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  824. else:
  825. f.write(indented_str(6,
  826. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  827. if features["ls"]["status"]:
  828. f.write(
  829. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  830. else:
  831. f.write(indented_str(6,
  832. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  833. if security["secure_folder"]:
  834. f.write(
  835. indented_str(6,
  836. 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  837. else:
  838. f.write(indented_str(6,
  839. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  840. f.write(indented_str(6,
  841. 'API.configureFloating(fb);'))
  842. else:
  843. f.write(indented_str(0, ""))
  844. elif "API.connect" in line:
  845. replaced = line
  846. if app_id:
  847. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  848. if mode == "floating":
  849. replaced = replaced.replace("0", "1")
  850. f.write(replaced)
  851. else:
  852. f.write(line)
  853. write_android_manifest(manifest_path, features, security)
  854. elif platform == "android_ionic":
  855. main_act_path = os.path.join(path_dest, "src/app/app.component.ts")
  856. main_act_android = os.path.join(path_dest,
  857. "android/app/src/main/java/com/example/nexilissamplecodeionic/MainActivity.java")
  858. manifest_path = os.path.join(path_dest, "android/app/src/main/AndroidManifest.xml")
  859. with open(main_act_path, "r") as f:
  860. lines = f.readlines()
  861. with open(main_act_path, "w") as f:
  862. for line in lines:
  863. if "//FEATURES" in line:
  864. f.write(indented_str(4, '{', spaces=2))
  865. f.write(indented_str(5, "text: 'Settings',", spaces=2))
  866. f.write(indented_str(5, "handler: () => {", spaces=2))
  867. f.write(indented_str(6, "this.openSettings();", spaces=2))
  868. f.write(indented_str(5, "},", spaces=2))
  869. f.write(indented_str(4, "},", spaces=2))
  870. f.write(indented_str(4, '{', spaces=2))
  871. f.write(indented_str(5, "text: 'Profile',", spaces=2))
  872. f.write(indented_str(5, "handler: () => {", spaces=2))
  873. f.write(indented_str(6, "this.openProfile();", spaces=2))
  874. f.write(indented_str(5, "},", spaces=2))
  875. f.write(indented_str(4, "},", spaces=2))
  876. if features["cc"]["status"]:
  877. f.write(indented_str(4, '{', spaces=2))
  878. f.write(indented_str(5, "text: 'Contact Center',", spaces=2))
  879. f.write(indented_str(5, "handler: () => {", spaces=2))
  880. f.write(indented_str(6, "this.openContactCenter();", spaces=2))
  881. f.write(indented_str(5, "},", spaces=2))
  882. f.write(indented_str(4, "},", spaces=2))
  883. else:
  884. f.write(indented_str(4, '// {', spaces=2))
  885. f.write(indented_str(5, "// text: 'Contact Center',", spaces=2))
  886. f.write(indented_str(5, "// handler: () => {", spaces=2))
  887. f.write(indented_str(6, "// this.openContactCenter();", spaces=2))
  888. f.write(indented_str(5, "// },", spaces=2))
  889. f.write(indented_str(4, "// },", spaces=2))
  890. if features["nc"]["status"]:
  891. f.write(indented_str(4, '{', spaces=2))
  892. f.write(indented_str(5, "text: 'Notification Center',", spaces=2))
  893. f.write(indented_str(5, "handler: () => {", spaces=2))
  894. f.write(indented_str(6, "this.openNotificationCenter();", spaces=2))
  895. f.write(indented_str(5, "},", spaces=2))
  896. f.write(indented_str(4, "},", spaces=2))
  897. else:
  898. f.write(indented_str(4, '// {', spaces=2))
  899. f.write(indented_str(5, "// text: 'Notification Center',", spaces=2))
  900. f.write(indented_str(5, "// handler: () => {", spaces=2))
  901. f.write(indented_str(6, "// this.openNotificationCenter();", spaces=2))
  902. f.write(indented_str(5, "// },", spaces=2))
  903. f.write(indented_str(4, "// },", spaces=2))
  904. if features["im"]["status"]:
  905. f.write(indented_str(4, '{', spaces=2))
  906. f.write(indented_str(5, "text: 'Instant Messaging',", spaces=2))
  907. f.write(indented_str(5, "handler: () => {", spaces=2))
  908. f.write(indented_str(6, "this.openChat();", spaces=2))
  909. f.write(indented_str(5, "},", spaces=2))
  910. f.write(indented_str(4, "},", spaces=2))
  911. else:
  912. f.write(indented_str(4, '// {', spaces=2))
  913. f.write(indented_str(5, "// text: 'Instant Messaging',", spaces=2))
  914. f.write(indented_str(5, "// handler: () => {", spaces=2))
  915. f.write(indented_str(6, "// this.openChat();", spaces=2))
  916. f.write(indented_str(5, "// },", spaces=2))
  917. f.write(indented_str(4, "// },", spaces=2))
  918. if features["call"]["status"]:
  919. f.write(indented_str(4, '{', spaces=2))
  920. f.write(indented_str(5, "text: 'Call',", spaces=2))
  921. f.write(indented_str(5, "handler: () => {", spaces=2))
  922. f.write(indented_str(6, "this.openCall();", spaces=2))
  923. f.write(indented_str(5, "},", spaces=2))
  924. f.write(indented_str(4, "},", spaces=2))
  925. else:
  926. f.write(indented_str(4, '// {', spaces=2))
  927. f.write(indented_str(5, "// text: 'Call',", spaces=2))
  928. f.write(indented_str(5, "// handler: () => {", spaces=2))
  929. f.write(indented_str(6, "// this.openCall();", spaces=2))
  930. f.write(indented_str(5, "// },", spaces=2))
  931. f.write(indented_str(4, "// },", spaces=2))
  932. if features["ls"]["status"]:
  933. f.write(indented_str(4, '{', spaces=2))
  934. f.write(indented_str(5, "text: 'Streaming',", spaces=2))
  935. f.write(indented_str(5, "handler: () => {", spaces=2))
  936. f.write(indented_str(6, "this.openStreaming();", spaces=2))
  937. f.write(indented_str(5, "},", spaces=2))
  938. f.write(indented_str(4, "},", spaces=2))
  939. else:
  940. f.write(indented_str(4, '// {', spaces=2))
  941. f.write(indented_str(5, "// text: 'Streaming',", spaces=2))
  942. f.write(indented_str(5, "// handler: () => {", spaces=2))
  943. f.write(indented_str(6, "// this.openStreaming();", spaces=2))
  944. f.write(indented_str(5, "// },", spaces=2))
  945. f.write(indented_str(4, "// },", spaces=2))
  946. if security["secure_folder"]:
  947. f.write(indented_str(4, '{', spaces=2))
  948. f.write(indented_str(5, "text: 'Secure Folder',", spaces=2))
  949. f.write(indented_str(5, "handler: () => {", spaces=2))
  950. f.write(indented_str(6, "this.openSecureFolder();", spaces=2))
  951. f.write(indented_str(5, "},", spaces=2))
  952. f.write(indented_str(4, "},", spaces=2))
  953. else:
  954. f.write(indented_str(4, '// {', spaces=2))
  955. f.write(indented_str(5, "// text: 'Secure Folder',", spaces=2))
  956. f.write(indented_str(5, "// handler: () => {", spaces=2))
  957. f.write(indented_str(6, "// this.openSecureFolder();", spaces=2))
  958. f.write(indented_str(5, "// },", spaces=2))
  959. f.write(indented_str(4, "// },", spaces=2))
  960. else:
  961. f.write(line)
  962. with open(main_act_android, "r") as f:
  963. lines = f.readlines()
  964. with open(main_act_android, "w") as f:
  965. for line in lines:
  966. if "//SECURITY" in line:
  967. if security["show_security"]:
  968. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);", spaces=2))
  969. f.write(os.linesep)
  970. else:
  971. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);", spaces=2))
  972. f.write(os.linesep)
  973. if security["emulator"]:
  974. f.write(indented_str(2, "API.setCheckEmulator(true);", spaces=2))
  975. f.write(os.linesep)
  976. else:
  977. f.write(indented_str(2, "// API.setCheckEmulator(true);", spaces=2))
  978. f.write(os.linesep)
  979. if security["debug"]:
  980. f.write(indented_str(2, "API.setCheckAdb(true);", spaces=2))
  981. f.write(os.linesep)
  982. else:
  983. f.write(indented_str(2, "// API.setCheckAdb(true);", spaces=2))
  984. f.write(os.linesep)
  985. if security["sim_swap"]:
  986. f.write(indented_str(2, "API.setCheckSimSwap(true);", spaces=2))
  987. f.write(os.linesep)
  988. else:
  989. f.write(indented_str(2, "// API.setCheckSimSwap(true);", spaces=2))
  990. f.write(os.linesep)
  991. if security["malware"]:
  992. f.write(indented_str(2, "API.setCheckMalware(true);", spaces=2))
  993. f.write(os.linesep)
  994. else:
  995. f.write(indented_str(2, "// API.setCheckMalware(true);", spaces=2))
  996. f.write(os.linesep)
  997. if security["capture"]:
  998. f.write(indented_str(2, "API.setPreventScreenCapture(true);", spaces=2))
  999. f.write(os.linesep)
  1000. else:
  1001. f.write(indented_str(2, "// API.setPreventScreenCapture(true);", spaces=2))
  1002. f.write(os.linesep)
  1003. if security["call_forwarding"]:
  1004. f.write(indented_str(2, "API.setCheckCallForwarding(true);", spaces=2))
  1005. f.write(os.linesep)
  1006. else:
  1007. f.write(indented_str(2, "// API.setCheckCallForwarding(true);", spaces=2))
  1008. f.write(os.linesep)
  1009. if security["screen_share"]:
  1010. f.write(indented_str(2, "API.setCheckScreenCasting(true);", spaces=2))
  1011. f.write(os.linesep)
  1012. else:
  1013. f.write(indented_str(2, "// API.setCheckScreenCasting(true);", spaces=2))
  1014. f.write(os.linesep)
  1015. if security["side_load"]:
  1016. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);", spaces=2))
  1017. f.write(os.linesep)
  1018. else:
  1019. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);", spaces=2))
  1020. f.write(os.linesep)
  1021. if security["key_logger"]:
  1022. f.write(indented_str(2, "API.setPreventKeylogger(true);", spaces=2))
  1023. f.write(os.linesep)
  1024. else:
  1025. f.write(indented_str(2, "// API.setPreventKeylogger(true);", spaces=2))
  1026. f.write(os.linesep)
  1027. elif "//SMS" in line:
  1028. if features["sms"]["status"]:
  1029. f.write(indented_str(2, "API.setEnabledSMS(true);", spaces=2))
  1030. else:
  1031. f.write(indented_str(2, "// API.setEnabledSMS(true);", spaces=2))
  1032. elif "//EMAIL" in line:
  1033. if features["email"]["status"]:
  1034. f.write(indented_str(2, "API.setEnabledEmail(true);", spaces=2))
  1035. else:
  1036. f.write(indented_str(2, "// API.setEnabledEmail(true);", spaces=2))
  1037. elif "//SMARTBOT" in line:
  1038. if features["smartbot"]["status"]:
  1039. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  1040. else:
  1041. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  1042. elif "//FLOATING" in line:
  1043. if mode == "floating":
  1044. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();", spaces=2))
  1045. if features["cc"]["status"]:
  1046. f.write(indented_str(6,
  1047. 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));',
  1048. spaces=2))
  1049. else:
  1050. f.write(indented_str(6,
  1051. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));',
  1052. spaces=2))
  1053. if features["nc"]["status"]:
  1054. f.write(
  1055. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));',
  1056. spaces=2))
  1057. else:
  1058. f.write(indented_str(6,
  1059. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));',
  1060. spaces=2))
  1061. if features["im"]["status"]:
  1062. f.write(
  1063. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));',
  1064. spaces=2))
  1065. else:
  1066. f.write(indented_str(6,
  1067. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));',
  1068. spaces=2))
  1069. if features["call"]["status"]:
  1070. f.write(
  1071. indented_str(6,
  1072. 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));',
  1073. spaces=2))
  1074. else:
  1075. f.write(indented_str(6,
  1076. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));',
  1077. spaces=2))
  1078. if features["ls"]["status"]:
  1079. f.write(
  1080. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));',
  1081. spaces=2))
  1082. else:
  1083. f.write(indented_str(6,
  1084. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));',
  1085. spaces=2))
  1086. if security["secure_folder"]:
  1087. f.write(
  1088. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));',
  1089. spaces=2))
  1090. else:
  1091. f.write(indented_str(6,
  1092. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));',
  1093. spaces=2))
  1094. f.write(indented_str(6,
  1095. 'API.configureFloating(fb);', spaces=2))
  1096. else:
  1097. f.write(indented_str(0, "", spaces=2))
  1098. elif "API.connect" in line:
  1099. replaced = line
  1100. if app_id:
  1101. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  1102. if mode == "floating":
  1103. replaced = replaced.replace("0", "1")
  1104. f.write(replaced)
  1105. else:
  1106. f.write(line)
  1107. write_android_manifest(manifest_path, features, security)
  1108. elif platform == "android_react":
  1109. main_act_path = os.path.join(path_dest, "App.tsx")
  1110. main_act_android = os.path.join(path_dest,
  1111. "android/app/src/main/java/com/paliolitesamplecode/MainActivity.java")
  1112. manifest_path = os.path.join(path_dest, "android/app/src/main/AndroidManifest.xml")
  1113. with open(main_act_path, "r") as f:
  1114. lines = f.readlines()
  1115. with open(main_act_path, "w") as f:
  1116. for line in lines:
  1117. if "'Features'" in line:
  1118. f.write(indented_str(4, "'Setting',", spaces=2))
  1119. f.write(indented_str(4, "'Profile',", spaces=2))
  1120. if features["cc"]["status"]:
  1121. f.write(indented_str(4, "'Contact Center',", spaces=2))
  1122. else:
  1123. f.write(indented_str(4, "// 'Contact Center',", spaces=2))
  1124. if features["nc"]["status"]:
  1125. f.write(indented_str(4, "'Notification Center',", spaces=2))
  1126. else:
  1127. f.write(indented_str(4, "// 'Notification Center',", spaces=2))
  1128. if features["im"]["status"]:
  1129. f.write(indented_str(4, "'Chat',", spaces=2))
  1130. else:
  1131. f.write(indented_str(4, "// 'Chat',", spaces=2))
  1132. if features["call"]["status"]:
  1133. f.write(indented_str(4, "'Call',", spaces=2))
  1134. else:
  1135. f.write(indented_str(4, "// 'Call',", spaces=2))
  1136. if features["ls"]["status"]:
  1137. f.write(indented_str(4, "'Live Streaming',", spaces=2))
  1138. else:
  1139. f.write(indented_str(4, "// 'Live Streaming',", spaces=2))
  1140. if security["secure_folder"]:
  1141. f.write(indented_str(4, "'Secure Folder',", spaces=2))
  1142. else:
  1143. f.write(indented_str(4, "// 'Secure Folder',", spaces=2))
  1144. elif "//FEATURES1" in line:
  1145. n = 0
  1146. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1147. f.write(indented_str(6, "CallNative.openSetting();", spaces=2))
  1148. f.write(indented_str(5, "}", spaces=2))
  1149. n = n + 1
  1150. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1151. f.write(indented_str(6, "CallNative.openProfile();", spaces=2))
  1152. f.write(indented_str(5, "}", spaces=2))
  1153. n = n + 1
  1154. if features["cc"]["status"]:
  1155. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1156. f.write(indented_str(6, "CallNative.openContactCenter();", spaces=2))
  1157. f.write(indented_str(5, "}", spaces=2))
  1158. n = n + 1
  1159. else:
  1160. f.write(indented_str(5, "// if (buttonIndex === 2) {", spaces=2))
  1161. f.write(indented_str(6, "// CallNative.openContactCenter();", spaces=2))
  1162. f.write(indented_str(5, "// }", spaces=2))
  1163. if features["nc"]["status"]:
  1164. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1165. f.write(indented_str(6, "CallNative.openNotificationCenter();", spaces=2))
  1166. f.write(indented_str(5, "}", spaces=2))
  1167. n = n + 1
  1168. else:
  1169. f.write(indented_str(5, "// if (buttonIndex === 3) {", spaces=2))
  1170. f.write(indented_str(6, "// CallNative.openNotificationCenter();", spaces=2))
  1171. f.write(indented_str(5, "// }", spaces=2))
  1172. if features["im"]["status"]:
  1173. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1174. f.write(indented_str(6, "CallNative.openChat();", spaces=2))
  1175. f.write(indented_str(5, "}", spaces=2))
  1176. n = n + 1
  1177. else:
  1178. f.write(indented_str(5, "// if (buttonIndex === 4) {", spaces=2))
  1179. f.write(indented_str(6, "// CallNative.openChat();", spaces=2))
  1180. f.write(indented_str(5, "// }", spaces=2))
  1181. if features["call"]["status"]:
  1182. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1183. f.write(indented_str(6, "CallNative.openCall();", spaces=2))
  1184. f.write(indented_str(5, "}", spaces=2))
  1185. n = n + 1
  1186. else:
  1187. f.write(indented_str(5, "// if (buttonIndex === 5) {", spaces=2))
  1188. f.write(indented_str(6, "// CallNative.openCall();", spaces=2))
  1189. f.write(indented_str(5, "// }", spaces=2))
  1190. if features["ls"]["status"]:
  1191. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1192. f.write(indented_str(6, "CallNative.openStreaming();", spaces=2))
  1193. f.write(indented_str(5, "}", spaces=2))
  1194. n = n + 1
  1195. else:
  1196. f.write(indented_str(5, "// if (buttonIndex === 6) {", spaces=2))
  1197. f.write(indented_str(6, "// CallNative.openStreaming();", spaces=2))
  1198. f.write(indented_str(5, "// }", spaces=2))
  1199. if security["secure_folder"]:
  1200. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1201. f.write(indented_str(6, "CallNative.openSecureFolder();", spaces=2))
  1202. f.write(indented_str(5, "}", spaces=2))
  1203. n = n + 1
  1204. else:
  1205. f.write(indented_str(5, "// if (buttonIndex === 7) {", spaces=2))
  1206. f.write(indented_str(6, "// CallNative.openSecureFolder();", spaces=2))
  1207. f.write(indented_str(5, "// }", spaces=2))
  1208. elif "//FEATURES2" in line:
  1209. n = 0
  1210. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1211. f.write(indented_str(3, "try {", spaces=2))
  1212. f.write(indented_str(4, "CallNative.openSetting();", spaces=2))
  1213. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1214. f.write(indented_str(4, "console.log(e);", spaces=2))
  1215. f.write(indented_str(3, "}", spaces=2))
  1216. f.write(indented_str(2, "}", spaces=2))
  1217. n = n + 1
  1218. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1219. f.write(indented_str(3, "try {", spaces=2))
  1220. f.write(indented_str(4, "CallNative.openProfile();", spaces=2))
  1221. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1222. f.write(indented_str(4, "console.log(e);", spaces=2))
  1223. f.write(indented_str(3, "}", spaces=2))
  1224. f.write(indented_str(2, "}", spaces=2))
  1225. n = n + 1
  1226. if features["cc"]["status"]:
  1227. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1228. f.write(indented_str(3, "try {", spaces=2))
  1229. f.write(indented_str(4, "CallNative.openContactCenter();", spaces=2))
  1230. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1231. f.write(indented_str(4, "console.log(e);", spaces=2))
  1232. f.write(indented_str(3, "}", spaces=2))
  1233. f.write(indented_str(2, "}", spaces=2))
  1234. n = n + 1
  1235. else:
  1236. f.write(indented_str(2, "// if (buttonIndex === 2) {", spaces=2))
  1237. f.write(indented_str(3, "// try {", spaces=2))
  1238. f.write(indented_str(4, "// CallNative.openContactCenter();", spaces=2))
  1239. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1240. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1241. f.write(indented_str(3, "// }", spaces=2))
  1242. f.write(indented_str(2, "// }", spaces=2))
  1243. if features["nc"]["status"]:
  1244. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1245. f.write(indented_str(3, "try {", spaces=2))
  1246. f.write(indented_str(4, "CallNative.openNotificationCenter();", spaces=2))
  1247. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1248. f.write(indented_str(4, "console.log(e);", spaces=2))
  1249. f.write(indented_str(3, "}", spaces=2))
  1250. f.write(indented_str(2, "}", spaces=2))
  1251. n = n + 1
  1252. else:
  1253. f.write(indented_str(2, "// if (buttonIndex === 3) {", spaces=2))
  1254. f.write(indented_str(3, "// try {", spaces=2))
  1255. f.write(indented_str(4, "// CallNative.openNotificationCenter();", spaces=2))
  1256. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1257. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1258. f.write(indented_str(3, "// }", spaces=2))
  1259. f.write(indented_str(2, "// }", spaces=2))
  1260. if features["im"]["status"]:
  1261. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1262. f.write(indented_str(3, "try {", spaces=2))
  1263. f.write(indented_str(4, "CallNative.openChat();", spaces=2))
  1264. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1265. f.write(indented_str(4, "console.log(e);", spaces=2))
  1266. f.write(indented_str(3, "}", spaces=2))
  1267. f.write(indented_str(2, "}", spaces=2))
  1268. n = n + 1
  1269. else:
  1270. f.write(indented_str(2, "// if (buttonIndex === 4) {", spaces=2))
  1271. f.write(indented_str(3, "// try {", spaces=2))
  1272. f.write(indented_str(4, "// CallNative.openChat();", spaces=2))
  1273. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1274. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1275. f.write(indented_str(3, "// }", spaces=2))
  1276. f.write(indented_str(2, "// }", spaces=2))
  1277. if features["call"]["status"]:
  1278. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1279. f.write(indented_str(3, "try {", spaces=2))
  1280. f.write(indented_str(4, "CallNative.openCall();", spaces=2))
  1281. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1282. f.write(indented_str(4, "console.log(e);", spaces=2))
  1283. f.write(indented_str(3, "}", spaces=2))
  1284. f.write(indented_str(2, "}", spaces=2))
  1285. n = n + 1
  1286. else:
  1287. f.write(indented_str(2, "// if (buttonIndex === 5) {", spaces=2))
  1288. f.write(indented_str(3, "// try {", spaces=2))
  1289. f.write(indented_str(4, "// CallNative.openCall();", spaces=2))
  1290. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1291. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1292. f.write(indented_str(3, "// }", spaces=2))
  1293. f.write(indented_str(2, "// }", spaces=2))
  1294. if features["ls"]["status"]:
  1295. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1296. f.write(indented_str(3, "try {", spaces=2))
  1297. f.write(indented_str(4, "CallNative.openStreaming();", spaces=2))
  1298. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1299. f.write(indented_str(4, "console.log(e);", spaces=2))
  1300. f.write(indented_str(3, "}", spaces=2))
  1301. f.write(indented_str(2, "}", spaces=2))
  1302. n = n + 1
  1303. else:
  1304. f.write(indented_str(2, "// if (buttonIndex === 6) {", spaces=2))
  1305. f.write(indented_str(3, "// try {", spaces=2))
  1306. f.write(indented_str(4, "// CallNative.openStreaming();", spaces=2))
  1307. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1308. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1309. f.write(indented_str(3, "// }", spaces=2))
  1310. f.write(indented_str(2, "// }", spaces=2))
  1311. if security["secure_folder"]:
  1312. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1313. f.write(indented_str(3, "try {", spaces=2))
  1314. f.write(indented_str(4, "CallNative.openSecureFolder();", spaces=2))
  1315. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1316. f.write(indented_str(4, "console.log(e);", spaces=2))
  1317. f.write(indented_str(3, "}", spaces=2))
  1318. f.write(indented_str(2, "}", spaces=2))
  1319. n = n + 1
  1320. else:
  1321. f.write(indented_str(2, "// if (buttonIndex === 7) {", spaces=2))
  1322. f.write(indented_str(3, "// try {", spaces=2))
  1323. f.write(indented_str(4, "// CallNative.openSecureFolder();", spaces=2))
  1324. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1325. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1326. f.write(indented_str(3, "// }", spaces=2))
  1327. f.write(indented_str(2, "// }", spaces=2))
  1328. elif "//FEATURES3" in line:
  1329. n = 0
  1330. f.write(indented_str(5, "<Button", spaces=2))
  1331. f.write(indented_str(6, 'title="Setting"', spaces=2))
  1332. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1333. f.write(indented_str(5, "/>", spaces=2))
  1334. n = n + 1
  1335. f.write(indented_str(5, "<Button", spaces=2))
  1336. f.write(indented_str(6, 'title="Profile"', spaces=2))
  1337. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1338. f.write(indented_str(5, "/>", spaces=2))
  1339. n = n + 1
  1340. if features["cc"]["status"]:
  1341. f.write(indented_str(5, "<Button", spaces=2))
  1342. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  1343. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1344. f.write(indented_str(5, "/>", spaces=2))
  1345. n = n + 1
  1346. else:
  1347. f.write(indented_str(5, "{/* <Button", spaces=2))
  1348. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  1349. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(2)}}', spaces=2))
  1350. f.write(indented_str(5, "/> */}", spaces=2))
  1351. if features["nc"]["status"]:
  1352. f.write(indented_str(5, "<Button", spaces=2))
  1353. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  1354. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1355. f.write(indented_str(5, "/>", spaces=2))
  1356. n = n + 1
  1357. else:
  1358. f.write(indented_str(5, "{/* <Button", spaces=2))
  1359. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  1360. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(3)}}', spaces=2))
  1361. f.write(indented_str(5, "/> */}", spaces=2))
  1362. if features["im"]["status"]:
  1363. f.write(indented_str(5, "<Button", spaces=2))
  1364. f.write(indented_str(6, 'title="Chat"', spaces=2))
  1365. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1366. f.write(indented_str(5, "/>", spaces=2))
  1367. n = n + 1
  1368. else:
  1369. f.write(indented_str(5, "{/* <Button", spaces=2))
  1370. f.write(indented_str(6, 'title="Chat"', spaces=2))
  1371. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(4)}}', spaces=2))
  1372. f.write(indented_str(5, "/> */}", spaces=2))
  1373. if features["call"]["status"]:
  1374. f.write(indented_str(5, "<Button", spaces=2))
  1375. f.write(indented_str(6, 'title="Call"', spaces=2))
  1376. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1377. f.write(indented_str(5, "/>", spaces=2))
  1378. n = n + 1
  1379. else:
  1380. f.write(indented_str(5, "{/* <Button", spaces=2))
  1381. f.write(indented_str(6, 'title="Call"', spaces=2))
  1382. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(5)}}', spaces=2))
  1383. f.write(indented_str(5, "/> */}", spaces=2))
  1384. if features["ls"]["status"]:
  1385. f.write(indented_str(5, "<Button", spaces=2))
  1386. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  1387. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1388. f.write(indented_str(5, "/>", spaces=2))
  1389. n = n + 1
  1390. else:
  1391. f.write(indented_str(5, "{/* <Button", spaces=2))
  1392. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  1393. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(6)}}', spaces=2))
  1394. f.write(indented_str(5, "/> */}", spaces=2))
  1395. if security["secure_folder"]:
  1396. f.write(indented_str(5, "<Button", spaces=2))
  1397. f.write(indented_str(6, 'title="Secure Folder"', spaces=2))
  1398. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  1399. f.write(indented_str(5, "/>", spaces=2))
  1400. n = n + 1
  1401. else:
  1402. f.write(indented_str(5, "{/* <Button", spaces=2))
  1403. f.write(indented_str(6, 'title="Secure Folder"', spaces=2))
  1404. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(7)}}', spaces=2))
  1405. f.write(indented_str(5, "/> */}", spaces=2))
  1406. else:
  1407. f.write(line)
  1408. with open(main_act_android, "r") as f:
  1409. lines = f.readlines()
  1410. with open(main_act_android, "w") as f:
  1411. for line in lines:
  1412. if "//SECURITY" in line:
  1413. if security["show_security"]:
  1414. f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);"))
  1415. f.write(os.linesep)
  1416. else:
  1417. f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);"))
  1418. f.write(os.linesep)
  1419. if security["emulator"]:
  1420. f.write(indented_str(2, "API.setCheckEmulator(true);"))
  1421. f.write(os.linesep)
  1422. else:
  1423. f.write(indented_str(2, "// API.setCheckEmulator(true);"))
  1424. f.write(os.linesep)
  1425. if security["debug"]:
  1426. f.write(indented_str(2, "API.setCheckAdb(true);"))
  1427. f.write(os.linesep)
  1428. else:
  1429. f.write(indented_str(2, "// API.setCheckAdb(true);"))
  1430. f.write(os.linesep)
  1431. if security["sim_swap"]:
  1432. f.write(indented_str(2, "API.setCheckSimSwap(true);"))
  1433. f.write(os.linesep)
  1434. else:
  1435. f.write(indented_str(2, "// API.setCheckSimSwap(true);"))
  1436. f.write(os.linesep)
  1437. if security["malware"]:
  1438. f.write(indented_str(2, "API.setCheckMalware(true);"))
  1439. f.write(os.linesep)
  1440. else:
  1441. f.write(indented_str(2, "// API.setCheckMalware(true);"))
  1442. f.write(os.linesep)
  1443. if security["capture"]:
  1444. f.write(indented_str(2, "API.setPreventScreenCapture(true);"))
  1445. f.write(os.linesep)
  1446. else:
  1447. f.write(indented_str(2, "// API.setPreventScreenCapture(true);"))
  1448. f.write(os.linesep)
  1449. if security["call_forwarding"]:
  1450. f.write(indented_str(2, "API.setCheckCallForwarding(true);"))
  1451. f.write(os.linesep)
  1452. else:
  1453. f.write(indented_str(2, "// API.setCheckCallForwarding(true);"))
  1454. f.write(os.linesep)
  1455. if security["screen_share"]:
  1456. f.write(indented_str(2, "API.setCheckScreenCasting(true);"))
  1457. f.write(os.linesep)
  1458. else:
  1459. f.write(indented_str(2, "// API.setCheckScreenCasting(true);"))
  1460. f.write(os.linesep)
  1461. if security["side_load"]:
  1462. f.write(indented_str(2, "API.setCheckSideLoadedApp(true);"))
  1463. f.write(os.linesep)
  1464. else:
  1465. f.write(indented_str(2, "// API.setCheckSideLoadedApp(true);"))
  1466. f.write(os.linesep)
  1467. if security["key_logger"]:
  1468. f.write(indented_str(2, "API.setPreventKeylogger(true);"))
  1469. f.write(os.linesep)
  1470. else:
  1471. f.write(indented_str(2, "// API.setPreventKeylogger(true);"))
  1472. f.write(os.linesep)
  1473. elif "//SMS" in line:
  1474. if features["sms"]["status"]:
  1475. f.write(indented_str(2, "API.setEnabledSMS(true);"))
  1476. else:
  1477. f.write(indented_str(2, "// API.setEnabledSMS(true);"))
  1478. elif "//EMAIL" in line:
  1479. if features["email"]["status"]:
  1480. f.write(indented_str(2, "API.setEnabledEmail(true);"))
  1481. else:
  1482. f.write(indented_str(2, "// API.setEnabledEmail(true);"))
  1483. elif "//SMARTBOT" in line:
  1484. if features["smartbot"]["status"]:
  1485. f.write(indented_str(2, "API.setEnabledSmartBot(true);"))
  1486. else:
  1487. f.write(indented_str(2, "// API.setEnabledSmartBot(true);"))
  1488. elif "//FLOATING" in line:
  1489. if mode == "floating":
  1490. f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();"))
  1491. if features["cc"]["status"]:
  1492. f.write(indented_str(6,
  1493. 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  1494. else:
  1495. f.write(indented_str(6,
  1496. '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
  1497. if features["nc"]["status"]:
  1498. f.write(
  1499. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  1500. else:
  1501. f.write(indented_str(6,
  1502. '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
  1503. if features["im"]["status"]:
  1504. f.write(
  1505. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  1506. else:
  1507. f.write(indented_str(6,
  1508. '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
  1509. if features["call"]["status"]:
  1510. f.write(
  1511. indented_str(6,
  1512. 'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  1513. else:
  1514. f.write(indented_str(6,
  1515. '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
  1516. if features["ls"]["status"]:
  1517. f.write(
  1518. indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  1519. else:
  1520. f.write(indented_str(6,
  1521. '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
  1522. if security["secure_folder"]:
  1523. f.write(
  1524. indented_str(6,
  1525. 'fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  1526. else:
  1527. f.write(indented_str(6,
  1528. '// fb.add(new FloatingButton(FloatingButton.FEATURE.SECURE_FOLDER, ""));'))
  1529. f.write(indented_str(6,
  1530. 'API.configureFloating(fb);'))
  1531. else:
  1532. f.write(indented_str(0, ""))
  1533. elif "API.connect" in line:
  1534. replaced = line
  1535. if app_id:
  1536. replaced = replaced.replace('***REPLACE***WITH***YOUR***APPLICATION***NAME***', app_id)
  1537. if mode == "floating":
  1538. replaced = replaced.replace("0", "1")
  1539. f.write(replaced)
  1540. else:
  1541. f.write(line)
  1542. write_android_manifest(manifest_path, features, security)
  1543. elif platform == "ios":
  1544. main_act_path = os.path.join(path_dest, "ExampleCode/ViewController.swift")
  1545. with open(main_act_path, "r") as f:
  1546. lines = f.readlines()
  1547. with open(main_act_path, "w") as f:
  1548. for line in lines:
  1549. if "//FEATURES" in line:
  1550. f.write(indented_str(3, 'UIAction(title: "Setting".localized(), handler: {(_) in'))
  1551. f.write(indented_str(4, "APIS.openSetting();"))
  1552. f.write(indented_str(3, "}),"))
  1553. f.write(indented_str(3, 'UIAction(title: "Profile".localized(), handler: {(_) in'))
  1554. f.write(indented_str(4, "APIS.openProfile();"))
  1555. f.write(indented_str(3, "}),"))
  1556. if features["cc"]["status"]:
  1557. f.write(indented_str(3, 'UIAction(title: "Contact Center".localized(), handler: {(_) in'))
  1558. f.write(indented_str(4, "APIS.openContactCenter();"))
  1559. f.write(indented_str(3, "}),"))
  1560. else:
  1561. f.write(indented_str(3, '// UIAction(title: "Contact Center".localized(), handler: {(_) in'))
  1562. f.write(indented_str(4, "// APIS.openContactCenter();"))
  1563. f.write(indented_str(3, "// }),"))
  1564. if features["nc"]["status"]:
  1565. f.write(indented_str(3, 'UIAction(title: "Notification Center".localized(), handler: {(_) in'))
  1566. f.write(indented_str(4, "APIS.openNotificationCenter();"))
  1567. f.write(indented_str(3, "}),"))
  1568. else:
  1569. f.write(
  1570. indented_str(3, '// UIAction(title: "Notification Center".localized(), handler: {(_) in'))
  1571. f.write(indented_str(4, "// APIS.openNotificationCenter();"))
  1572. f.write(indented_str(3, "// }),"))
  1573. if features["im"]["status"]:
  1574. f.write(indented_str(3, 'UIAction(title: "Chat".localized(), handler: {(_) in'))
  1575. f.write(indented_str(4, "APIS.openChat();"))
  1576. f.write(indented_str(3, "}),"))
  1577. else:
  1578. f.write(indented_str(3, '// UIAction(title: "Chat".localized(), handler: {(_) in'))
  1579. f.write(indented_str(4, "// APIS.openChat();"))
  1580. f.write(indented_str(3, "// }),"))
  1581. if features["call"]["status"]:
  1582. f.write(indented_str(3, 'UIAction(title: "Call".localized(), handler: {(_) in'))
  1583. f.write(indented_str(4, "APIS.openCall();"))
  1584. f.write(indented_str(3, "}),"))
  1585. else:
  1586. f.write(indented_str(3, '// UIAction(title: "Call".localized(), handler: {(_) in'))
  1587. f.write(indented_str(4, "// APIS.openCall();"))
  1588. f.write(indented_str(3, "// }),"))
  1589. if features["ls"]["status"]:
  1590. f.write(indented_str(3, 'UIAction(title: "Live Streaming".localized(), handler: {(_) in'))
  1591. f.write(indented_str(4, "APIS.openStreaming();"))
  1592. f.write(indented_str(3, "}),"))
  1593. else:
  1594. f.write(indented_str(3, '// UIAction(title: "Live Streaming".localized(), handler: {(_) in'))
  1595. f.write(indented_str(4, "// APIS.openStreaming();"))
  1596. f.write(indented_str(3, "// }),"))
  1597. elif "//FLOATING" in line:
  1598. if mode == "floating":
  1599. if features["cc"]["status"]:
  1600. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1601. else:
  1602. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1603. if features["nc"]["status"]:
  1604. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1605. else:
  1606. f.write(
  1607. indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1608. if features["im"]["status"]:
  1609. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1610. else:
  1611. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1612. if features["call"]["status"]:
  1613. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1614. else:
  1615. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1616. if features["ls"]["status"]:
  1617. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1618. else:
  1619. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1620. else:
  1621. f.write(indented_str(0, ""))
  1622. elif "APIS.connect" in line:
  1623. if mode == "floating":
  1624. replaced = line.replace("false", "true")
  1625. f.write(replaced)
  1626. else:
  1627. f.write(line)
  1628. else:
  1629. f.write(line)
  1630. elif platform == "ios_flutter":
  1631. main_act_path = os.path.join(path_dest, "lib/main.dart")
  1632. main_act_ios = os.path.join(path_dest, "ios/Runner/AppDelegate.swift")
  1633. with open(main_act_path, "r") as f:
  1634. lines = f.readlines()
  1635. with open(main_act_path, "w") as f:
  1636. features_str = []
  1637. for line in lines:
  1638. if "'Features List'" in line:
  1639. features_str.append("'Settings'")
  1640. features_str.append("'Profile'")
  1641. if features["cc"]["status"]:
  1642. features_str.append("'Contact Center'")
  1643. else:
  1644. features_str.append("// 'Contact Center'")
  1645. if features["nc"]["status"]:
  1646. features_str.append("'Notification Center'")
  1647. else:
  1648. features_str.append("// 'Notification Center'")
  1649. if features["im"]["status"]:
  1650. features_str.append("'Instant Messaging'")
  1651. else:
  1652. features_str.append("// 'Instant Messaging'")
  1653. if features["call"]["status"]:
  1654. features_str.append("'Call'")
  1655. else:
  1656. features_str.append("// 'Call'")
  1657. if features["ls"]["status"]:
  1658. features_str.append("'Streaming'")
  1659. else:
  1660. features_str.append("// 'Streaming'")
  1661. for feature_str in features_str:
  1662. f.write(indented_str(8, f"{feature_str},", spaces=2))
  1663. elif "//FEATURES" in line:
  1664. f.write(indented_str(3, 'case "Settings":', spaces=2))
  1665. f.write(indented_str(4, 'nativeChannel.invokeMethod("openSettings");', spaces=2))
  1666. f.write(indented_str(4, "break;", spaces=2))
  1667. f.write(indented_str(3, 'case "Profile":', spaces=2))
  1668. f.write(indented_str(4, 'nativeChannel.invokeMethod("openProfile");', spaces=2))
  1669. f.write(indented_str(4, "break;", spaces=2))
  1670. if features["cc"]["status"]:
  1671. f.write(indented_str(3, 'case "Contact Center":', spaces=2))
  1672. f.write(indented_str(4, 'nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  1673. f.write(indented_str(4, "break;", spaces=2))
  1674. else:
  1675. f.write(indented_str(3, '// case "Contact Center":', spaces=2))
  1676. f.write(indented_str(4, '// nativeChannel.invokeMethod("openContactCenter");', spaces=2))
  1677. f.write(indented_str(4, "// break;", spaces=2))
  1678. if features["nc"]["status"]:
  1679. f.write(indented_str(3, 'case "Notification Center":', spaces=2))
  1680. f.write(indented_str(4, 'nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  1681. f.write(indented_str(4, "break;", spaces=2))
  1682. else:
  1683. f.write(indented_str(3, '// case "Notification Center":', spaces=2))
  1684. f.write(indented_str(4, '// nativeChannel.invokeMethod("openNotificationCenter");', spaces=2))
  1685. f.write(indented_str(4, "// break;", spaces=2))
  1686. if features["im"]["status"]:
  1687. f.write(indented_str(3, 'case "Instant Messaging":', spaces=2))
  1688. f.write(indented_str(4, 'nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  1689. f.write(indented_str(4, "break;", spaces=2))
  1690. else:
  1691. f.write(indented_str(3, '// case "Instant Messaging":', spaces=2))
  1692. f.write(indented_str(4, '// nativeChannel.invokeMethod("openInstantMessaging");', spaces=2))
  1693. f.write(indented_str(4, "// break;", spaces=2))
  1694. if features["call"]["status"]:
  1695. f.write(indented_str(3, 'case "Call":', spaces=2))
  1696. f.write(indented_str(4, 'nativeChannel.invokeMethod("openCall");', spaces=2))
  1697. f.write(indented_str(4, "break;", spaces=2))
  1698. else:
  1699. f.write(indented_str(3, '// case "Call":', spaces=2))
  1700. f.write(indented_str(4, '// nativeChannel.invokeMethod("openCall");', spaces=2))
  1701. f.write(indented_str(4, "// break;", spaces=2))
  1702. if features["ls"]["status"]:
  1703. f.write(indented_str(3, 'case "Streaming":', spaces=2))
  1704. f.write(indented_str(4, 'nativeChannel.invokeMethod("openStreaming");', spaces=2))
  1705. f.write(indented_str(4, "break;", spaces=2))
  1706. else:
  1707. f.write(indented_str(3, '// case "Streaming":', spaces=2))
  1708. f.write(indented_str(4, '// nativeChannel.invokeMethod("openStreaming");', spaces=2))
  1709. f.write(indented_str(4, "// break;", spaces=2))
  1710. else:
  1711. f.write(line)
  1712. with open(main_act_ios, "r") as f:
  1713. lines = f.readlines()
  1714. with open(main_act_ios, "w") as f:
  1715. for line in lines:
  1716. if "//FLOATING" in line:
  1717. if mode == "floating":
  1718. if features["cc"]["status"]:
  1719. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1720. else:
  1721. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1722. if features["nc"]["status"]:
  1723. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1724. else:
  1725. f.write(
  1726. indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1727. if features["im"]["status"]:
  1728. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1729. else:
  1730. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1731. if features["call"]["status"]:
  1732. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1733. else:
  1734. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1735. if features["ls"]["status"]:
  1736. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1737. else:
  1738. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1739. else:
  1740. f.write(indented_str(0, ""))
  1741. elif "APIS.connect" in line:
  1742. if mode == "floating":
  1743. replaced = line.replace("false", "true")
  1744. f.write(replaced)
  1745. else:
  1746. f.write(line)
  1747. else:
  1748. f.write(line)
  1749. elif platform == "ios_ionic":
  1750. main_act_path = os.path.join(path_dest, "src/app/app.component.ts")
  1751. main_act_ios = os.path.join(path_dest, "ios/App/App/AppDelegate.swift")
  1752. with open(main_act_path, "r") as f:
  1753. lines = f.readlines()
  1754. with open(main_act_path, "w") as f:
  1755. for line in lines:
  1756. if "//FEATURES" in line:
  1757. f.write(indented_str(4, '{', spaces=2))
  1758. f.write(indented_str(5, "text: 'Settings',", spaces=2))
  1759. f.write(indented_str(5, "handler: () => {", spaces=2))
  1760. f.write(indented_str(6, "this.openSettings();", spaces=2))
  1761. f.write(indented_str(5, "},", spaces=2))
  1762. f.write(indented_str(4, "},", spaces=2))
  1763. f.write(indented_str(4, '{', spaces=2))
  1764. f.write(indented_str(5, "text: 'Profile',", spaces=2))
  1765. f.write(indented_str(5, "handler: () => {", spaces=2))
  1766. f.write(indented_str(6, "this.openProfile();", spaces=2))
  1767. f.write(indented_str(5, "},", spaces=2))
  1768. f.write(indented_str(4, "},", spaces=2))
  1769. if features["cc"]["status"]:
  1770. f.write(indented_str(4, '{', spaces=2))
  1771. f.write(indented_str(5, "text: 'Contact Center',", spaces=2))
  1772. f.write(indented_str(5, "handler: () => {", spaces=2))
  1773. f.write(indented_str(6, "this.openContactCenter();", spaces=2))
  1774. f.write(indented_str(5, "},", spaces=2))
  1775. f.write(indented_str(4, "},", spaces=2))
  1776. else:
  1777. f.write(indented_str(4, '// {', spaces=2))
  1778. f.write(indented_str(5, "// text: 'Contact Center',", spaces=2))
  1779. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1780. f.write(indented_str(6, "// this.openContactCenter();", spaces=2))
  1781. f.write(indented_str(5, "// },", spaces=2))
  1782. f.write(indented_str(4, "// },", spaces=2))
  1783. if features["nc"]["status"]:
  1784. f.write(indented_str(4, '{', spaces=2))
  1785. f.write(indented_str(5, "text: 'Notification Center',", spaces=2))
  1786. f.write(indented_str(5, "handler: () => {", spaces=2))
  1787. f.write(indented_str(6, "this.openNotificationCenter();", spaces=2))
  1788. f.write(indented_str(5, "},", spaces=2))
  1789. f.write(indented_str(4, "},", spaces=2))
  1790. else:
  1791. f.write(indented_str(4, '// {', spaces=2))
  1792. f.write(indented_str(5, "// text: 'Notification Center',", spaces=2))
  1793. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1794. f.write(indented_str(6, "// this.openNotificationCenter();", spaces=2))
  1795. f.write(indented_str(5, "// },", spaces=2))
  1796. f.write(indented_str(4, "// },", spaces=2))
  1797. if features["im"]["status"]:
  1798. f.write(indented_str(4, '{', spaces=2))
  1799. f.write(indented_str(5, "text: 'Instant Messaging',", spaces=2))
  1800. f.write(indented_str(5, "handler: () => {", spaces=2))
  1801. f.write(indented_str(6, "this.openChat();", spaces=2))
  1802. f.write(indented_str(5, "},", spaces=2))
  1803. f.write(indented_str(4, "},", spaces=2))
  1804. else:
  1805. f.write(indented_str(4, '// {', spaces=2))
  1806. f.write(indented_str(5, "// text: 'Instant Messaging',", spaces=2))
  1807. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1808. f.write(indented_str(6, "// this.openChat();", spaces=2))
  1809. f.write(indented_str(5, "// },", spaces=2))
  1810. f.write(indented_str(4, "// },", spaces=2))
  1811. if features["call"]["status"]:
  1812. f.write(indented_str(4, '{', spaces=2))
  1813. f.write(indented_str(5, "text: 'Call',", spaces=2))
  1814. f.write(indented_str(5, "handler: () => {", spaces=2))
  1815. f.write(indented_str(6, "this.openCall();", spaces=2))
  1816. f.write(indented_str(5, "},", spaces=2))
  1817. f.write(indented_str(4, "},", spaces=2))
  1818. else:
  1819. f.write(indented_str(4, '// {', spaces=2))
  1820. f.write(indented_str(5, "// text: 'Call',", spaces=2))
  1821. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1822. f.write(indented_str(6, "// this.openCall();", spaces=2))
  1823. f.write(indented_str(5, "// },", spaces=2))
  1824. f.write(indented_str(4, "// },", spaces=2))
  1825. if features["ls"]["status"]:
  1826. f.write(indented_str(4, '{', spaces=2))
  1827. f.write(indented_str(5, "text: 'Streaming',", spaces=2))
  1828. f.write(indented_str(5, "handler: () => {", spaces=2))
  1829. f.write(indented_str(6, "this.openStreaming();", spaces=2))
  1830. f.write(indented_str(5, "},", spaces=2))
  1831. f.write(indented_str(4, "},", spaces=2))
  1832. else:
  1833. f.write(indented_str(4, '// {', spaces=2))
  1834. f.write(indented_str(5, "// text: 'Streaming',", spaces=2))
  1835. f.write(indented_str(5, "// handler: () => {", spaces=2))
  1836. f.write(indented_str(6, "// this.openStreaming();", spaces=2))
  1837. f.write(indented_str(5, "// },", spaces=2))
  1838. f.write(indented_str(4, "// },", spaces=2))
  1839. else:
  1840. f.write(line)
  1841. with open(main_act_ios, "r") as f:
  1842. lines = f.readlines()
  1843. with open(main_act_ios, "w") as f:
  1844. for line in lines:
  1845. if "//FLOATING" in line:
  1846. if mode == "floating":
  1847. if features["cc"]["status"]:
  1848. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1849. else:
  1850. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  1851. if features["nc"]["status"]:
  1852. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1853. else:
  1854. f.write(
  1855. indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  1856. if features["im"]["status"]:
  1857. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1858. else:
  1859. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  1860. if features["call"]["status"]:
  1861. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1862. else:
  1863. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  1864. if features["ls"]["status"]:
  1865. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1866. else:
  1867. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  1868. else:
  1869. f.write(indented_str(0, ""))
  1870. elif "APIS.connect" in line:
  1871. if mode == "floating":
  1872. replaced = line.replace("false", "true")
  1873. f.write(replaced)
  1874. else:
  1875. f.write(line)
  1876. else:
  1877. f.write(line)
  1878. elif platform == "ios_react":
  1879. main_act_path = os.path.join(path_dest, "App.tsx")
  1880. main_act_ios = os.path.join(path_dest, "ios/CallNative.swift")
  1881. with open(main_act_path, "r") as f:
  1882. lines = f.readlines()
  1883. with open(main_act_path, "w") as f:
  1884. for line in lines:
  1885. if "'Features'" in line:
  1886. f.write(indented_str(4, "'Setting',", spaces=2))
  1887. f.write(indented_str(4, "'Profile',", spaces=2))
  1888. if features["cc"]["status"]:
  1889. f.write(indented_str(4, "'Contact Center',", spaces=2))
  1890. else:
  1891. f.write(indented_str(4, "// 'Contact Center',", spaces=2))
  1892. if features["nc"]["status"]:
  1893. f.write(indented_str(4, "'Notification Center',", spaces=2))
  1894. else:
  1895. f.write(indented_str(4, "// 'Notification Center',", spaces=2))
  1896. if features["im"]["status"]:
  1897. f.write(indented_str(4, "'Chat',", spaces=2))
  1898. else:
  1899. f.write(indented_str(4, "// 'Chat',", spaces=2))
  1900. if features["call"]["status"]:
  1901. f.write(indented_str(4, "'Call',", spaces=2))
  1902. else:
  1903. f.write(indented_str(4, "// 'Call',", spaces=2))
  1904. if features["ls"]["status"]:
  1905. f.write(indented_str(4, "'Live Streaming',", spaces=2))
  1906. else:
  1907. f.write(indented_str(4, "// 'Live Streaming',", spaces=2))
  1908. elif "//FEATURES1" in line:
  1909. n = 0
  1910. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1911. f.write(indented_str(6, "CallNative.openSetting();", spaces=2))
  1912. f.write(indented_str(5, "}", spaces=2))
  1913. n = n + 1
  1914. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1915. f.write(indented_str(6, "CallNative.openProfile();", spaces=2))
  1916. f.write(indented_str(5, "}", spaces=2))
  1917. n = n + 1
  1918. if features["cc"]["status"]:
  1919. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1920. f.write(indented_str(6, "CallNative.openContactCenter();", spaces=2))
  1921. f.write(indented_str(5, "}", spaces=2))
  1922. n = n + 1
  1923. else:
  1924. f.write(indented_str(5, "// if (buttonIndex === 2) {", spaces=2))
  1925. f.write(indented_str(6, "// CallNative.openContactCenter();", spaces=2))
  1926. f.write(indented_str(5, "// }", spaces=2))
  1927. if features["nc"]["status"]:
  1928. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1929. f.write(indented_str(6, "CallNative.openNotificationCenter();", spaces=2))
  1930. f.write(indented_str(5, "}", spaces=2))
  1931. n = n + 1
  1932. else:
  1933. f.write(indented_str(5, "// if (buttonIndex === 3) {", spaces=2))
  1934. f.write(indented_str(6, "// CallNative.openNotificationCenter();", spaces=2))
  1935. f.write(indented_str(5, "// }", spaces=2))
  1936. if features["im"]["status"]:
  1937. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1938. f.write(indented_str(6, "CallNative.openChat();", spaces=2))
  1939. f.write(indented_str(5, "}", spaces=2))
  1940. n = n + 1
  1941. else:
  1942. f.write(indented_str(5, "// if (buttonIndex === 4) {", spaces=2))
  1943. f.write(indented_str(6, "// CallNative.openChat();", spaces=2))
  1944. f.write(indented_str(5, "// }", spaces=2))
  1945. if features["call"]["status"]:
  1946. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1947. f.write(indented_str(6, "CallNative.openCall();", spaces=2))
  1948. f.write(indented_str(5, "}", spaces=2))
  1949. n = n + 1
  1950. else:
  1951. f.write(indented_str(5, "// if (buttonIndex === 5) {", spaces=2))
  1952. f.write(indented_str(6, "// CallNative.openCall();", spaces=2))
  1953. f.write(indented_str(5, "// }", spaces=2))
  1954. if features["ls"]["status"]:
  1955. f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
  1956. f.write(indented_str(6, "CallNative.openStreaming();", spaces=2))
  1957. f.write(indented_str(5, "}", spaces=2))
  1958. n = n + 1
  1959. else:
  1960. f.write(indented_str(5, "// if (buttonIndex === 6) {", spaces=2))
  1961. f.write(indented_str(6, "// CallNative.openStreaming();", spaces=2))
  1962. f.write(indented_str(5, "// }", spaces=2))
  1963. elif "//FEATURES2" in line:
  1964. n = 0
  1965. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1966. f.write(indented_str(3, "try {", spaces=2))
  1967. f.write(indented_str(4, "CallNative.openSetting();", spaces=2))
  1968. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1969. f.write(indented_str(4, "console.log(e);", spaces=2))
  1970. f.write(indented_str(3, "}", spaces=2))
  1971. f.write(indented_str(2, "}", spaces=2))
  1972. n = n + 1
  1973. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1974. f.write(indented_str(3, "try {", spaces=2))
  1975. f.write(indented_str(4, "CallNative.openProfile();", spaces=2))
  1976. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1977. f.write(indented_str(4, "console.log(e);", spaces=2))
  1978. f.write(indented_str(3, "}", spaces=2))
  1979. f.write(indented_str(2, "}", spaces=2))
  1980. n = n + 1
  1981. if features["cc"]["status"]:
  1982. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  1983. f.write(indented_str(3, "try {", spaces=2))
  1984. f.write(indented_str(4, "CallNative.openContactCenter();", spaces=2))
  1985. f.write(indented_str(3, "} catch (e) {", spaces=2))
  1986. f.write(indented_str(4, "console.log(e);", spaces=2))
  1987. f.write(indented_str(3, "}", spaces=2))
  1988. f.write(indented_str(2, "}", spaces=2))
  1989. n = n + 1
  1990. else:
  1991. f.write(indented_str(2, "// if (buttonIndex === 2) {", spaces=2))
  1992. f.write(indented_str(3, "// try {", spaces=2))
  1993. f.write(indented_str(4, "// CallNative.openContactCenter();", spaces=2))
  1994. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  1995. f.write(indented_str(4, "// console.log(e);", spaces=2))
  1996. f.write(indented_str(3, "// }", spaces=2))
  1997. f.write(indented_str(2, "// }", spaces=2))
  1998. if features["nc"]["status"]:
  1999. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  2000. f.write(indented_str(3, "try {", spaces=2))
  2001. f.write(indented_str(4, "CallNative.openNotificationCenter();", spaces=2))
  2002. f.write(indented_str(3, "} catch (e) {", spaces=2))
  2003. f.write(indented_str(4, "console.log(e);", spaces=2))
  2004. f.write(indented_str(3, "}", spaces=2))
  2005. f.write(indented_str(2, "}", spaces=2))
  2006. n = n + 1
  2007. else:
  2008. f.write(indented_str(2, "// if (buttonIndex === 3) {", spaces=2))
  2009. f.write(indented_str(3, "// try {", spaces=2))
  2010. f.write(indented_str(4, "// CallNative.openNotificationCenter();", spaces=2))
  2011. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  2012. f.write(indented_str(4, "// console.log(e);", spaces=2))
  2013. f.write(indented_str(3, "// }", spaces=2))
  2014. f.write(indented_str(2, "// }", spaces=2))
  2015. if features["im"]["status"]:
  2016. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  2017. f.write(indented_str(3, "try {", spaces=2))
  2018. f.write(indented_str(4, "CallNative.openChat();", spaces=2))
  2019. f.write(indented_str(3, "} catch (e) {", spaces=2))
  2020. f.write(indented_str(4, "console.log(e);", spaces=2))
  2021. f.write(indented_str(3, "}", spaces=2))
  2022. f.write(indented_str(2, "}", spaces=2))
  2023. n = n + 1
  2024. else:
  2025. f.write(indented_str(2, "// if (buttonIndex === 4) {", spaces=2))
  2026. f.write(indented_str(3, "// try {", spaces=2))
  2027. f.write(indented_str(4, "// CallNative.openChat();", spaces=2))
  2028. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  2029. f.write(indented_str(4, "// console.log(e);", spaces=2))
  2030. f.write(indented_str(3, "// }", spaces=2))
  2031. f.write(indented_str(2, "// }", spaces=2))
  2032. if features["call"]["status"]:
  2033. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  2034. f.write(indented_str(3, "try {", spaces=2))
  2035. f.write(indented_str(4, "CallNative.openCall();", spaces=2))
  2036. f.write(indented_str(3, "} catch (e) {", spaces=2))
  2037. f.write(indented_str(4, "console.log(e);", spaces=2))
  2038. f.write(indented_str(3, "}", spaces=2))
  2039. f.write(indented_str(2, "}", spaces=2))
  2040. n = n + 1
  2041. else:
  2042. f.write(indented_str(2, "// if (buttonIndex === 5) {", spaces=2))
  2043. f.write(indented_str(3, "// try {", spaces=2))
  2044. f.write(indented_str(4, "// CallNative.openCall();", spaces=2))
  2045. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  2046. f.write(indented_str(4, "// console.log(e);", spaces=2))
  2047. f.write(indented_str(3, "// }", spaces=2))
  2048. f.write(indented_str(2, "// }", spaces=2))
  2049. if features["ls"]["status"]:
  2050. f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
  2051. f.write(indented_str(3, "try {", spaces=2))
  2052. f.write(indented_str(4, "CallNative.openStreaming();", spaces=2))
  2053. f.write(indented_str(3, "} catch (e) {", spaces=2))
  2054. f.write(indented_str(4, "console.log(e);", spaces=2))
  2055. f.write(indented_str(3, "}", spaces=2))
  2056. f.write(indented_str(2, "}", spaces=2))
  2057. n = n + 1
  2058. else:
  2059. f.write(indented_str(2, "// if (buttonIndex === {n}) {", spaces=2))
  2060. f.write(indented_str(3, "// try {", spaces=2))
  2061. f.write(indented_str(4, "// CallNative.openStreaming();", spaces=2))
  2062. f.write(indented_str(3, "// } catch (e) {", spaces=2))
  2063. f.write(indented_str(4, "// console.log(e);", spaces=2))
  2064. f.write(indented_str(3, "// }", spaces=2))
  2065. f.write(indented_str(2, "// }", spaces=2))
  2066. elif "//FEATURES3" in line:
  2067. n = 0
  2068. f.write(indented_str(5, "<Button", spaces=2))
  2069. f.write(indented_str(6, 'title="Setting"', spaces=2))
  2070. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  2071. f.write(indented_str(5, "/>", spaces=2))
  2072. n = n + 1
  2073. f.write(indented_str(5, "<Button", spaces=2))
  2074. f.write(indented_str(6, 'title="Profile"', spaces=2))
  2075. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  2076. f.write(indented_str(5, "/>", spaces=2))
  2077. n = n + 1
  2078. if features["cc"]["status"]:
  2079. f.write(indented_str(5, "<Button", spaces=2))
  2080. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  2081. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  2082. f.write(indented_str(5, "/>", spaces=2))
  2083. n = n + 1
  2084. else:
  2085. f.write(indented_str(5, "{/* <Button", spaces=2))
  2086. f.write(indented_str(6, 'title="Contact Center"', spaces=2))
  2087. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(2)}}', spaces=2))
  2088. f.write(indented_str(5, "/> */}", spaces=2))
  2089. if features["nc"]["status"]:
  2090. f.write(indented_str(5, "<Button", spaces=2))
  2091. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  2092. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  2093. f.write(indented_str(5, "/>", spaces=2))
  2094. n = n + 1
  2095. else:
  2096. f.write(indented_str(5, "{/* <Button", spaces=2))
  2097. f.write(indented_str(6, 'title="Notification Center"', spaces=2))
  2098. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(3)}}', spaces=2))
  2099. f.write(indented_str(5, "/> */}", spaces=2))
  2100. if features["im"]["status"]:
  2101. f.write(indented_str(5, "<Button", spaces=2))
  2102. f.write(indented_str(6, 'title="Chat"', spaces=2))
  2103. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  2104. f.write(indented_str(5, "/>", spaces=2))
  2105. n = n + 1
  2106. else:
  2107. f.write(indented_str(5, "{/* <Button", spaces=2))
  2108. f.write(indented_str(6, 'title="Chat"', spaces=2))
  2109. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(4)}}', spaces=2))
  2110. f.write(indented_str(5, "/> */}", spaces=2))
  2111. if features["call"]["status"]:
  2112. f.write(indented_str(5, "<Button", spaces=2))
  2113. f.write(indented_str(6, 'title="Call"', spaces=2))
  2114. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  2115. f.write(indented_str(5, "/>", spaces=2))
  2116. n = n + 1
  2117. else:
  2118. f.write(indented_str(5, "{/* <Button", spaces=2))
  2119. f.write(indented_str(6, 'title="Call"', spaces=2))
  2120. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(5)}}', spaces=2))
  2121. f.write(indented_str(5, "/> */}", spaces=2))
  2122. if features["ls"]["status"]:
  2123. f.write(indented_str(5, "<Button", spaces=2))
  2124. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  2125. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
  2126. f.write(indented_str(5, "/>", spaces=2))
  2127. n = n + 1
  2128. else:
  2129. f.write(indented_str(5, "{/* <Button", spaces=2))
  2130. f.write(indented_str(6, 'title="Live Streaming"', spaces=2))
  2131. f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(5)}}', spaces=2))
  2132. f.write(indented_str(5, "/> */}", spaces=2))
  2133. else:
  2134. f.write(line)
  2135. with open(main_act_ios, "r") as f:
  2136. lines = f.readlines()
  2137. with open(main_act_ios, "w") as f:
  2138. for line in lines:
  2139. if "//FLOATING" in line:
  2140. if mode == "floating":
  2141. if features["cc"]["status"]:
  2142. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  2143. else:
  2144. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CC)'))
  2145. if features["nc"]["status"]:
  2146. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  2147. else:
  2148. f.write(
  2149. indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_NOTIF_CENTER)'))
  2150. if features["im"]["status"]:
  2151. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  2152. else:
  2153. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CHAT)'))
  2154. if features["call"]["status"]:
  2155. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  2156. else:
  2157. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_CALL)'))
  2158. if features["ls"]["status"]:
  2159. f.write(indented_str(2, 'Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  2160. else:
  2161. f.write(indented_str(2, '// Nexilis.defaultFloatingButton.append(Nexilis.IDX_STREAM)'))
  2162. else:
  2163. f.write(indented_str(0, ""))
  2164. elif "APIS.connect" in line:
  2165. if mode == "floating":
  2166. replaced = line.replace("false", "true")
  2167. f.write(replaced)
  2168. else:
  2169. f.write(line)
  2170. else:
  2171. f.write(line)
  2172. def deliver_zip(path_dest, uid):
  2173. rand_name = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(32))
  2174. zip_name = f"{rand_name}"
  2175. new_dir = os.path.join(app.zip_folder, zip_name)
  2176. try:
  2177. shutil.make_archive(new_dir, 'zip', path_dest)
  2178. project_path = os.path.join(app.temp_folder, uid)
  2179. shutil.rmtree(project_path)
  2180. return {"status": "0", "name": zip_name + ".zip"}
  2181. except Exception as e:
  2182. return {"status": "4", "message": "Deliver ZIP failed"}
  2183. @app.route('/', methods=["GET", "POST"])
  2184. def build_project():
  2185. vprint('==============================================================')
  2186. if request.method == 'POST':
  2187. platform = "android"
  2188. mode = "burger"
  2189. app_id = ""
  2190. feature_dict = {
  2191. "im": {
  2192. "status": False
  2193. },
  2194. "cc": {
  2195. "status": False
  2196. },
  2197. "call": {
  2198. "status": False
  2199. },
  2200. "ls": {
  2201. "status": False
  2202. },
  2203. "nc": {
  2204. "status": False
  2205. },
  2206. "sms": {
  2207. "status": False
  2208. },
  2209. "email": {
  2210. "status": False
  2211. },
  2212. "smartbot": {
  2213. "status": False
  2214. }
  2215. }
  2216. security_dict = {
  2217. "root_device": False,
  2218. "malware": False,
  2219. "clone": False,
  2220. "emulator": False,
  2221. "debug": False,
  2222. "sim_swap": False,
  2223. "capture": False,
  2224. "call_forwarding": False,
  2225. "secure_folder": False,
  2226. "show_security": False,
  2227. "screen_share": False,
  2228. "side_load": False,
  2229. "key_logger": False,
  2230. }
  2231. try:
  2232. if "feature_im" in request.form:
  2233. feature_dict["im"]["status"] = request.form["feature_im"] == "1"
  2234. if "feature_cc" in request.form:
  2235. feature_dict["cc"]["status"] = request.form["feature_cc"] == "1"
  2236. if "feature_vc" in request.form:
  2237. feature_dict["call"]["status"] = request.form["feature_vc"] == "1"
  2238. if "feature_ac" in request.form and not feature_dict["call"]["status"]:
  2239. feature_dict["call"]["status"] = request.form["feature_ac"] == "1"
  2240. if "feature_ls" in request.form:
  2241. feature_dict["ls"]["status"] = request.form["feature_ls"] == "1"
  2242. if "feature_nc" in request.form:
  2243. feature_dict["nc"]["status"] = request.form["feature_nc"] == "1"
  2244. if "feature_sms" in request.form:
  2245. feature_dict["sms"]["status"] = request.form["feature_sms"] == "1"
  2246. if "feature_email" in request.form:
  2247. feature_dict["email"]["status"] = request.form["feature_email"] == "1"
  2248. if "feature_smartbot" in request.form:
  2249. feature_dict["smartbot"]["status"] = request.form["feature_smartbot"] == "1"
  2250. if "feature_settings" in request.form:
  2251. feature_dict["settings"]["status"] = request.form["feature_settings"] == "1"
  2252. if "security_malware" in request.form:
  2253. security_dict["malware"] = request.form["security_malware"] == "1"
  2254. if "security_clone" in request.form:
  2255. security_dict["clone"] = request.form["security_clone"] == "1"
  2256. if "security_emulator" in request.form:
  2257. security_dict["emulator"] = request.form["security_emulator"] == "1"
  2258. if "security_debug" in request.form:
  2259. security_dict["debug"] = request.form["security_debug"] == "1"
  2260. if "security_sim_swap" in request.form:
  2261. security_dict["sim_swap"] = request.form["security_sim_swap"] == "1"
  2262. if "security_capture" in request.form:
  2263. security_dict["capture"] = request.form["security_capture"] == "1"
  2264. if "security_call_forwarding" in request.form:
  2265. security_dict["call_forwarding"] = request.form["security_call_forwarding"] == "1"
  2266. if "security_secure_folder" in request.form:
  2267. security_dict["secure_folder"] = request.form["security_secure_folder"] == "1"
  2268. if "show_security" in request.form:
  2269. security_dict["show_security"] = request.form["show_security"] == "1"
  2270. if "security_rootdevice" in request.form:
  2271. security_dict["root_device"] = request.form["security_rootdevice"] == "1"
  2272. if "security_screenshare" in request.form:
  2273. security_dict["screen_share"] = request.form["security_screenshare"] == "1"
  2274. if "security_sideloaded" in request.form:
  2275. security_dict["side_load"] = request.form["security_sideloaded"] == "1"
  2276. if "security_keylogger" in request.form:
  2277. security_dict["key_logger"] = request.form["security_keylogger"] == "1"
  2278. security_dict["show_security"] = (security_dict["malware"] or security_dict["clone"]
  2279. or security_dict["emulator"] or security_dict["debug"]
  2280. or security_dict["sim_swap"] or security_dict["capture"]
  2281. or security_dict["call_forwarding"]
  2282. or security_dict["secure_folder"])
  2283. if "platform" in request.form:
  2284. platform = request.form["platform"]
  2285. if "mode" in request.form:
  2286. mode = request.form["mode"]
  2287. if "app_id" in request.form:
  2288. app_id = request.form["app_id"]
  2289. except BaseException as e:
  2290. vprint(traceback.format_exc())
  2291. return {"status": "1", "message": "Parameter mismatch\n{}\n".format(str(e))}, 400
  2292. try:
  2293. uu_id = str(uuid.uuid4())
  2294. path_dest = create_folder(platform, uu_id)
  2295. change(app_id, platform, mode, path_dest, feature_dict, security_dict)
  2296. return deliver_zip(path_dest, uu_id)
  2297. except BaseException as e:
  2298. vprint(traceback.format_exc())
  2299. return {"status": "2", "message": "Process failure\n{}\n".format(str(e))}, 200
  2300. else:
  2301. if 'e' in request.args:
  2302. return request.args['e']
  2303. return "Hello World!"
  2304. if __name__ == '__main__':
  2305. app.run(host='0.0.0.0', port=8056, debug=app.verbose, ssl_context=app.ssl)