-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from fahim44/dev
v1.0.0
- Loading branch information
Showing
51 changed files
with
1,531 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,65 @@ | ||
# YetAnotherAccountChip | ||
General Android account drawable generator | ||
|
||
<a href="https://www.buymeacoffee.com/fahim44" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a> | ||
|
||
Dynamic account icon drawable generator for android. | ||
|
||
## SetUp | ||
|
||
Add it in your project level `build.gradle` at the end of repositories: | ||
```gradle | ||
repositories { | ||
mavenCentral() | ||
maven { url "https://jitpack.io" } | ||
} | ||
``` | ||
|
||
Add the dependency in your app level `build.gradle` file: | ||
```gradle | ||
dependencies { | ||
} | ||
``` | ||
|
||
## Example | ||
|
||
- Create new account chip drawable for account `John Doe` | ||
|
||
```kotlin | ||
ChipDrawableBuilder().build("John Doe") // create drawable with default configuration values. Background & text colors will be calculated by string's hashCode | ||
|
||
ChipDrawableBuilder().build("John Doe", 10) // create drawable with default configuration values. Here, index=10. Background & text colors will be selected from the predefine color list. & select the color = color[listSize % index] | ||
``` | ||
|
||
- Create account chip drawable for `[email protected]` with all configurations | ||
|
||
```kotlin | ||
ChipDrawableBuilder() | ||
.setBackgroundShape(GradientDrawable.OVAL) // set the background shape. Can be OVAL / RECTANGLE | ||
.setBackgroundColor(ContextCompat.getColor(context, R.color.purple_500)) // set background shape's color | ||
.setTypeFace(Typeface.create("Arial", Typeface.ITALIC)) // inside text font & style | ||
.setTextSizeInSp(context, 14.0f) // inside text size | ||
.setTextColor(ContextCompat.getColor(context, R.color.white)) // inside text color | ||
.setChipTextStyle(ChipTextStyle.FIRST_CHAR_LOWERCASE) // set the text character count & case | ||
// ChipTextStyle all options are: | ||
// FIRST_CHAR, FIRST_CHAR_UPPERCASE, FIRST_CHAR_LOWERCASE, | ||
// FIRST_TWO_CHAR, FIRST_TWO_CHAR_UPPERCASE, FIRST_TWO_CHAR_LOWERCASE, | ||
// FIRST_THREE_CHAR, FIRST_THREE_CHAR_UPPERCASE, FIRST_THREE_CHAR_LOWERCASE, | ||
// FIRST_CHARS_OF_WORDS, FIRST_CHAR_OF_WORDS_UPPERCASE, FIRST_CHAR_OF_WORDS_LOWERCASE | ||
.build("[email protected]") // build drawable for [email protected] account name | ||
``` | ||
|
||
- Change the Default configuration values | ||
|
||
```kotlin | ||
DefaultConfiguration.setBackgroundShape(GradientDrawable.RECTANGLE) // default value: OVAL | ||
DefaultConfiguration.setBackgroundColors(listOf("#FF0000", "#00FF00", "#0000FF").toTypedArray()) // background shape's color list. | ||
// For any item if the background color is not set, color will be selected from this list. | ||
// default values: Amber, Orange, Red, Lime, Light green, green, teal, cyan, light blue, blue, indigo, pink, purple, deep purple, blue gray | ||
DefaultConfiguration.setTextColors(listOf("#FFFFFF").toTypedArray()) // text color list. | ||
// For any item if the text color is not set, one color will be selected from this list. | ||
// default values: white | ||
DefaultConfiguration.setTypeface(Typeface.create("Arial", Typeface.NORMAL)) // default value: DEFAULT_BOLD | ||
DefaultConfiguration.setTextSizeInSp(context, 14.0f) // default value: 50 pixel | ||
DefaultConfiguration.setChipTextStyle(ChipTextStyle.FIRST_CHAR) // default value: FIRST_CHAR_UPPERCASE | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'org.jetbrains.kotlin.android' | ||
} | ||
|
||
android { | ||
compileSdk 32 | ||
|
||
defaultConfig { | ||
applicationId "com.lamounjush.yetanotheraccountchip" | ||
minSdk 21 | ||
targetSdk 32 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation project(path: ':yetanotheraccountchip') | ||
implementation 'androidx.core:core-ktx:1.8.0' | ||
implementation 'androidx.appcompat:appcompat:1.4.2' | ||
implementation 'com.google.android.material:material:1.6.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
40 changes: 40 additions & 0 deletions
40
app/src/androidTest/java/com/lamounjush/yetanotheraccountchip/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Fahim Salam Chowdhury ([email protected]) 2022 | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.lamounjush.yetanotheraccountchip | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.lamounjush.yetanotheraccountchip", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
package="com.lamounjush.yetanotheraccountchip"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:dataExtractionRules="@xml/data_extraction_rules" | ||
android:fullBackupContent="@xml/backup_rules" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.YetAnotherAccountChip" | ||
tools:targetApi="31"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/lamounjush/yetanotheraccountchip/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright Fahim Salam Chowdhury ([email protected]) 2022 | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.lamounjush.yetanotheraccountchip | ||
|
||
import android.graphics.Typeface | ||
import android.graphics.drawable.GradientDrawable | ||
import android.os.Bundle | ||
import android.widget.ImageView | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.content.ContextCompat | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
DefaultConfiguration.setBackgroundShape(GradientDrawable.OVAL) | ||
DefaultConfiguration.setTextSizeInSp(this, 30.0f) | ||
DefaultConfiguration.setChipTextStyle(ChipTextStyle.FIRST_CHAR_OF_WORDS_UPPERCASE) | ||
DefaultConfiguration.setTextColors(listOf("#FFFFFF").toTypedArray()) | ||
|
||
val imageView1: ImageView = findViewById(R.id.image1) | ||
imageView1.setImageDrawable( | ||
ChipDrawableBuilder() | ||
.build("John Doe") | ||
) | ||
|
||
|
||
val imageView2: ImageView = findViewById(R.id.image2) | ||
imageView2.setImageDrawable( | ||
ChipDrawableBuilder() | ||
.setBackgroundShape(GradientDrawable.RECTANGLE) | ||
.setBackgroundColor(ContextCompat.getColor(this, R.color.purple_500)) | ||
.setTextColor(ContextCompat.getColor(this, R.color.teal_700)) | ||
.setTextSizeInSp(this, 20.0f) | ||
.setChipTextStyle(ChipTextStyle.FIRST_THREE_CHAR) | ||
.build("[email protected]") | ||
) | ||
|
||
val imageView3: ImageView = findViewById(R.id.image3) | ||
imageView3.setImageDrawable( | ||
ChipDrawableBuilder() | ||
.setChipTextStyle(ChipTextStyle.FIRST_TWO_CHAR_LOWERCASE) | ||
.setTypeface(Typeface.create("Arial", Typeface.ITALIC)) | ||
.build("ActiveUser 1122", 15) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108"> | ||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:endX="85.84757" | ||
android:endY="92.4963" | ||
android:startX="42.9492" | ||
android:startY="49.59793" | ||
android:type="linear"> | ||
<item | ||
android:color="#44000000" | ||
android:offset="0.0" /> | ||
<item | ||
android:color="#00000000" | ||
android:offset="1.0" /> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:fillType="nonZero" | ||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00000000" /> | ||
</vector> |
Oops, something went wrong.