New About App dialog, improvements and fixes (#922)

Possible fix for #917

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/922
Reviewed-by: opyale <opyale@noreply.codeberg.org>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-committed-by: M M Arif <mmarif@noreply.codeberg.org>
This commit is contained in:
M M Arif 2021-05-30 19:28:14 +02:00 committed by opyale
parent 547e7c705d
commit 881aad5f2d
27 changed files with 346 additions and 564 deletions

View File

@ -569,7 +569,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
} }
TinyDB tinyDb = TinyDB.getInstance(appCtx); TinyDB tinyDb = TinyDB.getInstance(appCtx);
final String locale = getResources().getConfiguration().locale.getLanguage(); final Locale locale = getResources().getConfiguration().locale;
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
tinyDb.putString("issueState", singleIssue.getState()); tinyDb.putString("issueState", singleIssue.getState());
tinyDb.putString("issueTitle", singleIssue.getTitle()); tinyDb.putString("issueTitle", singleIssue.getTitle());
@ -660,7 +660,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
if(timeFormat.equals("normal") || timeFormat.equals("pretty")) { if(timeFormat.equals("normal") || timeFormat.equals("pretty")) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", locale);
String dueDate = formatter.format(singleIssue.getDue_date()); String dueDate = formatter.format(singleIssue.getDue_date());
viewBinding.issueDueDate.setText(dueDate); viewBinding.issueDueDate.setText(dueDate);
viewBinding.issueDueDate viewBinding.issueDueDate
@ -668,7 +668,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
} }
else if(timeFormat.equals("normal1")) { else if(timeFormat.equals("normal1")) {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", locale);
String dueDate = formatter.format(singleIssue.getDue_date()); String dueDate = formatter.format(singleIssue.getDue_date());
viewBinding.issueDueDate.setText(dueDate); viewBinding.issueDueDate.setText(dueDate);
} }
@ -714,7 +714,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
viewBinding.issueDescription.setLayoutParams(paramsDesc); viewBinding.issueDescription.setLayoutParams(paramsDesc);
} }
viewBinding.issueCreatedTime.setText(TimeHelper.formatTime(singleIssue.getCreated_at(), new Locale(locale), timeFormat, ctx)); viewBinding.issueCreatedTime.setText(TimeHelper.formatTime(singleIssue.getCreated_at(), locale, timeFormat, ctx));
viewBinding.issueCreatedTime.setVisibility(View.VISIBLE); viewBinding.issueCreatedTime.setVisibility(View.VISIBLE);
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {

View File

@ -44,7 +44,7 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
super(itemView); super(itemView);
Context ctx = itemView.getContext(); Context ctx = itemView.getContext();
final String locale = ctx.getResources().getConfiguration().locale.getLanguage(); final Locale locale = ctx.getResources().getConfiguration().locale;
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
ImageView runTask = itemView.findViewById(R.id.runTask); ImageView runTask = itemView.findViewById(R.id.runTask);
@ -58,10 +58,10 @@ public class AdminCronTasksAdapter extends RecyclerView.Adapter<AdminCronTasksAd
String lastRun = ""; String lastRun = "";
if(cronTasks.getNext() != null) { if(cronTasks.getNext() != null) {
nextRun = TimeHelper.formatTime(cronTasks.getNext(), new Locale(locale), timeFormat, ctx); nextRun = TimeHelper.formatTime(cronTasks.getNext(), locale, timeFormat, ctx);
} }
if(cronTasks.getPrev() != null) { if(cronTasks.getPrev() != null) {
lastRun = TimeHelper.formatTime(cronTasks.getPrev(), new Locale(locale), timeFormat, ctx); lastRun = TimeHelper.formatTime(cronTasks.getPrev(), locale, timeFormat, ctx);
} }
View view = LayoutInflater.from(ctx).inflate(R.layout.layout_cron_task_info, null); View view = LayoutInflater.from(ctx).inflate(R.layout.layout_cron_task_info, null);

View File

@ -57,13 +57,11 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) { if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
isLoading = true; isLoading = true;
loadMoreListener.onLoadMore(); loadMoreListener.onLoadMore();
} }
if(getItemViewType(position) == TYPE_LOAD) { if(getItemViewType(position) == TYPE_LOAD) {
((CommitsHolder) holder).bindData(commitsList.get(position)); ((CommitsHolder) holder).bindData(commitsList.get(position));
} }
} }
@ -106,18 +104,16 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
void bindData(Commits commitsModel) { void bindData(Commits commitsModel) {
final TinyDB tinyDb = TinyDB.getInstance(context); final TinyDB tinyDb = TinyDB.getInstance(context);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
commitTitle.setText(EmojiParser.parseToUnicode(commitsModel.getCommit().getMessage())); commitTitle.setText(EmojiParser.parseToUnicode(commitsModel.getCommit().getMessage()));
commitCommitter.setText(context.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName())); commitCommitter.setText(context.getString(R.string.commitCommittedBy, commitsModel.getCommit().getCommitter().getName()));
commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), locale, timeFormat, context));
commitDate.setText(TimeHelper.formatTime(commitsModel.getCommit().getCommitter().getDate(), new Locale(locale), timeFormat, context));
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {
commitDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(commitsModel.getCommit().getCommitter().getDate()), context)); commitDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(commitsModel.getCommit().getCommitter().getDate()), context));
} }
commitHtmlUrl.setOnClickListener(v -> context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(commitsModel.getHtml_url())))); commitHtmlUrl.setOnClickListener(v -> context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(commitsModel.getHtml_url()))));
} }
@ -126,36 +122,29 @@ public class CommitsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
static class LoadHolder extends RecyclerView.ViewHolder { static class LoadHolder extends RecyclerView.ViewHolder {
LoadHolder(View itemView) { LoadHolder(View itemView) {
super(itemView); super(itemView);
} }
} }
public void setMoreDataAvailable(boolean moreDataAvailable) { public void setMoreDataAvailable(boolean moreDataAvailable) {
isMoreDataAvailable = moreDataAvailable; isMoreDataAvailable = moreDataAvailable;
} }
public void notifyDataChanged() { public void notifyDataChanged() {
notifyDataSetChanged(); notifyDataSetChanged();
isLoading = false; isLoading = false;
} }
public interface OnLoadMoreListener { public interface OnLoadMoreListener {
void onLoadMore(); void onLoadMore();
} }
public void setLoadMoreListener(CommitsAdapter.OnLoadMoreListener loadMoreListener) { public void setLoadMoreListener(CommitsAdapter.OnLoadMoreListener loadMoreListener) {
this.loadMoreListener = loadMoreListener; this.loadMoreListener = loadMoreListener;
} }
public void updateList(List<Commits> list) { public void updateList(List<Commits> list) {
commitsList = list; commitsList = list;
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }

View File

@ -33,13 +33,13 @@ import java.util.Locale;
* Author M M Arif * Author M M Arif
*/ */
public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapter.SearchViewHolder> { public class ExploreIssuesAdapter extends RecyclerView.Adapter<ExploreIssuesAdapter.SearchViewHolder> {
private final List<Issues> searchedList; private final List<Issues> searchedList;
private final Context context; private final Context context;
private final TinyDB tinyDb; private final TinyDB tinyDb;
public SearchIssuesAdapter(List<Issues> dataList, Context ctx) { public ExploreIssuesAdapter(List<Issues> dataList, Context ctx) {
this.context = ctx; this.context = ctx;
this.searchedList = dataList; this.searchedList = dataList;
@ -49,7 +49,6 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
class SearchViewHolder extends RecyclerView.ViewHolder { class SearchViewHolder extends RecyclerView.ViewHolder {
private Issues issue; private Issues issue;
private final ImageView issueAssigneeAvatar; private final ImageView issueAssigneeAvatar;
private final TextView issueTitle; private final TextView issueTitle;
private final TextView issueCreatedTime; private final TextView issueCreatedTime;
@ -67,7 +66,6 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
itemView.setOnClickListener(v -> { itemView.setOnClickListener(v -> {
Context context = v.getContext(); Context context = v.getContext();
Intent intent = new Intent(context, IssueDetailActivity.class); Intent intent = new Intent(context, IssueDetailActivity.class);
intent.putExtra("issueNumber", issue.getNumber()); intent.putExtra("issueNumber", issue.getNumber());
@ -90,13 +88,11 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName); long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", id); tinyDb.putLong("repositoryId", id);
} }
else { else {
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName); Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
tinyDb.putLong("repositoryId", data.getRepositoryId()); tinyDb.putLong("repositoryId", data.getRepositoryId());
} }
context.startActivity(intent); context.startActivity(intent);
@ -113,19 +109,19 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
@NonNull @NonNull
@Override @Override
public SearchIssuesAdapter.SearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public ExploreIssuesAdapter.SearchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issues, parent, false); View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_issues, parent, false);
return new SearchIssuesAdapter.SearchViewHolder(v); return new ExploreIssuesAdapter.SearchViewHolder(v);
} }
@Override @Override
public void onBindViewHolder(@NonNull final SearchIssuesAdapter.SearchViewHolder holder, int position) { public void onBindViewHolder(@NonNull final ExploreIssuesAdapter.SearchViewHolder holder, int position) {
Issues currentItem = searchedList.get(position); Issues currentItem = searchedList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
PicassoService.getInstance(context).get() PicassoService.getInstance(context).get()
@ -144,20 +140,20 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
switch(timeFormat) { switch(timeFormat) {
case "pretty": { case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(locale);
String createdTime = prettyTime.format(currentItem.getCreated_at()); String createdTime = prettyTime.format(currentItem.getCreated_at());
holder.issueCreatedTime.setText(createdTime); holder.issueCreatedTime.setText(createdTime);
holder.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), context)); holder.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getCreated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getCreated_at()); String createdTime = formatter.format(currentItem.getCreated_at());
holder.issueCreatedTime.setText(createdTime); holder.issueCreatedTime.setText(createdTime);
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getCreated_at()); String createdTime = formatter.format(currentItem.getCreated_at());
holder.issueCreatedTime.setText(createdTime); holder.issueCreatedTime.setText(createdTime);
break; break;
@ -167,12 +163,10 @@ public class SearchIssuesAdapter extends RecyclerView.Adapter<SearchIssuesAdapte
@Override @Override
public int getItemCount() { public int getItemCount() {
return searchedList.size(); return searchedList.size();
} }
public void notifyDataChanged() { public void notifyDataChanged() {
notifyDataSetChanged(); notifyDataSetChanged();
} }
} }

View File

@ -23,7 +23,7 @@ import java.util.List;
* Author M M Arif * Author M M Arif
*/ */
public class PublicOrganizationsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class ExplorePublicOrganizationsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final Context context; private final Context context;
private final int TYPE_LOAD = 0; private final int TYPE_LOAD = 0;
@ -31,7 +31,7 @@ public class PublicOrganizationsAdapter extends RecyclerView.Adapter<RecyclerVie
private OnLoadMoreListener loadMoreListener; private OnLoadMoreListener loadMoreListener;
private boolean isLoading = false, isMoreDataAvailable = true; private boolean isLoading = false, isMoreDataAvailable = true;
public PublicOrganizationsAdapter(Context ctx, List<Organization> organizationsListMain) { public ExplorePublicOrganizationsAdapter(Context ctx, List<Organization> organizationsListMain) {
this.context = ctx; this.context = ctx;
this.organizationsList = organizationsListMain; this.organizationsList = organizationsListMain;
} }
@ -41,10 +41,10 @@ public class PublicOrganizationsAdapter extends RecyclerView.Adapter<RecyclerVie
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
if(viewType == TYPE_LOAD) { if(viewType == TYPE_LOAD) {
return new PublicOrganizationsAdapter.OrganizationsHolder(inflater.inflate(R.layout.list_organizations, parent, false)); return new ExplorePublicOrganizationsAdapter.OrganizationsHolder(inflater.inflate(R.layout.list_organizations, parent, false));
} }
else { else {
return new PublicOrganizationsAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); return new ExplorePublicOrganizationsAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
} }
} }
@ -56,7 +56,7 @@ public class PublicOrganizationsAdapter extends RecyclerView.Adapter<RecyclerVie
} }
if(getItemViewType(position) == TYPE_LOAD) { if(getItemViewType(position) == TYPE_LOAD) {
((PublicOrganizationsAdapter.OrganizationsHolder) holder).bindData(organizationsList.get(position)); ((ExplorePublicOrganizationsAdapter.OrganizationsHolder) holder).bindData(organizationsList.get(position));
} }
} }

