/*
* Copyright (C) 2013 readyState Software Ltd
*
* 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.
*/
package com.github.rrj;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout.LayoutParams;
import java.lang.reflect.Method;
/**
* Class to manage status and navigation bar tint effects when using KitKat
* translucent system UI modes.
*/
public class SystemBarTintManager {
static {
// Android allows a system property to override the presence of the navigation bar.
// Used by the emulator.
// See https://github.com/android/platform_frameworks_base/blob/master/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#L1076
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
Class c = Class.forName("android.os.SystemProperties");
Method m = c.getDeclaredMethod("get", String.class);
m.setAccessible(true);
sNavBarOverride = (String) m.invoke(null, "qemu.hw.mainkeys");
} catch (Throwable e) {
sNavBarOverride = null;
}
}
}
/**
* The default system bar tint color value.
*/
public static final int DEFAULT_TINT_COLOR = 0x99000000;
private static String sNavBarOverride;
private final SystemBarConfig mConfig;
private boolean mStatusBarAvailable;
private boolean mNavBarAvailable;
private boolean mStatusBarTintEnabled;
private boolean mNavBarTintEnabled;
private View mStatusBarTintView;
private View mNavBarTintView;
/**
* Constructor. Call this in the host activity onCreate method after its
* content view has been set. You should always create new instances when
* the host activity is recreated.
*
* @param activity The host activity.
*/
@TargetApi(19)
public SystemBarTintManager(Activity activity) {
Window win = activity.getWindow();
ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// check theme attrs
int[] attrs = {android.R.attr.windowTranslucentStatus,
android.R.attr.windowTranslucentNavigation};
TypedArray a = activity.obtainStyledAttributes(attrs);
try {
mStatusBarAvailable = a.getBoolean(0, false);
mNavBarAvailable = a.getBoolean(1, false);
} finally {
a.recycle();
}
// check window flags
WindowManager.LayoutParams winParams = win.getAttributes();
int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
if ((winParams.flags & bits) != 0) {
mStatusBarAvailable = true;
}
bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
if ((winParams.flags & bits) != 0) {
mNavBarAvailable = true;
}
}
mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
// device might not have virtual navigation keys
if (!mConfig.hasNavigtionBar()) {
mNavBarAvailable = false;
}
if (mStatusBarAvailable) {
setupStatusBarView(activity, decorViewGroup);
}
if (mNavBarAvailable) {
setupNavBarView(activity, decorViewGroup);
}
}
/**
* Enable tinting of the system status bar.
* <p>
* If the platform is running Jelly Bean or earlier, or translucent system
* UI modes have not been enabled in either the theme or via window flags,
* then this method does nothing.
*
* @param enabled True to enable tinting, false to disable it (default).
*/
public void setStatusBarTintEnabled(boolean enabled) {
mStatusBarTintEnabled = enabled;
if (mStatusBarAvailable) {
mStatusBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
}
public void setStatusBarAvailable(boolean enabled) {
this.mStatusBarAvailable = enabled;
}
/**
* Enable tinting of the system navigation bar.
* <p>
* If the platform does not have soft navigation keys, is running Jelly Bean
* or earlier, or translucent system UI modes have not been enabled in either
* the theme or via window flags, then this method does nothing.
*
* @param enabled True to enable tinting, false to disable it (default).
*/
public void setNavigationBarTintEnabled(boolean enabled) {
mNavBarTintEnabled = enabled;
if (mNavBarAvailable) {
mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
}
}
/**
* Apply the specified color tint to all system UI bars.
*
* @param color The color of the background tint.
*/
public void setTintColor(int color) {
setStatusBarTintColor(color);
setNavigationBarTintColor(color);
}
/**
* Apply the specified drawable or color resource to all system UI bars.
*
* @param res The identifier of the resource.
*/
public void setTintResource(int res) {
setStatusBarTintResource(res);
setNavigationBarTintResource(res);
}
/**
* Apply the specified drawable to all system UI bars.
*
* @param drawable The drawable to use as the background, or null to remove it.
*/
public void setTintDrawable(Drawable drawable) {
setStatusBarTintDrawable(drawable);
setNavigationBarTintDrawable(drawable);
}
/**
* Apply the specified alpha to all system UI bars.
*
* @param alpha The alpha to use
*/
public void setTintAlpha(float alpha) {
setStatusBarAlpha(alpha);
setNavigationBarAlpha(alpha);
}
/**
* Apply the specified color tint to the system status bar.
*
* @param color The color of the background tint.
*/
public void setStatusBarTintColor(int color) {
if (mStatusBarAvailable) {
mStatusBarTintView.setBackgroundColor(color);
}
}
/**
* Apply the specified drawable or color resource to the system status bar.
*
* @param res The identifier of the resource.
*/
public void setStatusBarTintResource(int res) {
if (mStatusBarAvailable) {
mStatusBarTintView.setBackgroundResource(res);
}
}
/**
* Apply the specified drawable to the system status bar.
*
* @param drawable The drawable to use as the background, or null to remove it.
*/
@SuppressWarnings("deprecation")
public void setStatusBarTintDrawable(Drawable drawable) {
if (mStatusBarAvailable) {
mStatusBarTintView.setBackgroundDrawable(drawable);
}
}
/**
* Apply the specified alpha to the system
没有合适的资源?快使用搜索试试~ 我知道了~
Gradle多渠道打包(动态设定App名称,应用图标,背景图片,状态栏颜色)
共79个文件
png:27个
xml:23个
java:17个
5星 · 超过95%的资源 需积分: 49 18 下载量 82 浏览量
2017-03-15
09:03:32
上传
评论 2
收藏 2.35MB ZIP 举报
温馨提示
http://blog.csdn.net/u012551350/article/details/62041833
资源推荐
资源详情
资源评论
收起资源包目录
ChannelDemo-master.zip (79个子文件)
ChannelDemo-master
gradlew 5KB
settings.gradle 15B
.idea
runConfigurations.xml 564B
misc.xml 3KB
compiler.xml 686B
gradle.xml 626B
modules.xml 343B
copyright
profiles_settings.xml 74B
vcs.xml 180B
gradle
wrapper
gradle-wrapper.properties 233B
gradle-wrapper.jar 52KB
gradlew.bat 2KB
gradle.properties 730B
.gitignore 118B
app
app-release.apk 1.72MB
src
androidTest
java
com
github
rrj
ExampleInstrumentedTest.java 732B
test
java
com
github
rrj
ExampleUnitTest.java 536B
main
AndroidManifest.xml 3KB
res
mipmap-hdpi
klg_icon.png 8KB
icon.png 5KB
sjyg_icon.png 3KB
ic_launcher.png 3KB
klg_welcome.png 47KB
rrj_welcome.png 62KB
sjyg_welcome.png 23KB
mipmap-xxxhdpi
ic_launcher.png 10KB
mipmap-xhdpi
klg_icon.png 10KB
icon.png 6KB
sjyg_icon.png 3KB
ic_launcher.png 5KB
klg_welcome.png 85KB
rrj_welcome.png 115KB
sjyg_welcome.png 33KB
mipmap-mdpi
ic_launcher.png 2KB
drawable
btn_bg.xml 299B
btn_normal.9.png 215B
ic_error_page.png 4KB
btn_pressed.9.png 221B
ic_empty_page.png 1KB
progress_bg.xml 169B
layout
fragment_webview.xml 914B
activity_welcome.xml 596B
loadpage_empty.xml 831B
loadpage_error.xml 1KB
activity_webview.xml 750B
loadpage_loading.xml 911B
activity_main.xml 702B
values-w820dp
dimens.xml 358B
values
colors.xml 293B
attrs_page.xml 327B
strings.xml 125B
styles.xml 381B
dimens.xml 211B
mipmap-xxhdpi
klg_icon.png 14KB
icon.png 6KB
sjyg_icon.png 5KB
ic_launcher.png 8KB
klg_welcome.png 136KB
rrj_welcome.png 200KB
sjyg_welcome.png 73KB
java
com
github
rrj
MyApplication.java 3KB
fragment
WebViewFragment.java 8KB
WebClientClickListener.java 600B
FirstWebViewFragment.java 722B
receiver
NetworkConnectChangedReceiver.java 5KB
widget
MyAnimatorUpdateListener.java 565B
PageStateLayout.java 6KB
PageLoadingView.java 6KB
PageState.java 599B
WebViewActivity.java 6KB
SystemBarTintManager.java 20KB
BaseActivity.java 1KB
MainActivity.java 2KB
config
Constants.java 169B
WelcomeActivity.java 1KB
.gitignore 7B
build.gradle 2KB
proguard-rules.pro 658B
build.gradle 498B
共 79 条
- 1
资源评论
- 北极熊772017-12-06非常受用,谢谢了。苹果树上的女孩2018-04-12现在可以用python打包了,很方便,链接https://download.csdn.net/download/u012764110/10315200
苹果树上的女孩
- 粉丝: 48
- 资源: 17
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功