Add last updated under the title and author

Also, added styles for the title and the last updated text.
This commit is contained in:
mvp76 2017-03-21 16:53:14 +01:00
parent d457a5ca0a
commit 0689a39735
4 changed files with 76 additions and 41 deletions

View File

@ -50,7 +50,9 @@ import org.fdroid.fdroid.privileged.views.AppSecurityPermissions;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
public class AppDetailsRecyclerViewAdapter public class AppDetailsRecyclerViewAdapter
extends RecyclerView.Adapter<RecyclerView.ViewHolder> { extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
@ -289,6 +291,7 @@ public class AppDetailsRecyclerViewAdapter
final ImageView iconView; final ImageView iconView;
final TextView titleView; final TextView titleView;
final TextView authorView; final TextView authorView;
final TextView lastUpdateView;
final TextView descriptionView; final TextView descriptionView;
final TextView descriptionMoreView; final TextView descriptionMoreView;
final View buttonLayout; final View buttonLayout;
@ -306,6 +309,7 @@ public class AppDetailsRecyclerViewAdapter
iconView = (ImageView) view.findViewById(R.id.icon); iconView = (ImageView) view.findViewById(R.id.icon);
titleView = (TextView) view.findViewById(R.id.title); titleView = (TextView) view.findViewById(R.id.title);
authorView = (TextView) view.findViewById(R.id.author); authorView = (TextView) view.findViewById(R.id.author);
lastUpdateView = (TextView) view.findViewById(R.id.text_last_update);
descriptionView = (TextView) view.findViewById(R.id.description); descriptionView = (TextView) view.findViewById(R.id.description);
descriptionMoreView = (TextView) view.findViewById(R.id.description_more); descriptionMoreView = (TextView) view.findViewById(R.id.description_more);
buttonLayout = view.findViewById(R.id.button_layout); buttonLayout = view.findViewById(R.id.button_layout);
@ -390,6 +394,14 @@ public class AppDetailsRecyclerViewAdapter
} else { } else {
authorView.setVisibility(View.GONE); 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()); final Spanned desc = Html.fromHtml(app.description, null, new Utils.HtmlTagHandler());
descriptionView.setMovementMethod(LinkMovementMethod.getInstance()); descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
descriptionView.setText(trimTrailingNewlines(desc)); descriptionView.setText(trimTrailingNewlines(desc));

View File

@ -12,8 +12,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:orientation="vertical"
android:orientation="vertical"> android:padding="8dp">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -25,90 +25,103 @@
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="72dp" android:layout_width="72dp"
android:layout_height="72dp" android:layout_height="72dp"
android:paddingRight="8dp"
android:paddingBottom="8dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:paddingBottom="8dp"
android:paddingRight="8dp"
android:src="@drawable/ic_repo_app_default" /> android:src="@drawable/ic_repo_app_default" />
<TextView <LinearLayout
android:id="@+id/title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginTop="8dp"
android:layout_toEndOf="@id/icon" android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon" android:layout_toRightOf="@id/icon"
android:textAppearance="@style/TextAppearance.AppCompat.Headline" android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/DetailsAppTitleStyle"
tools:text="App Title" /> tools:text="App Title" />
<TextView <TextView
android:id="@+id/author" android:id="@+id/author"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignEnd="@id/title"
android:layout_alignLeft="@id/title"
android:layout_alignRight="@id/title"
android:layout_alignStart="@id/title"
android:layout_below="@id/title"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textAppearance="@style/TextAppearance.AppCompat.Body1"
tools:text="Author" /> tools:text="Author" />
<TextView
android:id="@+id/text_last_update"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/DetailsLastUpdatedStyle"
android:textColor="@android:color/darker_gray"
tools:text="Update released 12 days ago" />
</LinearLayout>
<RelativeLayout <RelativeLayout
android:id="@+id/progress_layout" android:id="@+id/progress_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/icon"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"> android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="@id/icon">
<ImageView <ImageView
android:id="@+id/progress_cancel" android:id="@+id/progress_cancel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:src="@android:drawable/ic_menu_close_clear_cancel" android:layout_centerVertical="true"
/> android:src="@android:drawable/ic_menu_close_clear_cancel" />
<TextView <TextView
android:id="@+id/progress_label" android:id="@+id/progress_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:text="@string/downloading" android:text="@string/downloading"
/> android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<TextView <TextView
android:id="@+id/progress_percent" android:id="@+id/progress_percent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/progress_cancel" android:layout_toLeftOf="@id/progress_cancel"
android:layout_toStartOf="@id/progress_cancel" android:layout_toStartOf="@id/progress_cancel"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:text="" android:text=""
/> android:textAppearance="@style/TextAppearance.AppCompat.Small" />
<ProgressBar <ProgressBar
android:id="@+id/progress_bar" android:id="@+id/progress_bar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal" style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toLeftOf="@id/progress_cancel"
android:layout_toStartOf="@id/progress_cancel"
android:layout_below="@id/progress_label"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
/> android:layout_below="@id/progress_label"
android:layout_toLeftOf="@id/progress_cancel"
android:layout_toStartOf="@id/progress_cancel" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout
android:id="@+id/button_layout" android:id="@+id/button_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@id/icon" android:layout_below="@id/icon"
android:layout_toEndOf="@id/icon" android:layout_toEndOf="@id/icon"
android:layout_toRightOf="@id/icon" android:layout_toRightOf="@id/icon"
@ -124,7 +137,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:maxLines="1"
android:ellipsize="marquee" android:ellipsize="marquee"
android:padding="12dp" android:padding="12dp"
tools:text="THIS IS BUTTON 1" /> tools:text="THIS IS BUTTON 1" />
@ -137,7 +149,6 @@
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_weight="1" android:layout_weight="1"
android:maxLines="1"
android:ellipsize="marquee" android:ellipsize="marquee"
android:padding="12dp" android:padding="12dp"
tools:text="THIS IS 2" /> tools:text="THIS IS 2" />
@ -150,19 +161,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" 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: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." />
<TextView <TextView
android:id="@+id/description_more" android:id="@+id/description_more"
style="@style/DetailsMoreButtonStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
style="@style/DetailsMoreButtonStyle"
android:gravity="right|end" android:gravity="right|end"
android:text="@string/more" android:text="@string/more"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
tools:text="more" /> tools:text="more" />
</LinearLayout> </LinearLayout>

View File

@ -473,4 +473,10 @@
<item quantity="one">View the single one app in the %2$s category</item> <item quantity="one">View the single one app in the %2$s category</item>
<item quantity="other">View all %1$d apps from the %2$s category</item> <item quantity="other">View all %1$d apps from the %2$s category</item>
</plurals> </plurals>
<plurals name="details_last_update_days">
<item quantity="zero">Updated today</item>
<item quantity="one">Updated %1$s day ago</item>
<item quantity="other">Updated %1$s days ago</item>
</plurals>
</resources> </resources>

View File

@ -34,4 +34,11 @@
<item name="android:textColor">@color/fdroid_blue</item> <item name="android:textColor">@color/fdroid_blue</item>
</style> </style>
<style name="DetailsAppTitleStyle" parent="TextAppearance.AppCompat.Title">
<item name="android:textSize">18sp</item>
</style>
<style name="DetailsLastUpdatedStyle" parent="TextAppearance.AppCompat.Small">
</style>
</resources> </resources>