View File

@ -122,45 +122,32 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<ExploreRepo
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token"); final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
WatchInfo watch = new WatchInfo(); WatchInfo watch = new WatchInfo();
Call<WatchInfo> call; Call<WatchInfo> call;
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName); call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
call.enqueue(new Callback<WatchInfo>() { call.enqueue(new Callback<WatchInfo>() {
@Override @Override
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) { public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
if(response.isSuccessful()) { if(response.isSuccessful()) {
assert response.body() != null; assert response.body() != null;
tinyDb.putBoolean("repoWatch", response.body().getSubscribed()); tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
}
} else { else {
tinyDb.putBoolean("repoWatch", false); tinyDb.putBoolean("repoWatch", false);
if(response.code() != 404) { if(response.code() != 404) {
Toasty.error(context, context.getString(R.string.genericApiStatusError)); Toasty.error(context, context.getString(R.string.genericApiStatusError));
} }
} }
} }
@Override @Override
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
tinyDb.putBoolean("repoWatch", false); tinyDb.putBoolean("repoWatch", false);
Toasty.error(context, context.getString(R.string.genericApiStatusError)); Toasty.error(context, context.getString(R.string.genericApiStatusError));
} }
}); });
} }
context.startActivity(intent); context.startActivity(intent);
}); });

