Improving milestones. (#525)

Removing unused strings.

Adding a little bit more space between title and progress bar.

Swapping icons.

Merge remote-tracking branch 'remotes/main/master' into improve-milestones

# Conflicts:
#	app/src/main/res/layout/list_milestones.xml

Minor improvements.

Merge branch 'improve-layouts' of https://gitea.com/opyale/GitNex into improve-milestones

Merge branch 'improve-layouts' of https://gitea.com/gitnex/GitNex into improve-milestones

Moving items.

Merge branch 'master' into improve-layouts

Merge branch 'master' into improve-layouts

Translation and additional formatting.

Enhancing editorconfig

Formatting and removing unused imports.

Removing milestone state.

Improving milestones.

branches and milestones layout update. Fix milestone infinite pagination loop for lower versions

layout updates for issues, pr. Fix pr nullable objects for lower versions

improve files layout

improve org info and list orgs

improve teams list layout by org

Fix repo layouts

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/525
Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
opyale 2020-06-01 16:43:58 +00:00 committed by M M Arif
parent 4f0091f151
commit 546346ff48
6 changed files with 384 additions and 373 deletions

View File

@ -4,6 +4,7 @@ end_of_line = lf
indent_size = 4 indent_size = 4
indent_style = space indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 150 max_line_length = 150
[*.java] [*.java]

View File

@ -2,7 +2,6 @@ package org.mian.gitnex.adapters;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.text.Spanned; import android.text.Spanned;
@ -15,7 +14,6 @@ import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.amulyakhare.textdrawable.TextDrawable;
import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.vdurmont.emoji.EmojiParser; import com.vdurmont.emoji.EmojiParser;
import org.mian.gitnex.R; import org.mian.gitnex.R;
@ -112,7 +110,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private TextView msOpenIssues; private TextView msOpenIssues;
private TextView msClosedIssues; private TextView msClosedIssues;
private TextView msDueDate; private TextView msDueDate;
private ImageView msStatus;
private ProgressBar msProgress; private ProgressBar msProgress;
private TextView milestoneStatus; private TextView milestoneStatus;
@ -122,7 +119,6 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
milestoneId = itemView.findViewById(R.id.milestoneId); milestoneId = itemView.findViewById(R.id.milestoneId);
msTitle = itemView.findViewById(R.id.milestoneTitle); msTitle = itemView.findViewById(R.id.milestoneTitle);
msStatus = itemView.findViewById(R.id.milestoneState);
msDescription = itemView.findViewById(R.id.milestoneDescription); msDescription = itemView.findViewById(R.id.milestoneDescription);
msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen); msOpenIssues = itemView.findViewById(R.id.milestoneIssuesOpen);
msClosedIssues = itemView.findViewById(R.id.milestoneIssuesClosed); msClosedIssues = itemView.findViewById(R.id.milestoneIssuesClosed);
@ -188,10 +184,9 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
milestoneId.setText(String.valueOf(dataModel.getId())); milestoneId.setText(String.valueOf(dataModel.getId()));
milestoneStatus.setText(dataModel.getState()); milestoneStatus.setText(dataModel.getState());
final Markwon markwon = Markwon.builder(Objects.requireNonNull(context)) Markwon markwon = Markwon.builder(Objects.requireNonNull(context)).usePlugin(CorePlugin.create()).usePlugin(ImagesPlugin.create(plugin -> {
.usePlugin(CorePlugin.create())
.usePlugin(ImagesPlugin.create(plugin -> {
plugin.addSchemeHandler(new SchemeHandler() { plugin.addSchemeHandler(new SchemeHandler() {
@NonNull @NonNull
@Override @Override
public ImageItem handle(@NonNull String raw, @NonNull Uri uri) { public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
@ -213,13 +208,16 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
return Collections.singleton("drawable"); return Collections.singleton("drawable");
} }
}); });
plugin.placeholderProvider(drawable -> null); plugin.placeholderProvider(drawable -> null);
plugin.addMediaDecoder(GifMediaDecoder.create(false)); plugin.addMediaDecoder(GifMediaDecoder.create(false));
plugin.addMediaDecoder(SvgMediaDecoder.create(context.getResources())); plugin.addMediaDecoder(SvgMediaDecoder.create(context.getResources()));
plugin.addMediaDecoder(SvgMediaDecoder.create()); plugin.addMediaDecoder(SvgMediaDecoder.create());
plugin.defaultMediaDecoder(DefaultMediaDecoder.create(context.getResources())); plugin.defaultMediaDecoder(DefaultMediaDecoder.create(context.getResources()));
plugin.defaultMediaDecoder(DefaultMediaDecoder.create()); plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
})) }))
.usePlugin(new AbstractMarkwonPlugin() { .usePlugin(new AbstractMarkwonPlugin() {
@Override @Override
public void configureTheme(@NonNull MarkwonTheme.Builder builder) { public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
@ -239,85 +237,58 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
Spanned msTitle_ = markwon.toMarkdown(dataModel.getTitle()); Spanned msTitle_ = markwon.toMarkdown(dataModel.getTitle());
markwon.setParsedMarkdown(msTitle, msTitle_); markwon.setParsedMarkdown(msTitle, msTitle_);
if(dataModel.getState().equals("open")) { if(!dataModel.getDescription().equals("")) {
@SuppressLint("ResourceType") int color = Color.parseColor(context.getResources().getString(R.color.releaseStable)); CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(dataModel.getDescription()));
TextDrawable drawable = TextDrawable.builder()
.beginConfig()
//.useFont(Typeface.DEFAULT)
.textColor(context.getResources().getColor(R.color.white))
.fontSize(30)
.toUpperCase()
.width(120)
.height(60)
.endConfig()
.buildRoundRect("open", color, 8);
msStatus.setImageDrawable(drawable);
}
else if(dataModel.getState().equals("closed")) {
@SuppressLint("ResourceType") int color = Color.parseColor(context.getResources().getString(R.color.colorRed));
TextDrawable drawable = TextDrawable.builder()
.beginConfig()
//.useFont(Typeface.DEFAULT)
.textColor(context.getResources().getColor(R.color.white))
.fontSize(30)
.toUpperCase()
.width(140)
.height(60)
.endConfig()
.buildRoundRect("closed", color, 8);
msStatus.setImageDrawable(drawable);
}
if (!dataModel.getDescription().equals("")) {
final CharSequence bodyWithMD = markwon.toMarkdown(EmojiParser.parseToUnicode(dataModel.getDescription()));
msDescription.setText(bodyWithMD); msDescription.setText(bodyWithMD);
} }
else { else {
msDescription.setText("");
msDescription.setText(context.getString(R.string.milestoneNoDescription));
} }
msOpenIssues.setText(String.valueOf(dataModel.getOpen_issues())); msOpenIssues.setText(context.getString(R.string.milestoneIssueStatusOpen, dataModel.getOpen_issues()));
msOpenIssues.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneOpenIssues, dataModel.getOpen_issues()), context)); msClosedIssues.setText(context.getString(R.string.milestoneIssueStatusClosed, dataModel.getClosed_issues()));
msClosedIssues.setText(String.valueOf(dataModel.getClosed_issues())); if((dataModel.getOpen_issues() + dataModel.getClosed_issues()) > 0) {
msClosedIssues.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneClosedIssues, dataModel.getClosed_issues()), context));
if ((dataModel.getOpen_issues() + dataModel.getClosed_issues()) > 0) { if(dataModel.getOpen_issues() == 0) {
if (dataModel.getOpen_issues() == 0) {
msProgress.setProgress(100); msProgress.setProgress(100);
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context)); msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 100), context));
} }
else { else {
int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues()); int msCompletion = 100 * dataModel.getClosed_issues() / (dataModel.getOpen_issues() + dataModel.getClosed_issues());
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context)); msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, msCompletion), context));
msProgress.setProgress(msCompletion); msProgress.setProgress(msCompletion);
} }
} }
else { else {
msProgress.setProgress(0); msProgress.setProgress(0);
msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context)); msProgress.setOnClickListener(new ClickListener(context.getResources().getString(R.string.milestoneCompletion, 0), context));
} }
if(dataModel.getDue_on() != null) { if(dataModel.getDue_on() != null) {
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", new Locale(locale));
Date date = null; Date date = null;
try { try {
date = formatter.parse(dataModel.getDue_on()); date = formatter.parse(dataModel.getDue_on());
} }
catch (ParseException e) { catch(ParseException e) {
Log.e(TAG, e.toString()); Log.e(TAG, e.toString());
} }
assert date != null; assert date != null;
String dueDate = formatter.format(date); String dueDate = formatter.format(date);
@ -329,16 +300,19 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context)); msDueDate.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToast(dataModel.getDue_on()), context));
} }
else if (timeFormat.equals("normal1")) { else if(timeFormat.equals("normal1")) {
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale)); SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", new Locale(locale));
Date date1 = null; Date date1 = null;
try { try {
date1 = formatter.parse(dataModel.getDue_on()); date1 = formatter.parse(dataModel.getDue_on());
} }
catch (ParseException e) { catch(ParseException e) {
Log.e(TAG, e.toString()); Log.e(TAG, e.toString());
} }
assert date1 != null; assert date1 != null;
String dueDate = formatter.format(date1); String dueDate = formatter.format(date1);
msDueDate.setText(dueDate); msDueDate.setText(dueDate);
@ -347,7 +321,8 @@ public class MilestonesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} }
else { else {
msDueDate.setText("");
msDueDate.setText(context.getString(R.string.milestoneNoDueDate));
} }
} }

