From f8cbab3f34b44306d6d7712c08d404358ff6f205 Mon Sep 17 00:00:00 2001 From: brave Date: Wed, 24 Jun 2020 17:36:49 +0800 Subject: [PATCH] Modify the MD usage document --- README.en.md | 59 ++++++++++------- README.md | 46 ++++++++++++- .../brave/system/bar/library/NavBarUtils.java | 61 +++++++++++++++++ .../system/bar/library/StatusBarUtils.java | 65 ++++++++++++++++++- .../brave/system/bar/utils/MainActivity.java | 5 ++ 5 files changed, 207 insertions(+), 29 deletions(-) diff --git a/README.en.md b/README.en.md index 8bc057d..b963ce4 100644 --- a/README.en.md +++ b/README.en.md @@ -1,36 +1,47 @@ # SystemBarUtils +--- +Android toolbar -#### Description -Android SystemBar Utils -#### Software Architecture -Software architecture description +# Dependency +--- +```groovy + dependencies { + implementation 'com.brave.system.bar:library:1.0.1' + } +``` -#### Installation -1. xxxx -2. xxxx -3. xxxx +# use +--- -#### Instructions + 1. Transparent -1. xxxx -2. xxxx -3. xxxx +```java + BarUtils.setTransparent(this); +``` -#### Contribution + 2. Transparent -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request +```java + BarUtils.setTransparent(this); +``` + 3. set colors -#### Gitee Feature +```java + BarUtils.setSystemBarColor(this, Color.BLUE); +``` -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +4. Other + +```java + BarUtils.setSystemBarColor(Window, View, boolean, boolean, boolean, boolean, boolean, boolean, int, int) +``` + +# notice + +- BarUtils StatusBarUtils NavBarUtils have three types of mutual exclusion and can only be used one of them +- BarUtils status bar and virtual button bar will be changed together +- StatusBarUtils only changes the status bar +- NavBarUtils only changes the virtual button bar \ No newline at end of file diff --git a/README.md b/README.md index 926882d..e13e633 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,47 @@ # SystemBarUtils +--- +安卓系统栏工具 -#### gradle导入 +# 依赖 +--- ```groovy - implementation 'com.brave.system.bar:library:1.0.1' -``` \ No newline at end of file + dependencies { + implementation 'com.brave.system.bar:library:1.0.1' + } +``` + + +# 使用 +--- + + 1. 半透明 + +```java + BarUtils.setTransparent(this); +``` + + 2. 透明 + +```java + BarUtils.setTransparent(this); +``` + + 3. 设置颜色 + +```java + BarUtils.setSystemBarColor(this, Color.BLUE); +``` + +4. 其他 + +```java + BarUtils.setSystemBarColor(Window, View, boolean, boolean, boolean, boolean, boolean, boolean, int, int) +``` + +# 注意 + +- BarUtils、StatusBarUtils、NavBarUtils三类互斥,只能使用其中一种 +- BarUtils 状态栏与虚拟按键栏会一起改变 +- StatusBarUtils 只改变状态栏 +- NavBarUtils 只改变虚拟按键栏 \ No newline at end of file diff --git a/library/src/main/java/com/brave/system/bar/library/NavBarUtils.java b/library/src/main/java/com/brave/system/bar/library/NavBarUtils.java index 08595f3..3eb16e7 100644 --- a/library/src/main/java/com/brave/system/bar/library/NavBarUtils.java +++ b/library/src/main/java/com/brave/system/bar/library/NavBarUtils.java @@ -1,6 +1,7 @@ package com.brave.system.bar.library; import android.app.Activity; +import android.graphics.Color; import android.view.View; import android.view.Window; @@ -144,4 +145,64 @@ public static final void setColor(@NonNull Activity activity, false, color); } + + /** + * 设置虚拟按键栏半透明 + */ + public static final void setTranslucent(@NonNull Window window, + @NonNull View rootView) { + BarUtils.setSystemBarColor(window, + rootView, + false, + true, + false, + true, + true, + Color.BLACK, + 112); + } + + /** + * 设置虚拟按键栏半透明 + */ + public static final void setTranslucent(@NonNull Activity activity) { + BarUtils.setSystemBarColor(activity, + false, + true, + false, + true, + true, + Color.BLACK, + 112); + } + + /** + * 设置虚拟按键栏透明 + */ + public static final void setTransparent(@NonNull Window window, + @NonNull View rootView) { + BarUtils.setSystemBarColor(window, + rootView, + false, + true, + false, + true, + true, + Color.BLACK, + 0); + } + + /** + * 设置虚拟按键栏透明 + */ + public static final void setTransparent(@NonNull Activity activity) { + BarUtils.setSystemBarColor(activity, + false, + true, + false, + true, + true, + Color.BLACK, + 0); + } } \ No newline at end of file diff --git a/library/src/main/java/com/brave/system/bar/library/StatusBarUtils.java b/library/src/main/java/com/brave/system/bar/library/StatusBarUtils.java index f7361a7..747aff8 100644 --- a/library/src/main/java/com/brave/system/bar/library/StatusBarUtils.java +++ b/library/src/main/java/com/brave/system/bar/library/StatusBarUtils.java @@ -1,6 +1,7 @@ package com.brave.system.bar.library; import android.app.Activity; +import android.graphics.Color; import android.view.View; import android.view.Window; @@ -28,7 +29,7 @@ public final class StatusBarUtils { * @param window 窗口 * @param rootView 根布局 * @param isBlack 深色字体 - * @param fitSystemWindows 系统栏占位 + * @param fitSystemWindows 状态栏占位 * @param clipToPadding 子View不能展示在Padding区域 * @param color 颜色 * @param alpha 透明度[0,255],值越小越透明 @@ -93,7 +94,7 @@ public static final void setColor(@NonNull Window window, * * @param activity 活动 * @param isBlack 深色字体 - * @param fitSystemWindows 系统栏占位 + * @param fitSystemWindows 状态栏占位 * @param clipToPadding 子View不能展示在Padding区域 * @param color 颜色 * @param alpha 透明度[0,255],值越小越透明 @@ -144,4 +145,64 @@ public static final void setColor(@NonNull Activity activity, false, color); } + + /** + * 设置状态栏半透明 + */ + public static final void setTranslucent(@NonNull Window window, + @NonNull View rootView) { + BarUtils.setSystemBarColor(window, + rootView, + true, + false, + false, + true, + true, + Color.BLACK, + 112); + } + + /** + * 设置状态栏半透明 + */ + public static final void setTranslucent(@NonNull Activity activity) { + BarUtils.setSystemBarColor(activity, + true, + false, + false, + true, + true, + Color.BLACK, + 112); + } + + /** + * 设置状态栏透明 + */ + public static final void setTransparent(@NonNull Window window, + @NonNull View rootView) { + BarUtils.setSystemBarColor(window, + rootView, + true, + false, + false, + true, + true, + Color.BLACK, + 0); + } + + /** + * 设置状态栏透明 + */ + public static final void setTransparent(@NonNull Activity activity) { + BarUtils.setSystemBarColor(activity, + true, + false, + false, + true, + true, + Color.BLACK, + 0); + } } \ No newline at end of file diff --git a/sample/src/main/java/com/brave/system/bar/utils/MainActivity.java b/sample/src/main/java/com/brave/system/bar/utils/MainActivity.java index 9f7e65a..7e27b51 100644 --- a/sample/src/main/java/com/brave/system/bar/utils/MainActivity.java +++ b/sample/src/main/java/com/brave/system/bar/utils/MainActivity.java @@ -10,6 +10,8 @@ import androidx.appcompat.app.AppCompatActivity; import com.brave.system.bar.library.BarUtils; +import com.brave.system.bar.library.NavBarUtils; +import com.brave.system.bar.library.StatusBarUtils; public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; @@ -26,6 +28,9 @@ protected void onCreate(Bundle savedInstanceState) { true, Color.BLUE, 255); + BarUtils.setTransparent(this); + StatusBarUtils.setTranslucent(this); + NavBarUtils.setTranslucent(this); setRootView(this); }