View File

@ -50,6 +50,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
private final List<IssueComments> issuesComments; private final List<IssueComments> issuesComments;
private final FragmentManager fragmentManager; private final FragmentManager fragmentManager;
private final BottomSheetReplyFragment.OnInteractedListener onInteractedListener; private final BottomSheetReplyFragment.OnInteractedListener onInteractedListener;
private final Locale locale;
public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) { public IssueCommentsAdapter(Context ctx, Bundle bundle, List<IssueComments> issuesCommentsMain, FragmentManager fragmentManager, BottomSheetReplyFragment.OnInteractedListener onInteractedListener) {
@ -58,8 +59,8 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
this.issuesComments = issuesCommentsMain; this.issuesComments = issuesCommentsMain;
this.fragmentManager = fragmentManager; this.fragmentManager = fragmentManager;
this.onInteractedListener = onInteractedListener; this.onInteractedListener = onInteractedListener;
tinyDB = TinyDB.getInstance(ctx); tinyDB = TinyDB.getInstance(ctx);
locale = ctx.getResources().getConfiguration().locale;
} }
class IssueCommentViewHolder extends RecyclerView.ViewHolder { class IssueCommentViewHolder extends RecyclerView.ViewHolder {
@ -119,18 +120,15 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
ReactionSpinner reactionSpinner = new ReactionSpinner(ctx, bundle1); ReactionSpinner reactionSpinner = new ReactionSpinner(ctx, bundle1);
reactionSpinner.setOnInteractedListener(() -> { reactionSpinner.setOnInteractedListener(() -> {
tinyDB.putBoolean("commentEdited", true); tinyDB.putBoolean("commentEdited", true);
onInteractedListener.onInteracted(); onInteractedListener.onInteracted();
dialog.dismiss(); dialog.dismiss();
}); });
linearLayout.addView(reactionSpinner); linearLayout.addView(reactionSpinner);
commentMenuEdit.setOnClickListener(v1 -> { commentMenuEdit.setOnClickListener(v1 -> {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putInt("commentId", issueComment.getId()); bundle.putInt("commentId", issueComment.getId());
bundle.putString("commentAction", "edit"); bundle.putString("commentAction", "edit");
@ -141,11 +139,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet"); bottomSheetReplyFragment.show(fragmentManager, "replyBottomSheet");
dialog.dismiss(); dialog.dismiss();
}); });
commentShare.setOnClickListener(v1 -> { commentShare.setOnClickListener(v1 -> {
// get comment Url // get comment Url
CharSequence commentUrl = issueComment.getHtml_url(); CharSequence commentUrl = issueComment.getHtml_url();
@ -158,11 +154,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
ctx.startActivity(Intent.createChooser(sharingIntent, intentHeader)); ctx.startActivity(Intent.createChooser(sharingIntent, intentHeader));
dialog.dismiss(); dialog.dismiss();
}); });
issueCommentCopyUrl.setOnClickListener(v1 -> { issueCommentCopyUrl.setOnClickListener(v1 -> {
// comment Url // comment Url
CharSequence commentUrl = issueComment.getHtml_url(); CharSequence commentUrl = issueComment.getHtml_url();
@ -174,23 +168,19 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
dialog.dismiss(); dialog.dismiss();
Toasty.success(ctx, ctx.getString(R.string.copyIssueUrlToastMsg)); Toasty.success(ctx, ctx.getString(R.string.copyIssueUrlToastMsg));
}); });
commentMenuQuote.setOnClickListener(v1 -> { commentMenuQuote.setOnClickListener(v1 -> {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
String commenterName = issueComment.getUser().getUsername(); String commenterName = issueComment.getUser().getUsername();
if(!commenterName.equals(tinyDB.getString("userLogin"))) { if(!commenterName.equals(tinyDB.getString("userLogin"))) {
stringBuilder.append("@").append(commenterName).append("\n\n"); stringBuilder.append("@").append(commenterName).append("\n\n");
} }
String[] lines = issueComment.getBody().split("\\R"); String[] lines = issueComment.getBody().split("\\R");
for(String line : lines) { for(String line : lines) {
stringBuilder.append(">").append(line).append("\n"); stringBuilder.append(">").append(line).append("\n");
} }
@ -202,11 +192,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
dialog.dismiss(); dialog.dismiss();
BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet"); BottomSheetReplyFragment.newInstance(bundle).show(fragmentManager, "replyBottomSheet");
}); });
commentMenuCopy.setOnClickListener(v1 -> { commentMenuCopy.setOnClickListener(v1 -> {
ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) Objects.requireNonNull(ctx).getSystemService(Context.CLIPBOARD_SERVICE);
assert clipboard != null; assert clipboard != null;
@ -215,14 +203,11 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
dialog.dismiss(); dialog.dismiss();
Toasty.success(ctx, ctx.getString(R.string.copyIssueCommentToastMsg)); Toasty.success(ctx, ctx.getString(R.string.copyIssueCommentToastMsg));
}); });
commentMenuDelete.setOnClickListener(v1 -> { commentMenuDelete.setOnClickListener(v1 -> {
deleteIssueComment(ctx, issueComment.getId(), getAdapterPosition()); deleteIssueComment(ctx, issueComment.getId(), getAdapterPosition());
dialog.dismiss(); dialog.dismiss();
}); });
}); });
@ -230,12 +215,9 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
avatar.setOnClickListener(loginId -> { avatar.setOnClickListener(loginId -> {
Context context = loginId.getContext(); Context context = loginId.getContext();
AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId)); AppUtil.copyToClipboard(context, userLoginId, context.getString(R.string.copyLoginIdToClipBoard, userLoginId));
}); });
} }
} }
private void updateAdapter(int position) { private void updateAdapter(int position) {
@ -243,7 +225,6 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
issuesComments.remove(position); issuesComments.remove(position);
notifyItemRemoved(position); notifyItemRemoved(position);
notifyItemRangeChanged(position, issuesComments.size()); notifyItemRangeChanged(position, issuesComments.size());
} }
private void deleteIssueComment(final Context ctx, final int commentId, int position) { private void deleteIssueComment(final Context ctx, final int commentId, int position) {
@ -337,14 +318,11 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
if(issueComment.getCreated_at() != null) { if(issueComment.getCreated_at() != null) {
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), locale, "pretty", context));
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), context.getResources().getConfiguration().locale, "pretty", context));
holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at())); holder.information.setOnClickListener(v -> TimeHelper.customDateFormatForToastDateFormat(issueComment.getCreated_at()));
} }
else if(timeFormat.equals("normal")) { else if(timeFormat.equals("normal")) {
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), locale, "normal", context));
informationBuilder = new StringBuilder(TimeHelper.formatTime(issueComment.getCreated_at(), context.getResources().getConfiguration().locale, "normal", context));
} }
if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) { if(!issueComment.getCreated_at().equals(issueComment.getUpdated_at())) {
@ -374,7 +352,6 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<IssueCommentsAdap
@Override @Override
public int getItemCount() { public int getItemCount() {
return issuesComments.size(); return issuesComments.size();
} }

View File

@ -135,7 +135,7 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
void bindData(Issues issue) { void bindData(Issues issue) {
TinyDB tinyDb = TinyDB.getInstance(context); TinyDB tinyDb = TinyDB.getInstance(context);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
@ -156,20 +156,20 @@ public class IssuesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
switch(timeFormat) { switch(timeFormat) {
case "pretty": { case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(locale);
String createdTime = prettyTime.format(issue.getCreated_at()); String createdTime = prettyTime.format(issue.getCreated_at());
this.issueCreatedTime.setText(createdTime); this.issueCreatedTime.setText(createdTime);
this.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreated_at()), context)); this.issueCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(issue.getCreated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(issue.getCreated_at()); String createdTime = formatter.format(issue.getCreated_at());
this.issueCreatedTime.setText(createdTime); this.issueCreatedTime.setText(createdTime);
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(issue.getCreated_at()); String createdTime = formatter.format(issue.getCreated_at());
this.issueCreatedTime.setText(createdTime); this.issueCreatedTime.setText(createdTime);
break; break;

View File

@ -190,7 +190,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem; holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]); holder.orgName.setText(currentItem.getFullName().split("/")[0]);
@ -219,20 +219,20 @@ public class MyReposListAdapter extends RecyclerView.Adapter<MyReposListAdapter.
switch(timeFormat) { switch(timeFormat) {
case "pretty": { case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(locale);
String createdTime = prettyTime.format(currentItem.getUpdated_at()); String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context)); holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;

View File

@ -147,7 +147,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
void bindData(PullRequests pullRequest) { void bindData(PullRequests pullRequest) {
TinyDB tinyDb = TinyDB.getInstance(context); TinyDB tinyDb = TinyDB.getInstance(context);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
@ -165,7 +165,7 @@ public class PullRequestsAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
this.prTitle.setText(HtmlCompat.fromHtml(prNumber_ + " " + EmojiParser.parseToUnicode(pullRequest.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY)); this.prTitle.setText(HtmlCompat.fromHtml(prNumber_ + " " + EmojiParser.parseToUnicode(pullRequest.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY));
this.prCommentsCount.setText(String.valueOf(pullRequest.getComments())); this.prCommentsCount.setText(String.valueOf(pullRequest.getComments()));
this.prCreatedTime.setText(TimeHelper.formatTime(pullRequest.getCreated_at(), new Locale(locale), timeFormat, context)); this.prCreatedTime.setText(TimeHelper.formatTime(pullRequest.getCreated_at(), locale, timeFormat, context));
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {
this.prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(pullRequest.getCreated_at()), context)); this.prCreatedTime.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(pullRequest.getCreated_at()), context));

View File

@ -89,7 +89,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) { public void onBindViewHolder(@NonNull ReleasesAdapter.ReleasesViewHolder holder, int position) {
final TinyDB tinyDb = TinyDB.getInstance(context); final TinyDB tinyDb = TinyDB.getInstance(context);
final String locale = context.getResources().getConfiguration().locale.getLanguage(); final Locale locale = context.getResources().getConfiguration().locale;
final String timeFormat = tinyDb.getString("dateFormat"); final String timeFormat = tinyDb.getString("dateFormat");
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
@ -120,7 +120,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
} }
if(currentItem.getPublished_at() != null) { if(currentItem.getPublished_at() != null) {
holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), new Locale(locale), timeFormat, context)); holder.releaseDate.setText(TimeHelper.formatTime(currentItem.getPublished_at(), locale, timeFormat, context));
} }
if(timeFormat.equals("pretty")) { if(timeFormat.equals("pretty")) {

View File

@ -132,7 +132,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
TinyDB tinyDb = TinyDB.getInstance(context); TinyDB tinyDb = TinyDB.getInstance(context);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
this.userRepositories = forksModel; this.userRepositories = forksModel;
orgName.setText(forksModel.getFullName().split("/")[0]); orgName.setText(forksModel.getFullName().split("/")[0]);
@ -164,20 +164,20 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
switch(timeFormat) { switch(timeFormat) {
case "pretty": { case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(locale);
String createdTime = prettyTime.format(forksModel.getUpdated_at()); String createdTime = prettyTime.format(forksModel.getUpdated_at());
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdated_at()), context)); repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(forksModel.getUpdated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(forksModel.getUpdated_at()); String createdTime = formatter.format(forksModel.getUpdated_at());
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(forksModel.getUpdated_at()); String createdTime = formatter.format(forksModel.getUpdated_at());
repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;

View File

@ -189,7 +189,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem; holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]); holder.orgName.setText(currentItem.getFullName().split("/")[0]);
@ -218,20 +218,20 @@ public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.Repo
switch(timeFormat) { switch(timeFormat) {
case "pretty": { case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(locale);
String createdTime = prettyTime.format(currentItem.getUpdated_at()); String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context)); holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;

View File

@ -186,7 +186,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem; holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]); holder.orgName.setText(currentItem.getFullName().split("/")[0]);
@ -222,20 +222,20 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesB
switch(timeFormat) { switch(timeFormat) {
case "pretty": { case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(locale);
String createdTime = prettyTime.format(currentItem.getUpdated_at()); String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context)); holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;

View File

@ -187,7 +187,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
UserRepositories currentItem = reposList.get(position); UserRepositories currentItem = reposList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 3); int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
String locale = context.getResources().getConfiguration().locale.getLanguage(); Locale locale = context.getResources().getConfiguration().locale;
String timeFormat = tinyDb.getString("dateFormat"); String timeFormat = tinyDb.getString("dateFormat");
holder.userRepositories = currentItem; holder.userRepositories = currentItem;
holder.orgName.setText(currentItem.getFullName().split("/")[0]); holder.orgName.setText(currentItem.getFullName().split("/")[0]);
@ -223,20 +223,20 @@ public class StarredReposListAdapter extends RecyclerView.Adapter<StarredReposLi
switch(timeFormat) { switch(timeFormat) {
case "pretty": { case "pretty": {
PrettyTime prettyTime = new PrettyTime(new Locale(locale)); PrettyTime prettyTime = new PrettyTime(locale);
String createdTime = prettyTime.format(currentItem.getUpdated_at()); String createdTime = prettyTime.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context)); holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
break; break;
} }
case "normal": { case "normal": {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;
} }
case "normal1": { case "normal1": {
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale)); DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", locale);
String createdTime = formatter.format(currentItem.getUpdated_at()); String createdTime = formatter.format(currentItem.getUpdated_at());
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime)); holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
break; break;

