Browse Source

[FrontPort #429] Dismiss bottom sheet on subscribe/unsubscribe to issue & Fix (#428)

Merge branch 'master' into 427-dismiss-bottom-sheet

Does not really fix the issue as there is way to handle this without a proper call.
And dismiss does not work properly either.

But added few improvements and fixed close/reopen issue along the way.

Co-authored-by: 6543 <6543@noreply.gitea.io>
Reviewed-on: #428
Reviewed-by: 6543 <6543@noreply.gitea.io>
pull/431/head
M M Arif 1 month ago
parent
commit
af6cbfdb66
4 changed files with 40 additions and 35 deletions
  1. +23
    -6
      app/src/main/java/org/mian/gitnex/actions/IssueActions.java
  2. +14
    -27
      app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java
  3. +2
    -1
      app/src/main/res/layout/bottom_sheet_single_issue_layout.xml
  4. +1
    -1
      build.gradle

+ 23
- 6
app/src/main/java/org/mian/gitnex/actions/IssueActions.java View File

@@ -120,11 +120,18 @@ public class IssueActions {

tinyDb.putBoolean("resumeIssues", true);
tinyDb.putBoolean("resumeClosedIssues", true);

if(issueState.equals("closed")) {

Toasty.info(ctx, ctx.getString(R.string.issueStateClosed));
tinyDb.putString("issueState", "closed");

}
else if(issueState.equals("open")) {

Toasty.info(ctx, ctx.getString(R.string.issueStateReopened));
tinyDb.putString("issueState", "open");

}

}
@@ -191,9 +198,14 @@ public class IssueActions {

if(response.isSuccessful()) {

Toasty.info(ctx, ctx.getString(R.string.issueSubscribtion));
subscribeIssue.setVisibility(View.GONE);
unsubscribeIssue.setVisibility(View.VISIBLE);
if(response.code() == 201) {

unsubscribeIssue.setVisibility(View.VISIBLE);
subscribeIssue.setVisibility(View.GONE);
Toasty.info(ctx, ctx.getString(R.string.issueSubscribtion));
tinyDB.putString("issueSubscriptionState", "unsubscribeToIssue");

}

}
else if(response.code() == 401) {
@@ -248,9 +260,14 @@ public class IssueActions {

if(response.isSuccessful()) {

Toasty.info(ctx, ctx.getString(R.string.issueUnsubscribtion));
unsubscribeIssue.setVisibility(View.GONE);
subscribeIssue.setVisibility(View.VISIBLE);
if(response.code() == 201) {

unsubscribeIssue.setVisibility(View.GONE);
subscribeIssue.setVisibility(View.VISIBLE);
Toasty.info(ctx, ctx.getString(R.string.issueUnsubscribtion));
tinyDB.putString("issueSubscriptionState", "subscribeToIssue");

}

}
else if(response.code() == 401) {


+ 14
- 27
app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java View File

@@ -15,9 +15,6 @@ import org.mian.gitnex.activities.AddRemoveLabelsActivity;
import org.mian.gitnex.activities.EditIssueActivity;
import org.mian.gitnex.activities.FileDiffActivity;
import org.mian.gitnex.activities.MergePullRequestActivity;
import org.mian.gitnex.activities.ReplyToIssueActivity;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.util.TinyDB;
import androidx.annotation.NonNull;
@@ -25,8 +22,6 @@ import androidx.annotation.Nullable;
import android.content.ClipboardManager;
import android.content.ClipData;
import java.util.Objects;
import retrofit2.Call;
import retrofit2.Callback;

/**
* Author M M Arif
@@ -187,30 +182,26 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {
if (tinyDB.getString("issueState").equals("open")) { // close issue

reOpenIssue.setVisibility(View.GONE);
closeIssue.setVisibility(View.VISIBLE);

closeIssue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
closeIssue.setOnClickListener(closeSingleIssue -> {

IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "closed");
dismiss();
IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "closed");
dismiss();

}
});

}
else if (tinyDB.getString("issueState").equals("closed")) {

closeIssue.setVisibility(View.GONE);
reOpenIssue.setVisibility(View.VISIBLE);

reOpenIssue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reOpenIssue.setOnClickListener(reOpenSingleIssue -> {

IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "open");
dismiss();
IssueActions.closeReopenIssue(ctx, Integer.parseInt(tinyDB.getString("issueNumber")), "open");
dismiss();

}
});

}
@@ -223,22 +214,18 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment {

}

subscribeIssue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subscribeIssue.setOnClickListener(subscribeToIssue -> {

IssueActions.subscribe(ctx, subscribeIssue, unsubscribeIssue);
IssueActions.subscribe(ctx, subscribeIssue, unsubscribeIssue);
//dismiss();

}
});

unsubscribeIssue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
unsubscribeIssue.setOnClickListener(unsubscribeToIssue -> {

IssueActions.unsubscribe(ctx, subscribeIssue, unsubscribeIssue);
IssueActions.unsubscribe(ctx, subscribeIssue, unsubscribeIssue);
//dismiss();

}
});

//if RepoWatch True Provide Unsubscribe first


+ 2
- 1
app/src/main/res/layout/bottom_sheet_single_issue_layout.xml View File

@@ -88,7 +88,8 @@
android:drawablePadding="24dp"
android:textColor="?attr/primaryTextColor"
android:textSize="16sp"
android:padding="16dp" />
android:padding="16dp"
android:visibility="gone" />

<TextView
android:id="@+id/unsubscribeIssue"


+ 1
- 1
build.gradle View File

@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.android.tools.build:gradle:3.6.3'

}
}


Loading…
Cancel
Save