|
|
@@ -1,20 +1,15 @@
|
|
|
package com.sheep.gamegroup.module.skin.util;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
-import android.content.ComponentName;
|
|
|
-import android.content.pm.PackageManager;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import com.sheep.gamegroup.absBase.AbsObserver;
|
|
|
import com.sheep.gamegroup.module.plugin.model.Plugin;
|
|
|
import com.sheep.gamegroup.module.plugin.util.SheepPluginUtil;
|
|
|
-import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.gamegroup.util.Md5Util;
|
|
|
import com.sheep.gamegroup.util.PreferenceUtils;
|
|
|
import com.sheep.gamegroup.util.TestUtil;
|
|
|
-import com.sheep.gamegroup.view.activity.SplashAct;
|
|
|
-import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
|
|
|
@@ -24,12 +19,13 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
import io.reactivex.schedulers.Schedulers;
|
|
|
import rx.functions.Action1;
|
|
|
import skin.support.SkinCompatManager;
|
|
|
-//import skin.support.app.SkinAppCompatViewInflater;
|
|
|
import skin.support.app.SkinCardViewInflater;
|
|
|
import skin.support.constraint.app.SkinConstraintViewInflater;
|
|
|
import skin.support.design.app.SkinMaterialViewInflater;
|
|
|
import skin.support.utils.SkinPreference;
|
|
|
|
|
|
+//import skin.support.app.SkinAppCompatViewInflater;
|
|
|
+
|
|
|
/**
|
|
|
* Created by realicing on 2019/1/15.
|
|
|
* realicing@sina.com
|
|
|
@@ -68,7 +64,6 @@ public class SkinUtil {
|
|
|
if(TextUtils.isEmpty(curSkinMd5) || !TextUtils.isEmpty(curSkinName)){
|
|
|
PreferenceUtils.setPrefString(SheepApp.getInstance(), KEY_CUR_SKIN_MD5, "");
|
|
|
restoreDefaultTheme();
|
|
|
- changeDefaultIcon();
|
|
|
}
|
|
|
action1.call(null);
|
|
|
return;
|
|
|
@@ -104,8 +99,6 @@ public class SkinUtil {
|
|
|
public void onSuccess() {
|
|
|
LogUtil.println(SkinUtil.class.getSimpleName(), "changeSkin", "loadSkin", skinName, "onSuccess");
|
|
|
curPlugin = willLoadPlugin;
|
|
|
- if(isLoadNewYearSkin())
|
|
|
- changeIcon();
|
|
|
PreferenceUtils.setPrefString(SheepApp.getInstance(), KEY_CUR_SKIN_MD5, md5);
|
|
|
action1.call(null);
|
|
|
}
|
|
|
@@ -151,61 +144,9 @@ public class SkinUtil {
|
|
|
public static String getSkinPath(String skinName) {
|
|
|
return SheepPluginUtil.getFileByName(skinName, curPlugin).getAbsolutePath();
|
|
|
}
|
|
|
-
|
|
|
- public static void changeIcon() {
|
|
|
- //拿到我们注册的MainActivity组件
|
|
|
- ComponentName defaultComponent = new ComponentName(SheepApp.getInstance(), SplashAct.class.getName()); //拿到默认的组件
|
|
|
- //拿到我注册的别名test组件
|
|
|
- ComponentName testComponent = new ComponentName(SheepApp.getInstance(), BuildConfig.APPLICATION_ID + ".NewYearSplashAct");
|
|
|
- if(!TestUtil.isDev())
|
|
|
- disableComponent(defaultComponent);
|
|
|
- enableComponent(testComponent);
|
|
|
- }
|
|
|
-
|
|
|
- public static void changeDefaultIcon() {
|
|
|
- //拿到我们注册的MainActivity组件
|
|
|
- ComponentName defaultComponent = new ComponentName(SheepApp.getInstance(), SplashAct.class.getName()); //拿到默认的组件
|
|
|
- //拿到我注册的别名test组件
|
|
|
- ComponentName testComponent = new ComponentName(SheepApp.getInstance(), BuildConfig.APPLICATION_ID + ".NewYearSplashAct");
|
|
|
- enableComponent(defaultComponent);
|
|
|
- disableComponent(testComponent);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 启用组件
|
|
|
- *
|
|
|
- * @param componentName
|
|
|
- */
|
|
|
- private static void enableComponent(ComponentName componentName) {
|
|
|
- PackageManager packageManager = SheepApp.getInstance().getPackageManager();
|
|
|
- int state = packageManager.getComponentEnabledSetting(componentName);
|
|
|
- if (state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
|
|
|
- //已经启用
|
|
|
- return;
|
|
|
- }
|
|
|
- packageManager.setComponentEnabledSetting(componentName,
|
|
|
- PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
|
|
|
- PackageManager.DONT_KILL_APP);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 禁用组件
|
|
|
- *
|
|
|
- * @param componentName
|
|
|
- */
|
|
|
- private static void disableComponent(ComponentName componentName) {
|
|
|
- PackageManager packageManager = SheepApp.getInstance().getPackageManager();
|
|
|
- int state = packageManager.getComponentEnabledSetting(componentName);
|
|
|
- if (state == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
|
|
- //已经禁用
|
|
|
- return;
|
|
|
- }
|
|
|
- packageManager.setComponentEnabledSetting(componentName,
|
|
|
- PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
|
|
|
- PackageManager.DONT_KILL_APP);
|
|
|
- }
|
|
|
//获取应用图标
|
|
|
public static int getAppIcon(){
|
|
|
- return isLoadNewYearSkin() ? R.mipmap.icon_new_year : R.mipmap.icon;
|
|
|
+ return R.mipmap.icon;
|
|
|
}
|
|
|
|
|
|
/**
|