tama 9 ヶ月 前
コミット
6e4d24144c
1 ファイル変更151 行追加17 行削除
  1. 151 17
      main-embed.py

+ 151 - 17
main-embed.py

@@ -317,6 +317,20 @@ def write_android_menu(xml_menu_path: str, features: dict, security: dict):
                     f.write(indented_str(2, 'android:title="Contact List"'))
                     f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
                     n = n + 1
+                if features["community"]["status"]:
+                    f.write(indented_str(1, "<item"))
+                    f.write(indented_str(2, 'android:id="@+id/action_community"'))
+                    f.write(indented_str(2, f'android:orderInCategory="{n}"'))
+                    f.write(indented_str(2, 'android:title="Community"'))
+                    f.write(indented_str(2, 'app:showAsAction="never" />'))
+                    n = n + 1
+                else:
+                    f.write(indented_str(1, "<!-- <item"))
+                    f.write(indented_str(2, 'android:id="@+id/action_community"'))
+                    f.write(indented_str(2, f'android:orderInCategory="{n}"'))
+                    f.write(indented_str(2, 'android:title="Community"'))
+                    f.write(indented_str(2, 'app:showAsAction="never" /> -->'))
+                    n = n + 1
                 if security["secure_folder"]:
                     f.write(indented_str(1, "<item"))
                     f.write(indented_str(2, 'android:id="@+id/action_sf"'))
@@ -507,6 +521,16 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(3, "// API.openConversation();"))
                         f.write(indented_str(3, "// return true;"))
                         f.write(indented_str(2, "// }"))
+                    if features["community"]["status"]:
+                        f.write(indented_str(2, "if (id == R.id.action_community) {"))
+                        f.write(indented_str(3, "API.openCommunity();"))
+                        f.write(indented_str(3, "return true;"))
+                        f.write(indented_str(2, "}"))
+                    else:
+                        f.write(indented_str(2, "// if (id == R.id.action_community) {"))
+                        f.write(indented_str(3, "// API.openCommunity();"))
+                        f.write(indented_str(3, "// return true;"))
+                        f.write(indented_str(2, "// }"))
                     if security["secure_folder"]:
                         f.write(indented_str(2, "if (id == R.id.action_sf) {"))
                         f.write(indented_str(3, "API.openSecureFolder();"))
@@ -689,6 +713,10 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(2, "ImageView imageViewContactList = findViewById(R.id.btn_contact_list);"))
                     else:
                         f.write(indented_str(2, "// ImageView imageViewContactList = findViewById(R.id.btn_contact_list);"))
+                    if features["community"]["status"]:
+                        f.write(indented_str(2, "ImageView imageViewContactList = findViewById(R.id.btn_community);"))
+                    else:
+                        f.write(indented_str(2, "// ImageView imageViewContactList = findViewById(R.id.btn_community);"))
                     f.write(indented_str(0, ""))
                     f.write(indented_str(2, "imageViewSetting.setOnClickListener(v -> {"))
                     f.write(indented_str(3, "API.openSettings();"))
@@ -824,6 +852,14 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(2, "// imageViewContactList.setOnClickListener(v -> {"))
                         f.write(indented_str(3, "// API.openConversation();"))
                         f.write(indented_str(2, "// });"))
+                    if features["community"]["status"]:
+                        f.write(indented_str(2, "imageViewCommunity.setOnClickListener(v -> {"))
+                        f.write(indented_str(3, "API.openCommunity();"))
+                        f.write(indented_str(2, "});"))
+                    else:
+                        f.write(indented_str(2, "// imageViewCommunity.setOnClickListener(v -> {"))
+                        f.write(indented_str(3, "// API.opencommunity();"))
+                        f.write(indented_str(2, "// });"))
                 elif "//BREAK" in line:
                     if mode == "floating" or mode == "grid":
                         f.write("}")
@@ -1108,6 +1144,20 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
                         f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
                         f.write(indented_str(2, '<!--android:src="@drawable/pb_button_contact_list"/>-->'))
