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"> - + - + - + - + + - + - - - - - - - +