View File

@ -9,8 +9,8 @@
android:right="1dp" android:right="1dp"
android:left="1dp"> android:left="1dp">
<shape> <shape>
<corners android:radius="15dp"/> <corners android:radius="10dp"/>
<solid android:color="@color/divider"/> <solid android:color="?attr/inputBackgroundColor"/>
</shape> </shape>
</item> </item>
@ -23,7 +23,7 @@
<scale android:scaleWidth="100%"> <scale android:scaleWidth="100%">
<shape> <shape>
<corners android:radius="15dp" /> <corners android:radius="10dp" />
</shape> </shape>
</scale> </scale>
</item> </item>

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/milestoneFrame" android:id="@+id/milestoneFrame"
@ -14,10 +16,11 @@
android:id="@+id/milestoneId" /> android:id="@+id/milestoneId" />
<TextView <TextView
android:id="@+id/milestoneStatus"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
android:id="@+id/milestoneStatus" /> tools:visibility="visible" />
<LinearLayout <LinearLayout
android:id="@+id/mainFrame" android:id="@+id/mainFrame"
@ -31,115 +34,145 @@
android:id="@+id/frameTitle" android:id="@+id/frameTitle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
android:id="@+id/milestoneTitle" android:id="@+id/milestoneTitle"
android:layout_width="0dp" android:layout_width="wrap_content"
android:textIsSelectable="true"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight=".80" android:layout_weight="0"
android:layout_marginBottom="5dp"
android:textColor="?attr/primaryTextColor" android:textColor="?attr/primaryTextColor"
android:textIsSelectable="true"
android:textSize="18sp" /> android:textSize="18sp" />
<ImageView <ProgressBar
android:id="@+id/milestoneState" android:id="@+id/milestoneProgress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="10dp"
android:layout_weight=".15" android:layout_marginLeft="15dp"
android:layout_gravity="end" android:layout_marginRight="10dp"
android:gravity="end" android:layout_weight="1"
android:scaleType="fitEnd" android:indeterminate="false"
android:contentDescription="@string/pageTitleCreateMilestone" android:progress="50"
android:layout_marginBottom="5dp" /> android:progressDrawable="@drawable/progress_bar"
android:progressTint="@color/btnBackground" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="15dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_calendar" />
<TextView
android:id="@+id/milestoneDueDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dueDate"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="15dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_issue_open" />
<TextView
android:id="@+id/milestoneIssuesOpen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repoStars"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:contentDescription="@string/generalImgContentText"
app:srcCompat="@drawable/ic_issue_closed" />
<TextView
android:id="@+id/milestoneIssuesClosed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/repoWatchers"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/milestoneDateMenuFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/dueDateFrame"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_weight=".90"
android:orientation="horizontal">
<TextView <TextView
android:id="@+id/milestoneDescription" android:id="@+id/milestoneDescription"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/repoDescription" android:text="@string/repoDescription"
android:textColor="?attr/primaryTextColor"
android:textIsSelectable="true" android:textIsSelectable="true"
android:textColor="?attr/primaryTextColor" android:textSize="14sp"
android:textSize="14sp" /> android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/milestoneIssuesClosed"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:text="@string/repoWatchers"
android:gravity="start"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
<ProgressBar
android:id="@+id/milestoneProgress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="80"
android:progress="50"
android:layout_marginTop="2dp"
android:progressDrawable="@drawable/progress_bar"
android:progressTint="@color/colorLightGreen" />
<TextView
android:id="@+id/milestoneIssuesOpen"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:text="@string/repoStars"
android:gravity="end"
android:textColor="?attr/primaryTextColor"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/milestoneDateMenuFrame"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_weight=".90"
android:layout_height="wrap_content"
android:id="@+id/dueDateFrame"
android:orientation="horizontal"
android:layout_marginTop="3dp">
<TextView
android:id="@+id/milestoneDueDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dueDate"
android:gravity="start"
android:textColor="?attr/primaryTextColor"
android:textSize="12sp" />
</RelativeLayout> </RelativeLayout>
<ImageView <ImageView
android:id="@+id/milestonesMenu" android:id="@+id/milestonesMenu"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight=".10"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end" android:layout_gravity="end|bottom"
android:layout_weight=".10"
android:contentDescription="@string/menuContentDesc"
android:scaleType="fitEnd" android:scaleType="fitEnd"
android:src="@drawable/ic_dotted_menu_horizontal" android:src="@drawable/ic_dotted_menu_horizontal" />
android:contentDescription="@string/menuContentDesc" />
</LinearLayout> </LinearLayout>

