main-embed.py 179 KB

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