Skip to content

Commit

Permalink
移除 Library 中的 BGABadgeXxxxView,改为 annotationProcessor 的形式
Browse files Browse the repository at this point in the history
  • Loading branch information
bingoogolapple committed Jan 16, 2018
1 parent 05a14a2 commit 02db075
Show file tree
Hide file tree
Showing 40 changed files with 616 additions and 810 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ proguard/
# Mac system files
.DS_Store

*.keystore
*.keystore

repo/
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
Change Log
==========

Version 1.1.5 *(2018-01-16)*
----------------------------

- 移除 Library 中的 BGABadgeXxxxView,改为 annotationProcessor 的形式

[ ![Download](https://api.bintray.com/packages/bingoogolapple/maven/bga-badgeview-api/images/download.svg) ](https://bintray.com/bingoogolapple/maven/bga-badgeview-api/_latestVersion) bga-badgeview-api 后面的「latestVersion」指的是左边这个 Download 徽章后面的「数字」,请自行替换。

```groovy
dependencies {
implementation 'cn.bingoogolapple:bga-badgeview-api:latestVersion'
annotationProcessor "cn.bingoogolapple:bga-badgeview-compiler:latestVersion"
}
```

```Java
/**
* 作者:王浩 邮件:bingoogolapple@gmail.com
* 创建时间:2018/1/14
* 描述:初始化 BGABadgeView-Android
* 1.在项目任意一个类上面添加 BGABadge 注解
* 2.需要哪些类具有徽章功能,就把那些类的全限定名作为 BGABadge 注解的参数
* 3.再 AS 中执行 Build => Rebuild Project
* 4.经过前面三个步骤后就可以通过「cn.bingoogolapple.badgeview.BGABadge原始类名」来使用徽章控件了
*/
@BGABadge({
"android.view.View", // 对应 cn.bingoogolapple.badgeview.BGABadgeFloatingActionButton
"android.widget.ImageView", // 对应 cn.bingoogolapple.badgeview.BGABadgeImageView
"android.widget.TextView", // 对应 cn.bingoogolapple.badgeview.BGABadgeFloatingTextView
"android.widget.RadioButton", // 对应 cn.bingoogolapple.badgeview.BGABadgeRadioButton
"android.widget.LinearLayout", // 对应 cn.bingoogolapple.badgeview.BGABadgeLinearLayout
"android.widget.FrameLayout", // 对应 cn.bingoogolapple.badgeview.BGABadgeFrameLayout
"android.widget.RelativeLayout", // 对应 cn.bingoogolapple.badgeview.BGABadgeRelativeLayout
"android.support.design.widget.FloatingActionButton", // 对应 cn.bingoogolapple.badgeview.BGABadgeFloatingActionButton
})
public class BGABadgeInit {
}
```

Version 1.1.4 *(2018-01-14)*
----------------------------

- 修改拖拽效果 Window 类型 TYPE_APPLICATION_PANEL

Version 1.1.3 *(2016-07-22)*
----------------------------

Expand Down
34 changes: 28 additions & 6 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-BGABadgeView-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2106)
[![License](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-badgeview/badge.svg)](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-badgeview)
[ ![Download](https://api.bintray.com/packages/bingoogolapple/maven/bga-badgeview-api/images/download.svg) ](https://bintray.com/bingoogolapple/maven/bga-badgeview-api/_latestVersion)

### [中文文档](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/README.md)

Expand All @@ -24,12 +24,38 @@

### Gradle Dependencies

[ ![Download](https://api.bintray.com/packages/bingoogolapple/maven/bga-badgeview-api/images/download.svg) ](https://bintray.com/bingoogolapple/maven/bga-badgeview-api/_latestVersion)

```groovy
dependencies {
compile 'cn.bingoogolapple:bga-badgeview:latestVersion@aar'
implementation 'cn.bingoogolapple:bga-badgeview-api:latestVersion'
annotationProcessor "cn.bingoogolapple:bga-badgeview-compiler:latestVersion"
}
```

### Initialize BGABadge

Add BGABadge annotation to any class, such as newly created class BGABadgeInit

```Java
@BGABadge({
"android.view.View", // ===> cn.bingoogolapple.badgeview.BGABadgeFloatingActionButton,If you do not need, please delete this line
"android.widget.ImageView", // ===> cn.bingoogolapple.badgeview.BGABadgeImageView,If you do not need, please delete this line
"android.widget.TextView", // ===> cn.bingoogolapple.badgeview.BGABadgeFloatingTextView,If you do not need, please delete this line
"android.widget.RadioButton", // ===> cn.bingoogolapple.badgeview.BGABadgeRadioButton,If you do not need, please delete this line
"android.widget.LinearLayout", // ===> cn.bingoogolapple.badgeview.BGABadgeLinearLayout,If you do not need, please delete this line
"android.widget.RelativeLayout", // ===> cn.bingoogolapple.badgeview.BGABadgeRelativeLayout,If you do not need, please delete this line
"android.support.design.widget.FloatingActionButton", // ===> cn.bingoogolapple.badgeview.BGABadgeFloatingActionButton,If you do not need, please delete this line
...
...
...

})
public class BGABadgeInit {
}
```


### Supported badge style for now

Class name | usage scenario
Expand Down Expand Up @@ -100,10 +126,6 @@ badge_borderWidth | Border width of badge | 0dp
badge_borderColor | Border color of badge | Color.WHITE
badge_dragExtra | Extra distance of trigger drag event | 4dp

### Extend your own BadgeView

Extends one of widget above, override the method in interface [BGABadgeable](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeable.java), then call the method in [BGABadgeViewHelper](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeViewHelper.java). More realization details of custom widget refer to [BGABadgeRadioButton](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeRadioButton.java), combination realization of custom widget refer to [BGABadgeLinearLayout](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeLinearLayout.java)

### About me

| Sina weibo | Personal homepage | email | QQ for the BGA funs |
Expand Down
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-BGABadgeView-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/2106)
[![License](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-badgeview/badge.svg)](https://maven-badges.herokuapp.com/maven-central/cn.bingoogolapple/bga-badgeview)
[ ![Download](https://api.bintray.com/packages/bingoogolapple/maven/bga-badgeview-api/images/download.svg) ](https://bintray.com/bingoogolapple/maven/bga-badgeview-api/_latestVersion)

### [English Document](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/README-en.md)

Expand All @@ -27,22 +27,38 @@

### Gradle依赖

[ ![Download](https://api.bintray.com/packages/bingoogolapple/maven/bga-badgeview-api/images/download.svg) ](https://bintray.com/bingoogolapple/maven/bga-badgeview-api/_latestVersion) bga-badgeview-api 后面的「latestVersion」指的是左边这个 Download 徽章后面的「数字」,请自行替换。

```groovy
dependencies {
compile 'cn.bingoogolapple:bga-badgeview:latestVersion@aar'
implementation 'cn.bingoogolapple:bga-badgeview-api:latestVersion'
annotationProcessor "cn.bingoogolapple:bga-badgeview-compiler:latestVersion"
}
```

### 目前支持的徽章类

类名 | 应用场景
:----------- | :-----------
BGABadgeRadioButton | 微博首页底部导航
BGABadgeImageView | 微博列表用户头像
BGABadgeTextView | 其实这个可以用BGABadgeCheckedTextView代替
BGABadgeLinearLayout | 列表item右侧消息条数
BGABadgeRelativeLayout | 列表item右侧消息条数
BGABadgeFrameLayout | 列表item右侧消息条数
### 初始化徽章控件

1. 在项目任意一个类上面添加 BGABadge 注解,例如新建一个类 BGABadgeInit 专门用于初始化徽章控件
2. 需要哪些类具有徽章功能,就把那些类的全限定名作为 BGABadge 注解的参数「下面的代码块给出了例子,不需要的可以删掉对应的行」
```Java
@BGABadge({
"android.view.View", // 对应 cn.bingoogolapple.badgeview.BGABadgeFloatingActionButton,不想用这个类的话就删了这一行
"android.widget.ImageView", // 对应 cn.bingoogolapple.badgeview.BGABadgeImageView,不想用这个类的话就删了这一行
"android.widget.TextView", // 对应 cn.bingoogolapple.badgeview.BGABadgeFloatingTextView,不想用这个类的话就删了这一行
"android.widget.RadioButton", // 对应 cn.bingoogolapple.badgeview.BGABadgeRadioButton,不想用这个类的话就删了这一行
"android.widget.LinearLayout", // 对应 cn.bingoogolapple.badgeview.BGABadgeLinearLayout,不想用这个类的话就删了这一行
"android.widget.FrameLayout", // 对应 cn.bingoogolapple.badgeview.BGABadgeFrameLayout,不想用这个类的话就删了这一行
"android.widget.RelativeLayout", // 对应 cn.bingoogolapple.badgeview.BGABadgeRelativeLayout,不想用这个类的话就删了这一行
"android.support.design.widget.FloatingActionButton", // 对应 cn.bingoogolapple.badgeview.BGABadgeFloatingActionButton,不想用这个类的话就删了这一行
...
...
...
})
public class BGABadgeInit {
}
```
3. 再 AS 中执行 Build => Rebuild Project
4. 经过前面三个步骤后就可以通过「cn.bingoogolapple.badgeview.BGABadge原始类名」来使用徽章控件了

### 接口说明

Expand Down Expand Up @@ -103,10 +119,6 @@ badge_borderWidth | 徽章描边宽度 | 0dp
badge_borderColor | 徽章描边颜色 | Color.WHITE
badge_dragExtra | 触发开始拖拽徽章事件的扩展触摸距离 | 4dp

### 扩展自己的BadgeView

继承特定的控件,实现[BGABadgeable](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeable.java)接口中相应的方法,并调用[BGABadgeViewHelper](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeViewHelper.java)中相应的方法,自定义控件实现方式请参考[BGABadgeRadioButton](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeRadioButton.java),自定义组合控件实现方式请参考[BGABadgeLinearLayout](https://github.com/bingoogolapple/BGABadgeView-Android/blob/master/library/src/main/java/cn/bingoogolapple/badgeview/BGABadgeLinearLayout.java)

## 关于我

| 新浪微博 | 个人主页 | 邮箱 | BGA系列开源库QQ群
Expand Down
14 changes: 14 additions & 0 deletions annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apply plugin: 'java-library'

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7


// gradle clean build uploadArchives -PpublishAar
if (hasProperty("publishAar")) {
apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/local-release.gradle'
}
// gradle clean build bintrayUpload -PpublishAar
if (hasProperty("publishAar")) {
apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/jcenter-release.gradle'
}
2 changes: 2 additions & 0 deletions annotation/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLISH_AAR_ARTIFACT_ID=bga-badgeview-annotation
PUBLISH_AAR_DESCRIPTION=Android BadgeView Annotation
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright 2018 bingoogolapple
* <p/>
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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 cn.bingoogolapple.badgeview.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* 作者:王浩 邮件:bingoogolapple@gmail.com
* 创建时间:2018/1/14
* 描述:
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.TYPE)
public @interface BGABadge {
String[] value() default {};
}
35 changes: 35 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion ANDROID_BUILD_SDK_VERSION as int

defaultConfig {
minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION as int
targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int
}

android {
lintOptions {
abortOnError false
}
}
}

dependencies {
compileOnly 'com.android.support:appcompat-v7:27.0.2'

// 发布到 jcenter 时
// api 中用 compile 传递依赖,用 api 不会传递依赖
// api project(':annotation')
// 发布完 annotation 后,改用依赖仓库里的 annotation 后再发布 api
compile "cn.bingoogolapple:bga-badgeview-annotation:${VERSION_NAME}"
}

// gradle clean build uploadArchives -PpublishAar
if (hasProperty("publishAar")) {
apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/local-release.gradle'
}
// gradle clean build bintrayUpload -PpublishAar
if (hasProperty("publishAar")) {
apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/jcenter-release.gradle'
}
2 changes: 2 additions & 0 deletions api/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLISH_AAR_ARTIFACT_ID=bga-badgeview-api
PUBLISH_AAR_DESCRIPTION=Android BadgeView Api
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public interface BGABadgeable {
*
* @param delegate
*/
void setDragDismissDelegage(BGADragDismissDelegate delegate);
void setDragDismissDelegate(BGADragDismissDelegate delegate);

/**
* 是否显示徽章
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ buildscript {

allprojects {
repositories {
maven {
url uri("${rootDir.path}/repo")
}
jcenter()
google()
}
Expand Down
23 changes: 23 additions & 0 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apply plugin: 'java-library'

dependencies {
// compiler 中用 implementation
// implementation project(':annotation')
// 发布完 annotation 后,改用依赖仓库里的 annotation 后再发布 compiler
implementation "cn.bingoogolapple:bga-badgeview-annotation:${VERSION_NAME}"

implementation 'com.google.auto.service:auto-service:1.0-rc4'
implementation 'com.squareup:javapoet:1.9.0'
}

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

// gradle clean build uploadArchives -PpublishAar
if (hasProperty("publishAar")) {
apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/local-release.gradle'
}
// gradle clean build bintrayUpload -PpublishAar
if (hasProperty("publishAar")) {
apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/jcenter-release.gradle'
}
2 changes: 2 additions & 0 deletions compiler/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLISH_AAR_ARTIFACT_ID=bga-badgeview-compiler
PUBLISH_AAR_DESCRIPTION=Android BadgeView Compiler
Loading

0 comments on commit 02db075

Please sign in to comment.