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 <example@example.com>
Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/362
Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
opyale 2020-04-07 21:17:12 +00:00 committed by M M Arif
parent e07ee1aceb
commit e310a16bad
10 changed files with 393 additions and 369 deletions

View File

@ -537,29 +537,11 @@ public class IssueDetailActivity extends BaseActivity {
issueDescription.setLayoutParams(paramsDesc); issueDescription.setLayoutParams(paramsDesc);
} }
switch (timeFormat) { issueCreatedTime.setText(TimeHelper.formatTime(singleIssue.getCreated_at(), new Locale(locale), timeFormat, ctx));
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(singleIssue.getCreated_at());
issueCreatedTime.setText(createdTime);
issueCreatedTime.setVisibility(View.VISIBLE); issueCreatedTime.setVisibility(View.VISIBLE);
issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), getApplicationContext()));
break; if(timeFormat.equals("pretty")) {
} issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(singleIssue.getCreated_at()), ctx));
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;
}
} }
if(singleIssue.getMilestone() != null) { if(singleIssue.getMilestone() != null) {

View File

@ -193,26 +193,10 @@ public class ClosedIssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
issueNumber.setText(String.valueOf(issuesModel.getNumber())); issueNumber.setText(String.valueOf(issuesModel.getNumber()));
issueCommentsCount.setText(String.valueOf(issuesModel.getComments())); issueCommentsCount.setText(String.valueOf(issuesModel.getComments()));
switch (timeFormat) { issueCreatedTime.setText(TimeHelper.formatTime(issuesModel.getClosed_at(), new Locale(locale), timeFormat, context));
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); if(timeFormat.equals("pretty")) {
String createdTime = prettyTime.format(issuesModel.getCreated_at()); issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issuesModel.getClosed_at()), context));
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;
}
} }
} }

View File

@ -23,6 +23,7 @@ import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.util.TinyDB; import org.mian.gitnex.util.TinyDB;
import org.mian.gitnex.helpers.ClickListener; import org.mian.gitnex.helpers.ClickListener;
import org.ocpsoft.prettytime.PrettyTime; import org.ocpsoft.prettytime.PrettyTime;
import java.sql.Time;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Collection; import java.util.Collection;
@ -261,30 +262,11 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
} }
switch(timeFormat) { holder.issueCommentDate.setText(TimeHelper.formatTime(currentItem.getCreated_date(), new Locale(locale), timeFormat, mCtx));
case "pretty": { if(timeFormat.equals("pretty")) {
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
String createdTime = prettyTime.format(currentItem.getCreated_at());
holder.issueCommentDate.setText(createdTime);
holder.issueCommentDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx)); holder.issueCommentDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), mCtx));
break;
} }
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getCreated_at());
holder.issueCommentDate.setText(createdTime);
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + mCtx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(currentItem.getCreated_at());
holder.issueCommentDate.setText(createdTime);
break;
}
}
} }
@Override @Override

View File

@ -189,26 +189,10 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
issueNumber.setText(String.valueOf(issuesModel.getNumber())); issueNumber.setText(String.valueOf(issuesModel.getNumber()));
issueCommentsCount.setText(String.valueOf(issuesModel.getComments())); issueCommentsCount.setText(String.valueOf(issuesModel.getComments()));
switch (timeFormat) { issueCreatedTime.setText(TimeHelper.formatTime(issuesModel.getCreated_at(), new Locale(locale), timeFormat, context));
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); if(timeFormat.equals("pretty")) {
String createdTime = prettyTime.format(issuesModel.getCreated_at());
issueCreatedTime.setText(createdTime);
issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issuesModel.getCreated_at()), context)); 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;
}
} }
} }

View File

@ -181,26 +181,10 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
prNumber.setText(String.valueOf(prModel.getNumber())); prNumber.setText(String.valueOf(prModel.getNumber()));
prCommentsCount.setText(String.valueOf(prModel.getComments())); prCommentsCount.setText(String.valueOf(prModel.getComments()));
switch (timeFormat) { prCreatedTime.setText(TimeHelper.formatTime(prModel.getCreated_at(), new Locale(locale), timeFormat, context));
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); if(timeFormat.equals("pretty")) {
String createdTime = prettyTime.format(prModel.getCreated_at());
prCreatedTime.setText(createdTime);
prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(prModel.getCreated_at()), context)); prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(prModel.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(prModel.getCreated_at());
prCreatedTime.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(prModel.getCreated_at());
prCreatedTime.setText(createdTime);
break;
}
} }
} }

