- * 描述
- */
-enum SkinMode {
-
- /**
- * 白天
- */
- Light( false, "light" ),
-
- /**
- * 夜晚
- */
- Night( true, "" );
-
- private boolean isDefault;
- private String name;
-
- SkinMode( boolean isDefault, String name ) {
- this.isDefault = isDefault;
- this.name = name;
- }
-
- public boolean isDefault() {
- return isDefault;
- }
-
- public String getName() {
- return name;
- }
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/SkinSupportInstallerConstants.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/SkinSupportInstallerConstants.java
deleted file mode 100644
index 8faea926ca..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/SkinSupportInstallerConstants.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.mogo.skin.support;
-
-public
-/**
- * @author congtaowang
- * @since 2020/8/28
- *
- * 描述
- */
-class SkinSupportInstallerConstants {
-
- public static final String PATH = "/skin/install";
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatBackgroundHelperDelegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatBackgroundHelperDelegate.java
deleted file mode 100644
index a0071395ce..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatBackgroundHelperDelegate.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.view.View;
-
-import androidx.annotation.Keep;
-
-import java.lang.reflect.Method;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 代理 skin.support.widget.SkinCompatBackgroundHelper 类
- */
-class MogoSkinCompatBackgroundHelperDelegate extends MogoSkinCompatHelperDelegate {
-
- private static Method sMethodOnSetBackgroundResource;
-
- @Keep
- @Override
- protected String getDelegateClazzName() {
- return "skin.support.widget.SkinCompatBackgroundHelper";
- }
-
- public MogoSkinCompatBackgroundHelperDelegate( View view ) {
- super( view );
- }
-
- @Override
- protected Class< ? extends View >[] getConstructParameterClazz() {
- return new Class[]{View.class};
- }
-
- @Keep
- public void onSetBackgroundResource( int resId ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sMethodOnSetBackgroundResource == null ) {
- try {
- sMethodOnSetBackgroundResource = mTargetClazz.getDeclaredMethod( "onSetBackgroundResource", int.class );
- sMethodOnSetBackgroundResource.setAccessible( true );
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- if ( sMethodOnSetBackgroundResource != null ) {
- try {
- sMethodOnSetBackgroundResource.invoke( mDelegate, resId );
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatCompoundButtonHelperDelegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatCompoundButtonHelperDelegate.java
deleted file mode 100644
index 8e755983fb..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatCompoundButtonHelperDelegate.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.view.View;
-import android.widget.CompoundButton;
-
-import androidx.annotation.Keep;
-
-import com.mogo.skin.support.IMogoSkinCompatSupportable;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 描述
- */
-class MogoSkinCompatCompoundButtonHelperDelegate extends MogoSkinCompatHelperDelegate implements IMogoSkinCompatSupportable {
-
- protected static Method sSetButtonDrawableMethod;
-
- public MogoSkinCompatCompoundButtonHelperDelegate( CompoundButton view ) {
- super( view );
- }
-
- @Override
- protected Class< ? extends View >[] getConstructParameterClazz() {
- return new Class[]{CompoundButton.class};
- }
-
- @Keep
- public void setButtonDrawable( int resId ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sSetButtonDrawableMethod == null ) {
- try {
- sSetButtonDrawableMethod = mTargetClazz.getDeclaredMethod( "setButtonDrawable", int.class );
- sSetButtonDrawableMethod.setAccessible( true );
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- if ( sSetButtonDrawableMethod != null ) {
- try {
- sSetButtonDrawableMethod.invoke( mDelegate, resId );
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Keep
- @Override
- protected String getDelegateClazzName() {
- return "skin.support.widget.SkinCompatCompoundButtonHelper";
- }
-
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatHelperDelegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatHelperDelegate.java
deleted file mode 100644
index 7a21b2a275..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatHelperDelegate.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.util.AttributeSet;
-import android.view.View;
-
-import androidx.annotation.Keep;
-
-import com.mogo.skin.support.IMogoSkinCompatSupportable;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 描述
- */
-abstract class MogoSkinCompatHelperDelegate implements IMogoSkinCompatSupportable {
-
- protected Class< ? > mTargetClazz;
- protected Object mDelegate;
- protected Method sMethodApplySkin;
- protected Method sMethodLoadFromAttributes;
- private Constructor sConstructor;
-
- private boolean sIsSupport = false;
-
- public MogoSkinCompatHelperDelegate( View view ) {
- loadClazz();
- initDelegateInstance( view );
- }
-
- @Keep
- protected void loadClazz() {
- if ( mTargetClazz == null ) {
- try {
- mTargetClazz = Class.forName( getDelegateClazzName() );
- getLoadFromAttributesMethod();
- getApplySkinMethod();
- sIsSupport = true;
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Keep
- protected void initDelegateInstance( View view ) {
- try {
- if ( sConstructor == null ) {
- if ( mTargetClazz != null ) {
- sConstructor = mTargetClazz.getConstructor( getConstructParameterClazz() );
- sConstructor.setAccessible( true );
- }
- }
- if ( sConstructor != null ) {
- mDelegate = sConstructor.newInstance( view );
- }
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
-
- protected abstract Class< ? extends View >[] getConstructParameterClazz();
-
- protected abstract String getDelegateClazzName();
-
- @Keep
- protected Method getLoadFromAttributesMethod() throws Exception {
- if ( mTargetClazz != null ) {
- sMethodLoadFromAttributes = mTargetClazz.getDeclaredMethod( "loadFromAttributes", AttributeSet.class, int.class );
- sMethodLoadFromAttributes.setAccessible( true );
- }
- return null;
- }
-
- @Keep
- private Method getApplySkinMethod() throws Exception {
- if ( mTargetClazz != null ) {
- sMethodApplySkin = mTargetClazz.getDeclaredMethod( "applySkin" );
- sMethodApplySkin.setAccessible( true );
- }
- return null;
- }
-
- public void loadFromAttributes( AttributeSet attrs, int defStyleAttr ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sMethodLoadFromAttributes != null ) {
- try {
- sMethodLoadFromAttributes.invoke( mDelegate, attrs, defStyleAttr );
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- public void applySkin() {
- if ( !isSupport() ) {
- return;
- }
- if ( sMethodApplySkin != null ) {
- try {
- sMethodApplySkin.invoke( mDelegate );
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- }
-
- public boolean isSupport() {
- return sIsSupport;
- }
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatImageHelperDelegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatImageHelperDelegate.java
deleted file mode 100644
index 127427c351..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatImageHelperDelegate.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.view.View;
-import android.widget.ImageView;
-
-import androidx.annotation.Keep;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 描述
- */
-class MogoSkinCompatImageHelperDelegate extends MogoSkinCompatHelperDelegate {
-
- private static Method sSetImageResourceMethod;
-
- public MogoSkinCompatImageHelperDelegate( ImageView view ) {
- super( view );
- }
-
- @Override
- protected Class< ? extends View >[] getConstructParameterClazz() {
- return new Class[]{ImageView.class};
- }
-
- @Keep
- public void setImageResource( int resId ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sSetImageResourceMethod == null ) {
- try {
- sSetImageResourceMethod = mTargetClazz.getDeclaredMethod( "setImageResource", int.class );
- sSetImageResourceMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sSetImageResourceMethod != null ) {
- try {
- sSetImageResourceMethod.invoke( mDelegate, resId );
- } catch ( IllegalAccessException e ) {
- e.printStackTrace();
- } catch ( InvocationTargetException e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Override
- protected String getDelegateClazzName() {
- return "skin.support.widget.SkinCompatImageHelper";
- }
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatProgressBarHelperDelegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatProgressBarHelperDelegate.java
deleted file mode 100644
index 98a689068c..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatProgressBarHelperDelegate.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.view.View;
-import android.widget.ProgressBar;
-
-import androidx.annotation.Keep;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 描述
- */
-class MogoSkinCompatProgressBarHelperDelegate extends MogoSkinCompatHelperDelegate {
-
- public MogoSkinCompatProgressBarHelperDelegate( ProgressBar view ) {
- super( view );
- }
-
- @Override
- protected Class< ? extends View >[] getConstructParameterClazz() {
- return new Class[]{ProgressBar.class};
- }
-
- @Keep
- @Override
- protected String getDelegateClazzName() {
- return "skin.support.widget.SkinCompatProgressBarHelper";
- }
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatSeekBarHelperDelegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatSeekBarHelperDelegate.java
deleted file mode 100644
index 32a706c839..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatSeekBarHelperDelegate.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.view.View;
-import android.widget.SeekBar;
-
-import androidx.annotation.Keep;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 描述
- */
-class MogoSkinCompatSeekBarHelperDelegate extends MogoSkinCompatHelperDelegate {
-
- public MogoSkinCompatSeekBarHelperDelegate( SeekBar view ) {
- super( view );
- }
-
- @Override
- protected Class< ? extends View >[] getConstructParameterClazz() {
- return new Class[]{SeekBar.class};
- }
-
- @Keep
- @Override
- protected String getDelegateClazzName() {
- return "skin.support.widget.SkinCompatSeekBarHelper";
- }
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatTextHelperDelegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatTextHelperDelegate.java
deleted file mode 100644
index f3d6add899..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatTextHelperDelegate.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.content.Context;
-import android.view.View;
-import android.widget.TextView;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.Keep;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 描述
- */
-class MogoSkinCompatTextHelperDelegate extends MogoSkinCompatHelperDelegate {
-
- private static Method sOnSetTextAppearanceMethod;
- private static Method sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod;
- private static Method sOnSetCompoundDrawablesWithIntrinsicBoundsMethod;
- private static Method sGetTextColorResIdMethod;
-
- public MogoSkinCompatTextHelperDelegate( TextView view ) {
- super( view );
- }
-
- @Override
- protected Class< ? extends View >[] getConstructParameterClazz() {
- return new Class[]{TextView.class};
- }
-
- @Keep
- public void onSetTextAppearance( Context context, int resId ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sOnSetTextAppearanceMethod == null ) {
- try {
- sOnSetTextAppearanceMethod = mTargetClazz.getDeclaredMethod( "onSetTextAppearance", Context.class, int.class );
- sOnSetTextAppearanceMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sOnSetTextAppearanceMethod != null ) {
- try {
- sOnSetTextAppearanceMethod.invoke( mDelegate, context, resId );
- } catch ( IllegalAccessException e ) {
- e.printStackTrace();
- } catch ( InvocationTargetException e ) {
- e.printStackTrace();
- }
- }
-
- }
-
- @Keep
- public void onSetCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod == null ) {
- try {
- sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod = mTargetClazz.getDeclaredMethod( "onSetCompoundDrawablesRelativeWithIntrinsicBounds", int.class, int.class, int.class, int.class );
- sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod != null ) {
- try {
- sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod.invoke( mDelegate, start, top, end, bottom );
- } catch ( IllegalAccessException e ) {
- e.printStackTrace();
- } catch ( InvocationTargetException e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Keep
- public void onSetCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sOnSetCompoundDrawablesWithIntrinsicBoundsMethod == null ) {
- try {
- sOnSetCompoundDrawablesWithIntrinsicBoundsMethod = mTargetClazz.getDeclaredMethod( "onSetCompoundDrawablesWithIntrinsicBounds", int.class, int.class, int.class, int.class );
- sOnSetCompoundDrawablesWithIntrinsicBoundsMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sOnSetCompoundDrawablesWithIntrinsicBoundsMethod != null ) {
- try {
- sOnSetCompoundDrawablesWithIntrinsicBoundsMethod.invoke( mDelegate, left, top, right, bottom );
- } catch ( IllegalAccessException e ) {
- e.printStackTrace();
- } catch ( InvocationTargetException e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Keep
- public int getTextColorResId() {
- if ( !isSupport() ) {
- return 0;
- }
- if ( sGetTextColorResIdMethod == null ) {
- try {
- sGetTextColorResIdMethod = mTargetClazz.getDeclaredMethod( "getTextColorResId" );
- sGetTextColorResIdMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sGetTextColorResIdMethod != null ) {
- try {
- Object result = sGetTextColorResIdMethod.invoke( mDelegate );
- return ( ( Integer ) result ).intValue();
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- return 0;
- }
-
- @Keep
- @Override
- protected String getDelegateClazzName() {
- return "skin.support.widget.SkinCompatTextHelper";
- }
-}
diff --git a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatTextHelperV17Delegate.java b/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatTextHelperV17Delegate.java
deleted file mode 100644
index a96d811f9e..0000000000
--- a/skin/mogo-skin-support/src/main/java/com/mogo/skin/support/helper/MogoSkinCompatTextHelperV17Delegate.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package com.mogo.skin.support.helper;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.view.View;
-import android.widget.TextView;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.Keep;
-import androidx.annotation.RequiresApi;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public
-/**
- * @author congtaowang
- * @since 2020/9/3
- *
- * 描述
- */
-@RequiresApi( 17 )
-@TargetApi( 17 )
-class MogoSkinCompatTextHelperV17Delegate extends MogoSkinCompatHelperDelegate {
-
- private static Method sOnSetTextAppearanceMethod;
- private static Method sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod;
- private static Method sOnSetCompoundDrawablesWithIntrinsicBoundsMethod;
- private static Method sGetTextColorResIdMethod;
-
- public MogoSkinCompatTextHelperV17Delegate( TextView view ) {
- super( view );
- }
-
- @Override
- protected Class< ? extends View >[] getConstructParameterClazz() {
- return new Class[]{TextView.class};
- }
-
- @Keep
- public void onSetTextAppearance( Context context, int resId ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sOnSetTextAppearanceMethod == null ) {
- try {
- sOnSetTextAppearanceMethod = mTargetClazz.getDeclaredMethod( "onSetTextAppearance", Context.class, int.class );
- sOnSetTextAppearanceMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sOnSetTextAppearanceMethod != null ) {
- try {
- sOnSetTextAppearanceMethod.invoke( mDelegate, context, resId );
- } catch ( IllegalAccessException e ) {
- e.printStackTrace();
- } catch ( InvocationTargetException e ) {
- e.printStackTrace();
- }
- }
-
- }
-
- @Keep
- public void onSetCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod == null ) {
- try {
- sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod = mTargetClazz.getDeclaredMethod( "onSetCompoundDrawablesRelativeWithIntrinsicBounds", int.class, int.class, int.class, int.class );
- sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod != null ) {
- try {
- sOnSetCompoundDrawablesRelativeWithIntrinsicBoundsMethod.invoke( mDelegate, start, top, end, bottom );
- } catch ( IllegalAccessException e ) {
- e.printStackTrace();
- } catch ( InvocationTargetException e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Keep
- public void onSetCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom ) {
- if ( !isSupport() ) {
- return;
- }
- if ( sOnSetCompoundDrawablesWithIntrinsicBoundsMethod == null ) {
- try {
- sOnSetCompoundDrawablesWithIntrinsicBoundsMethod = mTargetClazz.getDeclaredMethod( "onSetCompoundDrawablesWithIntrinsicBounds", int.class, int.class, int.class, int.class );
- sOnSetCompoundDrawablesWithIntrinsicBoundsMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sOnSetCompoundDrawablesWithIntrinsicBoundsMethod != null ) {
- try {
- sOnSetCompoundDrawablesWithIntrinsicBoundsMethod.invoke( mDelegate, left, top, right, bottom );
- } catch ( IllegalAccessException e ) {
- e.printStackTrace();
- } catch ( InvocationTargetException e ) {
- e.printStackTrace();
- }
- }
- }
-
- @Keep
- public int getTextColorResId() {
- if ( !isSupport() ) {
- return 0;
- }
- if ( sGetTextColorResIdMethod == null ) {
- try {
- sGetTextColorResIdMethod = mTargetClazz.getDeclaredMethod( "getTextColorResId" );
- sGetTextColorResIdMethod.setAccessible( true );
- } catch ( NoSuchMethodException e ) {
- e.printStackTrace();
- }
- }
- if ( sGetTextColorResIdMethod != null ) {
- try {
- Object result = sGetTextColorResIdMethod.invoke( mDelegate );
- return ( ( Integer ) result ).intValue();
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
- return 0;
- }
-
- @Keep
- @Override
- protected String getDelegateClazzName() {
- return "skin.support.widget.SkinCompatTextHelperV17";
- }
-}
diff --git a/skin/mogo-skin-support/src/main/res/values/attrs.xml b/skin/mogo-skin-support/src/main/res/values/attrs.xml
deleted file mode 100755
index e5a1cc0817..0000000000
--- a/skin/mogo-skin-support/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/.gitignore b/skin/skin-support-appcompat/.gitignore
deleted file mode 100755
index 796b96d1c4..0000000000
--- a/skin/skin-support-appcompat/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/skin/skin-support-appcompat/build.gradle b/skin/skin-support-appcompat/build.gradle
deleted file mode 100755
index 4c8cb21a1a..0000000000
--- a/skin/skin-support-appcompat/build.gradle
+++ /dev/null
@@ -1,36 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion rootProject.ext.android.compileSdkVersion
- // buildToolsVersion rootProject.ext.android.buildToolsVersion
- defaultConfig {
- minSdkVersion rootProject.ext.android.minSdkVersion
- targetSdkVersion rootProject.ext.android.targetSdkVersion
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
- sourceSets {
- main {
- res.srcDirs = ['src/main/res', 'src/main/res-alertdialog']
- }
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation rootProject.ext.dependencies.androidxappcompat
-
- if( Boolean.valueOf(USE_MAVEN_PACKAGE) ){
- implementation rootProject.ext.dependencies.skinsupportbase
- } else {
- implementation project(":skin:skin-support")
- }
-}
-
-apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/consumer-rules.pro b/skin/skin-support-appcompat/consumer-rules.pro
deleted file mode 100644
index 7511958b62..0000000000
--- a/skin/skin-support-appcompat/consumer-rules.pro
+++ /dev/null
@@ -1,2 +0,0 @@
--keep class androidx.appcompat.app.SkinAppCompatDelegateImpl{*;}
--keep class skin.support.**{*;}
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/gradle.properties b/skin/skin-support-appcompat/gradle.properties
deleted file mode 100644
index ab3645e7fe..0000000000
--- a/skin/skin-support-appcompat/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-GROUP=com.mogo.skin
-POM_ARTIFACT_ID=skin-support-appcompat
-VERSION_CODE=1
diff --git a/skin/skin-support-appcompat/proguard-rules.pro b/skin/skin-support-appcompat/proguard-rules.pro
deleted file mode 100755
index f1b424510d..0000000000
--- a/skin/skin-support-appcompat/proguard-rules.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/skin/skin-support-appcompat/src/main/AndroidManifest.xml b/skin/skin-support-appcompat/src/main/AndroidManifest.xml
deleted file mode 100755
index 23d3ebdfc8..0000000000
--- a/skin/skin-support-appcompat/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
diff --git a/skin/skin-support-appcompat/src/main/java/androidx/appcompat/app/SkinAppCompatDelegateImpl.java b/skin/skin-support-appcompat/src/main/java/androidx/appcompat/app/SkinAppCompatDelegateImpl.java
deleted file mode 100755
index 9abc4d4146..0000000000
--- a/skin/skin-support-appcompat/src/main/java/androidx/appcompat/app/SkinAppCompatDelegateImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package androidx.appcompat.app;
-
-import android.app.Activity;
-import android.content.Context;
-import android.view.Window;
-
-import java.lang.ref.WeakReference;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-public class SkinAppCompatDelegateImpl extends AppCompatDelegateImpl {
- private static Map> sDelegateMap = new WeakHashMap<>();
-
- public static AppCompatDelegate get(Activity activity, AppCompatCallback callback) {
- WeakReference delegateRef = sDelegateMap.get(activity);
- AppCompatDelegate delegate = (delegateRef == null ? null : delegateRef.get());
- if (delegate == null) {
- delegate = new SkinAppCompatDelegateImpl(activity, activity.getWindow(), callback);
- sDelegateMap.put(activity, new WeakReference<>(delegate));
- }
- return delegate;
- }
-
- private SkinAppCompatDelegateImpl(Context context, Window window, AppCompatCallback callback) {
- super(context, window, callback);
- }
-
- @Override
- public void installViewFactory() {
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/app/SkinAppCompatViewInflater.java b/skin/skin-support-appcompat/src/main/java/skin/support/app/SkinAppCompatViewInflater.java
deleted file mode 100755
index 5605d84e4d..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/app/SkinAppCompatViewInflater.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package skin.support.app;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Build;
-
-import androidx.core.view.ViewCompat;
-import androidx.appcompat.view.ContextThemeWrapper;
-import androidx.appcompat.widget.TintContextWrapper;
-import androidx.appcompat.widget.VectorEnabledTintResources;
-
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewParent;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatVectorResources;
-import skin.support.utils.Slog;
-import skin.support.widget.SkinCompatAutoCompleteTextView;
-import skin.support.widget.SkinCompatButton;
-import skin.support.widget.SkinCompatCheckBox;
-import skin.support.widget.SkinCompatCheckedTextView;
-import skin.support.widget.SkinCompatEditText;
-import skin.support.widget.SkinCompatFrameLayout;
-import skin.support.widget.SkinCompatImageButton;
-import skin.support.widget.SkinCompatImageView;
-import skin.support.widget.SkinCompatLinearLayout;
-import skin.support.widget.SkinCompatMultiAutoCompleteTextView;
-import skin.support.widget.SkinCompatProgressBar;
-import skin.support.widget.SkinCompatRadioButton;
-import skin.support.widget.SkinCompatRadioGroup;
-import skin.support.widget.SkinCompatRatingBar;
-import skin.support.widget.SkinCompatRelativeLayout;
-import skin.support.widget.SkinCompatScrollView;
-import skin.support.widget.SkinCompatSeekBar;
-import skin.support.widget.SkinCompatSpinner;
-import skin.support.widget.SkinCompatTextView;
-import skin.support.widget.SkinCompatToolbar;
-import skin.support.widget.SkinCompatView;
-
-public class SkinAppCompatViewInflater implements SkinLayoutInflater, SkinWrapper {
- private static final String LOG_TAG = "SkinAppCompatViewInflater";
-
- public SkinAppCompatViewInflater() {
- SkinCompatVectorResources.getInstance();
- }
-
- @Override
- public View createView(Context context, String name, AttributeSet attrs) {
- View view = createViewFromFV(context, name, attrs);
-
- if (view == null) {
- view = createViewFromV7(context, name, attrs);
- }
- return view;
- }
-
- private View createViewFromFV(Context context, String name, AttributeSet attrs) {
- View view = null;
- if (name.contains(".")) {
- return null;
- }
- switch (name) {
- case "View":
- view = new SkinCompatView(context, attrs);
- break;
- case "LinearLayout":
- view = new SkinCompatLinearLayout(context, attrs);
- break;
- case "RelativeLayout":
- view = new SkinCompatRelativeLayout(context, attrs);
- break;
- case "FrameLayout":
- view = new SkinCompatFrameLayout(context, attrs);
- break;
- case "TextView":
- view = new SkinCompatTextView(context, attrs);
- break;
- case "ImageView":
- view = new SkinCompatImageView(context, attrs);
- break;
- case "Button":
- view = new SkinCompatButton(context, attrs);
- break;
- case "EditText":
- view = new SkinCompatEditText(context, attrs);
- break;
- case "Spinner":
- view = new SkinCompatSpinner(context, attrs);
- break;
- case "ImageButton":
- view = new SkinCompatImageButton(context, attrs);
- break;
- case "CheckBox":
- view = new SkinCompatCheckBox(context, attrs);
- break;
- case "RadioButton":
- view = new SkinCompatRadioButton(context, attrs);
- break;
- case "RadioGroup":
- view = new SkinCompatRadioGroup(context, attrs);
- break;
- case "CheckedTextView":
- view = new SkinCompatCheckedTextView(context, attrs);
- break;
- case "AutoCompleteTextView":
- view = new SkinCompatAutoCompleteTextView(context, attrs);
- break;
- case "MultiAutoCompleteTextView":
- view = new SkinCompatMultiAutoCompleteTextView(context, attrs);
- break;
- case "RatingBar":
- view = new SkinCompatRatingBar(context, attrs);
- break;
- case "SeekBar":
- view = new SkinCompatSeekBar(context, attrs);
- break;
- case "ProgressBar":
- view = new SkinCompatProgressBar(context, attrs);
- break;
- case "ScrollView":
- view = new SkinCompatScrollView(context, attrs);
- break;
- default:
- break;
- }
- return view;
- }
-
- private View createViewFromV7(Context context, String name, AttributeSet attrs) {
- View view = null;
- switch (name) {
- case "androidx.appcompat.widget.Toolbar":
- view = new SkinCompatToolbar(context, attrs);
- break;
- default:
- break;
- }
- return view;
- }
-
- @Override
- public Context wrapContext(Context context, View parent, AttributeSet attrs) {
- final boolean isPre21 = Build.VERSION.SDK_INT < 21;
-
- // We only want the View to inherit its context if we're running pre-v21
- final boolean inheritContext = isPre21 && shouldInheritContext(context, (ViewParent) parent);
-
- // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy
- // by using the parent's context
- if (inheritContext && parent != null) {
- context = parent.getContext();
- }
- boolean readAndroidTheme = isPre21; /* Only read android:theme pre-L (L+ handles this anyway) */
- boolean readAppTheme = true; /* Read read app:theme as a fallback at all times for legacy reasons */
- boolean wrapContext = VectorEnabledTintResources.shouldBeUsed(); /* Only tint wrap the context if enabled */
-
- // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy
- // by using the parent's context
- if (inheritContext && parent != null) {
- context = parent.getContext();
- }
- if (readAndroidTheme || readAppTheme) {
- // We then apply the theme on the context, if specified
- context = themifyContext(context, attrs, readAndroidTheme, readAppTheme);
- }
- if (wrapContext) {
- context = TintContextWrapper.wrap(context);
- }
- return context;
- }
-
- private boolean shouldInheritContext(Context context, ViewParent parent) {
- if (parent == null) {
- // The initial parent is null so just return false
- return false;
- }
- if (context instanceof Activity) {
- final View windowDecor = ((Activity) context).getWindow().getDecorView();
- while (true) {
- if (parent == null) {
- // Bingo. We've hit a view which has a null parent before being terminated from
- // the loop. This is (most probably) because it's the root view in an inflation
- // call, therefore we should inherit. This works as the inflated layout is only
- // added to the hierarchy at the end of the inflate() call.
- return true;
- } else if (parent == windowDecor || !(parent instanceof View)
- || ViewCompat.isAttachedToWindow((View) parent)) {
- // We have either hit the window's decor view, a parent which isn't a View
- // (i.e. ViewRootImpl), or an attached view, so we know that the original parent
- // is currently added to the view hierarchy. This means that it has not be
- // inflated in the current inflate() call and we should not inherit the context.
- return false;
- }
- parent = parent.getParent();
- }
- }
- return false;
- }
-
- /**
- * Allows us to emulate the {@code android:theme} attribute for devices before L.
- */
- private static Context themifyContext(Context context, AttributeSet attrs,
- boolean useAndroidTheme, boolean useAppTheme) {
- final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0);
- int themeId = 0;
- if (useAndroidTheme) {
- // First try reading android:theme if enabled
- themeId = a.getResourceId(R.styleable.View_android_theme, 0);
- }
- if (useAppTheme && themeId == 0) {
- // ...if that didn't work, try reading app:theme (for legacy reasons) if enabled
- themeId = a.getResourceId(R.styleable.View_theme, 0);
-
- if (themeId != 0) {
- Slog.i(LOG_TAG, "app:theme is now deprecated. "
- + "Please move to using android:theme instead.");
- }
- }
- a.recycle();
-
- if (themeId != 0 && (!(context instanceof ContextThemeWrapper)
- || ((ContextThemeWrapper) context).getThemeResId() != themeId)) {
- // If the context isn't a ContextThemeWrapper, or it is but does not have
- // the same theme as we need, wrap it in a new wrapper
- context = new ContextThemeWrapper(context, themeId);
- }
- return context;
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/app/SkinCompatActivity.java b/skin/skin-support-appcompat/src/main/java/skin/support/app/SkinCompatActivity.java
deleted file mode 100755
index 550281ac87..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/app/SkinCompatActivity.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package skin.support.app;
-
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.core.view.LayoutInflaterCompat;
-import androidx.appcompat.app.AppCompatActivity;
-
-import skin.support.SkinCompatManager;
-import skin.support.content.res.SkinCompatThemeUtils;
-import skin.support.content.res.SkinCompatVectorResources;
-import skin.support.observe.SkinObservable;
-import skin.support.observe.SkinObserver;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-import static skin.support.widget.SkinCompatHelper.checkResourceId;
-
-/**
- * Created by ximsfei on 17-1-8.
- */
-@Deprecated
-public class SkinCompatActivity extends AppCompatActivity implements SkinObserver {
-
- private SkinCompatDelegate mSkinDelegate;
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- LayoutInflaterCompat.setFactory2(getLayoutInflater(), getSkinDelegate());
- super.onCreate(savedInstanceState);
- updateStatusBarColor();
- updateWindowBackground();
- }
-
- @NonNull
- public SkinCompatDelegate getSkinDelegate() {
- if (mSkinDelegate == null) {
- mSkinDelegate = SkinCompatDelegate.create(this);
- }
- return mSkinDelegate;
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- SkinCompatManager.getInstance().addObserver(this);
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- SkinCompatManager.getInstance().deleteObserver(this);
- }
-
- protected void updateStatusBarColor() {
- }
-
- protected void updateWindowBackground() {
- int windowBackgroundResId = SkinCompatThemeUtils.getWindowBackgroundResId(this);
- if (checkResourceId(windowBackgroundResId) != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(this, windowBackgroundResId);
- if (drawable != null) {
- getWindow().setBackgroundDrawable(drawable);
- }
- }
- }
-
- @Override
- public void updateSkin(SkinObservable observable, Object o) {
- updateStatusBarColor();
- updateWindowBackground();
- getSkinDelegate().applySkin();
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatDrawableManager.java b/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatDrawableManager.java
deleted file mode 100755
index 49b80d91be..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatDrawableManager.java
+++ /dev/null
@@ -1,754 +0,0 @@
-package skin.support.content.res;
-
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.graphics.Color;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.Drawable.ConstantState;
-import android.graphics.drawable.LayerDrawable;
-import android.os.Build;
-import androidx.annotation.ColorInt;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
-import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
-import androidx.vectordrawable.graphics.drawable.VectorDrawableCompat;
-import androidx.core.graphics.drawable.DrawableCompat;
-import androidx.collection.ArrayMap;
-import androidx.collection.LongSparseArray;
-import androidx.collection.LruCache;
-import androidx.appcompat.R;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.SparseArray;
-import android.util.TypedValue;
-import android.util.Xml;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-import static androidx.core.graphics.ColorUtils.compositeColors;
-import static skin.support.content.res.SkinCompatThemeUtils.getDisabledThemeAttrColor;
-import static skin.support.content.res.SkinCompatThemeUtils.getThemeAttrColor;
-import static skin.support.content.res.SkinCompatThemeUtils.getThemeAttrColorStateList;
-
-final class SkinCompatDrawableManager {
- private interface InflateDelegate {
- Drawable createFromXmlInner(@NonNull Context context, @NonNull XmlPullParser parser,
- @NonNull AttributeSet attrs, @Nullable Resources.Theme theme);
- }
-
- private static final String TAG = SkinCompatDrawableManager.class.getSimpleName();
- private static final boolean DEBUG = false;
- private static final PorterDuff.Mode DEFAULT_MODE = PorterDuff.Mode.SRC_IN;
- private static final String SKIP_DRAWABLE_TAG = "appcompat_skip_skip";
-
- private static final String PLATFORM_VD_CLAZZ = "android.graphics.drawable.VectorDrawable";
-
- private static SkinCompatDrawableManager INSTANCE;
-
- public static SkinCompatDrawableManager get() {
- if (INSTANCE == null) {
- INSTANCE = new SkinCompatDrawableManager();
- installDefaultInflateDelegates(INSTANCE);
- }
- return INSTANCE;
- }
-
- private static void installDefaultInflateDelegates(@NonNull SkinCompatDrawableManager manager) {
- // This sdk version check will affect src:appCompat code path.
- // Although VectorDrawable exists in Android framework from Lollipop, AppCompat will use the
- // VectorDrawableCompat before Nougat to utilize the bug fixes in VectorDrawableCompat.
- if (Build.VERSION.SDK_INT < 24) {
- manager.addDelegate("vector", new VdcInflateDelegate());
- // AnimatedVectorDrawableCompat only works on API v11+
- manager.addDelegate("animated-vector", new AvdcInflateDelegate());
- }
- }
-
- private static final ColorFilterLruCache COLOR_FILTER_CACHE = new ColorFilterLruCache(6);
-
- /**
- * Drawables which should be tinted with the value of {@code R.attr.colorControlNormal},
- * using the default mode using a raw color filter.
- */
- private static final int[] COLORFILTER_TINT_COLOR_CONTROL_NORMAL = {
- R.drawable.abc_textfield_search_default_mtrl_alpha,
- R.drawable.abc_textfield_default_mtrl_alpha,
- R.drawable.abc_ab_share_pack_mtrl_alpha
- };
-
- /**
- * Drawables which should be tinted with the value of {@code R.attr.colorControlNormal}, using
- * {@link DrawableCompat}'s tinting functionality.
- */
- private static final int[] TINT_COLOR_CONTROL_NORMAL = {
- R.drawable.abc_ic_commit_search_api_mtrl_alpha,
- R.drawable.abc_seekbar_tick_mark_material,
- R.drawable.abc_ic_menu_share_mtrl_alpha,
- R.drawable.abc_ic_menu_copy_mtrl_am_alpha,
- R.drawable.abc_ic_menu_cut_mtrl_alpha,
- R.drawable.abc_ic_menu_selectall_mtrl_alpha,
- R.drawable.abc_ic_menu_paste_mtrl_am_alpha
- };
-
- /**
- * Drawables which should be tinted with the value of {@code R.attr.colorControlActivated},
- * using a color filter.
- */
- private static final int[] COLORFILTER_COLOR_CONTROL_ACTIVATED = {
- R.drawable.abc_textfield_activated_mtrl_alpha,
- R.drawable.abc_textfield_search_activated_mtrl_alpha,
- R.drawable.abc_cab_background_top_mtrl_alpha,
- R.drawable.abc_text_cursor_material,
- R.drawable.abc_text_cursor_material,
- R.drawable.abc_text_cursor_material,
- R.drawable.abc_text_cursor_material,
- R.drawable.abc_text_cursor_material,
- R.drawable.abc_text_cursor_material,
- R.drawable.abc_text_cursor_material
- };
-
- /**
- * Drawables which should be tinted with the value of {@code android.R.attr.colorBackground},
- * using the {@link PorterDuff.Mode#MULTIPLY} mode and a color filter.
- */
- private static final int[] COLORFILTER_COLOR_BACKGROUND_MULTIPLY = {
- R.drawable.abc_popup_background_mtrl_mult,
- R.drawable.abc_cab_background_internal_bg,
- R.drawable.abc_menu_hardkey_panel_mtrl_mult
- };
-
- /**
- * Drawables which should be tinted using a state list containing values of
- * {@code R.attr.colorControlNormal} and {@code R.attr.colorControlActivated}
- */
- private static final int[] TINT_COLOR_CONTROL_STATE_LIST = {
- R.drawable.abc_tab_indicator_material,
- R.drawable.abc_textfield_search_material
- };
-
- /**
- * Drawables which should be tinted using a state list containing values of
- * {@code R.attr.colorControlNormal} and {@code R.attr.colorControlActivated} for the checked
- * state.
- */
- private static final int[] TINT_CHECKABLE_BUTTON_LIST = {
- R.drawable.abc_btn_check_material,
- R.drawable.abc_btn_radio_material
- };
-
- private WeakHashMap> mTintLists;
- private ArrayMap mDelegates;
- private SparseArray mKnownDrawableIdTags;
-
- private final Object mDrawableCacheLock = new Object();
- private final WeakHashMap>>
- mDrawableCaches = new WeakHashMap<>(0);
-
- private TypedValue mTypedValue;
-
- private boolean mHasCheckedVectorDrawableSetup;
-
- void clearCaches() {
- mDrawableCaches.clear();
- if (mKnownDrawableIdTags != null) {
- mKnownDrawableIdTags.clear();
- }
- if (mTintLists != null) {
- mTintLists.clear();
- }
- COLOR_FILTER_CACHE.evictAll();
- }
-
- public Drawable getDrawable(@NonNull Context context, @DrawableRes int resId) {
- return getDrawable(context, resId, false);
- }
-
- Drawable getDrawable(@NonNull Context context, @DrawableRes int resId,
- boolean failIfNotKnown) {
- checkVectorDrawableSetup(context);
-
- Drawable drawable = loadDrawableFromDelegates(context, resId);
- if (drawable == null) {
- drawable = createDrawableIfNeeded(context, resId);
- }
- if (drawable == null) {
- drawable = SkinCompatResources.getDrawable(context, resId);
- }
-
- if (drawable != null) {
- // Tint it if needed
- drawable = tintDrawable(context, resId, failIfNotKnown, drawable);
- }
- if (drawable != null) {
- // See if we need to 'fix' the drawable
- SkinCompatDrawableUtils.fixDrawable(drawable);
- }
- return drawable;
- }
-
- public void onConfigurationChanged(@NonNull Context context) {
- synchronized (mDrawableCacheLock) {
- LongSparseArray> cache = mDrawableCaches.get(context);
- if (cache != null) {
- // Crude, but we'll just clear the cache when the configuration changes
- cache.clear();
- }
- }
- }
-
- private static long createCacheKey(TypedValue tv) {
- return (((long) tv.assetCookie) << 32) | tv.data;
- }
-
- private Drawable createDrawableIfNeeded(@NonNull Context context,
- @DrawableRes final int resId) {
- if (mTypedValue == null) {
- mTypedValue = new TypedValue();
- }
- final TypedValue tv = mTypedValue;
- SkinCompatResources.getValue(context, resId, tv, true);
- final long key = createCacheKey(tv);
-
- Drawable dr = getCachedDrawable(context, key);
- if (dr != null) {
- // If we got a cached drawable, return it
- return dr;
- }
-
- // Else we need to try and create one...
- if (resId == R.drawable.abc_cab_background_top_material) {
- dr = new LayerDrawable(new Drawable[]{
- getDrawable(context, R.drawable.abc_cab_background_internal_bg),
- getDrawable(context, R.drawable.abc_cab_background_top_mtrl_alpha)
- });
- }
-
- if (dr != null) {
- dr.setChangingConfigurations(tv.changingConfigurations);
- // If we reached here then we created a new drawable, add it to the cache
- addDrawableToCache(context, key, dr);
- }
-
- return dr;
- }
-
- private Drawable tintDrawable(@NonNull Context context, @DrawableRes int resId,
- boolean failIfNotKnown, @NonNull Drawable drawable) {
- final ColorStateList tintList = getTintList(context, resId);
- if (tintList != null) {
- // First mutate the Drawable, then wrap it and set the tint list
- if (SkinCompatDrawableUtils.canSafelyMutateDrawable(drawable)) {
- drawable = drawable.mutate();
- }
- drawable = DrawableCompat.wrap(drawable);
- DrawableCompat.setTintList(drawable, tintList);
-
- // If there is a blending mode specified for the drawable, use it
- final PorterDuff.Mode tintMode = getTintMode(resId);
- if (tintMode != null) {
- DrawableCompat.setTintMode(drawable, tintMode);
- }
- } else if (resId == R.drawable.abc_seekbar_track_material) {
- LayerDrawable ld = (LayerDrawable) drawable;
- setPorterDuffColorFilter(ld.findDrawableByLayerId(android.R.id.background),
- getThemeAttrColor(context, R.attr.colorControlNormal), DEFAULT_MODE);
- setPorterDuffColorFilter(ld.findDrawableByLayerId(android.R.id.secondaryProgress),
- getThemeAttrColor(context, R.attr.colorControlNormal), DEFAULT_MODE);
- setPorterDuffColorFilter(ld.findDrawableByLayerId(android.R.id.progress),
- getThemeAttrColor(context, R.attr.colorControlActivated), DEFAULT_MODE);
- } else if (resId == R.drawable.abc_ratingbar_material
- || resId == R.drawable.abc_ratingbar_indicator_material
- || resId == R.drawable.abc_ratingbar_small_material) {
- LayerDrawable ld = (LayerDrawable) drawable;
- setPorterDuffColorFilter(ld.findDrawableByLayerId(android.R.id.background),
- getDisabledThemeAttrColor(context, R.attr.colorControlNormal),
- DEFAULT_MODE);
- setPorterDuffColorFilter(ld.findDrawableByLayerId(android.R.id.secondaryProgress),
- getThemeAttrColor(context, R.attr.colorControlActivated), DEFAULT_MODE);
- setPorterDuffColorFilter(ld.findDrawableByLayerId(android.R.id.progress),
- getThemeAttrColor(context, R.attr.colorControlActivated), DEFAULT_MODE);
- } else {
- final boolean tinted = tintDrawableUsingColorFilter(context, resId, drawable);
- if (!tinted && failIfNotKnown) {
- // If we didn't tint using a ColorFilter, and we're set to fail if we don't
- // know the id, return null
- drawable = null;
- }
- }
- return drawable;
- }
-
- private Drawable loadDrawableFromDelegates(@NonNull Context context, @DrawableRes int resId) {
- if (mDelegates != null && !mDelegates.isEmpty()) {
- if (mKnownDrawableIdTags != null) {
- final String cachedTagName = mKnownDrawableIdTags.get(resId);
- if (SKIP_DRAWABLE_TAG.equals(cachedTagName)
- || (cachedTagName != null && mDelegates.get(cachedTagName) == null)) {
- // If we don't have a delegate for the drawable tag, or we've been set to
- // skip it, fail fast and return null
- if (DEBUG) {
- Log.d(TAG, "[loadDrawableFromDelegates] Skipping drawable: "
- + context.getResources().getResourceName(resId));
- }
- return null;
- }
- } else {
- // Create an id cache as we'll need one later
- mKnownDrawableIdTags = new SparseArray<>();
- }
-
- if (mTypedValue == null) {
- mTypedValue = new TypedValue();
- }
- final TypedValue tv = mTypedValue;
- SkinCompatResources.getValue(context, resId, tv, true);
-
- final long key = createCacheKey(tv);
-
- Drawable dr = getCachedDrawable(context, key);
- if (dr != null) {
- if (DEBUG) {
- Log.i(TAG, "[loadDrawableFromDelegates] Returning cached drawable: " +
- context.getResources().getResourceName(resId));
- }
- // We have a cached drawable, return it!
- return dr;
- }
-
- if (tv.string != null && tv.string.toString().endsWith(".xml")) {
- // If the resource is an XML file, let's try and parse it
- try {
- final XmlPullParser parser = SkinCompatResources.getXml(context, resId);
- final AttributeSet attrs = Xml.asAttributeSet(parser);
- int type;
- while ((type = parser.next()) != XmlPullParser.START_TAG &&
- type != XmlPullParser.END_DOCUMENT) {
- // Empty loop
- }
- if (type != XmlPullParser.START_TAG) {
- throw new XmlPullParserException("No start tag found");
- }
-
- final String tagName = parser.getName();
- // Add the tag name to the cache
- mKnownDrawableIdTags.append(resId, tagName);
-
- // Now try and find a delegate for the tag name and inflate if found
- final InflateDelegate delegate = mDelegates.get(tagName);
- if (delegate != null) {
- dr = delegate.createFromXmlInner(context, parser, attrs, null);
- }
- if (dr != null) {
- // Add it to the drawable cache
- dr.setChangingConfigurations(tv.changingConfigurations);
- if (addDrawableToCache(context, key, dr) && DEBUG) {
- Log.i(TAG, "[loadDrawableFromDelegates] Saved drawable to cache: " +
- context.getResources().getResourceName(resId));
- }
- }
- } catch (Exception e) {
- Log.e(TAG, "Exception while inflating drawable", e);
- }
- }
- if (dr == null) {
- // If we reach here then the delegate inflation of the resource failed. Mark it as
- // bad so we skip the id next time
- mKnownDrawableIdTags.append(resId, SKIP_DRAWABLE_TAG);
- }
- return dr;
- }
-
- return null;
- }
-
- private Drawable getCachedDrawable(@NonNull final Context context, final long key) {
- synchronized (mDrawableCacheLock) {
- final LongSparseArray> cache
- = mDrawableCaches.get(context);
- if (cache == null) {
- return null;
- }
-
- final WeakReference wr = cache.get(key);
- if (wr != null) {
- // We have the key, and the secret
- ConstantState entry = wr.get();
- if (entry != null) {
- return entry.newDrawable(context.getResources());
- } else {
- // Our entry has been purged
- cache.delete(key);
- }
- }
- }
- return null;
- }
-
- private boolean addDrawableToCache(@NonNull final Context context, final long key,
- @NonNull final Drawable drawable) {
- final ConstantState cs = drawable.getConstantState();
- if (cs != null) {
- synchronized (mDrawableCacheLock) {
- LongSparseArray> cache = mDrawableCaches.get(context);
- if (cache == null) {
- cache = new LongSparseArray<>();
- mDrawableCaches.put(context, cache);
- }
- cache.put(key, new WeakReference(cs));
- }
- return true;
- }
- return false;
- }
-
- static boolean tintDrawableUsingColorFilter(@NonNull Context context,
- @DrawableRes final int resId, @NonNull Drawable drawable) {
- PorterDuff.Mode tintMode = DEFAULT_MODE;
- boolean colorAttrSet = false;
- int colorAttr = 0;
- int alpha = -1;
-
- if (arrayContains(COLORFILTER_TINT_COLOR_CONTROL_NORMAL, resId)) {
- colorAttr = R.attr.colorControlNormal;
- colorAttrSet = true;
- } else if (arrayContains(COLORFILTER_COLOR_CONTROL_ACTIVATED, resId)) {
- colorAttr = R.attr.colorControlActivated;
- colorAttrSet = true;
- } else if (arrayContains(COLORFILTER_COLOR_BACKGROUND_MULTIPLY, resId)) {
- colorAttr = android.R.attr.colorBackground;
- colorAttrSet = true;
- tintMode = PorterDuff.Mode.MULTIPLY;
- } else if (resId == R.drawable.abc_list_divider_mtrl_alpha) {
- colorAttr = android.R.attr.colorForeground;
- colorAttrSet = true;
- alpha = Math.round(0.16f * 255);
- } else if (resId == R.drawable.abc_dialog_material_background) {
- colorAttr = android.R.attr.colorBackground;
- colorAttrSet = true;
- }
-
- if (colorAttrSet) {
- if (SkinCompatDrawableUtils.canSafelyMutateDrawable(drawable)) {
- drawable = drawable.mutate();
- }
-
- final int color = getThemeAttrColor(context, colorAttr);
- drawable.setColorFilter(getPorterDuffColorFilter(color, tintMode));
-
- if (alpha != -1) {
- drawable.setAlpha(alpha);
- }
-
- if (DEBUG) {
- Log.d(TAG, "[tintDrawableUsingColorFilter] Tinted "
- + context.getResources().getResourceName(resId) +
- " with color: #" + Integer.toHexString(color));
- }
- return true;
- }
- return false;
- }
-
- private void addDelegate(@NonNull String tagName, @NonNull InflateDelegate delegate) {
- if (mDelegates == null) {
- mDelegates = new ArrayMap<>();
- }
- mDelegates.put(tagName, delegate);
- }
-
- private void removeDelegate(@NonNull String tagName, @NonNull InflateDelegate delegate) {
- if (mDelegates != null && mDelegates.get(tagName) == delegate) {
- mDelegates.remove(tagName);
- }
- }
-
- private static boolean arrayContains(int[] array, int value) {
- for (int id : array) {
- if (id == value) {
- return true;
- }
- }
- return false;
- }
-
- static PorterDuff.Mode getTintMode(final int resId) {
- PorterDuff.Mode mode = null;
-
- if (resId == R.drawable.abc_switch_thumb_material) {
- mode = PorterDuff.Mode.MULTIPLY;
- }
-
- return mode;
- }
-
- ColorStateList getTintList(@NonNull Context context, @DrawableRes int resId) {
- // Try the cache first (if it exists)
- ColorStateList tint = getTintListFromCache(context, resId);
-
- if (tint == null) {
- // ...if the cache did not contain a color state list, try and create one
- if (resId == R.drawable.abc_edit_text_material) {
- tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_edittext);
- } else if (resId == R.drawable.abc_switch_track_mtrl_alpha) {
- tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_switch_track);
- } else if (resId == R.drawable.abc_switch_thumb_material) {
- tint = createSwitchThumbColorStateList(context);
- } else if (resId == R.drawable.abc_btn_default_mtrl_shape) {
- tint = createDefaultButtonColorStateList(context);
- } else if (resId == R.drawable.abc_btn_borderless_material) {
- tint = createBorderlessButtonColorStateList(context);
- } else if (resId == R.drawable.abc_btn_colored_material) {
- tint = createColoredButtonColorStateList(context);
- } else if (resId == R.drawable.abc_spinner_mtrl_am_alpha
- || resId == R.drawable.abc_spinner_textfield_background_material) {
- tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_spinner);
- } else if (arrayContains(TINT_COLOR_CONTROL_NORMAL, resId)) {
- tint = getThemeAttrColorStateList(context, R.attr.colorControlNormal);
- } else if (arrayContains(TINT_COLOR_CONTROL_STATE_LIST, resId)) {
- tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_default);
- } else if (arrayContains(TINT_CHECKABLE_BUTTON_LIST, resId)) {
- tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_btn_checkable);
- } else if (resId == R.drawable.abc_seekbar_thumb_material) {
- tint = SkinCompatResources.getColorStateList(context, R.color.abc_tint_seek_thumb);
- }
-
- if (tint != null) {
- addTintListToCache(context, resId, tint);
- }
- }
- return tint;
- }
-
- private ColorStateList getTintListFromCache(@NonNull Context context, @DrawableRes int resId) {
- if (mTintLists != null) {
- final SparseArray tints = mTintLists.get(context);
- return tints != null ? tints.get(resId) : null;
- }
- return null;
- }
-
- private void addTintListToCache(@NonNull Context context, @DrawableRes int resId,
- @NonNull ColorStateList tintList) {
- if (mTintLists == null) {
- mTintLists = new WeakHashMap<>();
- }
- SparseArray themeTints = mTintLists.get(context);
- if (themeTints == null) {
- themeTints = new SparseArray<>();
- mTintLists.put(context, themeTints);
- }
- themeTints.append(resId, tintList);
- }
-
- private ColorStateList createDefaultButtonColorStateList(@NonNull Context context) {
- return createButtonColorStateList(context,
- getThemeAttrColor(context, R.attr.colorButtonNormal));
- }
-
- private ColorStateList createBorderlessButtonColorStateList(@NonNull Context context) {
- // We ignore the custom tint for borderless buttons
- return createButtonColorStateList(context, Color.TRANSPARENT);
- }
-
- private ColorStateList createColoredButtonColorStateList(@NonNull Context context) {
- return createButtonColorStateList(context,
- getThemeAttrColor(context, R.attr.colorAccent));
- }
-
- private ColorStateList createButtonColorStateList(@NonNull final Context context,
- @ColorInt final int baseColor) {
- final int[][] states = new int[4][];
- final int[] colors = new int[4];
- int i = 0;
-
- final int colorControlHighlight = getThemeAttrColor(context, R.attr.colorControlHighlight);
- final int disabledColor = getDisabledThemeAttrColor(context, R.attr.colorButtonNormal);
-
- // Disabled state
- states[i] = SkinCompatThemeUtils.DISABLED_STATE_SET;
- colors[i] = disabledColor;
- i++;
-
- states[i] = SkinCompatThemeUtils.PRESSED_STATE_SET;
- colors[i] = compositeColors(colorControlHighlight, baseColor);
- i++;
-
- states[i] = SkinCompatThemeUtils.FOCUSED_STATE_SET;
- colors[i] = compositeColors(colorControlHighlight, baseColor);
- i++;
-
- // Default enabled state
- states[i] = SkinCompatThemeUtils.EMPTY_STATE_SET;
- colors[i] = baseColor;
- i++;
-
- return new ColorStateList(states, colors);
- }
-
- private ColorStateList createSwitchThumbColorStateList(Context context) {
- final int[][] states = new int[3][];
- final int[] colors = new int[3];
- int i = 0;
-
- final ColorStateList thumbColor = SkinCompatThemeUtils.getThemeAttrColorStateList(context,
- R.attr.colorSwitchThumbNormal);
-
- if (thumbColor != null && thumbColor.isStateful()) {
- // If colorSwitchThumbNormal is a valid ColorStateList, extract the default and
- // disabled colors from it
-
- // Disabled state
- states[i] = SkinCompatThemeUtils.DISABLED_STATE_SET;
- colors[i] = thumbColor.getColorForState(states[i], 0);
- i++;
-
- states[i] = SkinCompatThemeUtils.CHECKED_STATE_SET;
- colors[i] = SkinCompatThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated);
- i++;
-
- // Default enabled state
- states[i] = SkinCompatThemeUtils.EMPTY_STATE_SET;
- colors[i] = thumbColor.getDefaultColor();
- i++;
- } else {
- // Else we'll use an approximation using the default disabled alpha
-
- // Disabled state
- states[i] = SkinCompatThemeUtils.DISABLED_STATE_SET;
- colors[i] = SkinCompatThemeUtils.getDisabledThemeAttrColor(context, R.attr.colorSwitchThumbNormal);
- i++;
-
- states[i] = SkinCompatThemeUtils.CHECKED_STATE_SET;
- colors[i] = SkinCompatThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated);
- i++;
-
- // Default enabled state
- states[i] = SkinCompatThemeUtils.EMPTY_STATE_SET;
- colors[i] = SkinCompatThemeUtils.getThemeAttrColor(context, R.attr.colorSwitchThumbNormal);
- i++;
- }
-
- return new ColorStateList(states, colors);
- }
-
- private static class ColorFilterLruCache extends LruCache {
-
- public ColorFilterLruCache(int maxSize) {
- super(maxSize);
- }
-
- PorterDuffColorFilter get(int color, PorterDuff.Mode mode) {
- return get(generateCacheKey(color, mode));
- }
-
- PorterDuffColorFilter put(int color, PorterDuff.Mode mode, PorterDuffColorFilter filter) {
- return put(generateCacheKey(color, mode), filter);
- }
-
- private static int generateCacheKey(int color, PorterDuff.Mode mode) {
- int hashCode = 1;
- hashCode = 31 * hashCode + color;
- hashCode = 31 * hashCode + mode.hashCode();
- return hashCode;
- }
- }
-
- private static PorterDuffColorFilter createTintFilter(ColorStateList tint,
- PorterDuff.Mode tintMode, final int[] state) {
- if (tint == null || tintMode == null) {
- return null;
- }
- final int color = tint.getColorForState(state, Color.TRANSPARENT);
- return getPorterDuffColorFilter(color, tintMode);
- }
-
- public static PorterDuffColorFilter getPorterDuffColorFilter(int color, PorterDuff.Mode mode) {
- // First, lets see if the cache already contains the color filter
- PorterDuffColorFilter filter = COLOR_FILTER_CACHE.get(color, mode);
-
- if (filter == null) {
- // Cache miss, so create a color filter and add it to the cache
- filter = new PorterDuffColorFilter(color, mode);
- COLOR_FILTER_CACHE.put(color, mode, filter);
- }
-
- return filter;
- }
-
- private static void setPorterDuffColorFilter(Drawable d, int color, PorterDuff.Mode mode) {
- if (SkinCompatDrawableUtils.canSafelyMutateDrawable(d)) {
- d = d.mutate();
- }
- d.setColorFilter(getPorterDuffColorFilter(color, mode == null ? DEFAULT_MODE : mode));
- }
-
- private void checkVectorDrawableSetup(@NonNull Context context) {
- if (mHasCheckedVectorDrawableSetup) {
- // We've already checked so return now...
- return;
- }
- // Here we will check that a known Vector drawable resource inside AppCompat can be
- // correctly decoded
- mHasCheckedVectorDrawableSetup = true;
- final Drawable d = getDrawable(context, R.drawable.abc_vector_test);
- if (d == null || !isVectorDrawable(d)) {
- mHasCheckedVectorDrawableSetup = false;
- throw new IllegalStateException("This app has been built with an incorrect "
- + "configuration. Please configure your build for VectorDrawableCompat.");
- }
- }
-
- private static boolean isVectorDrawable(@NonNull Drawable d) {
- return d instanceof VectorDrawableCompat
- || PLATFORM_VD_CLAZZ.equals(d.getClass().getName());
- }
-
- private static class VdcInflateDelegate implements InflateDelegate {
- VdcInflateDelegate() {
- }
-
- @SuppressLint("NewApi")
- @Override
- public Drawable createFromXmlInner(@NonNull Context context, @NonNull XmlPullParser parser,
- @NonNull AttributeSet attrs, @Nullable Resources.Theme theme) {
- try {
- return VectorDrawableCompat
- .createFromXmlInner(context.getResources(), parser, attrs, theme);
- } catch (Exception e) {
- Log.e("VdcInflateDelegate", "Exception while inflating ", e);
- return null;
- }
- }
- }
-
- @RequiresApi(11)
- @TargetApi(11)
- private static class AvdcInflateDelegate implements InflateDelegate {
- AvdcInflateDelegate() {
- }
-
- @SuppressLint("NewApi")
- @Override
- public Drawable createFromXmlInner(@NonNull Context context, @NonNull XmlPullParser parser,
- @NonNull AttributeSet attrs, @Nullable Resources.Theme theme) {
- try {
- return AnimatedVectorDrawableCompat
- .createFromXmlInner(context, context.getResources(), parser, attrs, theme);
- } catch (Exception e) {
- Log.e("AvdcInflateDelegate", "Exception while inflating ", e);
- return null;
- }
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatDrawableUtils.java b/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatDrawableUtils.java
deleted file mode 100755
index 3f2699ef7d..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatDrawableUtils.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package skin.support.content.res;
-
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.DrawableContainer;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.InsetDrawable;
-import android.graphics.drawable.LayerDrawable;
-import android.graphics.drawable.ScaleDrawable;
-import android.os.Build;
-import androidx.annotation.NonNull;
-
-import skin.support.utils.SkinCompatVersionUtils;
-
-class SkinCompatDrawableUtils {
-
- private static final String VECTOR_DRAWABLE_CLAZZ_NAME
- = "android.graphics.drawable.VectorDrawable";
-
- /**
- * Attempt the fix any issues in the given drawable, usually caused by platform bugs in the
- * implementation. This method should be call after retrieval from
- * {@link android.content.res.Resources} or a {@link android.content.res.TypedArray}.
- */
- static void fixDrawable(@NonNull final Drawable drawable) {
- if (Build.VERSION.SDK_INT == 21
- && VECTOR_DRAWABLE_CLAZZ_NAME.equals(drawable.getClass().getName())) {
- fixVectorDrawableTinting(drawable);
- }
- }
-
- /**
- * Some drawable implementations have problems with mutation. This method returns false if
- * there is a known issue in the given drawable's implementation.
- */
- public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
- if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
- return false;
- } else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
- // GradientDrawable has a bug pre-ICS which results in mutate() resulting
- // in loss of color
- return false;
- } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
- return false;
- }
-
- if (drawable instanceof DrawableContainer) {
- // If we have a DrawableContainer, let's traverse it's child array
- final Drawable.ConstantState state = drawable.getConstantState();
- if (state instanceof DrawableContainer.DrawableContainerState) {
- final DrawableContainer.DrawableContainerState containerState =
- (DrawableContainer.DrawableContainerState) state;
- for (final Drawable child : containerState.getChildren()) {
- if (!canSafelyMutateDrawable(child)) {
- return false;
- }
- }
- }
- } else if (SkinCompatVersionUtils.isV4DrawableWrapper(drawable)) {
- return canSafelyMutateDrawable(SkinCompatVersionUtils.getV4DrawableWrapperWrappedDrawable(drawable));
- } else if (SkinCompatVersionUtils.isV4WrappedDrawable(drawable)) {
- return canSafelyMutateDrawable(SkinCompatVersionUtils.getV4WrappedDrawableWrappedDrawable(drawable));
- } else if (SkinCompatVersionUtils.isV7DrawableWrapper(drawable)) {
- return canSafelyMutateDrawable(SkinCompatVersionUtils.getV7DrawableWrapperWrappedDrawable(drawable));
- } else if (drawable instanceof ScaleDrawable) {
- Drawable scaleDrawable = ((ScaleDrawable) drawable).getDrawable();
- if (scaleDrawable != null) {
- return canSafelyMutateDrawable(scaleDrawable);
- }
- }
-
- return true;
- }
-
- /**
- * VectorDrawable has an issue on API 21 where it sometimes doesn't create its tint filter.
- * Fixed by toggling it's state to force a filter creation.
- */
- private static void fixVectorDrawableTinting(final Drawable drawable) {
- final int[] originalState = drawable.getState();
- if (originalState == null || originalState.length == 0) {
- // The drawable doesn't have a state, so set it to be checked
- drawable.setState(SkinCompatThemeUtils.CHECKED_STATE_SET);
- } else {
- // Else the drawable does have a state, so clear it
- drawable.setState(SkinCompatThemeUtils.EMPTY_STATE_SET);
- }
- // Now set the original state
- drawable.setState(originalState);
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatV7ThemeUtils.java b/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatV7ThemeUtils.java
deleted file mode 100755
index 313d91c54c..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatV7ThemeUtils.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package skin.support.content.res;
-
-import android.content.Context;
-
-import static skin.support.content.res.SkinCompatThemeUtils.getResId;
-
-/**
- * Created by ximsfei on 2017/3/25.
- */
-
-public class SkinCompatV7ThemeUtils {
-
- private static final int[] APPCOMPAT_COLOR_PRIMARY_ATTRS = {
- androidx.appcompat.R.attr.colorPrimary
- };
- private static final int[] APPCOMPAT_COLOR_PRIMARY_DARK_ATTRS = {
- androidx.appcompat.R.attr.colorPrimaryDark
- };
- private static final int[] APPCOMPAT_COLOR_ACCENT_ATTRS = {
- androidx.appcompat.R.attr.colorAccent
- };
-
- public static int getColorPrimaryResId(Context context) {
- return getResId(context, APPCOMPAT_COLOR_PRIMARY_ATTRS);
- }
-
- public static int getColorPrimaryDarkResId(Context context) {
- return getResId(context, APPCOMPAT_COLOR_PRIMARY_DARK_ATTRS);
- }
-
- public static int getColorAccentResId(Context context) {
- return getResId(context, APPCOMPAT_COLOR_ACCENT_ATTRS);
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatVectorResources.java b/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatVectorResources.java
deleted file mode 100755
index 08a8b8eefc..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/content/res/SkinCompatVectorResources.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package skin.support.content.res;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-import androidx.appcompat.app.AppCompatDelegate;
-import androidx.appcompat.content.res.AppCompatResources;
-
-public class SkinCompatVectorResources implements SkinResources {
- private static SkinCompatVectorResources sInstance;
-
- private SkinCompatVectorResources() {
- SkinCompatResources.getInstance().addSkinResources(this);
- }
-
- public static SkinCompatVectorResources getInstance() {
- if (sInstance == null) {
- synchronized (SkinCompatVectorResources.class) {
- if (sInstance == null) {
- sInstance = new SkinCompatVectorResources();
- }
- }
- }
- return sInstance;
- }
-
- @Override
- public void clear() {
- SkinCompatDrawableManager.get().clearCaches();
- }
-
- private Drawable getSkinDrawableCompat(Context context, int resId) {
- if (AppCompatDelegate.isCompatVectorFromResourcesEnabled()) {
- if (!SkinCompatResources.getInstance().isDefaultSkin()) {
- try {
- return SkinCompatDrawableManager.get().getDrawable(context, resId);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- // SkinCompatDrawableManager.get().getDrawable(context, resId) 中会调用getSkinDrawable等方法。
- // 这里只需要拦截使用默认皮肤的情况。
- if (!SkinCompatUserThemeManager.get().isColorEmpty()) {
- ColorStateList colorStateList = SkinCompatUserThemeManager.get().getColorStateList(resId);
- if (colorStateList != null) {
- return new ColorDrawable(colorStateList.getDefaultColor());
- }
- }
- if (!SkinCompatUserThemeManager.get().isDrawableEmpty()) {
- Drawable drawable = SkinCompatUserThemeManager.get().getDrawable(resId);
- if (drawable != null) {
- return drawable;
- }
- }
- Drawable drawable = SkinCompatResources.getInstance().getStrategyDrawable(context, resId);
- if (drawable != null) {
- return drawable;
- }
- return AppCompatResources.getDrawable(context, resId);
- } else {
- if (!SkinCompatUserThemeManager.get().isColorEmpty()) {
- ColorStateList colorStateList = SkinCompatUserThemeManager.get().getColorStateList(resId);
- if (colorStateList != null) {
- return new ColorDrawable(colorStateList.getDefaultColor());
- }
- }
- if (!SkinCompatUserThemeManager.get().isDrawableEmpty()) {
- Drawable drawable = SkinCompatUserThemeManager.get().getDrawable(resId);
- if (drawable != null) {
- return drawable;
- }
- }
- Drawable drawable = SkinCompatResources.getInstance().getStrategyDrawable(context, resId);
- if (drawable != null) {
- return drawable;
- }
- if (!SkinCompatResources.getInstance().isDefaultSkin()) {
- int targetResId = SkinCompatResources.getInstance().getTargetResId(context, resId);
- if (targetResId != 0) {
- return SkinCompatResources.getInstance().getSkinResources().getDrawable(targetResId);
- }
- }
- return AppCompatResources.getDrawable(context, resId);
- }
- }
-
- public static Drawable getDrawableCompat(Context context, int resId) {
- return getInstance().getSkinDrawableCompat(context, resId);
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java
deleted file mode 100755
index 7dc3a9db2b..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatAutoCompleteTextView.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatAutoCompleteTextView;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatVectorResources;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 2017/1/13.
- */
-
-public class SkinCompatAutoCompleteTextView extends AppCompatAutoCompleteTextView implements SkinCompatSupportable {
- private static final int[] TINT_ATTRS = {
- android.R.attr.popupBackground
- };
- private int mDropDownBackgroundResId = INVALID_ID;
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatAutoCompleteTextView(Context context) {
- this(context, null);
- }
-
- public SkinCompatAutoCompleteTextView(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.autoCompleteTextViewStyle);
- }
-
- public SkinCompatAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- TypedArray a = context.obtainStyledAttributes(attrs, TINT_ATTRS, defStyleAttr, 0);
- if (a.hasValue(0)) {
- mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID);
- }
- a.recycle();
- applyDropDownBackgroundResource();
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setDropDownBackgroundResource(@DrawableRes int resId) {
- super.setDropDownBackgroundResource(resId);
- mDropDownBackgroundResId = resId;
- applyDropDownBackgroundResource();
- }
-
- private void applyDropDownBackgroundResource() {
- mDropDownBackgroundResId = SkinCompatHelper.checkResourceId(mDropDownBackgroundResId);
- if (mDropDownBackgroundResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(getContext(), mDropDownBackgroundResId);
- if (drawable != null) {
- setDropDownBackgroundDrawable(drawable);
- }
- }
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- applyDropDownBackgroundResource();
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatBackgroundHelper.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatBackgroundHelper.java
deleted file mode 100755
index d42176edc3..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatBackgroundHelper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package skin.support.widget;
-
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import androidx.core.view.ViewCompat;
-import android.util.AttributeSet;
-import android.view.View;
-
-import skin.support.R;
-import skin.support.content.res.SkinCompatVectorResources;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinCompatBackgroundHelper extends SkinCompatHelper {
- private final View mView;
-
- private int mBackgroundResId = INVALID_ID;
-
- public SkinCompatBackgroundHelper(View view) {
- mView = view;
- }
-
- public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
- TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.SkinBackgroundHelper, defStyleAttr, 0);
- try {
- if (a.hasValue(R.styleable.SkinBackgroundHelper_android_background)) {
- mBackgroundResId = a.getResourceId(
- R.styleable.SkinBackgroundHelper_android_background, INVALID_ID);
- }
- } finally {
- a.recycle();
- }
- applySkin();
- }
-
- public void onSetBackgroundResource(int resId) {
- mBackgroundResId = resId;
- // Update the default background tint
- applySkin();
- }
-
- @Override
- public void applySkin() {
- mBackgroundResId = checkResourceId(mBackgroundResId);
- if (mBackgroundResId == INVALID_ID) {
- return;
- }
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mBackgroundResId);
- if (drawable != null) {
- int paddingLeft = mView.getPaddingLeft();
- int paddingTop = mView.getPaddingTop();
- int paddingRight = mView.getPaddingRight();
- int paddingBottom = mView.getPaddingBottom();
- ViewCompat.setBackground(mView, drawable);
- mView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatButton.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatButton.java
deleted file mode 100755
index ad369949ed..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatButton.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.R;
-import androidx.appcompat.widget.AppCompatButton;
-import android.util.AttributeSet;
-
-/**
- * Created by ximsfei on 17-1-11.
- */
-public class SkinCompatButton extends AppCompatButton implements SkinCompatSupportable {
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatButton(Context context) {
- this(context, null);
- }
-
- public SkinCompatButton(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.buttonStyle);
- }
-
- public SkinCompatButton(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCheckBox.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCheckBox.java
deleted file mode 100755
index 4598485900..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCheckBox.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatCheckBox;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-
-/**
- * Created by ximsfei on 17-1-14.
- */
-
-public class SkinCompatCheckBox extends AppCompatCheckBox implements SkinCompatSupportable {
- private SkinCompatCompoundButtonHelper mCompoundButtonHelper;
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatCheckBox(Context context) {
- this(context, null);
- }
-
- public SkinCompatCheckBox(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.checkboxStyle);
- }
-
- public SkinCompatCheckBox(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mCompoundButtonHelper = new SkinCompatCompoundButtonHelper(this);
- mCompoundButtonHelper.loadFromAttributes(attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setButtonDrawable(@DrawableRes int resId) {
- super.setButtonDrawable(resId);
- if (mCompoundButtonHelper != null) {
- mCompoundButtonHelper.setButtonDrawable(resId);
- }
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mCompoundButtonHelper != null) {
- mCompoundButtonHelper.applySkin();
- }
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCheckedTextView.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCheckedTextView.java
deleted file mode 100755
index 48a9ad0f95..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCheckedTextView.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatCheckedTextView;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatVectorResources;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 17-1-14.
- */
-
-public class SkinCompatCheckedTextView extends AppCompatCheckedTextView implements SkinCompatSupportable {
-
- private static final int[] TINT_ATTRS = {
- android.R.attr.checkMark
- };
- private int mCheckMarkResId = INVALID_ID;
-
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatCheckedTextView(Context context) {
- this(context, null);
- }
-
- public SkinCompatCheckedTextView(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.checkedTextViewStyle);
- }
-
- public SkinCompatCheckedTextView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
-
- TypedArray a = context.obtainStyledAttributes(attrs, TINT_ATTRS, defStyleAttr, 0);
- mCheckMarkResId = a.getResourceId(0, INVALID_ID);
- a.recycle();
- applyCheckMark();
- }
-
- @Override
- public void setCheckMarkDrawable(@DrawableRes int resId) {
- mCheckMarkResId = resId;
- applyCheckMark();
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- applyCheckMark();
- }
-
- private void applyCheckMark() {
- mCheckMarkResId = SkinCompatHelper.checkResourceId(mCheckMarkResId);
- if (mCheckMarkResId != INVALID_ID) {
- setCheckMarkDrawable(SkinCompatVectorResources.getDrawableCompat(getContext(), mCheckMarkResId));
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCompoundButtonHelper.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCompoundButtonHelper.java
deleted file mode 100755
index 94c1671e03..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatCompoundButtonHelper.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package skin.support.widget;
-
-import android.content.res.TypedArray;
-import androidx.core.widget.CompoundButtonCompat;
-import android.util.AttributeSet;
-import android.widget.CompoundButton;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatVectorResources;
-
-/**
- * Created by ximsfei on 17-1-14.
- */
-public class SkinCompatCompoundButtonHelper extends SkinCompatHelper {
- private final CompoundButton mView;
- private int mButtonResourceId = INVALID_ID;
- private int mButtonTintResId = INVALID_ID;
-
- public SkinCompatCompoundButtonHelper(CompoundButton view) {
- mView = view;
- }
-
- void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
- TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.CompoundButton,
- defStyleAttr, INVALID_ID);
- try {
- if (a.hasValue(R.styleable.CompoundButton_android_button)) {
- mButtonResourceId = a.getResourceId(
- R.styleable.CompoundButton_android_button, INVALID_ID);
- }
-
- if (a.hasValue(R.styleable.CompoundButton_buttonTint)) {
- mButtonTintResId = a.getResourceId(R.styleable.CompoundButton_buttonTint, INVALID_ID);
- }
- } finally {
- a.recycle();
- }
- applySkin();
- }
-
- public void setButtonDrawable(int resId) {
- mButtonResourceId = resId;
- applySkin();
- }
-
- @Override
- public void applySkin() {
- mButtonResourceId = SkinCompatHelper.checkResourceId(mButtonResourceId);
- if (mButtonResourceId != INVALID_ID) {
- mView.setButtonDrawable(SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mButtonResourceId));
- }
- mButtonTintResId = SkinCompatHelper.checkResourceId(mButtonTintResId);
- if (mButtonTintResId != INVALID_ID) {
- CompoundButtonCompat.setButtonTintList(mView, SkinCompatResources.getColorStateList(mView.getContext(), mButtonTintResId));
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatEditText.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatEditText.java
deleted file mode 100755
index f6c4418b06..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatEditText.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.R;
-import androidx.appcompat.widget.AppCompatEditText;
-import android.util.AttributeSet;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinCompatEditText extends AppCompatEditText implements SkinCompatSupportable {
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatEditText(Context context) {
- this(context, null);
- }
-
- public SkinCompatEditText(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.editTextStyle);
- }
-
- public SkinCompatEditText(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- public int getTextColorResId() {
- return mTextHelper != null ? mTextHelper.getTextColorResId() : INVALID_ID;
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatFrameLayout.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatFrameLayout.java
deleted file mode 100755
index a0904d5ba4..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatFrameLayout.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.FrameLayout;
-
-/**
- * Created by pengfengwang on 2017/1/13.
- */
-
-public class SkinCompatFrameLayout extends FrameLayout implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatFrameLayout(Context context) {
- this(context, null);
- }
-
- public SkinCompatFrameLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageButton.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageButton.java
deleted file mode 100755
index 275d3ab9d1..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageButton.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.R;
-import androidx.appcompat.widget.AppCompatImageButton;
-import android.util.AttributeSet;
-
-/**
- * Created by ximsfei on 17-1-13.
- */
-
-public class SkinCompatImageButton extends AppCompatImageButton implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
- private SkinCompatImageHelper mImageHelper;
-
- public SkinCompatImageButton(Context context) {
- this(context, null);
- }
-
- public SkinCompatImageButton(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.imageButtonStyle);
- }
-
- public SkinCompatImageButton(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
-
- mImageHelper = new SkinCompatImageHelper(this);
- mImageHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setImageResource(@DrawableRes int resId) {
- // Intercept this call and instead retrieve the Drawable via the image helper
- if (mImageHelper != null) {
- mImageHelper.setImageResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mImageHelper != null) {
- mImageHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageHelper.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageHelper.java
deleted file mode 100755
index 8fcc0a8782..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageHelper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package skin.support.widget;
-
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.util.AttributeSet;
-import android.widget.ImageView;
-
-import androidx.core.widget.ImageViewCompat;
-
-import skin.support.R;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatVectorResources;
-
-/**
- * Created by ximsfei on 2017/1/12.
- */
-public class SkinCompatImageHelper extends SkinCompatHelper {
- private static final String TAG = SkinCompatImageHelper.class.getSimpleName();
- private final ImageView mView;
- private int mSrcResId = INVALID_ID;
- private int mSrcCompatResId = INVALID_ID;
- private int mSrcTintResId = INVALID_ID;
-
- public SkinCompatImageHelper(ImageView imageView) {
- mView = imageView;
- }
-
- public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
- TypedArray a = null;
- try {
- a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.SkinCompatImageView, defStyleAttr, 0);
- mSrcResId = a.getResourceId(R.styleable.SkinCompatImageView_android_src, INVALID_ID);
- mSrcCompatResId = a.getResourceId(R.styleable.SkinCompatImageView_srcCompat, INVALID_ID);
- mSrcTintResId = a.getResourceId(R.styleable.SkinCompatImageView_tint, INVALID_ID);
- if (mSrcTintResId == INVALID_ID) {
- mSrcTintResId = a.getResourceId(R.styleable.SkinCompatImageView_android_tint, INVALID_ID);
- }
- } finally {
- if (a != null) {
- a.recycle();
- }
- }
- applySkin();
- }
-
- public void setImageResource(int resId) {
- mSrcResId = resId;
- mSrcCompatResId = INVALID_ID;
- applySkin();
- }
-
- @Override
- public void applySkin() {
- mSrcCompatResId = checkResourceId(mSrcCompatResId);
- if (mSrcCompatResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mSrcCompatResId);
- if (drawable != null) {
- mView.setImageDrawable(drawable);
- }
- } else {
- mSrcResId = checkResourceId(mSrcResId);
- if (mSrcResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mSrcResId);
- if (drawable != null) {
- mView.setImageDrawable(drawable);
- }
- }
- }
- mSrcTintResId = checkResourceId(mSrcTintResId);
- if (mSrcTintResId != INVALID_ID) {
- ColorStateList tintList = SkinCompatResources.getColorStateList(mView.getContext(), mSrcTintResId);
- ImageViewCompat.setImageTintList(mView, tintList);
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageView.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageView.java
deleted file mode 100755
index 3a63e5f969..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatImageView.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatImageView;
-import android.util.AttributeSet;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinCompatImageView extends AppCompatImageView implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
- private SkinCompatImageHelper mImageHelper;
-
- public SkinCompatImageView(Context context) {
- this(context, null);
- }
-
- public SkinCompatImageView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatImageView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
-
- mImageHelper = new SkinCompatImageHelper(this);
- mImageHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setImageResource(@DrawableRes int resId) {
- // Intercept this call and instead retrieve the Drawable via the image helper
- if (mImageHelper != null) {
- mImageHelper.setImageResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mImageHelper != null) {
- mImageHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatLinearLayout.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatLinearLayout.java
deleted file mode 100755
index e920550592..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatLinearLayout.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-
-/**
- * Created by pengfengwang on 2017/1/13.
- */
-
-public class SkinCompatLinearLayout extends LinearLayout implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatLinearLayout(Context context) {
- this(context, null);
- }
-
- public SkinCompatLinearLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatMultiAutoCompleteTextView.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatMultiAutoCompleteTextView.java
deleted file mode 100755
index 7fdcc75fb6..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatMultiAutoCompleteTextView.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatMultiAutoCompleteTextView;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatVectorResources;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * @author ximsfei
- * @date 17-1-14
- */
-
-public class SkinCompatMultiAutoCompleteTextView extends AppCompatMultiAutoCompleteTextView implements SkinCompatSupportable {
- private static final int[] TINT_ATTRS = {
- android.R.attr.popupBackground
- };
- private int mDropDownBackgroundResId = INVALID_ID;
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatMultiAutoCompleteTextView(Context context) {
- this(context, null);
- }
-
- public SkinCompatMultiAutoCompleteTextView(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.editTextStyle);
- }
-
- public SkinCompatMultiAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- TypedArray a = context.obtainStyledAttributes(attrs, TINT_ATTRS, defStyleAttr, 0);
- if (a.hasValue(0)) {
- mDropDownBackgroundResId = a.getResourceId(0, INVALID_ID);
- }
- a.recycle();
- applyDropDownBackgroundResource();
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setDropDownBackgroundResource(@DrawableRes int resId) {
- super.setDropDownBackgroundResource(resId);
- mDropDownBackgroundResId = resId;
- applyDropDownBackgroundResource();
- }
-
- private void applyDropDownBackgroundResource() {
- mDropDownBackgroundResId = SkinCompatHelper.checkResourceId(mDropDownBackgroundResId);
- if (mDropDownBackgroundResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(getContext(), mDropDownBackgroundResId);
- if (drawable != null) {
- setDropDownBackgroundDrawable(drawable);
- }
- }
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- applyDropDownBackgroundResource();
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatProgressBar.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatProgressBar.java
deleted file mode 100755
index aca7038a7b..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatProgressBar.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.ProgressBar;
-
-/**
- * Created by ximsfei on 2017/1/19.
- */
-
-public class SkinCompatProgressBar extends ProgressBar implements SkinCompatSupportable {
- private SkinCompatProgressBarHelper mSkinCompatProgressBarHelper;
-
- public SkinCompatProgressBar(Context context) {
- this(context, null);
- }
-
- public SkinCompatProgressBar(Context context, AttributeSet attrs) {
- this(context, attrs, android.R.attr.progressBarStyle);
- }
-
- public SkinCompatProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mSkinCompatProgressBarHelper = new SkinCompatProgressBarHelper(this);
- mSkinCompatProgressBarHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void applySkin() {
- if (mSkinCompatProgressBarHelper != null) {
- mSkinCompatProgressBarHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatProgressBarHelper.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatProgressBarHelper.java
deleted file mode 100755
index 2956c649e2..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatProgressBarHelper.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package skin.support.widget;
-
-import android.content.res.TypedArray;
-import android.graphics.Bitmap;
-import android.graphics.BitmapShader;
-import android.graphics.Shader;
-import android.graphics.drawable.AnimationDrawable;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.ClipDrawable;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
-import android.graphics.drawable.ShapeDrawable;
-import android.graphics.drawable.shapes.RoundRectShape;
-import android.graphics.drawable.shapes.Shape;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.widget.ProgressBar;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatVectorResources;
-import skin.support.utils.SkinCompatVersionUtils;
-
-/**
- * Created by ximsfei on 2017/1/20.
- */
-
-public class SkinCompatProgressBarHelper extends SkinCompatHelper {
-
- private final ProgressBar mView;
-
- private Bitmap mSampleTile;
- private int mIndeterminateDrawableResId = INVALID_ID;
- private int mProgressDrawableResId = INVALID_ID;
- private int mIndeterminateTintResId = INVALID_ID;
-
- SkinCompatProgressBarHelper(ProgressBar view) {
- mView = view;
- }
-
- void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
- TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.SkinCompatProgressBar, defStyleAttr, 0);
-
- mIndeterminateDrawableResId = a.getResourceId(R.styleable.SkinCompatProgressBar_android_indeterminateDrawable, INVALID_ID);
- mProgressDrawableResId = a.getResourceId(R.styleable.SkinCompatProgressBar_android_progressDrawable, INVALID_ID);
-
- a.recycle();
- if (Build.VERSION.SDK_INT > 21) {
- a = mView.getContext().obtainStyledAttributes(attrs, new int[]{android.R.attr.indeterminateTint}, defStyleAttr, 0);
- mIndeterminateTintResId = a.getResourceId(0, INVALID_ID);
- a.recycle();
- }
- applySkin();
- }
-
- /**
- * Converts a drawable to a tiled version of itself. It will recursively
- * traverse layer and state list drawables.
- */
- private Drawable tileify(Drawable drawable, boolean clip) {
- if (SkinCompatVersionUtils.isV4WrappedDrawable(drawable)) {
- Drawable inner = SkinCompatVersionUtils.getV4WrappedDrawableWrappedDrawable(drawable);
- if (inner != null) {
- inner = tileify(inner, clip);
- SkinCompatVersionUtils.setV4WrappedDrawableWrappedDrawable(drawable, inner);
- }
- } else if (SkinCompatVersionUtils.isV4DrawableWrapper(drawable)) {
- Drawable inner = SkinCompatVersionUtils.getV4DrawableWrapperWrappedDrawable(drawable);
- if (inner != null) {
- inner = tileify(inner, clip);
- SkinCompatVersionUtils.setV4DrawableWrapperWrappedDrawable(drawable, inner);
- }
- } else if (drawable instanceof LayerDrawable) {
- LayerDrawable background = (LayerDrawable) drawable;
- final int N = background.getNumberOfLayers();
- Drawable[] outDrawables = new Drawable[N];
-
- for (int i = 0; i < N; i++) {
- int id = background.getId(i);
- outDrawables[i] = tileify(background.getDrawable(i),
- (id == android.R.id.progress || id == android.R.id.secondaryProgress));
- }
- LayerDrawable newBg = new LayerDrawable(outDrawables);
-
- for (int i = 0; i < N; i++) {
- newBg.setId(i, background.getId(i));
- }
-
- return newBg;
-
- } else if (drawable instanceof BitmapDrawable) {
- final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
- final Bitmap tileBitmap = bitmapDrawable.getBitmap();
- if (mSampleTile == null) {
- mSampleTile = tileBitmap;
- }
-
- final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
- final BitmapShader bitmapShader = new BitmapShader(tileBitmap,
- Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
- shapeDrawable.getPaint().setShader(bitmapShader);
- shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter());
- return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT,
- ClipDrawable.HORIZONTAL) : shapeDrawable;
- }
-
- return drawable;
- }
-
- /**
- * Convert a AnimationDrawable for use as a barberpole animation.
- * Each frame of the animation is wrapped in a ClipDrawable and
- * given a tiling BitmapShader.
- */
- private Drawable tileifyIndeterminate(Drawable drawable) {
- if (drawable instanceof AnimationDrawable) {
- AnimationDrawable background = (AnimationDrawable) drawable;
- final int N = background.getNumberOfFrames();
- AnimationDrawable newBg = new AnimationDrawable();
- newBg.setOneShot(background.isOneShot());
-
- for (int i = 0; i < N; i++) {
- Drawable frame = tileify(background.getFrame(i), true);
- frame.setLevel(10000);
- newBg.addFrame(frame, background.getDuration(i));
- }
- newBg.setLevel(10000);
- drawable = newBg;
- }
- return drawable;
- }
-
- private Shape getDrawableShape() {
- final float[] roundedCorners = new float[]{5, 5, 5, 5, 5, 5, 5, 5};
- return new RoundRectShape(roundedCorners, null, null);
- }
-
- @Override
- public void applySkin() {
- mIndeterminateDrawableResId = checkResourceId(mIndeterminateDrawableResId);
- if (mIndeterminateDrawableResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mIndeterminateDrawableResId);
- drawable.setBounds(mView.getIndeterminateDrawable().getBounds());
- mView.setIndeterminateDrawable(tileifyIndeterminate(drawable));
- }
-
- mProgressDrawableResId = checkProgressDrawableResId(mProgressDrawableResId);
- if (mProgressDrawableResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mProgressDrawableResId);
- mView.setProgressDrawable(tileify(drawable, false));
- }
- if (Build.VERSION.SDK_INT > 21) {
- mIndeterminateTintResId = checkResourceId(mIndeterminateTintResId);
- if (mIndeterminateTintResId != INVALID_ID) {
- mView.setIndeterminateTintList(SkinCompatResources.getColorStateList(mView.getContext(), mIndeterminateTintResId));
- }
- }
- }
-
- private int checkProgressDrawableResId(int mProgressDrawableResId) {
- return checkResourceId(mProgressDrawableResId);
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRadioButton.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRadioButton.java
deleted file mode 100755
index 0f33a117db..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRadioButton.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatRadioButton;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-
-/**
- * Created by ximsfei on 17-1-14.
- */
-
-public class SkinCompatRadioButton extends AppCompatRadioButton implements SkinCompatSupportable {
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatCompoundButtonHelper mCompoundButtonHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatRadioButton(Context context) {
- this(context, null);
- }
-
- public SkinCompatRadioButton(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.radioButtonStyle);
- }
-
- public SkinCompatRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mCompoundButtonHelper = new SkinCompatCompoundButtonHelper(this);
- mCompoundButtonHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setButtonDrawable(@DrawableRes int resId) {
- super.setButtonDrawable(resId);
- if (mCompoundButtonHelper != null) {
- mCompoundButtonHelper.setButtonDrawable(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mCompoundButtonHelper != null) {
- mCompoundButtonHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRadioGroup.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRadioGroup.java
deleted file mode 100755
index 90771bbead..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRadioGroup.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.RadioGroup;
-
-/**
- * Created by ximsf on 2017/3/23.
- */
-
-public class SkinCompatRadioGroup extends RadioGroup implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
- public SkinCompatRadioGroup(Context context) {
- this(context, null);
- }
-
- public SkinCompatRadioGroup(Context context, AttributeSet attrs) {
- super(context, attrs);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, 0);
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRatingBar.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRatingBar.java
deleted file mode 100755
index 88664330ad..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRatingBar.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.appcompat.widget.AppCompatRatingBar;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-
-/**
- * Created by ximsfei on 17-1-21.
- */
-
-public class SkinCompatRatingBar extends AppCompatRatingBar implements SkinCompatSupportable {
- private SkinCompatProgressBarHelper mSkinCompatProgressBarHelper;
-
- public SkinCompatRatingBar(Context context) {
- this(context, null);
- }
-
- public SkinCompatRatingBar(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.ratingBarStyle);
- }
-
- public SkinCompatRatingBar(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mSkinCompatProgressBarHelper = new SkinCompatProgressBarHelper(this);
- mSkinCompatProgressBarHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void applySkin() {
- if (mSkinCompatProgressBarHelper != null) {
- mSkinCompatProgressBarHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRelativeLayout.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRelativeLayout.java
deleted file mode 100755
index d2e2c47ba1..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatRelativeLayout.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.RelativeLayout;
-
-/**
- * Created by pengfengwang on 2017/1/13.
- */
-
-public class SkinCompatRelativeLayout extends RelativeLayout implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatRelativeLayout(Context context) {
- this(context, null);
- }
-
- public SkinCompatRelativeLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatScrollView.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatScrollView.java
deleted file mode 100755
index 0df419a060..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatScrollView.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import android.util.AttributeSet;
-import android.widget.ScrollView;
-
-/**
- * Created by Jungle68 on 2017/6/27.
- */
-public class SkinCompatScrollView extends ScrollView implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatScrollView(Context context) {
- this(context, null);
- }
-
- public SkinCompatScrollView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSeekBar.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSeekBar.java
deleted file mode 100755
index a6f488e3ea..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSeekBar.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.appcompat.widget.AppCompatSeekBar;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-
-/**
- * Created by ximsfei on 17-1-21.
- */
-
-public class SkinCompatSeekBar extends AppCompatSeekBar implements SkinCompatSupportable {
- private SkinCompatSeekBarHelper mSkinCompatSeekBarHelper;
-
- public SkinCompatSeekBar(Context context) {
- this(context, null);
- }
-
- public SkinCompatSeekBar(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.seekBarStyle);
- }
-
- public SkinCompatSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mSkinCompatSeekBarHelper = new SkinCompatSeekBarHelper(this);
- mSkinCompatSeekBarHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
-
- @Override
- public void applySkin() {
- if (mSkinCompatSeekBarHelper != null) {
- mSkinCompatSeekBarHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSeekBarHelper.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSeekBarHelper.java
deleted file mode 100755
index 88673a1353..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSeekBarHelper.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package skin.support.widget;
-
-import android.content.res.TypedArray;
-import android.util.AttributeSet;
-import android.widget.SeekBar;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatVectorResources;
-
-/**
- * Created by ximsfei on 17-1-21.
- */
-public class SkinCompatSeekBarHelper extends SkinCompatProgressBarHelper {
- private final SeekBar mView;
-
- private int mThumbResId = INVALID_ID;
-
- public SkinCompatSeekBarHelper(SeekBar view) {
- super(view);
- mView = view;
- }
-
- @Override
- void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
- super.loadFromAttributes(attrs, defStyleAttr);
-
- TypedArray a = mView.getContext().obtainStyledAttributes(attrs, R.styleable.AppCompatSeekBar, defStyleAttr, 0);
- mThumbResId = a.getResourceId(R.styleable.AppCompatSeekBar_android_thumb, INVALID_ID);
- a.recycle();
-
- applySkin();
- }
-
- @Override
- public void applySkin() {
- super.applySkin();
- mThumbResId = checkResourceId(mThumbResId);
- if (mThumbResId != INVALID_ID) {
- mView.setThumb(SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mThumbResId));
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSpinner.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSpinner.java
deleted file mode 100755
index 78e16dd6cd..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatSpinner.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.content.res.TypedArray;
-import android.os.Build;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatSpinner;
-import android.util.AttributeSet;
-import android.util.Log;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatVectorResources;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-import static skin.support.widget.SkinCompatHelper.checkResourceId;
-
-/**
- * Created by ximsfei on 17-1-21.
- */
-
-public class SkinCompatSpinner extends AppCompatSpinner implements SkinCompatSupportable {
- private static final String TAG = SkinCompatSpinner.class.getSimpleName();
-
- private static final int[] ATTRS_ANDROID_SPINNERMODE = {android.R.attr.spinnerMode};
-
- private static final int MODE_DIALOG = 0;
- private static final int MODE_DROPDOWN = 1;
- private static final int MODE_THEME = -1;
-
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
- private int mPopupBackgroundResId = INVALID_ID;
-
- public SkinCompatSpinner(Context context) {
- this(context, null);
- }
-
- public SkinCompatSpinner(Context context, int mode) {
- this(context, null, R.attr.spinnerStyle, mode);
- }
-
- public SkinCompatSpinner(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.spinnerStyle);
- }
-
- public SkinCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
- this(context, attrs, defStyleAttr, MODE_THEME);
- }
-
- public SkinCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode) {
- this(context, attrs, defStyleAttr, mode, null);
- }
-
- public SkinCompatSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode, Resources.Theme popupTheme) {
- super(context, attrs, defStyleAttr, mode, popupTheme);
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Spinner, defStyleAttr, 0);
-
- if (getPopupContext() != null) {
- if (mode == MODE_THEME) {
- if (Build.VERSION.SDK_INT >= 11) {
- // If we're running on API v11+ we will try and read android:spinnerMode
- TypedArray aa = null;
- try {
- aa = context.obtainStyledAttributes(attrs, ATTRS_ANDROID_SPINNERMODE,
- defStyleAttr, 0);
- if (aa.hasValue(0)) {
- mode = aa.getInt(0, MODE_DIALOG);
- }
- } catch (Exception e) {
- Log.i(TAG, "Could not read android:spinnerMode", e);
- } finally {
- if (aa != null) {
- aa.recycle();
- }
- }
- } else {
- // Else, we use a default mode of dropdown
- mode = MODE_DROPDOWN;
- }
- }
-
- if (mode == MODE_DROPDOWN) {
- final TypedArray pa = getPopupContext().obtainStyledAttributes(attrs, R.styleable.Spinner, defStyleAttr, 0);
- mPopupBackgroundResId = pa.getResourceId(R.styleable.Spinner_android_popupBackground, INVALID_ID);
- pa.recycle();
- }
- }
- a.recycle();
-
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setPopupBackgroundResource(@DrawableRes int resId) {
- super.setPopupBackgroundResource(resId);
- mPopupBackgroundResId = resId;
- applyPopupBackground();
- }
-
- private void applyPopupBackground() {
- mPopupBackgroundResId = checkResourceId(mPopupBackgroundResId);
- if (mPopupBackgroundResId != INVALID_ID) {
- setPopupBackgroundDrawable(SkinCompatVectorResources.getDrawableCompat(getContext(), mPopupBackgroundResId));
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- applyPopupBackground();
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextHelper.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextHelper.java
deleted file mode 100755
index 9422846df9..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextHelper.java
+++ /dev/null
@@ -1,186 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import androidx.annotation.DrawableRes;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import skin.support.R;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatVectorResources;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinCompatTextHelper extends SkinCompatHelper {
- private static final String TAG = SkinCompatTextHelper.class.getSimpleName();
-
- public static SkinCompatTextHelper create(TextView textView) {
- if (Build.VERSION.SDK_INT >= 17) {
- return new SkinCompatTextHelperV17(textView);
- }
- return new SkinCompatTextHelper(textView);
- }
-
- final TextView mView;
-
- private int mTextColorResId = INVALID_ID;
- private int mTextColorHintResId = INVALID_ID;
- protected int mDrawableBottomResId = INVALID_ID;
- protected int mDrawableLeftResId = INVALID_ID;
- protected int mDrawableRightResId = INVALID_ID;
- protected int mDrawableTopResId = INVALID_ID;
-
- public SkinCompatTextHelper(TextView view) {
- mView = view;
- }
-
- public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
- final Context context = mView.getContext();
-
- // First read the TextAppearance style id
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SkinCompatTextHelper, defStyleAttr, 0);
- final int ap = a.getResourceId(R.styleable.SkinCompatTextHelper_android_textAppearance, INVALID_ID);
-
- if (a.hasValue(R.styleable.SkinCompatTextHelper_android_drawableLeft)) {
- mDrawableLeftResId = a.getResourceId(R.styleable.SkinCompatTextHelper_android_drawableLeft, INVALID_ID);
- }
- if (a.hasValue(R.styleable.SkinCompatTextHelper_android_drawableTop)) {
- mDrawableTopResId = a.getResourceId(R.styleable.SkinCompatTextHelper_android_drawableTop, INVALID_ID);
- }
- if (a.hasValue(R.styleable.SkinCompatTextHelper_android_drawableRight)) {
- mDrawableRightResId = a.getResourceId(R.styleable.SkinCompatTextHelper_android_drawableRight, INVALID_ID);
- }
- if (a.hasValue(R.styleable.SkinCompatTextHelper_android_drawableBottom)) {
- mDrawableBottomResId = a.getResourceId(R.styleable.SkinCompatTextHelper_android_drawableBottom, INVALID_ID);
- }
- a.recycle();
-
- if (ap != INVALID_ID) {
- a = context.obtainStyledAttributes(ap, R.styleable.SkinTextAppearance);
- if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
- mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- }
- if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
- mTextColorHintResId = a.getResourceId(
- R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
- }
- a.recycle();
- }
-
- // Now read the style's values
- a = context.obtainStyledAttributes(attrs, R.styleable.SkinTextAppearance, defStyleAttr, 0);
- if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
- mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- }
- if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
- mTextColorHintResId = a.getResourceId(
- R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
- }
- a.recycle();
- applySkin();
- }
-
- public void onSetTextAppearance(Context context, int resId) {
- final TypedArray a = context.obtainStyledAttributes(resId, R.styleable.SkinTextAppearance);
- if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
- mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- }
- if (a.hasValue(R.styleable.SkinTextAppearance_android_textColorHint)) {
- mTextColorHintResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColorHint, INVALID_ID);
- }
- a.recycle();
- applyTextColorResource();
- applyTextColorHintResource();
- }
-
- private void applyTextColorHintResource() {
- mTextColorHintResId = checkResourceId(mTextColorHintResId);
- if (mTextColorHintResId != INVALID_ID) {
- // TODO: HTC_U-3u OS:8.0上调用framework的getColorStateList方法,有可能抛出异常,暂时没有找到更好的解决办法.
- // issue: https://github.com/ximsfei/Android-skin-support/issues/110
- try {
- ColorStateList color = SkinCompatResources.getColorStateList(mView.getContext(), mTextColorHintResId);
- mView.setHintTextColor(color);
- } catch (Exception e) {
- }
- }
- }
-
- private void applyTextColorResource() {
- mTextColorResId = checkResourceId(mTextColorResId);
- if (mTextColorResId != INVALID_ID) {
- // TODO: HTC_U-3u OS:8.0上调用framework的getColorStateList方法,有可能抛出异常,暂时没有找到更好的解决办法.
- // issue: https://github.com/ximsfei/Android-skin-support/issues/110
- try {
- ColorStateList color = SkinCompatResources.getColorStateList(mView.getContext(), mTextColorResId);
- mView.setTextColor(color);
- } catch (Exception e) {
- }
- }
- }
-
- public void onSetCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- mDrawableLeftResId = start;
- mDrawableTopResId = top;
- mDrawableRightResId = end;
- mDrawableBottomResId = bottom;
- applyCompoundDrawablesRelativeResource();
- }
-
- public void onSetCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- mDrawableLeftResId = left;
- mDrawableTopResId = top;
- mDrawableRightResId = right;
- mDrawableBottomResId = bottom;
- applyCompoundDrawablesResource();
- }
-
- protected void applyCompoundDrawablesRelativeResource() {
- applyCompoundDrawablesResource();
- }
-
- protected void applyCompoundDrawablesResource() {
- Drawable drawableLeft = null, drawableTop = null, drawableRight = null, drawableBottom = null;
- mDrawableLeftResId = checkResourceId(mDrawableLeftResId);
- if (mDrawableLeftResId != INVALID_ID) {
- drawableLeft = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableLeftResId);
- }
- mDrawableTopResId = checkResourceId(mDrawableTopResId);
- if (mDrawableTopResId != INVALID_ID) {
- drawableTop = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableTopResId);
- }
- mDrawableRightResId = checkResourceId(mDrawableRightResId);
- if (mDrawableRightResId != INVALID_ID) {
- drawableRight = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableRightResId);
- }
- mDrawableBottomResId = checkResourceId(mDrawableBottomResId);
- if (mDrawableBottomResId != INVALID_ID) {
- drawableBottom = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableBottomResId);
- }
- if (mDrawableLeftResId != INVALID_ID
- || mDrawableTopResId != INVALID_ID
- || mDrawableRightResId != INVALID_ID
- || mDrawableBottomResId != INVALID_ID) {
- mView.setCompoundDrawablesWithIntrinsicBounds(drawableLeft, drawableTop, drawableRight, drawableBottom);
- }
- }
-
- public int getTextColorResId() {
- return mTextColorResId;
- }
-
- @Override
- public void applySkin() {
- applyCompoundDrawablesRelativeResource();
- applyTextColorResource();
- applyTextColorHintResource();
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextHelperV17.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextHelperV17.java
deleted file mode 100755
index beb1a7fcb7..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextHelperV17.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package skin.support.widget;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.RequiresApi;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import skin.support.R;
-import skin.support.content.res.SkinCompatVectorResources;
-
-/**
- * Created by pengfengwang on 2017/3/8.
- */
-
-@RequiresApi(17)
-@TargetApi(17)
-public class SkinCompatTextHelperV17 extends SkinCompatTextHelper {
- private int mDrawableStartResId = INVALID_ID;
- private int mDrawableEndResId = INVALID_ID;
-
- public SkinCompatTextHelperV17(TextView view) {
- super(view);
- }
-
- @Override
- public void loadFromAttributes(AttributeSet attrs, int defStyleAttr) {
- final Context context = mView.getContext();
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SkinCompatTextHelper,
- defStyleAttr, 0);
- if (a.hasValue(R.styleable.SkinCompatTextHelper_android_drawableStart)) {
- mDrawableStartResId = a.getResourceId(R.styleable.SkinCompatTextHelper_android_drawableStart, INVALID_ID);
- mDrawableStartResId = SkinCompatHelper.checkResourceId(mDrawableStartResId);
- }
- if (a.hasValue(R.styleable.SkinCompatTextHelper_android_drawableEnd)) {
- mDrawableEndResId = a.getResourceId(R.styleable.SkinCompatTextHelper_android_drawableEnd, INVALID_ID);
- mDrawableEndResId = SkinCompatHelper.checkResourceId(mDrawableEndResId);
- }
- a.recycle();
- super.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void onSetCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- mDrawableStartResId = start;
- mDrawableTopResId = top;
- mDrawableEndResId = end;
- mDrawableBottomResId = bottom;
- applyCompoundDrawablesRelativeResource();
- }
-
- @Override
- protected void applyCompoundDrawablesRelativeResource() {
- Drawable drawableLeft = null, drawableTop = null, drawableRight = null, drawableBottom = null,
- drawableStart = null, drawableEnd = null;
- mDrawableLeftResId = checkResourceId(mDrawableLeftResId);
- if (mDrawableLeftResId != INVALID_ID) {
- drawableLeft = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableLeftResId);
- }
- mDrawableTopResId = checkResourceId(mDrawableTopResId);
- if (mDrawableTopResId != INVALID_ID) {
- drawableTop = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableTopResId);
- }
- mDrawableRightResId = checkResourceId(mDrawableRightResId);
- if (mDrawableRightResId != INVALID_ID) {
- drawableRight = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableRightResId);
- }
- mDrawableBottomResId = checkResourceId(mDrawableBottomResId);
- if (mDrawableBottomResId != INVALID_ID) {
- drawableBottom = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableBottomResId);
- }
- if (mDrawableStartResId != INVALID_ID) {
- drawableStart = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableStartResId);
- }
- if (drawableStart == null) {
- drawableStart = drawableLeft;
- }
- if (mDrawableEndResId != INVALID_ID) {
- drawableEnd = SkinCompatVectorResources.getDrawableCompat(mView.getContext(), mDrawableEndResId);
- }
- if (drawableEnd == null) {
- drawableEnd = drawableRight;
- }
- if (mDrawableLeftResId != INVALID_ID
- || mDrawableTopResId != INVALID_ID
- || mDrawableRightResId != INVALID_ID
- || mDrawableBottomResId != INVALID_ID
- || mDrawableStartResId != INVALID_ID
- || mDrawableEndResId != INVALID_ID) {
- mView.setCompoundDrawablesWithIntrinsicBounds(drawableStart, drawableTop, drawableEnd, drawableBottom);
- }
- }
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextView.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextView.java
deleted file mode 100755
index 696dae429e..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatTextView.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import androidx.appcompat.widget.AppCompatTextView;
-import android.util.AttributeSet;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinCompatTextView extends AppCompatTextView implements SkinCompatSupportable {
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatTextView(Context context) {
- this(context, null);
- }
-
- public SkinCompatTextView(Context context, AttributeSet attrs) {
- this(context, attrs, android.R.attr.textViewStyle);
- }
-
- public SkinCompatTextView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatToolbar.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatToolbar.java
deleted file mode 100755
index cc1348b2dd..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatToolbar.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
-import android.util.AttributeSet;
-
-import skin.support.appcompat.R;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatVectorResources;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 17-1-12.
- */
-
-public class SkinCompatToolbar extends Toolbar implements SkinCompatSupportable {
- private int mTitleTextColorResId = INVALID_ID;
- private int mSubtitleTextColorResId = INVALID_ID;
- private int mNavigationIconResId = INVALID_ID;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatToolbar(Context context) {
- this(context, null);
- }
-
- public SkinCompatToolbar(Context context, @Nullable AttributeSet attrs) {
- this(context, attrs, R.attr.toolbarStyle);
- }
-
- public SkinCompatToolbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Toolbar, defStyleAttr, 0);
- mNavigationIconResId = a.getResourceId(R.styleable.Toolbar_navigationIcon, INVALID_ID);
-
- int titleAp = a.getResourceId(R.styleable.Toolbar_titleTextAppearance, INVALID_ID);
- int subtitleAp = a.getResourceId(R.styleable.Toolbar_subtitleTextAppearance, INVALID_ID);
- a.recycle();
- if (titleAp != INVALID_ID) {
- a = context.obtainStyledAttributes(titleAp, R.styleable.SkinTextAppearance);
- mTitleTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- a.recycle();
- }
- if (subtitleAp != INVALID_ID) {
- a = context.obtainStyledAttributes(subtitleAp, R.styleable.SkinTextAppearance);
- mSubtitleTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- a.recycle();
- }
- a = context.obtainStyledAttributes(attrs, R.styleable.Toolbar, defStyleAttr, 0);
- if (a.hasValue(R.styleable.Toolbar_titleTextColor)) {
- mTitleTextColorResId = a.getResourceId(R.styleable.Toolbar_titleTextColor, INVALID_ID);
- }
- if (a.hasValue(R.styleable.Toolbar_subtitleTextColor)) {
- mSubtitleTextColorResId = a.getResourceId(R.styleable.Toolbar_subtitleTextColor, INVALID_ID);
- }
- a.recycle();
- applyTitleTextColor();
- applySubtitleTextColor();
- applyNavigationIcon();
- }
-
- private void applyTitleTextColor() {
- mTitleTextColorResId = SkinCompatHelper.checkResourceId(mTitleTextColorResId);
- if (mTitleTextColorResId != INVALID_ID) {
- setTitleTextColor(SkinCompatResources.getColor(getContext(), mTitleTextColorResId));
- }
- }
-
- private void applySubtitleTextColor() {
- mSubtitleTextColorResId = SkinCompatHelper.checkResourceId(mSubtitleTextColorResId);
- if (mSubtitleTextColorResId != INVALID_ID) {
- setSubtitleTextColor(SkinCompatResources.getColor(getContext(), mSubtitleTextColorResId));
- }
- }
-
- private void applyNavigationIcon() {
- mNavigationIconResId = SkinCompatHelper.checkResourceId(mNavigationIconResId);
- if (mNavigationIconResId != INVALID_ID) {
- setNavigationIcon(SkinCompatVectorResources.getDrawableCompat(getContext(), mNavigationIconResId));
- }
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setNavigationIcon(@DrawableRes int resId) {
- super.setNavigationIcon(resId);
- mNavigationIconResId = resId;
- applyNavigationIcon();
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- applyTitleTextColor();
- applySubtitleTextColor();
- applyNavigationIcon();
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatView.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatView.java
deleted file mode 100755
index 14f9f2a8ec..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatView.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-
-/**
- * Created by pengfengwang on 2017/1/13.
- */
-
-public class SkinCompatView extends View implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatView(Context context) {
- this(context, null);
- }
-
- public SkinCompatView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
-
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatViewGroup.java b/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatViewGroup.java
deleted file mode 100755
index 9404ad71cf..0000000000
--- a/skin/skin-support-appcompat/src/main/java/skin/support/widget/SkinCompatViewGroup.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.ViewGroup;
-
-public abstract class SkinCompatViewGroup extends ViewGroup implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatViewGroup(Context context) {
- this(context, null);
- }
-
- public SkinCompatViewGroup(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
-
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check.xml
deleted file mode 100755
index 8892df6656..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check_box.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check_box.xml
deleted file mode 100755
index 9948171c21..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check_box.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check_box_outline_blank.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check_box_outline_blank.xml
deleted file mode 100755
index cf8bfa24b5..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_check_box_outline_blank.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio.xml
deleted file mode 100755
index d71d47732d..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio_checked.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio_checked.xml
deleted file mode 100755
index 229a3560de..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio_checked.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio_unchecked.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio_unchecked.xml
deleted file mode 100755
index ec9f72c4c2..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/drawable/skin_btn_radio_unchecked.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog.xml
deleted file mode 100755
index 1422a82c89..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog_button_bar.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog_button_bar.xml
deleted file mode 100755
index 5ecc7e0ab2..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog_button_bar.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog_title.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog_title.xml
deleted file mode 100755
index 91ec04df44..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_alert_dialog_title.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog.xml
deleted file mode 100755
index 71aadbbc29..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_item.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_item.xml
deleted file mode 100755
index 09da6a73d8..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_item.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_multichoice.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_multichoice.xml
deleted file mode 100755
index 4ac4297603..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_multichoice.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_singlechoice.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_singlechoice.xml
deleted file mode 100755
index 9276b7ab74..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/layout/skin_select_dialog_singlechoice.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/values/attrs.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/values/attrs.xml
deleted file mode 100755
index ab895eec21..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/values/attrs.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/values/dimens.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/values/dimens.xml
deleted file mode 100755
index 37b21c616e..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/values/dimens.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- 18dp
- 8dp
- 8dp
- 8dp
- 20dp
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res-alertdialog/values/styles.xml b/skin/skin-support-appcompat/src/main/res-alertdialog/values/styles.xml
deleted file mode 100755
index 9589258c26..0000000000
--- a/skin/skin-support-appcompat/src/main/res-alertdialog/values/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support-appcompat/src/main/res/values/strings.xml b/skin/skin-support-appcompat/src/main/res/values/strings.xml
deleted file mode 100755
index 6a952b094f..0000000000
--- a/skin/skin-support-appcompat/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- skin-support-appcompat
-
diff --git a/skin/skin-support-cardview/.gitignore b/skin/skin-support-cardview/.gitignore
deleted file mode 100755
index 796b96d1c4..0000000000
--- a/skin/skin-support-cardview/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/skin/skin-support-cardview/build.gradle b/skin/skin-support-cardview/build.gradle
deleted file mode 100755
index 21a1dfef52..0000000000
--- a/skin/skin-support-cardview/build.gradle
+++ /dev/null
@@ -1,32 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion rootProject.ext.android.compileSdkVersion
- // buildToolsVersion rootProject.ext.android.buildToolsVersion
- defaultConfig {
- minSdkVersion rootProject.ext.android.minSdkVersion
- targetSdkVersion rootProject.ext.android.targetSdkVersion
- versionCode 1
- versionName "1.0"
-
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation rootProject.ext.dependencies.androidxcardview
-
- if( Boolean.valueOf(USE_MAVEN_PACKAGE) ){
- implementation rootProject.ext.dependencies.skinsupportbase
- } else {
- implementation project(":skin:skin-support")
- }
-}
-
-apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support-cardview/gradle.properties b/skin/skin-support-cardview/gradle.properties
deleted file mode 100644
index 752039f8a7..0000000000
--- a/skin/skin-support-cardview/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-GROUP=com.mogo.skin
-POM_ARTIFACT_ID=skin-support-cardview
-VERSION_CODE=1
diff --git a/skin/skin-support-cardview/proguard-rules.pro b/skin/skin-support-cardview/proguard-rules.pro
deleted file mode 100755
index bc6b4289e0..0000000000
--- a/skin/skin-support-cardview/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in C:\Users\ximsf\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/skin/skin-support-cardview/src/main/AndroidManifest.xml b/skin/skin-support-cardview/src/main/AndroidManifest.xml
deleted file mode 100755
index 7ca38156a6..0000000000
--- a/skin/skin-support-cardview/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
diff --git a/skin/skin-support-cardview/src/main/java/skin/support/SkinCardViewManager.java b/skin/skin-support-cardview/src/main/java/skin/support/SkinCardViewManager.java
deleted file mode 100755
index d367423ddf..0000000000
--- a/skin/skin-support-cardview/src/main/java/skin/support/SkinCardViewManager.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package skin.support;
-
-import android.content.Context;
-
-import skin.support.app.SkinCardViewInflater;
-
-/**
- * Created by ximsfei on 2017/3/5.
- */
-
-public class SkinCardViewManager {
- private static volatile SkinCardViewManager sInstance;
-
- public static SkinCardViewManager init(Context context) {
- if (sInstance == null) {
- synchronized (SkinCardViewManager.class) {
- if (sInstance == null) {
- sInstance = new SkinCardViewManager(context);
- }
- }
- }
- return sInstance;
- }
-
- public static SkinCardViewManager getInstance() {
- return sInstance;
- }
-
- private SkinCardViewManager(Context context) {
- SkinCompatManager.init(context).addInflater(new SkinCardViewInflater());
- }
-}
diff --git a/skin/skin-support-cardview/src/main/java/skin/support/app/SkinCardViewInflater.java b/skin/skin-support-cardview/src/main/java/skin/support/app/SkinCardViewInflater.java
deleted file mode 100755
index 215d172b32..0000000000
--- a/skin/skin-support-cardview/src/main/java/skin/support/app/SkinCardViewInflater.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package skin.support.app;
-
-import android.content.Context;
-import androidx.annotation.NonNull;
-import android.util.AttributeSet;
-import android.view.View;
-
-import skin.support.widget.SkinCompatCardView;
-
-/**
- * Created by ximsf on 2017/3/5.
- */
-
-public class SkinCardViewInflater implements SkinLayoutInflater {
- @Override
- public View createView(@NonNull Context context, final String name, @NonNull AttributeSet attrs) {
- View view = null;
- switch (name) {
- case "androidx.cardview.widget.CardView":
- view = new SkinCompatCardView(context, attrs);
- break;
- default:
- break;
- }
- return view;
- }
-}
diff --git a/skin/skin-support-cardview/src/main/java/skin/support/widget/SkinCompatCardView.java b/skin/skin-support-cardview/src/main/java/skin/support/widget/SkinCompatCardView.java
deleted file mode 100755
index 41c764ee41..0000000000
--- a/skin/skin-support-cardview/src/main/java/skin/support/widget/SkinCompatCardView.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package skin.support.widget;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.Color;
-import androidx.cardview.widget.CardView;
-import android.util.AttributeSet;
-
-import skin.support.cardview.R;
-import skin.support.content.res.SkinCompatResources;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 2017/3/5.
- */
-
-public class SkinCompatCardView extends CardView implements SkinCompatSupportable {
- private static final int[] COLOR_BACKGROUND_ATTR = {android.R.attr.colorBackground};
- private int mThemeColorBackgroundResId = INVALID_ID;
- private int mBackgroundColorResId = INVALID_ID;
-
- public SkinCompatCardView(Context context) {
- this(context, null);
- }
-
- public SkinCompatCardView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatCardView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CardView, defStyleAttr,
- R.style.CardView);
- if (a.hasValue(R.styleable.CardView_cardBackgroundColor)) {
- mBackgroundColorResId = a.getResourceId(R.styleable.CardView_cardBackgroundColor, INVALID_ID);
- } else {
- final TypedArray aa = getContext().obtainStyledAttributes(COLOR_BACKGROUND_ATTR);
- mThemeColorBackgroundResId = aa.getResourceId(0, INVALID_ID);
- aa.recycle();
- }
- a.recycle();
- applyBackgroundColorResource();
- }
-
- private void applyBackgroundColorResource() {
- mBackgroundColorResId = SkinCompatHelper.checkResourceId(mBackgroundColorResId);
- mThemeColorBackgroundResId = SkinCompatHelper.checkResourceId(mThemeColorBackgroundResId);
- ColorStateList backgroundColor;
- if (mBackgroundColorResId != INVALID_ID) {
- backgroundColor = SkinCompatResources.getColorStateList(getContext(), mBackgroundColorResId);
- setCardBackgroundColor(backgroundColor);
- } else if (mThemeColorBackgroundResId != INVALID_ID) {
- int themeColorBackground = SkinCompatResources.getColor(getContext(), mThemeColorBackgroundResId);
- final float[] hsv = new float[3];
- Color.colorToHSV(themeColorBackground, hsv);
- backgroundColor = ColorStateList.valueOf(hsv[2] > 0.5f
- ? getResources().getColor(R.color.cardview_light_background)
- : getResources().getColor(R.color.cardview_dark_background));
- setCardBackgroundColor(backgroundColor);
- }
- }
-
- @Override
- public void applySkin() {
- applyBackgroundColorResource();
- }
-
-}
diff --git a/skin/skin-support-cardview/src/main/res/values/strings.xml b/skin/skin-support-cardview/src/main/res/values/strings.xml
deleted file mode 100755
index 30a6a887e6..0000000000
--- a/skin/skin-support-cardview/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Skin-Support-CardView
-
diff --git a/skin/skin-support-constraint-layout/.gitignore b/skin/skin-support-constraint-layout/.gitignore
deleted file mode 100755
index 796b96d1c4..0000000000
--- a/skin/skin-support-constraint-layout/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/skin/skin-support-constraint-layout/build.gradle b/skin/skin-support-constraint-layout/build.gradle
deleted file mode 100755
index f77a530ab1..0000000000
--- a/skin/skin-support-constraint-layout/build.gradle
+++ /dev/null
@@ -1,33 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion rootProject.ext.android.compileSdkVersion
- // buildToolsVersion rootProject.ext.android.buildToolsVersion
- defaultConfig {
- minSdkVersion rootProject.ext.android.minSdkVersion
- targetSdkVersion rootProject.ext.android.targetSdkVersion
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation rootProject.ext.dependencies.androidxconstraintlayout
-
- if( Boolean.valueOf(USE_MAVEN_PACKAGE) ){
- implementation rootProject.ext.dependencies.skinsupportbase
- implementation rootProject.ext.dependencies.skinsupportappcompat
- } else {
- implementation project(":skin:skin-support")
- implementation project(":skin:skin-support-appcompat")
- }
-}
-
-apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support-constraint-layout/gradle.properties b/skin/skin-support-constraint-layout/gradle.properties
deleted file mode 100644
index d04ff62a59..0000000000
--- a/skin/skin-support-constraint-layout/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-GROUP=com.mogo.skin
-POM_ARTIFACT_ID=skin-support-constraint-layout
-VERSION_CODE=1
diff --git a/skin/skin-support-constraint-layout/proguard-rules.pro b/skin/skin-support-constraint-layout/proguard-rules.pro
deleted file mode 100755
index 2c61b494bc..0000000000
--- a/skin/skin-support-constraint-layout/proguard-rules.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/ximsfei/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/skin/skin-support-constraint-layout/src/main/AndroidManifest.xml b/skin/skin-support-constraint-layout/src/main/AndroidManifest.xml
deleted file mode 100755
index a9e9478378..0000000000
--- a/skin/skin-support-constraint-layout/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
diff --git a/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/SkinCompatConstraintLayout.java b/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/SkinCompatConstraintLayout.java
deleted file mode 100755
index 3336768f9b..0000000000
--- a/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/SkinCompatConstraintLayout.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package skin.support.constraint;
-
-import android.content.Context;
-import androidx.constraintlayout.widget.ConstraintLayout;
-import android.util.AttributeSet;
-
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-/**
- * Created by pengfengwang on 2017/6/19.
- */
-
-public class SkinCompatConstraintLayout extends ConstraintLayout implements SkinCompatSupportable {
- private final SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinCompatConstraintLayout(Context context) {
- this(context, null);
- }
-
- public SkinCompatConstraintLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinCompatConstraintLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-}
diff --git a/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/SkinConstraintManager.java b/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/SkinConstraintManager.java
deleted file mode 100755
index 3c99a9f69e..0000000000
--- a/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/SkinConstraintManager.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package skin.support.constraint;
-
-import android.content.Context;
-
-import skin.support.SkinCompatManager;
-import skin.support.constraint.app.SkinConstraintViewInflater;
-
-/**
- * Created by ximsfei on 2017/1/13.
- */
-
-public class SkinConstraintManager {
- private static volatile SkinConstraintManager sInstance;
-
- public static SkinConstraintManager init(Context context) {
- if (sInstance == null) {
- synchronized (SkinConstraintManager.class) {
- if (sInstance == null) {
- sInstance = new SkinConstraintManager(context);
- }
- }
- }
- return sInstance;
- }
-
- public static SkinConstraintManager getInstance() {
- return sInstance;
- }
-
- private SkinConstraintManager(Context context) {
- SkinCompatManager.init(context).addInflater(new SkinConstraintViewInflater());
- }
-}
diff --git a/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/app/SkinConstraintViewInflater.java b/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/app/SkinConstraintViewInflater.java
deleted file mode 100755
index daab8dc0d6..0000000000
--- a/skin/skin-support-constraint-layout/src/main/java/skin/support/constraint/app/SkinConstraintViewInflater.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package skin.support.constraint.app;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-
-import skin.support.app.SkinLayoutInflater;
-import skin.support.constraint.SkinCompatConstraintLayout;
-
-public class SkinConstraintViewInflater implements SkinLayoutInflater {
- @Override
- public View createView(Context context, final String name, AttributeSet attrs) {
- View view = null;
- switch (name) {
- case "androidx.constraintlayout.widget.ConstraintLayout":
- view = new SkinCompatConstraintLayout(context, attrs);
- break;
- default:
- break;
- }
- return view;
- }
-}
diff --git a/skin/skin-support-constraint-layout/src/main/res/values/strings.xml b/skin/skin-support-constraint-layout/src/main/res/values/strings.xml
deleted file mode 100755
index 73781e7077..0000000000
--- a/skin/skin-support-constraint-layout/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Skin-support-constraint-layout
-
diff --git a/skin/skin-support-design/.gitignore b/skin/skin-support-design/.gitignore
deleted file mode 100755
index 796b96d1c4..0000000000
--- a/skin/skin-support-design/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/skin/skin-support-design/build.gradle b/skin/skin-support-design/build.gradle
deleted file mode 100755
index 2111c06e70..0000000000
--- a/skin/skin-support-design/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion rootProject.ext.android.compileSdkVersion
- // buildToolsVersion rootProject.ext.android.buildToolsVersion
- defaultConfig {
- minSdkVersion rootProject.ext.android.minSdkVersion
- targetSdkVersion rootProject.ext.android.targetSdkVersion
- versionCode 1
- versionName "1.0"
- consumerProguardFiles 'consumer-rules.pro'
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation rootProject.ext.dependencies.androidxappcompat
- implementation rootProject.ext.dependencies.material
-
- if( Boolean.valueOf(USE_MAVEN_PACKAGE) ){
- implementation rootProject.ext.dependencies.skinsupportbase
- implementation rootProject.ext.dependencies.skinsupportappcompat
- } else {
- implementation project(":skin:skin-support")
- implementation project(":skin:skin-support-appcompat")
- }
-}
-
-apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support-design/consumer-rules.pro b/skin/skin-support-design/consumer-rules.pro
deleted file mode 100644
index 4578d55d8a..0000000000
--- a/skin/skin-support-design/consumer-rules.pro
+++ /dev/null
@@ -1 +0,0 @@
--keep class skin.support.widget.*{*;}
diff --git a/skin/skin-support-design/gradle.properties b/skin/skin-support-design/gradle.properties
deleted file mode 100644
index 30288cd0d8..0000000000
--- a/skin/skin-support-design/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-GROUP=com.mogo.skin
-POM_ARTIFACT_ID=skin-support-design
-VERSION_CODE=1
diff --git a/skin/skin-support-design/proguard-rules.pro b/skin/skin-support-design/proguard-rules.pro
deleted file mode 100755
index 5b74856f04..0000000000
--- a/skin/skin-support-design/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/ximsfei/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/skin/skin-support-design/src/main/AndroidManifest.xml b/skin/skin-support-design/src/main/AndroidManifest.xml
deleted file mode 100755
index 5bcda5424b..0000000000
--- a/skin/skin-support-design/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/SkinMaterialManager.java b/skin/skin-support-design/src/main/java/skin/support/design/SkinMaterialManager.java
deleted file mode 100755
index 2b52de04e9..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/SkinMaterialManager.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package skin.support.design;
-
-import android.content.Context;
-
-import skin.support.SkinCompatManager;
-import skin.support.design.app.SkinMaterialViewInflater;
-
-/**
- * Created by ximsfei on 2017/1/13.
- */
-
-public class SkinMaterialManager {
- private static volatile SkinMaterialManager sInstance;
-
- public static SkinMaterialManager init(Context context) {
- if (sInstance == null) {
- synchronized (SkinMaterialManager.class) {
- if (sInstance == null) {
- sInstance = new SkinMaterialManager(context);
- }
- }
- }
- return sInstance;
- }
-
- public static SkinMaterialManager getInstance() {
- return sInstance;
- }
-
- private SkinMaterialManager(Context context) {
- SkinCompatManager.init(context).addInflater(new SkinMaterialViewInflater());
- }
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/app/SkinMaterialViewInflater.java b/skin/skin-support-design/src/main/java/skin/support/design/app/SkinMaterialViewInflater.java
deleted file mode 100755
index 5ba077918d..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/app/SkinMaterialViewInflater.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package skin.support.design.app;
-
-import android.content.Context;
-import androidx.annotation.NonNull;
-import android.util.AttributeSet;
-import android.view.View;
-
-import skin.support.app.SkinLayoutInflater;
-import skin.support.design.widget.SkinMaterialAppBarLayout;
-import skin.support.design.widget.SkinMaterialBottomNavigationView;
-import skin.support.design.widget.SkinMaterialCollapsingToolbarLayout;
-import skin.support.design.widget.SkinMaterialCoordinatorLayout;
-import skin.support.design.widget.SkinMaterialFloatingActionButton;
-import skin.support.design.widget.SkinMaterialNavigationView;
-import skin.support.design.widget.SkinMaterialTabLayout;
-import skin.support.design.widget.SkinMaterialTextInputEditText;
-import skin.support.design.widget.SkinMaterialTextInputLayout;
-
-/**
- * Created by ximsfei on 2017/1/13.
- */
-public class SkinMaterialViewInflater implements SkinLayoutInflater {
- @Override
- public View createView(@NonNull Context context, final String name, @NonNull AttributeSet attrs) {
- if ("androidx.coordinatorlayout.widget.CoordinatorLayout".equals(name)) {
- return new SkinMaterialCoordinatorLayout(context, attrs);
- }
- if (!name.startsWith("com.google.android.material.")) {
- return null;
- }
- View view = null;
- switch (name) {
- case "com.google.android.material.appbar.AppBarLayout":
- view = new SkinMaterialAppBarLayout(context, attrs);
- break;
- case "com.google.android.material.tabs.TabLayout":
- view = new SkinMaterialTabLayout(context, attrs);
- break;
- case "com.google.android.material.textfield.TextInputLayout":
- view = new SkinMaterialTextInputLayout(context, attrs);
- break;
- case "com.google.android.material.textfield.TextInputEditText":
- view = new SkinMaterialTextInputEditText(context, attrs);
- break;
- case "com.google.android.material.navigation.NavigationView":
- view = new SkinMaterialNavigationView(context, attrs);
- break;
- case "com.google.android.material.floatingactionbutton.FloatingActionButton":
- view = new SkinMaterialFloatingActionButton(context, attrs);
- break;
- case "com.google.android.material.bottomnavigation.BottomNavigationView":
- view = new SkinMaterialBottomNavigationView(context, attrs);
- break;
- case "com.google.android.material.appbar.CollapsingToolbarLayout":
- view = new SkinMaterialCollapsingToolbarLayout(context, attrs);
- break;
- default:
- break;
- }
- return view;
- }
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialAppBarLayout.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialAppBarLayout.java
deleted file mode 100755
index 3621500148..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialAppBarLayout.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import com.google.android.material.appbar.AppBarLayout;
-import android.util.AttributeSet;
-
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-/**
- * Created by ximsfei on 2017/1/13.
- */
-
-public class SkinMaterialAppBarLayout extends AppBarLayout implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinMaterialAppBarLayout(Context context) {
- this(context, null);
- }
-
- public SkinMaterialAppBarLayout(Context context, AttributeSet attrs) {
- super(context, attrs);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, 0);
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialBottomNavigationView.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialBottomNavigationView.java
deleted file mode 100755
index a686508a26..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialBottomNavigationView.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-
-import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-import com.google.android.material.bottomnavigation.BottomNavigationView;
-import android.util.AttributeSet;
-import android.util.TypedValue;
-
-import skin.support.content.res.SkinCompatResources;
-import skin.support.design.R;
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 17-3-1.
- */
-
-public class SkinMaterialBottomNavigationView extends BottomNavigationView implements SkinCompatSupportable {
- private static final int[] DISABLED_STATE_SET = new int[]{-android.R.attr.state_enabled};
- private static final int[] CHECKED_STATE_SET = {android.R.attr.state_checked};
-
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- private int mTextColorResId = INVALID_ID;
- private int mIconTintResId = INVALID_ID;
- private int mDefaultTintResId = INVALID_ID;
-
- public SkinMaterialBottomNavigationView(@NonNull Context context) {
- this(context, null);
- }
-
- public SkinMaterialBottomNavigationView(@NonNull Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinMaterialBottomNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BottomNavigationView, defStyleAttr,
- R.style.Widget_Design_BottomNavigationView);
-
- if (a.hasValue(R.styleable.NavigationBarView_itemIconTint)) {
- mIconTintResId = a.getResourceId(R.styleable.NavigationBarView_itemIconTint, INVALID_ID);
- } else {
- mDefaultTintResId = resolveColorPrimary();
- }
- if (a.hasValue(R.styleable.NavigationBarView_itemTextColor)) {
- mTextColorResId = a.getResourceId(R.styleable.NavigationBarView_itemTextColor, INVALID_ID);
- } else {
- mDefaultTintResId = resolveColorPrimary();
- }
- a.recycle();
- applyItemIconTintResource();
- applyItemTextColorResource();
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- private void applyItemTextColorResource() {
- mTextColorResId = SkinCompatHelper.checkResourceId(mTextColorResId);
- if (mTextColorResId != INVALID_ID) {
- setItemTextColor(SkinCompatResources.getColorStateList(getContext(), mTextColorResId));
- } else {
- mDefaultTintResId = SkinCompatHelper.checkResourceId(mDefaultTintResId);
- if (mDefaultTintResId != INVALID_ID) {
- setItemTextColor(createDefaultColorStateList(android.R.attr.textColorSecondary));
- }
- }
- }
-
- private void applyItemIconTintResource() {
- mIconTintResId = SkinCompatHelper.checkResourceId(mIconTintResId);
- if (mIconTintResId != INVALID_ID) {
- setItemIconTintList(SkinCompatResources.getColorStateList(getContext(), mIconTintResId));
- } else {
- mDefaultTintResId = SkinCompatHelper.checkResourceId(mDefaultTintResId);
- if (mDefaultTintResId != INVALID_ID) {
- setItemIconTintList(createDefaultColorStateList(android.R.attr.textColorSecondary));
- }
- }
- }
-
- private ColorStateList createDefaultColorStateList(int baseColorThemeAttr) {
- final TypedValue value = new TypedValue();
- if (!getContext().getTheme().resolveAttribute(baseColorThemeAttr, value, true)) {
- return null;
- }
- ColorStateList baseColor = SkinCompatResources.getColorStateList(getContext(), value.resourceId);
-
- int colorPrimary = SkinCompatResources.getColor(getContext(), mDefaultTintResId);
- int defaultColor = baseColor.getDefaultColor();
- return new ColorStateList(new int[][]{
- DISABLED_STATE_SET,
- CHECKED_STATE_SET,
- EMPTY_STATE_SET
- }, new int[]{
- baseColor.getColorForState(DISABLED_STATE_SET, defaultColor),
- colorPrimary,
- defaultColor
- });
- }
-
- private int resolveColorPrimary() {
- final TypedValue value = new TypedValue();
- if (!getContext().getTheme().resolveAttribute(
- R.attr.colorPrimary, value, true)) {
- return INVALID_ID;
- }
- return value.resourceId;
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- applyItemIconTintResource();
- applyItemTextColorResource();
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialCollapsingToolbarLayout.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialCollapsingToolbarLayout.java
deleted file mode 100755
index ba3baa9136..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialCollapsingToolbarLayout.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import com.google.android.material.appbar.CollapsingToolbarLayout;
-import android.util.AttributeSet;
-
-import skin.support.content.res.SkinCompatVectorResources;
-import skin.support.design.R;
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 17-3-2.
- */
-
-public class SkinMaterialCollapsingToolbarLayout extends CollapsingToolbarLayout implements SkinCompatSupportable {
- private int mContentScrimResId = INVALID_ID;
- private int mStatusBarScrimResId = INVALID_ID;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinMaterialCollapsingToolbarLayout(Context context) {
- this(context, null);
- }
-
- public SkinMaterialCollapsingToolbarLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinMaterialCollapsingToolbarLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
-
- TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.CollapsingToolbarLayout, defStyleAttr,
- R.style.Widget_Design_CollapsingToolbar);
- mContentScrimResId = a.getResourceId(R.styleable.CollapsingToolbarLayout_contentScrim, INVALID_ID);
- mStatusBarScrimResId = a.getResourceId(R.styleable.CollapsingToolbarLayout_statusBarScrim, INVALID_ID);
- a.recycle();
- applyContentScrimResource();
- applyStatusBarScrimResource();
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, 0);
- }
-
- private void applyStatusBarScrimResource() {
- mStatusBarScrimResId = SkinCompatHelper.checkResourceId(mStatusBarScrimResId);
- if (mStatusBarScrimResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(getContext(), mStatusBarScrimResId);
- if (drawable != null) {
- setStatusBarScrim(drawable);
- }
- }
- }
-
- private void applyContentScrimResource() {
- mContentScrimResId = SkinCompatHelper.checkResourceId(mContentScrimResId);
- if (mContentScrimResId != INVALID_ID) {
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(getContext(), mContentScrimResId);
- if (drawable != null) {
- setContentScrim(drawable);
- }
- }
- }
-
- @Override
- public void applySkin() {
- applyContentScrimResource();
- applyStatusBarScrimResource();
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialCoordinatorLayout.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialCoordinatorLayout.java
deleted file mode 100755
index 1d52f03c2a..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialCoordinatorLayout.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import android.util.AttributeSet;
-
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-/**
- * Created by ximsf on 2017/3/5.
- */
-
-public class SkinMaterialCoordinatorLayout extends CoordinatorLayout implements SkinCompatSupportable {
-
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinMaterialCoordinatorLayout(Context context) {
- this(context, null);
- }
-
- public SkinMaterialCoordinatorLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinMaterialCoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, 0);
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialFloatingActionButton.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialFloatingActionButton.java
deleted file mode 100755
index 9ea7cfbd7d..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialFloatingActionButton.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-import android.util.AttributeSet;
-
-import skin.support.content.res.SkinCompatResources;
-import skin.support.design.R;
-import skin.support.widget.SkinCompatHelper;
-import skin.support.widget.SkinCompatImageHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by pengfengwang on 2017/3/1.
- */
-
-public class SkinMaterialFloatingActionButton extends FloatingActionButton implements SkinCompatSupportable {
- private int mRippleColorResId = INVALID_ID;
- private int mBackgroundTintResId = INVALID_ID;
-
- private SkinCompatImageHelper mImageHelper;
-
- public SkinMaterialFloatingActionButton(Context context) {
- this(context, null);
- }
-
- public SkinMaterialFloatingActionButton(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinMaterialFloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.FloatingActionButton, defStyleAttr,
- R.style.Widget_Design_FloatingActionButton);
- mBackgroundTintResId = a.getResourceId(R.styleable.FloatingActionButton_backgroundTint, INVALID_ID);
- mRippleColorResId = a.getResourceId(R.styleable.FloatingActionButton_rippleColor, INVALID_ID);
- a.recycle();
- applyBackgroundTintResource();
- applyRippleColorResource();
-
- mImageHelper = new SkinCompatImageHelper(this);
- mImageHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- private void applyBackgroundTintResource() {
- mBackgroundTintResId = SkinCompatHelper.checkResourceId(mBackgroundTintResId);
- if (mBackgroundTintResId != INVALID_ID) {
- setBackgroundTintList(SkinCompatResources.getColorStateList(getContext(), mBackgroundTintResId));
- }
- }
-
- private void applyRippleColorResource() {
- mRippleColorResId = SkinCompatHelper.checkResourceId(mRippleColorResId);
- if (mRippleColorResId != INVALID_ID) {
- setRippleColor(SkinCompatResources.getColor(getContext(), mRippleColorResId));
- }
- }
-
- @Override
- public void applySkin() {
- applyBackgroundTintResource();
- applyRippleColorResource();
- if (mImageHelper != null) {
- mImageHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialNavigationView.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialNavigationView.java
deleted file mode 100755
index 978208e245..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialNavigationView.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import androidx.annotation.DrawableRes;
-import androidx.annotation.StyleRes;
-import com.google.android.material.navigation.NavigationView;
-import android.util.AttributeSet;
-import android.util.TypedValue;
-
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatV7ThemeUtils;
-import skin.support.content.res.SkinCompatVectorResources;
-import skin.support.design.R;
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatHelper;
-import skin.support.widget.SkinCompatSupportable;
-import skin.support.content.res.SkinCompatThemeUtils;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by pengfengwang on 2017/1/15.
- */
-
-public class SkinMaterialNavigationView extends NavigationView implements SkinCompatSupportable {
- private static final int[] CHECKED_STATE_SET = {android.R.attr.state_checked};
- private static final int[] DISABLED_STATE_SET = {-android.R.attr.state_enabled};
- private int mItemBackgroundResId = INVALID_ID;
- private int mTextColorResId = INVALID_ID;
- private int mDefaultTintResId = INVALID_ID;
- private int mIconTintResId = INVALID_ID;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinMaterialNavigationView(Context context) {
- this(context, null);
- }
-
- public SkinMaterialNavigationView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinMaterialNavigationView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, 0);
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NavigationView, defStyleAttr,
- R.style.Widget_Design_NavigationView);
- if (a.hasValue(R.styleable.NavigationView_itemIconTint)) {
- mIconTintResId = a.getResourceId(R.styleable.NavigationView_itemIconTint, INVALID_ID);
- } else {
- mDefaultTintResId = SkinCompatV7ThemeUtils.getColorPrimaryResId(context);
- }
- if (a.hasValue(R.styleable.NavigationView_itemTextAppearance)) {
- int textAppearance = a.getResourceId(R.styleable.NavigationView_itemTextAppearance, INVALID_ID);
- if (textAppearance != INVALID_ID) {
- TypedArray ap = context.obtainStyledAttributes(textAppearance, R.styleable.SkinTextAppearance);
- if (ap.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
- mTextColorResId = ap.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- }
- ap.recycle();
- }
- }
- if (a.hasValue(R.styleable.NavigationView_itemTextColor)) {
- mTextColorResId = a.getResourceId(R.styleable.NavigationView_itemTextColor, INVALID_ID);
- } else {
- mDefaultTintResId = SkinCompatV7ThemeUtils.getColorPrimaryResId(context);
- }
- if (mTextColorResId == INVALID_ID) {
- mTextColorResId = SkinCompatThemeUtils.getTextColorPrimaryResId(context);
- }
- mItemBackgroundResId = a.getResourceId(R.styleable.NavigationView_itemBackground, INVALID_ID);
- a.recycle();
- applyItemIconTintResource();
- applyItemTextColorResource();
- applyItemBackgroundResource();
- }
-
- @Override
- public void setItemBackgroundResource(@DrawableRes int resId) {
- super.setItemBackgroundResource(resId);
- mItemBackgroundResId = resId;
- applyItemBackgroundResource();
- }
-
- private void applyItemBackgroundResource() {
- mItemBackgroundResId = SkinCompatHelper.checkResourceId(mItemBackgroundResId);
- if (mItemBackgroundResId == INVALID_ID) {
- return;
- }
- Drawable drawable = SkinCompatVectorResources.getDrawableCompat(getContext(), mItemBackgroundResId);
- if (drawable != null) {
- setItemBackground(drawable);
- }
- }
-
- @Override
- public void setItemTextAppearance(@StyleRes int resId) {
- super.setItemTextAppearance(resId);
- if (resId != INVALID_ID) {
- TypedArray a = getContext().obtainStyledAttributes(resId, R.styleable.SkinTextAppearance);
- if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
- mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- }
- a.recycle();
- applyItemTextColorResource();
- }
- }
-
- private void applyItemTextColorResource() {
- mTextColorResId = SkinCompatHelper.checkResourceId(mTextColorResId);
- if (mTextColorResId != INVALID_ID) {
- setItemTextColor(SkinCompatResources.getColorStateList(getContext(), mTextColorResId));
- } else {
- mDefaultTintResId = SkinCompatHelper.checkResourceId(mDefaultTintResId);
- if (mDefaultTintResId != INVALID_ID) {
- setItemTextColor(createDefaultColorStateList(android.R.attr.textColorPrimary));
- }
- }
- }
-
- private void applyItemIconTintResource() {
- mIconTintResId = SkinCompatHelper.checkResourceId(mIconTintResId);
- if (mIconTintResId != INVALID_ID) {
- setItemIconTintList(SkinCompatResources.getColorStateList(getContext(), mIconTintResId));
- } else {
- mDefaultTintResId = SkinCompatHelper.checkResourceId(mDefaultTintResId);
- if (mDefaultTintResId != INVALID_ID) {
- setItemIconTintList(createDefaultColorStateList(android.R.attr.textColorSecondary));
- }
- }
- }
-
- private ColorStateList createDefaultColorStateList(int baseColorThemeAttr) {
- final TypedValue value = new TypedValue();
- if (!getContext().getTheme().resolveAttribute(baseColorThemeAttr, value, true)) {
- return null;
- }
- ColorStateList baseColor = SkinCompatResources.getColorStateList(getContext(), value.resourceId);
-
- int colorPrimary = SkinCompatResources.getColor(getContext(), mDefaultTintResId);
- int defaultColor = baseColor.getDefaultColor();
- return new ColorStateList(new int[][]{
- DISABLED_STATE_SET,
- CHECKED_STATE_SET,
- EMPTY_STATE_SET
- }, new int[]{
- baseColor.getColorForState(DISABLED_STATE_SET, defaultColor),
- colorPrimary,
- defaultColor
- });
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- applyItemIconTintResource();
- applyItemTextColorResource();
- applyItemBackgroundResource();
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTabLayout.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTabLayout.java
deleted file mode 100755
index 460af3d1f1..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTabLayout.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import com.google.android.material.tabs.TabLayout;
-import android.util.AttributeSet;
-
-import skin.support.content.res.SkinCompatResources;
-import skin.support.design.R;
-import skin.support.widget.SkinCompatHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 17-1-14.
- */
-
-public class SkinMaterialTabLayout extends TabLayout implements SkinCompatSupportable {
- private int mTabIndicatorColorResId = INVALID_ID;
- private int mTabTextColorsResId = INVALID_ID;
- private int mTabSelectedTextColorResId = INVALID_ID;
-
- public SkinMaterialTabLayout(Context context) {
- this(context, null);
- }
-
- public SkinMaterialTabLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinMaterialTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout,
- defStyleAttr, 0);
-
- mTabIndicatorColorResId = a.getResourceId(R.styleable.TabLayout_tabIndicatorColor, INVALID_ID);
-
- int tabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance, R.style.TextAppearance_Design_Tab);
-
- // Text colors/sizes come from the text appearance first
- final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance);
- try {
- mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- } finally {
- ta.recycle();
- }
-
- if (a.hasValue(R.styleable.TabLayout_tabTextColor)) {
- // If we have an explicit text color set, use it instead
- mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID);
- }
-
- if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) {
- // We have an explicit selected text color set, so we need to make merge it with the
- // current colors. This is exposed so that developers can use theme attributes to set
- // this (theme attrs in ColorStateLists are Lollipop+)
- mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID);
- }
- a.recycle();
- applySkin();
- }
-
- @Override
- public void applySkin() {
- mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId);
- if (mTabIndicatorColorResId != INVALID_ID) {
- setSelectedTabIndicatorColor(SkinCompatResources.getColor(getContext(), mTabIndicatorColorResId));
- }
- mTabTextColorsResId = SkinCompatHelper.checkResourceId(mTabTextColorsResId);
- if (mTabTextColorsResId != INVALID_ID) {
- setTabTextColors(SkinCompatResources.getColorStateList(getContext(), mTabTextColorsResId));
- }
- mTabSelectedTextColorResId = SkinCompatHelper.checkResourceId(mTabSelectedTextColorResId);
- if (mTabSelectedTextColorResId != INVALID_ID) {
- int selected = SkinCompatResources.getColor(getContext(), mTabSelectedTextColorResId);
- if (getTabTextColors() != null) {
- setTabTextColors(getTabTextColors().getDefaultColor(), selected);
- }
- }
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTextInputEditText.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTextInputEditText.java
deleted file mode 100755
index 3a49ec9152..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTextInputEditText.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import androidx.annotation.DrawableRes;
-import com.google.android.material.textfield.TextInputEditText;
-import androidx.appcompat.R;
-import android.util.AttributeSet;
-
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatSupportable;
-import skin.support.widget.SkinCompatTextHelper;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinMaterialTextInputEditText extends TextInputEditText implements SkinCompatSupportable {
- private SkinCompatTextHelper mTextHelper;
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
-
- public SkinMaterialTextInputEditText(Context context) {
- this(context, null);
- }
-
- public SkinMaterialTextInputEditText(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.editTextStyle);
- }
-
- public SkinMaterialTextInputEditText(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
- mTextHelper = SkinCompatTextHelper.create(this);
- mTextHelper.loadFromAttributes(attrs, defStyleAttr);
- }
-
- @Override
- public void setBackgroundResource(@DrawableRes int resId) {
- super.setBackgroundResource(resId);
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.onSetBackgroundResource(resId);
- }
- }
-
- @Override
- public void setTextAppearance(int resId) {
- setTextAppearance(getContext(), resId);
- }
-
- @Override
- public void setTextAppearance(Context context, int resId) {
- super.setTextAppearance(context, resId);
- if (mTextHelper != null) {
- mTextHelper.onSetTextAppearance(context, resId);
- }
- }
-
- public int getTextColorResId() {
- return mTextHelper != null ? mTextHelper.getTextColorResId() : INVALID_ID;
- }
-
- @Override
- public void setCompoundDrawablesRelativeWithIntrinsicBounds(
- @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
- super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
- }
- }
-
- @Override
- public void setCompoundDrawablesWithIntrinsicBounds(
- @DrawableRes int left, @DrawableRes int top, @DrawableRes int right, @DrawableRes int bottom) {
- super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- if (mTextHelper != null) {
- mTextHelper.onSetCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
- }
- }
-
- @Override
- public void applySkin() {
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- if (mTextHelper != null) {
- mTextHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTextInputLayout.java b/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTextInputLayout.java
deleted file mode 100755
index 6f61b54c36..0000000000
--- a/skin/skin-support-design/src/main/java/skin/support/design/widget/SkinMaterialTextInputLayout.java
+++ /dev/null
@@ -1,222 +0,0 @@
-package skin.support.design.widget;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import androidx.annotation.StyleRes;
-import com.google.android.material.textfield.TextInputLayout;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import skin.support.content.res.SkinCompatResources;
-import skin.support.design.R;
-import skin.support.widget.SkinCompatBackgroundHelper;
-import skin.support.widget.SkinCompatEditText;
-import skin.support.widget.SkinCompatHelper;
-import skin.support.widget.SkinCompatSupportable;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 17-3-2.
- */
-
-public class SkinMaterialTextInputLayout extends TextInputLayout implements SkinCompatSupportable {
- private SkinCompatBackgroundHelper mBackgroundTintHelper;
- private int mPasswordToggleResId = INVALID_ID;
- private int mCounterTextColorResId = INVALID_ID;
- private int mErrorTextColorResId = INVALID_ID;
- private int mFocusedTextColorResId = INVALID_ID;
- private int mDefaultTextColorResId = INVALID_ID;
-
- public SkinMaterialTextInputLayout(Context context) {
- this(context, null);
- }
-
- public SkinMaterialTextInputLayout(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public SkinMaterialTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
- mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
-
- final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayout, defStyleAttr, R.style.Widget_Design_TextInputLayout);
- if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) {
- mDefaultTextColorResId = mFocusedTextColorResId =
- a.getResourceId(R.styleable.TextInputLayout_android_textColorHint, INVALID_ID);
- applyFocusedTextColorResource();
- }
-
- int errorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, INVALID_ID);
- loadErrorTextColorResFromAttributes(errorTextAppearance);
- int counterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, INVALID_ID);
- loadCounterTextColorResFromAttributes(counterTextAppearance);
- mPasswordToggleResId = a.getResourceId(R.styleable.TextInputLayout_passwordToggleDrawable, INVALID_ID);
- a.recycle();
- }
-
- private void loadCounterTextColorResFromAttributes(@StyleRes int resId) {
- if (resId != INVALID_ID) {
- TypedArray counterTA = getContext().obtainStyledAttributes(resId, skin.support.R.styleable.SkinTextAppearance);
- if (counterTA.hasValue(skin.support.R.styleable.SkinTextAppearance_android_textColor)) {
- mCounterTextColorResId = counterTA.getResourceId(skin.support.R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- }
- counterTA.recycle();
- }
- applyCounterTextColorResource();
- }
-
- @Override
- public void setCounterEnabled(boolean enabled) {
- super.setCounterEnabled(enabled);
- if (enabled) {
- applyCounterTextColorResource();
- }
- }
-
- private void applyCounterTextColorResource() {
- mCounterTextColorResId = SkinCompatHelper.checkResourceId(mCounterTextColorResId);
- if (mCounterTextColorResId != INVALID_ID) {
- TextView counterView = getCounterView();
- if (counterView != null) {
- counterView.setTextColor(SkinCompatResources.getColor(getContext(), mCounterTextColorResId));
- updateEditTextBackgroundInternal();
- }
- }
- }
-
- private TextView getCounterView() {
- try {
- Field counterView = TextInputLayout.class.getDeclaredField("mCounterView");
- counterView.setAccessible(true);
- return (TextView) counterView.get(this);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- @Override
- public void setErrorTextAppearance(@StyleRes int resId) {
- super.setErrorTextAppearance(resId);
- loadErrorTextColorResFromAttributes(resId);
- }
-
- private void loadErrorTextColorResFromAttributes(@StyleRes int resId) {
- if (resId != INVALID_ID) {
- TypedArray errorTA = getContext().obtainStyledAttributes(resId, skin.support.R.styleable.SkinTextAppearance);
- if (errorTA.hasValue(skin.support.R.styleable.SkinTextAppearance_android_textColor)) {
- mErrorTextColorResId = errorTA.getResourceId(skin.support.R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
- }
- errorTA.recycle();
- }
- applyErrorTextColorResource();
- }
-
- @Override
- public void setErrorEnabled(boolean enabled) {
- super.setErrorEnabled(enabled);
- if (enabled) {
- applyErrorTextColorResource();
- }
- }
-
- private void applyErrorTextColorResource() {
- mErrorTextColorResId = SkinCompatHelper.checkResourceId(mErrorTextColorResId);
- if (mErrorTextColorResId != INVALID_ID && mErrorTextColorResId != R.color.design_error) {
- TextView errorView = getErrorView();
- if (errorView != null) {
- errorView.setTextColor(SkinCompatResources.getColor(getContext(), mErrorTextColorResId));
- updateEditTextBackgroundInternal();
- }
- }
- }
-
- private TextView getErrorView() {
- try {
- Field errorView = TextInputLayout.class.getDeclaredField("mErrorView");
- errorView.setAccessible(true);
- return (TextView) errorView.get(this);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- private void updateEditTextBackgroundInternal() {
- try {
- Method updateEditTextBackground = TextInputLayout.class.getDeclaredMethod("updateEditTextBackground");
- updateEditTextBackground.setAccessible(true);
- updateEditTextBackground.invoke(this);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void setDefaultTextColor(ColorStateList colors) {
- try {
- Field defaultTextColor = TextInputLayout.class.getDeclaredField("mDefaultTextColor");
- defaultTextColor.setAccessible(true);
- defaultTextColor.set(this, colors);
- updateLabelState();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void applyFocusedTextColorResource() {
- mFocusedTextColorResId = SkinCompatHelper.checkResourceId(mFocusedTextColorResId);
- if (mFocusedTextColorResId != INVALID_ID && mFocusedTextColorResId != R.color.abc_hint_foreground_material_light) {
- setFocusedTextColor(SkinCompatResources.getColorStateList(getContext(), mFocusedTextColorResId));
- } else if (getEditText() != null) {
- int textColorResId = INVALID_ID;
- if (getEditText() instanceof SkinCompatEditText) {
- textColorResId = ((SkinCompatEditText) getEditText()).getTextColorResId();
- } else if (getEditText() instanceof SkinMaterialTextInputEditText) {
- textColorResId = ((SkinMaterialTextInputEditText) getEditText()).getTextColorResId();
- }
- textColorResId = SkinCompatHelper.checkResourceId(textColorResId);
- if (textColorResId != INVALID_ID) {
- ColorStateList colors = SkinCompatResources.getColorStateList(getContext(), textColorResId);
- setFocusedTextColor(colors);
- }
- }
- }
-
- private void setFocusedTextColor(ColorStateList colors) {
- try {
- Field focusedTextColor = TextInputLayout.class.getDeclaredField("mFocusedTextColor");
- focusedTextColor.setAccessible(true);
- focusedTextColor.set(this, colors);
- updateLabelState();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void updateLabelState() {
- try {
- Method updateLabelState = TextInputLayout.class.getDeclaredMethod("updateLabelState", boolean.class);
- updateLabelState.setAccessible(true);
- updateLabelState.invoke(this, false);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void applySkin() {
- applyErrorTextColorResource();
- applyCounterTextColorResource();
- applyFocusedTextColorResource();
- if (mBackgroundTintHelper != null) {
- mBackgroundTintHelper.applySkin();
- }
- }
-
-}
diff --git a/skin/skin-support-design/src/main/res/values/strings.xml b/skin/skin-support-design/src/main/res/values/strings.xml
deleted file mode 100755
index 42241a3248..0000000000
--- a/skin/skin-support-design/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- skin-support-design
-
diff --git a/skin/skin-support/.gitignore b/skin/skin-support/.gitignore
deleted file mode 100755
index 796b96d1c4..0000000000
--- a/skin/skin-support/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/skin/skin-support/build.gradle b/skin/skin-support/build.gradle
deleted file mode 100755
index 9d6b4c675b..0000000000
--- a/skin/skin-support/build.gradle
+++ /dev/null
@@ -1,30 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion rootProject.ext.android.compileSdkVersion
- // buildToolsVersion rootProject.ext.android.buildToolsVersion
- defaultConfig {
- minSdkVersion rootProject.ext.android.minSdkVersion
- targetSdkVersion rootProject.ext.android.targetSdkVersion
- versionCode 1
- versionName "1.0"
- consumerProguardFiles 'consumer-rules.pro'
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- if( Boolean.valueOf(USE_MAVEN_PACKAGE) ){
- implementation rootProject.ext.dependencies.skinsupport
- } else {
- implementation project(":skin:mogo-skin-support")
- }
-}
-
-apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
diff --git a/skin/skin-support/consumer-rules.pro b/skin/skin-support/consumer-rules.pro
deleted file mode 100644
index 44899c2a52..0000000000
--- a/skin/skin-support/consumer-rules.pro
+++ /dev/null
@@ -1,7 +0,0 @@
--keep class skin.support.annotation.*{*;}
--keep class skin.support.app.*{*;}
--keep class skin.support.content.res.ColorState.*{*;}
--keep class skin.support.content.res.ColorState.ColorBuilder{*;}
--keep class skin.support.utils.SkinCompatVersionUtils{*;}
--keep class skin.support.utils.SkinPreference{*;}
--keep class skin.support.view.*{*;}
diff --git a/skin/skin-support/gradle.properties b/skin/skin-support/gradle.properties
deleted file mode 100644
index 363e181caa..0000000000
--- a/skin/skin-support/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-GROUP=com.mogo.skin
-POM_ARTIFACT_ID=skin-support-base
-VERSION_CODE=1
diff --git a/skin/skin-support/proguard-rules.pro b/skin/skin-support/proguard-rules.pro
deleted file mode 100755
index e98b0f59af..0000000000
--- a/skin/skin-support/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /home/ximsfei/Android/Sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/skin/skin-support/src/main/AndroidManifest.xml b/skin/skin-support/src/main/AndroidManifest.xml
deleted file mode 100755
index 58d850e5a4..0000000000
--- a/skin/skin-support/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
diff --git a/skin/skin-support/src/main/java/skin/support/SkinCompatManager.java b/skin/skin-support/src/main/java/skin/support/SkinCompatManager.java
deleted file mode 100755
index c4522b2fae..0000000000
--- a/skin/skin-support/src/main/java/skin/support/SkinCompatManager.java
+++ /dev/null
@@ -1,468 +0,0 @@
-package skin.support;
-
-import android.app.Application;
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
-import android.text.TextUtils;
-import android.util.SparseArray;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import skin.support.annotation.NonNull;
-import skin.support.annotation.Nullable;
-import skin.support.app.SkinActivityLifecycle;
-import skin.support.app.SkinLayoutInflater;
-import skin.support.app.SkinWrapper;
-import skin.support.load.SkinAssetsLoader;
-import skin.support.load.SkinBuildInLoader;
-import skin.support.load.SkinNoneLoader;
-import skin.support.load.SkinPrefixBuildInLoader;
-import skin.support.observe.SkinObservable;
-import skin.support.utils.SkinPreference;
-import skin.support.content.res.SkinCompatResources;
-
-public class SkinCompatManager extends SkinObservable {
- public static final int SKIN_LOADER_STRATEGY_NONE = -1;
- public static final int SKIN_LOADER_STRATEGY_ASSETS = 0;
- public static final int SKIN_LOADER_STRATEGY_BUILD_IN = 1;
- public static final int SKIN_LOADER_STRATEGY_PREFIX_BUILD_IN = 2;
- private static volatile SkinCompatManager sInstance;
- private final Object mLock = new Object();
- private final Context mAppContext;
- private boolean mLoading = false;
- private List mWrappers = new ArrayList<>();
- private List mInflaters = new ArrayList<>();
- private List mHookInflaters = new ArrayList<>();
- private SparseArray mStrategyMap = new SparseArray<>();
- private boolean mSkinAllActivityEnable = true;
- private boolean mSkinStatusBarColorEnable = false;
- private boolean mSkinWindowBackgroundColorEnable = true;
-
- /**
- * 皮肤包加载监听.
- */
- public interface SkinLoaderListener {
- /**
- * 开始加载.
- */
- void onStart();
-
- /**
- * 加载成功.
- */
- void onSuccess();
-
- /**
- * 加载失败.
- *
- * @param errMsg 错误信息.
- */
- void onFailed( String errMsg );
- }
-
- /**
- * 皮肤包加载策略.
- */
- public interface SkinLoaderStrategy {
- /**
- * 加载皮肤包.
- *
- * @param context {@link Context}
- * @param skinName 皮肤包名称.
- * @return 加载成功,返回皮肤包名称;失败,则返回空。
- */
- String loadSkinInBackground( Context context, String skinName );
-
- /**
- * 根据应用中的资源ID,获取皮肤包相应资源的资源名.
- *
- * @param context {@link Context}
- * @param skinName 皮肤包名称.
- * @param resId 应用中需要换肤的资源ID.
- * @return 皮肤包中相应的资源名.
- */
- String getTargetResourceEntryName( Context context, String skinName, int resId );
-
- /**
- * 开发者可以拦截应用中的资源ID,返回对应color值。
- *
- * @param context {@link Context}
- * @param skinName 皮肤包名称.
- * @param resId 应用中需要换肤的资源ID.
- * @return 获得拦截后的颜色值,添加到ColorStateList的defaultColor中。不需要拦截,则返回空
- */
- ColorStateList getColor( Context context, String skinName, int resId );
-
- /**
- * 开发者可以拦截应用中的资源ID,返回对应ColorStateList。
- *
- * @param context {@link Context}
- * @param skinName 皮肤包名称.
- * @param resId 应用中需要换肤的资源ID.
- * @return 返回对应ColorStateList。不需要拦截,则返回空
- */
- ColorStateList getColorStateList( Context context, String skinName, int resId );
-
- /**
- * 开发者可以拦截应用中的资源ID,返回对应Drawable。
- *
- * @param context {@link Context}
- * @param skinName 皮肤包名称.
- * @param resId 应用中需要换肤的资源ID.
- * @return 返回对应Drawable。不需要拦截,则返回空
- */
- Drawable getDrawable( Context context, String skinName, int resId );
-
- /**
- * {@link #SKIN_LOADER_STRATEGY_NONE}
- * {@link #SKIN_LOADER_STRATEGY_ASSETS}
- * {@link #SKIN_LOADER_STRATEGY_BUILD_IN}
- * {@link #SKIN_LOADER_STRATEGY_PREFIX_BUILD_IN}
- *
- * @return 皮肤包加载策略类型.
- */
- int getType();
- }
-
- /**
- * 初始化换肤框架. 通过该方法初始化,应用中Activity需继承自{@link skin.support.app.SkinCompatActivity}.
- *
- * @param context
- * @return
- */
- public static SkinCompatManager init(Context context) {
- if (sInstance == null) {
- synchronized (SkinCompatManager.class) {
- if (sInstance == null) {
- sInstance = new SkinCompatManager(context);
- }
- }
- }
- SkinPreference.init(context);
- return sInstance;
- }
-
- public static SkinCompatManager getInstance() {
- return sInstance;
- }
-
- public static void destroy(){
- sInstance.onDestroy();
- }
-
- public void onDestroy(){
- SkinActivityLifecycle.destroy((Application)mAppContext);
- }
-
- /**
- * 初始化换肤框架,监听Activity生命周期. 通过该方法初始化,应用中Activity无需继承{@link skin.support.app.SkinCompatActivity}.
- *
- * @param application 应用Application.
- * @return
- */
- public static SkinCompatManager withoutActivity(Application application) {
- init(application);
- SkinActivityLifecycle.init(application);
- return sInstance;
- }
-
- private SkinCompatManager(Context context) {
- mAppContext = context.getApplicationContext();
- initLoaderStrategy();
- }
-
- private void initLoaderStrategy() {
- mStrategyMap.put(SKIN_LOADER_STRATEGY_NONE, new SkinNoneLoader());
- mStrategyMap.put(SKIN_LOADER_STRATEGY_ASSETS, new SkinAssetsLoader());
- mStrategyMap.put(SKIN_LOADER_STRATEGY_BUILD_IN, new SkinBuildInLoader());
- mStrategyMap.put(SKIN_LOADER_STRATEGY_PREFIX_BUILD_IN, new SkinPrefixBuildInLoader());
- }
-
- public Context getContext() {
- return mAppContext;
- }
-
- /**
- * 添加皮肤包加载策略.
- *
- * @param strategy 自定义加载策略
- * @return
- */
- public SkinCompatManager addStrategy(SkinLoaderStrategy strategy) {
- mStrategyMap.put(strategy.getType(), strategy);
- return this;
- }
-
- public SparseArray getStrategies() {
- return mStrategyMap;
- }
-
- /**
- * 自定义View换肤时,可选择添加一个{@link SkinLayoutInflater}
- *
- * @param inflater 在{@link skin.support.app.SkinCompatViewInflater#createView(Context, String, String)}方法中调用.
- * @return
- */
- public SkinCompatManager addInflater(SkinLayoutInflater inflater) {
- if (inflater instanceof SkinWrapper) {
- mWrappers.add((SkinWrapper) inflater);
- }
- mInflaters.add(inflater);
- return this;
- }
-
- public List getWrappers() {
- return mWrappers;
- }
-
- public List getInflaters() {
- return mInflaters;
- }
-
-
- /**
- * 自定义View换肤时,可选择添加一个{@link SkinLayoutInflater}
- *
- * @param inflater 在{@link skin.support.app.SkinCompatViewInflater#createView(Context, String, String)}方法中最先调用.
- * @return
- */
- @Deprecated
- public SkinCompatManager addHookInflater(SkinLayoutInflater inflater) {
- mHookInflaters.add(inflater);
- return this;
- }
-
- @Deprecated
- public List getHookInflaters() {
- return mHookInflaters;
- }
-
- /**
- * 获取当前皮肤包.
- *
- * @return
- */
- @Deprecated
- public String getCurSkinName() {
- return SkinPreference.getInstance().getSkinName();
- }
-
- /**
- * 恢复默认主题,使用应用自带资源.
- */
- public void restoreDefaultTheme() {
- loadSkin("", SKIN_LOADER_STRATEGY_NONE);
- }
-
- /**
- * 设置是否所有Activity都换肤.
- *
- * @param enable true: 所有Activity都换肤; false: 添加注解Skinable或实现SkinCompatSupportable的Activity支持换肤.
- * @return
- */
- public SkinCompatManager setSkinAllActivityEnable(boolean enable) {
- mSkinAllActivityEnable = enable;
- return this;
- }
-
- public boolean isSkinAllActivityEnable() {
- return mSkinAllActivityEnable;
- }
-
- @Deprecated
- public SkinCompatManager setSkinStatusBarColorEnable(boolean enable) {
- mSkinStatusBarColorEnable = enable;
- return this;
- }
-
- @Deprecated
- public boolean isSkinStatusBarColorEnable() {
- return mSkinStatusBarColorEnable;
- }
-
- /**
- * 设置WindowBackground换肤,使用Theme中的{@link android.R.attr#windowBackground}属性.
- *
- * @param enable true: 打开; false: 关闭.
- * @return
- */
- public SkinCompatManager setSkinWindowBackgroundEnable(boolean enable) {
- mSkinWindowBackgroundColorEnable = enable;
- return this;
- }
-
- public boolean isSkinWindowBackgroundEnable() {
- return mSkinWindowBackgroundColorEnable;
- }
-
- /**
- * 加载记录的皮肤包,一般在Application中初始化换肤框架后调用.
- *
- * @return
- */
- public AsyncTask loadSkin() {
- String skin = SkinPreference.getInstance().getSkinName();
- int strategy = SkinPreference.getInstance().getSkinStrategy();
- if (TextUtils.isEmpty(skin) || strategy == SKIN_LOADER_STRATEGY_NONE) {
- return null;
- }
- return loadSkin(skin, null, strategy);
- }
-
- /**
- * 加载记录的皮肤包,一般在Application中初始化换肤框架后调用.
- *
- * @param listener 皮肤包加载监听.
- * @return
- */
- public AsyncTask loadSkin(SkinLoaderListener listener) {
- String skin = SkinPreference.getInstance().getSkinName();
- int strategy = SkinPreference.getInstance().getSkinStrategy();
- if (TextUtils.isEmpty(skin) || strategy == SKIN_LOADER_STRATEGY_NONE) {
- return null;
- }
- return loadSkin(skin, listener, strategy);
- }
-
- @Deprecated
- public AsyncTask loadSkin(String skinName) {
- return loadSkin(skinName, null);
- }
-
- @Deprecated
- public AsyncTask loadSkin(String skinName, final SkinLoaderListener listener) {
- return loadSkin(skinName, listener, SKIN_LOADER_STRATEGY_ASSETS);
- }
-
- /**
- * 加载皮肤包.
- *
- * @param skinName 皮肤包名称.
- * @param strategy 皮肤包加载策略.
- * @return
- */
- public AsyncTask loadSkin(String skinName, int strategy) {
- return loadSkin(skinName, null, strategy);
- }
-
- /**
- * 加载皮肤包.
- *
- * @param skinName 皮肤包名称.
- * @param listener 皮肤包加载监听.
- * @param strategy 皮肤包加载策略.
- * @return
- */
- public AsyncTask loadSkin(String skinName, SkinLoaderListener listener, int strategy) {
- SkinLoaderStrategy loaderStrategy = mStrategyMap.get(strategy);
- if (loaderStrategy == null) {
- return null;
- }
- return new SkinLoadTask(listener, loaderStrategy).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, skinName);
- }
-
- private class SkinLoadTask extends AsyncTask {
- private final SkinLoaderListener mListener;
- private final SkinLoaderStrategy mStrategy;
-
- SkinLoadTask(@Nullable SkinLoaderListener listener, @NonNull SkinLoaderStrategy strategy) {
- mListener = listener;
- mStrategy = strategy;
- }
-
- @Override
- protected void onPreExecute() {
- if (mListener != null) {
- mListener.onStart();
- }
- }
-
- @Override
- protected String doInBackground(String... params) {
- synchronized (mLock) {
- while (mLoading) {
- try {
- mLock.wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- mLoading = true;
- }
- try {
- if (params.length == 1) {
- String skinName = mStrategy.loadSkinInBackground(mAppContext, params[0]);
- if (TextUtils.isEmpty(skinName)) {
- SkinCompatResources.getInstance().reset(mStrategy);
- return "";
- }
- return params[0];
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- SkinCompatResources.getInstance().reset();
- return null;
- }
-
- @Override
- protected void onPostExecute(String skinName) {
- synchronized (mLock) {
- // skinName 为""时,恢复默认皮肤
- if (skinName != null) {
- SkinPreference.getInstance().setSkinName(skinName).setSkinStrategy(mStrategy.getType()).commitEditor();
- notifyUpdateSkin();
- if (mListener != null) {
- mListener.onSuccess();
- }
- } else {
- SkinPreference.getInstance().setSkinName("").setSkinStrategy(SKIN_LOADER_STRATEGY_NONE).commitEditor();
- if (mListener != null) {
- mListener.onFailed("皮肤资源获取失败");
- }
- }
- mLoading = false;
- mLock.notifyAll();
- }
- }
- }
-
- /**
- * 获取皮肤包包名.
- *
- * @param skinPkgPath sdcard中皮肤包路径.
- * @return
- */
- public String getSkinPackageName(String skinPkgPath) {
- PackageManager mPm = mAppContext.getPackageManager();
- PackageInfo info = mPm.getPackageArchiveInfo(skinPkgPath, PackageManager.GET_ACTIVITIES);
- return info.packageName;
- }
-
- /**
- * 获取皮肤包资源{@link Resources}.
- *
- * @param skinPkgPath sdcard中皮肤包路径.
- * @return
- */
- @Nullable
- public Resources getSkinResources(String skinPkgPath) {
- try {
- PackageInfo packageInfo = mAppContext.getPackageManager().getPackageArchiveInfo(skinPkgPath, 0);
- packageInfo.applicationInfo.sourceDir = skinPkgPath;
- packageInfo.applicationInfo.publicSourceDir = skinPkgPath;
- Resources res = mAppContext.getPackageManager().getResourcesForApplication(packageInfo.applicationInfo);
- Resources superRes = mAppContext.getResources();
- return new Resources(res.getAssets(), superRes.getDisplayMetrics(), superRes.getConfiguration());
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-}
\ No newline at end of file
diff --git a/skin/skin-support/src/main/java/skin/support/annotation/AnyRes.java b/skin/skin-support/src/main/java/skin/support/annotation/AnyRes.java
deleted file mode 100755
index 498c774bf3..0000000000
--- a/skin/skin-support/src/main/java/skin/support/annotation/AnyRes.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package skin.support.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-/**
- * Denotes that an integer parameter, field or method return value is expected
- * to be a resource reference of any type. If the specific type is known, use
- * one of the more specific annotations instead, such as {@link StringRes} or
- * {@link DrawableRes}.
- */
-@Documented
-@Retention(CLASS)
-@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE})
-public @interface AnyRes {
-}
diff --git a/skin/skin-support/src/main/java/skin/support/annotation/ColorRes.java b/skin/skin-support/src/main/java/skin/support/annotation/ColorRes.java
deleted file mode 100755
index f9f94f8010..0000000000
--- a/skin/skin-support/src/main/java/skin/support/annotation/ColorRes.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package skin.support.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-/**
- * Denotes that an integer parameter, field or method return value is expected
- * to be a color resource reference (e.g. {@code android.R.color.black}).
- */
-@Documented
-@Retention(CLASS)
-@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE})
-public @interface ColorRes {
-}
diff --git a/skin/skin-support/src/main/java/skin/support/annotation/DrawableRes.java b/skin/skin-support/src/main/java/skin/support/annotation/DrawableRes.java
deleted file mode 100755
index 5399b0e1cf..0000000000
--- a/skin/skin-support/src/main/java/skin/support/annotation/DrawableRes.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package skin.support.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-/**
- * Denotes that an integer parameter, field or method return value is expected
- * to be a drawable resource reference (e.g. {@code android.R.attr.alertDialogIcon}).
- */
-@Documented
-@Retention(CLASS)
-@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE})
-public @interface DrawableRes {
-}
diff --git a/skin/skin-support/src/main/java/skin/support/annotation/NonNull.java b/skin/skin-support/src/main/java/skin/support/annotation/NonNull.java
deleted file mode 100755
index 23e0b250c7..0000000000
--- a/skin/skin-support/src/main/java/skin/support/annotation/NonNull.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package skin.support.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PACKAGE;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-/**
- * Denotes that a parameter, field or method return value can never be null.
- *
- * This is a marker annotation and it has no specific attributes.
- */
-@Documented
-@Retention(CLASS)
-@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE})
-public @interface NonNull {
-}
diff --git a/skin/skin-support/src/main/java/skin/support/annotation/Nullable.java b/skin/skin-support/src/main/java/skin/support/annotation/Nullable.java
deleted file mode 100755
index 0de1ae315c..0000000000
--- a/skin/skin-support/src/main/java/skin/support/annotation/Nullable.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package skin.support.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PACKAGE;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-/**
- * Denotes that a parameter, field or method return value can be null.
- *
- * When decorating a method call parameter, this denotes that the parameter can
- * legitimately be null and the method will gracefully deal with it. Typically
- * used on optional parameters.
- *
- * When decorating a method, this denotes the method might legitimately return
- * null.
- *
- * This is a marker annotation and it has no specific attributes.
- */
-@Documented
-@Retention(CLASS)
-@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE})
-public @interface Nullable {
-}
diff --git a/skin/skin-support/src/main/java/skin/support/annotation/Skinable.java b/skin/skin-support/src/main/java/skin/support/annotation/Skinable.java
deleted file mode 100755
index f387b20888..0000000000
--- a/skin/skin-support/src/main/java/skin/support/annotation/Skinable.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package skin.support.annotation;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-@Retention(RUNTIME)
-@Target({TYPE})
-public @interface Skinable {
-}
diff --git a/skin/skin-support/src/main/java/skin/support/annotation/StringRes.java b/skin/skin-support/src/main/java/skin/support/annotation/StringRes.java
deleted file mode 100755
index b6edf15e0b..0000000000
--- a/skin/skin-support/src/main/java/skin/support/annotation/StringRes.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package skin.support.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-
-/**
- * Denotes that an integer parameter, field or method return value is expected
- * to be a String resource reference (e.g. {@code android.R.string.ok}).
- */
-@Documented
-@Retention(CLASS)
-@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE})
-public @interface StringRes {
-}
diff --git a/skin/skin-support/src/main/java/skin/support/app/SkinActivityLifecycle.java b/skin/skin-support/src/main/java/skin/support/app/SkinActivityLifecycle.java
deleted file mode 100755
index 2ec077bc52..0000000000
--- a/skin/skin-support/src/main/java/skin/support/app/SkinActivityLifecycle.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package skin.support.app;
-
-import android.app.Activity;
-import android.app.Application;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-
-import java.lang.ref.WeakReference;
-import java.util.WeakHashMap;
-
-import skin.support.SkinCompatManager;
-import skin.support.annotation.Skinable;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.content.res.SkinCompatThemeUtils;
-import skin.support.observe.SkinObservable;
-import skin.support.observe.SkinObserver;
-import skin.support.utils.Slog;
-import skin.support.view.LayoutInflaterCompat;
-import skin.support.widget.SkinCompatSupportable;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-import static skin.support.widget.SkinCompatHelper.checkResourceId;
-
-public class SkinActivityLifecycle implements Application.ActivityLifecycleCallbacks {
- private static final String TAG = "SkinActivityLifecycle";
- private static volatile SkinActivityLifecycle sInstance = null;
- private WeakHashMap< Context, SkinCompatDelegate > mSkinDelegateMap;
- private WeakHashMap< Context, LazySkinObserver > mSkinObserverMap;
- /**
- * 用于记录当前Activity,在换肤后,立即刷新当前Activity以及非Activity创建的View。
- */
- private WeakReference< Activity > mCurActivityRef;
-
- public static SkinActivityLifecycle init( Application application ) {
- if ( sInstance == null ) {
- synchronized ( SkinActivityLifecycle.class ) {
- if ( sInstance == null ) {
- sInstance = new SkinActivityLifecycle( application );
- }
- }
- }
- return sInstance;
- }
-
- private SkinActivityLifecycle( Application application ) {
- application.registerActivityLifecycleCallbacks( this );
- installLayoutFactory( application );
- SkinCompatManager.getInstance().addObserver( getObserver( application ) );
- }
-
- @Override
- public void onActivityCreated( Activity activity, Bundle savedInstanceState ) {
- Log.d( "onCreated", "----onCreated2" );
- onCompensateActivityCreated( activity, savedInstanceState );
- }
-
- /**
- * 补偿启动页的 create 回调
- */
- public void onCompensateActivityCreated( Activity activity, Bundle savedInstanceState ) {
- if ( isContextSkinEnable( activity ) ) {
- installLayoutFactory( activity );
- updateWindowBackground( activity );
- if ( activity instanceof SkinCompatSupportable ) {
- ( ( SkinCompatSupportable ) activity ).applySkin();
- }
- }
- }
-
- @Override
- public void onActivityStarted( Activity activity ) {
-
- }
-
- @Override
- public void onActivityResumed( Activity activity ) {
- mCurActivityRef = new WeakReference<>( activity );
- if ( isContextSkinEnable( activity ) ) {
- LazySkinObserver observer = getObserver( activity );
- SkinCompatManager.getInstance().addObserver( observer );
- observer.updateSkinIfNeeded();
- }
- }
-
- @Override
- public void onActivityPaused( Activity activity ) {
- }
-
- @Override
- public void onActivityStopped( Activity activity ) {
-
- }
-
- @Override
- public void onActivitySaveInstanceState( Activity activity, Bundle outState ) {
-
- }
-
- @Override
- public void onActivityDestroyed( Activity activity ) {
- if ( isContextSkinEnable( activity ) ) {
- SkinCompatManager.getInstance().deleteObserver( getObserver( activity ) );
- mSkinObserverMap.remove( activity );
- mSkinDelegateMap.remove( activity );
- }
- }
-
- private void installLayoutFactory( Context context ) {
- try {
- LayoutInflater layoutInflater = LayoutInflater.from( context );
- LayoutInflaterCompat.setFactory2( layoutInflater, getSkinDelegate( context ) );
- } catch ( Throwable e ) {
- Slog.i( "SkinActivity", "A factory has already been set on this LayoutInflater" );
- }
- }
-
- private SkinCompatDelegate getSkinDelegate( Context context ) {
- if ( mSkinDelegateMap == null ) {
- mSkinDelegateMap = new WeakHashMap<>();
- }
-
- SkinCompatDelegate mSkinDelegate = mSkinDelegateMap.get( context );
- if ( mSkinDelegate == null ) {
- mSkinDelegate = SkinCompatDelegate.create( context );
- mSkinDelegateMap.put( context, mSkinDelegate );
- }
- return mSkinDelegate;
- }
-
- private LazySkinObserver getObserver( final Context context ) {
- if ( mSkinObserverMap == null ) {
- mSkinObserverMap = new WeakHashMap<>();
- }
- LazySkinObserver observer = mSkinObserverMap.get( context );
- if ( observer == null ) {
- observer = new LazySkinObserver( context );
- mSkinObserverMap.put( context, observer );
- }
- return observer;
- }
-
- private void updateWindowBackground( Activity activity ) {
- if ( SkinCompatManager.getInstance().isSkinWindowBackgroundEnable() ) {
- int windowBackgroundResId = SkinCompatThemeUtils.getWindowBackgroundResId( activity );
- if ( checkResourceId( windowBackgroundResId ) != INVALID_ID ) {
- Drawable drawable = SkinCompatResources.getDrawable( activity, windowBackgroundResId );
- if ( drawable != null ) {
- activity.getWindow().setBackgroundDrawable( drawable );
- }
- }
- }
- }
-
- private boolean isContextSkinEnable( Context context ) {
- return SkinCompatManager.getInstance().isSkinAllActivityEnable()
- || context.getClass().getAnnotation( Skinable.class ) != null
- || context instanceof SkinCompatSupportable;
- }
-
- private class LazySkinObserver implements SkinObserver {
- private final Context mContext;
- private boolean mMarkNeedUpdate = false;
-
- LazySkinObserver( Context context ) {
- mContext = context;
- }
-
- @Override
- public void updateSkin( SkinObservable observable, Object o ) {
- // 当前Activity,或者非Activity,立即刷新,否则延迟到下次onResume方法中刷新。
- if ( mCurActivityRef == null
- || mContext == mCurActivityRef.get()
- || !( mContext instanceof Activity ) ) {
- updateSkinForce();
- } else {
- mMarkNeedUpdate = true;
- }
- }
-
- void updateSkinIfNeeded() {
- if ( mMarkNeedUpdate ) {
- updateSkinForce();
- }
- }
-
- void updateSkinForce() {
- if ( Slog.DEBUG ) {
- Slog.i( TAG, "Context: " + mContext + " updateSkinForce" );
- }
- if ( mContext == null ) {
- return;
- }
- if ( mContext instanceof Activity && isContextSkinEnable( mContext ) ) {
- updateWindowBackground( ( Activity ) mContext );
- }
- getSkinDelegate( mContext ).applySkin();
- if ( mContext instanceof SkinCompatSupportable ) {
- ( ( SkinCompatSupportable ) mContext ).applySkin();
- }
- mMarkNeedUpdate = false;
- }
- }
-
- public static void destroy(Application application){
- application.unregisterActivityLifecycleCallbacks( sInstance );
- sInstance = null;
- }
-
-}
\ No newline at end of file
diff --git a/skin/skin-support/src/main/java/skin/support/app/SkinCompatDelegate.java b/skin/skin-support/src/main/java/skin/support/app/SkinCompatDelegate.java
deleted file mode 100755
index 33097b29d8..0000000000
--- a/skin/skin-support/src/main/java/skin/support/app/SkinCompatDelegate.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package skin.support.app;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-
-import com.mogo.skin.support.IMogoSkinCompatSupportable;
-
-import java.lang.ref.WeakReference;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import skin.support.SkinCompatManager;
-import skin.support.annotation.NonNull;
-import skin.support.widget.SkinCompatSupportable;
-
-/**
- * Created by ximsfei on 2017/1/9.
- */
-
-public class SkinCompatDelegate implements LayoutInflater.Factory2 {
- private final Context mContext;
- private SkinCompatViewInflater mSkinCompatViewInflater;
- private List> mSkinHelpers = new CopyOnWriteArrayList<>();
- private List> mMogoSkinHelpers = new CopyOnWriteArrayList<>();
-
- private SkinCompatDelegate(Context context) {
- mContext = context;
- }
-
- @Override
- public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
- View view = createView(parent, name, context, attrs);
-
- if (view == null) {
- return null;
- }
- if (view instanceof SkinCompatSupportable) {
- mSkinHelpers.add(new WeakReference<>((SkinCompatSupportable) view));
- }
- if (view instanceof IMogoSkinCompatSupportable) {
- mMogoSkinHelpers.add(new WeakReference<>((IMogoSkinCompatSupportable) view));
- }
-
- return view;
- }
-
- @Override
- public View onCreateView(String name, Context context, AttributeSet attrs) {
- View view = createView(null, name, context, attrs);
-
- if (view == null) {
- return null;
- }
- if (view instanceof SkinCompatSupportable) {
- mSkinHelpers.add(new WeakReference<>((SkinCompatSupportable) view));
- }
- if (view instanceof IMogoSkinCompatSupportable) {
- mMogoSkinHelpers.add(new WeakReference<>((IMogoSkinCompatSupportable) view));
- }
-
- return view;
- }
-
- public View createView(View parent, final String name, @NonNull Context context,
- @NonNull AttributeSet attrs) {
- if (mSkinCompatViewInflater == null) {
- mSkinCompatViewInflater = new SkinCompatViewInflater();
- }
-
- List wrapperList = SkinCompatManager.getInstance().getWrappers();
-
- if ( wrapperList != null ) {
- for (SkinWrapper wrapper : wrapperList) {
- Context wrappedContext = wrapper.wrapContext(mContext, parent, attrs);
- if (wrappedContext != null) {
- context = wrappedContext;
- }
- }
- }
-
- return mSkinCompatViewInflater.createView(parent, name, context, attrs);
- }
-
- public static SkinCompatDelegate create(Context context) {
- return new SkinCompatDelegate(context);
- }
-
- public void applySkin() {
- if (mSkinHelpers != null && !mSkinHelpers.isEmpty()) {
- for (WeakReference ref : mSkinHelpers) {
- if (ref != null && ref.get() != null) {
- ((SkinCompatSupportable) ref.get()).applySkin();
- }
- }
- }
- if (mMogoSkinHelpers != null && !mMogoSkinHelpers.isEmpty()) {
- for (WeakReference ref : mMogoSkinHelpers) {
- if (ref != null && ref.get() != null) {
- ((IMogoSkinCompatSupportable) ref.get()).applySkin();
- }
- }
- }
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/app/SkinCompatViewInflater.java b/skin/skin-support/src/main/java/skin/support/app/SkinCompatViewInflater.java
deleted file mode 100755
index ba99960457..0000000000
--- a/skin/skin-support/src/main/java/skin/support/app/SkinCompatViewInflater.java
+++ /dev/null
@@ -1,258 +0,0 @@
-package skin.support.app;
-
-import android.content.Context;
-import android.content.ContextWrapper;
-import android.content.res.TypedArray;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.InflateException;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import skin.support.SkinCompatManager;
-import skin.support.annotation.NonNull;
-import skin.support.annotation.Nullable;
-import skin.support.collection.ArrayMap;
-import skin.support.view.ViewCompat;
-
-/**
- * Created by ximsfei on 17-1-9.
- */
-
-public class SkinCompatViewInflater {
-
- private static final String TAG = "SkinCompatViewInflater";
-
- private static final Class< ? >[] sConstructorSignature = new Class[]{
- Context.class, AttributeSet.class};
- private static final int[] sOnClickAttrs = new int[]{android.R.attr.onClick};
-
- private static final String[] sClassPrefixList = {
- "android.widget.",
- "android.view.",
- "android.webkit."
- };
-
- private static final Map< String, Constructor< ? extends View > > sConstructorMap
- = new ArrayMap<>();
-
- private final Object[] mConstructorArgs = new Object[2];
-
- public final View createView( View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs ) {
- View view = null;
-
-// if ( !ViewFromTagFilter.getInstance().isStarted() ) {
-// if ( ViewFromTagFilter.getInstance().isAMapNaviView( name ) ) {
-// ViewFromTagFilter.getInstance().setStarted( true );
-// }
-// }
-// if ( ViewFromTagFilter.getInstance().isStarted() ) {
-// if ( !ViewFromTagFilter.getInstance().isEnd() ) {
-// try {
-// ViewFromTagFilter.getInstance().increaseCounter();
-// Log.d( TAG, "inflate view: " + name );
-// view = createView( context, name, null );
-// } catch ( ClassNotFoundException e ) {
-// e.printStackTrace();
-// }
-// } else {
-// ViewFromTagFilter.getInstance().setStarted( false );
-// }
-// }
-
- if ( view == null ) {
- view = createViewFromHackInflater( context, name, attrs );
- }
-
- if ( view == null ) {
- view = createViewFromInflater( context, name, attrs );
- }
-
- if ( view == null ) {
- view = createViewFromTag( context, name, attrs );
- }
-
- if ( view != null ) {
- // If we have created a view, check it's android:onClick
- checkOnClickListener( view, attrs );
- }
-
- return view;
- }
-
- private View createViewFromHackInflater( Context context, String name, AttributeSet attrs ) {
- View view = null;
- for ( SkinLayoutInflater inflater : SkinCompatManager.getInstance().getHookInflaters() ) {
- view = inflater.createView( context, name, attrs );
- if ( view == null ) {
- continue;
- } else {
- break;
- }
- }
- return view;
- }
-
- private View createViewFromInflater( Context context, String name, AttributeSet attrs ) {
- View view = null;
- for ( SkinLayoutInflater inflater : SkinCompatManager.getInstance().getInflaters() ) {
- view = inflater.createView( context, name, attrs );
- if ( view == null ) {
- continue;
- } else {
- break;
- }
- }
- return view;
- }
-
- public View createViewFromTag( Context context, String name, AttributeSet attrs ) {
- if ( "view".equals( name ) ) {
- name = attrs.getAttributeValue( null, "class" );
- }
-
- try {
- mConstructorArgs[0] = context;
- mConstructorArgs[1] = attrs;
-
- if ( -1 == name.indexOf( '.' ) ) {
- for ( int i = 0; i < sClassPrefixList.length; i++ ) {
- final View view = createView( context, name, sClassPrefixList[i] );
- if ( view != null ) {
- return view;
- }
- }
- return null;
- } else {
- return createView( context, name, null );
- }
- } catch ( Exception e ) {
- // We do not want to catch these, lets return null and let the actual LayoutInflater
- // try
- return null;
- } finally {
- // Don't retain references on context.
- mConstructorArgs[0] = null;
- mConstructorArgs[1] = null;
- }
- }
-
- /**
- * android:onClick doesn't handle views with a ContextWrapper context. This method
- * backports new framework functionality to traverse the Context wrappers to find a
- * suitable target.
- */
- private void checkOnClickListener( View view, AttributeSet attrs ) {
- final Context context = view.getContext();
-
- if ( !( context instanceof ContextWrapper ) ||
- ( Build.VERSION.SDK_INT >= 15 && !ViewCompat.hasOnClickListeners( view ) ) ) {
- // Skip our compat functionality if: the Context isn't a ContextWrapper, or
- // the view doesn't have an OnClickListener (we can only rely on this on API 15+ so
- // always use our compat code on older devices)
- return;
- }
-
- final TypedArray a = context.obtainStyledAttributes( attrs, sOnClickAttrs );
- final String handlerName = a.getString( 0 );
- if ( handlerName != null ) {
- view.setOnClickListener( new DeclaredOnClickListener( view, handlerName ) );
- }
- a.recycle();
- }
-
- private View createView( Context context, String name, String prefix )
- throws ClassNotFoundException, InflateException {
- Constructor< ? extends View > constructor = sConstructorMap.get( name );
-
- try {
- if ( constructor == null ) {
- // Class not found in the cache, see if it's real, and try to add it
- Class< ? extends View > clazz = context.getClassLoader().loadClass(
- prefix != null ? ( prefix + name ) : name ).asSubclass( View.class );
-
- constructor = clazz.getConstructor( sConstructorSignature );
- sConstructorMap.put( name, constructor );
- }
- constructor.setAccessible( true );
- return constructor.newInstance( mConstructorArgs );
- } catch ( Exception e ) {
- // We do not want to catch these, lets return null and let the actual LayoutInflater
- // try
- return null;
- }
- }
-
- /**
- * An implementation of OnClickListener that attempts to lazily load a
- * named click handling method from a parent or ancestor context.
- */
- private static class DeclaredOnClickListener implements View.OnClickListener {
- private final View mHostView;
- private final String mMethodName;
-
- private Method mResolvedMethod;
- private Context mResolvedContext;
-
- public DeclaredOnClickListener( @NonNull View hostView, @NonNull String methodName ) {
- mHostView = hostView;
- mMethodName = methodName;
- }
-
- @Override
- public void onClick( @NonNull View v ) {
- if ( mResolvedMethod == null ) {
- resolveMethod( mHostView.getContext(), mMethodName );
- }
-
- try {
- mResolvedMethod.invoke( mResolvedContext, v );
- } catch ( IllegalAccessException e ) {
- throw new IllegalStateException(
- "Could not execute non-public method for android:onClick", e );
- } catch ( InvocationTargetException e ) {
- throw new IllegalStateException(
- "Could not execute method for android:onClick", e );
- }
- }
-
- @NonNull
- private void resolveMethod( @Nullable Context context, @NonNull String name ) {
- while ( context != null ) {
- try {
- if ( !context.isRestricted() ) {
- final Method method = context.getClass().getMethod( mMethodName, View.class );
- if ( method != null ) {
- mResolvedMethod = method;
- mResolvedContext = context;
- return;
- }
- }
- } catch ( NoSuchMethodException e ) {
- // Failed to find method, keep searching up the hierarchy.
- }
-
- if ( context instanceof ContextWrapper ) {
- context = ( ( ContextWrapper ) context ).getBaseContext();
- } else {
- // Can't search up the hierarchy, null out and fail.
- context = null;
- }
- }
-
- final int id = mHostView.getId();
- final String idText = id == View.NO_ID ? "" : " with id '"
- + mHostView.getContext().getResources().getResourceEntryName( id ) + "'";
- throw new IllegalStateException( "Could not find method " + mMethodName
- + "(View) in a parent or ancestor Context for android:onClick "
- + "attribute defined on view " + mHostView.getClass() + idText );
- }
- }
-}
-
diff --git a/skin/skin-support/src/main/java/skin/support/app/SkinLayoutInflater.java b/skin/skin-support/src/main/java/skin/support/app/SkinLayoutInflater.java
deleted file mode 100755
index 68c8dec532..0000000000
--- a/skin/skin-support/src/main/java/skin/support/app/SkinLayoutInflater.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package skin.support.app;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-
-import skin.support.annotation.NonNull;
-
-/**
- * Created by ximsfei on 2017/1/13.
- */
-
-public interface SkinLayoutInflater {
- View createView( @NonNull Context context, final String name, @NonNull AttributeSet attrs );
-}
diff --git a/skin/skin-support/src/main/java/skin/support/app/SkinWrapper.java b/skin/skin-support/src/main/java/skin/support/app/SkinWrapper.java
deleted file mode 100755
index 8ec0ce6afa..0000000000
--- a/skin/skin-support/src/main/java/skin/support/app/SkinWrapper.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package skin.support.app;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-
-public interface SkinWrapper {
- Context wrapContext( Context context, View parent, AttributeSet attrs );
-}
diff --git a/skin/skin-support/src/main/java/skin/support/app/ViewFromTagFilter.java b/skin/skin-support/src/main/java/skin/support/app/ViewFromTagFilter.java
deleted file mode 100644
index 637738219c..0000000000
--- a/skin/skin-support/src/main/java/skin/support/app/ViewFromTagFilter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package skin.support.app;
-
-import android.text.TextUtils;
-
-public
-/**
- * @author congtaowang
- * @since 2020/8/26
- *
- * 描述
- */
-class ViewFromTagFilter {
-
- private int mCounter = 0;
- private boolean mStarted = false;
-
- private ViewFromTagFilter() {
- // private constructor
- }
-
- private static final class InstanceHolder {
- private static final ViewFromTagFilter INSTANCE = new ViewFromTagFilter();
- }
-
- public static ViewFromTagFilter getInstance() {
- return InstanceHolder.INSTANCE;
- }
-
- private Object readResolve() {
- // 阻止反序列化,必须实现 Serializable 接口
- return InstanceHolder.INSTANCE;
- }
-
- public boolean isStarted() {
- return mStarted;
- }
-
- public boolean isAMapNaviView( String name ) {
- return TextUtils.equals( "com.amap.api.navi.AMapNaviView", name );
- }
-
- public void setStarted( boolean mStarted ) {
- this.mStarted = mStarted;
- }
-
- public void increaseCounter() {
- ++mCounter;
- }
-
- public boolean isEnd() {
- return mCounter >= 27;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/collection/ArrayMap.java b/skin/skin-support/src/main/java/skin/support/collection/ArrayMap.java
deleted file mode 100755
index e7bcb00bda..0000000000
--- a/skin/skin-support/src/main/java/skin/support/collection/ArrayMap.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package skin.support.collection;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-public class ArrayMap extends SimpleArrayMap implements Map {
- MapCollections mCollections;
-
- public ArrayMap() {
- super();
- }
-
- /**
- * Create a new ArrayMap with a given initial capacity.
- */
- public ArrayMap(int capacity) {
- super(capacity);
- }
-
- /**
- * Create a new ArrayMap with the mappings from the given ArrayMap.
- */
- public ArrayMap(SimpleArrayMap map) {
- super(map);
- }
-
- private MapCollections getCollection() {
- if (mCollections == null) {
- mCollections = new MapCollections() {
- @Override
- protected int colGetSize() {
- return mSize;
- }
-
- @Override
- protected Object colGetEntry(int index, int offset) {
- return mArray[(index<<1) + offset];
- }
-
- @Override
- protected int colIndexOfKey(Object key) {
- return indexOfKey(key);
- }
-
- @Override
- protected int colIndexOfValue(Object value) {
- return indexOfValue(value);
- }
-
- @Override
- protected Map colGetMap() {
- return ArrayMap.this;
- }
-
- @Override
- protected void colPut(K key, V value) {
- put(key, value);
- }
-
- @Override
- protected V colSetValue(int index, V value) {
- return setValueAt(index, value);
- }
-
- @Override
- protected void colRemoveAt(int index) {
- removeAt(index);
- }
-
- @Override
- protected void colClear() {
- clear();
- }
- };
- }
- return mCollections;
- }
-
- /**
- * Determine if the array map contains all of the keys in the given collection.
- * @param collection The collection whose contents are to be checked against.
- * @return Returns true if this array map contains a key for every entry
- * in collection, else returns false.
- */
- public boolean containsAll(Collection> collection) {
- return MapCollections.containsAllHelper(this, collection);
- }
-
- /**
- * Perform a {@link #put(Object, Object)} of all key/value pairs in map
- * @param map The map whose contents are to be retrieved.
- */
- @Override
- public void putAll(Map extends K, ? extends V> map) {
- ensureCapacity(mSize + map.size());
- for ( Entry extends K, ? extends V> entry : map.entrySet()) {
- put(entry.getKey(), entry.getValue());
- }
- }
-
- /**
- * Remove all keys in the array map that exist in the given collection.
- * @param collection The collection whose contents are to be used to remove keys.
- * @return Returns true if any keys were removed from the array map, else false.
- */
- public boolean removeAll(Collection> collection) {
- return MapCollections.removeAllHelper(this, collection);
- }
-
- /**
- * Remove all keys in the array map that do not exist in the given collection.
- * @param collection The collection whose contents are to be used to determine which
- * keys to keep.
- * @return Returns true if any keys were removed from the array map, else false.
- */
- public boolean retainAll(Collection> collection) {
- return MapCollections.retainAllHelper(this, collection);
- }
-
- /**
- * Return a {@link Set} for iterating over and interacting with all mappings
- * in the array map.
- *
- *
Note: this is a very inefficient way to access the array contents, it
- * requires generating a number of temporary objects.
- *
- *
Note:
the semantics of this
- * Set are subtly different than that of a {@link java.util.HashMap}: most important,
- * the {@link Entry Map.Entry} object returned by its iterator is a single
- * object that exists for the entire iterator, so you can not hold on to it
- * after calling {@link java.util.Iterator#next() Iterator.next}.
- */
- @Override
- public Set> entrySet() {
- return getCollection().getEntrySet();
- }
-
- /**
- * Return a {@link Set} for iterating over and interacting with all keys
- * in the array map.
- *
- *
Note: this is a fairly inefficient way to access the array contents, it
- * requires generating a number of temporary objects.
- */
- @Override
- public Set keySet() {
- return getCollection().getKeySet();
- }
-
- /**
- * Return a {@link Collection} for iterating over and interacting with all values
- * in the array map.
- *
- *
Note: this is a fairly inefficient way to access the array contents, it
- * requires generating a number of temporary objects.
- */
- @Override
- public Collection values() {
- return getCollection().getValues();
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/collection/ContainerHelpers.java b/skin/skin-support/src/main/java/skin/support/collection/ContainerHelpers.java
deleted file mode 100755
index d725ec060c..0000000000
--- a/skin/skin-support/src/main/java/skin/support/collection/ContainerHelpers.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package skin.support.collection;
-
-class ContainerHelpers {
- static final int[] EMPTY_INTS = new int[0];
- static final long[] EMPTY_LONGS = new long[0];
- static final Object[] EMPTY_OBJECTS = new Object[0];
-
- public static int idealIntArraySize(int need) {
- return idealByteArraySize(need * 4) / 4;
- }
-
- public static int idealLongArraySize(int need) {
- return idealByteArraySize(need * 8) / 8;
- }
-
- public static int idealByteArraySize(int need) {
- for (int i = 4; i < 32; i++)
- if (need <= (1 << i) - 12)
- return (1 << i) - 12;
-
- return need;
- }
-
- public static boolean equal(Object a, Object b) {
- return a == b || (a != null && a.equals(b));
- }
-
- // This is Arrays.binarySearch(), but doesn't do any argument validation.
- static int binarySearch(int[] array, int size, int value) {
- int lo = 0;
- int hi = size - 1;
-
- while (lo <= hi) {
- int mid = (lo + hi) >>> 1;
- int midVal = array[mid];
-
- if (midVal < value) {
- lo = mid + 1;
- } else if (midVal > value) {
- hi = mid - 1;
- } else {
- return mid; // value found
- }
- }
- return ~lo; // value not present
- }
-
- static int binarySearch(long[] array, int size, long value) {
- int lo = 0;
- int hi = size - 1;
-
- while (lo <= hi) {
- final int mid = (lo + hi) >>> 1;
- final long midVal = array[mid];
-
- if (midVal < value) {
- lo = mid + 1;
- } else if (midVal > value) {
- hi = mid - 1;
- } else {
- return mid; // value found
- }
- }
- return ~lo; // value not present
- }
-
- private ContainerHelpers() {
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/collection/MapCollections.java b/skin/skin-support/src/main/java/skin/support/collection/MapCollections.java
deleted file mode 100755
index cf0f5b07da..0000000000
--- a/skin/skin-support/src/main/java/skin/support/collection/MapCollections.java
+++ /dev/null
@@ -1,554 +0,0 @@
-package skin.support.collection;
-
-import java.lang.reflect.Array;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-abstract class MapCollections {
- EntrySet mEntrySet;
- KeySet mKeySet;
- ValuesCollection mValues;
-
- final class ArrayIterator implements Iterator {
- final int mOffset;
- int mSize;
- int mIndex;
- boolean mCanRemove = false;
-
- ArrayIterator(int offset) {
- mOffset = offset;
- mSize = colGetSize();
- }
-
- @Override
- public boolean hasNext() {
- return mIndex < mSize;
- }
-
- @Override
- public T next() {
- if (!hasNext()) throw new NoSuchElementException();
- Object res = colGetEntry(mIndex, mOffset);
- mIndex++;
- mCanRemove = true;
- return (T) res;
- }
-
- @Override
- public void remove() {
- if (!mCanRemove) {
- throw new IllegalStateException();
- }
- mIndex--;
- mSize--;
- mCanRemove = false;
- colRemoveAt(mIndex);
- }
- }
-
- final class MapIterator implements Iterator>, Map.Entry {
- int mEnd;
- int mIndex;
- boolean mEntryValid = false;
-
- MapIterator() {
- mEnd = colGetSize() - 1;
- mIndex = -1;
- }
-
- @Override
- public boolean hasNext() {
- return mIndex < mEnd;
- }
-
- @Override
- public Map.Entry next() {
- if (!hasNext()) throw new NoSuchElementException();
- mIndex++;
- mEntryValid = true;
- return this;
- }
-
- @Override
- public void remove() {
- if (!mEntryValid) {
- throw new IllegalStateException();
- }
- colRemoveAt(mIndex);
- mIndex--;
- mEnd--;
- mEntryValid = false;
- }
-
- @Override
- public K getKey() {
- if (!mEntryValid) {
- throw new IllegalStateException(
- "This container does not support retaining Map.Entry objects");
- }
- return (K) colGetEntry(mIndex, 0);
- }
-
- @Override
- public V getValue() {
- if (!mEntryValid) {
- throw new IllegalStateException(
- "This container does not support retaining Map.Entry objects");
- }
- return (V) colGetEntry(mIndex, 1);
- }
-
- @Override
- public V setValue(V object) {
- if (!mEntryValid) {
- throw new IllegalStateException(
- "This container does not support retaining Map.Entry objects");
- }
- return colSetValue(mIndex, object);
- }
-
- @Override
- public boolean equals(Object o) {
- if (!mEntryValid) {
- throw new IllegalStateException(
- "This container does not support retaining Map.Entry objects");
- }
- if (!(o instanceof Map.Entry)) {
- return false;
- }
- Map.Entry, ?> e = (Map.Entry, ?>) o;
- return ContainerHelpers.equal(e.getKey(), colGetEntry(mIndex, 0))
- && ContainerHelpers.equal(e.getValue(), colGetEntry(mIndex, 1));
- }
-
- @Override
- public int hashCode() {
- if (!mEntryValid) {
- throw new IllegalStateException(
- "This container does not support retaining Map.Entry objects");
- }
- final Object key = colGetEntry(mIndex, 0);
- final Object value = colGetEntry(mIndex, 1);
- return (key == null ? 0 : key.hashCode()) ^
- (value == null ? 0 : value.hashCode());
- }
-
- @Override
- public String toString() {
- return getKey() + "=" + getValue();
- }
- }
-
- final class EntrySet implements Set> {
- @Override
- public boolean add(Map.Entry object) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addAll(Collection extends Map.Entry> collection) {
- int oldSize = colGetSize();
- for (Map.Entry entry : collection) {
- colPut(entry.getKey(), entry.getValue());
- }
- return oldSize != colGetSize();
- }
-
- @Override
- public void clear() {
- colClear();
- }
-
- @Override
- public boolean contains(Object o) {
- if (!(o instanceof Map.Entry))
- return false;
- Map.Entry, ?> e = (Map.Entry, ?>) o;
- int index = colIndexOfKey(e.getKey());
- if (index < 0) {
- return false;
- }
- Object foundVal = colGetEntry(index, 1);
- return ContainerHelpers.equal(foundVal, e.getValue());
- }
-
- @Override
- public boolean containsAll(Collection> collection) {
- Iterator> it = collection.iterator();
- while (it.hasNext()) {
- if (!contains(it.next())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean isEmpty() {
- return colGetSize() == 0;
- }
-
- @Override
- public Iterator> iterator() {
- return new MapIterator();
- }
-
- @Override
- public boolean remove(Object object) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean removeAll(Collection> collection) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean retainAll(Collection> collection) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int size() {
- return colGetSize();
- }
-
- @Override
- public Object[] toArray() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public T[] toArray(T[] array) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean equals(Object object) {
- return equalsSetHelper(this, object);
- }
-
- @Override
- public int hashCode() {
- int result = 0;
- for (int i = colGetSize() - 1; i >= 0; i--) {
- final Object key = colGetEntry(i, 0);
- final Object value = colGetEntry(i, 1);
- result += ((key == null ? 0 : key.hashCode()) ^
- (value == null ? 0 : value.hashCode()));
- }
- return result;
- }
- }
-
- ;
-
- final class KeySet implements Set {
-
- @Override
- public boolean add(K object) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addAll(Collection extends K> collection) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clear() {
- colClear();
- }
-
- @Override
- public boolean contains(Object object) {
- return colIndexOfKey(object) >= 0;
- }
-
- @Override
- public boolean containsAll(Collection> collection) {
- return containsAllHelper(colGetMap(), collection);
- }
-
- @Override
- public boolean isEmpty() {
- return colGetSize() == 0;
- }
-
- @Override
- public Iterator iterator() {
- return new ArrayIterator(0);
- }
-
- @Override
- public boolean remove(Object object) {
- int index = colIndexOfKey(object);
- if (index >= 0) {
- colRemoveAt(index);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean removeAll(Collection> collection) {
- return removeAllHelper(colGetMap(), collection);
- }
-
- @Override
- public boolean retainAll(Collection> collection) {
- return retainAllHelper(colGetMap(), collection);
- }
-
- @Override
- public int size() {
- return colGetSize();
- }
-
- @Override
- public Object[] toArray() {
- return toArrayHelper(0);
- }
-
- @Override
- public T[] toArray(T[] array) {
- return toArrayHelper(array, 0);
- }
-
- @Override
- public boolean equals(Object object) {
- return equalsSetHelper(this, object);
- }
-
- @Override
- public int hashCode() {
- int result = 0;
- for (int i = colGetSize() - 1; i >= 0; i--) {
- Object obj = colGetEntry(i, 0);
- result += obj == null ? 0 : obj.hashCode();
- }
- return result;
- }
- }
-
- ;
-
- final class ValuesCollection implements Collection {
-
- @Override
- public boolean add(V object) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean addAll(Collection extends V> collection) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void clear() {
- colClear();
- }
-
- @Override
- public boolean contains(Object object) {
- return colIndexOfValue(object) >= 0;
- }
-
- @Override
- public boolean containsAll(Collection> collection) {
- Iterator> it = collection.iterator();
- while (it.hasNext()) {
- if (!contains(it.next())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean isEmpty() {
- return colGetSize() == 0;
- }
-
- @Override
- public Iterator iterator() {
- return new ArrayIterator(1);
- }
-
- @Override
- public boolean remove(Object object) {
- int index = colIndexOfValue(object);
- if (index >= 0) {
- colRemoveAt(index);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean removeAll(Collection> collection) {
- int N = colGetSize();
- boolean changed = false;
- for (int i = 0; i < N; i++) {
- Object cur = colGetEntry(i, 1);
- if (collection.contains(cur)) {
- colRemoveAt(i);
- i--;
- N--;
- changed = true;
- }
- }
- return changed;
- }
-
- @Override
- public boolean retainAll(Collection> collection) {
- int N = colGetSize();
- boolean changed = false;
- for (int i = 0; i < N; i++) {
- Object cur = colGetEntry(i, 1);
- if (!collection.contains(cur)) {
- colRemoveAt(i);
- i--;
- N--;
- changed = true;
- }
- }
- return changed;
- }
-
- @Override
- public int size() {
- return colGetSize();
- }
-
- @Override
- public Object[] toArray() {
- return toArrayHelper(1);
- }
-
- @Override
- public T[] toArray(T[] array) {
- return toArrayHelper(array, 1);
- }
- }
-
- ;
-
- public static boolean containsAllHelper(Map map, Collection> collection) {
- Iterator> it = collection.iterator();
- while (it.hasNext()) {
- if (!map.containsKey(it.next())) {
- return false;
- }
- }
- return true;
- }
-
- public static boolean removeAllHelper(Map map, Collection> collection) {
- int oldSize = map.size();
- Iterator> it = collection.iterator();
- while (it.hasNext()) {
- map.remove(it.next());
- }
- return oldSize != map.size();
- }
-
- public static boolean retainAllHelper(Map map, Collection> collection) {
- int oldSize = map.size();
- Iterator it = map.keySet().iterator();
- while (it.hasNext()) {
- if (!collection.contains(it.next())) {
- it.remove();
- }
- }
- return oldSize != map.size();
- }
-
-
- public Object[] toArrayHelper(int offset) {
- final int N = colGetSize();
- Object[] result = new Object[N];
- for (int i = 0; i < N; i++) {
- result[i] = colGetEntry(i, offset);
- }
- return result;
- }
-
- public T[] toArrayHelper(T[] array, int offset) {
- final int N = colGetSize();
- if (array.length < N) {
- @SuppressWarnings("unchecked") T[] newArray
- = (T[]) Array.newInstance(array.getClass().getComponentType(), N);
- array = newArray;
- }
- for (int i = 0; i < N; i++) {
- array[i] = (T) colGetEntry(i, offset);
- }
- if (array.length > N) {
- array[N] = null;
- }
- return array;
- }
-
- public static boolean equalsSetHelper(Set set, Object object) {
- if (set == object) {
- return true;
- }
- if (object instanceof Set) {
- Set> s = (Set>) object;
-
- try {
- return set.size() == s.size() && set.containsAll(s);
- } catch (NullPointerException ignored) {
- return false;
- } catch (ClassCastException ignored) {
- return false;
- }
- }
- return false;
- }
-
- public Set> getEntrySet() {
- if (mEntrySet == null) {
- mEntrySet = new EntrySet();
- }
- return mEntrySet;
- }
-
- public Set getKeySet() {
- if (mKeySet == null) {
- mKeySet = new KeySet();
- }
- return mKeySet;
- }
-
- public Collection getValues() {
- if (mValues == null) {
- mValues = new ValuesCollection();
- }
- return mValues;
- }
-
- protected abstract int colGetSize();
-
- protected abstract Object colGetEntry(int index, int offset);
-
- protected abstract int colIndexOfKey(Object key);
-
- protected abstract int colIndexOfValue(Object key);
-
- protected abstract Map colGetMap();
-
- protected abstract void colPut(K key, V value);
-
- protected abstract V colSetValue(int index, V value);
-
- protected abstract void colRemoveAt(int index);
-
- protected abstract void colClear();
-}
diff --git a/skin/skin-support/src/main/java/skin/support/collection/SimpleArrayMap.java b/skin/skin-support/src/main/java/skin/support/collection/SimpleArrayMap.java
deleted file mode 100755
index 6d17701ee5..0000000000
--- a/skin/skin-support/src/main/java/skin/support/collection/SimpleArrayMap.java
+++ /dev/null
@@ -1,682 +0,0 @@
-package skin.support.collection;
-
-import java.util.ConcurrentModificationException;
-import java.util.Map;
-
-public class SimpleArrayMap {
- private static final boolean DEBUG = false;
- private static final String TAG = "ArrayMap";
-
- /**
- * Attempt to spot concurrent modifications to this data structure.
- *
- * It's best-effort, but any time we can throw something more diagnostic than an
- * ArrayIndexOutOfBoundsException deep in the ArrayMap internals it's going to
- * save a lot of development time.
- *
- * Good times to look for CME include after any allocArrays() call and at the end of
- * functions that change mSize (put/remove/clear).
- */
- private static final boolean CONCURRENT_MODIFICATION_EXCEPTIONS = true;
-
- /**
- * The minimum amount by which the capacity of a ArrayMap will increase.
- * This is tuned to be relatively space-efficient.
- */
- private static final int BASE_SIZE = 4;
-
- /**
- * Maximum number of entries to have in array caches.
- */
- private static final int CACHE_SIZE = 10;
-
- /**
- * Caches of small array objects to avoid spamming garbage. The cache
- * Object[] variable is a pointer to a linked list of array objects.
- * The first entry in the array is a pointer to the next array in the
- * list; the second entry is a pointer to the int[] hash code array for it.
- */
- static Object[] mBaseCache;
- static int mBaseCacheSize;
- static Object[] mTwiceBaseCache;
- static int mTwiceBaseCacheSize;
-
- int[] mHashes;
- Object[] mArray;
- int mSize;
-
- private static int binarySearchHashes(int[] hashes, int N, int hash) {
- try {
- return ContainerHelpers.binarySearch(hashes, N, hash);
- } catch (ArrayIndexOutOfBoundsException e) {
- if (CONCURRENT_MODIFICATION_EXCEPTIONS) {
- throw new ConcurrentModificationException();
- } else {
- throw e; // the cache is poisoned at this point, there's not much we can do
- }
- }
- }
-
- int indexOf(Object key, int hash) {
- final int N = mSize;
-
- // Important fast case: if nothing is in here, nothing to look for.
- if (N == 0) {
- return ~0;
- }
-
- int index = binarySearchHashes(mHashes, N, hash);
-
- // If the hash code wasn't found, then we have no entry for this key.
- if (index < 0) {
- return index;
- }
-
- // If the key at the returned index matches, that's what we want.
- if (key.equals(mArray[index << 1])) {
- return index;
- }
-
- // Search for a matching key after the index.
- int end;
- for (end = index + 1; end < N && mHashes[end] == hash; end++) {
- if (key.equals(mArray[end << 1])) return end;
- }
-
- // Search for a matching key before the index.
- for (int i = index - 1; i >= 0 && mHashes[i] == hash; i--) {
- if (key.equals(mArray[i << 1])) return i;
- }
-
- // Key not found -- return negative value indicating where a
- // new entry for this key should go. We use the end of the
- // hash chain to reduce the number of array entries that will
- // need to be copied when inserting.
- return ~end;
- }
-
- int indexOfNull() {
- final int N = mSize;
-
- // Important fast case: if nothing is in here, nothing to look for.
- if (N == 0) {
- return ~0;
- }
-
- int index = binarySearchHashes(mHashes, N, 0);
-
- // If the hash code wasn't found, then we have no entry for this key.
- if (index < 0) {
- return index;
- }
-
- // If the key at the returned index matches, that's what we want.
- if (null == mArray[index << 1]) {
- return index;
- }
-
- // Search for a matching key after the index.
- int end;
- for (end = index + 1; end < N && mHashes[end] == 0; end++) {
- if (null == mArray[end << 1]) return end;
- }
-
- // Search for a matching key before the index.
- for (int i = index - 1; i >= 0 && mHashes[i] == 0; i--) {
- if (null == mArray[i << 1]) return i;
- }
-
- // Key not found -- return negative value indicating where a
- // new entry for this key should go. We use the end of the
- // hash chain to reduce the number of array entries that will
- // need to be copied when inserting.
- return ~end;
- }
-
- @SuppressWarnings("ArrayToString")
- private void allocArrays(final int size) {
- if (size == (BASE_SIZE * 2)) {
- synchronized (ArrayMap.class) {
- if (mTwiceBaseCache != null) {
- final Object[] array = mTwiceBaseCache;
- mArray = array;
- mTwiceBaseCache = (Object[]) array[0];
- mHashes = (int[]) array[1];
- array[0] = array[1] = null;
- mTwiceBaseCacheSize--;
- if (DEBUG) System.out.println(TAG + " Retrieving 2x cache " + mHashes
- + " now have " + mTwiceBaseCacheSize + " entries");
- return;
- }
- }
- } else if (size == BASE_SIZE) {
- synchronized (ArrayMap.class) {
- if (mBaseCache != null) {
- final Object[] array = mBaseCache;
- mArray = array;
- mBaseCache = (Object[]) array[0];
- mHashes = (int[]) array[1];
- array[0] = array[1] = null;
- mBaseCacheSize--;
- if (DEBUG) System.out.println(TAG + " Retrieving 1x cache " + mHashes
- + " now have " + mBaseCacheSize + " entries");
- return;
- }
- }
- }
-
- mHashes = new int[size];
- mArray = new Object[size << 1];
- }
-
- @SuppressWarnings("ArrayToString")
- private static void freeArrays(final int[] hashes, final Object[] array, final int size) {
- if (hashes.length == (BASE_SIZE * 2)) {
- synchronized (ArrayMap.class) {
- if (mTwiceBaseCacheSize < CACHE_SIZE) {
- array[0] = mTwiceBaseCache;
- array[1] = hashes;
- for (int i = (size << 1) - 1; i >= 2; i--) {
- array[i] = null;
- }
- mTwiceBaseCache = array;
- mTwiceBaseCacheSize++;
- if (DEBUG) System.out.println(TAG + " Storing 2x cache " + array
- + " now have " + mTwiceBaseCacheSize + " entries");
- }
- }
- } else if (hashes.length == BASE_SIZE) {
- synchronized (ArrayMap.class) {
- if (mBaseCacheSize < CACHE_SIZE) {
- array[0] = mBaseCache;
- array[1] = hashes;
- for (int i = (size << 1) - 1; i >= 2; i--) {
- array[i] = null;
- }
- mBaseCache = array;
- mBaseCacheSize++;
- if (DEBUG) System.out.println(TAG + " Storing 1x cache " + array
- + " now have " + mBaseCacheSize + " entries");
- }
- }
- }
- }
-
- /**
- * Create a new empty ArrayMap. The default capacity of an array map is 0, and
- * will grow once items are added to it.
- */
- public SimpleArrayMap() {
- mHashes = ContainerHelpers.EMPTY_INTS;
- mArray = ContainerHelpers.EMPTY_OBJECTS;
- mSize = 0;
- }
-
- /**
- * Create a new ArrayMap with a given initial capacity.
- */
- @SuppressWarnings("NullAway") // allocArrays initializes mHashes and mArray.
- public SimpleArrayMap(int capacity) {
- if (capacity == 0) {
- mHashes = ContainerHelpers.EMPTY_INTS;
- mArray = ContainerHelpers.EMPTY_OBJECTS;
- } else {
- allocArrays(capacity);
- }
- mSize = 0;
- }
-
- /**
- * Create a new ArrayMap with the mappings from the given ArrayMap.
- */
- public SimpleArrayMap(SimpleArrayMap map) {
- this();
- if (map != null) {
- putAll(map);
- }
- }
-
- /**
- * Make the array map empty. All storage is released.
- */
- public void clear() {
- if (mSize > 0) {
- final int[] ohashes = mHashes;
- final Object[] oarray = mArray;
- final int osize = mSize;
- mHashes = ContainerHelpers.EMPTY_INTS;
- mArray = ContainerHelpers.EMPTY_OBJECTS;
- mSize = 0;
- freeArrays(ohashes, oarray, osize);
- }
- if (CONCURRENT_MODIFICATION_EXCEPTIONS && mSize > 0) {
- throw new ConcurrentModificationException();
- }
- }
-
- /**
- * Ensure the array map can hold at least minimumCapacity
- * items.
- */
- public void ensureCapacity(int minimumCapacity) {
- final int osize = mSize;
- if (mHashes.length < minimumCapacity) {
- final int[] ohashes = mHashes;
- final Object[] oarray = mArray;
- allocArrays(minimumCapacity);
- if (mSize > 0) {
- System.arraycopy(ohashes, 0, mHashes, 0, osize);
- System.arraycopy(oarray, 0, mArray, 0, osize << 1);
- }
- freeArrays(ohashes, oarray, osize);
- }
- if (CONCURRENT_MODIFICATION_EXCEPTIONS && mSize != osize) {
- throw new ConcurrentModificationException();
- }
- }
-
- /**
- * Check whether a key exists in the array.
- *
- * @param key The key to search for.
- * @return Returns true if the key exists, else false.
- */
- public boolean containsKey(Object key) {
- return indexOfKey(key) >= 0;
- }
-
- /**
- * Returns the index of a key in the set.
- *
- * @param key The key to search for.
- * @return Returns the index of the key if it exists, else a negative integer.
- */
- public int indexOfKey(Object key) {
- return key == null ? indexOfNull() : indexOf(key, key.hashCode());
- }
-
- int indexOfValue(Object value) {
- final int N = mSize * 2;
- final Object[] array = mArray;
- if (value == null) {
- for (int i = 1; i < N; i += 2) {
- if (array[i] == null) {
- return i >> 1;
- }
- }
- } else {
- for (int i = 1; i < N; i += 2) {
- if (value.equals(array[i])) {
- return i >> 1;
- }
- }
- }
- return -1;
- }
-
- /**
- * Check whether a value exists in the array. This requires a linear search
- * through the entire array.
- *
- * @param value The value to search for.
- * @return Returns true if the value exists, else false.
- */
- public boolean containsValue(Object value) {
- return indexOfValue(value) >= 0;
- }
-
- /**
- * Retrieve a value from the array.
- *
- * @param key The key of the value to retrieve.
- * @return Returns the value associated with the given key,
- * or null if there is no such key.
- */
- public V get(Object key) {
- final int index = indexOfKey(key);
- return index >= 0 ? (V) mArray[(index << 1) + 1] : null;
- }
-
- /**
- * Return the key at the given index in the array.
- *
- * @param index The desired index, must be between 0 and {@link #size()}-1.
- * @return Returns the key stored at the given index.
- */
- public K keyAt(int index) {
- return (K) mArray[index << 1];
- }
-
- /**
- * Return the value at the given index in the array.
- *
- * @param index The desired index, must be between 0 and {@link #size()}-1.
- * @return Returns the value stored at the given index.
- */
- public V valueAt(int index) {
- return (V) mArray[(index << 1) + 1];
- }
-
- /**
- * Set the value at a given index in the array.
- *
- * @param index The desired index, must be between 0 and {@link #size()}-1.
- * @param value The new value to store at this index.
- * @return Returns the previous value at the given index.
- */
- public V setValueAt(int index, V value) {
- index = (index << 1) + 1;
- V old = (V) mArray[index];
- mArray[index] = value;
- return old;
- }
-
- /**
- * Return true if the array map contains no items.
- */
- public boolean isEmpty() {
- return mSize <= 0;
- }
-
- /**
- * Add a new value to the array map.
- *
- * @param key The key under which to store the value. Must not be null. If
- * this key already exists in the array, its value will be replaced.
- * @param value The value to store for the given key.
- * @return Returns the old value that was stored for the given key, or null if there
- * was no such key.
- */
- public V put(K key, V value) {
- final int osize = mSize;
- final int hash;
- int index;
- if (key == null) {
- hash = 0;
- index = indexOfNull();
- } else {
- hash = key.hashCode();
- index = indexOf(key, hash);
- }
- if (index >= 0) {
- index = (index << 1) + 1;
- final V old = (V) mArray[index];
- mArray[index] = value;
- return old;
- }
-
- index = ~index;
- if (osize >= mHashes.length) {
- final int n = osize >= (BASE_SIZE * 2) ? (osize + (osize >> 1))
- : (osize >= BASE_SIZE ? (BASE_SIZE * 2) : BASE_SIZE);
-
- if (DEBUG) System.out.println(TAG + " put: grow from " + mHashes.length + " to " + n);
-
- final int[] ohashes = mHashes;
- final Object[] oarray = mArray;
- allocArrays(n);
-
- if (CONCURRENT_MODIFICATION_EXCEPTIONS && osize != mSize) {
- throw new ConcurrentModificationException();
- }
-
- if (mHashes.length > 0) {
- if (DEBUG) System.out.println(TAG + " put: copy 0-" + osize + " to 0");
- System.arraycopy(ohashes, 0, mHashes, 0, ohashes.length);
- System.arraycopy(oarray, 0, mArray, 0, oarray.length);
- }
-
- freeArrays(ohashes, oarray, osize);
- }
-
- if (index < osize) {
- if (DEBUG) System.out.println(TAG + " put: move " + index + "-" + (osize - index)
- + " to " + (index + 1));
- System.arraycopy(mHashes, index, mHashes, index + 1, osize - index);
- System.arraycopy(mArray, index << 1, mArray, (index + 1) << 1, (mSize - index) << 1);
- }
-
- if (CONCURRENT_MODIFICATION_EXCEPTIONS) {
- if (osize != mSize || index >= mHashes.length) {
- throw new ConcurrentModificationException();
- }
- }
-
- mHashes[index] = hash;
- mArray[index << 1] = key;
- mArray[(index << 1) + 1] = value;
- mSize++;
- return null;
- }
-
- /**
- * Perform a {@link #put(Object, Object)} of all key/value pairs in array
- *
- * @param array The array whose contents are to be retrieved.
- */
- public void putAll(SimpleArrayMap extends K, ? extends V> array) {
- final int N = array.mSize;
- ensureCapacity(mSize + N);
- if (mSize == 0) {
- if (N > 0) {
- System.arraycopy(array.mHashes, 0, mHashes, 0, N);
- System.arraycopy(array.mArray, 0, mArray, 0, N << 1);
- mSize = N;
- }
- } else {
- for (int i = 0; i < N; i++) {
- put(array.keyAt(i), array.valueAt(i));
- }
- }
- }
-
- /**
- * Remove an existing key from the array map.
- *
- * @param key The key of the mapping to remove.
- * @return Returns the value that was stored under the key, or null if there
- * was no such key.
- */
- public V remove(Object key) {
- final int index = indexOfKey(key);
- if (index >= 0) {
- return removeAt(index);
- }
-
- return null;
- }
-
- /**
- * Remove the key/value mapping at the given index.
- *
- * @param index The desired index, must be between 0 and {@link #size()}-1.
- * @return Returns the value that was stored at this index.
- */
- public V removeAt(int index) {
- final Object old = mArray[(index << 1) + 1];
- final int osize = mSize;
- final int nsize;
- if (osize <= 1) {
- // Now empty.
- if (DEBUG) System.out.println(TAG + " remove: shrink from " + mHashes.length + " to 0");
- freeArrays(mHashes, mArray, osize);
- mHashes = ContainerHelpers.EMPTY_INTS;
- mArray = ContainerHelpers.EMPTY_OBJECTS;
- nsize = 0;
- } else {
- nsize = osize - 1;
- if (mHashes.length > (BASE_SIZE * 2) && mSize < mHashes.length / 3) {
- // Shrunk enough to reduce size of arrays. We don't allow it to
- // shrink smaller than (BASE_SIZE*2) to avoid flapping between
- // that and BASE_SIZE.
- final int n = osize > (BASE_SIZE * 2) ? (osize + (osize >> 1)) : (BASE_SIZE * 2);
-
- if (DEBUG)
- System.out.println(TAG + " remove: shrink from " + mHashes.length + " to " + n);
-
- final int[] ohashes = mHashes;
- final Object[] oarray = mArray;
- allocArrays(n);
-
- if (CONCURRENT_MODIFICATION_EXCEPTIONS && osize != mSize) {
- throw new ConcurrentModificationException();
- }
-
- if (index > 0) {
- if (DEBUG) System.out.println(TAG + " remove: copy from 0-" + index + " to 0");
- System.arraycopy(ohashes, 0, mHashes, 0, index);
- System.arraycopy(oarray, 0, mArray, 0, index << 1);
- }
- if (index < nsize) {
- if (DEBUG)
- System.out.println(TAG + " remove: copy from " + (index + 1) + "-" + nsize
- + " to " + index);
- System.arraycopy(ohashes, index + 1, mHashes, index, nsize - index);
- System.arraycopy(oarray, (index + 1) << 1, mArray, index << 1,
- (nsize - index) << 1);
- }
- } else {
- if (index < nsize) {
- if (DEBUG) System.out.println(TAG + " remove: move " + (index + 1) + "-" + nsize
- + " to " + index);
- System.arraycopy(mHashes, index + 1, mHashes, index, nsize - index);
- System.arraycopy(mArray, (index + 1) << 1, mArray, index << 1,
- (nsize - index) << 1);
- }
- mArray[nsize << 1] = null;
- mArray[(nsize << 1) + 1] = null;
- }
- }
- if (CONCURRENT_MODIFICATION_EXCEPTIONS && osize != mSize) {
- throw new ConcurrentModificationException();
- }
- mSize = nsize;
- return (V) old;
- }
-
- /**
- * Return the number of items in this array map.
- */
- public int size() {
- return mSize;
- }
-
- /**
- * {@inheritDoc}
- *
- *
This implementation returns false if the object is not a Map or
- * SimpleArrayMap, or if the maps have different sizes. Otherwise, for each
- * key in this map, values of both maps are compared. If the values for any
- * key are not equal, the method returns false, otherwise it returns true.
- */
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof SimpleArrayMap) {
- SimpleArrayMap, ?> map = (SimpleArrayMap, ?>) object;
- if (size() != map.size()) {
- return false;
- }
-
- try {
- for (int i = 0; i < mSize; i++) {
- K key = keyAt(i);
- V mine = valueAt(i);
- Object theirs = map.get(key);
- if (mine == null) {
- if (theirs != null || !map.containsKey(key)) {
- return false;
- }
- } else if (!mine.equals(theirs)) {
- return false;
- }
- }
- } catch (NullPointerException ignored) {
- return false;
- } catch (ClassCastException ignored) {
- return false;
- }
- return true;
- } else if (object instanceof Map) {
- Map, ?> map = (Map, ?>) object;
- if (size() != map.size()) {
- return false;
- }
-
- try {
- for (int i = 0; i < mSize; i++) {
- K key = keyAt(i);
- V mine = valueAt(i);
- Object theirs = map.get(key);
- if (mine == null) {
- if (theirs != null || !map.containsKey(key)) {
- return false;
- }
- } else if (!mine.equals(theirs)) {
- return false;
- }
- }
- } catch (NullPointerException ignored) {
- return false;
- } catch (ClassCastException ignored) {
- return false;
- }
- return true;
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- final int[] hashes = mHashes;
- final Object[] array = mArray;
- int result = 0;
- for (int i = 0, v = 1, s = mSize; i < s; i++, v += 2) {
- Object value = array[v];
- result += hashes[i] ^ (value == null ? 0 : value.hashCode());
- }
- return result;
- }
-
- /**
- * {@inheritDoc}
- *
- *
This implementation composes a string by iterating over its mappings. If
- * this map contains itself as a key or a value, the string "(this Map)"
- * will appear in its place.
- */
- @Override
- public String toString() {
- if (isEmpty()) {
- return "{}";
- }
-
- StringBuilder buffer = new StringBuilder(mSize * 28);
- buffer.append('{');
- for (int i = 0; i < mSize; i++) {
- if (i > 0) {
- buffer.append(", ");
- }
- Object key = keyAt(i);
- if (key != this) {
- buffer.append(key);
- } else {
- buffer.append("(this Map)");
- }
- buffer.append('=');
- Object value = valueAt(i);
- if (value != this) {
- buffer.append(value);
- } else {
- buffer.append("(this Map)");
- }
- }
- buffer.append('}');
- return buffer.toString();
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/content/res/ColorState.java b/skin/skin-support/src/main/java/skin/support/content/res/ColorState.java
deleted file mode 100755
index 380851589d..0000000000
--- a/skin/skin-support/src/main/java/skin/support/content/res/ColorState.java
+++ /dev/null
@@ -1,600 +0,0 @@
-package skin.support.content.res;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.graphics.Color;
-import android.text.TextUtils;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import skin.support.annotation.ColorRes;
-import skin.support.exception.SkinCompatException;
-import skin.support.utils.Slog;
-
-public final class ColorState {
- private static final String TAG = "ColorState";
- boolean onlyDefaultColor;
- String colorName;
- String colorWindowFocused;
- String colorSelected;
- String colorFocused;
- String colorEnabled;
- String colorPressed;
- String colorChecked;
- String colorActivated;
- String colorAccelerated;
- String colorHovered;
- String colorDragCanAccept;
- String colorDragHovered;
- String colorDefault;
-
- ColorState(String colorWindowFocused, String colorSelected, String colorFocused,
- String colorEnabled, String colorPressed, String colorChecked, String colorActivated,
- String colorAccelerated, String colorHovered, String colorDragCanAccept,
- String colorDragHovered, String colorDefault) {
- this.colorWindowFocused = colorWindowFocused;
- this.colorSelected = colorSelected;
- this.colorFocused = colorFocused;
- this.colorEnabled = colorEnabled;
- this.colorPressed = colorPressed;
- this.colorChecked = colorChecked;
- this.colorActivated = colorActivated;
- this.colorAccelerated = colorAccelerated;
- this.colorHovered = colorHovered;
- this.colorDragCanAccept = colorDragCanAccept;
- this.colorDragHovered = colorDragHovered;
- this.colorDefault = colorDefault;
- this.onlyDefaultColor = TextUtils.isEmpty(colorWindowFocused)
- && TextUtils.isEmpty(colorSelected)
- && TextUtils.isEmpty(colorFocused)
- && TextUtils.isEmpty(colorEnabled)
- && TextUtils.isEmpty(colorPressed)
- && TextUtils.isEmpty(colorChecked)
- && TextUtils.isEmpty(colorActivated)
- && TextUtils.isEmpty(colorAccelerated)
- && TextUtils.isEmpty(colorHovered)
- && TextUtils.isEmpty(colorDragCanAccept)
- && TextUtils.isEmpty(colorDragHovered);
- if (onlyDefaultColor) {
- if (!colorDefault.startsWith("#")) {
- throw new SkinCompatException("Default color cannot be a reference, when only default color is available!");
- }
- }
- }
-
- ColorState(String colorName, String colorDefault) {
- this.colorName = colorName;
- this.colorDefault = colorDefault;
- this.onlyDefaultColor = true;
- if (!colorDefault.startsWith("#")) {
- throw new SkinCompatException("Default color cannot be a reference, when only default color is available!");
- }
- }
-
- public boolean isOnlyDefaultColor() {
- return onlyDefaultColor;
- }
-
- public String getColorName() {
- return colorName;
- }
-
- public String getColorWindowFocused() {
- return colorWindowFocused;
- }
-
- public String getColorSelected() {
- return colorSelected;
- }
-
- public String getColorFocused() {
- return colorFocused;
- }
-
- public String getColorEnabled() {
- return colorEnabled;
- }
-
- public String getColorPressed() {
- return colorPressed;
- }
-
- public String getColorChecked() {
- return colorChecked;
- }
-
- public String getColorActivated() {
- return colorActivated;
- }
-
- public String getColorAccelerated() {
- return colorAccelerated;
- }
-
- public String getColorHovered() {
- return colorHovered;
- }
-
- public String getColorDragCanAccept() {
- return colorDragCanAccept;
- }
-
- public String getColorDragHovered() {
- return colorDragHovered;
- }
-
- public String getColorDefault() {
- return colorDefault;
- }
-
- ColorStateList parse() {
- if (onlyDefaultColor) {
- int defaultColor = Color.parseColor(colorDefault);
- return ColorStateList.valueOf(defaultColor);
- }
- return parseAll();
- }
-
- private ColorStateList parseAll() {
- int stateColorCount = 0;
- List stateSetList = new ArrayList<>();
- List stateColorList = new ArrayList<>();
- if (!TextUtils.isEmpty(colorWindowFocused)) {
- try {
- String windowFocusedColorStr = getColorStr(colorWindowFocused);
- if (!TextUtils.isEmpty(windowFocusedColorStr)) {
- int windowFocusedColorInt = Color.parseColor(windowFocusedColorStr);
- stateSetList.add(SkinCompatThemeUtils.WINDOW_FOCUSED_STATE_SET);
- stateColorList.add(windowFocusedColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorSelected)) {
- try {
- String colorSelectedStr = getColorStr(colorSelected);
- if (!TextUtils.isEmpty(colorSelectedStr)) {
- int selectedColorInt = Color.parseColor(colorSelectedStr);
- stateSetList.add(SkinCompatThemeUtils.SELECTED_STATE_SET);
- stateColorList.add(selectedColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorFocused)) {
- try {
- String colorFocusedStr = getColorStr(colorFocused);
- if (!TextUtils.isEmpty(colorFocusedStr)) {
- int focusedColorInt = Color.parseColor(colorFocusedStr);
- stateSetList.add(SkinCompatThemeUtils.FOCUSED_STATE_SET);
- stateColorList.add(focusedColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorEnabled)) {
- try {
- String colorEnabledStr = getColorStr(colorEnabled);
- if (!TextUtils.isEmpty(colorEnabledStr)) {
- int enabledColorInt = Color.parseColor(colorEnabledStr);
- stateSetList.add(SkinCompatThemeUtils.ENABLED_STATE_SET);
- stateColorList.add(enabledColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorPressed)) {
- try {
- String colorPressedStr = getColorStr(colorPressed);
- if (!TextUtils.isEmpty(colorPressedStr)) {
- int pressedColorInt = Color.parseColor(colorPressedStr);
- stateSetList.add(SkinCompatThemeUtils.PRESSED_STATE_SET);
- stateColorList.add(pressedColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorChecked)) {
- try {
- String colorCheckedStr = getColorStr(colorChecked);
- if (!TextUtils.isEmpty(colorCheckedStr)) {
- int checkedColorInt = Color.parseColor(colorCheckedStr);
- stateSetList.add(SkinCompatThemeUtils.CHECKED_STATE_SET);
- stateColorList.add(checkedColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorActivated)) {
- try {
- String colorActivatedStr = getColorStr(colorActivated);
- if (!TextUtils.isEmpty(colorActivatedStr)) {
- int activatedColorInt = Color.parseColor(colorActivatedStr);
- stateSetList.add(SkinCompatThemeUtils.ACTIVATED_STATE_SET);
- stateColorList.add(activatedColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorAccelerated)) {
- try {
- String colorAcceleratedStr = getColorStr(colorAccelerated);
- if (!TextUtils.isEmpty(colorAcceleratedStr)) {
- int acceleratedColorInt = Color.parseColor(colorAcceleratedStr);
- stateSetList.add(SkinCompatThemeUtils.ACCELERATED_STATE_SET);
- stateColorList.add(acceleratedColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorHovered)) {
- try {
- String colorHoveredStr = getColorStr(colorHovered);
- if (!TextUtils.isEmpty(colorHoveredStr)) {
- int hoveredColorInt = Color.parseColor(colorHoveredStr);
- stateSetList.add(SkinCompatThemeUtils.HOVERED_STATE_SET);
- stateColorList.add(hoveredColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorDragCanAccept)) {
- try {
- String colorDragCanAcceptStr = getColorStr(colorDragCanAccept);
- if (!TextUtils.isEmpty(colorDragCanAcceptStr)) {
- int dragCanAcceptColorInt = Color.parseColor(colorDragCanAcceptStr);
- stateSetList.add(SkinCompatThemeUtils.DRAG_CAN_ACCEPT_STATE_SET);
- stateColorList.add(dragCanAcceptColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- if (!TextUtils.isEmpty(colorDragHovered)) {
- try {
- String colorDragHoveredStr = getColorStr(colorDragHovered);
- if (!TextUtils.isEmpty(colorDragHoveredStr)) {
- int dragHoveredColorInt = Color.parseColor(colorDragHoveredStr);
- stateSetList.add(SkinCompatThemeUtils.DRAG_HOVERED_STATE_SET);
- stateColorList.add(dragHoveredColorInt);
- stateColorCount++;
- }
- } catch (Exception e) {
- }
- }
- try {
- String colorDefaultStr = getColorStr(colorDefault);
- if (!TextUtils.isEmpty(colorDefaultStr)) {
- int baseColor = Color.parseColor(colorDefaultStr);
- stateSetList.add(SkinCompatThemeUtils.EMPTY_STATE_SET);
- stateColorList.add(baseColor);
- stateColorCount++;
- }
-
- final int[][] states = new int[stateColorCount][];
- final int[] colors = new int[stateColorCount];
- for (int index = 0; index < stateColorCount; index++) {
- states[index] = stateSetList.get(index);
- colors[index] = stateColorList.get(index);
- }
- return new ColorStateList(states, colors);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, colorName + " parse failure.");
- }
- SkinCompatUserThemeManager.get().removeColorState(colorName);
- return null;
- }
- }
-
- private String getColorStr(String colorName) {
- if (colorName.startsWith("#")) {
- return colorName;
- } else {
- ColorState stateRef = SkinCompatUserThemeManager.get().getColorState(colorName);
- if (stateRef != null) {
- if (stateRef.isOnlyDefaultColor()) {
- return stateRef.colorDefault;
- } else {
- if (Slog.DEBUG) {
- Slog.i(TAG, colorName + " cannot reference " + stateRef.colorName);
- }
- }
- }
- }
- return null;
- }
-
- static boolean checkColorValid(String name, String color) {
- // 不为空
- boolean colorValid = !TextUtils.isEmpty(color)
- // 不以#开始,说明是引用其他颜色值 或者以#开始,则长度必须为7或9
- && (!color.startsWith("#") || color.length() == 7 || color.length() == 9);
- if (Slog.DEBUG && !colorValid) {
- Slog.i(TAG, "Invalid color -> " + name + ": " + color);
- }
- return colorValid;
- }
-
- static JSONObject toJSONObject(ColorState state) throws JSONException {
- JSONObject object = new JSONObject();
- if (state.onlyDefaultColor) {
- object.putOpt("colorName", state.colorName)
- .putOpt("colorDefault", state.colorDefault)
- .putOpt("onlyDefaultColor", state.onlyDefaultColor);
- } else {
- object.putOpt("colorName", state.colorName)
- .putOpt("colorWindowFocused", state.colorWindowFocused)
- .putOpt("colorSelected", state.colorSelected)
- .putOpt("colorFocused", state.colorFocused)
- .putOpt("colorEnabled", state.colorEnabled)
- .putOpt("colorPressed", state.colorPressed)
- .putOpt("colorChecked", state.colorChecked)
- .putOpt("colorActivated", state.colorActivated)
- .putOpt("colorAccelerated", state.colorAccelerated)
- .putOpt("colorHovered", state.colorHovered)
- .putOpt("colorDragCanAccept", state.colorDragCanAccept)
- .putOpt("colorDragHovered", state.colorDragHovered)
- .putOpt("colorDefault", state.colorDefault)
- .putOpt("onlyDefaultColor", state.onlyDefaultColor);
- }
- return object;
- }
-
- static ColorState fromJSONObject(JSONObject jsonObject) {
- if (jsonObject.has("colorName")
- && jsonObject.has("colorDefault")
- && jsonObject.has("onlyDefaultColor")) {
- try {
- boolean onlyDefaultColor = jsonObject.getBoolean("onlyDefaultColor");
- String colorName = jsonObject.getString("colorName");
- String colorDefault = jsonObject.getString("colorDefault");
- if (onlyDefaultColor) {
- return new ColorState(colorName, colorDefault);
- } else {
- ColorBuilder builder = new ColorBuilder();
- builder.setColorDefault(colorDefault);
- if (jsonObject.has("colorWindowFocused")) {
- builder.setColorWindowFocused(jsonObject.getString("colorWindowFocused"));
- }
- if (jsonObject.has("colorSelected")) {
- builder.setColorSelected(jsonObject.getString("colorSelected"));
- }
- if (jsonObject.has("colorFocused")) {
- builder.setColorFocused(jsonObject.getString("colorFocused"));
- }
- if (jsonObject.has("colorEnabled")) {
- builder.setColorEnabled(jsonObject.getString("colorEnabled"));
- }
- if (jsonObject.has("colorPressed")) {
- builder.setColorPressed(jsonObject.getString("colorPressed"));
- }
- if (jsonObject.has("colorChecked")) {
- builder.setColorChecked(jsonObject.getString("colorChecked"));
- }
- if (jsonObject.has("colorActivated")) {
- builder.setColorActivated(jsonObject.getString("colorActivated"));
- }
- if (jsonObject.has("colorAccelerated")) {
- builder.setColorAccelerated(jsonObject.getString("colorAccelerated"));
- }
- if (jsonObject.has("colorHovered")) {
- builder.setColorHovered(jsonObject.getString("colorHovered"));
- }
- if (jsonObject.has("colorDragCanAccept")) {
- builder.setColorDragCanAccept(jsonObject.getString("colorDragCanAccept"));
- }
- if (jsonObject.has("colorDragHovered")) {
- builder.setColorDragHovered(jsonObject.getString("colorDragHovered"));
- }
- ColorState state = builder.build();
- state.colorName = colorName;
- return state;
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- return null;
- }
-
- public static class ColorBuilder {
- String colorWindowFocused;
- String colorSelected;
- String colorFocused;
- String colorEnabled;
- String colorPressed;
- String colorChecked;
- String colorActivated;
- String colorAccelerated;
- String colorHovered;
- String colorDragCanAccept;
- String colorDragHovered;
- String colorDefault;
-
- public ColorBuilder() {
- }
-
- public ColorBuilder(ColorState state) {
- colorWindowFocused = state.colorWindowFocused;
- colorSelected = state.colorSelected;
- colorFocused = state.colorFocused;
- colorEnabled = state.colorEnabled;
- colorPressed = state.colorPressed;
- colorChecked = state.colorChecked;
- colorActivated = state.colorActivated;
- colorAccelerated = state.colorAccelerated;
- colorHovered = state.colorHovered;
- colorDragCanAccept = state.colorDragCanAccept;
- colorDragHovered = state.colorDragHovered;
- colorDefault = state.colorDefault;
- }
-
- public ColorBuilder setColorWindowFocused(String colorWindowFocused) {
- if (checkColorValid("colorWindowFocused", colorWindowFocused)) {
- this.colorWindowFocused = colorWindowFocused;
- }
- return this;
-
- }
-
- public ColorBuilder setColorWindowFocused(Context context, @ColorRes int colorRes) {
- this.colorWindowFocused = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorSelected(String colorSelected) {
- if (checkColorValid("colorSelected", colorSelected)) {
- this.colorSelected = colorSelected;
- }
- return this;
- }
-
- public ColorBuilder setColorSelected(Context context, @ColorRes int colorRes) {
- this.colorSelected = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorFocused(String colorFocused) {
- if (checkColorValid("colorFocused", colorFocused)) {
- this.colorFocused = colorFocused;
- }
- return this;
- }
-
- public ColorBuilder setColorFocused(Context context, @ColorRes int colorRes) {
- this.colorFocused = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorEnabled(String colorEnabled) {
- if (checkColorValid("colorEnabled", colorEnabled)) {
- this.colorEnabled = colorEnabled;
- }
- return this;
- }
-
- public ColorBuilder setColorEnabled(Context context, @ColorRes int colorRes) {
- this.colorEnabled = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorChecked(String colorChecked) {
- if (checkColorValid("colorChecked", colorChecked)) {
- this.colorChecked = colorChecked;
- }
- return this;
- }
-
- public ColorBuilder setColorChecked(Context context, @ColorRes int colorRes) {
- this.colorChecked = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorPressed(String colorPressed) {
- if (checkColorValid("colorPressed", colorPressed)) {
- this.colorPressed = colorPressed;
- }
- return this;
- }
-
- public ColorBuilder setColorPressed(Context context, @ColorRes int colorRes) {
- this.colorPressed = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorActivated(String colorActivated) {
- if (checkColorValid("colorActivated", colorActivated)) {
- this.colorActivated = colorActivated;
- }
- return this;
- }
-
- public ColorBuilder setColorActivated(Context context, @ColorRes int colorRes) {
- this.colorActivated = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorAccelerated(String colorAccelerated) {
- if (checkColorValid("colorAccelerated", colorAccelerated)) {
- this.colorAccelerated = colorAccelerated;
- }
- return this;
- }
-
- public ColorBuilder setColorAccelerated(Context context, @ColorRes int colorRes) {
- this.colorAccelerated = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorHovered(String colorHovered) {
- if (checkColorValid("colorHovered", colorHovered)) {
- this.colorHovered = colorHovered;
- }
- return this;
- }
-
- public ColorBuilder setColorHovered(Context context, @ColorRes int colorRes) {
- this.colorHovered = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorDragCanAccept(String colorDragCanAccept) {
- if (checkColorValid("colorDragCanAccept", colorDragCanAccept)) {
- this.colorDragCanAccept = colorDragCanAccept;
- }
- return this;
- }
-
- public ColorBuilder setColorDragCanAccept(Context context, @ColorRes int colorRes) {
- this.colorDragCanAccept = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorDragHovered(String colorDragHovered) {
- if (checkColorValid("colorDragHovered", colorDragHovered)) {
- this.colorDragHovered = colorDragHovered;
- }
- return this;
- }
-
- public ColorBuilder setColorDragHovered(Context context, @ColorRes int colorRes) {
- this.colorDragHovered = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorBuilder setColorDefault(String colorDefault) {
- if (checkColorValid("colorDefault", colorDefault)) {
- this.colorDefault = colorDefault;
- }
- return this;
- }
-
- public ColorBuilder setColorDefault(Context context, @ColorRes int colorRes) {
- this.colorDefault = context.getResources().getResourceEntryName(colorRes);
- return this;
- }
-
- public ColorState build() {
- if (TextUtils.isEmpty(colorDefault)) {
- throw new SkinCompatException("Default color can not empty!");
- }
- return new ColorState(colorWindowFocused, colorSelected, colorFocused,
- colorEnabled, colorPressed, colorChecked, colorActivated, colorAccelerated,
- colorHovered, colorDragCanAccept, colorDragHovered, colorDefault);
- }
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java b/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java
deleted file mode 100755
index fd1fce8830..0000000000
--- a/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package skin.support.content.res;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.content.res.XmlResourceParser;
-import android.graphics.drawable.ColorDrawable;
-import android.graphics.drawable.Drawable;
-
-import android.os.Build;
-import android.text.TextUtils;
-import android.util.TypedValue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import skin.support.SkinCompatManager;
-import skin.support.annotation.AnyRes;
-
-public class SkinCompatResources {
- private static volatile SkinCompatResources sInstance;
- private Resources mResources;
- private String mSkinPkgName = "";
- private String mSkinName = "";
- private SkinCompatManager.SkinLoaderStrategy mStrategy;
- private boolean isDefaultSkin = true;
- private List mSkinResources = new ArrayList<>();
-
- private SkinCompatResources() {
- }
-
- public static SkinCompatResources getInstance() {
- if (sInstance == null) {
- synchronized (SkinCompatResources.class) {
- if (sInstance == null) {
- sInstance = new SkinCompatResources();
- }
- }
- }
- return sInstance;
- }
-
- void addSkinResources(SkinResources resources) {
- mSkinResources.add(resources);
- }
-
- public void reset() {
- reset(SkinCompatManager.getInstance().getStrategies().get(SkinCompatManager.SKIN_LOADER_STRATEGY_NONE));
- }
-
- public void reset(SkinCompatManager.SkinLoaderStrategy strategy) {
- mResources = SkinCompatManager.getInstance().getContext().getResources();
- mSkinPkgName = "";
- mSkinName = "";
- mStrategy = strategy;
- isDefaultSkin = true;
- SkinCompatUserThemeManager.get().clearCaches();
- for (SkinResources skinResources : mSkinResources) {
- skinResources.clear();
- }
- }
-
- public void setupSkin(Resources resources, String pkgName, String skinName, SkinCompatManager.SkinLoaderStrategy strategy) {
- if (resources == null || TextUtils.isEmpty(pkgName) || TextUtils.isEmpty(skinName)) {
- reset(strategy);
- return;
- }
- mResources = resources;
- mSkinPkgName = pkgName;
- mSkinName = skinName;
- mStrategy = strategy;
- isDefaultSkin = false;
- SkinCompatUserThemeManager.get().clearCaches();
- for (SkinResources skinResources : mSkinResources) {
- skinResources.clear();
- }
- }
-
- public Resources getSkinResources() {
- return mResources;
- }
-
- public String getSkinPkgName() {
- return mSkinPkgName;
- }
-
- public SkinCompatManager.SkinLoaderStrategy getStrategy() {
- return mStrategy;
- }
-
- public boolean isDefaultSkin() {
- return isDefaultSkin;
- }
-
- @Deprecated
- public int getColor(int resId) {
- return getColor(SkinCompatManager.getInstance().getContext(), resId);
- }
-
- @Deprecated
- public Drawable getDrawable(int resId) {
- return getDrawable(SkinCompatManager.getInstance().getContext(), resId);
- }
-
- @Deprecated
- public ColorStateList getColorStateList(int resId) {
- return getColorStateList(SkinCompatManager.getInstance().getContext(), resId);
- }
-
- public int getTargetResId(Context context, int resId) {
- try {
- String resName = null;
- if (mStrategy != null) {
- resName = mStrategy.getTargetResourceEntryName(context, mSkinName, resId);
- }
- if (TextUtils.isEmpty(resName)) {
- resName = context.getResources().getResourceEntryName(resId);
- }
- String type = context.getResources().getResourceTypeName(resId);
- return mResources.getIdentifier(resName, type, mSkinPkgName);
- } catch (Exception e) {
- // 换肤失败不至于应用崩溃.
- return 0;
- }
- }
-
- private int getSkinColor(Context context, int resId) {
- if (!SkinCompatUserThemeManager.get().isColorEmpty()) {
- ColorStateList colorStateList = SkinCompatUserThemeManager.get().getColorStateList(resId);
- if (colorStateList != null) {
- return colorStateList.getDefaultColor();
- }
- }
- if (mStrategy != null) {
- ColorStateList colorStateList = mStrategy.getColor(context, mSkinName, resId);
- if (colorStateList != null) {
- return colorStateList.getDefaultColor();
- }
- }
- if (!isDefaultSkin) {
- int targetResId = getTargetResId(context, resId);
- if (targetResId != 0) {
- return mResources.getColor(targetResId);
- }
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- return context.getResources().getColor(resId, context.getTheme());
- }
- return context.getResources().getColor(resId);
- }
-
- private ColorStateList getSkinColorStateList(Context context, int resId) {
- if (!SkinCompatUserThemeManager.get().isColorEmpty()) {
- ColorStateList colorStateList = SkinCompatUserThemeManager.get().getColorStateList(resId);
- if (colorStateList != null) {
- return colorStateList;
- }
- }
- if (mStrategy != null) {
- ColorStateList colorStateList = mStrategy.getColorStateList(context, mSkinName, resId);
- if (colorStateList != null) {
- return colorStateList;
- }
- }
- if (!isDefaultSkin) {
- int targetResId = getTargetResId(context, resId);
- if (targetResId != 0) {
- return mResources.getColorStateList(targetResId);
- }
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- return context.getResources().getColorStateList(resId, context.getTheme());
- }
- return context.getResources().getColorStateList(resId);
- }
-
- private Drawable getSkinDrawable(Context context, int resId) {
- if (!SkinCompatUserThemeManager.get().isColorEmpty()) {
- ColorStateList colorStateList = SkinCompatUserThemeManager.get().getColorStateList(resId);
- if (colorStateList != null) {
- return new ColorDrawable(colorStateList.getDefaultColor());
- }
- }
- if (!SkinCompatUserThemeManager.get().isDrawableEmpty()) {
- Drawable drawable = SkinCompatUserThemeManager.get().getDrawable(resId);
- if (drawable != null) {
- return drawable;
- }
- }
- if (mStrategy != null) {
- Drawable drawable = mStrategy.getDrawable(context, mSkinName, resId);
- if (drawable != null) {
- return drawable;
- }
- }
- if (!isDefaultSkin) {
- int targetResId = getTargetResId(context, resId);
- if (targetResId != 0) {
- return mResources.getDrawable(targetResId);
- }
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- return context.getResources().getDrawable(resId, context.getTheme());
- }
- return context.getResources().getDrawable(resId);
- }
-
- Drawable getStrategyDrawable(Context context, int resId) {
- if (mStrategy != null) {
- return mStrategy.getDrawable(context, mSkinName, resId);
- }
- return null;
- }
-
- private XmlResourceParser getSkinXml(Context context, int resId) {
- if (!isDefaultSkin) {
- int targetResId = getTargetResId(context, resId);
- if (targetResId != 0) {
- return mResources.getXml(targetResId);
- }
- }
- return context.getResources().getXml(resId);
- }
-
- private void getSkinValue(Context context, @AnyRes int resId, TypedValue outValue, boolean resolveRefs) {
- if (!isDefaultSkin) {
- int targetResId = getTargetResId(context, resId);
- if (targetResId != 0) {
- mResources.getValue(targetResId, outValue, resolveRefs);
- return;
- }
- }
- context.getResources().getValue(resId, outValue, resolveRefs);
- }
-
- public static int getColor(Context context, int resId) {
- return getInstance().getSkinColor(context, resId);
- }
-
- public static ColorStateList getColorStateList(Context context, int resId) {
- return getInstance().getSkinColorStateList(context, resId);
- }
-
- public static Drawable getDrawable(Context context, int resId) {
- return getInstance().getSkinDrawable(context, resId);
- }
-
- public static XmlResourceParser getXml(Context context, int resId) {
- return getInstance().getSkinXml(context, resId);
- }
-
- public static void getValue(Context context, @AnyRes int resId, TypedValue outValue, boolean resolveRefs) {
- getInstance().getSkinValue(context, resId, outValue, resolveRefs);
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatThemeUtils.java b/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatThemeUtils.java
deleted file mode 100755
index 42836fedd9..0000000000
--- a/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatThemeUtils.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package skin.support.content.res;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.TypedArray;
-import android.graphics.Color;
-import android.util.TypedValue;
-
-import skin.support.graphics.ColorUtils;
-
-import static skin.support.widget.SkinCompatHelper.INVALID_ID;
-
-/**
- * Created by ximsfei on 2017/3/25.
- */
-
-public class SkinCompatThemeUtils {
-
- private static final ThreadLocal TL_TYPED_VALUE = new ThreadLocal<>();
-
- static final int[] DISABLED_STATE_SET = new int[]{-android.R.attr.state_enabled};
- static final int[] ENABLED_STATE_SET = new int[]{android.R.attr.state_enabled};
- static final int[] WINDOW_FOCUSED_STATE_SET = new int[]{android.R.attr.state_window_focused};
- static final int[] FOCUSED_STATE_SET = new int[]{android.R.attr.state_focused};
- static final int[] ACTIVATED_STATE_SET = new int[]{android.R.attr.state_activated};
- static final int[] ACCELERATED_STATE_SET = new int[]{android.R.attr.state_accelerated};
- static final int[] HOVERED_STATE_SET = new int[]{android.R.attr.state_hovered};
- static final int[] DRAG_CAN_ACCEPT_STATE_SET = new int[]{android.R.attr.state_drag_can_accept};
- static final int[] DRAG_HOVERED_STATE_SET = new int[]{android.R.attr.state_drag_hovered};
- static final int[] PRESSED_STATE_SET = new int[]{android.R.attr.state_pressed};
- static final int[] CHECKED_STATE_SET = new int[]{android.R.attr.state_checked};
- static final int[] SELECTED_STATE_SET = new int[]{android.R.attr.state_selected};
- static final int[] NOT_PRESSED_OR_FOCUSED_STATE_SET = new int[]{
- -android.R.attr.state_pressed, -android.R.attr.state_focused};
- static final int[] EMPTY_STATE_SET = new int[0];
-
- private static final int[] TEMP_ARRAY = new int[1];
-
- public static int getTextColorPrimaryResId(Context context) {
- return getResId(context, new int[]{android.R.attr.textColorPrimary});
- }
-
- public static int getWindowBackgroundResId(Context context) {
- return getResId(context, new int[]{android.R.attr.windowBackground});
- }
-
- static int getResId(Context context, int[] attrs) {
- TypedArray a = context.obtainStyledAttributes(attrs);
- final int resId = a.getResourceId(0, INVALID_ID);
- a.recycle();
- return resId;
- }
-
- public static int getThemeAttrColor(Context context, int attr) {
- TEMP_ARRAY[0] = attr;
- TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
- try {
- int resId = a.getResourceId(0, 0);
- if (resId != 0) {
- return SkinCompatResources.getColor(context, resId);
- }
- return 0;
- } finally {
- a.recycle();
- }
- }
-
- public static ColorStateList getThemeAttrColorStateList(Context context, int attr) {
- TEMP_ARRAY[0] = attr;
- TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY);
- try {
- int resId = a.getResourceId(0, 0);
- if (resId != 0) {
- return SkinCompatResources.getColorStateList(context, resId);
- }
- return null;
- } finally {
- a.recycle();
- }
- }
-
- public static int getDisabledThemeAttrColor(Context context, int attr) {
- final ColorStateList csl = getThemeAttrColorStateList(context, attr);
- if (csl != null && csl.isStateful()) {
- // If the CSL is stateful, we'll assume it has a disabled state and use it
- return csl.getColorForState(DISABLED_STATE_SET, csl.getDefaultColor());
- } else {
- // Else, we'll generate the color using disabledAlpha from the theme
-
- final TypedValue tv = getTypedValue();
- // Now retrieve the disabledAlpha value from the theme
- context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, tv, true);
- final float disabledAlpha = tv.getFloat();
-
- return getThemeAttrColor(context, attr, disabledAlpha);
- }
- }
-
- private static TypedValue getTypedValue() {
- TypedValue typedValue = TL_TYPED_VALUE.get();
- if (typedValue == null) {
- typedValue = new TypedValue();
- TL_TYPED_VALUE.set(typedValue);
- }
- return typedValue;
- }
-
- static int getThemeAttrColor(Context context, int attr, float alpha) {
- final int color = getThemeAttrColor(context, attr);
- final int originalAlpha = Color.alpha(color);
- return ColorUtils.setAlphaComponent(color, Math.round(originalAlpha * alpha));
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatUserThemeManager.java b/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatUserThemeManager.java
deleted file mode 100755
index fc8580c4d6..0000000000
--- a/skin/skin-support/src/main/java/skin/support/content/res/SkinCompatUserThemeManager.java
+++ /dev/null
@@ -1,397 +0,0 @@
-package skin.support.content.res;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-import java.util.WeakHashMap;
-
-import skin.support.SkinCompatManager;
-import skin.support.annotation.ColorRes;
-import skin.support.annotation.DrawableRes;
-import skin.support.utils.ImageUtils;
-import skin.support.utils.SkinPreference;
-import skin.support.utils.Slog;
-
-import static skin.support.content.res.ColorState.checkColorValid;
-import static skin.support.content.res.ColorState.toJSONObject;
-
-public class SkinCompatUserThemeManager {
- private static final String TAG = "SkinCompatUserThemeManager";
- private static final String KEY_TYPE = "type";
- private static final String KEY_TYPE_COLOR = "color";
- private static final String KEY_TYPE_DRAWABLE = "drawable";
- private static final String KEY_DRAWABLE_NAME = "drawableName";
- private static final String KEY_DRAWABLE_PATH_AND_ANGLE = "drawablePathAndAngle";
-
- private static SkinCompatUserThemeManager INSTANCE = new SkinCompatUserThemeManager();
-
- private final HashMap mColorNameStateMap = new HashMap<>();
- private final Object mColorCacheLock = new Object();
- private final WeakHashMap> mColorCaches = new WeakHashMap<>();
- private boolean mColorEmpty;
-
- private final HashMap mDrawablePathAndAngleMap = new HashMap<>();
- private final Object mDrawableCacheLock = new Object();
- private final WeakHashMap> mDrawableCaches = new WeakHashMap<>();
- private boolean mDrawableEmpty;
-
- private SkinCompatUserThemeManager() {
- try {
- startLoadFromSharedPreferences();
- } catch (JSONException e) {
- mColorNameStateMap.clear();
- mDrawablePathAndAngleMap.clear();
- if (Slog.DEBUG) {
- Slog.i(TAG, "startLoadFromSharedPreferences error: " + e);
- }
- }
- }
-
- private void startLoadFromSharedPreferences() throws JSONException {
- String colors = SkinPreference.getInstance().getUserTheme();
- if (!TextUtils.isEmpty(colors)) {
- JSONArray jsonArray = new JSONArray(colors);
- if (Slog.DEBUG) {
- Slog.i(TAG, "startLoadFromSharedPreferences: " + jsonArray.toString());
- }
- int count = jsonArray.length();
- for (int i = 0; i < count; i++) {
- JSONObject jsonObject = jsonArray.getJSONObject(i);
- if (jsonObject.has(KEY_TYPE)) {
- String type = jsonObject.getString(KEY_TYPE);
- if (KEY_TYPE_COLOR.equals(type)) {
- ColorState state = ColorState.fromJSONObject(jsonObject);
- if (state != null) {
- mColorNameStateMap.put(state.colorName, state);
- }
- } else if (KEY_TYPE_DRAWABLE.equals(type)) {
- String drawableName = jsonObject.getString(KEY_DRAWABLE_NAME);
- String drawablePathAndAngle = jsonObject.getString(KEY_DRAWABLE_PATH_AND_ANGLE);
- if (!TextUtils.isEmpty(drawableName) && !TextUtils.isEmpty(drawablePathAndAngle)) {
- mDrawablePathAndAngleMap.put(drawableName, drawablePathAndAngle);
- }
- }
- }
- }
- }
- mColorEmpty = mColorNameStateMap.isEmpty();
- mDrawableEmpty = mDrawablePathAndAngleMap.isEmpty();
- }
-
- public void apply() {
- JSONArray jsonArray = new JSONArray();
- for (String colorName : mColorNameStateMap.keySet()) {
- ColorState state = mColorNameStateMap.get(colorName);
- if (state != null) {
- try {
- jsonArray.put(toJSONObject(state).putOpt(KEY_TYPE, KEY_TYPE_COLOR));
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- }
- for (String drawableName : mDrawablePathAndAngleMap.keySet()) {
- JSONObject object = new JSONObject();
- try {
- jsonArray.put(object.putOpt(KEY_TYPE, KEY_TYPE_DRAWABLE)
- .putOpt(KEY_DRAWABLE_NAME, drawableName)
- .putOpt(KEY_DRAWABLE_PATH_AND_ANGLE, mDrawablePathAndAngleMap.get(drawableName)));
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
- if (Slog.DEBUG) {
- Slog.i(TAG, "Apply user theme: " + jsonArray.toString());
- }
- SkinPreference.getInstance().setUserTheme(jsonArray.toString()).commitEditor();
- SkinCompatManager.getInstance().notifyUpdateSkin();
- }
-
- public static SkinCompatUserThemeManager get() {
- return INSTANCE;
- }
-
- public void addColorState(@ColorRes int colorRes, ColorState state) {
- String entry = getEntryName(colorRes, KEY_TYPE_COLOR);
- if (!TextUtils.isEmpty(entry) && state != null) {
- state.colorName = entry;
- mColorNameStateMap.put(entry, state);
- removeColorInCache(colorRes);
- mColorEmpty = false;
- }
- }
-
- public void addColorState(@ColorRes int colorRes, String colorDefault) {
- if (!checkColorValid("colorDefault", colorDefault)) {
- return;
- }
- String entry = getEntryName(colorRes, KEY_TYPE_COLOR);
- if (!TextUtils.isEmpty(entry)) {
- mColorNameStateMap.put(entry, new ColorState(entry, colorDefault));
- removeColorInCache(colorRes);
- mColorEmpty = false;
- }
- }
-
- public void removeColorState(@ColorRes int colorRes) {
- String entry = getEntryName(colorRes, KEY_TYPE_COLOR);
- if (!TextUtils.isEmpty(entry)) {
- mColorNameStateMap.remove(entry);
- removeColorInCache(colorRes);
- mColorEmpty = mColorNameStateMap.isEmpty();
- }
- }
-
- void removeColorState(String colorName) {
- if (!TextUtils.isEmpty(colorName)) {
- mColorNameStateMap.remove(colorName);
- mColorEmpty = mColorNameStateMap.isEmpty();
- }
- }
-
- public ColorState getColorState(String colorName) {
- return mColorNameStateMap.get(colorName);
- }
-
- public ColorState getColorState(@ColorRes int colorRes) {
- String entry = getEntryName(colorRes, KEY_TYPE_COLOR);
- if (!TextUtils.isEmpty(entry)) {
- return mColorNameStateMap.get(entry);
- }
- return null;
- }
-
- public ColorStateList getColorStateList(@ColorRes int colorRes) {
- ColorStateList colorStateList = getCachedColor(colorRes);
- if (colorStateList == null) {
- String entry = getEntryName(colorRes, KEY_TYPE_COLOR);
- if (!TextUtils.isEmpty(entry)) {
- ColorState state = mColorNameStateMap.get(entry);
- if (state != null) {
- colorStateList = state.parse();
- if (colorStateList != null) {
- addColorToCache(colorRes, colorStateList);
- }
- }
- }
- }
- return colorStateList;
- }
-
- public void addDrawablePath(@DrawableRes int drawableRes, String drawablePath) {
- if (!checkPathValid(drawablePath)) {
- return;
- }
- String entry = getEntryName(drawableRes, KEY_TYPE_DRAWABLE);
- if (!TextUtils.isEmpty(entry)) {
- int angle = ImageUtils.getImageRotateAngle(drawablePath);
- String drawablePathAndAngle = drawablePath + ":" + String.valueOf(angle);
- mDrawablePathAndAngleMap.put(entry, drawablePathAndAngle);
- removeDrawableInCache(drawableRes);
- mDrawableEmpty = false;
- }
- }
-
- public void addDrawablePath(@DrawableRes int drawableRes, String drawablePath, int angle) {
- if (!checkPathValid(drawablePath)) {
- return;
- }
- String entry = getEntryName(drawableRes, KEY_TYPE_DRAWABLE);
- if (!TextUtils.isEmpty(entry)) {
- String drawablePathAndAngle = drawablePath + ":" + String.valueOf(angle);
- mDrawablePathAndAngleMap.put(entry, drawablePathAndAngle);
- removeDrawableInCache(drawableRes);
- mDrawableEmpty = false;
- }
- }
-
- public void removeDrawablePath(@DrawableRes int drawableRes) {
- String entry = getEntryName(drawableRes, KEY_TYPE_DRAWABLE);
- if (!TextUtils.isEmpty(entry)) {
- mDrawablePathAndAngleMap.remove(entry);
- removeDrawableInCache(drawableRes);
- mDrawableEmpty = mDrawablePathAndAngleMap.isEmpty();
- }
- }
-
- public String getDrawablePath(String drawableName) {
- String drawablePathAndAngle = mDrawablePathAndAngleMap.get(drawableName);
- if (!TextUtils.isEmpty(drawablePathAndAngle)) {
- String[] splits = drawablePathAndAngle.split(":");
- return splits[0];
- }
- return "";
- }
-
- public int getDrawableAngle(String drawableName) {
- String drawablePathAndAngle = mDrawablePathAndAngleMap.get(drawableName);
- if (!TextUtils.isEmpty(drawablePathAndAngle)) {
- String[] splits = drawablePathAndAngle.split(":");
- if (splits.length == 2) {
- return Integer.valueOf(splits[1]);
- }
- }
- return 0;
- }
-
- public Drawable getDrawable(@DrawableRes int drawableRes) {
- Drawable drawable = getCachedDrawable(drawableRes);
- if (drawable == null) {
- String entry = getEntryName(drawableRes, KEY_TYPE_DRAWABLE);
- if (!TextUtils.isEmpty(entry)) {
- String drawablePathAndAngle = mDrawablePathAndAngleMap.get(entry);
- if (!TextUtils.isEmpty(drawablePathAndAngle)) {
- String[] splits = drawablePathAndAngle.split(":");
- String path = splits[0];
- int angle = 0;
- if (splits.length == 2) {
- angle = Integer.valueOf(splits[1]);
- }
- if (checkPathValid(path)) {
- if (angle == 0) {
- drawable = Drawable.createFromPath(path);
- } else {
- Matrix m = new Matrix();
- m.postRotate(angle);
- Bitmap bitmap = BitmapFactory.decodeFile(path);
- bitmap = Bitmap.createBitmap(bitmap, 0, 0,
- bitmap.getWidth(), bitmap.getHeight(), m, true);
- drawable = new BitmapDrawable(null, bitmap);
- }
- if (drawable != null) {
- addDrawableToCache(drawableRes, drawable);
- }
- }
- }
- }
- }
- return drawable;
- }
-
- public void clearColors() {
- mColorNameStateMap.clear();
- clearColorCaches();
- mColorEmpty = true;
- apply();
- }
-
- public void clearDrawables() {
- mDrawablePathAndAngleMap.clear();
- clearDrawableCaches();
- mDrawableEmpty = true;
- apply();
- }
-
- boolean isColorEmpty() {
- return mColorEmpty;
- }
-
- boolean isDrawableEmpty() {
- return mDrawableEmpty;
- }
-
- void clearCaches() {
- clearColorCaches();
- clearDrawableCaches();
- }
-
- private void clearColorCaches() {
- synchronized (mColorCacheLock) {
- mColorCaches.clear();
- }
- }
-
- private void clearDrawableCaches() {
- synchronized (mDrawableCacheLock) {
- mDrawableCaches.clear();
- }
- }
-
- private ColorStateList getCachedColor(@ColorRes int colorRes) {
- synchronized (mColorCacheLock) {
- WeakReference colorRef = mColorCaches.get(colorRes);
- if (colorRef != null) {
- ColorStateList colorStateList = colorRef.get();
- if (colorStateList != null) {
- return colorStateList;
- } else {
- mColorCaches.remove(colorRes);
- }
- }
- }
- return null;
- }
-
- private void addColorToCache(@ColorRes int colorRes, ColorStateList colorStateList) {
- if (colorStateList != null) {
- synchronized (mColorCacheLock) {
- mColorCaches.put(colorRes, new WeakReference<>(colorStateList));
- }
- }
- }
-
- private void removeColorInCache(@ColorRes int colorRes) {
- synchronized (mColorCacheLock) {
- mColorCaches.remove(colorRes);
- }
- }
-
- private Drawable getCachedDrawable(@DrawableRes int drawableRes) {
- synchronized (mDrawableCacheLock) {
- WeakReference drawableRef = mDrawableCaches.get(drawableRes);
- if (drawableRef != null) {
- Drawable drawable = drawableRef.get();
- if (drawable != null) {
- return drawable;
- } else {
- mDrawableCaches.remove(drawableRes);
- }
- }
- }
- return null;
- }
-
- private void addDrawableToCache(@DrawableRes int drawableRes, Drawable drawable) {
- if (drawable != null) {
- synchronized (mDrawableCacheLock) {
- mDrawableCaches.put(drawableRes, new WeakReference<>(drawable));
- }
- }
- }
-
- private void removeDrawableInCache(@DrawableRes int drawableRes) {
- synchronized (mDrawableCacheLock) {
- mDrawableCaches.remove(drawableRes);
- }
- }
-
- private String getEntryName(int resId, String entryType) {
- Context context = SkinCompatManager.getInstance().getContext();
- String type = context.getResources().getResourceTypeName(resId);
- if (entryType.equalsIgnoreCase(type)) {
- return context.getResources().getResourceEntryName(resId);
- }
- return null;
- }
-
- private static boolean checkPathValid(String path) {
- boolean valid = !TextUtils.isEmpty(path) && new File(path).exists();
- if (Slog.DEBUG && !valid) {
- Slog.i(TAG, "Invalid drawable path : " + path);
- }
- return valid;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/content/res/SkinResources.java b/skin/skin-support/src/main/java/skin/support/content/res/SkinResources.java
deleted file mode 100755
index b6c163bf48..0000000000
--- a/skin/skin-support/src/main/java/skin/support/content/res/SkinResources.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package skin.support.content.res;
-
-interface SkinResources {
- void clear();
-}
diff --git a/skin/skin-support/src/main/java/skin/support/exception/SkinCompatException.java b/skin/skin-support/src/main/java/skin/support/exception/SkinCompatException.java
deleted file mode 100755
index 2a63091765..0000000000
--- a/skin/skin-support/src/main/java/skin/support/exception/SkinCompatException.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package skin.support.exception;
-
-public class SkinCompatException extends RuntimeException {
- public SkinCompatException(String message) {
- super(message);
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/graphics/ColorUtils.java b/skin/skin-support/src/main/java/skin/support/graphics/ColorUtils.java
deleted file mode 100755
index c1bced9d5e..0000000000
--- a/skin/skin-support/src/main/java/skin/support/graphics/ColorUtils.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package skin.support.graphics;
-
-/**
- * A set of color-related utility methods, building upon those available in {@code Color}.
- */
-public final class ColorUtils {
- /**
- * Set the alpha component of {@code color} to be {@code alpha}.
- */
- public static int setAlphaComponent(int color, int alpha) {
- if (alpha < 0 || alpha > 255) {
- throw new IllegalArgumentException("alpha must be between 0 and 255.");
- }
- return (color & 0x00ffffff) | (alpha << 24);
- }
-}
-
diff --git a/skin/skin-support/src/main/java/skin/support/load/SkinAssetsLoader.java b/skin/skin-support/src/main/java/skin/support/load/SkinAssetsLoader.java
deleted file mode 100755
index 3a8f05a249..0000000000
--- a/skin/skin-support/src/main/java/skin/support/load/SkinAssetsLoader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package skin.support.load;
-
-import android.content.Context;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import skin.support.SkinCompatManager;
-import skin.support.utils.SkinConstants;
-import skin.support.utils.SkinFileUtils;
-
-public class SkinAssetsLoader extends SkinSDCardLoader {
- @Override
- protected String getSkinPath(Context context, String skinName) {
- return copySkinFromAssets(context, skinName);
- }
-
- @Override
- public String getTargetResourceEntryName(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public int getType() {
- return SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS;
- }
-
- private String copySkinFromAssets(Context context, String name) {
- String skinPath = new File(SkinFileUtils.getSkinDir(context), name).getAbsolutePath();
- try {
- InputStream is = context.getAssets().open(
- SkinConstants.SKIN_DEPLOY_PATH + File.separator + name);
- OutputStream os = new FileOutputStream(skinPath);
- int byteCount;
- byte[] bytes = new byte[1024];
- while ((byteCount = is.read(bytes)) != -1) {
- os.write(bytes, 0, byteCount);
- }
- os.close();
- is.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return skinPath;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/load/SkinBuildInLoader.java b/skin/skin-support/src/main/java/skin/support/load/SkinBuildInLoader.java
deleted file mode 100755
index 4d19b4bbfb..0000000000
--- a/skin/skin-support/src/main/java/skin/support/load/SkinBuildInLoader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package skin.support.load;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.graphics.drawable.Drawable;
-
-import skin.support.SkinCompatManager;
-import skin.support.SkinCompatManager.SkinLoaderStrategy;
-import skin.support.content.res.SkinCompatResources;
-
-public class SkinBuildInLoader implements SkinLoaderStrategy {
- @Override
- public String loadSkinInBackground(Context context, String skinName) {
- SkinCompatResources.getInstance().setupSkin(
- context.getResources(),
- context.getPackageName(),
- skinName,
- this);
- return skinName;
- }
-
- @Override
- public String getTargetResourceEntryName(Context context, String skinName, int resId) {
- return context.getResources().getResourceEntryName(resId) + "_" + skinName;
- }
-
- @Override
- public ColorStateList getColor(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public ColorStateList getColorStateList(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public Drawable getDrawable(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public int getType() {
- return SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/load/SkinNoneLoader.java b/skin/skin-support/src/main/java/skin/support/load/SkinNoneLoader.java
deleted file mode 100755
index 76473e3e1b..0000000000
--- a/skin/skin-support/src/main/java/skin/support/load/SkinNoneLoader.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package skin.support.load;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.graphics.drawable.Drawable;
-
-import skin.support.SkinCompatManager;
-import skin.support.SkinCompatManager.SkinLoaderStrategy;
-
-public class SkinNoneLoader implements SkinLoaderStrategy {
- @Override
- public String loadSkinInBackground(Context context, String skinName) {
- return "";
- }
-
- @Override
- public String getTargetResourceEntryName(Context context, String skinName, int resId) {
- return "";
- }
-
- @Override
- public ColorStateList getColor(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public ColorStateList getColorStateList(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public Drawable getDrawable(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public int getType() {
- return SkinCompatManager.SKIN_LOADER_STRATEGY_NONE;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/load/SkinPrefixBuildInLoader.java b/skin/skin-support/src/main/java/skin/support/load/SkinPrefixBuildInLoader.java
deleted file mode 100755
index d679aa3bec..0000000000
--- a/skin/skin-support/src/main/java/skin/support/load/SkinPrefixBuildInLoader.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package skin.support.load;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.graphics.drawable.Drawable;
-
-import skin.support.SkinCompatManager;
-import skin.support.SkinCompatManager.SkinLoaderStrategy;
-import skin.support.content.res.SkinCompatResources;
-
-public class SkinPrefixBuildInLoader implements SkinLoaderStrategy {
- @Override
- public String loadSkinInBackground(Context context, String skinName) {
- SkinCompatResources.getInstance().setupSkin(
- context.getResources(),
- context.getPackageName(),
- skinName,
- this);
- return skinName;
- }
-
- @Override
- public String getTargetResourceEntryName(Context context, String skinName, int resId) {
- return skinName + "_" + context.getResources().getResourceEntryName(resId);
- }
-
- @Override
- public ColorStateList getColor(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public ColorStateList getColorStateList(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public Drawable getDrawable(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public int getType() {
- return SkinCompatManager.SKIN_LOADER_STRATEGY_PREFIX_BUILD_IN;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/load/SkinSDCardLoader.java b/skin/skin-support/src/main/java/skin/support/load/SkinSDCardLoader.java
deleted file mode 100755
index d86f6ebe11..0000000000
--- a/skin/skin-support/src/main/java/skin/support/load/SkinSDCardLoader.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package skin.support.load;
-
-import android.content.Context;
-import android.content.res.ColorStateList;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-
-import skin.support.SkinCompatManager;
-import skin.support.SkinCompatManager.SkinLoaderStrategy;
-import skin.support.content.res.SkinCompatResources;
-import skin.support.utils.SkinFileUtils;
-
-public abstract class SkinSDCardLoader implements SkinLoaderStrategy {
- @Override
- public String loadSkinInBackground(Context context, String skinName) {
- if (TextUtils.isEmpty(skinName)) {
- return skinName;
- }
- String skinPkgPath = getSkinPath(context, skinName);
- if (SkinFileUtils.isFileExists(skinPkgPath)) {
- String pkgName = SkinCompatManager.getInstance().getSkinPackageName(skinPkgPath);
- Resources resources = SkinCompatManager.getInstance().getSkinResources(skinPkgPath);
- if (resources != null && !TextUtils.isEmpty(pkgName)) {
- SkinCompatResources.getInstance().setupSkin(
- resources,
- pkgName,
- skinName,
- this);
- return skinName;
- }
- }
- return null;
- }
-
- protected abstract String getSkinPath(Context context, String skinName);
-
- @Override
- public String getTargetResourceEntryName(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public ColorStateList getColor(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public ColorStateList getColorStateList(Context context, String skinName, int resId) {
- return null;
- }
-
- @Override
- public Drawable getDrawable(Context context, String skinName, int resId) {
- return null;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/observe/SkinObservable.java b/skin/skin-support/src/main/java/skin/support/observe/SkinObservable.java
deleted file mode 100755
index 491ff13376..0000000000
--- a/skin/skin-support/src/main/java/skin/support/observe/SkinObservable.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package skin.support.observe;
-
-import java.util.ArrayList;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinObservable {
- private final ArrayList observers;
-
- public SkinObservable() {
- observers = new ArrayList<>();
- }
-
- public synchronized void addObserver(SkinObserver o) {
- if (o == null) {
- throw new NullPointerException();
- }
- if (!observers.contains(o)) {
- observers.add(o);
- }
- }
-
- public synchronized void deleteObserver(SkinObserver o) {
- observers.remove(o);
- }
-
- public void notifyUpdateSkin() {
- notifyUpdateSkin(null);
- }
-
- public void notifyUpdateSkin(Object arg) {
- SkinObserver[] arrLocal;
-
- synchronized (this) {
- arrLocal = observers.toArray(new SkinObserver[observers.size()]);
- }
-
- for (int i = arrLocal.length-1; i>=0; i--) {
- arrLocal[i].updateSkin(this, arg);
- }
- }
-
- public synchronized void deleteObservers() {
- observers.clear();
- }
-
- public synchronized int countObservers() {
- return observers.size();
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/observe/SkinObserver.java b/skin/skin-support/src/main/java/skin/support/observe/SkinObserver.java
deleted file mode 100755
index a1b0529aac..0000000000
--- a/skin/skin-support/src/main/java/skin/support/observe/SkinObserver.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package skin.support.observe;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public interface SkinObserver {
- void updateSkin( SkinObservable observable, Object o );
-}
diff --git a/skin/skin-support/src/main/java/skin/support/utils/ImageUtils.java b/skin/skin-support/src/main/java/skin/support/utils/ImageUtils.java
deleted file mode 100755
index a78cb152e8..0000000000
--- a/skin/skin-support/src/main/java/skin/support/utils/ImageUtils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package skin.support.utils;
-
-import android.media.ExifInterface;
-
-import java.io.IOException;
-
-public class ImageUtils {
- public static int getImageRotateAngle(String filePath) {
- ExifInterface exif;
- try {
- exif = new ExifInterface(filePath);
- } catch (IOException e) {
- e.printStackTrace();
- exif = null;
-
- }
- int angle = 0;
- if (exif != null) {
- int ori = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);
- switch (ori) {
- case ExifInterface.ORIENTATION_ROTATE_90:
- angle = 90;
- break;
- case ExifInterface.ORIENTATION_ROTATE_180:
- angle = 180;
- break;
- case ExifInterface.ORIENTATION_ROTATE_270:
- angle = 270;
- break;
- default:
- angle = 0;
- break;
- }
- }
- return angle;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/utils/SkinCompatVersionUtils.java b/skin/skin-support/src/main/java/skin/support/utils/SkinCompatVersionUtils.java
deleted file mode 100755
index 4694465a51..0000000000
--- a/skin/skin-support/src/main/java/skin/support/utils/SkinCompatVersionUtils.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package skin.support.utils;
-
-import android.graphics.drawable.Drawable;
-
-import java.lang.reflect.Method;
-
-public final class SkinCompatVersionUtils {
- private static final String TAG = "SkinCompatUtils";
- // 27.1.0后删除
- private static Class> sV4DrawableWrapperClass;
- private static Method sV4DrawableWrapperGetM;
- private static Method sV4DrawableWrapperSetM;
- // 27.1.0后增加
- private static Class> sV4WrappedDrawableClass;
- private static Method sV4WrappedDrawableGetM;
- private static Method sV4WrappedDrawableSetM;
-
- private static Class> sV7DrawableWrapperClass;
- private static Method sV7DrawableWrapperGetM;
- private static Method sV7DrawableWrapperSetM;
-
- static {
- try {
- sV4WrappedDrawableClass = Class.forName("android.support.v4.graphics.drawable.WrappedDrawable");
- } catch (ClassNotFoundException e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "hasV4WrappedDrawable = false");
- }
- }
- try {
- sV4DrawableWrapperClass = Class.forName("android.support.v4.graphics.drawable.DrawableWrapper");
- } catch (ClassNotFoundException e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "hasV4DrawableWrapper = false");
- }
- }
- try {
- sV7DrawableWrapperClass = Class.forName("android.support.v7.graphics.drawable.DrawableWrapper");
- } catch (ClassNotFoundException e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "hasV7DrawableWrapper = false");
- }
- }
- }
-
- public static boolean hasV4WrappedDrawable() {
- return sV4WrappedDrawableClass != null;
- }
-
- public static boolean isV4WrappedDrawable(Drawable drawable) {
- return sV4WrappedDrawableClass != null
- && sV4WrappedDrawableClass.isAssignableFrom(drawable.getClass());
- }
-
- public static Drawable getV4WrappedDrawableWrappedDrawable(Drawable drawable) {
- if (sV4WrappedDrawableClass != null) {
- if (sV4WrappedDrawableGetM == null) {
- try {
- sV4WrappedDrawableGetM = sV4WrappedDrawableClass.getDeclaredMethod("getWrappedDrawable");
- sV4WrappedDrawableGetM.setAccessible(true);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "getV4WrappedDrawableWrappedDrawable No Such Method");
- }
- }
- }
- if (sV4WrappedDrawableGetM != null) {
- try {
- return (Drawable) sV4WrappedDrawableGetM.invoke(drawable);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "getV4WrappedDrawableWrappedDrawable invoke error: " + e);
- }
- }
- }
- }
- return drawable;
- }
-
- public static void setV4WrappedDrawableWrappedDrawable(Drawable drawable, Drawable inner) {
- if (sV4WrappedDrawableClass != null) {
- if (sV4WrappedDrawableSetM == null) {
- try {
- sV4WrappedDrawableSetM = sV4WrappedDrawableClass.getDeclaredMethod("setWrappedDrawable", Drawable.class);
- sV4WrappedDrawableSetM.setAccessible(true);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "setV4WrappedDrawableWrappedDrawable No Such Method");
- }
- }
- }
- if (sV4WrappedDrawableSetM != null) {
- try {
- sV4WrappedDrawableSetM.invoke(drawable, inner);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "setV4WrappedDrawableWrappedDrawable invoke error: " + e);
- }
- }
- }
- }
- }
-
- public static boolean hasV4DrawableWrapper() {
- return sV4DrawableWrapperClass != null;
- }
-
- public static boolean isV4DrawableWrapper(Drawable drawable) {
- return sV4DrawableWrapperClass != null
- && sV4DrawableWrapperClass.isAssignableFrom(drawable.getClass());
- }
-
- public static Drawable getV4DrawableWrapperWrappedDrawable(Drawable drawable) {
- if (sV4DrawableWrapperClass != null) {
- if (sV4DrawableWrapperGetM == null) {
- try {
- sV4DrawableWrapperGetM = sV4DrawableWrapperClass.getDeclaredMethod("getWrappedDrawable");
- sV4DrawableWrapperGetM.setAccessible(true);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "getV4DrawableWrapperWrappedDrawable No Such Method");
- }
- }
- }
- if (sV4DrawableWrapperGetM != null) {
- try {
- return (Drawable) sV4DrawableWrapperGetM.invoke(drawable);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "getV4DrawableWrapperWrappedDrawable invoke error: " + e);
- }
- }
- }
- }
- return drawable;
- }
-
- public static void setV4DrawableWrapperWrappedDrawable(Drawable drawable, Drawable inner) {
- if (sV4DrawableWrapperClass != null) {
- if (sV4DrawableWrapperSetM == null) {
- try {
- sV4DrawableWrapperSetM = sV4DrawableWrapperClass.getDeclaredMethod("setWrappedDrawable", Drawable.class);
- sV4DrawableWrapperSetM.setAccessible(true);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "setV4DrawableWrapperWrappedDrawable No Such Method");
- }
- }
- }
- if (sV4DrawableWrapperSetM != null) {
- try {
- sV4DrawableWrapperSetM.invoke(drawable, inner);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "setV4DrawableWrapperWrappedDrawable invoke error: " + e);
- }
- }
- }
- }
- }
-
- public static boolean hasV7DrawableWrapper() {
- return sV7DrawableWrapperClass != null;
- }
-
- public static boolean isV7DrawableWrapper(Drawable drawable) {
- return sV7DrawableWrapperClass != null
- && sV7DrawableWrapperClass.isAssignableFrom(drawable.getClass());
- }
-
- public static Drawable getV7DrawableWrapperWrappedDrawable(Drawable drawable) {
- if (sV7DrawableWrapperClass != null) {
- if (sV7DrawableWrapperGetM == null) {
- try {
- sV7DrawableWrapperGetM = sV7DrawableWrapperClass.getDeclaredMethod("getWrappedDrawable");
- sV7DrawableWrapperGetM.setAccessible(true);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "getV7DrawableWrapperWrappedDrawable No Such Method");
- }
- }
- }
- if (sV7DrawableWrapperGetM != null) {
- try {
- return (Drawable) sV7DrawableWrapperGetM.invoke(drawable);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "getV7DrawableWrapperWrappedDrawable invoke error: " + e);
- }
- }
- }
- }
- return drawable;
- }
-
- public static void setV7DrawableWrapperWrappedDrawable(Drawable drawable, Drawable inner) {
- if (sV7DrawableWrapperClass != null) {
- if (sV7DrawableWrapperSetM == null) {
- try {
- sV7DrawableWrapperSetM = sV7DrawableWrapperClass.getDeclaredMethod("setWrappedDrawable", Drawable.class);
- sV7DrawableWrapperSetM.setAccessible(true);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "setV7DrawableWrapperWrappedDrawable No Such Method");
- }
- }
- }
- if (sV7DrawableWrapperSetM != null) {
- try {
- sV7DrawableWrapperSetM.invoke(drawable, inner);
- } catch (Exception e) {
- if (Slog.DEBUG) {
- Slog.i(TAG, "setV7DrawableWrapperWrappedDrawable invoke error: " + e);
- }
- }
- }
- }
- }
-
-}
diff --git a/skin/skin-support/src/main/java/skin/support/utils/SkinConstants.java b/skin/skin-support/src/main/java/skin/support/utils/SkinConstants.java
deleted file mode 100755
index 2bbec12510..0000000000
--- a/skin/skin-support/src/main/java/skin/support/utils/SkinConstants.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package skin.support.utils;
-
-/**
- * Created by ximsfei on 17-1-9.
- */
-
-public class SkinConstants {
- public static final String SKIN_DEPLOY_PATH = "skins";
-}
diff --git a/skin/skin-support/src/main/java/skin/support/utils/SkinFileUtils.java b/skin/skin-support/src/main/java/skin/support/utils/SkinFileUtils.java
deleted file mode 100755
index 37eaae9724..0000000000
--- a/skin/skin-support/src/main/java/skin/support/utils/SkinFileUtils.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package skin.support.utils;
-
-import android.content.Context;
-import android.os.Environment;
-import android.text.TextUtils;
-
-import java.io.File;
-
-/**
- * Created by ximsfei on 17-1-10.
- */
-
-public class SkinFileUtils {
- public static String getSkinDir(Context context) {
- File skinDir = new File(getCacheDir(context), SkinConstants.SKIN_DEPLOY_PATH);
- if (!skinDir.exists()) {
- skinDir.mkdirs();
- }
- return skinDir.getAbsolutePath();
- }
-
- private static String getCacheDir(Context context) {
- if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
- File cacheDir = context.getExternalCacheDir();
- if (cacheDir != null && (cacheDir.exists() || cacheDir.mkdirs())) {
- return cacheDir.getAbsolutePath();
- }
- }
-
- return context.getCacheDir().getAbsolutePath();
- }
-
-
- public static boolean isFileExists(String path) {
- return !TextUtils.isEmpty(path) && new File(path).exists();
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/utils/SkinPreference.java b/skin/skin-support/src/main/java/skin/support/utils/SkinPreference.java
deleted file mode 100755
index 09115a0ba1..0000000000
--- a/skin/skin-support/src/main/java/skin/support/utils/SkinPreference.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package skin.support.utils;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import skin.support.SkinCompatManager;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public class SkinPreference {
- private static final String FILE_NAME = "meta-data";
-
- private static final String KEY_SKIN_NAME = "skin-name";
- private static final String KEY_SKIN_STRATEGY = "skin-strategy";
- private static final String KEY_SKIN_USER_THEME = "skin-user-theme-json";
- private static SkinPreference sInstance;
- private final Context mApp;
- private final SharedPreferences mPref;
- private final SharedPreferences.Editor mEditor;
-
- public static void init(Context context) {
- if (sInstance == null) {
- synchronized (SkinPreference.class) {
- if (sInstance == null) {
- sInstance = new SkinPreference(context.getApplicationContext());
- }
- }
- }
- }
-
- public static SkinPreference getInstance() {
- return sInstance;
- }
-
- private SkinPreference(Context applicationContext) {
- mApp = applicationContext;
- mPref = mApp.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
- mEditor = mPref.edit();
- }
-
- public SkinPreference setSkinName(String skinName) {
- mEditor.putString(KEY_SKIN_NAME, skinName);
- return this;
- }
-
- public String getSkinName() {
- return mPref.getString(KEY_SKIN_NAME, "");
- }
-
- public SkinPreference setSkinStrategy(int strategy) {
- mEditor.putInt(KEY_SKIN_STRATEGY, strategy);
- return this;
- }
-
- public int getSkinStrategy() {
- return mPref.getInt(KEY_SKIN_STRATEGY, SkinCompatManager.SKIN_LOADER_STRATEGY_NONE);
- }
-
- public SkinPreference setUserTheme(String themeJson) {
- mEditor.putString(KEY_SKIN_USER_THEME, themeJson);
- return this;
- }
-
- public String getUserTheme() {
- return mPref.getString(KEY_SKIN_USER_THEME, "");
- }
-
- public void commitEditor() {
- mEditor.apply();
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/utils/Slog.java b/skin/skin-support/src/main/java/skin/support/utils/Slog.java
deleted file mode 100755
index c7002de3d7..0000000000
--- a/skin/skin-support/src/main/java/skin/support/utils/Slog.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package skin.support.utils;
-
-import android.util.Log;
-
-public class Slog {
- public static boolean DEBUG = false;
- private static final String TAG = "skin-support";
-
- public static void i(String msg) {
- if (DEBUG) {
- Log.i(TAG, msg);
- }
- }
-
- public static void i(String subtag, String msg) {
- if (DEBUG) {
- Log.i(TAG, subtag + ": " + msg);
- }
- }
-
- public static void r(String msg) {
- Log.i(TAG, msg);
- }
-
- public static void r(String subtag, String msg) {
- Log.i(TAG, subtag + ": " + msg);
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/view/LayoutInflaterCompat.java b/skin/skin-support/src/main/java/skin/support/view/LayoutInflaterCompat.java
deleted file mode 100755
index 0df3396bac..0000000000
--- a/skin/skin-support/src/main/java/skin/support/view/LayoutInflaterCompat.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package skin.support.view;
-
-import android.content.Context;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-
-import java.lang.reflect.Field;
-
-public final class LayoutInflaterCompat {
- private static final String TAG = "LayoutInflaterCompatHC";
-
- private static Field sLayoutInflaterFactory2Field;
- private static boolean sCheckedField;
-
- @SuppressWarnings("deprecation")
- static class Factory2Wrapper implements LayoutInflater.Factory2 {
- final LayoutInflaterFactory mDelegateFactory;
-
- Factory2Wrapper(LayoutInflaterFactory delegateFactory) {
- mDelegateFactory = delegateFactory;
- }
-
- @Override
- public View onCreateView(String name, Context context, AttributeSet attrs) {
- return mDelegateFactory.onCreateView(null, name, context, attrs);
- }
-
- @Override
- public View onCreateView(View parent, String name, Context context,
- AttributeSet attributeSet) {
- return mDelegateFactory.onCreateView(parent, name, context, attributeSet);
- }
-
- @Override
- public String toString() {
- return getClass().getName() + "{" + mDelegateFactory + "}";
- }
- }
-
- /**
- * For APIs < 21, there was a framework bug that prevented a LayoutInflater's
- * Factory2 from being merged properly if set after a cloneInContext from a LayoutInflater
- * that already had a Factory2 registered. We work around that bug here. If we can't we
- * log an error.
- */
- private static void forceSetFactory2(LayoutInflater inflater, LayoutInflater.Factory2 factory) {
- if (!sCheckedField) {
- try {
- sLayoutInflaterFactory2Field = LayoutInflater.class.getDeclaredField("mFactory2");
- sLayoutInflaterFactory2Field.setAccessible(true);
- } catch (NoSuchFieldException e) {
- Log.e(TAG, "forceSetFactory2 Could not find field 'mFactory2' on class "
- + LayoutInflater.class.getName()
- + "; inflation may have unexpected results.", e);
- }
- sCheckedField = true;
- }
- if (sLayoutInflaterFactory2Field != null) {
- try {
- sLayoutInflaterFactory2Field.set(inflater, factory);
- } catch (IllegalAccessException e) {
- Log.e(TAG, "forceSetFactory2 could not set the Factory2 on LayoutInflater "
- + inflater + "; inflation may have unexpected results.", e);
- }
- }
- }
-
- /*
- * Hide the constructor.
- */
- private LayoutInflaterCompat() {
- }
-
- /**
- * Attach a custom Factory interface for creating views while using
- * this LayoutInflater. This must not be null, and can only be set once;
- * after setting, you can not change the factory.
- *
- * @see LayoutInflater#setFactory(LayoutInflater.Factory)
- * @deprecated Use {@link #setFactory2(LayoutInflater, LayoutInflater.Factory2)} instead to set
- * and {@link LayoutInflater#getFactory2()} to get the factory.
- */
- @Deprecated
- public static void setFactory(
- LayoutInflater inflater, LayoutInflaterFactory factory) {
- if (Build.VERSION.SDK_INT >= 21) {
- inflater.setFactory2(factory != null ? new Factory2Wrapper(factory) : null);
- } else {
- final LayoutInflater.Factory2 factory2 = factory != null
- ? new Factory2Wrapper(factory) : null;
- inflater.setFactory2(factory2);
-
- final LayoutInflater.Factory f = inflater.getFactory();
- if (f instanceof LayoutInflater.Factory2) {
- // The merged factory is now set to getFactory(), but not getFactory2() (pre-v21).
- // We will now try and force set the merged factory to mFactory2
- forceSetFactory2(inflater, (LayoutInflater.Factory2) f);
- } else {
- // Else, we will force set the original wrapped Factory2
- forceSetFactory2(inflater, factory2);
- }
- }
- }
-
- /**
- * Attach a custom {@link LayoutInflater.Factory2} for creating views while using
- * this {@link LayoutInflater}. This must not be null, and can only be set once;
- * after setting, you can not change the factory.
- *
- * @see LayoutInflater#setFactory2(LayoutInflater.Factory2)
- */
- public static void setFactory2(
- LayoutInflater inflater, LayoutInflater.Factory2 factory) {
- inflater.setFactory2(factory);
-
- if (Build.VERSION.SDK_INT < 21) {
- final LayoutInflater.Factory f = inflater.getFactory();
- if (f instanceof LayoutInflater.Factory2) {
- // The merged factory is now set to getFactory(), but not getFactory2() (pre-v21).
- // We will now try and force set the merged factory to mFactory2
- forceSetFactory2(inflater, (LayoutInflater.Factory2) f);
- } else {
- // Else, we will force set the original wrapped Factory2
- forceSetFactory2(inflater, factory);
- }
- }
- }
-
- /**
- * Return the current {@link LayoutInflaterFactory} (or null). This is
- * called on each element name. If the factory returns a View, add that
- * to the hierarchy. If it returns null, proceed to call onCreateView(name).
- *
- * @return The {@link LayoutInflaterFactory} associated with the
- * {@link LayoutInflater}. Will be {@code null} if the inflater does not
- * have a {@link LayoutInflaterFactory} but a raw {@link LayoutInflater.Factory}.
- * @see LayoutInflater#getFactory()
- * @deprecated Use {@link #setFactory2(LayoutInflater, LayoutInflater.Factory2)} to set and
- * {@link LayoutInflater#getFactory2()} to get the factory.
- */
- @Deprecated
- public static LayoutInflaterFactory getFactory(LayoutInflater inflater) {
- LayoutInflater.Factory factory = inflater.getFactory();
- if (factory instanceof Factory2Wrapper) {
- return (( Factory2Wrapper) factory).mDelegateFactory;
- }
- return null;
- }
-}
\ No newline at end of file
diff --git a/skin/skin-support/src/main/java/skin/support/view/LayoutInflaterFactory.java b/skin/skin-support/src/main/java/skin/support/view/LayoutInflaterFactory.java
deleted file mode 100755
index e7a0275fc4..0000000000
--- a/skin/skin-support/src/main/java/skin/support/view/LayoutInflaterFactory.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package skin.support.view;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-
-public interface LayoutInflaterFactory {
-
- /**
- * Hook you can supply that is called when inflating from a LayoutInflater.
- * You can use this to customize the tag names available in your XML
- * layout files.
- *
- * @param parent The parent that the created view will be placed
- * in; note that this may be null.
- * @param name Tag name to be inflated.
- * @param context The context the view is being created in.
- * @param attrs Inflation attributes as specified in XML file.
- *
- * @return View Newly created view. Return null for the default
- * behavior.
- */
- View onCreateView( View parent, String name, Context context, AttributeSet attrs );
-}
diff --git a/skin/skin-support/src/main/java/skin/support/view/ViewCompat.java b/skin/skin-support/src/main/java/skin/support/view/ViewCompat.java
deleted file mode 100755
index def9af362d..0000000000
--- a/skin/skin-support/src/main/java/skin/support/view/ViewCompat.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package skin.support.view;
-
-import android.os.Build;
-import android.view.View;
-
-public class ViewCompat {
-
- /**
- * Returns whether the provided view has an attached {@link View.OnClickListener}.
- *
- * @return true if there is a listener, false if there is none.
- */
- public static boolean hasOnClickListeners(View view) {
- if (Build.VERSION.SDK_INT >= 15) {
- return view.hasOnClickListeners();
- }
- return false;
- }
-}
diff --git a/skin/skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java b/skin/skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java
deleted file mode 100755
index 3d4281f67e..0000000000
--- a/skin/skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package skin.support.widget;
-
-
-/**
- * Created by ximsfei on 2017/1/13.
- */
-
-public abstract class SkinCompatHelper {
- protected static final String SYSTEM_ID_PREFIX = "1";
- public static final int INVALID_ID = 0;
-
- final static public int checkResourceId(int resId) {
- String hexResId = Integer.toHexString(resId);
- return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId;
- }
-
- abstract public void applySkin();
-}
diff --git a/skin/skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java b/skin/skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java
deleted file mode 100755
index 48d5c7de15..0000000000
--- a/skin/skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package skin.support.widget;
-
-/**
- * Created by ximsfei on 2017/1/10.
- */
-
-public interface SkinCompatSupportable {
- void applySkin();
-}
diff --git a/skin/skin-support/src/main/res/values/attrs.xml b/skin/skin-support/src/main/res/values/attrs.xml
deleted file mode 100755
index 1eb9e7abd2..0000000000
--- a/skin/skin-support/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/skin/skin-support/src/main/res/values/strings.xml b/skin/skin-support/src/main/res/values/strings.xml
deleted file mode 100755
index 43a2a1c37a..0000000000
--- a/skin/skin-support/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- skin-support
-