Check Issue Subscription and display button based on that (#445)

update string names

Update strings

Merge branch 'master' into imprufe-issue-subscription-checking

switch icon as per @mmarif

Migrate to new Version Check & disable IssueSubscription function for gitea < 1.12.0

Merge branch 'master' into imprufe-issue-subscription-checking

Merge branch 'master' into imprufe-issue-subscription-checking

Merge branch 'master' into imprufe-issue-subscription-checking

refactor  & use dismiss()

realy check If issue is subscribed

add 200 http Status check and handle it

Rename WatchRepository to WatchInfo & add checkIssueWatchStatus

Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/445
Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
6543
2020-05-21 18:58:00 +00:00
committed by M M Arif
parent ad7c3696d5
commit e83b9eb736
14 changed files with 170 additions and 119 deletions

View File

@@ -47,8 +47,10 @@ import org.mian.gitnex.helpers.LabelWidthCalculator;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.TimeHelper;
import org.mian.gitnex.helpers.UserMentions;
import org.mian.gitnex.helpers.Version;
import org.mian.gitnex.models.IssueComments;
import org.mian.gitnex.models.Issues;
import org.mian.gitnex.models.WatchInfo;
import org.mian.gitnex.util.TinyDB;
import org.mian.gitnex.viewmodels.IssueCommentsViewModel;
import java.text.DateFormat;
@@ -550,6 +552,38 @@ public class IssueDetailActivity extends BaseActivity {
}
});
if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) {
Call<WatchInfo> call2 = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkIssueWatchStatus(Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, issueIndex);
call2.enqueue(new Callback<WatchInfo>() {
@Override
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull Response<WatchInfo> response) {
if(response.isSuccessful()) {
tinyDb.putBoolean("issueSubscribed", response.body().getSubscribed());
}
else {
tinyDb.putBoolean("issueSubscribed", false);
}
}
@Override
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
tinyDb.putBoolean("issueSubscribed", false);
}
});
}
}
private void initCloseListener() {

View File

@@ -40,7 +40,7 @@ import org.mian.gitnex.fragments.RepoInfoFragment;
import org.mian.gitnex.helpers.Authorization;
import org.mian.gitnex.helpers.Version;
import org.mian.gitnex.models.UserRepositories;
import org.mian.gitnex.models.WatchRepository;
import org.mian.gitnex.models.WatchInfo;
import org.mian.gitnex.util.AppUtil;
import org.mian.gitnex.util.TinyDB;
import java.util.Objects;
@@ -486,14 +486,14 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
private void checkRepositoryWatchStatus(String instanceUrl, String instanceToken, final String owner, String repo) {
Call<WatchRepository> call;
Call<WatchInfo> call;
call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().checkRepoWatchStatus(instanceToken, owner, repo);
call.enqueue(new Callback<WatchRepository>() {
call.enqueue(new Callback<WatchInfo>() {
@Override
public void onResponse(@NonNull Call<WatchRepository> call, @NonNull retrofit2.Response<WatchRepository> response) {
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
TinyDB tinyDb = new TinyDB(appCtx);
@@ -510,7 +510,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
}
@Override
public void onFailure(@NonNull Call<WatchRepository> call, @NonNull Throwable t) {
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
Log.e("onFailure", t.toString());
}