+                    if mode == "grid" and "community" in l_features:
+                        f.write(indented_str(1, "<ImageView"))
+                        f.write(indented_str(2, 'android:id="@+id/btn_community"'))
+                        f.write(indented_str(2, 'android:layout_height="100dp"'))
+                        f.write(indented_str(2, 'android:layout_width="100dp"'))
+                        f.write(indented_str(2, 'android:layout_margin="10dp"'))
+                        f.write(indented_str(2, 'android:src="@drawable/pb_button_community"/>'))
+                    else:
+                        f.write(indented_str(1, "<!--<ImageView-->"))
+                        f.write(indented_str(2, '<!--android:id="@+id/btn_community"-->'))
+                        f.write(indented_str(2, '<!--android:layout_height="100dp"-->'))
+                        f.write(indented_str(2, '<!--android:layout_width="100dp"-->'))
+                        f.write(indented_str(2, '<!--android:layout_margin="10dp"-->'))
+                        f.write(indented_str(2, '<!--android:src="@drawable/pb_button_community"/>-->'))
                 else:
                     f.write(line)
         write_android_manifest(manifest_path, features, security)
@@ -1152,6 +1202,10 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         features_str.append("'Streaming'")
                     else:
                         features_str.append("// 'Streaming'")
+                    if security["secure_folder"]:
+                        features_str.append("'Secure Folder'")
+                    else:
+                        features_str.append("// 'Secure Folder'")
                     if features["custom_url"]["status"]:
                         features_str.append("'Custom URL'")
                     else:
@@ -1179,15 +1233,15 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                     if features["news_update"]["status"]:
                         features_str.append("'News and Update'")
                     else:
-                        features_str.append("// 'ews and Update'")
+                        features_str.append("// 'News and Update'")
                     if features["contact_list"]["status"]:
                         features_str.append("'Contact List'")
                     else:
                         features_str.append("// 'Contact List'")
-                    if security["secure_folder"]:
-                        features_str.append("'Secure Folder'")
+                    if features["community"]["status"]:
+                        features_str.append("'Community'")
                     else:
-                        features_str.append("// 'Secure Folder'")
+                        features_str.append("// 'Community'")
                     for feature_str in features_str:
                         f.write(indented_str(8, f"{feature_str},", spaces=2))
                 elif "//FEATURES" in line:
@@ -1317,6 +1371,14 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(3, '// case "Contact List":', spaces=2))
                         f.write(indented_str(4, '// nativeChannel.invokeMethod("openConversation");', spaces=2))
                         f.write(indented_str(4, "// break;", spaces=2))
+                    if features["community"]["status"]:
+                        f.write(indented_str(3, 'case "Community":', spaces=2))
+                        f.write(indented_str(4, 'nativeChannel.invokeMethod("openCommunity");', spaces=2))
+                        f.write(indented_str(4, "break;", spaces=2))
+                    else:
+                        f.write(indented_str(3, '// case "Community":', spaces=2))
+                        f.write(indented_str(4, '// nativeChannel.invokeMethod("openCommunity");', spaces=2))
+                        f.write(indented_str(4, "// break;", spaces=2))
                     if security["secure_folder"]:
                         f.write(indented_str(3, 'case "Secure Folder":', spaces=2))
                         f.write(indented_str(4, 'nativeChannel.invokeMethod("openSecureFolder");', spaces=2))
@@ -1671,6 +1733,20 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(6, "// this.openConversation();", spaces=2))
                         f.write(indented_str(5, "// },", spaces=2))
                         f.write(indented_str(4, "// },", spaces=2))
+                    if features["community"]["status"]:
+                        f.write(indented_str(4, '{', spaces=2))
+                        f.write(indented_str(5, "text: 'Community',", spaces=2))
+                        f.write(indented_str(5, "handler: () => {", spaces=2))
+                        f.write(indented_str(6, "this.openCommunity();", spaces=2))
+                        f.write(indented_str(5, "},", spaces=2))
+                        f.write(indented_str(4, "},", spaces=2))
+                    else:
+                        f.write(indented_str(4, '// {', spaces=2))
+                        f.write(indented_str(5, "// text: 'Community',", spaces=2))
+                        f.write(indented_str(5, "// handler: () => {", spaces=2))
+                        f.write(indented_str(6, "// this.openCommunity();", spaces=2))
+                        f.write(indented_str(5, "// },", spaces=2))
+                        f.write(indented_str(4, "// },", spaces=2))
 
                 else:
                     f.write(line)
