Display module/releases last publish time (#2012)
* Display module/releases last update time Co-authored-by: Howard20181 <40033067+Howard20181@users.noreply.github.com> Co-authored-by: 南宫雪珊 <vvb2060@gmail.com>
This commit is contained in:
parent
307b88f1d6
commit
f565075c43
|
|
@ -46,6 +46,9 @@ public class OnlineModule {
|
|||
@SerializedName("latestRelease")
|
||||
@Expose
|
||||
private String latestRelease;
|
||||
@SerializedName("latestReleaseTime")
|
||||
@Expose
|
||||
private String latestReleaseTime;
|
||||
@SerializedName("releases")
|
||||
@Expose
|
||||
private List<Release> releases = new ArrayList<>();
|
||||
|
|
@ -125,6 +128,10 @@ public class OnlineModule {
|
|||
return releases;
|
||||
}
|
||||
|
||||
public String getLatestReleaseTime() {
|
||||
return latestReleaseTime;
|
||||
}
|
||||
|
||||
public void setReleases(List<Release> releases) {
|
||||
this.releases = releases;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ import org.lsposed.manager.ui.widget.EmptyStateRecyclerView;
|
|||
import org.lsposed.manager.util.ModuleUtil;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
|
@ -283,7 +286,10 @@ public class RepoFragment extends BaseFragment implements RepoLoader.RepoListene
|
|||
OnlineModule module = showList.get(position);
|
||||
holder.appName.setText(module.getDescription());
|
||||
holder.appPackageName.setText(module.getName());
|
||||
|
||||
var instant = Instant.parse(module.getLatestReleaseTime());
|
||||
var formatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)
|
||||
.withLocale(App.getLocale()).withZone(ZoneId.systemDefault());
|
||||
holder.publishedTime.setText(String.format(getString(R.string.module_repo_updated_time), formatter.format(instant)));
|
||||
SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
|
||||
String summary = module.getSummary();
|
||||
|
|
@ -352,7 +358,7 @@ public class RepoFragment extends BaseFragment implements RepoLoader.RepoListene
|
|||
if (sort == 0) {
|
||||
return labelComparator.compare(a.getDescription(), b.getDescription());
|
||||
} else {
|
||||
return Instant.parse(b.getReleases().get(0).getUpdatedAt()).compareTo(Instant.parse(a.getReleases().get(0).getUpdatedAt()));
|
||||
return Instant.parse(b.getLatestReleaseTime()).compareTo(Instant.parse(a.getLatestReleaseTime()));
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
String queryStr = searchView != null ? searchView.getQuery().toString() : "";
|
||||
|
|
@ -392,14 +398,16 @@ public class RepoFragment extends BaseFragment implements RepoLoader.RepoListene
|
|||
TextView appPackageName;
|
||||
TextView appDescription;
|
||||
TextView hint;
|
||||
TextView publishedTime;
|
||||
|
||||
ViewHolder(ItemOnlinemoduleBinding binding) {
|
||||
super(binding.getRoot());
|
||||
root = binding.itemRoot;
|
||||
appName = binding.appName;
|
||||
appPackageName=binding.appPackageName;
|
||||
appPackageName = binding.appPackageName;
|
||||
appDescription = binding.description;
|
||||
hint = binding.hint;
|
||||
publishedTime = binding.publishedTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ import org.lsposed.manager.util.chrome.CustomTabsURLSpan;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
|
@ -411,6 +415,10 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
|
|||
} else {
|
||||
Release release = items.get(position);
|
||||
holder.title.setText(release.getName());
|
||||
var instant = Instant.parse(release.getPublishedAt());
|
||||
var formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT)
|
||||
.withLocale(App.getLocale()).withZone(ZoneId.systemDefault());
|
||||
holder.publishedTime.setText(String.format(getString(R.string.module_repo_published_time), formatter.format(instant)));
|
||||
renderGithubMarkdown(holder.description, release.getDescriptionHTML());
|
||||
holder.openInBrowser.setOnClickListener(v -> NavUtil.startURL(requireActivity(), release.getUrl()));
|
||||
List<ReleaseAsset> assets = release.getReleaseAssets();
|
||||
|
|
@ -443,6 +451,7 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
|
|||
|
||||
class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView title;
|
||||
TextView publishedTime;
|
||||
WebView description;
|
||||
MaterialButton openInBrowser;
|
||||
MaterialButton viewAssets;
|
||||
|
|
@ -457,6 +466,7 @@ public class RepoItemFragment extends BaseFragment implements RepoLoader.RepoLis
|
|||
public ReleaseViewHolder(ItemRepoReleaseBinding binding) {
|
||||
super(binding.getRoot());
|
||||
title = binding.title;
|
||||
publishedTime = binding.publishedTime;
|
||||
description = binding.description;
|
||||
openInBrowser = binding.openInBrowser;
|
||||
viewAssets = binding.viewAssets;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@
|
|||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/published_Time"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
@ -106,5 +106,22 @@
|
|||
app:layout_constraintWidth_max="wrap"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/published_Time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
app:layout_constrainedWidth="true"
|
||||
android:textSize="12sp"
|
||||
android:layout_marginTop="2dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/hint"
|
||||
app:layout_constraintWidth_max="wrap"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
|||
|
|
@ -47,12 +47,26 @@
|
|||
android:textSize="16sp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/description"
|
||||
app:layout_constraintBottom_toTopOf="@id/published_Time"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_max="wrap"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/published_Time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textSize="14sp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/description"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintWidth_max="wrap"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<org.lsposed.manager.ui.widget.ScrollWebView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="0dp"
|
||||
|
|
@ -62,8 +76,8 @@
|
|||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="@+id/title"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"
|
||||
app:layout_constraintStart_toStartOf="@+id/published_Time"
|
||||
app:layout_constraintTop_toBottomOf="@id/published_Time"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
<string name="module_repo">仓库</string>
|
||||
<string name="module_repo_loading">加载中…</string>
|
||||
<string name="module_repo_up_to_date">所有模块均已最新</string>
|
||||
<string name="module_repo_published_time">发布于 %s</string>
|
||||
<string name="module_repo_updated_time">更新于 %s</string>
|
||||
<plurals name="module_repo_upgradable">
|
||||
<item quantity="other">%d 个模块可更新</item>
|
||||
</plurals>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
<string name="module_repo">Repository</string>
|
||||
<string name="module_repo_loading">Loading…</string>
|
||||
<string name="module_repo_up_to_date">All modules up to date</string>
|
||||
<string name="module_repo_published_time">Published at %s</string>
|
||||
<string name="module_repo_updated_time">Updated at %s</string>
|
||||
<plurals name="module_repo_upgradable">
|
||||
<item quantity="one">%d module upgradable</item>
|
||||
<item quantity="other">%d modules upgradable</item>
|
||||
|
|
|
|||
Loading…
Reference in New Issue