def updateNameWin(isHd, isAuto): strOld = "_APP_NAME_" rootConfig = common.GetProjectConfigApp() project = rootConfig + "/win/project" if isHd: project = rootConfig + "/win/project_hd" file_name_cn = project + "/strings/zh-cn/resources.resw" file_name_en = project + "/strings/en-us/resources.resw" data = loadJson(isHd) isOld = IsOldVersion(data) if not isOld: appname = data["appname"] if isOld: APP_NAME_CN = data["APP_NAME_CN_ANDROID"] APP_NAME_EN = data["APP_NAME_EN_ANDROID"] PACKAGE = data["PACKAGE_ANDROID"] else: APP_NAME_CN = appname["android"]["cn"] APP_NAME_EN = appname["android"]["en"] PACKAGE = data["apppackage"]["android"]["default"] # cn replaceFile(file_name_cn, strOld, APP_NAME_CN) # en replaceFile(file_name_en, strOld, APP_NAME_EN) filepath = project + "/strings/common.resw" replaceFile(filepath, "_APP_PACKAGE_", PACKAGE)
def GetAppDetail(isHd, lan): src = common.GetProjectConfigApp() + "/appinfo/app_description.xml" if isHd: src = common.GetProjectConfigApp() + "/appinfo/app_description_hd.xml" domTree = parse(src) # 文档根元素root = domTree.documentElement root = domTree.documentElement print(root.nodeName) strret = " " key = lan # if lan==source.LANGUAGE_CN: # key = "cn" list = root.getElementsByTagName(key) for item in list: strret = item.childNodes[0].data print(strret) return strret
def copyResFiles(str): dir_default = common.GetProjectConfigDefault() # "../../../default" dir_to = common.GetProjectConfigApp() dir1 = dir_default + "/" + str dir2 = dir_to + "/" + str print(dir2) flag = os.path.exists(dir2) if flag: shutil.rmtree(dir2) shutil.copytree(dir1, dir2)
def CopyAndroidJavaFile_Weixin(rootStudio, isHD): dirroot = common.GetProjectConfigApp() strFileFrom = dirroot + "/android/src/wxapi/WXEntryActivity.java" strFileTo = rootStudio + "/src/main/java/com/moonma/common/share/wxapi/WXEntryActivity.java" # loadJson package = AppInfo.GetPackage(source.ANDROID, isHD) # 替换包名 f = open(strFileFrom, 'r') strFile = f.read() f.close() strOut = strFile.replace("_PACKAGE_", package) common.saveString2File(strOut, strFileTo)
def updateName(isHd, isAuto): appinfoOld = AppInfoOld(isHd) if appinfoOld.IsOldVersion(): # 转换 ConvertOld2New(isHd, appinfoOld) rootConfig = common.GetProjectConfigApp() strHD = "HD" project_ios = rootConfig + "/ios/project" project_android = rootConfig + "/android/project" if isHd: project_ios = rootConfig + "/ios/project_hd" project_android = rootConfig + "/android/project_hd" # android file_name_cn_android = project_android + "/res/values/strings.xml" file_name_en_android = project_android + "/res/values-en/strings.xml" file_AndroidManifest = project_android + "/xml/AndroidManifest.xml" file_AndroidManifest_GP = project_android + "/xml_gp/AndroidManifest.xml" file_google_service_android = project_android + "/config/google-services.json" # ios file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings" file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings" file_info_plist_ios = project_ios + "/Info.plist" # loadJson data = loadJson(isHd) isOld = IsOldVersion(data) global versionCode if not isOld: appname = data["appname"] if isOld: APP_NAME_CN_ANDROID = data["APP_NAME_CN_ANDROID"] APP_NAME_EN_ANDROID = data["APP_NAME_EN_ANDROID"] APP_NAME_CN_IOS = data["APP_NAME_CN_IOS"] APP_NAME_EN_IOS = data["APP_NAME_EN_IOS"] PACKAGE_ANDROID = data["PACKAGE_ANDROID"] PACKAGE_IOS = data["PACKAGE_IOS"] versionCode = data["APPVERSION_CODE_ANDROID"] APPVERSION_IOS = data["APPVERSION_IOS"] appid_huawei = GetConfigDataAppId(source.ANDROID, source.HUAWEI, isHd) else: APP_NAME_CN_ANDROID = appname[source.ANDROID]["cn"] APP_NAME_EN_ANDROID = appname[source.ANDROID]["en"] APP_NAME_CN_IOS = appname[source.IOS]["cn"] APP_NAME_EN_IOS = appname[source.IOS]["en"] PACKAGE_ANDROID = data["apppackage"][source.ANDROID]["default"] PACKAGE_IOS = data["apppackage"][source.IOS]["default"] versionCode = data["appversion"][source.ANDROID]["code"] APPVERSION_IOS = data["appversion"][source.IOS]["value"] #appid appid_ios = GetJsonAppId(data, source.APPSTORE) appid_taptap = GetJsonAppId(data, source.TAPTAP) appid_huawei = GetJsonAppId(data, source.HUAWEI) SetConfigDataAppId(source.IOS, source.APPSTORE, appid_ios, isHd) SetConfigDataAppId(source.ANDROID, source.TAPTAP, appid_taptap, isHd) SetConfigDataAppId(source.ANDROID, source.HUAWEI, appid_huawei, isHd) UpdateLanguageName(APP_NAME_CN_ANDROID, APP_NAME_EN_ANDROID, isHd) # if data.has_key("PACKAGE_HD_ANDROID"): # PACKAGE_HD_ANDROID = data["PACKAGE_HD_ANDROID"] if isAuto == True: autoPlusVersion(isHd, data) # 重新加载 data = loadJson(isHd) APPVERSION_ANDROID = versionCodeToVersion() APPVERSION_CODE_ANDROID = versionCode # appversion.json if isAuto == False: src = common.GetProjectConfigDefault() + "/appinfo/appversion.json" dst = common.GetProjectConfigApp() + "/appinfo/appversion.json" flag = os.path.exists(dst) # if not isHd: shutil.copyfile(src, dst) strfile = common.GetFileString(dst) key = "_VERSION_ANDROID_" if isHd: key = "_VERSION_HD_ANDROID_" version_web = mainAppVersionHuawei.ParseVersion(appid_huawei) strfile = strfile.replace(key, version_web) common.saveString2File(strfile, dst) filepath = common.GetProjectConfigAppType() + "/appversion.json" flag = os.path.exists(filepath) strFileJson = "{}" if flag: strFileJson = common.GetFileString(filepath) dataRoot = json.loads(strFileJson) dataRoot[common.getGameName()] = json.loads(strfile) common.SaveJson(filepath, dataRoot) print(APP_NAME_CN_ANDROID) print(APP_NAME_EN_ANDROID) print(APP_NAME_CN_IOS) print(APP_NAME_EN_IOS) print(PACKAGE_ANDROID) print("android version:" + APPVERSION_ANDROID) print("ios version:" + APPVERSION_IOS) # android # name strStart = "app_name\">" strEnd = "<" # cn strOut = replaceStringOfFile(file_name_cn_android, strStart, strEnd, APP_NAME_CN_ANDROID) saveString2File(strOut, file_name_cn_android) # en strOut = replaceStringOfFile(file_name_en_android, strStart, strEnd, APP_NAME_EN_ANDROID) saveString2File(strOut, file_name_en_android) updateAndroidManifest(file_AndroidManifest, PACKAGE_ANDROID, APPVERSION_ANDROID, APPVERSION_CODE_ANDROID, isHd) updateAndroidManifest(file_AndroidManifest_GP, PACKAGE_ANDROID, APPVERSION_ANDROID, APPVERSION_CODE_ANDROID, isHd) # admob replaceGoogleServiceFile(file_google_service_android, PACKAGE_ANDROID) # ios #appname replaceFile(file_info_plist_ios, "_APP_NAME_", APP_NAME_CN_IOS) file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings" file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings" # cn replaceFile(file_name_cn_ios, "_APP_NAME_", APP_NAME_CN_IOS) # en replaceFile(file_name_en_ios, "_APP_NAME_", APP_NAME_EN_IOS) # package replaceFile(file_info_plist_ios, "_APP_PACKAGE_", PACKAGE_IOS) # version replaceFile(file_info_plist_ios, "_APP_VERSION_", APPVERSION_IOS) #admob appid appid = adconfig.GetCommonAppId(source.ADMOB, source.IOS, isHd) replaceFile(file_info_plist_ios, "_APP_ID_ADMOB_", appid) # CFBundleURLSchemes src = source.WEIBO appid = config.GetShareAppId(src, source.IOS, isHd) replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 0) src = source.WEIXIN appid = config.GetShareAppId(src, source.IOS, isHd) replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 0) src = source.QQ appid = config.GetShareAppId(src, source.IOS, isHd) replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 0) replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 1) # xiaomi aso keyword updateXiaoASOkeyword(data, isHd) # win updateNameWin(isHd, isAuto)
def GetJsonFile(isHd): cur_path = common.GetProjectConfigApp() + "/appinfo" jsonfile = cur_path + '/appinfo.json' if isHd: jsonfile = cur_path + '/appinfo_hd.json' return jsonfile
if i == 2: if sys.argv[i] == "true": is_auto_plus_version = True common.SetCmdPath(cmdPath) #先从default 拷贝 工程文件模版 # ios project file copyResFiles(source.IOS) # android project file copyResFiles(source.ANDROID) # win copyResFiles(source.WIN) # rename src = common.GetProjectConfigApp() + "/appname" dst = common.GetProjectConfigApp() + "/appinfo" flag = os.path.exists(src) if flag: os.rename(src, dst) src = common.GetProjectConfigApp() + "/appinfo/appname.json" dst = common.GetProjectConfigApp() + "/appinfo/appinfo.json" flag = os.path.exists(src) if flag: os.rename(src, dst) src = common.GetProjectConfigApp() + "/appinfo/appname_hd.json" dst = common.GetProjectConfigApp() + "/appinfo/appinfo_hd.json" flag = os.path.exists(src) if flag:
def updateChannel(channel, ishd): print("updateChannel") # project_config = common.GetProjectConfigApp() + "/android" + "/gradle" targetDir = common.GetRootDirAndroidStudio() sourceDir = common.GetProjectConfigApp() project_android = "android/project" rootAndroidStudio = common.GetRootDirAndroidStudio() targetDir = rootAndroidStudio + "/src/main" if ishd == True: project_android = "android/project_hd" if channel == source.GP: config_adsdk_android.SetShareSdk(False) config_adsdk_android.SetAdSdk(source.ADMOB, True) config_adsdk_android.SetAdSdk(source.ADVIEW, False) config_adsdk_android.SetAdSdk(source.GDT, False) config_adsdk_android.SetAdSdk(source.XIAOMI, False) config_adsdk_android.SetAdSdk(source.UNITY, True) config_adsdk_android.SetAdSdk(source.MOBVISTA, False) # project_config = sourceDir + "/" + project_android + "/config" xml = sourceDir + "/" + project_android + "/xml_gp" else: xml = sourceDir + "/" + project_android + "/xml" config_adsdk_android.SetAdSdk(source.ADMOB, True) config_adsdk_android.SetAdSdk(source.MOBVISTA, False) config_adsdk_android.SetAdSdk(source.UNITY, True) config_adsdk_android.SetShareSdk(True) # project_config = sourceDir + "/" + project_android + "/config" common.coverFiles(project_config, targetDir) common.coverFiles(xml, targetDir) build_gradle = common.GetProjectConfigApp() + "/android" + "/gradle/build" # or (channel == source.GP) if (channel == source.TAPTAP): build_gradle = build_gradle + "_" + channel build_gradle = build_gradle + ".gradle" #配置build.grade #common.coverFiles(build_gradle, targetDir) build_gradle_dst = rootAndroidStudio + "/build.gradle" flag = os.path.exists(build_gradle_dst) if flag: os.remove(build_gradle_dst) common.copyOneFile(build_gradle, build_gradle_dst) # "channel_android": "xiaomi" file = getConfigJsonFile() print("channel_android=" + file) strStart = "channel_android\": \"" strEnd = "\"" strOut = replaceStringOfFile(file, strStart, strEnd, channel) saveString2File(strOut, file)
iconDirName = sys.argv[2] # adDirName = sys.argv[3] project_ios = "ios/project" project_android = "android/project" isHD = False if iconDirName == "iconhd": isHD = True project_ios = "ios/project_hd" project_android = "android/project_hd" # project iconRoot = common.GetProjectOutPutApp() reousceDataRoot = common.GetResourceDataRoot() sourceDir = common.GetProjectConfigApp() # sourceAdDir = "../../../../ad_src/"+adDirName # adCommonDir = "../../../../../common_ad" # adSrcDir = adCommonDir+"/ad_src/"+adDirName targetDir = rootAndroidStudio + "/src/main" # resoucedata # dirname = "Resources" # dir1 = reousceDataRoot+"/"+resDataName+"/"+dirname # dir2 = reousceUnity # flag = os.path.exists(dir2) # if flag: # shutil.rmtree(dir2) # shutil.copytree(dir1,dir2) # ios icon