main.py 150 KB

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