Improve notifications list (#1009)
* show icons for repos and commit * hide repo if type is repo * improve some designs * allow click on repo notifications Co-authored-by: qwerty287 <ndev@web.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1009 Reviewed-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
parent
dec9c1e224
commit
95a5940f04
|
@ -12,6 +12,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import androidx.core.text.HtmlCompat;
|
import androidx.core.text.HtmlCompat;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.gitnex.tea4j.models.NotificationThread;
|
import org.gitnex.tea4j.models.NotificationThread;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.database.api.BaseApi;
|
import org.mian.gitnex.database.api.BaseApi;
|
||||||
|
@ -90,8 +91,10 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
private final TextView repository;
|
private final TextView repository;
|
||||||
private final ImageView typePr;
|
private final ImageView typePr;
|
||||||
private final ImageView typeIssue;
|
private final ImageView typeIssue;
|
||||||
|
private final ImageView typeRepo;
|
||||||
|
private final ImageView typeCommit;
|
||||||
private final ImageView typeUnknown;
|
private final ImageView typeUnknown;
|
||||||
private final ImageView pinned;
|
private ImageView pinned;
|
||||||
private final ImageView more;
|
private final ImageView more;
|
||||||
|
|
||||||
NotificationsHolder(View itemView) {
|
NotificationsHolder(View itemView) {
|
||||||
|
@ -102,6 +105,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
repository = itemView.findViewById(R.id.repository);
|
repository = itemView.findViewById(R.id.repository);
|
||||||
typePr = itemView.findViewById(R.id.typePr);
|
typePr = itemView.findViewById(R.id.typePr);
|
||||||
typeIssue = itemView.findViewById(R.id.typeIssue);
|
typeIssue = itemView.findViewById(R.id.typeIssue);
|
||||||
|
typeRepo = itemView.findViewById(R.id.typeRepo);
|
||||||
|
typeCommit = itemView.findViewById(R.id.typeCommit);
|
||||||
typeUnknown = itemView.findViewById(R.id.typeUnknown);
|
typeUnknown = itemView.findViewById(R.id.typeUnknown);
|
||||||
pinned = itemView.findViewById(R.id.pinned);
|
pinned = itemView.findViewById(R.id.pinned);
|
||||||
more = itemView.findViewById(R.id.more);
|
more = itemView.findViewById(R.id.more);
|
||||||
|
@ -111,10 +116,20 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
void bindData(NotificationThread notificationThread) {
|
void bindData(NotificationThread notificationThread) {
|
||||||
|
|
||||||
String url = notificationThread.getSubject().getUrl();
|
String url = notificationThread.getSubject().getUrl();
|
||||||
String subjectId = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + "</font>";
|
String subjectId = "";
|
||||||
|
|
||||||
|
if(StringUtils.containsAny(notificationThread.getSubject().getType().toLowerCase(), "pull", "issue")) {
|
||||||
|
subjectId = "<font color='" + ResourcesCompat.getColor(context.getResources(), R.color.lightGray, null) + "'>" + context.getResources().getString(R.string.hash) + url.substring(url.lastIndexOf("/") + 1) + "</font>";
|
||||||
|
}
|
||||||
|
|
||||||
subject.setText(HtmlCompat.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
subject.setText(HtmlCompat.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle(), HtmlCompat.FROM_HTML_MODE_LEGACY));
|
||||||
|
if(!notificationThread.getSubject().getType().equalsIgnoreCase("repository")) {
|
||||||
repository.setText(notificationThread.getRepository().getFullName());
|
repository.setText(notificationThread.getRepository().getFullName());
|
||||||
|
} else {
|
||||||
|
repository.setVisibility(View.GONE);
|
||||||
|
pinned.setVisibility(View.GONE);
|
||||||
|
pinned = itemView.findViewById(R.id.pinnedVertical);
|
||||||
|
}
|
||||||
|
|
||||||
if(notificationThread.isPinned()) {
|
if(notificationThread.isPinned()) {
|
||||||
pinned.setVisibility(View.VISIBLE);
|
pinned.setVisibility(View.VISIBLE);
|
||||||
|
@ -127,15 +142,35 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||||
case "Pull":
|
case "Pull":
|
||||||
typePr.setVisibility(View.VISIBLE);
|
typePr.setVisibility(View.VISIBLE);
|
||||||
typeIssue.setVisibility(View.GONE);
|
typeIssue.setVisibility(View.GONE);
|
||||||
|
typeRepo.setVisibility(View.GONE);
|
||||||
|
typeCommit.setVisibility(View.GONE);
|
||||||
typeUnknown.setVisibility(View.GONE);
|
typeUnknown.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case "Issue":
|
case "Issue":
|
||||||
typePr.setVisibility(View.GONE);
|
typePr.setVisibility(View.GONE);
|
||||||
|
typeRepo.setVisibility(View.GONE);
|
||||||
|
typeCommit.setVisibility(View.GONE);
|
||||||
typeIssue.setVisibility(View.VISIBLE);
|
typeIssue.setVisibility(View.VISIBLE);
|
||||||
typeUnknown.setVisibility(View.GONE);
|
typeUnknown.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
|
case "Repository":
|
||||||
|
typeUnknown.setVisibility(View.GONE);
|
||||||
|
typeIssue.setVisibility(View.GONE);
|
||||||
|
typePr.setVisibility(View.GONE);
|
||||||
|
typeRepo.setVisibility(View.VISIBLE);
|
||||||
|
typeCommit.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
|
case "Commit":
|
||||||
|
typeUnknown.setVisibility(View.GONE);
|
||||||
|
typeIssue.setVisibility(View.GONE);
|
||||||
|
typePr.setVisibility(View.GONE);
|
||||||
|
typeRepo.setVisibility(View.GONE);
|
||||||
|
typeCommit.setVisibility(View.VISIBLE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
typePr.setVisibility(View.GONE);
|
typePr.setVisibility(View.GONE);
|
||||||
|
typeRepo.setVisibility(View.GONE);
|
||||||
|
typeCommit.setVisibility(View.GONE);
|
||||||
typeIssue.setVisibility(View.GONE);
|
typeIssue.setVisibility(View.GONE);
|
||||||
typeUnknown.setVisibility(View.VISIBLE);
|
typeUnknown.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.gitnex.tea4j.models.NotificationThread;
|
||||||
import org.mian.gitnex.R;
|
import org.mian.gitnex.R;
|
||||||
import org.mian.gitnex.actions.NotificationsActions;
|
import org.mian.gitnex.actions.NotificationsActions;
|
||||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||||
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||||
import org.mian.gitnex.adapters.NotificationsAdapter;
|
import org.mian.gitnex.adapters.NotificationsAdapter;
|
||||||
import org.mian.gitnex.clients.RetrofitClient;
|
import org.mian.gitnex.clients.RetrofitClient;
|
||||||
import org.mian.gitnex.databinding.FragmentNotificationsBinding;
|
import org.mian.gitnex.databinding.FragmentNotificationsBinding;
|
||||||
|
@ -337,6 +338,11 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
|
||||||
tinyDB.putString("issueType", notificationThread.getSubject().getType());
|
tinyDB.putString("issueType", notificationThread.getSubject().getType());
|
||||||
tinyDB.putString("repoFullName", notificationThread.getRepository().getFullName());
|
tinyDB.putString("repoFullName", notificationThread.getRepository().getFullName());
|
||||||
|
|
||||||
|
startActivity(intent);
|
||||||
|
} else if(notificationThread.getSubject().getType().equalsIgnoreCase("repository")) {
|
||||||
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
||||||
|
tinyDB.putString("repoFullName", notificationThread.getRepository().getFullName());
|
||||||
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,22 @@
|
||||||
android:contentDescription="@string/generalImgContentText"
|
android:contentDescription="@string/generalImgContentText"
|
||||||
app:srcCompat="@drawable/ic_issue" />
|
app:srcCompat="@drawable/ic_issue" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/typeRepo"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:contentDescription="@string/generalImgContentText"
|
||||||
|
app:srcCompat="@drawable/ic_repo" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/typeCommit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:contentDescription="@string/generalImgContentText"
|
||||||
|
app:srcCompat="@drawable/ic_commit" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/typeUnknown"
|
android:id="@+id/typeUnknown"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -44,18 +60,6 @@
|
||||||
android:contentDescription="@string/generalImgContentText"
|
android:contentDescription="@string/generalImgContentText"
|
||||||
app:srcCompat="@drawable/ic_question" />
|
app:srcCompat="@drawable/ic_question" />
|
||||||
|
|
||||||
<Space
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/pinned"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:contentDescription="@string/generalImgContentText"
|
|
||||||
app:srcCompat="@drawable/ic_pin" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -80,10 +84,39 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/pinnedVertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:contentDescription="@string/generalImgContentText"
|
||||||
|
app:srcCompat="@drawable/ic_pin" />
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/pinned"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:layout_gravity="top"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
android:contentDescription="@string/generalImgContentText"
|
||||||
|
app:srcCompat="@drawable/ic_pin" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/more"
|
android:id="@+id/more"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
|
@ -92,6 +125,8 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
|
Loading…
Reference in New Issue