Skip to content

Commit

Permalink
Merge pull request #23 from minibugdev/feature/version-2
Browse files Browse the repository at this point in the history
Version 2.0.0
  • Loading branch information
minibugdev committed Jan 3, 2020
2 parents 7218c18 + 4f18676 commit 631c14c
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 245 deletions.
37 changes: 8 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,26 @@ version: 2
jobs:
build:
docker:
- image: circleci/android:api-26-alpha
- image: circleci/android:api-29
environment:
- JVM_OPTS: -Xmx3200m
- TERM: dumb
- JVM_OPTS: -Xmx1024m
- _JAVA_OPTIONS: "-Xmx1024m"
steps:
- run:
name: Install custom system image
command: sdkmanager "system-images;android-21;default;armeabi-v7a"
environment:
TERM: dumb
- run:
name: Create avd
command: echo no | avdmanager create avd -n testEmulator -k "system-images;android-21;default;armeabi-v7a"
environment:
TERM: dumb
- run:
name: Start emulator
command: export LD_LIBRARY_PATH=${ANDROID_HOME}/emulator/lib64:${ANDROID_HOME}/emulator/lib64/qt/lib && emulator64-arm -avd testEmulator -noaudio -no-boot-anim -no-window -accel on
background: true
environment:
TERM: dumb
- checkout
- run:
name: Wait for emulator
command: |
circle-android wait-for-boot
sleep 30
adb shell input keyevent 82
environment:
TERM: dumb
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "library/build.gradle" }}
key: jars-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "library/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "library/build.gradle" }}
- ~/.m2
key: jars-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "library/build.gradle" }}
- run:
name: Run Tests
command: ./gradlew :library:connectedAndroidTest
command: ./gradlew :library:test
- store_artifacts:
path: library/build/reports
destination: reports
2 changes: 0 additions & 2 deletions .jitpack.yml

This file was deleted.

