def autoPlusVersion(isHd, jsonData):
    global versionCode
    isOld = IsOldVersion(jsonData)
    if isOld:
        autoPlusVersionOldVersion(isHd, jsonData)
    else:
        jsonfile = GetJsonFile(isHd)
        int_v = int(versionCode)
        int_v = int_v + 1
        versionCode = str(int_v)
        dataCode = jsonData["appversion"][source.ANDROID]
        dataCode["code"] = versionCode

        data = jsonData["appversion"][source.ANDROID]
        data["value"] = versionCodeToVersion()

        data = jsonData["appversion"][source.IOS]
        codeios = data["code"]
        int_v = int(codeios)
        int_v = int_v + 1
        codeios = str(int_v)
        data["code"] = codeios
        versionCode = codeios
        data["value"] = versionCodeToVersion()

        # SaveJson(jsonfile,jsonData)
        common.SaveJson(jsonfile, jsonData)
def SetConfigDataAppId(os, chanel, appid, ishd):
    dirconfig = common.GetConfigDataDir()
    filepath = ""
    if os == source.ANDROID:
        filepath = dirconfig + "/config/config_android.json"
        if ishd:
            filepath = dirconfig + "/config/config_android_hd.json"

    if os == source.IOS:
        filepath = dirconfig + "/config/config_ios.json"
        if ishd:
            filepath = dirconfig + "/config/config_ios_hd.json"

    with open(filepath) as json_file:
        data = json.load(json_file)
        data["APPID"][chanel] = appid
        # SaveJson(filepath,data)
        common.SaveJson(filepath, data)
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 SetAppId(isHd, os, channel, appid):
    # loadJson
    data = loadJson(isHd)
    data["appid"][channel] = appid
    filePath = GetJsonFile(isHd)
    common.SaveJson(filePath, data)
Exemplo n.º 5
0
 def Save(self):
     common.SaveJson(self.GetJsonFileConVert(self.isHd),
                     self.rootJsonDataConvert)