View File

@ -18,7 +18,7 @@
<color name="divider">#1d1d1d</color> <color name="divider">#1d1d1d</color>
<color name="releasePre">#eb7121</color> <color name="releasePre">#eb7121</color>
<color name="releaseStable">#219214</color> <color name="releaseStable">#219214</color>
<color name="colorRed">#eb3718</color> <color name="colorRed">#CC361C</color>
<color name="colorLightGreen">#49da39</color> <color name="colorLightGreen">#49da39</color>
<color name="colorDarkGreen">#009486</color> <color name="colorDarkGreen">#009486</color>
<color name="darkRed">#e74c3c</color> <color name="darkRed">#e74c3c</color>

View File

@ -232,8 +232,10 @@
<string name="milestoneCreated">Milestone created successfully</string> <string name="milestoneCreated">Milestone created successfully</string>
<string name="milestoneCreatedError">Something went wrong, please try again</string> <string name="milestoneCreatedError">Something went wrong, please try again</string>
<string name="milestoneDateEmpty">Please choose due date</string> <string name="milestoneDateEmpty">Please choose due date</string>
<string name="milestoneOpenIssues">Open issues : %1$d</string> <string name="milestoneNoDueDate">No due date</string>
<string name="milestoneClosedIssues">Closed issues : %1$d</string> <string name="milestoneNoDescription">No description</string>
<string name="milestoneIssueStatusOpen">%1$d Open</string>
<string name="milestoneIssueStatusClosed">%1$d Closed</string>
<string name="newIssueSelectAssigneesListTitle">Select Assignees</string> <string name="newIssueSelectAssigneesListTitle">Select Assignees</string>
<string name="newIssueSelectLabelsListTitle">Select Labels</string> <string name="newIssueSelectLabelsListTitle">Select Labels</string>