-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 23 | ||
buildToolsVersion "23.0.2" | ||
|
||
defaultConfig { | ||
applicationId "com.jaeger.statusbardemo" | ||
minSdkVersion 14 | ||
targetSdkVersion 23 | ||
versionCode 1 | ||
versionName "1.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:23.1.1' | ||
compile 'com.android.support:design:23.1.1' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 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 *; | ||
#} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.jaeger.statusbardemo; | ||
|
||
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); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.jaeger.statusbardemo" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ColorStatusBarActivity" | ||
android:label="@string/app_name"/> | ||
<activity android:name=".ImageStatusBarActivity"/> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.jaeger.statusbardemo; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
|
||
/** | ||
* Created by Jaeger on 16/2/14. | ||
* StatusBarDemo | ||
*/ | ||
public class BaseActivity extends AppCompatActivity { | ||
|
||
@Override | ||
public void setContentView(int layoutResID) { | ||
super.setContentView(layoutResID); | ||
setStatusBarColor(); | ||
} | ||
|
||
protected void setStatusBarColor() { | ||
StatusBarUtils.setColor(this, getResources().getColor(R.color.colorPrimary)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.jaeger.statusbardemo; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.CheckBox; | ||
|
||
import java.util.Random; | ||
|
||
/** | ||
* Created by Jaeger on 16/2/14. | ||
* StatusBarDemo | ||
*/ | ||
public class ColorStatusBarActivity extends BaseActivity { | ||
private Toolbar toolbar; | ||
private Button btnChangeColor; | ||
private CheckBox chbShowToolBar; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_color_status_bar); | ||
|
||
toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
btnChangeColor = (Button) findViewById(R.id.btn_change_color); | ||
chbShowToolBar = (CheckBox) findViewById(R.id.chb_show_tool_bar); | ||
|
||
// 设置toolbar | ||
setSupportActionBar(toolbar); | ||
if (getSupportActionBar() != null) { | ||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); | ||
} | ||
|
||
// 改变颜色 | ||
btnChangeColor.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Random random = new Random(); | ||
int ranColor = 0xff000000 | random.nextInt(0x00ffffff); | ||
toolbar.setBackgroundColor(ranColor); | ||
StatusBarUtils.setColor(ColorStatusBarActivity.this, ranColor); | ||
} | ||
}); | ||
|
||
// 切换toolbar显示 | ||
chbShowToolBar.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (chbShowToolBar.isChecked()) { | ||
toolbar.setVisibility(View.VISIBLE); | ||
} else { | ||
toolbar.setVisibility(View.GONE); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
if (item.getItemId() == android.R.id.home) { | ||
finish(); | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.jaeger.statusbardemo; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.FrameLayout; | ||
|
||
/** | ||
* Created by Jaeger on 16/2/14. | ||
* StatusBarDemo | ||
*/ | ||
public class ImageStatusBarActivity extends BaseActivity { | ||
private FrameLayout rootLayout; | ||
private Button btnChangeBackground; | ||
private boolean isBgChanged; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_image_status_bar); | ||
|
||
rootLayout = (FrameLayout) findViewById(R.id.root_layout); | ||
btnChangeBackground = (Button) findViewById(R.id.btn_change_background); | ||
|
||
btnChangeBackground.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
isBgChanged = !isBgChanged; | ||
if (isBgChanged) { | ||
rootLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_girl)); | ||
} else { | ||
rootLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_run)); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
protected void setStatusBarColor() { | ||
StatusBarUtils.setTranslucent(this); | ||
} | ||
} |