main.py 111 KB

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