View File

@ -1,88 +0,0 @@
package org.mian.gitnex.fragments;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.MainActivity;
import org.mian.gitnex.databinding.FragmentAboutBinding;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.TinyDB;
import java.util.Objects;
/**
* Author M M Arif
*/
public class AboutFragment extends Fragment {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
FragmentAboutBinding viewBinding = FragmentAboutBinding.inflate(inflater, container, false);
TinyDB tinyDb = TinyDB.getInstance(getContext());
viewBinding.appVersion.setText(AppUtil.getAppVersion(requireContext()));
viewBinding.userServerVersion.setText(tinyDb.getString("giteaVersion"));
viewBinding.appBuild.setText(String.valueOf(AppUtil.getAppBuildNo(requireContext())));
Objects.requireNonNull(((MainActivity) requireActivity()).getSupportActionBar()).hide();
viewBinding.close.setOnClickListener(v15 -> {
requireActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
Objects.requireNonNull(((MainActivity) requireActivity()).getSupportActionBar()).show();
});
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
requireActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit();
Objects.requireNonNull(((MainActivity) requireActivity()).getSupportActionBar()).show();
}
};
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), callback);
viewBinding.donationLinkPatreon.setOnClickListener(v12 -> {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(getResources().getString(R.string.supportLinkPatreon)));
startActivity(intent);
});
viewBinding.translateLink.setOnClickListener(v13 -> {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(getResources().getString(R.string.crowdInLink)));
startActivity(intent);
});
viewBinding.appWebsite.setOnClickListener(v14 -> {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(getResources().getString(R.string.appWebsiteLink)));
startActivity(intent);
});
if(AppUtil.isPro(requireContext())) {
viewBinding.supportHeader.setVisibility(View.GONE);
viewBinding.dividerSupport.setVisibility(View.GONE);
viewBinding.donationLinkPatreon.setVisibility(View.GONE);
}
return viewBinding.getRoot();
}
}

