Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
SkinLibrary
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gaodapeng
SkinLibrary
Commits
05e635c3
Commit
05e635c3
authored
Jun 27, 2021
by
gaodapeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
非androidx版本
parent
f124de4e
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
47 additions
and
215 deletions
+47
-215
build.gradle
build.gradle
+0
-2
build.gradle
demo/build.gradle
+2
-14
ExampleInstrumentedTest.kt
...idTest/java/com/study/skindemo/ExampleInstrumentedTest.kt
+0
-24
MainActivity.java
demo/src/main/java/com/study/skindemo/MainActivity.java
+28
-0
MainActivity.kt
demo/src/main/java/com/study/skindemo/MainActivity.kt
+0
-24
activity_main.xml
demo/src/main/res/layout/activity_main.xml
+2
-2
content_main.xml
demo/src/main/res/layout/content_main.xml
+0
-19
fragment_first.xml
demo/src/main/res/layout/fragment_first.xml
+0
-28
fragment_second.xml
demo/src/main/res/layout/fragment_second.xml
+0
-27
nav_graph.xml
demo/src/main/res/navigation/nav_graph.xml
+0
-28
gradle.properties
gradle.properties
+2
-2
build.gradle
skin-lib/build.gradle
+4
-9
ExampleInstrumentedTest.kt
...ndroidTest/java/com/study/libs/ExampleInstrumentedTest.kt
+0
-24
AndroidManifest.xml
skin-lib/src/main/AndroidManifest.xml
+0
-2
ActivityLifeCycleCallback.java
...c/main/java/com/study/libs/ActivityLifeCycleCallback.java
+5
-4
SkinAttribute.java
skin-lib/src/main/java/com/study/libs/SkinAttribute.java
+1
-2
SkinLayoutInflaterFactory.java
...c/main/java/com/study/libs/SkinLayoutInflaterFactory.java
+2
-3
SkinResources.java
...lib/src/main/java/com/study/libs/utils/SkinResources.java
+1
-1
No files found.
build.gradle
View file @
05e635c3
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
{
ext
.
kotlin_version
=
"1.3.72"
repositories
{
google
()
jcenter
()
}
dependencies
{
classpath
"com.android.tools.build:gradle:4.0.1"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
...
...
demo/build.gradle
View file @
05e635c3
apply
plugin:
'com.android.application'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
android
{
compileSdkVersion
29
...
...
@@ -13,7 +11,6 @@ android {
versionCode
1
versionName
"1.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
}
buildTypes
{
...
...
@@ -26,24 +23,15 @@ android {
sourceCompatibility
JavaVersion
.
VERSION_1_8
targetCompatibility
JavaVersion
.
VERSION_1_8
}
kotlinOptions
{
jvmTarget
=
'1.8'
}
}
dependencies
{
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
'androidx.core:core-ktx:1.3.1'
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
"com.android.support:support-v13:28.0.0"
implementation
'com.google.android.material:material:1.2.1'
implementation
'androidx.constraintlayout:constraintlayout:2.0.1'
implementation
'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation
'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation
'com.android.support.constraint:constraint-layout:1.1.2'
implementation
project
(
':skin-lib'
)
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
}
\ No newline at end of file
demo/src/androidTest/java/com/study/skindemo/ExampleInstrumentedTest.kt
deleted
100644 → 0
View file @
f124de4e
package
com.study.skindemo
import
androidx.test.platform.app.InstrumentationRegistry
import
androidx.test.ext.junit.runners.AndroidJUnit4
import
org.junit.Test
import
org.junit.runner.RunWith
import
org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith
(
AndroidJUnit4
::
class
)
class
ExampleInstrumentedTest
{
@Test
fun
useAppContext
()
{
// Context of the app under test.
val
appContext
=
InstrumentationRegistry
.
getInstrumentation
().
targetContext
assertEquals
(
"com.study.skindemo"
,
appContext
.
packageName
)
}
}
\ No newline at end of file
demo/src/main/java/com/study/skindemo/MainActivity.java
0 → 100644
View file @
05e635c3
package
com
.
study
.
skindemo
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
android.view.View
;
import
com.study.libs.SkinManager
;
import
java.io.File
;
public
class
MainActivity
extends
AppCompatActivity
{
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
findViewById
(
R
.
id
.
btnCtl
).
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
SkinManager
.
getInstance
()
.
loadSkin
(
new
File
(
getCacheDir
(),
"skin1-release-unsigned.apk"
).
getAbsolutePath
());
}
});
}
}
demo/src/main/java/com/study/skindemo/MainActivity.kt
deleted
100644 → 0
View file @
f124de4e
package
com.study.skindemo
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
import
com.study.libs.SkinManager
import
kotlinx.android.synthetic.main.activity_main.*
import
java.io.File
/**
* 这个是换肤方案的demo,该demo目标是做成换肤的功能,支持同名资源替换型换肤
*/
class
MainActivity
:
AppCompatActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_main
)
btnCtl
.
setOnClickListener
{
SkinManager
.
getInstance
()
.
loadSkin
(
File
(
cacheDir
,
"skin1-release-unsigned.apk"
).
absolutePath
)
}
}
}
\ No newline at end of file
demo/src/main/res/layout/activity_main.xml
View file @
05e635c3
<?xml version="1.0" encoding="utf-8"?>
<android
x.constraintlayout.widge
t.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<android
.support.constrain
t.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
...
...
@@ -24,4 +24,4 @@
app:layout_constraintTop_toBottomOf=
"@id/btnCtl"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
demo/src/main/res/layout/content_main.xml
deleted
100644 → 0
View file @
f124de4e
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
>
<fragment
android:id=
"@+id/nav_host_fragment"
android:name=
"androidx.navigation.fragment.NavHostFragment"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
app:defaultNavHost=
"true"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintLeft_toLeftOf=
"parent"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:navGraph=
"@navigation/nav_graph"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
demo/src/main/res/layout/fragment_first.xml
deleted
100644 → 0
View file @
f124de4e
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".FirstFragment"
>
<TextView
android:id=
"@+id/textview_first"
android:layout_width=
"wrap_content"
android:layout_height=
"?actionBarSize"
android:text=
"@string/hello_first_fragment"
app:layout_constraintBottom_toTopOf=
"@id/button_first"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<Button
android:id=
"@+id/button_first"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/next"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/textview_first"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
demo/src/main/res/layout/fragment_second.xml
deleted
100644 → 0
View file @
f124de4e
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".SecondFragment"
>
<TextView
android:id=
"@+id/textview_second"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constraintBottom_toTopOf=
"@id/button_second"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<Button
android:id=
"@+id/button_second"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/previous"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/textview_second"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
demo/src/main/res/navigation/nav_graph.xml
deleted
100644 → 0
View file @
f124de4e
<?xml version="1.0" encoding="utf-8"?>
<navigation
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/nav_graph"
app:startDestination=
"@id/FirstFragment"
>
<fragment
android:id=
"@+id/FirstFragment"
android:name=
"com.study.skindemo.FirstFragment"
android:label=
"@string/first_fragment_label"
tools:layout=
"@layout/fragment_first"
>
<action
android:id=
"@+id/action_FirstFragment_to_SecondFragment"
app:destination=
"@id/SecondFragment"
/>
</fragment>
<fragment
android:id=
"@+id/SecondFragment"
android:name=
"com.study.skindemo.SecondFragment"
android:label=
"@string/second_fragment_label"
tools:layout=
"@layout/fragment_second"
>
<action
android:id=
"@+id/action_SecondFragment_to_FirstFragment"
app:destination=
"@id/FirstFragment"
/>
</fragment>
</navigation>
\ No newline at end of file
gradle.properties
View file @
05e635c3
...
...
@@ -14,8 +14,8 @@ org.gradle.jvmargs=-Xmx2048m
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX
=
true
#
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier
=
true
#
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style
=
official
\ No newline at end of file
skin-lib/build.gradle
View file @
05e635c3
apply
plugin:
'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
def
supportLibVersion
=
"28.0.0"
android
{
compileSdkVersion
28
buildToolsVersion
"29.0.3"
buildToolsVersion
supportLibVersion
defaultConfig
{
minSdkVersion
18
...
...
@@ -12,7 +12,6 @@ android {
versionCode
1
versionName
"1.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles
"consumer-rules.pro"
}
...
...
@@ -26,11 +25,7 @@ android {
dependencies
{
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
'androidx.core:core-ktx:1.3.2'
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
"com.android.support:support-v13:${supportLibVersion}"
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test.ext:junit:1.1.2'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.3.0'
}
\ No newline at end of file
skin-lib/src/androidTest/java/com/study/libs/ExampleInstrumentedTest.kt
deleted
100644 → 0
View file @
f124de4e
package
com.study.libs
import
androidx.test.platform.app.InstrumentationRegistry
import
androidx.test.ext.junit.runners.AndroidJUnit4
import
org.junit.Test
import
org.junit.runner.RunWith
import
org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith
(
AndroidJUnit4
::
class
)
class
ExampleInstrumentedTest
{
@Test
fun
useAppContext
()
{
// Context of the app under test.
val
appContext
=
InstrumentationRegistry
.
getInstrumentation
().
targetContext
assertEquals
(
"com.study.libs.test"
,
appContext
.
packageName
)
}
}
\ No newline at end of file
skin-lib/src/main/AndroidManifest.xml
View file @
05e635c3
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.study.libs"
>
/
</manifest>
\ No newline at end of file
skin-lib/src/main/java/com/study/libs/ActivityLifeCycleCallback.java
View file @
05e635c3
...
...
@@ -2,12 +2,13 @@ package com.study.libs;
import
android.app.Activity
;
import
android.app.Application
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.RequiresApi
;
import
android.support.v4.view.LayoutInflaterCompat
;
import
android.view.LayoutInflater
;
import
androidx.annotation.NonNull
;
import
androidx.core.view.LayoutInflaterCompat
;
import
com.study.libs.utils.SkinThemeUtils
;
import
java.lang.reflect.Field
;
...
...
@@ -33,7 +34,7 @@ public class ActivityLifeCycleCallback implements Application.ActivityLifecycleC
Field
field
=
LayoutInflater
.
class
.
getDeclaredField
(
"mFactorySet"
);
field
.
setAccessible
(
true
);
field
.
setBoolean
(
layoutInflater
,
false
);
}
catch
(
NoSuchFieldException
|
IllegalAccess
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
//创建工厂,并且
...
...
skin-lib/src/main/java/com/study/libs/SkinAttribute.java
View file @
05e635c3
...
...
@@ -2,13 +2,12 @@ package com.study.libs;
import
android.graphics.drawable.ColorDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.support.v4.view.ViewCompat
;
import
android.util.AttributeSet
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.core.view.ViewCompat
;
import
com.study.libs.utils.SkinResources
;
import
com.study.libs.utils.SkinThemeUtils
;
...
...
skin-lib/src/main/java/com/study/libs/SkinLayoutInflaterFactory.java
View file @
05e635c3
...
...
@@ -3,15 +3,14 @@ package com.study.libs;
import
android.app.Activity
;
import
android.content.Context
;
import
android.os.Trace
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.util.AttributeSet
;
import
android.view.InflateException
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewStub
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
com.study.libs.utils.SkinThemeUtils
;
import
java.lang.reflect.Constructor
;
...
...
skin-lib/src/main/java/com/study/libs/utils/SkinResources.java
View file @
05e635c3
...
...
@@ -4,9 +4,9 @@ import android.content.Context;
import
android.content.res.ColorStateList
;
import
android.content.res.Resources
;
import
android.graphics.drawable.Drawable
;
import
android.support.v4.content.res.ResourcesCompat
;
import
android.text.TextUtils
;
import
androidx.core.content.res.ResourcesCompat
;
public
class
SkinResources
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment