Browse Source

add floating android flutter

kevin 1 year ago
parent
commit
f3ae4248d8

+ 14 - 0
NexilisSampleCodeFlutter-Android/android/app/src/main/java/com/example/paliolitesamplecodeflutter/MainActivity.java

@@ -13,6 +13,8 @@ import io.flutter.embedding.engine.FlutterEngine;
 import io.flutter.plugin.common.MethodChannel;
 import io.flutter.plugin.common.MethodChannel;
 import io.nexilis.service.API;
 import io.nexilis.service.API;
 import io.nexilis.service.Callback;
 import io.nexilis.service.Callback;
+import io.nexilis.service.utils.callback.SimCardDetectionCallback;
+import io.nexilis.service.utils.xthunder.FloatingButton;
 
 
 public class MainActivity extends FlutterActivity {
 public class MainActivity extends FlutterActivity {
     private static final String CHANNEL = "nativeChannel";
     private static final String CHANNEL = "nativeChannel";
@@ -20,6 +22,17 @@ public class MainActivity extends FlutterActivity {
     @Override
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);
+
+        /**
+         *
+         * Nexilis provides an API security shield service, which functions to detect threats such as malware, ADB, screencapture, and Sim Swapping.
+         */
+
+        //SECURITY
+
+        //SMS
+        //EMAIL
+
         /*************************************
         /*************************************
          Connect to our server with your newuniverse.io Account, and implement the required Callback.
          Connect to our server with your newuniverse.io Account, and implement the required Callback.
          Please Subscribe or contact us to get your newuniverse.io Account.
          Please Subscribe or contact us to get your newuniverse.io Account.
@@ -53,6 +66,7 @@ public class MainActivity extends FlutterActivity {
                 runOnUiThread(new Runnable() {
                 runOnUiThread(new Runnable() {
                     @Override
                     @Override
                     public void run() {
                     public void run() {
+                        //FLOATING
                         Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID + " : " + getString(io.nexilis.service.R.string.pb_loading), Toast.LENGTH_LONG).show();
                         Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID + " : " + getString(io.nexilis.service.R.string.pb_loading), Toast.LENGTH_LONG).show();
                     }
                     }
                 });
                 });

+ 132 - 1
main.py

@@ -339,6 +339,7 @@ def change(platform: str, mode: str, path_dest: str, features: dict, security: d
                     f.write(line)
                     f.write(line)
     elif platform == "android_flutter":
     elif platform == "android_flutter":
         main_act_path = os.path.join(path_dest, "lib/main.dart")
         main_act_path = os.path.join(path_dest, "lib/main.dart")
+        main_act_android = os.path.join(path_dest, "android/app/src/main/java/com/example/paliolitesamplecodeflutter/MainActivity.java")
         with open(main_act_path, "r") as f:
         with open(main_act_path, "r") as f:
             lines = f.readlines()
             lines = f.readlines()
         with open(main_act_path, "w") as f:
         with open(main_act_path, "w") as f:
@@ -418,6 +419,136 @@ def change(platform: str, mode: str, path_dest: str, features: dict, security: d
                         f.write(indented_str(4, "// break;", spaces=2))
                         f.write(indented_str(4, "// break;", spaces=2))
                 else:
                 else:
                     f.write(line)
                     f.write(line)
+        with open(main_act_android, "r") as f:
+            lines = f.readlines()
+        with open(main_act_android, "w") as f:
+            for line in lines:
+                if "//SECURITY" in line:
+                    if security["show_security"]:
+                        f.write(indented_str(2, "API.setShowSecurityShieldDialog(true);"))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setShowSecurityShieldDialog(true);"))
+                        f.write(os.linesep)
+                    if security["emulator"]:
+                        f.write(indented_str(2, "API.setCheckEmulator(true);"))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setCheckEmulator(true);"))
+                        f.write(os.linesep)
+                    if security["debug"]:
+                        f.write(indented_str(2, "API.setCheckAdb(true);"))
+                        f.write(os.linesep)
+                    if security["sim_swap"]:
+                        f.write(indented_str(2,
+                                             "API.setCheckSimCardSwapListener(MainActivity.this, new SimCardDetectionCallback() {"))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override"))
+                        f.write(indented_str(3, "public boolean onSimCardChange() {"))
+                        f.write(indented_str(4, "return false;"))
+                        f.write(indented_str(3, "}"))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override"))
+                        f.write(indented_str(3, "public void onError(String s) {"))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "}"))
+                        f.write(indented_str(2, "});"))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2,
+                                             "/* API.setCheckSimCardSwapListener(MainActivity.this, new SimCardDetectionCallback() {"))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override"))
+                        f.write(indented_str(3, "public boolean onSimCardChange() {"))
+                        f.write(indented_str(4, "return false;"))
+                        f.write(indented_str(3, "}"))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "@Override"))
+                        f.write(indented_str(3, "public void onError(String s) {"))
+                        f.write(os.linesep)
+                        f.write(indented_str(3, "}"))
+                        f.write(indented_str(2, "}); */"))
+                        f.write(os.linesep)
+                    if security["malware"]:
+                        f.write(indented_str(2, "API.setCheckMalware(true);"))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setCheckMalware(true);"))
+                        f.write(os.linesep)
+                    if security["capture"]:
+                        f.write(indented_str(2, "API.setPreventScreenCapture(true);"))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setPreventScreenCapture(true);"))
+                        f.write(os.linesep)
+                    if security["call_forwarding"]:
+                        f.write(indented_str(2, "API.setCheckCallForwarding(true);"))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.setCheckCallForwarding(true);"))
+                        f.write(os.linesep)
+                    if security["secure_folder"]:
+                        f.write(indented_str(2, "API.openSecureFolder();"))
+                        f.write(os.linesep)
+                    else:
+                        f.write(indented_str(2, "// API.openSecureFolder();"))
+                        f.write(os.linesep)
+                elif "//SMS" in line:
+                    if features["sms"]["status"]:
+                        f.write(indented_str(2, "API.setEnabledSMS(true);"))
+                    else:
+                        f.write(indented_str(2, "// API.setEnabledSMS(true);"))
+                elif "//EMAIL" in line:
+                    if features["email"]["status"]:
+                        f.write(indented_str(2, "API.setEnabledEmail(true);"))
+                    else:
+                        f.write(indented_str(2, "// API.setEnabledEmail(true);"))
+                elif "//FLOATING" in line:
+                    if mode == "floating":
+                        f.write(indented_str(6, "ArrayList<FloatingButton> fb = new ArrayList<>();"))
+                        if features["cc"]["status"]:
+                            f.write(indented_str(6,
+                                                 'fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.CONTACT_CENTER, ""));'))
+                        if features["nc"]["status"]:
+                            f.write(
+                                indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.NOTIF_CENTER, ""));'))
+                        if features["im"]["status"]:
+                            f.write(
+                                indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.MESSAGING, ""));'))
+                        if features["call"]["status"]:
+                            f.write(
+                                indented_str(6,
+                                             'fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.AUDIO_VIDEO_CALL, ""));'))
+                        if features["ls"]["status"]:
+                            f.write(
+                                indented_str(6, 'fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
+                        else:
+                            f.write(indented_str(6,
+                                                 '// fb.add(new FloatingButton(FloatingButton.FEATURE.STREAMING, ""));'))
+                        f.write(indented_str(6,
+                                             'API.configureFloating(fb);'))
+                    else:
+                        f.write(indented_str(0, ""))
+                elif "API.connect" in line:
+                    if mode == "floating":
+                        replaced = line.replace("0", "1")
+                        f.write(replaced)
+                    else:
+                        f.write(line)
+                else:
+                    f.write(line)
     elif platform == "android_ionic":
     elif platform == "android_ionic":
         main_act_path = os.path.join(path_dest,"src/app/app.component.ts")
         main_act_path = os.path.join(path_dest,"src/app/app.component.ts")
         with open(main_act_path, "r") as f:
         with open(main_act_path, "r") as f:
@@ -1013,7 +1144,7 @@ def deliver_zip(path_dest, uid):
 def build_project():
 def build_project():
     vprint('==============================================================')
     vprint('==============================================================')
     if request.method == 'POST':
     if request.method == 'POST':
-        platform = "android"
+        platform = "android_flutter"
         mode = "burger"
         mode = "burger"
         feature_dict = {
         feature_dict = {
             "im": {
             "im": {