Skip to content

Commit

Permalink
add text & custom tags
Browse files Browse the repository at this point in the history
enable override some resources
update README.md
  • Loading branch information
am3n committed Apr 15, 2022
1 parent 2ab28cc commit 7a3183a
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 52 deletions.
5 changes: 5 additions & 0 deletions .idea/misc.xml

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

147 changes: 114 additions & 33 deletions README.md
Expand Up @@ -3,7 +3,8 @@
![MinAPI](https://img.shields.io/badge/API-21%2B-blue)
[![](https://jitpack.io/v/am3n/Changelog.svg)](https://jitpack.io/#am3n/Changelog)

Changelog is a android library, it helps developers display the history of changes in their applications.
Changelog is a android library, it helps developers display the history of changes in their
applications.

Supports Locales, Layout directions, Dark-Mode & it's very customizable!

Expand All @@ -12,61 +13,66 @@ You can find a sample code of Changelog in this repository.

Screenshots
-------

|Ltr-English|Rtlized-Farsi|Default-BG & Dark-Mode|
|-----------|-------------|--------------------|
|![ACTIVITY](art/changelog_dialog_ltr_eng.png)|![ACTIVITY](art/changelog_dialog_rtl_fa.png)|![ACTIVITY](art/changelog_dialog_rtl_fa_bg_dk.png)|

|Customization-Icons|
|-------------------|
|![ACTIVITY](art/changelog_dialog_customization_item_icon.png)|

Installation
-------

```groovy
repositories {
maven { url "https://jitpack.io" }
}
```

```groovy
dependencies {
implementation "com.github.am3n:Changelog:NEWEST-VERSION"
}
```


Usage
-------

###

Add log history as xml sources to `/res/xml`

```xml

<changelog>

<release version="1.3.0" versioncode="70" date="2021-11-20">
<text>Redesigned something</text>
<info>Improved performance</info>
<custom>Added features</custom>
<fix>Fixed reported bugs</fix>
</release>

<release version="1.2.0" versioncode="61" summary="Example summary" date="2021-3-2">
<change>Redesigned something</change>
<change>Improved performance</change>
<change>Fixed reported bugs</change>
<custom icon="R.drawable.ic_tools">Improved performance</custom>
<fix>Fixed reported bugs</fix>
</release>

<release version="1.1.0" versioncode="44" date="2020-12-26">
<change>Added features</change>
<change>Fixed reported bugs</change>
</release>
</changelog>
```
You can add change logs in other locales (e.g. `/res/xml-fa-rIR`)
```xml
<changelog>
<release version="۱.۲.۰" versioncode="61" summary="نمونه خلاصه" date="1400/11/2">
<change>بازطراحی صفحات</change>
<change>بهبود عملکرد</change>
<change>رفع مشکلات گزارش شده</change>
</release>
<release version="۱.۱.۰" versioncode="44" date="1400/9/26">
<change>امکان جدید</change>
<change>رفع مشکلات گزارش شده</change>
<new>Added features</new>
<fix>Fixed reported bugs</fix>
</release>

</changelog>
```


###

The `present` function is used to show change log list.

```kotlin
Changelog.present(
activity = this,
Expand All @@ -93,47 +99,122 @@ Changelog.present(
```

###
If use `layoutDirection` should add this your project
& handle Rtl supporting in your app by yourself.

If use `layoutDirection` should add this your project & handle Rtl supporting in your app by
yourself.

```xml
<application
android:supportsRtl="false">

<application android:supportsRtl="false">

</application>
```
Of course, to support layout direction by yourself
you can use A3 views in my library: https://github.com/am3n/NeedTool

Of course, to support layout direction by yourself you can use A3 views in my
library: https://github.com/am3n/NeedTool

###

The `clear` is used to reset this library history.

```kotlin
Changelog.clear(applicationContext)
```

###

Customization
-------------

- Can add change logs in other locales (e.g. `/res/xml-fa-rIR/`)

```xml

<changelog>

<release version="۱.۳.۰" versioncode="70" date="1401/1/20">
<text>بازطراحی صفحات</text>
<info>بهبود عملکرد</info>
<custom>امکان جدید</custom>
<fix>رفع مشکلات گزارش شده</fix>
</release>

<release version="۱.۲.۰" versioncode="61" summary="نمونه خلاصه" date="1400/11/2">
<change>بازطراحی صفحات</change>
<custom icon="R.drawable.ic_tools">بهبود عملکرد</custom>
<fix>رفع مشکلات گزارش شده</fix>
</release>

<release version="۱.۱.۰" versioncode="44" date="1400/9/26">
<new>امکان جدید</new>
<fix>رفع مشکلات گزارش شده</fix>
</release>

</changelog>
```

###

- Can override the `new`, `change`, `info`, `fix` tag icons.
- new: `R.drawable.ic_changelog_item_new`
- change: `R.drawable.ic_changelog_item_change`
- info: `R.drawable.ic_changelog_item_info`
- fix: `R.drawable.ic_changelog_item_fix`

###

- Can change default icon for all `custom` tags that has no `icon` parameter:

```xml

<release>
...
<custom>Added features</custom>
</release>
```

by overriding drawable: `R.drawable.ic_changelog_item_custom_default`

###

- Can override the `new`, `change`, `info`, `fix` tag icon default colors.
(e.g. `/res/values/`, `/res/values-night/`)

```xml

<resources>
...
<color name="colorChangelogItemNew">?</color>
<color name="colorChangelogItemChange">?</color>
<color name="colorChangelogItemInfo">?</color>
<color name="colorChangelogItemFix">?</color>
<color name="colorChangelogItemCustom">?</color>
</resources>
```

###

Upcoming
-------

* Add presentIn option to show as dialog or bottom sheet or ...
* Add custom animations option
* Add cell image custom resource option
* Add cell image custom tint option
* Add some features from 'Credits' libraries


Contribution
-------
If you've found an error in the library or sample, please file an issue.
Patches are encouraged, and may be submitted by forking this project and submitting a pull request.
If you've found an error in the library or sample, please file an issue. Patches are encouraged, and
may be submitted by forking this project and submitting a pull request.


Credits
-------

* https://github.com/MFlisar/changelog
* https://github.com/furkanakdemir/noticeboard
* https://github.com/anderscheow/WhatsNew
* https://github.com/cketti/ckChangeLog


License
-------

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_changelog_item_new.xml
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000"
android:pathData="M23,12L20.56,9.22L20.9,5.54L17.29,4.72L15.4,1.54L12,3L8.6,1.54L6.71,4.72L3.1,5.53L3.44,9.21L1,12L3.44,14.78L3.1,18.47L6.71,19.29L8.6,22.47L12,21L15.4,22.46L17.29,19.28L20.9,18.46L20.56,14.78L23,12M13,17H11V15H13V17M13,13H11V7H13V13Z" />
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_tools.xml
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000"
android:pathData="M21.71 20.29L20.29 21.71A1 1 0 0 1 18.88 21.71L7 9.85A3.81 3.81 0 0 1 6 10A4 4 0 0 1 2.22 4.7L4.76 7.24L5.29 6.71L6.71 5.29L7.24 4.76L4.7 2.22A4 4 0 0 1 10 6A3.81 3.81 0 0 1 9.85 7L21.71 18.88A1 1 0 0 1 21.71 20.29M2.29 18.88A1 1 0 0 0 2.29 20.29L3.71 21.71A1 1 0 0 0 5.12 21.71L10.59 16.25L7.76 13.42M20 2L16 4V6L13.83 8.17L15.83 10.17L18 8H20L22 4Z" />
</vector>
6 changes: 3 additions & 3 deletions app/src/main/res/xml-fa-rIR/changelog.xml
Expand Up @@ -2,15 +2,15 @@
<changelog>

<release version="۱.۳.۰" versioncode="70" date="1401/1/20">
<change>بازطراحی صفحات</change>
<text>بازطراحی صفحات</text>
<info>بهبود عملکرد</info>
<new>امکان جدید</new>
<custom>امکان جدید</custom>
<fix>رفع مشکلات گزارش شده</fix>
</release>

<release version="۱.۲.۰" versioncode="61" summary="نمونه خلاصه" date="1400/11/2">
<change>بازطراحی صفحات</change>
<info>بهبود عملکرد</info>
<custom icon="R.drawable.ic_tools">بهبود عملکرد</custom>
<fix>رفع مشکلات گزارش شده</fix>
</release>

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/xml/changelog.xml
Expand Up @@ -2,15 +2,15 @@
<changelog>

<release version="1.3.0" versioncode="70" date="2021-11-20">
<change>Redesigned something</change>
<text>Redesigned something</text>
<info>Improved performance</info>
<new>Added features</new>
<custom>Added features</custom>
<fix>Fixed reported bugs</fix>
</release>

<release version="1.2.0" versioncode="61" summary="Example summary" date="2021-3-2">
<change>Redesigned something</change>
<info>Improved performance</info>
<custom icon="R.drawable.ic_tools">Improved performance</custom>
<fix>Fixed reported bugs</fix>
</release>

Expand Down
Binary file added art/changelog_dialog_customization_item_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions changelog/src/main/java/ir/am3n/changelog/ChangelogAdapter.kt
Expand Up @@ -4,7 +4,10 @@ import android.graphics.Typeface
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.core.view.*
import androidx.recyclerview.widget.RecyclerView
import ir.am3n.needtool.iDp2Px

/** An adapter for [ChangelogItem] and [ChangelogHeader]. Nothing special, except that
* it will create two types of holders, depending on the data type. */
Expand Down Expand Up @@ -57,10 +60,19 @@ class ChangelogAdapter(
layoutDirection?.let { holder.imgDesc.direction = it }

holder.imgDesc.setImageResource(when (item.type) {
XmlTags.ItemType.NEW -> R.drawable.alert_decagram_outline
XmlTags.ItemType.CHANGE -> R.drawable.tune_vertical_variant
XmlTags.ItemType.FIX -> R.drawable.ic_bug_check_outline
else -> R.drawable.information_outline
XmlTags.ItemType.NEW -> R.drawable.ic_changelog_item_new
XmlTags.ItemType.CHANGE -> R.drawable.ic_changelog_item_change
XmlTags.ItemType.FIX -> R.drawable.ic_changelog_item_fix
XmlTags.ItemType.INFO -> R.drawable.ic_changelog_item_info
XmlTags.ItemType.CUSTOM -> item.icon ?: R.drawable.ic_changelog_item_custom_default
XmlTags.ItemType.TEXT -> {
holder.imgDesc.updateLayoutParams<LinearLayout.LayoutParams> {
width = 0
updateMarginsRelative(start = 6.iDp2Px)
}
0
}
else -> 0
})
holder.txtDesc.text = item.description
holder.txtDesc.typeface = defaultFont
Expand Down
5 changes: 4 additions & 1 deletion changelog/src/main/java/ir/am3n/changelog/ChangelogItem.kt
@@ -1,7 +1,10 @@
package ir.am3n.changelog

import androidx.annotation.DrawableRes

/** Holds information about one "item", i.e. a <change> */
open class ChangelogItem(
val type: XmlTags.ItemType? = null,
val description: String? = null
val description: String? = null,
@DrawableRes val icon: Int? = null
)

0 comments on commit 7a3183a

Please sign in to comment.