17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Drawable Badge
[![CircleCI](https://circleci.com/gh/minibugdev/DrawableBadge.svg?style=shield)](https://circleci.com/gh/minibugdev/DrawableBadge)
[![Release](https://jitpack.io/v/minibugdev/DrawableBadge.svg)](https://jitpack.io/#minibugdev/DrawableBadge/1.0.3)
[![Release](https://jitpack.io/v/minibugdev/DrawableBadge.svg)](https://jitpack.io/#minibugdev/DrawableBadge/2.0.0)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/minibugdev/DrawableBadge/master/LICENSE)

Drawable Badge is a android library for adding badges to drawables.
Expand All @@ -14,7 +14,8 @@ val drawable = DrawableBadge.Builder(context)
.drawableResId(R.mipmap.ic_launcher_round)
.badgeColor(R.color.badgeColor)
.badgeSize(R.dimen.badge_size)
.badgePosition(BadgePosition.TOP_RIGHT)
.badgeGravity(Gravity.CENTER_VERTICAL or Gravity.Start)
.badgeMargin(R.dimen.badge_margin)
.textColor(R.color.textColor)
.showBorder(true)
.badgeBorderColor(R.color.badgeBorderColor)
Expand All @@ -34,13 +35,17 @@ imageViewBadge.setImageDrawable(drawable)
- `bitmap`: Bitmap to added badges.
- `textColor`: Badge text color resource id, default `#FFFFFF`.
- `badgeColor`: Badge color resource id , default `#FF0000`.
- `badgeSize`: Badge size dimension id, default `16dp`.
- `badgePosition`: Position of Badge which need to added. (`TOP_LEFT`, `TOP_RIGHT`, `BOTTOM_RIGHT`, `BOTTOM_LEFT`), default `TOP_RIGHT`.
- `badgeSize`: Badge size supported `@DimenRes` or `@Px`, default `16dp`.
- `badgeGravity`: Position of badge by [Android Gravity](https://developer.android.com/reference/android/view/Gravity) which need to added. default `Gravity.TOP or Gravity.END`.
- `badgeMargin`: Badge margin supported `@DimenRes` or `@Px`, default `0`.
- `showBorder`: Set visible of badge border, default `true`.
- `badgeBorderColor`: Badge border color resource id , default `#FFFFFF`.
- `badgeBorderSize`: Badge border size dimension id, default `0.5dp`.
- `badgeBorderSize`: Badge border size supported `@DimenRes` or `@Px`, default `0.5dp`.
- `maximumCounter`: Maximum counter text will append with `+`, default and not more than `99`.

#### Deprecated
- `badgePosition`: Position of Badge which need to added.

## Download
``` groovy
repositories {
Expand All @@ -49,7 +54,7 @@ repositories {
```

``` groovy
compile 'com.github.minibugdev:drawablebadge:1.0.3'
compile 'com.github.minibugdev:drawablebadge:2.0.0'
```


Expand Down
19 changes: 8 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
buildscript {
ext.kotlin_version = '1.2.50'
ext.support_library_version = '27.1.1'
ext.test_runner_version = '1.0.1'
ext.kotlin_version = '1.3.61'
ext.androidx_version = '1.1.0'
ext.android_annotation_version = '1.1.0'

ext.test_runner_version = '1.2.0'
ext.junit_version = '4.12'
ext.mockito_version = '1.5.0'
ext.mockito_android_version = '2.13.0'
ext.mockk_version = '1.9.2'
ext.robolectric_version = '4.3.1'

repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'

Expand All @@ -27,11 +29,6 @@ allprojects {
}
}

task wrapper(type: Wrapper) {
description 'Creates the gradle wrapper.'
gradleVersion '4.5'
}

task clean(type: Delete) {
delete rootProject.buildDir
}
8 changes: 4 additions & 4 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.minibugdev"
minSdkVersion 15
targetSdkVersion 27
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand All @@ -25,6 +25,6 @@ android {

dependencies {
implementation project(':library')
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation "androidx.appcompat:appcompat:$androidx_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.minibugdev.drawablebadge.demo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.minibugdev.drawablebadge.BadgePosition
import android.view.Gravity
import androidx.appcompat.app.AppCompatActivity
import com.minibugdev.drawablebadge.DrawableBadge
import kotlinx.android.synthetic.main.activity_demo.*

Expand All @@ -15,14 +15,16 @@ class DemoActivity : AppCompatActivity() {
}

private fun registerEvents() {
buttonTopLeft.setOnClickListener { drawBadge(1, BadgePosition.TOP_LEFT) }
buttonTopRight.setOnClickListener { drawBadge(50, BadgePosition.TOP_RIGHT) }
buttonBottomLeft.setOnClickListener { drawBadge(99, BadgePosition.BOTTOM_LEFT) }
buttonBottomRight.setOnClickListener { drawBadge(100, BadgePosition.BOTTOM_RIGHT) }
buttonReset.setOnClickListener { drawBadge(0, BadgePosition.TOP_LEFT) }
buttonTopLeft.setOnClickListener { drawBadge(1, Gravity.TOP or Gravity.START) }
buttonTopRight.setOnClickListener { drawBadge(50, Gravity.TOP or Gravity.END) }
buttonBottomLeft.setOnClickListener { drawBadge(99, Gravity.BOTTOM or Gravity.START) }
buttonBottomRight.setOnClickListener { drawBadge(100, Gravity.BOTTOM or Gravity.END) }
buttonCenterHorizontal.setOnClickListener { drawBadge(100, Gravity.CENTER_HORIZONTAL or Gravity.TOP) }
buttonCenterVertical.setOnClickListener { drawBadge(100, Gravity.CENTER_VERTICAL or Gravity.START) }
buttonReset.setOnClickListener { drawBadge(0, Gravity.TOP or Gravity.END) }
}

private fun drawBadge(number: Int, position: BadgePosition) {
private fun drawBadge(number: Int, gravity: Int) {
val drawableResId = when (radioGroup.checkedRadioButtonId) {
R.id.radioButtonSelectorDrawable -> R.drawable.selector_badge
R.id.radioButtonVectorDrawable -> R.drawable.ic_notifications
Expand All @@ -33,12 +35,13 @@ class DemoActivity : AppCompatActivity() {
.drawableResId(drawableResId)
.badgeColor(R.color.badgeColor)
.badgeSize(R.dimen.badge_size)
.badgePosition(position)
.badgeGravity(gravity)
.textColor(R.color.textColor)
.showBorder(true)
.badgeBorderColor(R.color.borderColor)
.badgeBorderSize(R.dimen.badge_border_size)
.maximumCounter(99)
.badgeMargin(10f)
.build()
.get(number)
.let { drawable -> imageViewBadge.setImageDrawable(drawable) }
Expand Down
50 changes: 35 additions & 15 deletions demo/src/main/res/layout/activity_demo.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">

<ImageView
android:id="@+id/imageViewBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="48dp"
android:src="@mipmap/ic_launcher" />
<ImageView
android:id="@+id/imageViewBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="48dp"
android:src="@mipmap/ic_launcher" />

<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RadioButton
android:id="@+id/radioButtonDrawable"
Expand Down Expand Up @@ -72,6 +72,26 @@
android:text="Bottom Right" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/buttonCenterVertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Center Vertical" />

<Button
android:id="@+id/buttonCenterHorizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Center Horizontal" />
</LinearLayout>

<Button
android:id="@+id/buttonReset"
android:layout_width="match_parent"
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
android.enableUnitTestBinaryResources=true
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jul 03 15:46:50 ICT 2018
#Mon Jun 24 11:14:39 ICT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
34 changes: 19 additions & 15 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.github.minibugdev'

android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
compileSdkVersion 29
buildToolsVersion "29.0.2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 4
versionName "1.0.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
targetSdkVersion 29
versionCode 5
versionName "2.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -26,20 +26,24 @@ android {
test.java.srcDirs += 'src/test/kotlin'
}
testOptions {
unitTests.returnDefaultValues = true
unitTests {
returnDefaultValues = true
includeAndroidResources = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation "androidx.appcompat:appcompat:$androidx_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
androidTestImplementation "com.nhaarman:mockito-kotlin-kt1.1:$mockito_version"
androidTestImplementation "org.mockito:mockito-android:$mockito_android_version"
androidTestImplementation "com.android.support:support-annotations:$support_library_version"
androidTestImplementation "com.android.support.test:runner:$test_runner_version"
testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
testImplementation "org.robolectric:robolectric:$robolectric_version"
}

// build a jar with source files
Expand Down
Loading

0 comments on commit 631c14c

Please sign in to comment.