Repository: laobie/StatusBarUtil
Branch: master
Commit: 8bc86216b753
Files: 64
Total size: 111.3 KB
Directory structure:
gitextract_8yo7vtyc/
├── .gitignore
├── CHANGE_LOG.md
├── LICENSE.md
├── README.md
├── build.gradle
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── library/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src/
│ ├── androidTest/
│ │ └── java/
│ │ └── com/
│ │ └── example/
│ │ └── library/
│ │ └── ApplicationTest.java
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── jaeger/
│ │ └── library/
│ │ └── StatusBarUtil.java
│ └── res/
│ └── values/
│ ├── ids.xml
│ └── strings.xml
├── sample/
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ ├── release/
│ │ ├── output.json
│ │ └── sample-release.apk
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ └── com/
│ │ └── jaeger/
│ │ └── statusbarutil/
│ │ ├── BaseActivity.java
│ │ ├── ColorStatusBarActivity.java
│ │ ├── ImageFragment.java
│ │ ├── ImageStatusBarActivity.java
│ │ ├── ImageViewActivity.java
│ │ ├── MainActivity.java
│ │ ├── SimpleFragment.java
│ │ ├── SwipeBackActivity.java
│ │ ├── SwitchModeActivity.java
│ │ └── UseInFragmentActivity.java
│ └── res/
│ ├── anim/
│ │ ├── slide_in_left.xml
│ │ ├── slide_in_right.xml
│ │ ├── slide_out_left.xml
│ │ └── slide_out_right.xml
│ ├── drawable/
│ │ ├── ic_menu_camera.xml
│ │ ├── ic_menu_gallery.xml
│ │ ├── ic_menu_manage.xml
│ │ ├── ic_menu_send.xml
│ │ ├── ic_menu_share.xml
│ │ └── ic_menu_slideshow.xml
│ ├── layout/
│ │ ├── activity_color_status_bar.xml
│ │ ├── activity_image_status_bar.xml
│ │ ├── activity_image_view.xml
│ │ ├── activity_main.xml
│ │ ├── activity_switch_mode.xml
│ │ ├── activity_use_in_fragment.xml
│ │ ├── fragement_image.xml
│ │ ├── fragement_simple.xml
│ │ ├── nav_header.xml
│ │ ├── sss.xml
│ │ └── swipe_back_activity.xml
│ ├── menu/
│ │ ├── activity_main_drawer.xml
│ │ └── bottom_bar_items.xml
│ ├── values/
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── values-v19/
│ │ └── dimens.xml
│ └── values-w820dp/
│ └── dimens.xml
└── settings.gradle
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.idea
================================================
FILE: CHANGE_LOG.md
================================================
## Change Log
### 1.5.1
fix set light/dark mode bug
### 1.5.0
add set light/dark mode method
### 1.4.0
fix typo
### 1.3.6
- bug fix and remove StatusBarView
### 1.3.5
- add method `hideFakeStatusBarView` to hide fake StatusBarView
### 1.3.4
### 1.3.3
- fix `setColorForSwipeBack` method with `CoordinatorLayout` bug
### 1.3.2
- Bug fix
### 1.3.1
- Bug fix
### 1.3.0
- Fix multi-fragment problem && rootView may not ViewGroup bug
#### 1.2.8
####
- fix method `setColorDiff` bug
### 1.2.7
- add `setColorForSwipeBack` method, now support
- [r0adkll/Slidr: Easily add slide to dismiss functionality to an Activity](https://github.com/r0adkll/Slidr)
### 1.2.6
- update support version to 24.2.1
### 1.2.5
- add `@ColorInt`, if you pass a color res, now you will get a error
- fix bug: ContentView in DrawerLayout padding not work
### 1.2.4
- fix bug in method `setTransparentForImageViewInFragment`
### 1.2.3
- fix method `setTranslucentForImageView` support pass null as needOffsetView
- add method for fragment witch using ImageView as head view
~~~ java
setTranslucentForImageViewInFragment(Activity activity, View needOffsetView)
setTransparentForImageViewInFragment(Activity activity, View needOffsetView)
~~~
- fix setTranslucent bug when root layout is CoordinatorLayout
~~~ java
setTranslucentForCoordinatorLayout(Activity activity, int statusBarAlpha)
~~~
### 1.2.0
- add method for page witch using ImageView as head view
~~~ java
setTranslucentForImageView(Activity activity, int statusBarAlpha, View needOffsetView)
~~~
and
~~~ java
setTranslucentForImageView(Activity activity, View needOffsetView)
~~~
### 1.1.1
- fix set color bug on 4.4 devices
### 1.1.0
- fix some bugs
### 1.0.0
- first publish
================================================
FILE: LICENSE.md
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
# StatusBarUtil
[](https://996.icu)
[](https://android-arsenal.com/details/1/3341)
[  ](https://bintray.com/laobie/maven/StatusBarUtil/_latestVersion)
A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4).
[中文版点我](http://laobie.github.io/android/2016/03/27/statusbar-util.html)

### Sample
[Download StatusBarUtil-Demo](http://fir.im/5mnp)
### ChangeLog
[CLICK ME](CHANGE_LOG.md)
### Usage
1. Add the dependencies to your build.gradle file, StatusBarUtil is avaiable in JCenter:
```groovy
compile 'com.jaeger.statusbarutil:library:1.5.1'
```
I fixed typo, change "statusbaruitl" to "statusbarutil", please notice this.
2. Call method you need after `setContentView()`, such as :
```java
setContentView(R.layout.main_activity);
...
StatusBarUtil.setColor(MainActivity.this, mColor);
```
3. If you use this util in a page which containing a `DrawerLayout`, you need add `android:fitsSystemWindows="true"` for `DrawerLayout` in your layout XML:
```xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
...
</android.support.v4.widget.DrawerLayout>
```
4. Set color for swipe back page
Recommend using with [bingoogolapple/BGASwipeBackLayout\-Android: Android Activity 滑动返回](https://github.com/bingoogolapple/BGASwipeBackLayout-Android)
```java
StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)
```
5. All `statusBarAlpha` value you set should between 0 ~ 255
6. How to use in Fragment, please read [UseInFragmentActivity.java](https://github.com/laobie/StatusBarUtil/blob/master/sample/src/main/java/com/jaeger/statusbarutil/UseInFragmentActivity.java)
Handle all Fragments in ViewPager as ImageViewFragment, add a fake View in your Fragment layout as StatusBar :
```xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="@+id/fake_statusbar_view"
android:layout_width="match_parent"
android:layout_height="@dimen/statusbar_view_height"
android:background="@color/colorPrimary"/>
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/colorPrimary"
android:gravity="center"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="24sp"/>
</LinearLayout>
```
The fake StatusBar View height value ` statusbar_view_height` defined in `dimens.xml`
```xml
~ values-v19/dimens.xml
<dimen name="statusbar_view_height">25dp</dimen>
~ values/dimens.xml
<dimen name="statusbar_view_height">0dp</dimen>
```
When you change StatusBarColor :
```java
mFakeStatusBar.setBackgroundColor(color);
```
Then in the Activity which contains ViewPage, just invoke
```java
StatusBarUtil.setTranslucentForImageViewInFragment(UseInFragmentActivity.this, null);
```
Please read [UseInFragmentActivity.java](https://github.com/laobie/StatusBarUtil/blob/master/sample/src/main/java/com/jaeger/statusbarutil/UseInFragmentActivity.java)
### Features
- Set status bar color
```java
StatusBarUtil.setColor(Activity activity, int color)
```

- Set status bar translucent
```java
StatusBarUtil.setTranslucent(Activity activity, int statusBarAlpha)
```

- Set status bar transparent
```java
StatusBarUtil.setTransparent(Activity activity)
```

- Set status bar color for `DrawerLayout`
```java
StatusBarUtil.setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int color)
```

- Set translucent status bar for using ImageView as head view page
```java
StatusBarUtil.setTranslucentForImageView(Activity activity, int statusBarAlpha, View needOffsetView)
```

- Set Light or Dark mode
```
StatusBarUtil.setLightMode(Activity activity)
StatusBarUtil.setDarkMode(Activity activity)
```

- Use in fragment

- Set color for swipe back page
```java
StatusBarUtil.setColorForSwipeBack(Activity activity, @ColorInt int color, int statusBarAlpha)
```

- Pass statusBarAlpha param when necessary to change your status bar alpha, which is 112 by default.
### License
Copyright 2016 Jaeger Chen
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: build.gradle
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}
//apply plugin: 'com.jfrog.bintray'
allprojects {
repositories {
jcenter()
maven {
url "http://dl.bintray.com/laobie/maven"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
#Thu Mar 08 15:16:34 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
================================================
FILE: gradle.properties
================================================
## Project-wide Gradle settings.
#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sun Feb 14 13:26:50 CST 2016
#systemProp.http.proxyHost=127.0.0.1
#systemProp.http.proxyPort=1080
================================================
FILE: gradlew
================================================
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
================================================
FILE: gradlew.bat
================================================
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
================================================
FILE: library/.gitignore
================================================
/build
================================================
FILE: library/build.gradle
================================================
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "1.5.1"
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
resourcePrefix "statusbarutil_"
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
}
def siteUrl = 'https://github.com/laobie/StatusBarUtil'
def gitUrl = 'https://github.com/laobie/StatusBarUtil.git'
def issueUrl = 'https://github.com/laobie/StatusBarUtil/issues'
group = "com.jaeger.statusbarutil"
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
name 'Android StatusBar Util'
url siteUrl
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'laobie' //填写的一些基本信息
name 'Jaeger Chen'
email 'chjie.jaeger@gmail.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
options.encoding = "UTF-8"
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = "StatusBarUtil"
desc = 'Android StatusBar Util'
websiteUrl = siteUrl
issueTrackerUrl = issueUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
labels = ['android']
publish = true
publicDownloadNumbers = true
}
}
================================================
FILE: library/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Jaeger/Develop/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: library/src/androidTest/java/com/example/library/ApplicationTest.java
================================================
package com.example.library;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
================================================
FILE: library/src/main/AndroidManifest.xml
================================================
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jaeger.library">
<application />
</manifest>
================================================
FILE: library/src/main/java/com/jaeger/library/StatusBarUtil.java
================================================
package com.jaeger.library;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* Created by Jaeger on 16/2/14.
* <p>
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class StatusBarUtil {
public static final int DEFAULT_STATUS_BAR_ALPHA = 112;
private static final int FAKE_STATUS_BAR_VIEW_ID = R.id.statusbarutil_fake_status_bar_view;
private static final int FAKE_TRANSLUCENT_VIEW_ID = R.id.statusbarutil_translucent_view;
private static final int TAG_KEY_HAVE_SET_OFFSET = -123;
/**
* 设置状态栏颜色
*
* @param activity 需要设置的 activity
* @param color 状态栏颜色值
*/
public static void setColor(Activity activity, @ColorInt int color) {
setColor(activity, color, DEFAULT_STATUS_BAR_ALPHA);
}
/**
* 设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColor(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {
if (fakeStatusBarView.getVisibility() == View.GONE) {
fakeStatusBarView.setVisibility(View.VISIBLE);
}
fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
} else {
decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
}
setRootView(activity);
}
}
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
*/
public static void setColorForSwipeBack(Activity activity, int color) {
setColorForSwipeBack(activity, color, DEFAULT_STATUS_BAR_ALPHA);
}
/**
* 为滑动返回界面设置状态栏颜色
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForSwipeBack(Activity activity, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
View rootView = contentView.getChildAt(0);
int statusBarHeight = getStatusBarHeight(activity);
if (rootView != null && rootView instanceof CoordinatorLayout) {
final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
coordinatorLayout.setFitsSystemWindows(false);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
if (isNeedRequestLayout) {
contentView.setPadding(0, statusBarHeight, 0, 0);
coordinatorLayout.post(new Runnable() {
@Override
public void run() {
coordinatorLayout.requestLayout();
}
});
}
} else {
coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
} else {
contentView.setPadding(0, statusBarHeight, 0, 0);
contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setTransparentForWindow(activity);
}
}
/**
* 设置状态栏纯色 不加半透明效果
*
* @param activity 需要设置的 activity
* @param color 状态栏颜色值
*/
public static void setColorNoTranslucent(Activity activity, @ColorInt int color) {
setColor(activity, color, 0);
}
/**
* 设置状态栏颜色(5.0以下无半透明效果,不建议使用)
*
* @param activity 需要设置的 activity
* @param color 状态栏颜色值
*/
@Deprecated
public static void setColorDiff(Activity activity, @ColorInt int color) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
transparentStatusBar(activity);
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
// 移除半透明矩形,以免叠加
View fakeStatusBarView = contentView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {
if (fakeStatusBarView.getVisibility() == View.GONE) {
fakeStatusBarView.setVisibility(View.VISIBLE);
}
fakeStatusBarView.setBackgroundColor(color);
} else {
contentView.addView(createStatusBarView(activity, color));
}
setRootView(activity);
}
/**
* 使状态栏半透明
* <p>
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
*
* @param activity 需要设置的activity
*/
public static void setTranslucent(Activity activity) {
setTranslucent(activity, DEFAULT_STATUS_BAR_ALPHA);
}
/**
* 使状态栏半透明
* <p>
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
*
* @param activity 需要设置的activity
* @param statusBarAlpha 状态栏透明度
*/
public static void setTranslucent(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
setTransparent(activity);
addTranslucentView(activity, statusBarAlpha);
}
/**
* 针对根布局是 CoordinatorLayout, 使状态栏半透明
* <p>
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
*
* @param activity 需要设置的activity
* @param statusBarAlpha 状态栏透明度
*/
public static void setTranslucentForCoordinatorLayout(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
transparentStatusBar(activity);
addTranslucentView(activity, statusBarAlpha);
}
/**
* 设置状态栏全透明
*
* @param activity 需要设置的activity
*/
public static void setTransparent(Activity activity) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
transparentStatusBar(activity);
setRootView(activity);
}
/**
* 使状态栏透明(5.0以上半透明效果,不建议使用)
* <p>
* 适用于图片作为背景的界面,此时需要图片填充到状态栏
*
* @param activity 需要设置的activity
*/
@Deprecated
public static void setTranslucentDiff(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// 设置状态栏透明
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
setRootView(activity);
}
}
/**
* 为DrawerLayout 布局设置状态栏变色
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
* @param color 状态栏颜色值
*/
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
setColorForDrawerLayout(activity, drawerLayout, color, DEFAULT_STATUS_BAR_ALPHA);
}
/**
* 为DrawerLayout 布局设置状态栏颜色,纯色
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
* @param color 状态栏颜色值
*/
public static void setColorNoTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
setColorForDrawerLayout(activity, drawerLayout, color, 0);
}
/**
* 为DrawerLayout 布局设置状态栏变色
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
* @param color 状态栏颜色值
* @param statusBarAlpha 状态栏透明度
*/
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
} else {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
// 生成一个状态栏大小的矩形
// 添加 statusBarView 到布局中
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {
if (fakeStatusBarView.getVisibility() == View.GONE) {
fakeStatusBarView.setVisibility(View.VISIBLE);
}
fakeStatusBarView.setBackgroundColor(color);
} else {
contentLayout.addView(createStatusBarView(activity, color), 0);
}
// 内容布局不是 LinearLayout 时,设置padding top
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
contentLayout.getChildAt(1)
.setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(),
contentLayout.getPaddingRight(), contentLayout.getPaddingBottom());
}
// 设置属性
setDrawerLayoutProperty(drawerLayout, contentLayout);
addTranslucentView(activity, statusBarAlpha);
}
/**
* 设置 DrawerLayout 属性
*
* @param drawerLayout DrawerLayout
* @param drawerLayoutContentLayout DrawerLayout 的内容布局
*/
private static void setDrawerLayoutProperty(DrawerLayout drawerLayout, ViewGroup drawerLayoutContentLayout) {
ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
drawerLayout.setFitsSystemWindows(false);
drawerLayoutContentLayout.setFitsSystemWindows(false);
drawerLayoutContentLayout.setClipToPadding(true);
drawer.setFitsSystemWindows(false);
}
/**
* 为DrawerLayout 布局设置状态栏变色(5.0以下无半透明效果,不建议使用)
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
* @param color 状态栏颜色值
*/
@Deprecated
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 生成一个状态栏大小的矩形
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {
if (fakeStatusBarView.getVisibility() == View.GONE) {
fakeStatusBarView.setVisibility(View.VISIBLE);
}
fakeStatusBarView.setBackgroundColor(calculateStatusColor(color, DEFAULT_STATUS_BAR_ALPHA));
} else {
// 添加 statusBarView 到布局中
contentLayout.addView(createStatusBarView(activity, color), 0);
}
// 内容布局不是 LinearLayout 时,设置padding top
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
}
// 设置属性
setDrawerLayoutProperty(drawerLayout, contentLayout);
}
}
/**
* 为 DrawerLayout 布局设置状态栏透明
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
*/
public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
setTranslucentForDrawerLayout(activity, drawerLayout, DEFAULT_STATUS_BAR_ALPHA);
}
/**
* 为 DrawerLayout 布局设置状态栏透明
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
*/
public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout,
@IntRange(from = 0, to = 255) int statusBarAlpha) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
setTransparentForDrawerLayout(activity, drawerLayout);
addTranslucentView(activity, statusBarAlpha);
}
/**
* 为 DrawerLayout 布局设置状态栏透明
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
*/
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
} else {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
// 内容布局不是 LinearLayout 时,设置padding top
if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
}
// 设置属性
setDrawerLayoutProperty(drawerLayout, contentLayout);
}
/**
* 为 DrawerLayout 布局设置状态栏透明(5.0以上半透明效果,不建议使用)
*
* @param activity 需要设置的activity
* @param drawerLayout DrawerLayout
*/
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// 设置状态栏透明
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 设置内容布局属性
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
contentLayout.setFitsSystemWindows(true);
contentLayout.setClipToPadding(true);
// 设置抽屉布局属性
ViewGroup vg = (ViewGroup) drawerLayout.getChildAt(1);
vg.setFitsSystemWindows(false);
// 设置 DrawerLayout 属性
drawerLayout.setFitsSystemWindows(false);
}
}
/**
* 为头部是 ImageView 的界面设置状态栏全透明
*
* @param activity 需要设置的activity
* @param needOffsetView 需要向下偏移的 View
*/
public static void setTransparentForImageView(Activity activity, View needOffsetView) {
setTranslucentForImageView(activity, 0, needOffsetView);
}
/**
* 为头部是 ImageView 的界面设置状态栏透明(使用默认透明度)
*
* @param activity 需要设置的activity
* @param needOffsetView 需要向下偏移的 View
*/
public static void setTranslucentForImageView(Activity activity, View needOffsetView) {
setTranslucentForImageView(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView);
}
/**
* 为头部是 ImageView 的界面设置状态栏透明
*
* @param activity 需要设置的activity
* @param statusBarAlpha 状态栏透明度
* @param needOffsetView 需要向下偏移的 View
*/
public static void setTranslucentForImageView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha,
View needOffsetView) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
setTransparentForWindow(activity);
addTranslucentView(activity, statusBarAlpha);
if (needOffsetView != null) {
Object haveSetOffset = needOffsetView.getTag(TAG_KEY_HAVE_SET_OFFSET);
if (haveSetOffset != null && (Boolean) haveSetOffset) {
return;
}
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
layoutParams.setMargins(layoutParams.leftMargin, layoutParams.topMargin + getStatusBarHeight(activity),
layoutParams.rightMargin, layoutParams.bottomMargin);
needOffsetView.setTag(TAG_KEY_HAVE_SET_OFFSET, true);
}
}
/**
* 为 fragment 头部是 ImageView 的设置状态栏透明
*
* @param activity fragment 对应的 activity
* @param needOffsetView 需要向下偏移的 View
*/
public static void setTranslucentForImageViewInFragment(Activity activity, View needOffsetView) {
setTranslucentForImageViewInFragment(activity, DEFAULT_STATUS_BAR_ALPHA, needOffsetView);
}
/**
* 为 fragment 头部是 ImageView 的设置状态栏透明
*
* @param activity fragment 对应的 activity
* @param needOffsetView 需要向下偏移的 View
*/
public static void setTransparentForImageViewInFragment(Activity activity, View needOffsetView) {
setTranslucentForImageViewInFragment(activity, 0, needOffsetView);
}
/**
* 为 fragment 头部是 ImageView 的设置状态栏透明
*
* @param activity fragment 对应的 activity
* @param statusBarAlpha 状态栏透明度
* @param needOffsetView 需要向下偏移的 View
*/
public static void setTranslucentForImageViewInFragment(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha,
View needOffsetView) {
setTranslucentForImageView(activity, statusBarAlpha, needOffsetView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
clearPreviousSetting(activity);
}
}
/**
* 隐藏伪状态栏 View
*
* @param activity 调用的 Activity
*/
public static void hideFakeStatusBarView(Activity activity) {
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {
fakeStatusBarView.setVisibility(View.GONE);
}
View fakeTranslucentView = decorView.findViewById(FAKE_TRANSLUCENT_VIEW_ID);
if (fakeTranslucentView != null) {
fakeTranslucentView.setVisibility(View.GONE);
}
}
@TargetApi(Build.VERSION_CODES.M)
public static void setLightMode(Activity activity) {
setMIUIStatusBarDarkIcon(activity, true);
setMeizuStatusBarDarkIcon(activity, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
@TargetApi(Build.VERSION_CODES.M)
public static void setDarkMode(Activity activity) {
setMIUIStatusBarDarkIcon(activity, false);
setMeizuStatusBarDarkIcon(activity, false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
/**
* 修改 MIUI V6 以上状态栏颜色
*/
private static void setMIUIStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) {
Class<? extends Window> clazz = activity.getWindow().getClass();
try {
Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
int darkModeFlag = field.getInt(layoutParams);
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
extraFlagField.invoke(activity.getWindow(), darkIcon ? darkModeFlag : 0, darkModeFlag);
} catch (Exception e) {
//e.printStackTrace();
}
}
/**
* 修改魅族状态栏字体颜色 Flyme 4.0
*/
private static void setMeizuStatusBarDarkIcon(@NonNull Activity activity, boolean darkIcon) {
try {
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
darkFlag.setAccessible(true);
meizuFlags.setAccessible(true);
int bit = darkFlag.getInt(null);
int value = meizuFlags.getInt(lp);
if (darkIcon) {
value |= bit;
} else {
value &= ~bit;
}
meizuFlags.setInt(lp, value);
activity.getWindow().setAttributes(lp);
} catch (Exception e) {
//e.printStackTrace();
}
}
///////////////////////////////////////////////////////////////////////////////////
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
View fakeStatusBarView = decorView.findViewById(FAKE_STATUS_BAR_VIEW_ID);
if (fakeStatusBarView != null) {
decorView.removeView(fakeStatusBarView);
ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
rootView.setPadding(0, 0, 0, 0);
}
}
/**
* 添加半透明矩形条
*
* @param activity 需要设置的 activity
* @param statusBarAlpha 透明值
*/
private static void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) {
ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
View fakeTranslucentView = contentView.findViewById(FAKE_TRANSLUCENT_VIEW_ID);
if (fakeTranslucentView != null) {
if (fakeTranslucentView.getVisibility() == View.GONE) {
fakeTranslucentView.setVisibility(View.VISIBLE);
}
fakeTranslucentView.setBackgroundColor(Color.argb(statusBarAlpha, 0, 0, 0));
} else {
contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}
}
/**
* 生成一个和状态栏大小相同的彩色矩形条
*
* @param activity 需要设置的 activity
* @param color 状态栏颜色值
* @return 状态栏矩形条
*/
private static View createStatusBarView(Activity activity, @ColorInt int color) {
return createStatusBarView(activity, color, 0);
}
/**
* 生成一个和状态栏大小相同的半透明矩形条
*
* @param activity 需要设置的activity
* @param color 状态栏颜色值
* @param alpha 透明值
* @return 状态栏矩形条
*/
private static View createStatusBarView(Activity activity, @ColorInt int color, int alpha) {
// 绘制一个和状态栏一样高的矩形
View statusBarView = new View(activity);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
statusBarView.setLayoutParams(params);
statusBarView.setBackgroundColor(calculateStatusColor(color, alpha));
statusBarView.setId(FAKE_STATUS_BAR_VIEW_ID);
return statusBarView;
}
/**
* 设置根布局参数
*/
private static void setRootView(Activity activity) {
ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content);
for (int i = 0, count = parent.getChildCount(); i < count; i++) {
View childView = parent.getChildAt(i);
if (childView instanceof ViewGroup) {
childView.setFitsSystemWindows(true);
((ViewGroup) childView).setClipToPadding(true);
}
}
}
/**
* 设置透明
*/
private static void setTransparentForWindow(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
activity.getWindow()
.getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
activity.getWindow()
.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
/**
* 使状态栏透明
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void transparentStatusBar(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
} else {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
/**
* 创建半透明矩形 View
*
* @param alpha 透明值
* @return 半透明 View
*/
private static View createTranslucentStatusBarView(Activity activity, int alpha) {
// 绘制一个和状态栏一样高的矩形
View statusBarView = new View(activity);
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
statusBarView.setLayoutParams(params);
statusBarView.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
statusBarView.setId(FAKE_TRANSLUCENT_VIEW_ID);
return statusBarView;
}
/**
* 获取状态栏高度
*
* @param context context
* @return 状态栏高度
*/
private static int getStatusBarHeight(Context context) {
// 获得状态栏高度
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
return context.getResources().getDimensionPixelSize(resourceId);
}
/**
* 计算状态栏颜色
*
* @param color color值
* @param alpha alpha值
* @return 最终的状态栏颜色
*/
private static int calculateStatusColor(@ColorInt int color, int alpha) {
if (alpha == 0) {
return color;
}
float a = 1 - alpha / 255f;
int red = color >> 16 & 0xff;
int green = color >> 8 & 0xff;
int blue = color & 0xff;
red = (int) (red * a + 0.5);
green = (int) (green * a + 0.5);
blue = (int) (blue * a + 0.5);
return 0xff << 24 | red << 16 | green << 8 | blue;
}
}
================================================
FILE: library/src/main/res/values/ids.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="statusbarutil_fake_status_bar_view" />
<item type="id" name="statusbarutil_translucent_view" />
</resources>
================================================
FILE: library/src/main/res/values/strings.xml
================================================
<resources>
</resources>
================================================
FILE: sample/.gitignore
================================================
/build
================================================
FILE: sample/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.jaeger.statusbardemo"
minSdkVersion 14
targetSdkVersion 27
versionCode 8
versionName "1.5.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.1.0'
compile 'com.android.support:design:27.1.0'
compile 'com.ashokvarma.android:bottom-navigation-bar:1.3.0'
compile 'com.r0adkll:slidableactivity:2.0.5'
compile project(path: ':library')
// compile 'com.jaeger.statusbaruitl:library:1.3.2'
}
================================================
FILE: sample/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Jaeger/Develop/android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: sample/release/output.json
================================================
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":6},"path":"sample-release.apk","properties":{"packageId":"com.jaeger.statusbardemo","split":"","minSdkVersion":"14"}}]
================================================
FILE: sample/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jaeger.statusbardemo">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.jaeger.statusbarutil.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="com.jaeger.statusbarutil.ColorStatusBarActivity"
android:label="@string/app_name"/>
<activity android:name="com.jaeger.statusbarutil.ImageStatusBarActivity"/>
<activity android:name="com.jaeger.statusbarutil.ImageViewActivity"/>
<activity android:name="com.jaeger.statusbarutil.UseInFragmentActivity"/>
<activity android:name="com.jaeger.statusbarutil.SwipeBackActivity"/>
<activity android:name="com.jaeger.statusbarutil.SwitchModeActivity"/>
</application>
</manifest>
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/BaseActivity.java
================================================
package com.jaeger.statusbarutil;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
/**
* Created by Jaeger on 16/2/14.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class BaseActivity extends AppCompatActivity {
@Override
public void setContentView(int layoutResID) {
super.setContentView(layoutResID);
setStatusBar();
}
protected void setStatusBar() {
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/ColorStatusBarActivity.java
================================================
package com.jaeger.statusbarutil;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
import java.util.Random;
/**
* Created by Jaeger on 16/2/14.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class ColorStatusBarActivity extends BaseActivity {
private Toolbar mToolbar;
private Button mBtnChangeColor;
private SeekBar mSbChangeAlpha;
private TextView mTvStatusAlpha;
private int mColor;
private int mAlpha;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_color_status_bar);
mToolbar = findViewById(R.id.toolbar);
mBtnChangeColor = findViewById(R.id.btn_change_color);
mTvStatusAlpha = findViewById(R.id.tv_status_alpha);
mSbChangeAlpha = findViewById(R.id.sb_change_alpha);
// 设置toolbar
setSupportActionBar(mToolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// 改变颜色
mBtnChangeColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Random random = new Random();
mColor = 0xff000000 | random.nextInt(0xffffff);
mToolbar.setBackgroundColor(mColor);
StatusBarUtil.setColor(ColorStatusBarActivity.this, mColor, mAlpha);
}
});
mSbChangeAlpha.setMax(255);
mSbChangeAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mAlpha = progress;
StatusBarUtil.setColor(ColorStatusBarActivity.this, mColor, mAlpha);
mTvStatusAlpha.setText(String.valueOf(mAlpha));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mSbChangeAlpha.setProgress(StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA);
}
@Override
protected void setStatusBar() {
mColor = getResources().getColor(R.color.colorPrimary);
StatusBarUtil.setColor(this, mColor);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/ImageFragment.java
================================================
package com.jaeger.statusbarutil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.jaeger.statusbardemo.R;
/**
* Created by Jaeger on 16/8/11.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class ImageFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragement_image, container, false);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/ImageStatusBarActivity.java
================================================
package com.jaeger.statusbarutil;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
/**
* Created by Jaeger on 16/2/14.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class ImageStatusBarActivity extends BaseActivity {
public static final String EXTRA_IS_TRANSPARENT = "is_transparent";
private TextView mTvStatusAlpha;
private RelativeLayout mRootLayout;
private Button mBtnChangeBackground;
private boolean isBgChanged;
private SeekBar mSbChangeAlpha;
private boolean isTransparent;
private int mAlpha;
@Override
protected void onCreate(Bundle savedInstanceState) {
isTransparent = getIntent().getBooleanExtra(EXTRA_IS_TRANSPARENT, false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_status_bar);
mRootLayout = (RelativeLayout) findViewById(R.id.root_layout);
mBtnChangeBackground = (Button) findViewById(R.id.btn_change_background);
mTvStatusAlpha = (TextView) findViewById(R.id.tv_status_alpha);
mSbChangeAlpha = (SeekBar) findViewById(R.id.sb_change_alpha);
mBtnChangeBackground.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isBgChanged = !isBgChanged;
if (isBgChanged) {
mRootLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_girl));
} else {
mRootLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_monkey));
}
}
});
if (!isTransparent) {
mSbChangeAlpha.setVisibility(View.VISIBLE);
setSeekBar();
} else {
mSbChangeAlpha.setVisibility(View.GONE);
}
}
@Override
protected void setStatusBar() {
if (isTransparent) {
StatusBarUtil.setTransparent(this);
} else {
StatusBarUtil.setTranslucent(this, StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA);
}
}
private void setSeekBar() {
mSbChangeAlpha.setMax(255);
mSbChangeAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mAlpha = progress;
StatusBarUtil.setTranslucent(ImageStatusBarActivity.this, mAlpha);
mTvStatusAlpha.setText(String.valueOf(mAlpha));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mSbChangeAlpha.setProgress(StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/ImageViewActivity.java
================================================
package com.jaeger.statusbarutil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
import com.r0adkll.slidr.Slidr;
/**
* Created by Jaeger on 16/7/12.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class ImageViewActivity extends BaseActivity {
private Toolbar mToolbar;
private View mViewNeedOffset;
private SeekBar mSbChangeAlpha;
private TextView mTvStatusAlpha;
private int mAlpha;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_view);
// 设置右滑动返回
Slidr.attach(this);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mViewNeedOffset = findViewById(R.id.view_need_offset);
mTvStatusAlpha = (TextView) findViewById(R.id.tv_status_alpha);
mSbChangeAlpha = (SeekBar) findViewById(R.id.sb_change_alpha);
setSupportActionBar(mToolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
mSbChangeAlpha.setMax(255);
mSbChangeAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mAlpha = progress;
StatusBarUtil.setTranslucentForImageView(ImageViewActivity.this, mAlpha, mViewNeedOffset);
mTvStatusAlpha.setText(String.valueOf(mAlpha));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mSbChangeAlpha.setProgress(StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA);
}
@Override
protected void setStatusBar() {
mViewNeedOffset = findViewById(R.id.view_need_offset);
StatusBarUtil.setTranslucentForImageView(this, mViewNeedOffset);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/MainActivity.java
================================================
package com.jaeger.statusbarutil;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.SeekBar;
import android.widget.TextView;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
/**
* Created by Jaeger on 16/2/14.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class MainActivity extends BaseActivity {
private DrawerLayout mDrawerLayout;
private Toolbar mToolbar;
private CheckBox mChbTranslucent;
private Button mBtnSetColor;
private Button mBtnSetTransparent;
private Button mBtnSetTranslucent;
private Button mBtnSetForImageView;
private Button mBtnUseInFragment;
private Button mBtnSetColorForSwipeBack;
private Button mBtnSwitchMode;
private ViewGroup contentLayout;
private SeekBar mSbChangeAlpha;
private TextView mTvStatusAlpha;
private int mStatusBarColor;
private int mAlpha = StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDrawerLayout = findViewById(R.id.drawer_layout);
contentLayout = findViewById(R.id.main);
mToolbar = findViewById(R.id.toolbar);
mChbTranslucent = findViewById(R.id.chb_translucent);
mBtnSetColor = findViewById(R.id.btn_set_color);
mBtnSetTransparent = findViewById(R.id.btn_set_transparent);
mBtnSetTranslucent = findViewById(R.id.btn_set_translucent);
mBtnSetForImageView = findViewById(R.id.btn_set_for_image_view);
mBtnUseInFragment = findViewById(R.id.btn_use_in_fragment);
mBtnSetColorForSwipeBack = findViewById(R.id.btn_set_color_for_swipe_back);
mBtnSwitchMode = findViewById(R.id.btn_switch_mode);
mSbChangeAlpha = findViewById(R.id.sb_change_alpha);
mTvStatusAlpha = findViewById(R.id.tv_status_alpha);
setSupportActionBar(mToolbar);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close);
mDrawerLayout.setDrawerListener(toggle);
toggle.syncState();
mBtnSetColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ColorStatusBarActivity.class);
startActivity(intent);
}
});
mBtnSetTransparent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ImageStatusBarActivity.class);
intent.putExtra(ImageStatusBarActivity.EXTRA_IS_TRANSPARENT, true);
startActivity(intent);
}
});
mBtnSetTranslucent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ImageStatusBarActivity.class);
intent.putExtra(ImageStatusBarActivity.EXTRA_IS_TRANSPARENT, false);
startActivity(intent);
}
});
mBtnSetForImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ImageViewActivity.class);
startActivity(intent);
}
});
mBtnUseInFragment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, UseInFragmentActivity.class);
startActivity(intent);
}
});
mBtnSetColorForSwipeBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, SwipeBackActivity.class);
startActivity(intent);
}
});
mBtnSwitchMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, SwitchModeActivity.class);
startActivity(intent);
}
});
mChbTranslucent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mChbTranslucent.isChecked()) {
contentLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_monkey));
StatusBarUtil.setTranslucentForDrawerLayout(MainActivity.this, mDrawerLayout, mAlpha);
mToolbar.setBackgroundColor(getResources().getColor(android.R.color.transparent));
} else {
contentLayout.setBackgroundDrawable(null);
mToolbar.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
StatusBarUtil.setColorForDrawerLayout(MainActivity.this, mDrawerLayout,
getResources().getColor(R.color.colorPrimary), mAlpha);
}
}
});
mSbChangeAlpha.setMax(255);
mSbChangeAlpha.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mAlpha = progress;
if (mChbTranslucent.isChecked()) {
StatusBarUtil.setTranslucentForDrawerLayout(MainActivity.this, mDrawerLayout, mAlpha);
} else {
StatusBarUtil.setColorForDrawerLayout(MainActivity.this, mDrawerLayout, mStatusBarColor, mAlpha);
}
mTvStatusAlpha.setText(String.valueOf(mAlpha));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mSbChangeAlpha.setProgress(StatusBarUtil.DEFAULT_STATUS_BAR_ALPHA);
}
@Override
protected void setStatusBar() {
mStatusBarColor = getResources().getColor(R.color.colorPrimary);
StatusBarUtil.setColorForDrawerLayout(this, (DrawerLayout) findViewById(R.id.drawer_layout), mStatusBarColor, mAlpha);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/SimpleFragment.java
================================================
package com.jaeger.statusbarutil;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.jaeger.statusbardemo.R;
/**
* Created by Jaeger on 16/8/11.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class SimpleFragment extends Fragment {
private TextView mTvTitle;
private View mFakeStatusBar;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragement_simple, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mTvTitle = (TextView) view.findViewById(R.id.tv_title);
mFakeStatusBar = view.findViewById(R.id.fake_status_bar);
}
public void setTvTitleBackgroundColor(@ColorInt int color) {
mTvTitle.setBackgroundColor(color);
mFakeStatusBar.setBackgroundColor(color);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/SwipeBackActivity.java
================================================
package com.jaeger.statusbarutil;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
import com.r0adkll.slidr.Slidr;
import java.util.Random;
/**
* Created by Jaeger on 2016/10/15.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class SwipeBackActivity extends BaseActivity {
private Button mBtnChangeColor;
private int mColor = Color.GRAY;
private Toolbar mToolbar;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置右滑动返回
Slidr.attach(this);
setContentView(R.layout.swipe_back_activity);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mBtnChangeColor = (Button) findViewById(R.id.btn_change_color);
setSupportActionBar(mToolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
mToolbar.setBackgroundColor(mColor);
mBtnChangeColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Random random = new Random();
mColor = 0xff000000 | random.nextInt(0xffffff);
mToolbar.setBackgroundColor(mColor);
StatusBarUtil.setColorForSwipeBack(SwipeBackActivity.this, mColor, 38);
}
});
}
@Override
protected void setStatusBar() {
StatusBarUtil.setColorForSwipeBack(this, mColor, 38);
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/SwitchModeActivity.java
================================================
package com.jaeger.statusbarutil;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
/**
* Created by jaeger on 08/03/2018.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class SwitchModeActivity extends BaseActivity {
private Toolbar mToolbar;
private Button mBtnSetLightMode;
private Button mBtnSetDarkMode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_switch_mode);
mToolbar = findViewById(R.id.toolbar);
mBtnSetLightMode = findViewById(R.id.btn_set_light_mode);
mBtnSetDarkMode = findViewById(R.id.btn_set_dark_mode);
// 设置toolbar
setSupportActionBar(mToolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
mBtnSetLightMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int color = getResources().getColor(R.color.light_gray);
StatusBarUtil.setColor(SwitchModeActivity.this, color, 30);
mToolbar.setBackgroundColor(color);
StatusBarUtil.setLightMode(SwitchModeActivity.this);
}
});
mBtnSetDarkMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int color = getResources().getColor(R.color.colorPrimary);
StatusBarUtil.setColor(SwitchModeActivity.this, color);
mToolbar.setBackgroundColor(color);
StatusBarUtil.setDarkMode(SwitchModeActivity.this);
}
});
}
@Override
protected void setStatusBar() {
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
}
}
================================================
FILE: sample/src/main/java/com/jaeger/statusbarutil/UseInFragmentActivity.java
================================================
package com.jaeger.statusbarutil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import com.jaeger.library.StatusBarUtil;
import com.jaeger.statusbardemo.R;
import java.util.ArrayList;
import java.util.Random;
/**
* Created by Jaeger on 16/8/11.
*
* Email: chjie.jaeger@gmail.com
* GitHub: https://github.com/laobie
*/
public class UseInFragmentActivity extends BaseActivity {
private ViewPager mVpHome;
private BottomNavigationBar mBottomNavigationBar;
private ArrayList<Fragment> mFragmentList = new ArrayList<>();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_use_in_fragment);
mVpHome = (ViewPager) findViewById(R.id.vp_home);
mBottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
mBottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_favorite, "One"))
.addItem(new BottomNavigationItem(R.drawable.ic_gavel, "Two"))
.addItem(new BottomNavigationItem(R.drawable.ic_grade, "Three"))
.addItem(new BottomNavigationItem(R.drawable.ic_group_work, "Four"))
.initialise();
mBottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
@Override
public void onTabSelected(int position) {
mVpHome.setCurrentItem(position);
}
@Override
public void onTabUnselected(int position) {
}
@Override
public void onTabReselected(int position) {
}
});
mFragmentList.add(new ImageFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mVpHome.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mBottomNavigationBar.selectTab(position);
switch (position) {
case 0:
break;
default:
Random random = new Random();
int color = 0xff000000 | random.nextInt(0xffffff);
if (mFragmentList.get(position) instanceof SimpleFragment) {
((SimpleFragment) mFragmentList.get(position)).setTvTitleBackgroundColor(color);
}
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mVpHome.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
});
}
@Override
protected void setStatusBar() {
StatusBarUtil.setTranslucentForImageViewInFragment(UseInFragmentActivity.this, null);
}
}
================================================
FILE: sample/src/main/res/anim/slide_in_left.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="100%"
android:toXDelta="0"/>
</set>
================================================
FILE: sample/src/main/res/anim/slide_in_right.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="-100%"
android:toXDelta="0"/>
</set>
================================================
FILE: sample/src/main/res/anim/slide_out_left.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="0"
android:toXDelta="-100%"/>
</set>
================================================
FILE: sample/src/main/res/anim/slide_out_right.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="0"
android:toXDelta="100%"/>
</set>
================================================
FILE: sample/src/main/res/drawable/ic_menu_camera.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
<path
android:fillColor="#FF000000"
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
</vector>
================================================
FILE: sample/src/main/res/drawable/ic_menu_gallery.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z"/>
</vector>
================================================
FILE: sample/src/main/res/drawable/ic_menu_manage.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z"/>
</vector>
================================================
FILE: sample/src/main/res/drawable/ic_menu_send.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
</vector>
================================================
FILE: sample/src/main/res/drawable/ic_menu_share.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
</vector>
================================================
FILE: sample/src/main/res/drawable/ic_menu_slideshow.xml
================================================
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z"/>
</vector>
================================================
FILE: sample/src/main/res/layout/activity_color_status_bar.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:background="@color/white"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="16dp"
android:text="this is a color status bar page"
android:textColor="#333333"
android:textSize="18sp"/>
<Button
android:id="@+id/btn_change_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="16dp"
android:padding="16dp"
android:text="Change StatusBar Color"/>
<TextView
android:id="@+id/tv_status_alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/colorAccent"
android:textSize="24sp"
tools:text="112"/>
<SeekBar
android:id="@+id/sb_change_alpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
</LinearLayout>
================================================
FILE: sample/src/main/res/layout/activity_image_status_bar.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_monkey"
android:orientation="vertical">
<Button
android:id="@+id/btn_change_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom|center_horizontal"
android:layout_margin="16dp"
android:text="Change Background"/>
<SeekBar
android:id="@+id/sb_change_alpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/btn_change_background"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<TextView
android:id="@+id/tv_status_alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/sb_change_alpha"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:textColor="@color/colorAccent"
android:textSize="36sp"/>
</RelativeLayout>
================================================
FILE: sample/src/main/res/layout/activity_image_view.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@color/white"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="240dp"
android:scaleType="centerCrop"
android:src="@drawable/bg_monkey_king"/>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/view_need_offset"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/transparent"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<TextView
android:id="@+id/tv_status_alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/colorAccent"
android:textSize="24sp"
tools:text="112"/>
<SeekBar
android:id="@+id/sb_change_alpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="-64dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
</android.support.design.widget.CoordinatorLayout>
</RelativeLayout>
================================================
FILE: sample/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:fitsSystemWindows="true">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<CheckBox
android:id="@+id/chb_translucent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Translucent"/>
<TextView
android:id="@+id/tv_status_alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/colorAccent"
android:textSize="24sp"/>
<SeekBar
android:id="@+id/sb_change_alpha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"/>
<Button
android:id="@+id/btn_set_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
android:text="Set Color"/>
<Button
android:id="@+id/btn_set_transparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Set Transparent"/>
<Button
android:id="@+id/btn_set_translucent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Set Translucent"/>
<Button
android:id="@+id/btn_set_for_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Set For ImageView"/>
<Button
android:id="@+id/btn_use_in_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Use In Fragment"/>
<Button
android:id="@+id/btn_set_color_for_swipe_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Set Color For Swipe Back Page "/>
<Button
android:id="@+id/btn_switch_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="4dp"
android:text="Switch Light or Dark Mode"/>
</LinearLayout>
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/white"
app:headerLayout="@layout/nav_header"
app:menu="@menu/activity_main_drawer"/>
</android.support.v4.widget.DrawerLayout>
================================================
FILE: sample/src/main/res/layout/activity_switch_mode.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:background="@color/white"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<Button
android:id="@+id/btn_set_light_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="64dp"
android:padding="16dp"
android:text="Set Light Mode"/>
<Button
android:id="@+id/btn_set_dark_mode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:padding="16dp"
android:text="Set Dark Mode"/>
</LinearLayout>
================================================
FILE: sample/src/main/res/layout/activity_use_in_fragment.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:orientation="vertical"
android:background="@color/white">
<android.support.v4.view.ViewPager
android:id="@+id/vp_home"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"/>
<com.ashokvarma.bottomnavigation.BottomNavigationBar
android:id="@+id/bottom_navigation_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:bnbActiveColor="@color/white"
app:bnbBackgroundColor="@color/colorPrimary"
app:bnbBackgroundStyle="background_style_static"/>
</LinearLayout>
================================================
FILE: sample/src/main/res/layout/fragement_image.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="240dp"
android:scaleType="centerCrop"
android:src="@drawable/bg_monkey_king"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="56dp"
android:text="This is a fragment."
android:textSize="22sp"/>
</LinearLayout>
================================================
FILE: sample/src/main/res/layout/fragement_simple.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="@+id/fake_status_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/statusbar_view_height"
android:background="@color/colorPrimary"/>
<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/colorPrimary"
android:gravity="center"
android:text="@string/app_name"
android:textColor="@color/white"
android:textSize="24sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="56dp"
android:text="This is a fragment, too."
android:textSize="22sp"/>
</LinearLayout>
================================================
FILE: sample/src/main/res/layout/nav_header.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="192dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/nav_header_bg"
android:scaleType="centerCrop"/>
<ImageView
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_gravity="bottom"
android:layout_marginBottom="56dp"
android:padding="8dp"
android:src="@drawable/ic_avatar"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="24dp"
android:padding="16dp"
android:text="Jaeger"
android:textColor="@android:color/white"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:padding="16dp"
android:text="写代码的猴子"
android:textColor="@android:color/white"
android:textSize="12sp"/>
</FrameLayout>
================================================
FILE: sample/src/main/res/layout/sss.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="@color/white"
android:paddingTop="30dp"
android:layout_height="match_parent">
</FrameLayout>
================================================
FILE: sample/src/main/res/layout/swipe_back_activity.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:background="@color/white"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="16dp"
android:text="this is a color status bar page \n and can swipe back"
android:textColor="#333333"
android:textSize="18sp"/>
<Button
android:id="@+id/btn_change_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="16dp"
android:padding="16dp"
android:text="Change StatusBar Color"/>
</LinearLayout>
================================================
FILE: sample/src/main/res/menu/activity_main_drawer.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_camera"
android:icon="@drawable/ic_menu_camera"
android:title="Import"/>
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_menu_gallery"
android:title="Gallery"/>
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="Slideshow"/>
<item
android:id="@+id/nav_manage"
android:icon="@drawable/ic_menu_manage"
android:title="Tools"/>
</group>
<item android:title="Communicate">
<menu>
<item
android:id="@+id/nav_share"
android:icon="@drawable/ic_menu_share"
android:title="Share"/>
<item
android:id="@+id/nav_send"
android:icon="@drawable/ic_menu_send"
android:title="Send"/>
</menu>
</item>
</menu>
================================================
FILE: sample/src/main/res/menu/bottom_bar_items.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action0"
android:title="1"/>
<item
android:id="@+id/action1"
android:title="2"/>
<item
android:id="@+id/action2"
android:title="3"/>
<item
android:id="@+id/action3"
android:title="4"/>
</menu>
================================================
FILE: sample/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#146e6e</color>
<color name="colorPrimaryDark">#083939</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#ffffff</color>
<color name="gray">#4d4d4d</color>
<color name="light_gray">#bfbfbf</color>
</resources>
================================================
FILE: sample/src/main/res/values/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="statusbar_view_height">0dp</dimen>
</resources>
================================================
FILE: sample/src/main/res/values/strings.xml
================================================
<resources>
<string name="app_name">StatusBarUtil</string>
<string name="navigation_drawer_open">navigation_drawer_open</string>
<string name="navigation_drawer_close">navigation_drawer_close</string>
</resources>
================================================
FILE: sample/src/main/res/values/styles.xml
================================================
<resources>
<!-- Base application theme. -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:textAllCaps">false</item>
<item name="android:windowActionBar">false</item>
<item name="windowActionBar">false</item>
<item name="android:windowAnimationStyle">@style/AnimationActivity</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="AnimationActivity" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/slide_in_left</item>
<item name="android:activityOpenExitAnimation">@anim/slide_out_left</item>
<item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>
<item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
</style>
</resources>
================================================
FILE: sample/src/main/res/values-v19/dimens.xml
================================================
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="statusbar_view_height">25dp</dimen>
</resources>
================================================
FILE: sample/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
================================================
FILE: settings.gradle
================================================
include ':sample', ':library'
gitextract_8yo7vtyc/ ├── .gitignore ├── CHANGE_LOG.md ├── LICENSE.md ├── README.md ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── library/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── example/ │ │ └── library/ │ │ └── ApplicationTest.java │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── jaeger/ │ │ └── library/ │ │ └── StatusBarUtil.java │ └── res/ │ └── values/ │ ├── ids.xml │ └── strings.xml ├── sample/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ ├── release/ │ │ ├── output.json │ │ └── sample-release.apk │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── com/ │ │ └── jaeger/ │ │ └── statusbarutil/ │ │ ├── BaseActivity.java │ │ ├── ColorStatusBarActivity.java │ │ ├── ImageFragment.java │ │ ├── ImageStatusBarActivity.java │ │ ├── ImageViewActivity.java │ │ ├── MainActivity.java │ │ ├── SimpleFragment.java │ │ ├── SwipeBackActivity.java │ │ ├── SwitchModeActivity.java │ │ └── UseInFragmentActivity.java │ └── res/ │ ├── anim/ │ │ ├── slide_in_left.xml │ │ ├── slide_in_right.xml │ │ ├── slide_out_left.xml │ │ └── slide_out_right.xml │ ├── drawable/ │ │ ├── ic_menu_camera.xml │ │ ├── ic_menu_gallery.xml │ │ ├── ic_menu_manage.xml │ │ ├── ic_menu_send.xml │ │ ├── ic_menu_share.xml │ │ └── ic_menu_slideshow.xml │ ├── layout/ │ │ ├── activity_color_status_bar.xml │ │ ├── activity_image_status_bar.xml │ │ ├── activity_image_view.xml │ │ ├── activity_main.xml │ │ ├── activity_switch_mode.xml │ │ ├── activity_use_in_fragment.xml │ │ ├── fragement_image.xml │ │ ├── fragement_simple.xml │ │ ├── nav_header.xml │ │ ├── sss.xml │ │ └── swipe_back_activity.xml │ ├── menu/ │ │ ├── activity_main_drawer.xml │ │ └── bottom_bar_items.xml │ ├── values/ │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── values-v19/ │ │ └── dimens.xml │ └── values-w820dp/ │ └── dimens.xml └── settings.gradle
SYMBOL INDEX (77 symbols across 12 files)
FILE: library/src/androidTest/java/com/example/library/ApplicationTest.java
class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
method ApplicationTest (line 10) | public ApplicationTest() {
FILE: library/src/main/java/com/jaeger/library/StatusBarUtil.java
class StatusBarUtil (line 27) | public class StatusBarUtil {
method setColor (line 40) | public static void setColor(Activity activity, @ColorInt int color) {
method setColor (line 52) | public static void setColor(Activity activity, @ColorInt int color, @I...
method setColorForSwipeBack (line 79) | public static void setColorForSwipeBack(Activity activity, int color) {
method setColorForSwipeBack (line 90) | public static void setColorForSwipeBack(Activity activity, @ColorInt i...
method setColorNoTranslucent (line 129) | public static void setColorNoTranslucent(Activity activity, @ColorInt ...
method setColorDiff (line 139) | @Deprecated
method setTranslucent (line 166) | public static void setTranslucent(Activity activity) {
method setTranslucent (line 178) | public static void setTranslucent(Activity activity, @IntRange(from = ...
method setTranslucentForCoordinatorLayout (line 194) | public static void setTranslucentForCoordinatorLayout(Activity activit...
method setTransparent (line 207) | public static void setTransparent(Activity activity) {
method setTranslucentDiff (line 222) | @Deprecated
method setColorForDrawerLayout (line 238) | public static void setColorForDrawerLayout(Activity activity, DrawerLa...
method setColorNoTranslucentForDrawerLayout (line 249) | public static void setColorNoTranslucentForDrawerLayout(Activity activ...
method setColorForDrawerLayout (line 261) | public static void setColorForDrawerLayout(Activity activity, DrawerLa...
method setDrawerLayoutProperty (line 302) | private static void setDrawerLayoutProperty(DrawerLayout drawerLayout,...
method setColorForDrawerLayoutDiff (line 317) | @Deprecated
method setTranslucentForDrawerLayout (line 348) | public static void setTranslucentForDrawerLayout(Activity activity, Dr...
method setTranslucentForDrawerLayout (line 358) | public static void setTranslucentForDrawerLayout(Activity activity, Dr...
method setTransparentForDrawerLayout (line 373) | public static void setTransparentForDrawerLayout(Activity activity, Dr...
method setTranslucentForDrawerLayoutDiff (line 401) | @Deprecated
method setTransparentForImageView (line 424) | public static void setTransparentForImageView(Activity activity, View ...
method setTranslucentForImageView (line 434) | public static void setTranslucentForImageView(Activity activity, View ...
method setTranslucentForImageView (line 445) | public static void setTranslucentForImageView(Activity activity, @IntR...
method setTranslucentForImageViewInFragment (line 470) | public static void setTranslucentForImageViewInFragment(Activity activ...
method setTransparentForImageViewInFragment (line 480) | public static void setTransparentForImageViewInFragment(Activity activ...
method setTranslucentForImageViewInFragment (line 491) | public static void setTranslucentForImageViewInFragment(Activity activ...
method hideFakeStatusBarView (line 504) | public static void hideFakeStatusBarView(Activity activity) {
method setLightMode (line 516) | @TargetApi(Build.VERSION_CODES.M)
method setDarkMode (line 525) | @TargetApi(Build.VERSION_CODES.M)
method setMIUIStatusBarDarkIcon (line 537) | private static void setMIUIStatusBarDarkIcon(@NonNull Activity activit...
method setMeizuStatusBarDarkIcon (line 553) | private static void setMeizuStatusBarDarkIcon(@NonNull Activity activi...
method clearPreviousSetting (line 576) | @TargetApi(Build.VERSION_CODES.KITKAT)
method addTranslucentView (line 593) | private static void addTranslucentView(Activity activity, @IntRange(fr...
method createStatusBarView (line 613) | private static View createStatusBarView(Activity activity, @ColorInt i...
method createStatusBarView (line 625) | private static View createStatusBarView(Activity activity, @ColorInt i...
method setRootView (line 639) | private static void setRootView(Activity activity) {
method setTransparentForWindow (line 653) | private static void setTransparentForWindow(Activity activity) {
method transparentStatusBar (line 668) | @TargetApi(Build.VERSION_CODES.KITKAT)
method createTranslucentStatusBarView (line 686) | private static View createTranslucentStatusBarView(Activity activity, ...
method getStatusBarHeight (line 703) | private static int getStatusBarHeight(Context context) {
method calculateStatusColor (line 716) | private static int calculateStatusColor(@ColorInt int color, int alpha) {
FILE: sample/src/main/java/com/jaeger/statusbarutil/BaseActivity.java
class BaseActivity (line 14) | public class BaseActivity extends AppCompatActivity {
method setContentView (line 16) | @Override
method setStatusBar (line 22) | protected void setStatusBar() {
method onOptionsItemSelected (line 26) | @Override
FILE: sample/src/main/java/com/jaeger/statusbarutil/ColorStatusBarActivity.java
class ColorStatusBarActivity (line 19) | public class ColorStatusBarActivity extends BaseActivity {
method onCreate (line 28) | @Override
method setStatusBar (line 77) | @Override
FILE: sample/src/main/java/com/jaeger/statusbarutil/ImageFragment.java
class ImageFragment (line 17) | public class ImageFragment extends Fragment {
method onCreateView (line 19) | @Nullable
FILE: sample/src/main/java/com/jaeger/statusbarutil/ImageStatusBarActivity.java
class ImageStatusBarActivity (line 18) | public class ImageStatusBarActivity extends BaseActivity {
method onCreate (line 29) | @Override
method setStatusBar (line 60) | @Override
method setSeekBar (line 69) | private void setSeekBar() {
FILE: sample/src/main/java/com/jaeger/statusbarutil/ImageViewActivity.java
class ImageViewActivity (line 20) | public class ImageViewActivity extends BaseActivity {
method onCreate (line 28) | @Override
method setStatusBar (line 66) | @Override
method onOptionsItemSelected (line 72) | @Override
FILE: sample/src/main/java/com/jaeger/statusbarutil/MainActivity.java
class MainActivity (line 23) | public class MainActivity extends BaseActivity {
method onCreate (line 42) | @Override
method setStatusBar (line 167) | @Override
FILE: sample/src/main/java/com/jaeger/statusbarutil/SimpleFragment.java
class SimpleFragment (line 19) | public class SimpleFragment extends Fragment {
method onCreateView (line 23) | @Override
method onViewCreated (line 28) | @Override
method setTvTitleBackgroundColor (line 35) | public void setTvTitleBackgroundColor(@ColorInt int color) {
FILE: sample/src/main/java/com/jaeger/statusbarutil/SwipeBackActivity.java
class SwipeBackActivity (line 21) | public class SwipeBackActivity extends BaseActivity {
method onCreate (line 26) | @Override
method setStatusBar (line 51) | @Override
FILE: sample/src/main/java/com/jaeger/statusbarutil/SwitchModeActivity.java
class SwitchModeActivity (line 17) | public class SwitchModeActivity extends BaseActivity {
method onCreate (line 22) | @Override
method setStatusBar (line 58) | @Override
FILE: sample/src/main/java/com/jaeger/statusbarutil/UseInFragmentActivity.java
class UseInFragmentActivity (line 21) | public class UseInFragmentActivity extends BaseActivity {
method onCreate (line 26) | @Override
method setStatusBar (line 100) | @Override
Condensed preview — 64 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (123K chars).
[
{
"path": ".gitignore",
"chars": 102,
"preview": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.idea"
},
{
"path": "CHANGE_LOG.md",
"chars": 1797,
"preview": "## Change Log\n\n### 1.5.1\n\nfix set light/dark mode bug\n\n### 1.5.0\n\nadd set light/dark mode method\n\n### 1.4.0\n\nfix typo\n\n#"
},
{
"path": "LICENSE.md",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 5938,
"preview": "# StatusBarUtil\n\n[](https://996.icu)\n\n[
About this extraction
This page contains the full source code of the laobie/StatusBarUtil GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 64 files (111.3 KB), approximately 29.4k tokens, and a symbol index with 77 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.