main.py 159 KB

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