View File

@ -13,7 +13,7 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import org.gitnex.tea4j.models.Issues; import org.gitnex.tea4j.models.Issues;
import org.mian.gitnex.adapters.SearchIssuesAdapter; import org.mian.gitnex.adapters.ExploreIssuesAdapter;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.FragmentSearchIssuesBinding; import org.mian.gitnex.databinding.FragmentSearchIssuesBinding;
import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.AppUtil;
@ -33,7 +33,7 @@ import retrofit2.Response;
public class ExploreIssuesFragment extends Fragment { public class ExploreIssuesFragment extends Fragment {
private FragmentSearchIssuesBinding viewBinding; private FragmentSearchIssuesBinding viewBinding;
private SearchIssuesAdapter adapter; private ExploreIssuesAdapter adapter;
private List<Issues> dataList; private List<Issues> dataList;
Context ctx; Context ctx;
@ -48,7 +48,7 @@ public class ExploreIssuesFragment extends Fragment {
ctx = getContext(); ctx = getContext();
dataList = new ArrayList<>(); dataList = new ArrayList<>();
adapter = new SearchIssuesAdapter(dataList, ctx); adapter = new ExploreIssuesAdapter(dataList, ctx);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(ctx); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(ctx);

View File

@ -15,7 +15,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import org.gitnex.tea4j.models.Organization; import org.gitnex.tea4j.models.Organization;
import org.mian.gitnex.R; import org.mian.gitnex.R;
import org.mian.gitnex.adapters.PublicOrganizationsAdapter; import org.mian.gitnex.adapters.ExplorePublicOrganizationsAdapter;
import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.databinding.FragmentOrganizationsBinding; import org.mian.gitnex.databinding.FragmentOrganizationsBinding;
import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Authorization;
@ -37,7 +37,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
private FragmentOrganizationsBinding fragmentPublicOrgBinding; private FragmentOrganizationsBinding fragmentPublicOrgBinding;
private List<Organization> organizationsList; private List<Organization> organizationsList;
private PublicOrganizationsAdapter adapter; private ExplorePublicOrganizationsAdapter adapter;
private Context context; private Context context;
private int pageSize; private int pageSize;
private final String TAG = Constants.publicOrganizations; private final String TAG = Constants.publicOrganizations;
@ -68,7 +68,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment {
adapter.notifyDataChanged(); adapter.notifyDataChanged();
}, 200)); }, 200));
adapter = new PublicOrganizationsAdapter(getContext(), organizationsList); adapter = new ExplorePublicOrganizationsAdapter(getContext(), organizationsList);
adapter.setLoadMoreListener(() -> fragmentPublicOrgBinding.recyclerView.post(() -> { adapter.setLoadMoreListener(() -> fragmentPublicOrgBinding.recyclerView.post(() -> {
if(organizationsList.size() == resultLimit || pageSize == resultLimit) { if(organizationsList.size() == resultLimit || pageSize == resultLimit) {
int page = (organizationsList.size() + resultLimit) / resultLimit; int page = (organizationsList.size() + resultLimit) / resultLimit;

View File

@ -261,54 +261,21 @@ public class ExploreRepositoriesFragment extends Fragment {
dialogFilterOptions.setContentView(view); dialogFilterOptions.setContentView(view);
filterBinding.includeTopic.setOnClickListener(includeTopic -> { filterBinding.includeTopic.setOnClickListener(includeTopic -> {
tinyDb.putBoolean("exploreRepoIncludeTopic", filterBinding.includeTopic.isChecked());
if(filterBinding.includeTopic.isChecked()) {
tinyDb.putBoolean("exploreRepoIncludeTopic", true);
}
else {
tinyDb.putBoolean("exploreRepoIncludeTopic", false);
}
}); });
filterBinding.includeDesc.setOnClickListener(includeDesc -> { filterBinding.includeDesc.setOnClickListener(includeDesc -> {
tinyDb.putBoolean("exploreRepoIncludeDescription", filterBinding.includeDesc.isChecked());
if(filterBinding.includeDesc.isChecked()) {
tinyDb.putBoolean("exploreRepoIncludeDescription", true);
}
else {
tinyDb.putBoolean("exploreRepoIncludeDescription", false);
}
}); });
filterBinding.includeTemplate.setOnClickListener(includeTemplate -> { filterBinding.includeTemplate.setOnClickListener(includeTemplate -> {
tinyDb.putBoolean("exploreRepoIncludeTemplate", filterBinding.includeTemplate.isChecked());
if(filterBinding.includeTemplate.isChecked()) {
tinyDb.putBoolean("exploreRepoIncludeTemplate", true);
}
else {
tinyDb.putBoolean("exploreRepoIncludeTemplate", false);
}
}); });
filterBinding.onlyArchived.setOnClickListener(onlyArchived -> { filterBinding.onlyArchived.setOnClickListener(onlyArchived -> {
tinyDb.putBoolean("exploreRepoOnlyArchived", filterBinding.onlyArchived.isChecked());
if(filterBinding.onlyArchived.isChecked()) {
tinyDb.putBoolean("exploreRepoOnlyArchived", true);
}
else {
tinyDb.putBoolean("exploreRepoOnlyArchived", false);
}
}); });
filterBinding.includeTopic.setChecked(tinyDb.getBoolean("exploreRepoIncludeTopic")); filterBinding.includeTopic.setChecked(tinyDb.getBoolean("exploreRepoIncludeTopic"));
filterBinding.includeDesc.setChecked(tinyDb.getBoolean("exploreRepoIncludeDescription")); filterBinding.includeDesc.setChecked(tinyDb.getBoolean("exploreRepoIncludeDescription"));
filterBinding.includeTemplate.setChecked(tinyDb.getBoolean("exploreRepoIncludeTemplate")); filterBinding.includeTemplate.setChecked(tinyDb.getBoolean("exploreRepoIncludeTemplate"));

View File

@ -42,6 +42,7 @@ public class RepoInfoFragment extends Fragment {
private LinearLayout pageContent; private LinearLayout pageContent;
private static final String repoNameF = "param2"; private static final String repoNameF = "param2";
private static final String repoOwnerF = "param1"; private static final String repoOwnerF = "param1";
private Locale locale;
private FragmentRepoInfoBinding binding; private FragmentRepoInfoBinding binding;
@ -74,17 +75,16 @@ public class RepoInfoFragment extends Fragment {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
binding = FragmentRepoInfoBinding.inflate(inflater, container, false); binding = FragmentRepoInfoBinding.inflate(inflater, container, false);
TinyDB tinyDb = TinyDB.getInstance(getContext()); TinyDB tinyDb = TinyDB.getInstance(getContext());
ctx = getContext(); ctx = getContext();
locale = getResources().getConfiguration().locale;
pageContent = binding.repoInfoLayout; pageContent = binding.repoInfoLayout;
pageContent.setVisibility(View.GONE); pageContent.setVisibility(View.GONE);
binding.repoMetaFrame.setVisibility(View.GONE); binding.repoMetaFrame.setVisibility(View.GONE);
getRepoInfo(Authorization.get(getContext()), repoOwner, repoName, getResources().getConfiguration().locale, tinyDb.getString("dateFormat")); getRepoInfo(Authorization.get(getContext()), repoOwner, repoName, locale, tinyDb.getString("dateFormat"));
getFileContents(Authorization.get(getContext()), repoOwner, repoName, getResources().getString(R.string.defaultFilename)); getFileContents(Authorization.get(getContext()), repoOwner, repoName, getResources().getString(R.string.defaultFilename));
if(isExpandViewVisible()) { if(isExpandViewVisible()) {
@ -173,7 +173,7 @@ public class RepoInfoFragment extends Fragment {
return binding.repoMetaFrame.getVisibility() == View.VISIBLE; return binding.repoMetaFrame.getVisibility() == View.VISIBLE;
} }
private void getRepoInfo(String token, final String owner, String repo, final Locale locale, final String timeFormat) { private void getRepoInfo(String token, final String owner, String repo, Locale locale, final String timeFormat) {
final TinyDB tinyDb = TinyDB.getInstance(getContext()); final TinyDB tinyDb = TinyDB.getInstance(getContext());

View File

@ -1,8 +1,11 @@
package org.mian.gitnex.fragments; package org.mian.gitnex.fragments;
import android.app.Dialog;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -20,7 +23,9 @@ import org.mian.gitnex.activities.SettingsNotificationsActivity;
import org.mian.gitnex.activities.SettingsReportsActivity; import org.mian.gitnex.activities.SettingsReportsActivity;
import org.mian.gitnex.activities.SettingsSecurityActivity; import org.mian.gitnex.activities.SettingsSecurityActivity;
import org.mian.gitnex.activities.SettingsTranslationActivity; import org.mian.gitnex.activities.SettingsTranslationActivity;
import org.mian.gitnex.databinding.CustomAboutDialogBinding;
import org.mian.gitnex.databinding.FragmentSettingsBinding; import org.mian.gitnex.databinding.FragmentSettingsBinding;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.TinyDB;
import org.mian.gitnex.helpers.Version; import org.mian.gitnex.helpers.Version;
@ -32,6 +37,7 @@ public class SettingsFragment extends Fragment {
private Context ctx; private Context ctx;
private TinyDB tinyDB; private TinyDB tinyDB;
private Dialog aboutAppDialog;
@Nullable @Nullable
@Override @Override
@ -41,6 +47,7 @@ public class SettingsFragment extends Fragment {
ctx = getContext(); ctx = getContext();
tinyDB = TinyDB.getInstance(ctx); tinyDB = TinyDB.getInstance(ctx);
aboutAppDialog = new Dialog(ctx);
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navSettings)); ((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navSettings));
@ -63,37 +70,78 @@ public class SettingsFragment extends Fragment {
fragmentSettingsBinding.reportsFrame.setOnClickListener(v1 -> startActivity(new Intent(ctx, SettingsReportsActivity.class))); fragmentSettingsBinding.reportsFrame.setOnClickListener(v1 -> startActivity(new Intent(ctx, SettingsReportsActivity.class)));
fragmentSettingsBinding.rateAppFrame.setOnClickListener(aboutApp -> rateThisApp()); fragmentSettingsBinding.rateAppFrame.setOnClickListener(rateApp -> rateThisApp());
fragmentSettingsBinding.aboutAppFrame.setOnClickListener(aboutApp -> requireActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit()); fragmentSettingsBinding.aboutAppFrame.setOnClickListener(aboutApp -> showAboutAppDialog());
return fragmentSettingsBinding.getRoot(); return fragmentSettingsBinding.getRoot();
}
public void showAboutAppDialog() {
if (aboutAppDialog.getWindow() != null) {
aboutAppDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
CustomAboutDialogBinding aboutAppDialogBinding = CustomAboutDialogBinding.inflate(LayoutInflater.from(ctx));
View view = aboutAppDialogBinding.getRoot();
aboutAppDialog.setContentView(view);
aboutAppDialogBinding.appVersionBuild.setText(getString(R.string.appVersionBuild, AppUtil.getAppVersion(ctx), AppUtil.getAppBuildNo(ctx)));
aboutAppDialogBinding.userServerVersion.setText(tinyDB.getString("giteaVersion"));
aboutAppDialogBinding.donationLinkPatreon.setOnClickListener(v12 -> {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(getResources().getString(R.string.supportLinkPatreon)));
startActivity(intent);
});
aboutAppDialogBinding.translateLink.setOnClickListener(v13 -> {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(getResources().getString(R.string.crowdInLink)));
startActivity(intent);
});
aboutAppDialogBinding.appWebsite.setOnClickListener(v14 -> {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(getResources().getString(R.string.appWebsiteLink)));
startActivity(intent);
});
if(AppUtil.isPro(requireContext())) {
aboutAppDialogBinding.supportHeader.setVisibility(View.GONE);
aboutAppDialogBinding.dividerSupport.setVisibility(View.GONE);
aboutAppDialogBinding.donationLinkPatreon.setVisibility(View.GONE);
}
aboutAppDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
aboutAppDialog.show();
} }
public void rateThisApp() { public void rateThisApp() {
try { try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + requireActivity().getPackageName()))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + requireActivity().getPackageName())));
} }
catch(ActivityNotFoundException e) { catch(ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + requireActivity().getPackageName()))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + requireActivity().getPackageName())));
} }
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if(tinyDB.getBoolean("refreshParent")) { if(tinyDB.getBoolean("refreshParent")) {
requireActivity().recreate(); requireActivity().recreate();
requireActivity().overridePendingTransition(0, 0); requireActivity().overridePendingTransition(0, 0);
tinyDB.putBoolean("refreshParent", false); tinyDB.putBoolean("refreshParent", false);
} }
} }
} }

