Skip to content

Commit

Permalink
Merge pull request #18 from AmosKorir/develop
Browse files Browse the repository at this point in the history
Release 1.5,
Builder pattern, text size, solid background color
  • Loading branch information
AmosKorir authored Oct 25, 2021
2 parents 4b5da02 + e4d16d2 commit 8c53884
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 121 deletions.
58 changes: 0 additions & 58 deletions .circleci/config.yml

This file was deleted.

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

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

2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

10 changes: 9 additions & 1 deletion .idea/misc.xml

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

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

40 changes: 19 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# AvatarImageGenerator

[![CircleCI](https://circleci.com/gh/circleci/circleci-docs.svg?style=shield)](https://app.circleci.com/pipelines/github/AmosKorir/AvatarImageGenerator/) [![Join the chat at https://gitter.im/AvatarImageGenerator/community](https://badges.gitter.im/AvatarImageGenerator/community.svg)](https://gitter.im/AvatarImageGenerator/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [ ![Download](https://api.bintray.com/packages/skyways/AvatarGenerator/AvatarGenerator/images/download.svg?version=1.4) ](https://bintray.com/skyways/AvatarGenerator/AvatarGenerator/1.4/link)
[![CircleCI](https://circleci.com/gh/circleci/circleci-docs.svg?style=shield)](https://app.circleci.com/pipelines/github/AmosKorir/AvatarImageGenerator/) [Download](https://api.bintray.com/packages/skyways/AvatarGenerator/AvatarGenerator/images/download.svg?version=1.5) ](https://bintray.com/skyways/AvatarGenerator/AvatarGenerator/1.4/link)

Generate first letter avatar Image like gmail's contact avatar. It generates an drawable that can be be set to an ImageView.
<table>
<tr>
<td>
<img width="200" height="400" src="https://github.com/skyways/AvatarImageGenerator/blob/master/art/Screen2.png"/>
<img width="200" height="400" src="Screen2.jpg"/>
</td>
<td>

<img width="200" height="400" src="https://github.com/skyways/AvatarImageGenerator/blob/master/art/screen.jpeg"/>
<img width="200" height="400" src="screen.jpeg"/>
</td>
</tr>
</table>


**Installation**

Add the Following to your gradle file.
Expand All @@ -23,6 +23,19 @@ Add the Following to your gradle file.
implementation 'com.first.avatargenerator:AvatarImageGenerator:VERSION'
```

New Builder pattern

```kotlin
AvatarGenerator.AvatarBuilder(context)
.setLabel(users[position].login)
.setAvatarSize(120)
.setTextSize(30)
.toSquare()
.toCircle()
.setBackgroundColor(Color.RED)
.build()
```

**Supports**

Using glide or Picasso you can set the drawable to an imageView as a placeholder.
Expand Down Expand Up @@ -61,28 +74,13 @@ imageView.setImageDrawable(
)
```

**Color Model**
The current version supports material colors A 400,700 and 900.

1. COLOR400
2. COLOR700
3. COLOR900

```java
Picasso.get()
.load("https://brokenfortest")
.resize(50, 50)
.placeholder(AvatarGenerator.avatarImage(this, 200, AvatarConstants.CIRCLE, "Android",AvatarConstants.COLOR900))
.into(imageView2)
```

**Shape**

1. Circle
2. Square

```java
AvatarConstants.RECTANGLE,
AvatarConstants.CIRCLE
.toSquare(),
.toCircle()

```
15 changes: 9 additions & 6 deletions app/src/main/java/com/avatarfirst/avatagen/UsersAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.avatarfirst.avatagen

import android.content.Context
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -32,12 +33,14 @@ class UsersAdapter(
override fun onBindViewHolder(holder: UserViewHolder, position: Int) {
holder.itemView.usename.text = users[position].login
holder.itemView.userAvatar.setImageDrawable(
AvatarGenerator.avatarImage(
context,
200,
AvatarConstants.CIRCLE,
users[position].login
)
AvatarGenerator.AvatarBuilder(context)
.setLabel(users[position].login)
.setAvatarSize(120)
.setTextSize(30)
.toSquare()
.toCircle()
.setBackgroundColor(Color.RED)
.build()
)
}

Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_dark"
tools:context=".MainActivity">

<androidx.recyclerview.widget.RecyclerView
Expand Down
14 changes: 6 additions & 8 deletions app/src/main/res/layout/user_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/item_background">
android:layout_height="wrap_content">

<ImageView
android:id="@+id/userAvatar"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
Expand All @@ -21,10 +20,9 @@
android:id="@+id/usename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="67dp"
android:layout_marginLeft="67dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:text="TextView"
android:textColor="@android:color/white"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="@+id/userAvatar"
app:layout_constraintStart_toEndOf="@+id/userAvatar"
Expand All @@ -39,7 +37,7 @@
android:layout_marginTop="8dp"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:background="@android:color/white"
android:background="#F1F0F0"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/userAvatar"
app:layout_constraintTop_toBottomOf="@+id/userAvatar" />
Expand Down
Binary file removed art/Screen2.png
Binary file not shown.
Binary file added art/screen2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8c53884

Please sign in to comment.