Explorar o código

add floating native

kevin hai 1 ano
pai
achega
d73807cca7

+ 3 - 1
NexilisSampleCode/app/src/main/java/com/example/nexilissamplecodeburger/MainActivity.java

@@ -9,6 +9,7 @@ import android.widget.Toast;
 import io.nexilis.service.Callback;
 import io.nexilis.service.API;
 import io.nexilis.service.utils.callback.SimCardDetectionCallback;
+import io.nexilis.service.utils.xthunder.FloatingButton;
 
 public class MainActivity extends AppCompatActivity {
 
@@ -61,6 +62,7 @@ public class MainActivity extends AppCompatActivity {
                 runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
+                        //FLOATING
                         Toast.makeText(getBaseContext(), "Your User ID: " + NexilisUserID, Toast.LENGTH_LONG).show();
                     }
                 });
@@ -112,7 +114,7 @@ public class MainActivity extends AppCompatActivity {
          * NewUserID	: Desired User ID
          */
     }
-
+    //BREAK
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         // Inflate the menu; this adds items to the action bar if it is present.

+ 52 - 2
main.py

@@ -50,7 +50,7 @@ def create_folder(platform, uid):
     return path_dest
 
 
-def change(platform: str, path_dest: str, features: dict, security: dict):
+def change(platform: str, mode: str, path_dest: str, features: dict, security: dict):
     if platform == "android":
         main_act_path = os.path.join(path_dest,
                                      "app/src/main/java/com/example/nexilissamplecodeburger/MainActivity.java")
@@ -198,6 +198,53 @@ def change(platform: str, path_dest: str, features: dict, security: dict):
                         f.write(indented_str(2, "API.setEnabledEmail(true);"))
                     else:
                         f.write(indented_str(2, "// API.setEnabledEmail(true);"))
+                elif "//BREAK" in line:
+                    if mode == "floating":
+                        f.write("}")
+                        break
+                    else:
+                        f.write(indented_str(0,""))
+                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)
         with open(xml_menu_path, "r") as f:
@@ -967,6 +1014,7 @@ def build_project():
     vprint('==============================================================')
     if request.method == 'POST':
         platform = "android"
+        mode = "burger"
         feature_dict = {
             "im": {
                 "android_name": "action_chats",
@@ -1055,13 +1103,15 @@ def build_project():
                                                   or security_dict["secure_folder"])
             if "platform" in request.form:
                 platform = request.form["platform"]
+            if "mode" in request.form:
+                mode = request.form["mode"]
         except BaseException as e:
             vprint(traceback.format_exc())
             return {"status": "1", "message": "Parameter mismatch\n{}\n".format(str(e))}, 400
         try:
             uu_id = str(uuid.uuid4())
             path_dest = create_folder(platform, uu_id)
-            change(platform, path_dest, feature_dict, security_dict)
+            change(platform, mode, path_dest, feature_dict, security_dict)
             return deliver_zip(path_dest, uu_id)
         except BaseException as e:
             vprint(traceback.format_exc())