Specify the last time an app was updated when showing update button

This commit is contained in:
Peter Serwylo 2017-03-15 09:37:57 +11:00
parent 60a2ebe9fa
commit d527b26814
2 changed files with 13 additions and 1 deletions

View File

@ -263,7 +263,15 @@ public class AppListItemController extends RecyclerView.ViewHolder {
private void configureAppName(@NonNull App app) { private void configureAppName(@NonNull App app) {
if (isReadyToInstall(app)) { if (isReadyToInstall(app)) {
if (app.isInstalled()) { if (app.isInstalled()) {
name.setText(activity.getString(R.string.app_list__name__downloaded_and_ready_to_update, app.name)); String appName = activity.getString(R.string.app_list__name__downloaded_and_ready_to_update, app.name);
if (app.lastUpdated != null) {
long ageInMillis = System.currentTimeMillis() - app.lastUpdated.getTime();
int ageInDays = (int) (ageInMillis / 1000 / 60 / 60 / 24);
String age = activity.getResources().getQuantityString(R.plurals.app_list__age__released_x_days_ago, ageInDays, ageInDays);
name.setText(appName + "\n" + age);
} else {
name.setText(appName);
}
} else { } else {
name.setText(activity.getString(R.string.app_list__name__downloaded_and_ready_to_install, app.name)); name.setText(activity.getString(R.string.app_list__name__downloaded_and_ready_to_install, app.name));
} }

View File

@ -73,6 +73,10 @@
<string name="app_list__name__downloaded_and_ready_to_update">Update %1$s</string> <string name="app_list__name__downloaded_and_ready_to_update">Update %1$s</string>
<string name="app_list__name__downloaded_and_ready_to_install">Install %1$s</string> <string name="app_list__name__downloaded_and_ready_to_install">Install %1$s</string>
<string name="app_list__name__downloading_in_progress">Downloading %1$s</string> <string name="app_list__name__downloading_in_progress">Downloading %1$s</string>
<plurals name="app_list__age__released_x_days_ago">
<item quantity="one">Released %1$d day ago</item>
<item quantity="other">Released %1$d days ago</item>
</plurals>
<string name="installed_apps__activity_title">Installed Apps</string> <string name="installed_apps__activity_title">Installed Apps</string>
<string name="installed_app__updates_ignored">Updates ignored</string> <string name="installed_app__updates_ignored">Updates ignored</string>