View File

@ -424,16 +424,16 @@ public class MemorizingTrustManager implements X509TrustManager {
} }
} }
private static void certDetails(StringBuilder stringBuilder, X509Certificate c) { private void certDetails(StringBuilder stringBuilder, X509Certificate c) {
SimpleDateFormat validityDateFormater = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()); SimpleDateFormat validityDateFormatter = new SimpleDateFormat("yyyy-MM-dd", context.getResources().getConfiguration().locale);
stringBuilder.append("\n") stringBuilder.append("\n")
.append(c.getSubjectDN().toString()) .append(c.getSubjectDN().toString())
.append("\n") .append("\n")
.append(validityDateFormater.format(c.getNotBefore())) .append(validityDateFormatter.format(c.getNotBefore()))
.append(" - ") .append(" - ")
.append(validityDateFormater.format(c.getNotAfter())) .append(validityDateFormatter.format(c.getNotAfter()))
.append("\nSHA-256: ") .append("\nSHA-256: ")
.append(certHash(c, "SHA-256")) .append(certHash(c, "SHA-256"))
.append("\nSHA-1: ") .append("\nSHA-1: ")

View File

@ -42,39 +42,23 @@ public class FilesViewModel extends ViewModel {
.getFiles(token, owner, repo, ref); .getFiles(token, owner, repo, ref);
call.enqueue(new Callback<List<Files>>() { call.enqueue(new Callback<List<Files>>() {
@Override @Override
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) { public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
if (response.code() == 200) { if(response.isSuccessful() && response.body() != null && !response.body().isEmpty()) {
assert response.body() != null;
if(response.body().size() > 0) {
Collections.sort(response.body(), (byType1, byType2) -> byType1.getType().compareTo(byType2.getType())); Collections.sort(response.body(), (byType1, byType2) -> byType1.getType().compareTo(byType2.getType()));
filesList.postValue(response.body()); filesList.postValue(response.body());
} }
else { else {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
noDataFiles.setVisibility(View.VISIBLE); noDataFiles.setVisibility(View.VISIBLE);
} }
} }
else {
progressBar.setVisibility(View.GONE);
noDataFiles.setVisibility(View.VISIBLE);
}
}
@Override @Override
public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) {
Toasty.error(ctx, ctx.getString(R.string.errorOnLogin)); Toasty.error(ctx, ctx.getString(R.string.errorOnLogin));
} }
}); });
} }
@ -93,27 +77,14 @@ public class FilesViewModel extends ViewModel {
.getDirFiles(token, owner, repo, filesDir, ref); .getDirFiles(token, owner, repo, filesDir, ref);
call.enqueue(new Callback<List<Files>>() { call.enqueue(new Callback<List<Files>>() {
@Override @Override
public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) { public void onResponse(@NonNull Call<List<Files>> call, @NonNull Response<List<Files>> response) {
if (response.code() == 200) { if(response.isSuccessful() && response.body() != null && !response.body().isEmpty()) {
assert response.body() != null;
if(response.body().size() > 0) {
Collections.sort(response.body(), (byType1, byType2) -> byType1.getType().compareTo(byType2.getType())); Collections.sort(response.body(), (byType1, byType2) -> byType1.getType().compareTo(byType2.getType()));
filesList2.postValue(response.body()); filesList2.postValue(response.body());
} }
else { else {
progressBar.setVisibility(View.GONE);
noDataFiles.setVisibility(View.VISIBLE);
}
}
else {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
noDataFiles.setVisibility(View.VISIBLE); noDataFiles.setVisibility(View.VISIBLE);
} }
@ -121,10 +92,8 @@ public class FilesViewModel extends ViewModel {
@Override @Override
public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<List<Files>> call, @NonNull Throwable t) {
Toasty.error(ctx, ctx.getString(R.string.errorOnLogin)); Toasty.error(ctx, ctx.getString(R.string.errorOnLogin));
} }
}); });
} }

