From 0689a39735879b0e89d98331f139e0655b9caa40 Mon Sep 17 00:00:00 2001 From: mvp76 Date: Tue, 21 Mar 2017 16:53:14 +0100 Subject: [PATCH] Add last updated under the title and author Also, added styles for the title and the last updated text. --- .../views/AppDetailsRecyclerViewAdapter.java | 12 +++ .../main/res/layout/app_details2_header.xml | 92 ++++++++++--------- app/src/main/res/values/strings.xml | 6 ++ app/src/main/res/values/styles_detail.xml | 7 ++ 4 files changed, 76 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java index 3f13c2fbd..5f750a61c 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java @@ -50,7 +50,9 @@ import org.fdroid.fdroid.privileged.views.AppSecurityPermissions; import java.text.NumberFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; +import java.util.concurrent.TimeUnit; public class AppDetailsRecyclerViewAdapter extends RecyclerView.Adapter { @@ -289,6 +291,7 @@ public class AppDetailsRecyclerViewAdapter final ImageView iconView; final TextView titleView; final TextView authorView; + final TextView lastUpdateView; final TextView descriptionView; final TextView descriptionMoreView; final View buttonLayout; @@ -306,6 +309,7 @@ public class AppDetailsRecyclerViewAdapter iconView = (ImageView) view.findViewById(R.id.icon); titleView = (TextView) view.findViewById(R.id.title); authorView = (TextView) view.findViewById(R.id.author); + lastUpdateView = (TextView) view.findViewById(R.id.text_last_update); descriptionView = (TextView) view.findViewById(R.id.description); descriptionMoreView = (TextView) view.findViewById(R.id.description_more); buttonLayout = view.findViewById(R.id.button_layout); @@ -390,6 +394,14 @@ public class AppDetailsRecyclerViewAdapter } else { authorView.setVisibility(View.GONE); } + if (app.lastUpdated != null) { + long msDiff = Calendar.getInstance().getTimeInMillis() - app.lastUpdated.getTime(); + int daysDiff = (int) TimeUnit.MILLISECONDS.toDays(msDiff); + lastUpdateView.setText(lastUpdateView.getContext().getResources().getQuantityString(R.plurals.details_last_update_days, daysDiff, daysDiff)); + lastUpdateView.setVisibility(View.VISIBLE); + } else { + lastUpdateView.setVisibility(View.GONE); + } final Spanned desc = Html.fromHtml(app.description, null, new Utils.HtmlTagHandler()); descriptionView.setMovementMethod(LinkMovementMethod.getInstance()); descriptionView.setText(trimTrailingNewlines(desc)); diff --git a/app/src/main/res/layout/app_details2_header.xml b/app/src/main/res/layout/app_details2_header.xml index aa752a60b..5b8360680 100755 --- a/app/src/main/res/layout/app_details2_header.xml +++ b/app/src/main/res/layout/app_details2_header.xml @@ -12,8 +12,8 @@ + android:orientation="vertical" + android:padding="8dp"> - + android:orientation="vertical"> - + + + + + + + + android:layout_alignParentLeft="true" + android:layout_alignParentRight="true" + android:layout_alignParentStart="true" + android:layout_below="@id/icon"> + + android:layout_centerVertical="true" + android:src="@android:drawable/ic_menu_close_clear_cancel" /> + + android:textAppearance="@style/TextAppearance.AppCompat.Small" /> + + android:textAppearance="@style/TextAppearance.AppCompat.Small" /> + + android:layout_below="@id/progress_label" + android:layout_toLeftOf="@id/progress_cancel" + android:layout_toStartOf="@id/progress_cancel" /> @@ -137,7 +149,6 @@ android:layout_marginLeft="8dp" android:layout_marginStart="8dp" android:layout_weight="1" - android:maxLines="1" android:ellipsize="marquee" android:padding="12dp" tools:text="THIS IS 2" /> @@ -150,19 +161,18 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" - android:textAppearance="@style/TextAppearance.AppCompat.Body1" - tools:text="This is the app description of this awezome app. It can be several lines long, but will be truncated at just a few if it is. A 'read more' button will appear so that you can expand the view and view the full text, if you wish. Yes, it will be blue and beautiful." android:scrollbars="none" - /> + android:textAppearance="@style/TextAppearance.AppCompat.Body1" + tools:text="This is the app description of this awezome app. It can be several lines long, but will be truncated at just a few if it is. A 'read more' button will appear so that you can expand the view and view the full text, if you wish. Yes, it will be blue and beautiful." /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 77a11336d..8a433336a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -473,4 +473,10 @@ View the single one app in the %2$s category View all %1$d apps from the %2$s category + + + Updated today + Updated %1$s day ago + Updated %1$s days ago + diff --git a/app/src/main/res/values/styles_detail.xml b/app/src/main/res/values/styles_detail.xml index 19fa91439..7bca4da09 100644 --- a/app/src/main/res/values/styles_detail.xml +++ b/app/src/main/res/values/styles_detail.xml @@ -34,4 +34,11 @@ @color/fdroid_blue + + + + \ No newline at end of file