main.py 121 KB

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