Skip to content

Commit 213b736

Browse files
authored
Add update info (#956)
1 parent ca4e187 commit 213b736

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

feature/about/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies {
3232
implementation 'androidx.recyclerview:recyclerview:1.3.1'
3333
implementation 'com.google.android.material:material:1.10.0'
3434
implementation 'androidx.appcompat:appcompat:1.6.1'
35+
implementation 'org.threeten:threetenbp:1.5.1:no-tzdb'
3536

3637
androidTestImplementation 'junit:junit:4.13.2'
3738
androidTestImplementation espressoCore

feature/about/src/main/java/com/jraska/github/client/about/VersionInfoModel.kt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import android.view.View
44
import android.widget.TextView
55
import androidx.core.content.pm.PackageInfoCompat
66
import com.airbnb.epoxy.SimpleEpoxyModel
7+
import java.time.Instant
8+
import java.time.format.DateTimeFormatter.ISO_INSTANT
79

810
class VersionInfoModel : SimpleEpoxyModel(R.layout.about_item_version) {
911
override fun bind(view: View) {
@@ -15,8 +17,26 @@ class VersionInfoModel : SimpleEpoxyModel(R.layout.about_item_version) {
1517
view.findViewById<TextView>(R.id.version_build_type).text = buildTypeText
1618

1719
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
18-
val versionText = context.getString(R.string.about_version_name_and_code, packageInfo.versionName, PackageInfoCompat.getLongVersionCode(packageInfo))
20+
val versionText = context.getString(
21+
R.string.about_version_name_and_code,
22+
packageInfo.versionName,
23+
PackageInfoCompat.getLongVersionCode(packageInfo)
24+
)
1925
view.findViewById<TextView>(R.id.version_name_and_code).text = versionText
26+
27+
val firstInstallTimeText = ISO_INSTANT.format(
28+
Instant.ofEpochMilli(packageInfo.firstInstallTime)
29+
)
30+
val lastUpdateTimeText = ISO_INSTANT.format(
31+
Instant.ofEpochMilli(packageInfo.lastUpdateTime)
32+
)
33+
34+
val updateInfoText = context.getString(
35+
R.string.about_version_install_info,
36+
lastUpdateTimeText,
37+
firstInstallTimeText
38+
)
39+
view.findViewById<TextView>(R.id.version_update_info).text = updateInfoText
2040
}
2141

2242
override fun getSpanSize(totalSpanCount: Int, position: Int, itemCount: Int): Int {

feature/about/src/main/res/layout/about_item_version.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@
2828
tools:text="Build type: release"
2929
/>
3030

31+
<TextView
32+
android:id="@+id/version_update_info"
33+
android:layout_width="match_parent"
34+
android:layout_height="wrap_content"
35+
android:gravity="center"
36+
android:textColor="@color/textMain"
37+
android:textSize="@dimen/textMain"
38+
tools:text="Binary built on: 2023-10-21 17:00"
39+
/>
40+
3141
</LinearLayout>

feature/about/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010

1111
<string name="about_version_name_and_code">Version %s (%d)</string>
1212
<string name="about_version_build_type">Build type: %s</string>
13+
<string name="about_version_install_info">Update: %1$s\n Install: %2$s</string>
1314
</resources>

0 commit comments

Comments
 (0)