diff --git a/app/src/main/java/com/gh/common/constant/Config.java b/app/src/main/java/com/gh/common/constant/Config.java index 381b17cf49..88c181596a 100644 --- a/app/src/main/java/com/gh/common/constant/Config.java +++ b/app/src/main/java/com/gh/common/constant/Config.java @@ -8,23 +8,24 @@ import android.text.TextUtils; import androidx.annotation.Nullable; -import com.gh.gamecenter.common.utils.DarkModeUtils; -import com.gh.gamecenter.common.utils.EnvHelper; -import com.gh.gamecenter.common.constant.Constants; -import com.gh.gamecenter.core.utils.GsonUtils; import com.gh.common.util.PackageHelper; import com.gh.common.util.PackageUtils; import com.gh.gamecenter.BuildConfig; import com.gh.gamecenter.SuggestionActivity; +import com.gh.gamecenter.common.constant.Constants; +import com.gh.gamecenter.common.eventbus.EBReuse; +import com.gh.gamecenter.common.retrofit.BiResponse; +import com.gh.gamecenter.common.retrofit.Response; +import com.gh.gamecenter.common.utils.DarkModeUtils; +import com.gh.gamecenter.common.utils.EnvHelper; +import com.gh.gamecenter.core.utils.GsonUtils; import com.gh.gamecenter.core.utils.SPUtils; import com.gh.gamecenter.entity.GameGuidePopupEntity; +import com.gh.gamecenter.entity.NewApiSettingsEntity; import com.gh.gamecenter.entity.NewSettingsEntity; import com.gh.gamecenter.entity.NewsEntity; import com.gh.gamecenter.entity.SettingsEntity; -import com.gh.gamecenter.common.eventbus.EBReuse; import com.gh.gamecenter.entity.VSetting; -import com.gh.gamecenter.common.retrofit.BiResponse; -import com.gh.gamecenter.common.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; import com.gh.vspace.VHelper; import com.halo.assistant.HaloApp; @@ -63,8 +64,9 @@ public class Config { private static SettingsEntity mSettingsEntity; private static NewSettingsEntity mNewSettingsEntity; + private static NewApiSettingsEntity mNewApiSettingsEntity; - private static NewSettingsEntity.NightMode mNightModeSetting; + private static NewApiSettingsEntity.NightMode mNightModeSetting; private static VSetting mVSetting; private static GameGuidePopupEntity mGameGuidePopupEntity; private static SharedPreferences mDefaultSharedPreferences; @@ -221,11 +223,11 @@ public class Config { } @Nullable - public static NewSettingsEntity.NightMode getNightModeSetting() { + public static NewApiSettingsEntity.NightMode getNightModeSetting() { if (mNightModeSetting != null) { return mNightModeSetting; - } else if (mNewSettingsEntity != null && mNewSettingsEntity.getNightMode() != null) { - return mNewSettingsEntity.getNightMode(); + } else if (mNewApiSettingsEntity != null && mNewApiSettingsEntity.getNightMode() != null) { + return mNewApiSettingsEntity.getNightMode(); } else { return null; } @@ -350,9 +352,6 @@ public class Config { @Override public void onSuccess(NewSettingsEntity data) { mNewSettingsEntity = data; - if (mNightModeSetting != null) { - mNewSettingsEntity.setNightMode(mNightModeSetting); - } SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data)); } }); @@ -370,24 +369,21 @@ public class Config { }); } - if (mNightModeSetting == null) { + if (mNewApiSettingsEntity == null) { RetrofitManager.getInstance() .getNewApi().getNewSettings(PackageUtils.getGhVersionName(), channel) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new BiResponse() { + .subscribe(new BiResponse() { @Override - public void onSuccess(NewSettingsEntity data) { + public void onSuccess(NewApiSettingsEntity data) { + mNewApiSettingsEntity = data; mNightModeSetting = data.getNightMode(); if (HaloApp.getInstance().isNewForThisVersion && mNightModeSetting != null && mNightModeSetting.getInstall()) { DarkModeUtils.INSTANCE.updateFollowSystemDarkModeToSp(true); DarkModeUtils.INSTANCE.initDarkMode(); } - - if (mNewSettingsEntity != null) { - mNewSettingsEntity.setNightMode(mNightModeSetting); - SPUtils.setString(Constants.SP_NEW_SETTINGS, GsonUtils.toJson(data)); - } + SPUtils.setString(Constants.SP_NEW_API_SETTINGS, GsonUtils.toJson(data)); } }); } diff --git a/app/src/main/java/com/gh/gamecenter/entity/NewApiSettingsEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/NewApiSettingsEntity.kt new file mode 100644 index 0000000000..d4ca9d7078 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/entity/NewApiSettingsEntity.kt @@ -0,0 +1,20 @@ +package com.gh.gamecenter.entity + +import com.google.gson.annotations.SerializedName + +data class NewApiSettingsEntity( + @SerializedName("night_mode") + var nightMode: NightMode? = null, +) { + /** + * + * "icon": false, // 是否显示切换,true显示 + * "setting": false, // 设置页面是否显示,true显示 + * "install": false, // 安装时的默认值,true开启 + */ + data class NightMode( + val icon: Boolean, + val setting: Boolean, + val install: Boolean + ) +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/entity/NewSettingsEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/NewSettingsEntity.kt index c11ca689f2..6be2823b8b 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/NewSettingsEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/NewSettingsEntity.kt @@ -5,8 +5,6 @@ import com.google.gson.annotations.SerializedName data class NewSettingsEntity( @SerializedName("install_model") var installModel: InstallModel? = null, - @SerializedName("night_mode") - var nightMode: NightMode? = null, ) { data class InstallModel( var status: String = "", @@ -14,16 +12,4 @@ data class NewSettingsEntity( @SerializedName("white_list") var whiteList: ArrayList? = arrayListOf() ) - - /** - * - * "icon": false, // 是否显示切换,true显示 - * "setting": false, // 设置页面是否显示,true显示 - * "install": false, // 安装时的默认值,true开启 - */ - data class NightMode( - val icon: Boolean, - val setting: Boolean, - val install: Boolean - ) } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index 977d6015c3..fe843695d2 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -948,7 +948,7 @@ public interface ApiService { * 新的设置接口 */ @GET("settings") - Single getNewSettings(@Query("version") String version, @Query("channel") String channel); + Single getNewSettings(@Query("version") String version, @Query("channel") String channel); /** * 获取新的配置信息,因为旧的已经太大了避免冲突 diff --git a/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java b/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java index c48713da57..b9a7c6bee8 100644 --- a/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java +++ b/module_common/src/main/java/com/gh/gamecenter/common/constant/Constants.java @@ -207,6 +207,9 @@ public class Constants { // 补充配置项 public static final String SP_NEW_SETTINGS = "new_settings"; + // 新接口配置项 + public static final String SP_NEW_API_SETTINGS = "new_api_settings"; + // 畅玩组件的配置 public static final String SP_V_SETTINGS = "v_settings";