├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── styles.xml
│ │ │ └── color.xml
│ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ └── layout
│ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── kotlin
│ │ └── moe
│ │ └── feng
│ │ └── material
│ │ └── statusbar
│ │ └── demo
│ │ └── MainActivity.kt
├── proguard-rules.pro
└── build.gradle
├── demo-java
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── color.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ └── layout
│ │ │ │ └── activity_main.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── moe
│ │ │ └── feng
│ │ │ └── material
│ │ │ └── statusbar
│ │ │ └── demo
│ │ │ └── MainActivity.java
│ └── androidTest
│ │ └── java
│ │ └── moe
│ │ └── feng
│ │ └── material
│ │ └── statusbar
│ │ └── ApplicationTest.java
├── build.gradle
└── proguard-rules.pro
├── library-java
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ ├── values
│ │ │ ├── attrs.xml
│ │ │ └── styles.xml
│ │ ├── values-v19
│ │ │ └── styles.xml
│ │ └── values-v21
│ │ │ └── styles.xml
│ │ └── java
│ │ └── moe
│ │ └── feng
│ │ └── material
│ │ └── statusbar
│ │ ├── StatusBarCompat.java
│ │ ├── TranslucentSBActivity.java
│ │ ├── util
│ │ └── ViewHelper.java
│ │ ├── StatusBarHeaderView.java
│ │ └── AppBarLayout.java
├── build.gradle
└── proguard-rules.pro
├── library-kotlin
├── .gitignore
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ ├── values
│ │ │ ├── attrs.xml
│ │ │ └── styles.xml
│ │ ├── values-v19
│ │ │ └── styles.xml
│ │ └── values-v21
│ │ │ └── styles.xml
│ │ └── kotlin
│ │ └── moe
│ │ └── feng
│ │ └── material
│ │ └── statusbar
│ │ ├── StatusBarCompat.kt
│ │ ├── TranslucentSBActivity.kt
│ │ ├── util
│ │ └── ViewHelper.kt
│ │ ├── StatusBarHeaderView.kt
│ │ └── AppBarLayout.kt
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── art
├── Screenshot0.png
├── Screenshot1.png
├── Screenshot2.png
└── Screenshot3.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/demo-java/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library-java/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library-kotlin/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library-kotlin', ':app', ':library-java', ':demo-java'
2 |
--------------------------------------------------------------------------------
/art/Screenshot0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/art/Screenshot0.png
--------------------------------------------------------------------------------
/art/Screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/art/Screenshot1.png
--------------------------------------------------------------------------------
/art/Screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/art/Screenshot2.png
--------------------------------------------------------------------------------
/art/Screenshot3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/art/Screenshot3.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | StatusBarCompat
3 |
4 |
--------------------------------------------------------------------------------
/demo-java/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | StatusBarCompat
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | .DS_Store
4 | /captures
5 |
6 | *.iml
7 | *.apk
8 | /.idea
9 | /*/build
10 | /build
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library-java/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-kotlin/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/demo-java/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/demo-java/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-java/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/demo-java/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-java/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fython/MaterialStatusBarCompat/HEAD/demo-java/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jul 14 17:30:42 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/demo-java/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #2196F3
5 | #1976D2
6 |
7 | #673AB7
8 | #512DA8
9 |
10 |
--------------------------------------------------------------------------------
/demo-java/src/main/res/values/color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #2196F3
5 | #1976D2
6 |
7 | #673AB7
8 | #512DA8
9 |
10 |
--------------------------------------------------------------------------------
/demo-java/src/androidTest/java/moe/feng/material/statusbar/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/library-kotlin/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/library-java/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/library-java/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 15
9 | targetSdkVersion 22
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:22.2.0'
24 | }
25 |
--------------------------------------------------------------------------------
/demo-java/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "moe.feng.material.statusbar.demo"
9 | minSdkVersion 15
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile project(':library-java')
25 | compile 'com.android.support:appcompat-v7:22.2.0'
26 | }
27 |
--------------------------------------------------------------------------------
/library-kotlin/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in G:\adt\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library-java/src/main/res/values-v19/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/library-kotlin/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in G:\adt\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/demo-java/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in G:\adt\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library-java/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in G:\adt\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/library-kotlin/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/library-java/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/library-java/src/main/java/moe/feng/material/statusbar/StatusBarCompat.java:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.view.View;
7 |
8 | import moe.feng.material.statusbar.util.ViewHelper;
9 |
10 | public class StatusBarCompat {
11 |
12 | public static void setUpActivity(Activity activity) {
13 | if (Build.VERSION.SDK_INT >= 19 && !ViewHelper.isChrome()) {
14 | activity.getWindow().getDecorView()
15 | .setSystemUiVisibility(
16 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
17 | );
18 | }
19 |
20 | if (Build.VERSION.SDK_INT >= 21) {
21 | activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/demo-java/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/library-kotlin/src/main/kotlin/moe/feng/material/statusbar/StatusBarCompat.kt:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar
2 |
3 | import android.app.Activity
4 | import android.graphics.Color
5 | import android.os.Build
6 | import android.view.View
7 | import moe.feng.material.statusbar.util.ViewHelper
8 |
9 | public class StatusBarCompat {
10 |
11 | public fun setUpActivity(activity: Activity) {
12 | if (Build.VERSION.SDK_INT >= 19 && !ViewHelper().isChrome()) {
13 | activity.getWindow().getDecorView()
14 | .setSystemUiVisibility(
15 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
16 | );
17 | }
18 |
19 | if (Build.VERSION.SDK_INT >= 21) {
20 | activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
10 | #
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | #Tue Jul 14 18:25:31 CST 2015
16 | systemProp.http.proxyHost=127.0.0.1
17 | systemProp.http.proxyPort=1080
18 |
--------------------------------------------------------------------------------
/library-kotlin/src/main/kotlin/moe/feng/material/statusbar/TranslucentSBActivity.kt:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 |
6 | open public class TranslucentSBActivity: AppCompatActivity() {
7 |
8 | var needSetTranslucent = true; var isCreated = false;
9 |
10 | override protected fun onCreate(savedInstanceState: Bundle?) {
11 | super.onCreate(savedInstanceState)
12 | if (needSetTranslucent) StatusBarCompat().setUpActivity(this)
13 | isCreated = true
14 | }
15 |
16 | public fun setStatusBarTranslucent(needSetTranslucent: Boolean) {
17 | if (isCreated) {
18 | throw ShouldSetBeforeActivityCreatedException()
19 | } else {
20 | this.needSetTranslucent = needSetTranslucent;
21 | }
22 | }
23 |
24 | public class ShouldSetBeforeActivityCreatedException : Exception() {}
25 |
26 | }
--------------------------------------------------------------------------------
/library-java/src/main/java/moe/feng/material/statusbar/TranslucentSBActivity.java:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 |
6 | public class TranslucentSBActivity extends AppCompatActivity {
7 |
8 | boolean needSetTranslucent = true, isCreated = false;
9 |
10 | @Override
11 | protected void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | if (needSetTranslucent) {
14 | StatusBarCompat.setUpActivity(this);
15 | }
16 | isCreated = true;
17 | }
18 |
19 | public void setStatusBarTranslucent(boolean should) throws ShouldSetBeforeActivityCreatedException {
20 | if (isCreated) {
21 | throw new ShouldSetBeforeActivityCreatedException();
22 | } else {
23 | this.needSetTranslucent = should;
24 | }
25 | }
26 |
27 | public class ShouldSetBeforeActivityCreatedException extends Exception {}
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/library-kotlin/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion 22
6 | buildToolsVersion "22.0.1"
7 |
8 | defaultConfig {
9 | minSdkVersion 15
10 | targetSdkVersion 22
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | sourceSets {
21 | main.java.srcDirs += 'src/main/kotlin'
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | compile 'com.android.support:appcompat-v7:22.2.0'
28 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
29 | }
30 | buildscript {
31 | ext.kotlin_version = '0.12.613'
32 | repositories {
33 | mavenCentral()
34 | }
35 | dependencies {
36 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
37 | }
38 | }
39 | repositories {
40 | mavenCentral()
41 | }
42 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion 22
6 | buildToolsVersion "22.0.1"
7 |
8 | defaultConfig {
9 | applicationId "moe.feng.material.statusbar.demo"
10 | minSdkVersion 15
11 | targetSdkVersion 22
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | sourceSets {
22 | main.java.srcDirs += 'src/main/kotlin'
23 | }
24 | }
25 |
26 | dependencies {
27 | compile fileTree(dir: 'libs', include: ['*.jar'])
28 | compile project(':library-kotlin')
29 | compile 'com.android.support:appcompat-v7:22.2.0'
30 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
31 | }
32 | buildscript {
33 | ext.kotlin_version = '0.12.613'
34 | repositories {
35 | mavenCentral()
36 | }
37 | dependencies {
38 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
39 | }
40 | }
41 | repositories {
42 | mavenCentral()
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/kotlin/moe/feng/material/statusbar/demo/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar.demo
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import android.support.v7.widget.Toolbar
6 |
7 | import moe.feng.material.statusbar.AppBarLayout
8 | import moe.feng.material.statusbar.TranslucentSBActivity
9 |
10 | public class MainActivity : TranslucentSBActivity() {
11 |
12 | var mAppBarLayout : AppBarLayout? = null
13 |
14 | override public fun onCreate(savedInstanceState: Bundle?) {
15 | super.onCreate(savedInstanceState)
16 | setContentView(R.layout.activity_main)
17 |
18 | mAppBarLayout = findViewById(R.id.appbar_layout) as AppBarLayout
19 | setSupportActionBar(findViewById(R.id.toolbar) as Toolbar)
20 |
21 | findViewById(R.id.button_blue).setOnClickListener({
22 | mAppBarLayout?.setColorResources(R.color.blue_500, R.color.blue_700)
23 | })
24 |
25 | findViewById(R.id.button_deep_purple).setOnClickListener({
26 | mAppBarLayout?.setColorResources(R.color.deep_purple_500, R.color.deep_purple_700)
27 | })
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/library-kotlin/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
14 |
18 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
31 |
--------------------------------------------------------------------------------
/library-java/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
13 |
14 |
18 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
31 |
--------------------------------------------------------------------------------
/demo-java/src/main/java/moe/feng/material/statusbar/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar.demo;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.Toolbar;
5 | import android.view.View;
6 |
7 | import moe.feng.material.statusbar.AppBarLayout;
8 | import moe.feng.material.statusbar.TranslucentSBActivity;
9 |
10 | public class MainActivity extends TranslucentSBActivity {
11 |
12 | private AppBarLayout mAppBarLayout;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 |
19 | mAppBarLayout = (AppBarLayout) findViewById(R.id.appbar_layout);
20 | setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
21 |
22 | findViewById(R.id.button_blue).setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View view) {
25 | mAppBarLayout.setColorResources(R.color.blue_500, R.color.blue_700);
26 | }
27 | });
28 |
29 | findViewById(R.id.button_deep_purple).setOnClickListener(new View.OnClickListener() {
30 | @Override
31 | public void onClick(View view) {
32 | mAppBarLayout.setColorResources(R.color.deep_purple_500, R.color.deep_purple_700);
33 | }
34 | });
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
22 |
23 |
28 |
29 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/demo-java/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
20 |
21 |
22 |
23 |
28 |
29 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/library-java/src/main/java/moe/feng/material/statusbar/util/ViewHelper.java:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar.util;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.util.TypedValue;
7 |
8 | public class ViewHelper {
9 |
10 | public static boolean isChrome(){
11 | return Build.BRAND == "chromium" || Build.BRAND == "chrome";
12 | }
13 |
14 | public static int getStatusBarHeight(Context context) {
15 | int result = 0;
16 | int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
17 | if (resourceId > 0) {
18 | result = context.getResources().getDimensionPixelSize(resourceId);
19 | }
20 | return result;
21 | }
22 |
23 | private static int getMiddleValue(int prev, int next, float factor) {
24 | return Math.round(prev + (next - prev) * factor);
25 | }
26 |
27 | public static int getMiddleColor(int prevColor, int curColor, float factor) {
28 | if (prevColor == curColor) {
29 | return curColor;
30 | };
31 |
32 | if (factor == 0f) {
33 | return prevColor;
34 | } else if(factor == 1f) {
35 | return curColor;
36 | }
37 |
38 | int a = getMiddleValue(Color.alpha(prevColor), Color.alpha(curColor), factor);
39 | int r = getMiddleValue(Color.red(prevColor), Color.red(curColor), factor);
40 | int g = getMiddleValue(Color.green(prevColor), Color.green(curColor), factor);
41 | int b = getMiddleValue(Color.blue(prevColor), Color.blue(curColor), factor);
42 |
43 | return Color.argb(a, r, g, b);
44 | }
45 |
46 | public static int getColor(int baseColor, float alphaPercent) {
47 | int alpha = Math.round(Color.alpha(baseColor) * alphaPercent);
48 |
49 | return (baseColor & 0x00FFFFFF) | (alpha << 24);
50 | }
51 |
52 | public static float dpToPx(Context context, float dp) {
53 | return TypedValue.applyDimension(
54 | TypedValue.COMPLEX_UNIT_DIP,
55 | dp,
56 | context.getResources().getDisplayMetrics()
57 | ) + 0.5f;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/library-kotlin/src/main/kotlin/moe/feng/material/statusbar/util/ViewHelper.kt:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar.util
2 |
3 | import android.content.Context
4 | import android.graphics.Color
5 | import android.os.Build
6 | import android.util.TypedValue
7 |
8 | class ViewHelper {
9 |
10 | fun isChrome(): Boolean {
11 | return Build.BRAND == "chromium" || Build.BRAND == "chrome"
12 | }
13 |
14 | fun getStatusBarHeight(context: Context): Int {
15 | var result = 0
16 | val resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android")
17 | if (resourceId > 0) {
18 | result = context.getResources().getDimensionPixelSize(resourceId)
19 | }
20 | return result
21 | }
22 |
23 | private fun getMiddleValue(prev: Int, next: Int, factor: Float): Int{
24 | return Math.round(prev + (next - prev) * factor);
25 | }
26 |
27 | fun getMiddleColor(prevColor: Int, curColor: Int, factor: Float): Int {
28 | if (prevColor == curColor) {
29 | return curColor
30 | };
31 |
32 | if (factor == 0f) {
33 | return prevColor;
34 | } else if(factor == 1f) {
35 | return curColor;
36 | }
37 |
38 | var a = getMiddleValue(Color.alpha(prevColor), Color.alpha(curColor), factor)
39 | var r = getMiddleValue(Color.red(prevColor), Color.red(curColor), factor)
40 | var g = getMiddleValue(Color.green(prevColor), Color.green(curColor), factor)
41 | var b = getMiddleValue(Color.blue(prevColor), Color.blue(curColor), factor)
42 |
43 | return Color.argb(a, r, g, b);
44 | }
45 |
46 | fun getColor(baseColor: Int, alphaPercent: Float): Int{
47 | var alpha = Math.round(Color.alpha(baseColor) * alphaPercent)
48 |
49 | return (baseColor and 0x00FFFFFF) or (alpha shl 24)
50 | }
51 |
52 | fun dpToPx(context: Context, dp: Float) : Float {
53 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()) + 0.5f;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/library-java/src/main/java/moe/feng/material/statusbar/StatusBarHeaderView.java:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.os.Build;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import moe.feng.material.statusbar.util.ViewHelper;
12 |
13 | public class StatusBarHeaderView extends View {
14 |
15 | private int colorNormal, colorDark, enableMode;
16 |
17 | public static final int MODE_KITKAT = 1, MODE_LOLLIPOP = 2, MODE_ALL = 3;
18 |
19 | public StatusBarHeaderView(Context context) {
20 | this(context, null);
21 | }
22 |
23 | public StatusBarHeaderView(Context context, AttributeSet attrs) {
24 | this(context, attrs, 0);
25 | }
26 |
27 | public StatusBarHeaderView(Context context, AttributeSet attrs, int defStyle) {
28 | super(context, attrs, defStyle);
29 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StatusBarHeaderView, defStyle,
30 | R.style.Widget_FengMoe_StatusBarHeaderView);
31 | colorNormal = a.getColor(R.styleable.StatusBarHeaderView_colorNormal, Color.TRANSPARENT);
32 | if (a.hasValue(R.styleable.StatusBarHeaderView_colorDark)) {
33 | colorDark = a.getColor(R.styleable.StatusBarHeaderView_colorDark, Color.TRANSPARENT);
34 | } else {
35 | colorDark = ViewHelper.getMiddleColor(colorNormal, Color.BLACK, 0.2f);
36 | }
37 | enableMode = a.getInt(R.styleable.StatusBarHeaderView_enableMode, MODE_ALL);
38 | init();
39 | a.recycle();
40 | }
41 |
42 | public StatusBarHeaderView(Context context, int colorNormal, int colorDark, int enableMode) {
43 | this(context);
44 | this.colorNormal = colorNormal;
45 | this.colorDark = colorDark;
46 | this.enableMode = enableMode;
47 | init();
48 | }
49 |
50 | @Override
51 | public void onMeasure(int widthSpec, int heightSpec) {
52 | super.onMeasure(widthSpec, heightSpec);
53 | adjustHeight();
54 | }
55 |
56 | @Override
57 | public void invalidate() {
58 | super.invalidate();
59 | adjustHeight();
60 | }
61 |
62 | public void adjustHeight() {
63 | ViewGroup.LayoutParams params = getLayoutParams();
64 | params.height = ViewHelper.getStatusBarHeight(getContext());
65 | }
66 |
67 | void init() {
68 | int SDK_INT = Build.VERSION.SDK_INT;
69 | this.setBackgroundColor(SDK_INT == 19 ? colorNormal : colorDark);
70 | this.setVisibility(
71 | !ViewHelper.isChrome() && (
72 | (((enableMode == MODE_KITKAT) && (SDK_INT == 19)) ||
73 | ((enableMode == MODE_LOLLIPOP) && (SDK_INT == 21)) ||
74 | ((enableMode == MODE_ALL) && (SDK_INT >= 19)))
75 | ) ? View.VISIBLE : View.GONE
76 | );
77 | }
78 |
79 | public void setNormalColor(int colorNormal) {
80 | this.colorNormal = colorNormal;
81 | init();
82 | }
83 |
84 | public void setDarkColor(int colorDark) {
85 | this.colorDark = colorDark;
86 | init();
87 | }
88 |
89 | public int getNormalColor() {
90 | return this.colorNormal;
91 | }
92 |
93 | public int getDarkColor() {
94 | return this.colorDark;
95 | }
96 |
97 | public void setMode(int mode) {
98 | this.enableMode = mode;
99 | init();
100 | }
101 |
102 | public int getMode() {
103 | return this.enableMode;
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/library-java/src/main/java/moe/feng/material/statusbar/AppBarLayout.java:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.os.Build;
7 | import android.support.annotation.ColorInt;
8 | import android.support.annotation.ColorRes;
9 | import android.util.AttributeSet;
10 | import android.widget.LinearLayout;
11 |
12 | import moe.feng.material.statusbar.util.ViewHelper;
13 |
14 | public class AppBarLayout extends LinearLayout {
15 |
16 | private int colorNormal, colorDark, enableMode;
17 |
18 | private StatusBarHeaderView headerView;
19 |
20 | public static final int MODE_KITKAT = 1, MODE_LOLLIPOP = 2, MODE_ALL = 3;
21 |
22 | public AppBarLayout(Context context) {
23 | this(context, null);
24 | }
25 |
26 | public AppBarLayout(Context context, AttributeSet attrs) {
27 | this(context, attrs, 0);
28 | }
29 |
30 | public AppBarLayout(Context context, AttributeSet attrs, int defStyle) {
31 | super(context, attrs, defStyle);
32 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StatusBarHeaderView, defStyle,
33 | R.style.Widget_FengMoe_StatusBarHeaderView);
34 | colorNormal = a.getColor(R.styleable.StatusBarHeaderView_colorNormal, Color.TRANSPARENT);
35 | if (a.hasValue(R.styleable.StatusBarHeaderView_colorDark)) {
36 | colorDark = a.getColor(R.styleable.StatusBarHeaderView_colorDark, Color.TRANSPARENT);
37 | } else {
38 | colorDark = ViewHelper.getMiddleColor(colorNormal, Color.BLACK, 0.2f);
39 | }
40 | enableMode = a.getInt(R.styleable.StatusBarHeaderView_enableMode, MODE_ALL);
41 | headerView = new StatusBarHeaderView(context, colorNormal, colorDark, enableMode);
42 | this.setBackgroundColorWithoutAlpha(colorNormal);
43 | this.setOrientation(LinearLayout.VERTICAL);
44 | this.addView(headerView);
45 | a.recycle();
46 | if (Build.VERSION.SDK_INT >= 21) {
47 | this.setElevation(ViewHelper.dpToPx(context, 5f));
48 | }
49 | }
50 |
51 | public void setNormalColor(@ColorInt int colorNormal) {
52 | this.colorNormal = colorNormal;
53 | this.setBackgroundColorWithoutAlpha(colorNormal);
54 | headerView.setNormalColor(colorNormal);
55 | headerView.init();
56 | }
57 |
58 | public void setDarkColor(@ColorInt int colorDark) {
59 | this.colorDark = colorDark;
60 | headerView.setDarkColor(colorDark);
61 | headerView.init();
62 | }
63 |
64 | public void setColor(@ColorInt int colorNormal,@ColorInt int colorDark) {
65 | this.colorNormal = colorNormal;
66 | this.colorDark = colorDark;
67 | this.setBackgroundColorWithoutAlpha(colorNormal);
68 | headerView.setNormalColor(colorNormal);
69 | headerView.setDarkColor(colorDark);
70 | headerView.init();
71 | }
72 |
73 | public void setColorResources(@ColorRes int colorNormal, @ColorRes int colorDark) {
74 | this.setColor(
75 | getResources().getColor(colorNormal),
76 | getResources().getColor(colorDark)
77 | );
78 | }
79 |
80 | public int getNormalColor() {
81 | return this.colorNormal;
82 | }
83 |
84 | public int getDarkColor(){
85 | return this.colorDark;
86 | }
87 |
88 | public void setMode(int mode) {
89 | this.enableMode = mode;
90 | headerView.setMode(mode);
91 | headerView.init();
92 | }
93 |
94 | public int getMode(){
95 | return this.enableMode;
96 | }
97 |
98 | private void setBackgroundColorWithoutAlpha(int color) {
99 | this.setBackgroundColor(Color.argb(255, Color.red(color), Color.green(color), Color.blue(color)));
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/library-kotlin/src/main/kotlin/moe/feng/material/statusbar/StatusBarHeaderView.kt:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar
2 |
3 | import android.content.Context
4 | import android.graphics.Color
5 | import android.os.Build
6 | import android.util.AttributeSet
7 | import android.view.View
8 | import moe.feng.material.statusbar.util.ViewHelper
9 |
10 | open public class StatusBarHeaderView : View {
11 |
12 | private var colorNormal : Int
13 | private var colorDark : Int
14 | private var enableMode : Int
15 |
16 | final var MODE_KITKAT = 1 ; final var MODE_LOLLIPOP = 2 ; final var MODE_ALL = 3
17 |
18 | public constructor(context: Context): this(context, null) {
19 | }
20 |
21 | public constructor(context: Context, attrs: AttributeSet?): this(context, attrs, 0) {
22 | }
23 |
24 | public constructor(context: Context, attrs: AttributeSet?, defStyle: Int): super(context, attrs, defStyle) {
25 | var a = context.obtainStyledAttributes(attrs, R.styleable.StatusBarHeaderView, defStyle,
26 | R.style.Widget_FengMoe_StatusBarHeaderView)
27 | colorNormal = a.getColor(R.styleable.StatusBarHeaderView_colorNormal, Color.TRANSPARENT)
28 | if (a.hasValue(R.styleable.StatusBarHeaderView_colorDark)) {
29 | colorDark = a.getColor(R.styleable.StatusBarHeaderView_colorDark, Color.TRANSPARENT)
30 | } else {
31 | colorDark = ViewHelper().getMiddleColor(colorNormal, Color.BLACK, 0.2f)
32 | }
33 | enableMode = a.getInt(R.styleable.StatusBarHeaderView_enableMode, MODE_KITKAT or MODE_LOLLIPOP)
34 | init()
35 | a.recycle()
36 | }
37 |
38 | public constructor(context: Context, colorNormal: Int, colorDark: Int, enableMode: Int): super(context) {
39 | this.colorNormal = colorNormal
40 | this.colorDark = colorDark
41 | this.enableMode = enableMode
42 | init()
43 | }
44 |
45 | override public fun onMeasure(widthSpec: Int, heightSpec: Int) {
46 | super.onMeasure(widthSpec, heightSpec)
47 | adjustHeight()
48 | }
49 |
50 | override public fun invalidate() {
51 | super.invalidate()
52 | adjustHeight()
53 | }
54 |
55 | public fun adjustHeight() {
56 | var params = getLayoutParams()
57 | params.height = ViewHelper().getStatusBarHeight(getContext())
58 | }
59 |
60 | fun init() {
61 | var SDK_INT = Build.VERSION.SDK_INT
62 | this.setBackgroundColor(if (SDK_INT == 19) colorNormal else colorDark)
63 | this.setVisibility(
64 | if (!ViewHelper().isChrome() and (
65 | (
66 | ((enableMode == MODE_KITKAT) and (SDK_INT == 19)) or
67 | ((enableMode == MODE_LOLLIPOP) and (SDK_INT == 21)) or
68 | ((enableMode == MODE_ALL) and (SDK_INT >= 19)))
69 | )) View.VISIBLE else View.GONE
70 | )
71 | }
72 |
73 | public fun setNormalColor(colorNormal: Int) {
74 | this.colorNormal = colorNormal
75 | init()
76 | }
77 |
78 | public fun setDarkColor(colorDark: Int) {
79 | this.colorDark = colorDark
80 | init()
81 | }
82 |
83 | public fun getNormalColor(): Int {
84 | return this.colorNormal
85 | }
86 |
87 | public fun getDarkColor(): Int {
88 | return this.colorDark
89 | }
90 |
91 | public fun setMode(mode: Int) {
92 | this.enableMode = mode
93 | init()
94 | }
95 |
96 | public fun getMode(): Int {
97 | return this.enableMode
98 | }
99 |
100 | }
--------------------------------------------------------------------------------
/library-kotlin/src/main/kotlin/moe/feng/material/statusbar/AppBarLayout.kt:
--------------------------------------------------------------------------------
1 | package moe.feng.material.statusbar
2 |
3 | import android.content.Context
4 | import android.graphics.Color
5 | import android.os.Build
6 | import android.util.AttributeSet
7 | import android.util.TypedValue
8 | import android.widget.LinearLayout
9 | import moe.feng.material.statusbar.R
10 | import moe.feng.material.statusbar.StatusBarHeaderView
11 | import moe.feng.material.statusbar.util.ViewHelper
12 |
13 | open public class AppBarLayout : LinearLayout {
14 |
15 | private var colorNormal : Int
16 | private var colorDark : Int
17 | private var enableMode : Int
18 |
19 | private var headerView: StatusBarHeaderView
20 |
21 | final var MODE_KITKAT = 1 ; final var MODE_LOLLIPOP = 2 ; final var MODE_ALL = 3
22 |
23 | public constructor(context: Context) : this(context, null) {
24 | }
25 |
26 | public constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) {
27 | }
28 |
29 | public constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle) {
30 | var a = context.obtainStyledAttributes(attrs, R.styleable.StatusBarHeaderView, defStyle,
31 | R.style.Widget_FengMoe_StatusBarHeaderView)
32 | colorNormal = a.getColor(R.styleable.StatusBarHeaderView_colorNormal, Color.TRANSPARENT)
33 | if (a.hasValue(R.styleable.StatusBarHeaderView_colorDark)) {
34 | colorDark = a.getColor(R.styleable.StatusBarHeaderView_colorDark, Color.TRANSPARENT)
35 | } else {
36 | colorDark = ViewHelper().getMiddleColor(colorNormal, Color.BLACK, 0.2f)
37 | }
38 | enableMode = a.getInt(R.styleable.StatusBarHeaderView_enableMode, MODE_KITKAT or MODE_LOLLIPOP)
39 | headerView = StatusBarHeaderView(context, colorNormal, colorDark, enableMode)
40 | this.setBackgroundColorWithoutAlpha(colorNormal)
41 | this.setOrientation(LinearLayout.VERTICAL)
42 | this.addView(headerView)
43 | a.recycle()
44 | if (Build.VERSION.SDK_INT >= 21) {
45 | this.setElevation(ViewHelper().dpToPx(context, 5f))
46 | }
47 | }
48 |
49 | public fun setNormalColor(colorNormal: Int) {
50 | this.colorNormal = colorNormal
51 | this.setBackgroundColorWithoutAlpha(colorNormal)
52 | headerView.setNormalColor(colorNormal)
53 | headerView.init()
54 | }
55 |
56 | public fun setDarkColor(colorDark: Int) {
57 | this.colorDark = colorDark
58 | headerView.setDarkColor(colorDark)
59 | headerView.init()
60 | }
61 |
62 | public fun setColor(colorNormal: Int, colorDark: Int) {
63 | this.colorNormal = colorNormal
64 | this.colorDark = colorDark
65 | this.setBackgroundColorWithoutAlpha(colorNormal)
66 | headerView.setNormalColor(colorNormal)
67 | headerView.setDarkColor(colorDark)
68 | headerView.init()
69 | }
70 |
71 | public fun setColorResources(colorNormal: Int, colorDark: Int) {
72 | this.setColor(
73 | getResources().getColor(colorNormal),
74 | getResources().getColor(colorDark)
75 | )
76 | }
77 |
78 | public fun getNormalColor(): Int {
79 | return this.colorNormal
80 | }
81 |
82 | public fun getDarkColor(): Int {
83 | return this.colorDark
84 | }
85 |
86 | public fun setMode(mode: Int) {
87 | this.enableMode = mode
88 | headerView.setMode(mode)
89 | headerView.init()
90 | }
91 |
92 | public fun getMode(): Int {
93 | return this.enableMode
94 | }
95 |
96 | private fun setBackgroundColorWithoutAlpha(color: Int) {
97 | this.setBackgroundColor(Color.argb(255, Color.red(color), Color.green(color), Color.blue(color)))
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MaterialStatusBarCompat
2 | Easy to make status bar translucent/tint on both Kitkat and Lollipop
3 | 完美地使 Kitkat 与 Lollipop 上的状态栏同时透明/变色
4 |
5 | 第一个版本只有 Kotlin 版本,是作为 Hello, Kotlin! 的存在。
6 | 考虑到 Kotlin 在 Android 使用会增大安装包体积,稍后会推出 Java 版本。
7 |
8 | Tips: It may not be compatibled with Android Support Design Library.
9 | 提示:不保证和 Android Support Design Library 兼容。(我也不打算兼容因为我很讨厌它很多奇葩问题)
10 |
11 | ### Screenshots 截图
12 |
13 | Lollipop
14 |  
15 |
16 | Kitkat
17 |  
18 |
19 | ### Usage 用法
20 |
21 | ##### Step 0 第一步
22 |
23 | First, use `Theme.AppCompat.*.TranslucentStatusBar` instead of `Theme.AppCompat.*`
24 | 首先,采用 `Theme.AppCompat.*.TranslucentStatusBar` 主题代替 `Theme.AppCompat.*`
25 |
26 |
27 | ##### Step 1 第二步
28 |
29 | Then, modify your Java/Kotlin code by these ways.
30 | 接着,根据这些方法修改你的 Java/Kotlin 中的 Activity 部分
31 |
32 | Way 0 方法一:
33 |
34 | Call `StatusBarCompat.setUpActivity(this)` before `setContentView()` in your activites
35 | 在你的 Activity 中调用 `setContentView()` 之前调用 `StatusBarCompat.setUpActivity(this)`
36 |
37 | Java code:
38 | ```
39 | @Override
40 | public void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | StatusBarCompat.setUpActivity(this);
43 | setContentView(R.layout.activity_xxxxx);
44 | }
45 | ```
46 |
47 | Kotlin code:
48 | ```
49 | override public fun onCreate(savedInstanceState: Bundle?) {
50 | super.onCreate(savedInstanceState)
51 | StatusBarCompat().setUpActivity(this)
52 | setContentView(R.layout.activity_xxxxx)
53 | }
54 | ```
55 |
56 | Way 1 方法二:
57 |
58 | Use `TranslucentSBActivity` instead of `AppCompatActivity`
59 | 使用 `TranslucentSBActivity` 代替 `AppCompatActivity`
60 |
61 | ##### Step 2 第三步
62 |
63 | Way 0 方法一:
64 |
65 | Add `StatusBarHeaderView` above `Toolbar` in layout
66 | 在布局中添加 `StatusBarHeaderView` 到 `Toolbar` 上面
67 |
68 | ```
69 |
72 |
77 |
79 |
80 | ```
81 |
82 | Way 1 方法二:
83 |
84 | Put `Toolbar` and other views which should be a part of appbar (Such as `TabLayout`) in `AppBarLayout`
85 | 将 `Toolbar` 和其他应当作为 App 顶栏一部分的 View (比如 Tab 栏) 放在 `AppBarLayout` 中
86 |
87 | PS: AppBarLayout is based on a vertical LinearLayout(AppBarLayout 基于垂直方向的 LinearLayout)
88 |
89 | ```
90 |
94 |
96 |
97 | ```
98 |
99 | ##### Step 3 第三步
100 |
101 | Finish! You also can change their color in Java/Kotlin code.
102 | 没有第三步了!你也可以在 Java/Kotlin 代码中随时更改它们的颜色。
103 |
104 |
105 | ### Contact me 联系我
106 |
107 | Google Plus: +Fung Jichun
108 | 新浪微博: @某燒餅
109 | 我的 Android 开发交流群: 34725246
110 |
111 | ### 支持项目
112 |
113 | Alipay 支付宝: 316643843@qq.com
114 |
115 | ### License 开源协议
116 |
117 | ```
118 | Copyright 2015 FengMoe
119 |
120 | Licensed under the Apache License, Version 2.0 (the "License");
121 | you may not use this file except in compliance with the License.
122 | You may obtain a copy of the License at
123 |
124 | http://www.apache.org/licenses/LICENSE-2.0
125 |
126 | Unless required by applicable law or agreed to in writing, software
127 | distributed under the License is distributed on an "AS IS" BASIS,
128 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129 | See the License for the specific language governing permissions and
130 | limitations under the License.
131 | ```
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------