添加皮肤模块

This commit is contained in:
wangcongtao
2020-08-28 14:07:49 +08:00
parent b7110045e6
commit 8794ad282a
46 changed files with 684 additions and 68 deletions

5
.idea/gradle.xml generated
View File

@@ -56,6 +56,11 @@
<option value="$PROJECT_DIR$/services" />
<option value="$PROJECT_DIR$/services/mogo-service" />
<option value="$PROJECT_DIR$/services/mogo-service-api" />
<option value="$PROJECT_DIR$/skin" />
<option value="$PROJECT_DIR$/skin/mogo-skin-light" />
<option value="$PROJECT_DIR$/skin/mogo-skin-support" />
<option value="$PROJECT_DIR$/skin/mogo-skin-support-impl" />
<option value="$PROJECT_DIR$/skin/mogo-skin-support-noop" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />

View File

@@ -283,6 +283,7 @@ dependencies {
implementation rootProject.ext.dependencies.carcall
implementation rootProject.ext.dependencies.mogologlib
implementation "com.zhidao.adasconfig:adasconfig:1.0.1"
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogocommons
@@ -324,13 +325,7 @@ dependencies {
apply from: "./functions/socketpush.gradle"
apply from: "./functions/gpssimulator.gradle"
apply from: "./functions/leftpanel.gradle"
// 换肤功能
implementation 'skin.support:skin-support:4.0.5' // skin-support
implementation 'skin.support:skin-support-appcompat:4.0.5' // skin-support 基础控件支持
implementation 'skin.support:skin-support-design:4.0.5' // skin-support-design material design 控件支持[可选]
implementation 'skin.support:skin-support-cardview:4.0.5' // skin-support-cardview CardView 控件支持[可选]
implementation 'skin.support:skin-support-constraint-layout:4.0.5' // skin-support-constraint-layout ConstraintLayout 控件支持[可选]
apply from: "./functions/skin.gradle"
}
android.applicationVariants.all { variant ->

52
app/functions/skin.gradle Normal file
View File

@@ -0,0 +1,52 @@
project.dependencies {
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.skinsupport
bydautoImplementation rootProject.ext.dependencies.skinsupportnoop
f8xxImplementation rootProject.ext.dependencies.skinsupportimpl
f80xImplementation rootProject.ext.dependencies.skinsupportimpl
em4Implementation rootProject.ext.dependencies.skinsupportimpl
e8xxImplementation rootProject.ext.dependencies.skinsupportimpl
d8xxImplementation rootProject.ext.dependencies.skinsupportimpl
d82xImplementation rootProject.ext.dependencies.skinsupportimpl
em1Implementation rootProject.ext.dependencies.skinsupportimpl
d80xImplementation rootProject.ext.dependencies.skinsupportimpl
em3Implementation rootProject.ext.dependencies.skinsupportimpl
f8xxImplementation rootProject.ext.dependencies.skinsupportlight
f80xImplementation rootProject.ext.dependencies.skinsupportlight
em4Implementation rootProject.ext.dependencies.skinsupportlight
e8xxImplementation rootProject.ext.dependencies.skinsupportlight
d8xxImplementation rootProject.ext.dependencies.skinsupportlight
d82xImplementation rootProject.ext.dependencies.skinsupportlight
em1Implementation rootProject.ext.dependencies.skinsupportlight
d80xImplementation rootProject.ext.dependencies.skinsupportlight
em3Implementation rootProject.ext.dependencies.skinsupportlight
} else {
implementation project(":skin:mogo-skin-support")
bydautoImplementation project(':skin:mogo-skin-support-noop')
f8xxImplementation project(':skin:mogo-skin-support-impl')
f80xImplementation project(':skin:mogo-skin-support-impl')
em4Implementation project(':skin:mogo-skin-support-impl')
e8xxImplementation project(':skin:mogo-skin-support-impl')
d8xxImplementation project(':skin:mogo-skin-support-impl')
d82xImplementation project(':skin:mogo-skin-support-impl')
em1Implementation project(':skin:mogo-skin-support-impl')
d80xImplementation project(':skin:mogo-skin-support-impl')
em3Implementation project(':skin:mogo-skin-support-impl')
f8xxImplementation project(':skin:mogo-skin-light')
f80xImplementation project(':skin:mogo-skin-light')
em4Implementation project(':skin:mogo-skin-light')
e8xxImplementation project(':skin:mogo-skin-light')
d8xxImplementation project(':skin:mogo-skin-light')
d82xImplementation project(':skin:mogo-skin-light')
em1Implementation project(':skin:mogo-skin-light')
d80xImplementation project(':skin:mogo-skin-light')
em3Implementation project(':skin:mogo-skin-light')
}
}

View File

@@ -1,5 +1,6 @@
package com.mogo.launcher;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
@@ -30,9 +31,15 @@ import com.mogo.module.widgets.MogoWidgetsProvider;
import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.passport.IMogoTicketCallback;
import com.mogo.skin.support.MogoSkinManager;
import com.mogo.skin.support.SkinMode;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.zhidao.adasconfig.api.AdasConfigApiController;
import com.zhidao.adasconfig.common.config.EnumCarChatIncognitoMode;
import com.zhidao.adasconfig.listener.IAdasSettingUIListener;
import com.zhidao.adasconfig.listener.IAdasSkinStyleListener;
import com.zhidao.boot.persistent.lib.PersistentManager;
import com.zhidao.mogo.module.left.panel.LeftPanelConst;
import com.zhidao.mogo.tanlu.api.TanluApiConst;
@@ -88,8 +95,8 @@ public class MogoApplication extends AbsMogoApplication {
MogoModulePaths.addBaseModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) );
MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME ) );
MogoModulePaths.addBaseModule(new MogoModule( MogoServicePaths.PATH_STRATEGY_SHARE,"StrategyShare"));
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_MOGO_MONITOR, "MogoMonitor"));
MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_STRATEGY_SHARE, "StrategyShare" ) );
MogoModulePaths.addBaseModule( new MogoModule( MogoServicePaths.PATH_MOGO_MONITOR, "MogoMonitor" ) );
MogoModulePaths.addModule( new MogoModule( V2XConst.PATH_EVENT_PANEL, V2XConst.MODULE_NAME_EVENT_PANEL ) );
MogoModulePaths.addModule( new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME ) );
@@ -98,8 +105,7 @@ public class MogoApplication extends AbsMogoApplication {
Intent intent = new Intent( this, MogoMainService.class );
startService( intent );
}
initSkinStrategy();
listenerADASConfigChanged( this );
Log.i( "timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
}
@@ -122,18 +128,6 @@ public class MogoApplication extends AbsMogoApplication {
super.asyncInitImpl();
}
private void initSkinStrategy(){
SkinCompatManager.withoutActivity(this)
.addInflater(new SkinAppCompatViewInflater()) // 基础控件换肤初始化
.addInflater(new SkinMaterialViewInflater()) // material design 控件换肤初始化[可选]
.addInflater(new SkinConstraintViewInflater()) // ConstraintLayout 控件换肤初始化[可选]
.addInflater(new SkinCardViewInflater()) // CardView v7 控件换肤初始化[可选]
.setSkinAllActivityEnable(true)
.setSkinStatusBarColorEnable(false) // 关闭状态栏换肤,默认打开[可选]
.setSkinWindowBackgroundEnable(false) // 关闭windowBackground换肤默认打开[可选]
.loadSkin();
}
@Override
protected void init() {
super.init();
@@ -187,6 +181,37 @@ public class MogoApplication extends AbsMogoApplication {
} );
}
private void listenerADASConfigChanged( Application application ) {
MogoSkinManager.getInstance().getInstaller().install( application );
AdasConfigApiController.getInstance().registerAdasSettingUiListener( new IAdasSettingUIListener() {
@Override
public void northModel() {
}
@Override
public void carHeadUp() {
}
@Override
public void switchCarChat( EnumCarChatIncognitoMode enumCarChatIncognitoMode ) {
}
} );
AdasConfigApiController.getInstance().registerAdasSettingSkinModelListener( new IAdasSkinStyleListener() {
@Override
public void whiteModel() {
MogoSkinManager.getInstance().getInstaller().loadSkin( SkinMode.Light );
}
@Override
public void blackModel() {
MogoSkinManager.getInstance().getInstaller().loadSkin( SkinMode.Night );
}
} );
AdasConfigApiController.getInstance().init( application );
}
@Override
protected void attachBaseContext( Context base ) {
super.attachBaseContext( base );

View File

@@ -4,20 +4,19 @@ ext {
android = [
// applicationId : "com.mogo.launcher",
// zhidadoApplicationId: "com.zhidao.launcher",
launcherApplicationId : "com.mogo.launcher",
independentApplicationId : "com.mogo.launcher.app",
fLauncherApplicationId : "com.mogo.launcher.f",
bydautoIndependentApplicationId: "com.mogo.launcher.app.bydauto",
fLauncherAmapApiValue : "aa2c8a0547378ead2f9a37762d9dd179",
bydautoIndependentApiValue : "b1e1d527b02a493913c50985827c943a",
commonLauncherAmapApiValue : "a36b9f7b086fa3951bb35338a5a06dd3",
commonIndependentAmapApiValue : "1c3fbc5f5e183619ffb1e7bc01e6751f",
compileSdkVersion : 28,
buildToolsVersion : "29.0.2",
minSdkVersion : 19,
targetSdkVersion : 22,
launcherApplicationId : "com.mogo.launcher",
independentApplicationId : "com.mogo.launcher.app",
fLauncherApplicationId : "com.mogo.launcher.f",
bydautoIndependentApplicationId: "com.mogo.launcher.app.bydauto",
fLauncherAmapApiValue : "aa2c8a0547378ead2f9a37762d9dd179",
bydautoIndependentApiValue : "b1e1d527b02a493913c50985827c943a",
commonLauncherAmapApiValue : "a36b9f7b086fa3951bb35338a5a06dd3",
commonIndependentAmapApiValue : "1c3fbc5f5e183619ffb1e7bc01e6751f",
compileSdkVersion : 28,
buildToolsVersion : "29.0.2",
minSdkVersion : 19,
targetSdkVersion : 22,
]
dependencies = [
// androidx
androidxappcompat : "androidx.appcompat:appcompat:1.1.0",
@@ -198,6 +197,12 @@ ext {
//
mogomodulewidgets : "com.mogo.module:module-widgets:${MOGO_MODULE_WIDGETS_VERSION}",
kotlingradleplugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
kotlingradleplugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}",
skinsupport : "com.mogo.skin:skin-support:${MOGO_SKIN_SUPPORT_VERSION}",
skinsupportimpl : "com.mogo.skin:skin-support-impl:${MOGO_SKIN_SUPPORT_IMPL_VERSION}",
skinsupportnoop : "com.mogo.skin:skin-support-noop:${MOGO_SKIN_SUPPORT_NOOP_VERSION}",
skinsupportlight : "com.mogo.skin:skin-light:${MOGO_SKIN_LIGHT_VERSION}",
]
}

View File

@@ -50,13 +50,6 @@ dependencies {
implementation project(":foudations:mogo-utils")
}
api 'org.greenrobot:eventbus:3.1.1'
api 'skin.support:skin-support:4.0.5' // skin-support
api 'skin.support:skin-support-appcompat:4.0.5' // skin-support 基础控件支持
api 'skin.support:skin-support-design:4.0.5' // skin-support-design material design 控件支持[可选]
api 'skin.support:skin-support-cardview:4.0.5' // skin-support-cardview CardView 控件支持[可选]
api 'skin.support:skin-support-constraint-layout:4.0.5' // skin-support-constraint-layout ConstraintLayout 控件支持[可选]
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -2,7 +2,6 @@ package com.mogo.commons.mvp;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;

View File

@@ -104,6 +104,10 @@ MOGO_MODULE_OBU_VERSION = 1.2.1.10-SNAPSHOT
# 闪屏页
MOGO_MODULE_SPLASH_VERSION = 1.0.0-SNAPSHOT
MOGO_MODULE_SPLASH_NOOP_VERSION = 1.0.0-SNAPSHOT
MOGO_SKIN_SUPPORT_VERSION=1.0.0
MOGO_SKIN_LIGHT_VERSION=1.0.0
MOGO_SKIN_SUPPORT_IMPL_VERSION=1.0.0
MOGO_SKIN_SUPPORT_NOOP_VERSION=1.0.0
# loglib
LOGLIB_VERSION = 1.0.4

View File

@@ -4,7 +4,7 @@
android:id="@+id/module_apps_id_apps_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0C0C0C">
android:background="@color/module_app_page_bkg_color">
<ImageView
android:id="@+id/module_apps_id_apps_exit"

View File

@@ -16,5 +16,6 @@
<color name="bg_common">#080625</color>
<color name="txt_blue">#3E7FFC</color>
<color name="module_app_page_bkg_color">#0C0C0C</color>
</resources>

View File

@@ -34,7 +34,7 @@ android {
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res-night']
res.srcDirs = ['src/main/res', 'src/main/res-light']
}
}

View File

@@ -1,6 +1,5 @@
package com.mogo.module.extensions.entrance;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Bundle;
@@ -9,7 +8,6 @@ import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
@@ -65,9 +63,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import skin.support.SkinCompatManager;
/**
* @author congtaowang
* @since 2020-01-07
@@ -167,7 +162,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mUploading = findViewById(R.id.module_entrance_id_uploading);
mUploadRoadCondition.setOnClickListener(view -> {
showShareDialog();
SkinCompatManager.getInstance().loadSkin( "night", SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN );
});
mDisplayOverview = findViewById(R.id.module_ext_id_display_overview);

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<gradient android:angle="135" android:endColor="#cc0000" android:startColor="#ff0000" android:type="linear" />
<corners android:radius="@dimen/module_ext_common_corner" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<gradient android:angle="135" android:endColor="#ee0000" android:startColor="#330000" android:type="linear" />
<corners android:radius="@dimen/module_ext_common_corner" />
</shape>
</item>
</selector>

View File

@@ -48,6 +48,7 @@ dependencies {
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.modulecommon
} else {
api project(":libraries:mogo-map")
implementation project(":libraries:mogo-map-api")

View File

@@ -1,3 +1,7 @@
include ':skin:mogo-skin-light'
include ':skin:mogo-skin-support-impl'
include ':skin:mogo-skin-support-noop'
include ':skin:mogo-skin-support'
include ':modules:mogo-module-widgets'
include ':modules:mogo-module-monitor'
include ':libraries:mogo-tanlu-api'
@@ -42,3 +46,4 @@ include ':modules:mogo-module-push-noop'
include ':modules:mogo-module-tanlu'
include ':libraries:tanlulib'
include ':skin'

1
skin/mogo-skin-light/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,43 @@
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 Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
res.srcDirs = [
'src/main/res',
'src/main/module-apps-res'
]
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.skin
POM_ARTIFACT_ID=skin-light
VERSION_CODE=1

21
skin/mogo-skin-light/proguard-rules.pro vendored Normal file
View File

@@ -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

View File

@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.skin.light">
/
</manifest>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="module_app_page_bkg_color_light">#FFFFFF</color>
</resources>

View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,60 @@
apply plugin: 'com.android.library'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
// 换肤功能
implementation 'skin.support:skin-support:4.0.5' // skin-support
implementation 'skin.support:skin-support-appcompat:4.0.5' // skin-support 基础控件支持
implementation 'skin.support:skin-support-design:4.0.5' // skin-support-design material design 控件支持[可选]
implementation 'skin.support:skin-support-cardview:4.0.5' // skin-support-cardview CardView 控件支持[可选]
implementation 'skin.support:skin-support-constraint-layout:4.0.5' // skin-support-constraint-layout ConstraintLayout 控件支持[可选]
implementation "com.zhidao.adasconfig:adasconfig:1.0.1"
if( Boolean.valueOf(RELEASE) ){
implementation rootProject.ext.dependencies.skinsupport
compileOnly rootProject.ext.dependencies.modulecommon
} else {
implementation project(":skin:mogo-skin-support")
compileOnly project(':modules:mogo-module-common')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.skin
POM_ARTIFACT_ID=skin-support-impl
VERSION_CODE=1

View File

@@ -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

View File

@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.skin.support">
/
</manifest>

View File

@@ -0,0 +1,67 @@
package com.mogo.skin.support.impl;
import android.app.Application;
import android.content.Context;
import androidx.appcompat.app.AppCompatDelegate;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.skin.support.IMogoSkinSupportInstaller;
import com.mogo.skin.support.SkinMode;
import com.mogo.skin.support.SkinSupportInstallerConstants;
import skin.support.SkinCompatManager;
import skin.support.app.SkinAppCompatViewInflater;
import skin.support.app.SkinCardViewInflater;
import skin.support.constraint.app.SkinConstraintViewInflater;
import skin.support.design.app.SkinMaterialViewInflater;
public
/**
* @author congtaowang
* @since 2020/8/28
*
* 描述
*/
@Route( path = SkinSupportInstallerConstants.PATH )
class SkinSupportInstaller implements IMogoSkinSupportInstaller {
@Override
public void install( Application application ) {
initSkinManager( application );
}
@Override
public void loadSkin( SkinMode skinMode ) {
if ( skinMode == null ) {
return;
}
if ( skinMode.isDefault() ) {
SkinCompatManager.getInstance().restoreDefaultTheme();
} else {
SkinCompatManager.getInstance().loadSkin( skinMode.getName(), SkinCompatManager.SKIN_LOADER_STRATEGY_BUILD_IN );
}
}
private void initSkinManager( Application application ) {
SkinCompatManager.withoutActivity( application )
.addInflater( new SkinAppCompatViewInflater() ) // 基础控件换肤初始化
.addInflater( new SkinMaterialViewInflater() ) // material design 控件换肤初始化[可选]
.addInflater( new SkinConstraintViewInflater() ) // ConstraintLayout 控件换肤初始化[可选]
.addInflater( new SkinCardViewInflater() ) // CardView v7 控件换肤初始化[可选]
.setSkinAllActivityEnable( true )
.setSkinWindowBackgroundEnable( true ) // 关闭windowBackground换肤默认打开[可选]
.loadSkin();
}
@Override
public AppCompatDelegate getSkinAppCompatDelegate( AppCompatDelegate delegate ) {
return null;
}
@Override
public void init( Context context ) {
}
}

