Switch branches (#571)
Fix default branch Merge branch 'master' into switch-branches # Conflicts: # app/src/main/res/layout/bottom_sheet_repo.xml # app/src/main/res/values/strings.xml update icon Merge branch 'master' into switch-branches Merge branch 'master' into switch-branches update the missing parts Minor updates Merge branch 'master' into switch-branches Merge branch 'master' into switch-branches # Conflicts: # app/src/main/java/org/mian/gitnex/activities/CreateIssueActivity.java # app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java # app/src/main/java/org/mian/gitnex/fragments/BottomSheetRepoFragment.java # app/src/main/java/org/mian/gitnex/fragments/FilesFragment.java Add branch to breadcrumb and dir structure fix Make change branch work clean up Merge branch 'master' into switch-branches add icon in top bar, add interface listener Merge branch 'master' into switch-branches Merge remote-tracking branch 'remotes/main/master' into switch-branches # Conflicts: # app/src/main/java/org/mian/gitnex/activities/LoginActivity.java # app/src/main/java/org/mian/gitnex/fragments/ProfileFragment.java # app/src/main/java/org/mian/gitnex/helpers/PathsHelper.java Switching between branches. Minor fixes Merge remote-tracking branch 'remotes/main/master' into login-fix URL parsing, label and other improvements. Co-authored-by: M M Arif <mmarif@swatian.com> Co-authored-by: 6543 <6543@noreply.codeberg.org> Co-authored-by: opyale <opyale@noreply.gitea.io> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/571 Reviewed-by: 6543 <6543@noreply.codeberg.org>
This commit is contained in:
@@ -139,7 +139,7 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
||||
.multiSelectList(listOfCollaborators)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
Log.i("selectedNames", String.valueOf(selectedNames));
|
||||
|
||||
@@ -167,7 +167,7 @@ public class AddRemoveAssigneesActivity extends BaseActivity {
|
||||
.multiSelectList(listOfCollaborators)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
updateIssueAssignees(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, loginUid, issueIndex, selectedNames);
|
||||
tinyDb.putBoolean("singleIssueUpdate", true);
|
||||
|
||||
@@ -128,7 +128,7 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
||||
.multiSelectList(listOfLabels)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
String labelIds = selectedIds.toString();
|
||||
int[] integers;
|
||||
@@ -169,7 +169,7 @@ public class AddRemoveLabelsActivity extends BaseActivity {
|
||||
.multiSelectList(listOfLabels)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
String labelIds = selectedIds.toString();
|
||||
int[] integers;
|
||||
|
||||
@@ -444,7 +444,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
.multiSelectList(listOfAssignees)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
assigneesList.setText(dataString);
|
||||
|
||||
@@ -507,7 +507,7 @@ public class CreateIssueActivity extends BaseActivity implements View.OnClickLis
|
||||
.multiSelectList(listOfLabels)
|
||||
.onSubmit(new MultiSelectDialog.SubmitCallbackListener() {
|
||||
@Override
|
||||
public void onSelected(ArrayList<Integer> selectedIds, ArrayList<String> selectedNames, String dataString) {
|
||||
public void onSelected(List<Integer> selectedIds, List<String> selectedNames, String dataString) {
|
||||
|
||||
newIssueLabels.setText(dataString.trim());
|
||||
labelsIdHolder.setText(selectedIds.toString());
|
||||
|
||||
@@ -83,6 +83,7 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
String repoFullName = tinyDb.getString("repoFullName");
|
||||
String repoBranch = tinyDb.getString("repoBranch");
|
||||
String[] parts = repoFullName.split("/");
|
||||
final String repoOwner = parts[0];
|
||||
final String repoName = parts[1];
|
||||
@@ -125,15 +126,15 @@ public class FileViewActivity extends BaseActivity implements BottomSheetFileVie
|
||||
|
||||
toolbar_title.setText(singleFileName);
|
||||
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName);
|
||||
getSingleFileContents(instanceUrl, instanceToken, repoOwner, repoName, singleFileName, repoBranch);
|
||||
|
||||
}
|
||||
|
||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename) {
|
||||
private void getSingleFileContents(String instanceUrl, String token, final String owner, String repo, final String filename, String ref) {
|
||||
|
||||
final TinyDB tinyDb = new TinyDB(appCtx);
|
||||
|
||||
Call<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename);
|
||||
Call<Files> call = RetrofitClient.getInstance(instanceUrl, ctx).getApiInterface().getSingleFileContents(token, owner, repo, filename, ref);
|
||||
|
||||
call.enqueue(new Callback<Files>() {
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.mian.gitnex.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
@@ -16,6 +17,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -41,11 +43,15 @@ import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||
import org.mian.gitnex.helpers.Authorization;
|
||||
import org.mian.gitnex.helpers.TinyDB;
|
||||
import org.mian.gitnex.helpers.Version;
|
||||
import org.mian.gitnex.models.Branches;
|
||||
import org.mian.gitnex.models.UserRepositories;
|
||||
import org.mian.gitnex.models.WatchInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* Author M M Arif
|
||||
@@ -61,6 +67,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
private FragmentRefreshListener fragmentRefreshListener;
|
||||
private FragmentRefreshListenerPr fragmentRefreshListenerPr;
|
||||
private FragmentRefreshListenerMilestone fragmentRefreshListenerMilestone;
|
||||
private FragmentRefreshListenerFiles fragmentRefreshListenerFiles;
|
||||
|
||||
private final Context ctx = this;
|
||||
private Context appCtx;
|
||||
@@ -285,6 +292,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
filterMilestoneBottomSheet.show(getSupportFragmentManager(), "repoFilterMenuMilestoneBottomSheet");
|
||||
return true;
|
||||
|
||||
case R.id.switchBranches:
|
||||
chooseBranch();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
@@ -313,6 +324,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
startActivity(new Intent(RepoDetailActivity.this, AddCollaboratorToRepositoryActivity.class));
|
||||
break;
|
||||
|
||||
case "chooseBranch":
|
||||
chooseBranch();
|
||||
break;
|
||||
|
||||
case "createRelease":
|
||||
startActivity(new Intent(RepoDetailActivity.this, CreateReleaseActivity.class));
|
||||
break;
|
||||
@@ -374,6 +389,65 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
}
|
||||
|
||||
private void chooseBranch() {
|
||||
|
||||
Call<List<Branches>> call = RetrofitClient.getInstance(instanceUrl, ctx)
|
||||
.getApiInterface()
|
||||
.getBranches(instanceToken, repositoryOwner, repositoryName);
|
||||
|
||||
call.enqueue(new Callback<List<Branches>>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call<List<Branches>> call, @NonNull Response<List<Branches>> response) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
|
||||
List<String> branchesList = new ArrayList<>();
|
||||
int selectedBranch = 0;
|
||||
assert response.body() != null;
|
||||
|
||||
for(int i = 0; i < response.body().size(); i++) {
|
||||
|
||||
Branches branches = response.body().get(i);
|
||||
branchesList.add(branches.getName());
|
||||
|
||||
if(tinyDB.getString("repoBranch").equals(branches.getName())) {
|
||||
|
||||
selectedBranch = i;
|
||||
}
|
||||
}
|
||||
|
||||
AlertDialog.Builder pBuilder = new AlertDialog.Builder(ctx);
|
||||
pBuilder.setTitle(R.string.pageTitleChooseBranch);
|
||||
|
||||
pBuilder.setSingleChoiceItems(branchesList.toArray(new String[0]), selectedBranch, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
|
||||
tinyDB.putString("repoBranch", branchesList.get(i));
|
||||
if(getFragmentRefreshListenerFiles() != null) {
|
||||
getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i));
|
||||
}
|
||||
dialogInterface.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
pBuilder.create().show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NonNull Call<List<Branches>> call, @NonNull Throwable t) {
|
||||
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
SectionsPagerAdapter(FragmentManager fm) {
|
||||
@@ -393,7 +467,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
return RepoInfoFragment.newInstance(repositoryOwner, repositoryName);
|
||||
|
||||
case 1: // Files
|
||||
return FilesFragment.newInstance(repositoryOwner, repositoryName);
|
||||
return FilesFragment.newInstance(repositoryOwner, repositoryName, tinyDB.getString("repoBranch"));
|
||||
|
||||
case 2: // Issues
|
||||
fragment = new IssuesFragment();
|
||||
@@ -444,32 +518,28 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
UserRepositories repoInfo = response.body();
|
||||
|
||||
if(response.isSuccessful()) {
|
||||
if(response.code() == 200) {
|
||||
|
||||
if(response.code() == 200) {
|
||||
if(tinyDB.getBoolean("enableCounterBadges")) {
|
||||
assert repoInfo != null;
|
||||
|
||||
if(tinyDB.getBoolean("enableCounterBadges")) {
|
||||
assert repoInfo != null;
|
||||
if(repoInfo.getOpen_issues_count() != null) {
|
||||
|
||||
if(repoInfo.getOpen_issues_count() != null) {
|
||||
|
||||
textViewBadgeIssue.setVisibility(View.VISIBLE);
|
||||
textViewBadgeIssue.setText(repoInfo.getOpen_issues_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getOpen_pull_count() != null) {
|
||||
|
||||
textViewBadgePull.setVisibility(View.VISIBLE);
|
||||
textViewBadgePull.setText(repoInfo.getOpen_pull_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getRelease_count() != null) {
|
||||
|
||||
textViewBadgeRelease.setVisibility(View.VISIBLE);
|
||||
textViewBadgeRelease.setText(repoInfo.getRelease_count());
|
||||
}
|
||||
textViewBadgeIssue.setVisibility(View.VISIBLE);
|
||||
textViewBadgeIssue.setText(repoInfo.getOpen_issues_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getOpen_pull_count() != null) {
|
||||
|
||||
textViewBadgePull.setVisibility(View.VISIBLE);
|
||||
textViewBadgePull.setText(repoInfo.getOpen_pull_count());
|
||||
}
|
||||
|
||||
if(repoInfo.getRelease_count() != null) {
|
||||
|
||||
textViewBadgeRelease.setVisibility(View.VISIBLE);
|
||||
textViewBadgeRelease.setText(repoInfo.getRelease_count());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -567,4 +637,11 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
public interface FragmentRefreshListenerMilestone { void onRefresh(String text); }
|
||||
|
||||
// Files interface
|
||||
public FragmentRefreshListenerFiles getFragmentRefreshListenerFiles() { return fragmentRefreshListenerFiles; }
|
||||
|
||||
public void setFragmentRefreshListenerFiles(FragmentRefreshListenerFiles fragmentRefreshListenerFiles) { this.fragmentRefreshListenerFiles = fragmentRefreshListenerFiles; }
|
||||
|
||||
public interface FragmentRefreshListenerFiles { void onRefresh(String text); }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user