main.py 124 KB

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