From e310a16bad26b4d3ce318d833f64a60e01acbfcc Mon Sep 17 00:00:00 2001 From: opyale Date: Tue, 7 Apr 2020 21:17:12 +0000 Subject: [PATCH] Improving design of "Repository Meta" (#362) Merge branch 'master' into details-design Always open "Repository Meta" Fixing bugs. Merge remote-tracking branch 'remotes/main/master' into details-design Typo removal. Do not show pull requests when API returns null. Replacing size by watchers Removing unused imports. Moving time formatting into TimeHelper. Changing website icon and renaming button and dialog text. Further contentDescription Adding contentDescription Adding support for "timeFormat" Merge remote-tracking branch 'remotes/main/master' into details-design Full support for translation. Partially supporting translation. Adding "view additional information". Adding additional information. Adding forks count. First design changes. Improving usability by including whole header in "Details". Co-authored-by: opyale Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/362 Reviewed-by: M M Arif --- .../activities/IssueDetailActivity.java | 28 +- .../gitnex/adapters/ClosedIssuesAdapter.java | 24 +- .../gitnex/adapters/IssueCommentsAdapter.java | 26 +- .../mian/gitnex/adapters/IssuesAdapter.java | 24 +- .../gitnex/adapters/PullRequestsAdapter.java | 24 +- .../gitnex/fragments/RepoInfoFragment.java | 169 ++++--- .../org/mian/gitnex/helpers/TimeHelper.java | 27 ++ .../org/mian/gitnex/items/CommitsItems.java | 24 +- .../main/res/layout/fragment_repo_info.xml | 412 ++++++++++-------- app/src/main/res/values/strings.xml | 4 + 10 files changed, 393 insertions(+), 369 deletions(-) diff --git a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java index 9a85ed5a..13c2406b 100644 --- a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java @@ -537,29 +537,11 @@ public class IssueDetailActivity extends BaseActivity { issueDescription.setLayoutParams(paramsDesc); } - switch (timeFormat) { - case "pretty": { - PrettyTime prettyTime = new PrettyTime(new Locale(locale)); - String createdTime = prettyTime.format(singleIssue.getCreated_at()); - issueCreatedTime.setText(createdTime); - issueCreatedTime.setVisibility(View.VISIBLE); - issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), getApplicationContext())); - break; - } - case "normal": { - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); - String createdTime = formatter.format(singleIssue.getCreated_at()); - issueCreatedTime.setText(createdTime); - issueCreatedTime.setVisibility(View.VISIBLE); - break; - } - case "normal1": { - DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); - String createdTime = formatter.format(singleIssue.getCreated_at()); - issueCreatedTime.setText(createdTime); - issueCreatedTime.setVisibility(View.VISIBLE); - break; - } + issueCreatedTime.setText(TimeHelper.formatTime(singleIssue.getCreated_at(), new Locale(locale), timeFormat, ctx)); + issueCreatedTime.setVisibility(View.VISIBLE); + + if(timeFormat.equals("pretty")) { + issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx)); } if(singleIssue.getMilestone() != null) { diff --git a/app/src/main/java/org/mian/gitnex/adapters/ClosedIssuesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ClosedIssuesAdapter.java index 98d8aadd..7a9ea6ac 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ClosedIssuesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ClosedIssuesAdapter.java @@ -193,26 +193,10 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter issueNumber.setText(String.valueOf(issuesModel.getNumber())); issueCommentsCount.setText(String.valueOf(issuesModel.getComments())); - switch (timeFormat) { - case "pretty": { - PrettyTime prettyTime = new PrettyTime(new Locale(locale)); - String createdTime = prettyTime.format(issuesModel.getCreated_at()); - issueCreatedTime.setText(createdTime); - issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issuesModel.getCreated_at()), context)); - break; - } - case "normal": { - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); - String createdTime = formatter.format(issuesModel.getCreated_at()); - issueCreatedTime.setText(createdTime); - break; - } - case "normal1": { - DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); - String createdTime = formatter.format(issuesModel.getCreated_at()); - issueCreatedTime.setText(createdTime); - break; - } + issueCreatedTime.setText(TimeHelper.formatTime(issuesModel.getCreated_at(), new Locale(locale), timeFormat, context)); + + if(timeFormat.equals("pretty")) { + issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issuesModel.getCreated_at()), context)); } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java index 29c2bcf0..d2223994 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/PullRequestsAdapter.java @@ -181,26 +181,10 @@ public class PullRequestsAdapter extends RecyclerView.Adapter dialog.dismiss()); + alertDialog.create().show(); + + } + }); if(repoInfo.getHas_issues() != null) { tinyDb.putBoolean("hasIssues", repoInfo.getHas_issues()); @@ -253,28 +313,6 @@ public class RepoInfoFragment extends Fragment { tinyDb.putBoolean("hasIssues", true); } - switch (timeFormat) { - case "pretty": { - PrettyTime prettyTime = new PrettyTime(new Locale(locale)); - String createdTime = prettyTime.format(repoInfo.getCreated_at()); - repoCreatedAtInfo.setText(createdTime); - repoCreatedAtInfo.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(repoInfo.getCreated_at()), getContext())); - break; - } - case "normal": { - DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); - String createdTime = formatter.format(repoInfo.getCreated_at()); - repoCreatedAtInfo.setText(createdTime); - break; - } - case "normal1": { - DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); - String createdTime = formatter.format(repoInfo.getCreated_at()); - repoCreatedAtInfo.setText(createdTime); - break; - } - } - mProgressBar.setVisibility(View.GONE); pageContent.setVisibility(View.VISIBLE); @@ -373,13 +411,14 @@ public class RepoInfoFragment extends Fragment { .build(); Spanned bodyWithMD = null; + if (response.body() != null) { bodyWithMD = markwon.toMarkdown(response.body()); } + assert bodyWithMD != null; markwon.setParsedMarkdown(repoFileContents, bodyWithMD); - } else if (response.code() == 401) { AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), diff --git a/app/src/main/java/org/mian/gitnex/helpers/TimeHelper.java b/app/src/main/java/org/mian/gitnex/helpers/TimeHelper.java index 6096927e..b1e6419e 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/TimeHelper.java +++ b/app/src/main/java/org/mian/gitnex/helpers/TimeHelper.java @@ -1,5 +1,8 @@ package org.mian.gitnex.helpers; +import android.content.Context; +import org.mian.gitnex.R; +import org.ocpsoft.prettytime.PrettyTime; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -25,6 +28,30 @@ public class TimeHelper { } + public static String formatTime(Date date, Locale locale, String timeFormat, Context context) { + + switch (timeFormat) { + + case "pretty": { + PrettyTime prettyTime = new PrettyTime(Locale.getDefault()); + return prettyTime.format(date); + } + + case "normal": { + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale); + return formatter.format(date); + } + + case "normal1": { + DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale); + return formatter.format(date); + } + + } + + return ""; + } + public static String customDateFormatForToastDateFormat(Date customDate) { DateFormat format = DateFormat.getDateTimeInstance(); diff --git a/app/src/main/java/org/mian/gitnex/items/CommitsItems.java b/app/src/main/java/org/mian/gitnex/items/CommitsItems.java index bfa2a69f..8c3b03ef 100644 --- a/app/src/main/java/org/mian/gitnex/items/CommitsItems.java +++ b/app/src/main/java/org/mian/gitnex/items/CommitsItems.java @@ -138,26 +138,10 @@ public class CommitsItems extends AbstractItem" + ctx.getResources().getString(R.string.viewInBrowser) + " ")); diff --git a/app/src/main/res/layout/fragment_repo_info.xml b/app/src/main/res/layout/fragment_repo_info.xml index 79e7571d..e676a22f 100644 --- a/app/src/main/res/layout/fragment_repo_info.xml +++ b/app/src/main/res/layout/fragment_repo_info.xml @@ -1,5 +1,6 @@ @@ -52,214 +53,267 @@ + android:layout_height="wrap_content" + android:orientation="vertical"> - - - - + android:textSize="22sp" + android:textStyle="bold" + tools:text="GitNex" /> - - - - - - - - - - + tools:text="Android client for Gitea https://gitnex.com" /> - + android:layout_marginTop="20dp" + android:baselineAligned="false" + android:orientation="horizontal"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + android:layout_marginBottom="20dp" + android:orientation="horizontal" + android:paddingLeft="15dp" + android:paddingRight="15dp"> - + + + + + + + + + + + + android:layout_marginBottom="20dp" + android:orientation="horizontal" + android:paddingLeft="15dp" + android:paddingRight="15dp"> - + + + + + + + + + + + + android:layout_marginBottom="20dp" + android:orientation="horizontal" + android:paddingLeft="15dp" + android:paddingRight="15dp"> - + - + - + - + + - + - - - - - - - +