2019-06-03 23:25:05 +02:00
|
|
|
package org.mian.gitnex.fragments;
|
|
|
|
|
2020-04-05 11:54:34 +02:00
|
|
|
import android.content.Context;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.os.Bundle;
|
2021-10-04 15:35:34 +02:00
|
|
|
import android.view.Gravity;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.TextView;
|
2020-04-23 22:40:13 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
2019-06-03 23:25:05 +02:00
|
|
|
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
2022-09-21 07:43:00 +02:00
|
|
|
import java.util.Objects;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.R;
|
|
|
|
import org.mian.gitnex.actions.IssueActions;
|
2021-06-10 18:03:52 +02:00
|
|
|
import org.mian.gitnex.actions.PullRequestActions;
|
2022-09-14 20:40:44 +02:00
|
|
|
import org.mian.gitnex.activities.BaseActivity;
|
|
|
|
import org.mian.gitnex.activities.DiffActivity;
|
|
|
|
import org.mian.gitnex.activities.EditIssueActivity;
|
|
|
|
import org.mian.gitnex.activities.IssueDetailActivity;
|
|
|
|
import org.mian.gitnex.activities.MergePullRequestActivity;
|
2021-01-26 16:10:31 +01:00
|
|
|
import org.mian.gitnex.databinding.BottomSheetSingleIssueBinding;
|
2021-06-10 18:03:52 +02:00
|
|
|
import org.mian.gitnex.helpers.AlertDialogs;
|
2022-04-22 17:18:38 +02:00
|
|
|
import org.mian.gitnex.helpers.AppUtil;
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
import org.mian.gitnex.helpers.contexts.IssueContext;
|
2021-12-15 20:20:49 +01:00
|
|
|
import org.mian.gitnex.structs.BottomSheetListener;
|
2020-11-08 19:58:47 +01:00
|
|
|
import org.mian.gitnex.views.ReactionSpinner;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
/**
|
2022-04-18 09:10:54 +02:00
|
|
|
* @author M M Arif
|
2019-06-03 23:25:05 +02:00
|
|
|
*/
|
2020-03-16 20:28:03 +01:00
|
|
|
public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
private final IssueContext issue;
|
2022-02-11 15:27:31 +01:00
|
|
|
private final String issueCreator;
|
2022-08-15 16:26:02 +02:00
|
|
|
private BottomSheetListener bmListener;
|
2022-02-11 15:27:31 +01:00
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
public BottomSheetSingleIssueFragment(IssueContext issue, String username) {
|
|
|
|
this.issue = issue;
|
2022-02-11 15:27:31 +01:00
|
|
|
issueCreator = username;
|
|
|
|
}
|
2020-10-09 17:47:52 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
@Nullable @Override
|
|
|
|
public View onCreateView(
|
|
|
|
@NonNull LayoutInflater inflater,
|
|
|
|
@Nullable ViewGroup container,
|
|
|
|
@Nullable Bundle savedInstanceState) {
|
2020-04-23 22:40:13 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
BottomSheetSingleIssueBinding binding =
|
|
|
|
BottomSheetSingleIssueBinding.inflate(inflater, container, false);
|
2020-04-23 22:40:13 +02:00
|
|
|
|
|
|
|
final Context ctx = getContext();
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
boolean userIsCreator =
|
|
|
|
issueCreator.equals(
|
|
|
|
((BaseActivity) requireActivity()).getAccount().getAccount().getUserName());
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
boolean isRepoAdmin = issue.getRepository().getPermissions().isAdmin();
|
2022-04-18 09:10:54 +02:00
|
|
|
boolean canPush = issue.getRepository().getPermissions().isPush();
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
boolean archived = issue.getRepository().getRepository().isArchived();
|
2020-11-08 19:58:47 +01:00
|
|
|
|
2022-02-22 07:23:46 +01:00
|
|
|
Bundle bundle = new Bundle();
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
bundle.putString("repoOwner", issue.getRepository().getOwner());
|
|
|
|
bundle.putString("repoName", issue.getRepository().getName());
|
|
|
|
bundle.putInt("issueId", issue.getIssueIndex());
|
2020-11-08 19:58:47 +01:00
|
|
|
|
2021-10-04 15:35:34 +02:00
|
|
|
TextView loadReactions = new TextView(ctx);
|
|
|
|
loadReactions.setText(Objects.requireNonNull(ctx).getString(R.string.genericWaitFor));
|
|
|
|
loadReactions.setGravity(Gravity.CENTER);
|
2022-09-21 07:43:00 +02:00
|
|
|
loadReactions.setLayoutParams(
|
|
|
|
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 140));
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.commentReactionButtons.addView(loadReactions);
|
2021-10-04 15:35:34 +02:00
|
|
|
|
2022-02-22 07:23:46 +01:00
|
|
|
ReactionSpinner reactionSpinner = new ReactionSpinner(ctx, bundle);
|
2022-09-21 07:43:00 +02:00
|
|
|
reactionSpinner.setOnInteractedListener(
|
|
|
|
() -> {
|
|
|
|
IssueDetailActivity.singleIssueUpdate = true;
|
|
|
|
|
|
|
|
bmListener.onButtonClicked("onResume");
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
reactionSpinner.setOnLoadingFinishedListener(
|
|
|
|
() -> {
|
|
|
|
reactionSpinner.setLayoutParams(
|
|
|
|
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 160));
|
|
|
|
binding.commentReactionButtons.removeView(loadReactions);
|
|
|
|
binding.commentReactionButtons.addView(reactionSpinner);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
2020-04-23 22:40:13 +02:00
|
|
|
|
2022-04-22 17:18:38 +02:00
|
|
|
binding.editIssue.setText(R.string.menuEditText);
|
2020-04-23 22:40:13 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
boolean canPushPullSource =
|
|
|
|
issue.getPullRequest().getHead().getRepo() != null
|
|
|
|
? issue.getPullRequest().getHead().getRepo().getPermissions().isPush()
|
|
|
|
: false;
|
|
|
|
if (issue.getPullRequest().isMerged() || issue.getIssue().getState().equals("closed")) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.updatePullRequest.setVisibility(View.GONE);
|
|
|
|
binding.mergePullRequest.setVisibility(View.GONE);
|
2022-09-21 07:43:00 +02:00
|
|
|
if (canPushPullSource) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.deletePrHeadBranch.setVisibility(View.VISIBLE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
|
|
|
if (!canPush) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.editIssue.setVisibility(View.GONE);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.deletePrHeadBranch.setVisibility(View.GONE);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
|
|
|
if (canPushPullSource) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.updatePullRequest.setVisibility(View.VISIBLE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.updatePullRequest.setVisibility(View.GONE);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
if (!userIsCreator && !canPush) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.editIssue.setVisibility(View.GONE);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
if (canPush && issue.getPullRequest().isMergeable()) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.mergePullRequest.setVisibility(View.VISIBLE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.mergePullRequest.setVisibility(View.GONE);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.deletePrHeadBranch.setVisibility(View.GONE);
|
2020-04-23 22:40:13 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
binding.openFilesDiff.setVisibility(View.VISIBLE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
|
|
|
if (!userIsCreator && !canPush) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.editIssue.setVisibility(View.GONE);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.updatePullRequest.setVisibility(View.GONE);
|
|
|
|
binding.mergePullRequest.setVisibility(View.GONE);
|
|
|
|
binding.deletePrHeadBranch.setVisibility(View.GONE);
|
2020-04-23 22:40:13 +02:00
|
|
|
}
|
2019-11-27 16:09:26 +01:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
binding.updatePullRequest.setOnClickListener(
|
|
|
|
v -> {
|
|
|
|
if (((BaseActivity) requireActivity()).getAccount().requiresVersion("1.16.0")) {
|
|
|
|
AlertDialogs.selectPullUpdateStrategy(
|
|
|
|
requireContext(),
|
|
|
|
issue.getRepository().getOwner(),
|
|
|
|
issue.getRepository().getName(),
|
|
|
|
String.valueOf(issue.getIssueIndex()));
|
|
|
|
} else {
|
|
|
|
PullRequestActions.updatePr(
|
|
|
|
requireContext(),
|
|
|
|
issue.getRepository().getOwner(),
|
|
|
|
issue.getRepository().getName(),
|
|
|
|
String.valueOf(issue.getIssueIndex()),
|
|
|
|
null);
|
|
|
|
}
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.mergePullRequest.setOnClickListener(
|
|
|
|
v13 -> {
|
|
|
|
startActivity(issue.getIntent(ctx, MergePullRequestActivity.class));
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.deletePrHeadBranch.setOnClickListener(
|
|
|
|
v -> {
|
|
|
|
PullRequestActions.deleteHeadBranch(
|
|
|
|
ctx,
|
|
|
|
issue.getRepository().getOwner(),
|
|
|
|
issue.getRepository().getName(),
|
|
|
|
issue.getPullRequest().getHead().getRef(),
|
|
|
|
true);
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.openFilesDiff.setOnClickListener(
|
|
|
|
v14 -> {
|
|
|
|
startActivity(issue.getIntent(ctx, DiffActivity.class));
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.editIssue.setOnClickListener(
|
|
|
|
v15 -> {
|
|
|
|
((IssueDetailActivity) requireActivity())
|
|
|
|
.editIssueLauncher.launch(
|
|
|
|
issue.getIntent(ctx, EditIssueActivity.class));
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.editLabels.setOnClickListener(
|
|
|
|
v16 -> {
|
|
|
|
bmListener.onButtonClicked("showLabels");
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.addRemoveAssignees.setOnClickListener(
|
|
|
|
v17 -> {
|
|
|
|
bmListener.onButtonClicked("showAssignees");
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.shareIssue.setOnClickListener(
|
|
|
|
v1 -> {
|
|
|
|
AppUtil.sharingIntent(ctx, issue.getIssue().getHtmlUrl());
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.copyIssueUrl.setOnClickListener(
|
|
|
|
v12 -> {
|
|
|
|
AppUtil.copyToClipboard(
|
|
|
|
ctx,
|
|
|
|
issue.getIssue().getHtmlUrl(),
|
|
|
|
ctx.getString(R.string.copyIssueUrlToastMsg));
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.open.setOnClickListener(
|
|
|
|
v12 -> {
|
|
|
|
AppUtil.openUrlInBrowser(ctx, issue.getIssue().getHtmlUrl());
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
if (issue.getIssueType().equalsIgnoreCase("pull")) {
|
2022-04-22 17:18:38 +02:00
|
|
|
binding.bottomSheetHeader.setText(R.string.pullRequest);
|
|
|
|
}
|
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issue.getIssue().getState().equals("open")) { // close issue
|
|
|
|
if (!userIsCreator && !canPush) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.closeIssue.setVisibility(View.GONE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else if (issue.getIssueType().equalsIgnoreCase("Pull")) {
|
2022-04-22 17:18:38 +02:00
|
|
|
binding.closeIssue.setText(R.string.close);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
binding.closeIssue.setOnClickListener(
|
|
|
|
closeSingleIssue -> {
|
|
|
|
IssueActions.closeReopenIssue(ctx, "closed", issue);
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
} else if (issue.getIssue().getState().equals("closed")) {
|
|
|
|
if (userIsCreator || canPush) {
|
2022-04-22 17:18:38 +02:00
|
|
|
binding.closeIssue.setText(R.string.reopen);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.closeIssue.setVisibility(View.GONE);
|
2022-02-11 15:27:31 +01:00
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
binding.closeIssue.setOnClickListener(
|
|
|
|
closeSingleIssue -> {
|
|
|
|
IssueActions.closeReopenIssue(ctx, "open", issue);
|
|
|
|
dismiss();
|
|
|
|
});
|
2020-04-23 22:40:13 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
binding.subscribeIssue.setOnClickListener(
|
|
|
|
subscribeToIssue -> {
|
|
|
|
IssueActions.subscribe(ctx, issue);
|
|
|
|
issue.setSubscribed(true);
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
binding.unsubscribeIssue.setOnClickListener(
|
|
|
|
unsubscribeToIssue -> {
|
|
|
|
IssueActions.unsubscribe(ctx, issue);
|
|
|
|
issue.setSubscribed(false);
|
|
|
|
dismiss();
|
|
|
|
});
|
|
|
|
|
|
|
|
if (issue.isSubscribed()) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.subscribeIssue.setVisibility(View.GONE);
|
|
|
|
binding.unsubscribeIssue.setVisibility(View.VISIBLE);
|
2022-09-21 07:43:00 +02:00
|
|
|
} else {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.subscribeIssue.setVisibility(View.VISIBLE);
|
|
|
|
binding.unsubscribeIssue.setVisibility(View.GONE);
|
2020-05-21 20:58:00 +02:00
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2022-09-21 07:43:00 +02:00
|
|
|
if (archived) {
|
2022-02-22 07:23:46 +01:00
|
|
|
binding.subscribeIssue.setVisibility(View.GONE);
|
|
|
|
binding.unsubscribeIssue.setVisibility(View.GONE);
|
|
|
|
binding.editIssue.setVisibility(View.GONE);
|
|
|
|
binding.editLabels.setVisibility(View.GONE);
|
|
|
|
binding.closeIssue.setVisibility(View.GONE);
|
|
|
|
binding.addRemoveAssignees.setVisibility(View.GONE);
|
|
|
|
binding.commentReactionButtons.setVisibility(View.GONE);
|
2022-04-22 17:18:38 +02:00
|
|
|
binding.bottomSheetHeaderFrame.setVisibility(View.GONE);
|
|
|
|
binding.mergePullRequest.setVisibility(View.GONE);
|
|
|
|
binding.updatePullRequest.setVisibility(View.GONE);
|
2022-09-21 07:43:00 +02:00
|
|
|
if (issue.getIssueType().equalsIgnoreCase("issue")) {
|
2022-04-22 17:18:38 +02:00
|
|
|
binding.issuePrDivider.setVisibility(View.GONE);
|
|
|
|
}
|
2022-09-21 07:43:00 +02:00
|
|
|
} else if (!canPush) {
|
2022-04-20 15:46:50 +02:00
|
|
|
binding.addRemoveAssignees.setVisibility(View.GONE);
|
|
|
|
binding.editLabels.setVisibility(View.GONE);
|
|
|
|
}
|
2022-02-11 15:27:31 +01:00
|
|
|
|
2022-02-22 07:23:46 +01:00
|
|
|
return binding.getRoot();
|
2020-04-23 22:40:13 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-10-09 17:47:52 +02:00
|
|
|
@Override
|
|
|
|
public void onAttach(@NonNull Context context) {
|
|
|
|
|
|
|
|
super.onAttach(context);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
bmListener = (BottomSheetListener) context;
|
2022-09-21 07:43:00 +02:00
|
|
|
} catch (ClassCastException e) {
|
2020-10-09 17:47:52 +02:00
|
|
|
|
Don't use TinyDB as cache (#1034)
Do not use TinyDB as a cache or a way to send data between activities.
### How is this working
Instead of saving everything into the TinyDB, I created three `Context`s (a `RepositoryContext`, an `IssueContext` and an `AccountContext`). All are used to store things like API or database values/models and additional data, e.g. the `RepositoryContext` also contains information about the current filter state of a repository (issues, pull requests, releases/tags and milestones). These are sent using `Intent`s and `Bundle`s between activities and fragments. Changing a field (e.g. filter state) in any fragment changes it also for the whole repository (or at least it should do so).
Due to the size of the changes (after https://codeberg.org/gitnex/GitNex/commit/c9172f85efafd9f25739fdd8385e1904b711ea41, Git says `154 files changed, 3318 insertions(+), 3835 deletions(-)`) **I highly recommend you to create a beta/pre release before releasing a stable version**.
Additional changes:
* after logging out, the account remains in the account list (with a note) and you can log in again (you can't switch to this account)
* repositories and organizations are clickable on user profiles
* deleted two unused classes
Once finished, hopefully
* closes #354
* replaces #897
* fixes #947
* closes #1001
* closes #1015
* marks #876 and #578 as `Wontfix` since they are not necessary at this point
* and all the other TinyDB issues
Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1034
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
2022-03-13 03:59:13 +01:00
|
|
|
throw new ClassCastException(context + " must implement BottomSheetListener");
|
2020-10-09 17:47:52 +02:00
|
|
|
}
|
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
}
|