Skip to content

Commit

Permalink
svg
Browse files Browse the repository at this point in the history
timber
  • Loading branch information
tmwuzhen committed Aug 2, 2018
1 parent 773f116 commit b601649
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 39 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,43 @@
apply plugin: 'com.android.application'
apply plugin: 'svg'

svg {
// 配置vector目录,可以配置多个(如果直接使用svg格式图片,可以不配置此项)
vectorDirs = ["src/main/res_vector/drawable"]
// 配置生成空shape文件目录
shapeDir = "src/main/res_shape/drawable"
// 配置生成java文件目录
javaDir = "src/main/java/com/example/bledemo/drawables"

// 自动将vector和shape资源文件添加到SourceSet,此项默认是true,可以不设置
autoSourceSet = true

// 定义svg生成vector的配置,可以配置多个目录,方便图片分类
svg2vector {
svg_a {
svgDir = "${projectDir}/svg_a"
vectorDir = "src/main/res_svg/drawable"
// 配置生成的vector尺寸,不设置将按照图片尺寸大小
// 注意此处宽高比要与图片宽高比一致,否则图片会变形
height = 48
width = 48
}
svg_b {
svgDir = "${projectDir}/svg_b"
vectorDir = "src/main/res_svg/drawable"
// height = 48
// width = 48
}
}

}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "com.example.bledemo"
minSdkVersion 24
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
Expand All @@ -25,6 +58,9 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

compile 'com.inuker.bluetooth:library:1.4.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.inuker.bluetooth:library:1.4.0'
implementation 'com.clj.fastble:FastBleLib:2.2.4'
implementation 'com.github.megatronking:svg-support:1.3.2'
implementation 'com.jakewharton.timber:timber:4.5.1'
}
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bledemo">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:name=".MyApplication"
android:allowBackup="true"
Expand All @@ -11,6 +17,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">

</activity>
<activity android:name=".FastActivity"></activity>
<activity android:name=".SVGActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/example/bledemo/MyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import android.app.Application;
import android.content.Context;

import com.example.bledemo.drawables.SVGLoader;
import com.inuker.bluetooth.library.BluetoothClient;

import timber.log.Timber;

/**
* Created by KomoriWu
* on 2017-04-18.
Expand All @@ -16,8 +19,22 @@ public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
} else {
Timber.plant(new CrashReportingTree());
}
SVGLoader.load(this);
}

private static class CrashReportingTree extends Timber.Tree {
@Override
protected void log(int priority, String tag, String message, Throwable t) {

}
}


public static BluetoothClient getBluetoothClient(Context context) {
if (mBluetoothClient == null) {
synchronized (BluetoothClient.class) {
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/java/com/example/bledemo/SVGActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.example.bledemo;

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

import timber.log.Timber;

public class SVGActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_svg);
Timber.tag("wz");
Timber.d("Activity Created");
}
}
29 changes: 25 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@
android:id="@+id/btn_open"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开门" />
android:text="mac地址开门" />

<Button
android:id="@+id/btn_scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Scan开门" />

<Button
android:id="@+id/btn_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="清除" />

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
Expand All @@ -19,10 +33,17 @@
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"

android:layout_height="wrap_content"
android:text="Hello World!" />
android:textSize="16sp" />
</android.support.v4.widget.NestedScrollView>


<ProgressBar
android:id="@+id/pb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
18 changes: 18 additions & 0 deletions app/src/main/res/layout/activity_svg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.bledemo.SVGActivity">

<ImageView
android:layout_width="500dp"
android:layout_height="500dp"
android:visibility="gone"
android:src="@drawable/shangcheng" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shangcheng" />
</LinearLayout>
Loading

0 comments on commit b601649

Please sign in to comment.