@@ -1848,6 +1924,10 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(4, "'Contact List',", spaces=2))
                     else:
                         f.write(indented_str(4, "// 'Contact List',", spaces=2))
+                    if features["community"]["status"]:
+                        f.write(indented_str(4, "'Community',", spaces=2))
+                    else:
+                        f.write(indented_str(4, "// 'Community',", spaces=2))
 
                 elif "//FEATURES1" in line:
                     n = 0
@@ -2003,6 +2083,15 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(5, "// if (buttonIndex === 17) {", spaces=2))
                         f.write(indented_str(6, "// CallNative.openConversation();", spaces=2))
                         f.write(indented_str(5, "// }", spaces=2))
+                    if features["community"]["status"]:
+                        f.write(indented_str(5, f"if (buttonIndex === {n}) {{", spaces=2))
+                        f.write(indented_str(6, "CallNative.openCommunity();", spaces=2))
+                        f.write(indented_str(5, "}", spaces=2))
+                        n = n + 1
+                    else:
+                        f.write(indented_str(5, "// if (buttonIndex === 18) {", spaces=2))
+                        f.write(indented_str(6, "// CallNative.openCommunity();", spaces=2))
+                        f.write(indented_str(5, "// }", spaces=2))
 
                 elif "//FEATURES2" in line:
                     n = 0
@@ -2294,6 +2383,23 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(4, "// console.log(e);", spaces=2))
                         f.write(indented_str(3, "// }", spaces=2))
                         f.write(indented_str(2, "// }", spaces=2))
+                    if features["community"]["status"]:
+                        f.write(indented_str(2, f"if (buttonIndex === {n}) {{", spaces=2))
+                        f.write(indented_str(3, "try {", spaces=2))
+                        f.write(indented_str(4, "CallNative.openCommunity();", spaces=2))
+                        f.write(indented_str(3, "} catch (e) {", spaces=2))
+                        f.write(indented_str(4, "console.log(e);", spaces=2))
+                        f.write(indented_str(3, "}", spaces=2))
+                        f.write(indented_str(2, "}", spaces=2))
+                        n = n + 1
+                    else:
+                        f.write(indented_str(2, "// if (buttonIndex === 18) {", spaces=2))
+                        f.write(indented_str(3, "// try {", spaces=2))
+                        f.write(indented_str(4, "// CallNative.openCommunity();", spaces=2))
+                        f.write(indented_str(3, "// } catch (e) {", spaces=2))
+                        f.write(indented_str(4, "// console.log(e);", spaces=2))
+                        f.write(indented_str(3, "// }", spaces=2))
+                        f.write(indented_str(2, "// }", spaces=2))
                 elif "//FEATURES3" in line:
                     n = 0
                     f.write(indented_str(5, "<Button", spaces=2))
@@ -2482,6 +2588,17 @@ def change(app_id: str, platform: str, mode: str, path_dest: str, features: dict
                         f.write(indented_str(6, 'title="Contact List"', spaces=2))
                         f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(17)}}', spaces=2))
                         f.write(indented_str(5, "/> */}", spaces=2))
+                    if features["community"]["status"]:
+                        f.write(indented_str(5, "<Button", spaces=2))
+                        f.write(indented_str(6, 'title="Community"', spaces=2))
+                        f.write(indented_str(6, f'onPress={{() => handleActionSheetPress({n})}}', spaces=2))
+                        f.write(indented_str(5, "/>", spaces=2))
+                        n = n + 1
+                    else:
+                        f.write(indented_str(5, "{/* <Button", spaces=2))
+                        f.write(indented_str(6, 'title="Community"', spaces=2))
+                        f.write(indented_str(6, f'onPress={{() => handleActionSheetPress(18)}}', spaces=2))
+                        f.write(indented_str(5, "/> */}", spaces=2))
                 else:
                     f.write(line)
         with open(main_act_android, "r") as f:
@@ -3240,26 +3357,29 @@ def save_icons(app_id: str, platform: str, mode: str, path_dest: str, features:
             file = features["custom_url"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_custom_url.png"))
         if features["xapps"]["icon"]:
-            file = features["im"]["icon"]
+            file = features["xapps"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_external_apps.png"))
         if features["conpost"]["icon"]:
-            file = features["im"]["icon"]
+            file = features["conpost"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_user_content.png"))
         if features["ppob"]["icon"]:
-            file = features["im"]["icon"]
+            file = features["ppob"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_ppob.png"))
         if features["wallet"]["icon"]:
-            file = features["im"]["icon"]
+            file = features["wallet"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_wallet.png"))
         if features["social_commerce"]["icon"]:
-            file = features["im"]["icon"]
+            file = features["social_commerce"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_social_commerce.png"))
         if features["news_update"]["icon"]:
-            file = features["im"]["icon"]
+            file = features["news_update"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_news.png"))
         if features["contact_list"]["icon"]:
-            file = features["im"]["icon"]
+            file = features["contact_list"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_contact_list.png"))
+        if features["community"]["icon"]:
+            file = features["community"]["icon"]
+            file.save(os.path.join(drawable_path, "pb_button_community.png"))
         if features["secure_folder"]["icon"]:
             file = features["im"]["icon"]
             file.save(os.path.join(drawable_path, "pb_button_secure_folder.png"))
@@ -3383,6 +3503,11 @@ def build_project():
                 "status": False,
                 "icon": None
             },
+            "community": {
+                "status": False,
+                "icon": None
+            },
+
             "cc_chat": {
                 "status": False,
                 "icon": None
@@ -3461,15 +3586,20 @@ def build_project():
             if "feature_conpost" in request.form:
                 feature_dict["conpost"]["status"] = request.form["feature_conpost"] == "1"
             if "feature_ppob" in request.form:
-                feature_dict["ppob"]["status"] = request.form["check_ppob"] == "1"
+                feature_dict["ppob"]["status"] = request.form["feature_ppob"] == "1"
             if "feature_wallet" in request.form:
-                feature_dict["wallet"]["status"] = request.form["check_wallet"] == "1"
+                feature_dict["wallet"]["status"] = request.form["feature_wallet"] == "1"
             if "feature_social_commerce" in request.form:
-                feature_dict["social_commerce"]["status"] = request.form["social_commerce"] == "1"
+                feature_dict["social_commerce"]["status"] = request.form["feature_social_commerce"] == "1"
             if "feature_news_update" in request.form:
-                feature_dict["news_update"]["status"] = request.form["news_update"] == "1"
+                feature_dict["news_update"]["status"] = request.form["feature_news_update"] == "1"
             if "feature_contact_list" in request.form:
-                feature_dict["contact_list"]["status"] = request.form["contact_list"] == "1"
+                feature_dict["contact_list"]["status"] = request.form["feature_contact_list"] == "1"
+            if "feature_community" in request.form:
+                feature_dict["community"]["status"] = request.form["feature_community"] == "1"
+            if "feature_secure_folder" in request.form and not security_dict["secure_folder"]:
+                security_dict["secure_folder"] = request.form["feature_secure_folder"] == "1"
+
             if "feature_cc_chat" in request.form:
                 feature_dict["cc_chat"]["status"] = request.form["feature_cc_chat"] == "1"
             if "feature_cc_voip" in request.form:
@@ -3501,7 +3631,7 @@ def build_project():
                 security_dict["capture"] = request.form["security_capture"] == "1"
             if "security_call_forwarding" in request.form:
                 security_dict["call_forwarding"] = request.form["security_call_forwarding"] == "1"
-            if "security_secure_folder" in request.form:
+            if "security_secure_folder" in request.form and not security_dict["secure_folder"]::
                 security_dict["secure_folder"] = request.form["security_secure_folder"] == "1"
             if "secure_folder" in request.form and not security_dict["secure_folder"]:
                 security_dict["secure_folder"] = request.form["secure_folder"] == "1"
@@ -3581,6 +3711,10 @@ def build_project():
                 file = request.files['gridicon_contact_list']
                 if file and file.filename and allowed_file(file.filename):
                     feature_dict["contact_list"]["icon"] = file
+            if "gridicon_community" in request.files:
+                file = request.files['gridicon_community']
+                if file and file.filename and allowed_file(file.filename):
+                    feature_dict["community"]["icon"] = file
             if "gridicon_secure_folder" in request.files:
                 file = request.files['gridicon_secure_folder']
                 if file and file.filename and allowed_file(file.filename):