View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,50 @@
apply plugin: 'com.android.library'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if( Boolean.valueOf(RELEASE) ){
implementation rootProject.ext.dependencies.skinsupport
compileOnly rootProject.ext.dependencies.modulecommon
} else {
implementation project(":skin:mogo-skin-support")
compileOnly project(':modules:mogo-module-common')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.skin
POM_ARTIFACT_ID=skin-support-noop
VERSION_CODE=1

View File

@@ -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

View File

@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.skin.support">
/
</manifest>

View File

@@ -0,0 +1,38 @@
package com.mogo.skin.support.noop;
import android.app.Application;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.skin.support.IMogoSkinSupportInstaller;
import com.mogo.skin.support.SkinMode;
import com.mogo.skin.support.SkinSupportInstallerConstants;
import com.mogo.utils.logger.Logger;
public
/**
* @author congtaowang
* @since 2020/8/28
*
* 描述
*/
@Route( path = SkinSupportInstallerConstants.PATH )
class SkinSupportInstaller implements IMogoSkinSupportInstaller {
private static final String TAG = "SkinSupportInstaller";
@Override
public void install( Application application ) {
Logger.d( TAG, "noop - install" );
}
@Override
public void loadSkin( SkinMode skinMode ) {
Logger.d( TAG, "noop - loadSkin" );
}
@Override
public void init( Context context ) {
}
}

1
skin/mogo-skin-support/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,52 @@
apply plugin: 'com.android.library'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
// 换肤功能
implementation 'skin.support:skin-support:4.0.5' // skin-support
implementation 'skin.support:skin-support-appcompat:4.0.5' // skin-support 基础控件支持
implementation 'skin.support:skin-support-design:4.0.5' // skin-support-design material design 控件支持[可选]
implementation 'skin.support:skin-support-cardview:4.0.5' // skin-support-cardview CardView 控件支持[可选]
implementation 'skin.support:skin-support-constraint-layout:4.0.5' // skin-support-constraint-layout ConstraintLayout 控件支持[可选]
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.skin
POM_ARTIFACT_ID=skin-support
VERSION_CODE=1

View File

@@ -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

View File

@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.skin.support">
/
</manifest>

View File

@@ -0,0 +1,23 @@
package com.mogo.skin.support;
import android.app.Application;
import androidx.appcompat.app.AppCompatDelegate;
import com.alibaba.android.arouter.facade.template.IProvider;
public
/**
* @author congtaowang
* @since 2020/8/28
*
* 描述
*/
interface IMogoSkinSupportInstaller extends IProvider {
void install( Application application );
void loadSkin( SkinMode skinMode );
AppCompatDelegate getSkinAppCompatDelegate( AppCompatDelegate delegate );
}

View File

@@ -0,0 +1,45 @@
package com.mogo.skin.support;
import com.alibaba.android.arouter.launcher.ARouter;
public
/**
* @author congtaowang
* @since 2020/8/28
* <p>
* 描述
*/
class MogoSkinManager {
private IMogoSkinSupportInstaller mInstaller;
private static volatile MogoSkinManager sInstance;
private MogoSkinManager() {
mInstaller = ARouter.getInstance().navigation( IMogoSkinSupportInstaller.class );
}
public static MogoSkinManager getInstance() {
if ( sInstance == null ) {
synchronized ( MogoSkinManager.class ) {
if ( sInstance == null ) {
sInstance = new MogoSkinManager();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
public IMogoSkinSupportInstaller getInstaller() {
return mInstaller;
}
}

View File

@@ -0,0 +1,37 @@
package com.mogo.skin.support;
public
/**
* @author congtaowang
* @since 2020/8/28
* <p>
* 描述
*/
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;
}
}

View File

@@ -0,0 +1,13 @@
package com.mogo.skin.support;
public
/**
* @author congtaowang
* @since 2020/8/28
*
* 描述
*/
class SkinSupportInstallerConstants {
public static final String PATH = "/skin/install";
}