Skip to content

Commit

Permalink
init skin-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ximsfei committed Apr 25, 2018
1 parent 7be0931 commit 3708d25
Show file tree
Hide file tree
Showing 107 changed files with 659 additions and 317 deletions.
22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions demo/skin-demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
45 changes: 45 additions & 0 deletions demo/skin-demo/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion rootProject.compileSdkVersion

defaultConfig {
applicationId "com.ximsfei.skindemo"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.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-night']
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:appcompat-v7:${rootProject.supportLibraryVersion}"
implementation project(':android-support:skin-support')
// implementation 'skin.support:skin-support:3.0.0'

implementation "com.android.support:recyclerview-v7:${rootProject.supportLibraryVersion}"
implementation "com.android.support:design:${rootProject.supportLibraryVersion}"
implementation project(':android-support:skin-support-design')
// implementation 'skin.support:skin-support-design:3.0.0'

implementation "com.android.support.constraint:constraint-layout:1.1.0"
implementation project(':android-support:skin-support-constraint-layout')
// implementation 'skin.support:skin-support-constraint-layout:3.0.0'

implementation "com.android.support:cardview-v7:${rootProject.supportLibraryVersion}"
implementation project(':android-support:skin-support-cardview')
// implementation 'skin.support:skin-support-cardview:3.0.0'
}
21 changes: 21 additions & 0 deletions demo/skin-demo/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
22 changes: 22 additions & 0 deletions demo/skin-demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ximsfei.skindemo">

<application
android:name=".SkinApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Binary file added demo/skin-demo/src/main/assets/night.skin
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.ximsfei.skindemo;

import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;

import com.ximsfei.skindemo.loader.CustomSDCardLoader;

import skin.support.SkinCompatManager;

public class BaseActivity extends AppCompatActivity {
protected void initBottomMenu() {
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_menu);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_default:
SkinCompatManager.getInstance().restoreDefaultTheme();
return true;
case R.id.menu_built_in:
SkinCompatManager.getInstance().loadSkin("night", SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN);
return true;
case R.id.menu_plug_in:
SkinCompatManager.getInstance().loadSkin("night.skin", SkinCompatManager.SKIN_LOADER_STRATEGY_ASSETS);
return true;
case R.id.menu_sdcard:
SkinCompatManager.getInstance().loadSkin("night.skin", CustomSDCardLoader.SKIN_LOADER_STRATEGY_SDCARD);
return true;
case R.id.menu_color_picker:
return true;
default:
return false;
}
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ximsfei.skindemo;

import android.os.Bundle;

public class MainActivity extends BaseActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initBottomMenu();
}
}
34 changes: 34 additions & 0 deletions demo/skin-demo/src/main/java/com/ximsfei/skindemo/SkinApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ximsfei.skindemo;

import android.app.Application;
import android.support.v7.app.AppCompatDelegate;

import com.ximsfei.skindemo.loader.CustomSDCardLoader;

import skin.support.SkinCompatManager;
import skin.support.app.SkinCardViewInflater;
import skin.support.constraint.app.SkinConstraintViewInflater;
import skin.support.design.app.SkinMaterialViewInflater;

