Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增Gravity实现 #38

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
由于作者最近没空,我对原作者的库进行了简单的重构;

#Release 1.2.0
支持更多的绘制位置,水平方向支持左中右,垂直方向支持上中下
更改控件兼容Appcompat
## Gradle配置
```
allprojects {
repositories {
jcenter()
//在工程的build.gradle文件中添加下述语句
maven { url 'https://dl.bintray.com/supluo/maven' }
}
}
```

```
//在Module的build.gradle文件中添加下述语句
   compile 'ms.easy:badgeview:{latestVersion}'
```

:heartpulse:BGABadgeView-Android:heartpulse:
============

Expand Down
80 changes: 80 additions & 0 deletions badgeview/bintray.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

def proj_version = '1.2.0'
def proj_artifact_id = 'badgeview'
def proj_group='ms.easy'
def proj_pom_name = 'Badgeview for Android'

def siteUrl = 'https://github.com/SupLuo/BGABadgeView-Android' // 项目的主页
def gitUrl = 'https://github.com/SupLuo/BGABadgeView-Android.git' // Git仓库的url

group = proj_group
version = proj_version

install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
groupId proj_group
artifactId proj_artifact_id
version proj_version
packaging 'aar'
// Add your description here
name proj_pom_name //项目描述
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'SupLuo'
name 'luo.chao'
email '329721894@qq.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = proj_artifact_id //发布到JCenter上的项目名字
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}
32 changes: 32 additions & 0 deletions badgeview/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion ANDROID_BUILD_SDK_VERSION as int
buildToolsVersion ANDROID_BUILD_TOOLS_VERSION

defaultConfig {
minSdkVersion ANDROID_BUILD_MIN_SDK_VERSION as int
targetSdkVersion ANDROID_BUILD_TARGET_SDK_VERSION as int
}

buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-annotations:23.4.0'
compile files('libs/nineoldandroids-2.4.0.jar')
}
// gradle uploadArchives
//apply from: 'https://raw.githubusercontent.com/bingoogolapple/PublishAar/master/central-publish.gradle'

apply from:'./bintray.gradle'
File renamed without changes.
Binary file added badgeview/libs/nineoldandroids-2.4.0.jar
Binary file not shown.
132 changes: 132 additions & 0 deletions badgeview/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Lucio/Library/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:


#########################START############################
#来源:proguard-android-optimize.txt
#-优化-
#(Basic)优化算法
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
#(Basic)迭代优化,n表示proguard对代码进行迭代优化的次数,Android一般为5
-optimizationpasses 5
#(Basic)提高优化步骤
-allowaccessmodification
#如果不想开启优化,则注释上面三句,开启下面一句
#-dontoptimize
#-优化-

#(Basic)#不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度
-dontpreverify
#(Basic 包名不混合大小写
-dontusemixedcaseclassnames
#(Basic)不忽略非公共的库类
-dontskipnonpubliclibraryclasses
#(Basic)输出混淆日志
-verbose

#(Basic)
-keep public class com.google.vending.licensing.ILicensingService
#(Basic)
-keep public class com.android.vending.licensing.ILicensingService

# 混淆注意事项见:http://www.jianshu.com/p/1b76e4c10495
#(Basic)混淆注意事项第一条,保留清单文件相关的配置比如四大组件;保留参数只有一个View的方法是为了预防xml中定义OnClick属性
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
#(Basic)混淆注意事项第二条,保持 native 方法不被混淆
-keepclasseswithmembernames class * {
native <methods>;
}

#-webview-
# 混淆注意事项第四条,保持WebView中JavaScript调用的方法
# 下面新增的-keepattributes *Annotation*保留注解,还应该是包含了这句功能
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
# 建议:使用了WebView和JS的需要添加下面语句
# 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 *;
}
#-webview-

# (Basic)混淆注意事项第五条 自定义View
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# (Basic)混淆注意事项第七条,保持 Parcelable 不被混淆
-keepclassmembers class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator CREATOR;
}
#(Basic) 混淆注意事项第八条,保持枚举 enum 类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
#(Basic)
-keepclassmembers class **.R$* {
public static <fields>;
}

#(Basic)排除support的警告
-dontwarn android.support.**

#(Basic)保留注解
-keepattributes *Annotation*
# 建议配置:保护泛型
-keepattributes Signature
# 建议配置:保留源文件以及行号 方便查看具体的崩溃信息
-keepattributes SourceFile,LineNumberTable

#以上为基本配置
########################END#############################


#感觉语句没什么用,就是为了保留keep注解,但是上面已经添加了保留注解属性,应该包括以下内容
## Understand the @Keep support annotation.
## (Basic)不混淆指定的类及其类成员
#-keep class android.support.annotation.Keep
## (Basic)不混淆使用注解的类及其类成员
#-keep @android.support.annotation.Keep class * {*;}
## (Basic)不混淆所有类及其类成员中的使用注解的方法
#-keepclasseswithmembers class * {
# @android.support.annotation.Keep <methods>;
#}
## (Basic)不混淆所有类及其类成员中的使用注解的字段
#-keepclasseswithmembers class * {
# @android.support.annotation.Keep <fields>;
#}
## 不混淆所有类及其类成员中的使用注解的初始化方法
#-keepclasseswithmembers class * {
# @android.support.annotation.Keep <init>(...);
#}


##############以下为自定义配置规则#######################

##保持透明状态栏类和所有public static方法

-keep public class easy.badge.**{
public *;
protected *;
}
1 change: 1 addition & 0 deletions badgeview/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="easy.badge"/>
21 changes: 21 additions & 0 deletions badgeview/src/main/java/easy/badge/Badge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package easy.badge;

import android.content.Context;
import android.util.AttributeSet;

import easy.badge.impl.BadgeView;
import easy.badge.impl.BadgeViewHelper;

/**
* Created by Lucio on 17/4/17.
*/
public class Badge {

public static BadgeViewHelper createViewHelper(BadgeView badgeable, Context context, AttributeSet attrs, @HorizontalGravity int gravityH,@VerticalGravity int gravityV){
return new BadgeHelperImpl(badgeable,context,attrs,gravityH,gravityV);
}

public static BadgeDragView createDragView(Context context, BadgeHelperImpl badgeViewHelper){
return new BadgeDragView(context,badgeViewHelper);
}
}
Loading