View File

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_custom_dialog"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/appName"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor"
android:layout_gravity="center_horizontal"
android:textSize="24sp"
android:layout_marginTop="5dp" />
<TextView
android:id="@+id/appVersionBuild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textIsSelectable="true"
android:textSize="14sp"
android:text="@string/appVersionBuild"
android:layout_marginTop="5dp"
android:textColor="?attr/primaryTextColor" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="15dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- user server version -->
<TextView
android:id="@+id/userServerVersionHeader"
android:text="@string/commitPage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerUserServerVersion"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/userServerVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:textSize="14sp"
android:textColor="?attr/primaryTextColor" />
<!-- user server version -->
<!-- support -->
<TextView
android:id="@+id/supportHeader"
android:text="@string/supportText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerSupport"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/donationLinkPatreon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/supportTextPatreon"
android:textColor="@color/lightBlue"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:textSize="14sp"
android:autoLink="web"
android:textColorLink="@color/lightBlue" />
<!-- support -->
<!-- translate -->
<TextView
android:id="@+id/translateHeader"
android:text="@string/translateText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerTranslate"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/translateLink"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:gravity="start"
android:text="@string/translateWithCrowdin"
android:textColor="@color/lightBlue"
android:textColorLink="@color/lightBlue"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:textSize="14sp"
android:visibility="visible" />
<!-- translate -->
</LinearLayout>
<Button
android:id="@+id/appWebsite"
android:layout_width="140dp"
android:layout_height="60dp"
android:layout_marginTop="24dp"
android:layout_marginBottom="12dp"
android:layout_gravity="center_horizontal"
android:text="@string/websiteText"
android:textColor="@color/btnTextColor"
android:textSize="16sp" />
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/primaryBackgroundColor"
app:cardCornerRadius="48dp"
app:cardElevation="2dp"
app:contentPadding="4dp"
android:layout_gravity="center_horizontal"
tools:visibility="visible">
<ImageView
android:id="@+id/appLogo"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@mipmap/app_logo"
android:contentDescription="@string/appName" />
</androidx.cardview.widget.CardView>
</FrameLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -1,264 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:theme="@style/Widget.AppCompat.SearchView">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryBackgroundColor">
<ImageView
android:id="@+id/close"
android:layout_width="@dimen/close_button_size"
android:layout_height="@dimen/close_button_size"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:contentDescription="@string/close"
android:gravity="center_vertical"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:focusable="true"
android:clickable="true"
android:src="@drawable/ic_close" />
<TextView
android:id="@+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:text="@string/pageTitleAbout"
android:textColor="?attr/primaryTextColor"
android:textSize="20sp" />
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/primaryBackgroundColor">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:gravity="start"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="50dp"
android:id="@+id/aboutFrame">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:baselineAligned="false"
android:contentDescription="@string/appName"
android:src="@mipmap/app_logo" />
<TextView
android:id="@+id/appName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/appName"
android:textIsSelectable="true"
android:layout_marginTop="5dp"
android:textSize="24sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor"
android:layout_gravity="center_horizontal" />
<!-- version -->
<TextView
android:id="@+id/appVersionHeader"
android:text="@string/appVersion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerVersion"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/appVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:textSize="14sp"
android:textColor="?attr/primaryTextColor" />
<!-- version -->
<!-- build -->
<TextView
android:id="@+id/appBuildHeader"
android:text="@string/appBuild"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerBuild"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/appBuild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:textSize="14sp"
android:textColor="?attr/primaryTextColor" />
<!-- build -->
<!-- user server version -->
<TextView
android:id="@+id/userServerVersionHeader"
android:text="@string/commitPage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerUserServerVersion"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/userServerVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textIsSelectable="true"
android:textSize="14sp"
android:textColor="?attr/primaryTextColor" />
<!-- user server version -->
<!-- support -->
<TextView
android:id="@+id/supportHeader"
android:text="@string/supportText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerSupport"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/donationLinkPatreon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/supportTextPatreon"
android:textColor="@color/lightBlue"
android:textSize="14sp"
android:autoLink="web"
android:textColorLink="@color/lightBlue" />
<!-- support -->
<!-- translate -->
<TextView
android:id="@+id/translateHeader"
android:text="@string/translateText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerTranslate"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/translateLink"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:gravity="start"
android:text="@string/translateWithCrowdin"
android:textColor="@color/lightBlue"
android:textColorLink="@color/lightBlue"
android:textSize="14sp"
android:visibility="visible" />
<!-- translate -->
<!-- website -->
<TextView
android:id="@+id/websiteHeader"
android:text="@string/websiteText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="?attr/primaryTextColor" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="@+id/dividerWebsite"
android:background="?attr/dividerColor"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/appWebsite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/appWebsiteLink"
android:textColor="@color/lightBlue"
android:textSize="14sp"
android:autoLink="web"
android:layout_marginBottom="24dp"
android:textColorLink="@color/lightBlue" />
<!-- website -->
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>

