mirror of
https://codeberg.org/gitnex/GitNex
synced 2025-02-02 12:27:24 +01:00
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.text.HtmlCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.models.NotificationThread;
|
||||
import org.mian.gitnex.R;
|
||||
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 ImageView typePr;
|
||||
private final ImageView typeIssue;
|
||||
private final ImageView typeRepo;
|
||||
private final ImageView typeCommit;
|
||||
private final ImageView typeUnknown;
|
||||
private final ImageView pinned;
|
||||
private ImageView pinned;
|
||||
private final ImageView more;
|
||||
|
||||
NotificationsHolder(View itemView) {
|
||||
@ -102,6 +105,8 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
repository = itemView.findViewById(R.id.repository);
|
||||
typePr = itemView.findViewById(R.id.typePr);
|
||||
typeIssue = itemView.findViewById(R.id.typeIssue);
|
||||
typeRepo = itemView.findViewById(R.id.typeRepo);
|
||||
typeCommit = itemView.findViewById(R.id.typeCommit);
|
||||
typeUnknown = itemView.findViewById(R.id.typeUnknown);
|
||||
pinned = itemView.findViewById(R.id.pinned);
|
||||
more = itemView.findViewById(R.id.more);
|
||||
@ -111,10 +116,20 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
void bindData(NotificationThread notificationThread) {
|
||||
|
||||
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));
|
||||
repository.setText(notificationThread.getRepository().getFullName());
|
||||
if(!notificationThread.getSubject().getType().equalsIgnoreCase("repository")) {
|
||||
repository.setText(notificationThread.getRepository().getFullName());
|
||||
} else {
|
||||
repository.setVisibility(View.GONE);
|
||||
pinned.setVisibility(View.GONE);
|
||||
pinned = itemView.findViewById(R.id.pinnedVertical);
|
||||
}
|
||||
|
||||
if(notificationThread.isPinned()) {
|
||||
pinned.setVisibility(View.VISIBLE);
|
||||
@ -127,15 +142,35 @@ public class NotificationsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
case "Pull":
|
||||
typePr.setVisibility(View.VISIBLE);
|
||||
typeIssue.setVisibility(View.GONE);
|
||||
typeRepo.setVisibility(View.GONE);
|
||||
typeCommit.setVisibility(View.GONE);
|
||||
typeUnknown.setVisibility(View.GONE);
|
||||
break;
|
||||
case "Issue":
|
||||
typePr.setVisibility(View.GONE);
|
||||
typeRepo.setVisibility(View.GONE);
|
||||
typeCommit.setVisibility(View.GONE);
|
||||
typeIssue.setVisibility(View.VISIBLE);
|
||||
typeUnknown.setVisibility(View.GONE);
|
||||
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:
|
||||
typePr.setVisibility(View.GONE);
|
||||
typeRepo.setVisibility(View.GONE);
|
||||
typeCommit.setVisibility(View.GONE);
|
||||
typeIssue.setVisibility(View.GONE);
|
||||
typeUnknown.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
|
@ -24,6 +24,7 @@ import org.gitnex.tea4j.models.NotificationThread;
|
||||
import org.mian.gitnex.R;
|
||||
import org.mian.gitnex.actions.NotificationsActions;
|
||||
import org.mian.gitnex.activities.IssueDetailActivity;
|
||||
import org.mian.gitnex.activities.RepoDetailActivity;
|
||||
import org.mian.gitnex.adapters.NotificationsAdapter;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
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("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);
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,22 @@
|
||||
android:contentDescription="@string/generalImgContentText"
|
||||
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
|
||||
android:id="@+id/typeUnknown"
|
||||
android:layout_width="wrap_content"
|
||||
@ -44,18 +60,6 @@
|
||||
android:contentDescription="@string/generalImgContentText"
|
||||
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
|
||||
@ -81,14 +85,45 @@
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/more"
|
||||
android:id="@+id/pinnedVertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
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_dotted_menu_horizontal" />
|
||||
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
|
||||
android:id="@+id/more"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginStart="10dp"
|
||||
android:background="@android:color/transparent"
|
||||
android:contentDescription="@string/generalImgContentText"
|
||||
app:srcCompat="@drawable/ic_dotted_menu_horizontal" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user