View File

@ -6,6 +6,7 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon; import io.noties.markwon.Markwon;
@ -30,6 +31,7 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
@ -44,9 +46,6 @@ import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.models.UserRepositories; import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.util.AppUtil; import org.mian.gitnex.util.AppUtil;
import org.mian.gitnex.util.TinyDB; import org.mian.gitnex.util.TinyDB;
import org.ocpsoft.prettytime.PrettyTime;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Locale; import java.util.Locale;
@ -58,7 +57,7 @@ import java.util.Objects;
public class RepoInfoFragment extends Fragment { public class RepoInfoFragment extends Fragment {
private Context ctx = getContext(); private Context ctx;
private ProgressBar mProgressBar; private ProgressBar mProgressBar;
private LinearLayout pageContent; private LinearLayout pageContent;
private static String repoNameF = "param2"; private static String repoNameF = "param2";
@ -66,17 +65,17 @@ public class RepoInfoFragment extends Fragment {
private String repoName; private String repoName;
private String repoOwner; private String repoOwner;
private TextView repoNameInfo; private TextView repoMetaName;
private TextView repoOwnerInfo; private TextView repoMetaDescription;
private TextView repoDescriptionInfo; private TextView repoMetaStars;
private TextView repoWebsiteInfo; private TextView repoMetaPullRequests;
private TextView repoSizeInfo; private LinearLayout repoMetaPullRequestsFrame;
private TextView repoDefaultBranchInfo; private TextView repoMetaForks;
private TextView repoSshUrlInfo; private TextView repoMetaSize;
private TextView repoCloneUrlInfo; private TextView repoMetaWatchers;
private TextView repoRepoUrlInfo; private TextView repoMetaCreatedAt;
private TextView repoForksCountInfo; private TextView repoMetaWebsite;
private TextView repoCreatedAtInfo; private Button repoAdditionalButton;
private TextView repoFileContents; private TextView repoFileContents;
private LinearLayout repoMetaFrame; private LinearLayout repoMetaFrame;
private ImageView repoMetaDataExpandCollapse; private ImageView repoMetaDataExpandCollapse;
@ -120,21 +119,23 @@ public class RepoInfoFragment extends Fragment {
final String locale = tinyDb.getString("locale"); final String locale = tinyDb.getString("locale");
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
ctx = getActivity();
pageContent = v.findViewById(R.id.repoInfoLayout); pageContent = v.findViewById(R.id.repoInfoLayout);
pageContent.setVisibility(View.GONE); pageContent.setVisibility(View.GONE);
mProgressBar = v.findViewById(R.id.progress_bar); mProgressBar = v.findViewById(R.id.progress_bar);
repoNameInfo = v.findViewById(R.id.repoNameInfo); repoMetaName = v.findViewById(R.id.repoMetaName);
repoOwnerInfo = v.findViewById(R.id.repoOwnerInfo); repoMetaDescription = v.findViewById(R.id.repoMetaDescription);
repoDescriptionInfo = v.findViewById(R.id.repoDescriptionInfo); repoMetaStars = v.findViewById(R.id.repoMetaStars);
repoWebsiteInfo = v.findViewById(R.id.repoWebsiteInfo); repoMetaPullRequests = v.findViewById(R.id.repoMetaPullRequests);
repoSizeInfo = v.findViewById(R.id.repoSizeInfo); repoMetaPullRequestsFrame = v.findViewById(R.id.repoMetaPullRequestsFrame);
repoDefaultBranchInfo = v.findViewById(R.id.repoDefaultBranchInfo); repoMetaForks = v.findViewById(R.id.repoMetaForks);
repoSshUrlInfo = v.findViewById(R.id.repoSshUrlInfo); repoMetaSize = v.findViewById(R.id.repoMetaSize);
repoCloneUrlInfo = v.findViewById(R.id.repoCloneUrlInfo); repoMetaWatchers = v.findViewById(R.id.repoMetaWatchers);
repoRepoUrlInfo = v.findViewById(R.id.repoRepoUrlInfo); repoMetaCreatedAt = v.findViewById(R.id.repoMetaCreatedAt);
repoForksCountInfo = v.findViewById(R.id.repoForksCountInfo); repoMetaWebsite = v.findViewById(R.id.repoMetaWebsite);
repoCreatedAtInfo = v.findViewById(R.id.repoCreatedAtInfo); repoAdditionalButton = v.findViewById(R.id.repoAdditionalButton);
repoFileContents = v.findViewById(R.id.repoFileContents); repoFileContents = v.findViewById(R.id.repoFileContents);
repoMetaFrame = v.findViewById(R.id.repoMetaFrame); repoMetaFrame = v.findViewById(R.id.repoMetaFrame);
LinearLayout repoMetaFrameHeader = v.findViewById(R.id.repoMetaFrameHeader); LinearLayout repoMetaFrameHeader = v.findViewById(R.id.repoMetaFrameHeader);
@ -148,15 +149,23 @@ public class RepoInfoFragment extends Fragment {
getRepoInfo(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, locale, timeFormat); getRepoInfo(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, locale, timeFormat);
getFileContents(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getResources().getString(R.string.defaultFilename)); getFileContents(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), repoOwner, repoName, getResources().getString(R.string.defaultFilename));
if(isExpandViewVisible()) {
toggleExpandView();
}
if(!isExpandViewMetaVisible()) {
toggleExpandViewMeta();
}
fileContentsFrameHeader.setOnClickListener(new View.OnClickListener() { fileContentsFrameHeader.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
collapseExpandView(); toggleExpandView();
} }
}); });
repoMetaFrameHeader.setOnClickListener(new View.OnClickListener() { repoMetaFrameHeader.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
collapseExpandViewMeta(); toggleExpandViewMeta();
} }
}); });
@ -179,7 +188,7 @@ public class RepoInfoFragment extends Fragment {
void onFragmentInteraction(Uri uri); void onFragmentInteraction(Uri uri);
} }
private void collapseExpandView() { private void toggleExpandView() {
if (repoFileContents.getVisibility() == View.GONE) { if (repoFileContents.getVisibility() == View.GONE) {
repoFilenameExpandCollapse.setImageResource(R.drawable.ic_arrow_up); repoFilenameExpandCollapse.setImageResource(R.drawable.ic_arrow_up);
@ -193,10 +202,14 @@ public class RepoInfoFragment extends Fragment {
//Animation slide_up = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up); //Animation slide_up = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up);
//fileContentsFrame.startAnimation(slide_up); //fileContentsFrame.startAnimation(slide_up);
} }
} }
private void collapseExpandViewMeta() { private boolean isExpandViewVisible() {
return repoFileContents.getVisibility() == View.VISIBLE;
}
private void toggleExpandViewMeta() {
if (repoMetaFrame.getVisibility() == View.GONE) { if (repoMetaFrame.getVisibility() == View.GONE) {
repoMetaDataExpandCollapse.setImageResource(R.drawable.ic_arrow_up); repoMetaDataExpandCollapse.setImageResource(R.drawable.ic_arrow_up);
repoMetaFrame.setVisibility(View.VISIBLE); repoMetaFrame.setVisibility(View.VISIBLE);
@ -209,7 +222,10 @@ public class RepoInfoFragment extends Fragment {
//Animation slide_up = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up); //Animation slide_up = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up);
//repoMetaFrame.startAnimation(slide_up); //repoMetaFrame.startAnimation(slide_up);
} }
}
private boolean isExpandViewMetaVisible() {
return repoMetaFrame.getVisibility() == View.VISIBLE;
} }
private void getRepoInfo(String instanceUrl, String token, final String owner, String repo, final String locale, final String timeFormat) { private void getRepoInfo(String instanceUrl, String token, final String owner, String repo, final String locale, final String timeFormat) {
@ -235,16 +251,60 @@ public class RepoInfoFragment extends Fragment {
if (response.code() == 200) { if (response.code() == 200) {
assert repoInfo != null; assert repoInfo != null;
repoNameInfo.setText(repoInfo.getName()); repoMetaName.setText(repoInfo.getName());
repoOwnerInfo.setText(owner); repoMetaDescription.setText(repoInfo.getDescription());
repoDescriptionInfo.setText(repoInfo.getDescription()); repoMetaStars.setText(repoInfo.getStars_count());
repoWebsiteInfo.setText(repoInfo.getWebsite());
repoSizeInfo.setText(AppUtil.formatFileSize(repoInfo.getSize())); if(repoInfo.getOpen_pull_count() != null) {
repoDefaultBranchInfo.setText(repoInfo.getDefault_branch()); repoMetaPullRequests.setText(repoInfo.getOpen_pull_count());
repoSshUrlInfo.setText(repoInfo.getSsh_url()); }
repoCloneUrlInfo.setText(repoInfo.getClone_url()); else {
repoRepoUrlInfo.setText(repoInfo.getHtml_url()); repoMetaPullRequestsFrame.setVisibility(View.GONE);
repoForksCountInfo.setText(repoInfo.getForks_count()); }
repoMetaForks.setText(repoInfo.getForks_count());
repoMetaSize.setText(AppUtil.formatFileSize(repoInfo.getSize()));
repoMetaWatchers.setText(repoInfo.getWatchers_count());
repoMetaCreatedAt.setText(TimeHelper.formatTime(repoInfo.getCreated_at(), new Locale(locale), timeFormat, ctx));
if(timeFormat.equals("pretty")) {
repoMetaCreatedAt.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(repoInfo.getCreated_at()), ctx));
}
String website = (repoInfo.getWebsite().isEmpty()) ? getResources().getString(R.string.noDataWebsite) : repoInfo.getWebsite();
repoMetaWebsite.setText(website);
repoAdditionalButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StringBuilder message = new StringBuilder();
message.append(getResources().getString(R.string.infoTabRepoDefaultBranchText))
.append(":\n").append(repoInfo.getDefault_branch()).append("\n\n");
message.append(getResources().getString(R.string.infoTabRepoUpdatedAt))
.append(":\n").append(repoInfo.getUpdated_at()).append("\n\n");
message.append(getResources().getString(R.string.infoTabRepoSshUrl))
.append(":\n").append(repoInfo.getSsh_url()).append("\n\n");
message.append(getResources().getString(R.string.infoTabRepoCloneUrl))
.append(":\n").append(repoInfo.getClone_url()).append("\n\n");
message.append(getResources().getString(R.string.infoTabRepoRepoUrl))
.append(":\n").append(repoInfo.getHtml_url());
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctx);
alertDialog.setTitle(getResources().getString(R.string.infoMoreInformation));
alertDialog.setMessage(message);
alertDialog.setPositiveButton(getResources().getString(R.string.close), (dialog, which) -> dialog.dismiss());
alertDialog.create().show();
}
});
if(repoInfo.getHas_issues() != null) { if(repoInfo.getHas_issues() != null) {
tinyDb.putBoolean("hasIssues", repoInfo.getHas_issues()); tinyDb.putBoolean("hasIssues", repoInfo.getHas_issues());
@ -253,28 +313,6 @@ public class RepoInfoFragment extends Fragment {
tinyDb.putBoolean("hasIssues", true); 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); mProgressBar.setVisibility(View.GONE);
pageContent.setVisibility(View.VISIBLE); pageContent.setVisibility(View.VISIBLE);
@ -373,13 +411,14 @@ public class RepoInfoFragment extends Fragment {
.build(); .build();
Spanned bodyWithMD = null; Spanned bodyWithMD = null;
if (response.body() != null) { if (response.body() != null) {
bodyWithMD = markwon.toMarkdown(response.body()); bodyWithMD = markwon.toMarkdown(response.body());
} }
assert bodyWithMD != null; assert bodyWithMD != null;
markwon.setParsedMarkdown(repoFileContents, bodyWithMD); markwon.setParsedMarkdown(repoFileContents, bodyWithMD);
} else if (response.code() == 401) { } else if (response.code() == 401) {
AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle), AlertDialogs.authorizationTokenRevokedDialog(ctx, getResources().getString(R.string.alertDialogTokenRevokedTitle),

View File

@ -1,5 +1,8 @@
package org.mian.gitnex.helpers; 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.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; 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) { public static String customDateFormatForToastDateFormat(Date customDate) {
DateFormat format = DateFormat.getDateTimeInstance(); DateFormat format = DateFormat.getDateTimeInstance();

View File

@ -138,26 +138,10 @@ public class CommitsItems extends AbstractItem<CommitsItems, CommitsItems.ViewHo
commitTitleVw.setText(item.getCommitTitle()); commitTitleVw.setText(item.getCommitTitle());
commitCommitterVw.setText(ctx.getString(R.string.commitCommittedBy, item.getcommitCommitter())); commitCommitterVw.setText(ctx.getString(R.string.commitCommittedBy, item.getcommitCommitter()));
switch (timeFormat) { commitDateVw.setText(TimeHelper.formatTime(item.getcommitDate(), new Locale(locale), timeFormat, ctx));
case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); if(timeFormat.equals("pretty")) {
String createdTime = prettyTime.format(item.getcommitDate());
commitDateVw.setText(createdTime);
commitDateVw.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(item.getcommitDate()), ctx)); commitDateVw.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(item.getcommitDate()), ctx));
break;
}
case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + ctx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(item.getcommitDate());
commitDateVw.setText(createdTime);
break;
}
case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + ctx.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
String createdTime = formatter.format(item.getcommitDate());
commitDateVw.setText(createdTime);
break;
}
} }
commitHtmlUrlVw.setText(Html.fromHtml("<a href='" + item.getCommitHtmlUrl() + "'>" + ctx.getResources().getString(R.string.viewInBrowser) + "</a> ")); commitHtmlUrlVw.setText(Html.fromHtml("<a href='" + item.getCommitHtmlUrl() + "'>" + ctx.getResources().getString(R.string.viewInBrowser) + "</a> "));

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
@ -52,214 +53,267 @@
<LinearLayout <LinearLayout
android:id="@+id/repoMetaFrame" android:id="@+id/repoMetaFrame"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/repoMetaName"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:text="@string/infoTabRepoName1"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:id="@+id/repoNameInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoBlank"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoOwner1"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/> android:textSize="22sp"
android:textStyle="bold"
tools:text="GitNex" />
<TextView <TextView
android:id="@+id/repoOwnerInfo" android:id="@+id/repoMetaDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:text="@string/infoTabRepoBlank" android:layout_marginBottom="15dp"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoDesc"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
android:id="@+id/repoDescriptionInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoBlank"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:autoLink="web" android:autoLink="web"
android:textColor="?attr/primaryTextColor"/> android:ellipsize="end"
android:maxLines="3"
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoWebsite"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/> android:textSize="16sp"
tools:text="Android client for Gitea https://gitnex.com" />
<TextView <LinearLayout
android:id="@+id/repoWebsiteInfo"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="@string/infoTabRepoBlank" android:layout_marginTop="20dp"
android:textIsSelectable="true" android:baselineAligned="false"
android:textSize="14sp" android:orientation="horizontal">
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="?attr/primaryTextColor"/>
<TextView <LinearLayout
android:id="@+id/repoMetaStarsFrame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/repoStargazersInMenu"
app:srcCompat="@drawable/ic_star" />
<TextView
android:id="@+id/repoMetaStars"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/repoMetaPullRequestsFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/tabPullRequests"
app:srcCompat="@drawable/ic_merge" />
<TextView
android:id="@+id/repoMetaPullRequests"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/repoMetaForksFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/infoTabRepoForksCount"
app:srcCompat="@drawable/ic_forks_24" />
<TextView
android:id="@+id/repoMetaForks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/repoMetaWatchersFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/repoWatchersInMenu"
app:srcCompat="@drawable/ic_watchers" />
<TextView
android:id="@+id/repoMetaWatchers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="25dp"
android:layout_marginBottom="25dp"
android:alpha="0.2"
android:background="@color/lightGray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:orientation="horizontal"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/repoWatchersInMenu"
app:srcCompat="@drawable/ic_file_download_24dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/infoTabRepoSize" android:text="@string/infoTabRepoSize"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/> android:textSize="16sp" />
<TextView <TextView
android:id="@+id/repoSizeInfo" android:id="@+id/repoMetaSize"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:text="@string/infoTabRepoZero" android:alpha="0.9"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoDefaultBranch"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
android:id="@+id/repoDefaultBranchInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoDefaultBranchText"
android:textIsSelectable="true"
android:textSize="14sp" android:textSize="14sp"
android:paddingTop="5dp" tools:text="29" />
android:textColor="?attr/primaryTextColor"/> </LinearLayout>
<TextView </LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="@string/infoTabRepoSshUrl" android:layout_marginBottom="20dp"
android:textSize="16sp" android:orientation="horizontal"
android:textColor="?attr/primaryTextColor" android:paddingLeft="15dp"
android:layout_marginTop="15dp"/> android:paddingRight="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/infoTabRepoCreatedAt"
app:srcCompat="@drawable/ic_calendar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/repoSshUrlInfo" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="match_parent"
android:text="@string/infoTabRepoBlank"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoCloneUrl"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
android:id="@+id/repoCloneUrlInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoBlank"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoRepoUrl"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
android:id="@+id/repoRepoUrlInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoBlank"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoForksCount"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/>
<TextView
android:id="@+id/repoForksCountInfo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoZero"
android:textIsSelectable="true"
android:textSize="14sp"
android:paddingTop="5dp"
android:textColor="?attr/primaryTextColor"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/infoTabRepoCreatedAt" android:text="@string/infoTabRepoCreatedAt"
android:textSize="16sp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:layout_marginTop="15dp"/> android:textSize="16sp" />
<TextView <TextView
android:id="@+id/repoCreatedAtInfo" android:id="@+id/repoMetaCreatedAt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.9"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp"
tools:text="29" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="@string/infoTabRepoDummyTime" android:layout_marginBottom="20dp"
android:orientation="horizontal"
android:paddingLeft="15dp"
android:paddingRight="15dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/infoTabRepoWebsite"
app:srcCompat="@drawable/ic_link_24dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/websiteText"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp" />
<TextView
android:id="@+id/repoMetaWebsite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.9"
android:autoLink="web"
android:textColorLink="@color/lightBlue"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" android:textSize="14sp"
android:paddingTop="5dp" tools:text="29" />
android:textColor="?attr/primaryTextColor"/> </LinearLayout>
</LinearLayout>
<Button
android:id="@+id/repoAdditionalButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dp"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_buttons"
android:text="@string/infoShowMoreInformation"
android:textColor="@color/btnTextColor" />
</LinearLayout> </LinearLayout>

View File

@ -165,6 +165,9 @@
<string name="infoTabRepoZero" translatable="false">0</string> <string name="infoTabRepoZero" translatable="false">0</string>
<string name="infoTabRepoDefaultBranchText" translatable="false">master</string> <string name="infoTabRepoDefaultBranchText" translatable="false">master</string>
<string name="infoShowMoreInformation">Show more information</string>
<string name="infoMoreInformation">More information</string>
<string name="timeAtText">at</string> <string name="timeAtText">at</string>
<string name="hash" translatable="false">#</string> <string name="hash" translatable="false">#</string>
<string name="createdText">Opened\u0020</string> <string name="createdText">Opened\u0020</string>
@ -451,6 +454,7 @@
<string name="repoWatchersInMenu">Watchers</string> <string name="repoWatchersInMenu">Watchers</string>
<string name="noDataStargazers">No stars found</string> <string name="noDataStargazers">No stars found</string>
<string name="noDataWatchers">No watchers found</string> <string name="noDataWatchers">No watchers found</string>
<string name="noDataWebsite">No website found</string>
<string name="starMember">Star</string> <string name="starMember">Star</string>
<string name="watcherMember">Watcher</string> <string name="watcherMember">Watcher</string>