View File

@ -19,5 +19,4 @@
<item>tr</item> <item>tr</item>
<item>uk</item> <item>uk</item>
</string-array> </string-array>
</resources> </resources>

View File

@ -7,8 +7,7 @@
<string name="appWebsiteLink" translatable="false">https://gitnex.com/</string> <string name="appWebsiteLink" translatable="false">https://gitnex.com/</string>
<string name="commitPage" translatable="false">Your Gitea Version</string> <string name="commitPage" translatable="false">Your Gitea Version</string>
<string name="supportLinkPatreon" translatable="false">https://www.patreon.com/mmarif</string> <string name="supportLinkPatreon" translatable="false">https://www.patreon.com/mmarif</string>
<string name="appVersion" translatable="false">Version</string> <string name="appVersionBuild" translatable="false">%s / %d</string>
<string name="appBuild" translatable="false">Build</string>
<string name="appDesc" translatable="false">GitNex is a free, open-source Android client for Git repository management tool Gitea. GitNex is Licensed under GPLv3.\n\nThanks to all the contributors and donators for your generous work and donations.</string> <string name="appDesc" translatable="false">GitNex is a free, open-source Android client for Git repository management tool Gitea. GitNex is Licensed under GPLv3.\n\nThanks to all the contributors and donators for your generous work and donations.</string>
<string name="crowdInLink" translatable="false">https://crowdin.com/project/gitnex</string> <string name="crowdInLink" translatable="false">https://crowdin.com/project/gitnex</string>
<string name="crashReportEmailSubject" translatable="false">[GitNex] - Crash Report #%1$d</string> <string name="crashReportEmailSubject" translatable="false">[GitNex] - Crash Report #%1$d</string>