main.py 122 KB

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