Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':library')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:theme="@style/CjjBaseTheme">
<activity
android:name=".DemoActivity"
android:name=".SplashActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

<activity android:name=".DemoActivity"/>
</application>

</manifest>
24 changes: 23 additions & 1 deletion app/src/main/java/com/example/blockcanary/DemoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import android.app.Activity;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -15,7 +18,10 @@ public class DemoActivity extends Activity implements View.OnClickListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo);
setContentView(R.layout.activity_main);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("BlockCanary");

Button button1 = (Button) findViewById(R.id.button1);
Button button2 = (Button) findViewById(R.id.button2);
Expand All @@ -24,6 +30,22 @@ protected void onCreate(Bundle savedInstanceState) {
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showTipDlg();
}
});
}

private void showTipDlg() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Tip");
builder.setMessage(getResources().getString(R.string.hello_world));
builder.setNegativeButton("cancel",null);
builder.show();
}

@Override
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/example/blockcanary/SplashActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.blockcanary;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
SplashActivity.this.setTheme(R.style.CjjBaseTheme_WhiteActivity);
super.onCreate(savedInstanceState);
startActivity(new Intent(this, DemoActivity.class));
SplashActivity.this.finish();
overridePendingTransition(0, 0);
}
}
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/btn_nor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<solid android:color="@color/material_blue" />

<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp" />

</shape>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/btn_pre.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<solid android:color="@color/material_blue_dark" />

<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp" />

</shape>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/btn_select.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:state_focused="true" android:drawable="@drawable/btn_pre"></item>
<item android:state_pressed="true" android:drawable="@drawable/btn_pre"></item>
<item android:drawable="@drawable/btn_nor"></item>

</selector>
Binary file added app/src/main/res/drawable/ic_done.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 0 additions & 39 deletions app/src/main/res/layout/activity_demo.xml

This file was deleted.

99 changes: 99 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?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"
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="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical"
android:padding="10dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">


<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/btn_select"
android:gravity="center"
android:text="@string/thread_waiting"
android:textColor="@android:color/white"
android:textSize="24sp"/>

<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/btn_select"
android:gravity="center"
android:text="@string/io_waiting"
android:textColor="@android:color/white"
android:textSize="24sp"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">

<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/btn_select"
android:gravity="center"
android:text="@string/cpu_busy"
android:textColor="@android:color/white"
android:textSize="24sp"/>

<Button
android:id="@+id/button4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@drawable/btn_select"
android:gravity="center"
android:text="@string/more"
android:textColor="@android:color/white"
android:textSize="24sp"/>
</LinearLayout>

</LinearLayout>


<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:src="@drawable/ic_done"/>


</RelativeLayout>
10 changes: 10 additions & 0 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>

<resources>

<style name="CjjBaseTheme" parent="Base.Theme.DesignDemo">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>

</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="window_background">#FFF5F5F5</color>

<color name="material_blue">#2196F3</color>
<color name="material_blue_dark">#1976D2</color>
</resources>
7 changes: 4 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<string name="app_name">BlockCanary Demo</string>

<string name="hello_world">点击按钮后,会触发主线程耗时时间,从而被BlockCanary,并记录卡慢日志,弹出notification,可以点击对应消息查看</string>
<string name="thread_waiting">线程等待阻塞</string>
<string name="io_waiting">IO阻塞</string>
<string name="cpu_busy">计算阻塞</string>
<string name="thread_waiting">线程\n等待\n阻塞</string>
<string name="io_waiting">IO\n阻塞</string>
<string name="cpu_busy">计算\n阻塞</string>
<string name="more">尽请\n期待\n更多</string>
<string name="action_settings">Settings</string>
</resources>
17 changes: 14 additions & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.NoTitleBar">
<!-- Customize your theme here. -->
<style name="CjjBaseTheme" parent="Base.Theme.DesignDemo">
</style>

<style name="Base.Theme.DesignDemo" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#1976D2</item>
<item name="colorAccent">#F44336</item>
<item name="android:textColorPrimary">#ffffff</item>
<item name="android:windowBackground">@color/window_background</item>
</style>

<style name="CjjBaseTheme.WhiteActivity">
<item name="android:windowBackground">@color/material_blue</item>
<item name="android:windowIsTranslucent">false</item>
</style>

</resources>