public class SkinApp extends Application {
@Override
public void onCreate() {
super.onCreate();
SkinCompatManager.withoutActivity(this)
// 自定义加载策略,指定SDCard路径
.addStrategy(new CustomSDCardLoader())
// material design
.addInflater(new SkinMaterialViewInflater())
// ConstraintLayout
.addInflater(new SkinConstraintViewInflater())
// CardView v7
.addInflater(new SkinCardViewInflater())
// 关闭状态栏换肤
.setSkinStatusBarColorEnable(false)
// 关闭windowBackground换肤
.setSkinWindowBackgroundEnable(false)
// .setSkinAllActivityEnable(false) // true: 默认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤
.loadSkin();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ximsfei.skindemo.loader;

import android.content.Context;

import java.io.File;

import skin.support.load.SkinSDCardLoader;
import skin.support.utils.SkinFileUtils;

public class CustomSDCardLoader extends SkinSDCardLoader {
public static final int SKIN_LOADER_STRATEGY_SDCARD = Integer.MAX_VALUE;

@Override
protected String getSkinPath(Context context, String skinName) {
return new File(SkinFileUtils.getSkinDir(context), skinName).getAbsolutePath();
}

@Override
public int getType() {
return SKIN_LOADER_STRATEGY_SDCARD;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorAccent_night" android:state_pressed="true" />
<item android:color="@color/colorAccent_night" android:state_selected="true" />
<item android:color="@color/colorAccent_night" android:state_checked="true" />
<item android:color="@color/colorDefault_night" />
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
android:pathData="M13,7h-2v2h2L13,7zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM3,3v18h18L21,3L3,3zM19,19L5,19L5,5h14v14zM13,15h-2v2h2v-2zM9,11L7,11v2h2v-2z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,3c-4.97,0 -9,4.03 -9,9s4.03,9 9,9c0.83,0 1.5,-0.67 1.5,-1.5 0,-0.39 -0.15,-0.74 -0.39,-1.01 -0.23,-0.26 -0.38,-0.61 -0.38,-0.99 0,-0.83 0.67,-1.5 1.5,-1.5L16,16c2.76,0 5,-2.24 5,-5 0,-4.42 -4.03,-8 -9,-8zM6.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S5.67,9 6.5,9 8,9.67 8,10.5 7.33,12 6.5,12zM9.5,8C8.67,8 8,7.33 8,6.5S8.67,5 9.5,5s1.5,0.67 1.5,1.5S10.33,8 9.5,8zM14.5,8c-0.83,0 -1.5,-0.67 -1.5,-1.5S13.67,5 14.5,5s1.5,0.67 1.5,1.5S15.33,8 14.5,8zM17.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S16.67,9 17.5,9s1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
android:pathData="M5,13h14v-2L5,11v2zM3,17h14v-2L3,15v2zM7,7v2h14L21,7L7,7z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M16.21,4.16l4,4v-4zM20.21,16.16l-4,4h4zM8.21,20.16l-4,-4v4zM4.21,8.16l4,-4h-4zM17.16,7.21c-2.73,-2.73 -7.17,-2.73 -9.9,0s-2.73,7.17 0,9.9 7.17,2.73 9.9,0 2.73,-7.16 0,-9.9zM16.06,16.01c-2.13,2.13 -5.57,2.13 -7.7,0s-2.13,-5.57 0,-7.7 5.57,-2.13 7.7,0 2.13,5.57 0,7.7z" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,5v14H5V5h14m0,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z"/>
android:pathData="M18,2h-8L4.02,8 4,20c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2L20,4c0,-1.1 -0.9,-2 -2,-2zM12,8h-2L10,4h2v4zM15,8h-2L13,4h2v4zM18,8h-2L16,4h2v4z"/>
</vector>
17 changes: 17 additions & 0 deletions demo/skin-demo/src/main/res-night/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary_night">#902b2b</color>
<color name="colorPrimaryDark_night">#902b2b</color>
<color name="colorAccent_night">#902b2b</color>
<color name="colorDefault_night">#adaeb3</color>

<color name="textColorPrimary_night">#adaeb3</color>
<color name="textColorPrimaryPressed_night">#6b6c74</color>
<color name="textColorSecondary_night">#75777e</color>
<color name="textColorSecondaryPressed_night">#5b5d63</color>
<color name="textColorTip_night">#2b6e90</color>
<color name="textColorTipPressed_night">#3f6f99</color>
<color name="textBackground_night">#111214</color>
<color name="background_night">#111214</color>
<color name="divider_night">#2cffffff</color>
</resources>
7 changes: 7 additions & 0 deletions demo/skin-demo/src/main/res/color/navigation_item_tint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorAccent" android:state_pressed="true" />
<item android:color="@color/colorAccent" android:state_selected="true" />
<item android:color="@color/colorAccent" android:state_checked="true" />
<item android:color="@color/colorDefault" />
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
9 changes: 9 additions & 0 deletions demo/skin-demo/src/main/res/drawable/ic_built_in_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M13,7h-2v2h2L13,7zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM3,3v18h18L21,3L3,3zM19,19L5,19L5,5h14v14zM13,15h-2v2h2v-2zM9,11L7,11v2h2v-2z" />
</vector>
9 changes: 9 additions & 0 deletions demo/skin-demo/src/main/res/drawable/ic_color_picker_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,3c-4.97,0 -9,4.03 -9,9s4.03,9 9,9c0.83,0 1.5,-0.67 1.5,-1.5 0,-0.39 -0.15,-0.74 -0.39,-1.01 -0.23,-0.26 -0.38,-0.61 -0.38,-0.99 0,-0.83 0.67,-1.5 1.5,-1.5L16,16c2.76,0 5,-2.24 5,-5 0,-4.42 -4.03,-8 -9,-8zM6.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S5.67,9 6.5,9 8,9.67 8,10.5 7.33,12 6.5,12zM9.5,8C8.67,8 8,7.33 8,6.5S8.67,5 9.5,5s1.5,0.67 1.5,1.5S10.33,8 9.5,8zM14.5,8c-0.83,0 -1.5,-0.67 -1.5,-1.5S13.67,5 14.5,5s1.5,0.67 1.5,1.5S15.33,8 14.5,8zM17.5,12c-0.83,0 -1.5,-0.67 -1.5,-1.5S16.67,9 17.5,9s1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/>
</vector>
9 changes: 9 additions & 0 deletions demo/skin-demo/src/main/res/drawable/ic_default_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M5,13h14v-2L5,11v2zM3,17h14v-2L3,15v2zM7,7v2h14L21,7L7,7z" />
</vector>
Loading

0 comments on commit 3708d25

Please sign in to comment.