diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a3f23869..da640a82 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -84,6 +84,7 @@
+
diff --git a/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
index 4661a585..f438f4db 100644
--- a/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/AddCollaboratorToRepositoryActivity.java
@@ -144,5 +144,4 @@ public class AddCollaboratorToRepositoryActivity extends BaseActivity {
onClickListener = view -> finish();
}
-
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java
index 76c23b93..e3743446 100644
--- a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java
+++ b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java
@@ -402,6 +402,10 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
}
break;
+ case "repoSettings":
+ startActivity(new Intent(RepoDetailActivity.this, RepositorySettingsActivity.class));
+ break;
+
}
}
diff --git a/app/src/main/java/org/mian/gitnex/activities/RepositorySettingsActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepositorySettingsActivity.java
new file mode 100644
index 00000000..7d8d6262
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/RepositorySettingsActivity.java
@@ -0,0 +1,317 @@
+package org.mian.gitnex.activities;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import androidx.annotation.NonNull;
+import com.google.gson.JsonElement;
+import org.mian.gitnex.R;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.database.api.RepositoriesApi;
+import org.mian.gitnex.databinding.ActivityRepositorySettingsBinding;
+import org.mian.gitnex.databinding.CustomRepositoryDeleteDialogBinding;
+import org.mian.gitnex.databinding.CustomRepositoryEditPropertiesDialogBinding;
+import org.mian.gitnex.helpers.TinyDB;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.UserRepositories;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class RepositorySettingsActivity extends BaseActivity {
+
+ private ActivityRepositorySettingsBinding viewBinding;
+ private CustomRepositoryEditPropertiesDialogBinding propBinding;
+ private CustomRepositoryDeleteDialogBinding deleteRepoBinding;
+ private Dialog dialogProp;
+ private Dialog dialogDeleteRepository;
+ private View.OnClickListener onClickListener;
+ private Context ctx = this;
+ private Context appCtx;
+ private TinyDB tinyDb;
+
+ private String instanceUrl;
+ private String loginUid;
+ private String instanceToken;
+
+ private String repositoryOwner;
+ private String repositoryName;
+
+ @Override
+ protected int getLayoutResourceId(){
+ return R.layout.activity_repository_settings;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ appCtx = getApplicationContext();
+ tinyDb = new TinyDB(appCtx);
+
+ viewBinding = ActivityRepositorySettingsBinding.inflate(getLayoutInflater());
+ View view = viewBinding.getRoot();
+ setContentView(view);
+
+ instanceUrl = tinyDb.getString("instanceUrl");
+ loginUid = tinyDb.getString("loginUid");
+ String repoFullName = tinyDb.getString("repoFullName");
+ String[] parts = repoFullName.split("/");
+ repositoryOwner = parts[0];
+ repositoryName = parts[1];
+ instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ ImageView closeActivity = findViewById(R.id.close);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ viewBinding.editProperties.setOnClickListener(editProperties -> {
+ showRepositoryProperties();
+ });
+
+ viewBinding.deleteRepository.setOnClickListener(editProperties -> {
+ showDeleteRepository();
+ });
+
+ }
+
+ private void showDeleteRepository() {
+
+ dialogDeleteRepository = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
+
+ if (dialogDeleteRepository.getWindow() != null) {
+ dialogDeleteRepository.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ }
+
+ deleteRepoBinding = CustomRepositoryDeleteDialogBinding.inflate(LayoutInflater.from(ctx));
+
+ View view = deleteRepoBinding.getRoot();
+ dialogDeleteRepository.setContentView(view);
+
+ deleteRepoBinding.cancel.setOnClickListener(editProperties -> {
+ dialogDeleteRepository.dismiss();
+ });
+
+ deleteRepoBinding.delete.setOnClickListener(deleteRepo -> {
+
+ if(!repositoryName.equals(String.valueOf(deleteRepoBinding.repoNameForDeletion.getText()))) {
+
+ Toasty.error(ctx, getString(R.string.repoSettingsDeleteError));
+ }
+ else {
+
+ deleteRepository();
+ }
+ });
+
+ dialogDeleteRepository.show();
+ }
+
+ private void deleteRepository() {
+
+ Call deleteCall = RetrofitClient
+ .getInstance(instanceUrl, ctx)
+ .getApiInterface()
+ .deleteRepository(instanceToken, repositoryOwner, repositoryName);
+
+ deleteCall.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ deleteRepoBinding.delete.setVisibility(View.GONE);
+ deleteRepoBinding.processingRequest.setVisibility(View.VISIBLE);
+
+ if (response.code() == 204) {
+
+ dialogDeleteRepository.dismiss();
+ Toasty.success(ctx, getString(R.string.repoDeletionSuccess));
+
+ finish();
+ RepositoriesApi.deleteRepository((int) tinyDb.getLong("repositoryId", 0));
+ Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
+ RepositorySettingsActivity.this.startActivity(intent);
+ }
+ else {
+
+ Toasty.error(ctx, getString(R.string.genericError));
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ Toasty.error(ctx, getString(R.string.genericServerResponseError));
+ }
+ });
+ }
+
+ private void showRepositoryProperties() {
+
+ dialogProp = new Dialog(ctx, R.style.ThemeOverlay_MaterialComponents_Dialog_Alert);
+
+ if (dialogProp.getWindow() != null) {
+ dialogProp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ }
+
+ propBinding = CustomRepositoryEditPropertiesDialogBinding.inflate(LayoutInflater.from(ctx));
+
+ View view = propBinding.getRoot();
+ dialogProp.setContentView(view);
+
+ propBinding.cancel.setOnClickListener(editProperties -> {
+ dialogProp.dismiss();
+ });
+
+ Call call = RetrofitClient
+ .getInstance(instanceUrl, ctx)
+ .getApiInterface()
+ .getUserRepository(instanceToken, repositoryOwner, repositoryName);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ UserRepositories repoInfo = response.body();
+
+ propBinding.progressBar.setVisibility(View.GONE);
+ propBinding.mainView.setVisibility(View.VISIBLE);
+
+ if (response.code() == 200) {
+
+ assert repoInfo != null;
+ propBinding.repoName.setText(repoInfo.getName());
+ propBinding.repoWebsite.setText(repoInfo.getWebsite());
+ propBinding.repoDescription.setText(repoInfo.getDescription());
+ propBinding.repoPrivate.setChecked(repoInfo.getPrivateFlag());
+ propBinding.repoAsTemplate.setChecked(repoInfo.isTemplate());
+
+ propBinding.repoEnableIssues.setChecked(repoInfo.getHas_issues());
+
+ propBinding.repoEnableIssues.setOnCheckedChangeListener((buttonView, isChecked) -> {
+
+ if (isChecked) {
+ propBinding.repoEnableTimer.setVisibility(View.VISIBLE);
+ }
+ else {
+ propBinding.repoEnableTimer.setVisibility(View.GONE);
+ }
+ });
+
+ if(repoInfo.getInternal_tracker() != null) {
+ propBinding.repoEnableTimer.setChecked(repoInfo.getInternal_tracker().isEnable_time_tracker());
+ }
+ else {
+ propBinding.repoEnableTimer.setVisibility(View.GONE);
+ }
+ propBinding.repoEnableWiki.setChecked(repoInfo.isHas_wiki());
+ propBinding.repoEnablePr.setChecked(repoInfo.isHas_pull_requests());
+ propBinding.repoEnableMerge.setChecked(repoInfo.isAllow_merge_commits());
+ propBinding.repoEnableRebase.setChecked(repoInfo.isAllow_rebase());
+ propBinding.repoEnableSquash.setChecked(repoInfo.isAllow_squash_merge());
+ propBinding.repoEnableForceMerge.setChecked(repoInfo.isAllow_rebase_explicit());
+
+ }
+ else {
+
+ Toasty.error(ctx, getString(R.string.genericError));
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ Toasty.error(ctx, getString(R.string.genericServerResponseError));
+ }
+ });
+
+ propBinding.save.setOnClickListener(saveProperties -> saveRepositoryProperties(String.valueOf(propBinding.repoName.getText()),
+ String.valueOf(propBinding.repoWebsite.getText()),
+ String.valueOf(propBinding.repoDescription.getText()),
+ propBinding.repoPrivate.isChecked(), propBinding.repoAsTemplate.isChecked(),
+ propBinding.repoEnableIssues.isChecked(), propBinding.repoEnableWiki.isChecked(),
+ propBinding.repoEnablePr.isChecked(), propBinding.repoEnableTimer.isChecked(),
+ propBinding.repoEnableMerge.isChecked(), propBinding.repoEnableRebase.isChecked(),
+ propBinding.repoEnableSquash.isChecked(), propBinding.repoEnableForceMerge.isChecked()));
+
+ dialogProp.show();
+
+ }
+
+ private void saveRepositoryProperties(String repoName, String repoWebsite, String repoDescription,
+ boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues, boolean repoEnableWiki,
+ boolean repoEnablePr, boolean repoEnableTimer, boolean repoEnableMerge, boolean repoEnableRebase,
+ boolean repoEnableSquash, boolean repoEnableForceMerge) {
+
+ UserRepositories.internalTimeTrackerObject repoPropsTimeTracker = new UserRepositories.internalTimeTrackerObject(repoEnableTimer);
+
+ UserRepositories repoProps;
+ if(!repoEnableIssues) {
+ repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoEnableMerge,
+ repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
+ }
+ else {
+ repoProps = new UserRepositories(repoName, repoWebsite, repoDescription, repoPrivate, repoAsTemplate, repoEnableIssues, repoEnableWiki, repoEnablePr, repoPropsTimeTracker, repoEnableMerge,
+ repoEnableRebase, repoEnableSquash, repoEnableForceMerge);
+ }
+
+ Call propsCall = RetrofitClient
+ .getInstance(instanceUrl, ctx)
+ .getApiInterface()
+ .updateRepositoryProperties(instanceToken, repositoryOwner, repositoryName, repoProps);
+
+ propsCall.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ propBinding.save.setVisibility(View.GONE);
+ propBinding.processingRequest.setVisibility(View.VISIBLE);
+
+ if (response.code() == 200) {
+
+ dialogProp.dismiss();
+ Toasty.success(ctx, getString(R.string.repoPropertiesSaveSuccess));
+
+ if(!repositoryName.equals(repoName)) {
+
+ finish();
+ RepositoriesApi.updateRepositoryOwnerAndName(repositoryOwner, repoName, (int) tinyDb.getLong("repositoryId", 0));
+ Intent intent = new Intent(RepositorySettingsActivity.this, MainActivity.class);
+ RepositorySettingsActivity.this.startActivity(intent);
+
+ }
+ }
+ else {
+
+ Toasty.error(ctx, getString(R.string.genericError));
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ Toasty.error(ctx, getString(R.string.genericServerResponseError));
+ }
+ });
+ }
+
+ private void initCloseListener() {
+ onClickListener = view -> finish();
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java
index bd9b146a..5cc2e917 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java
@@ -286,7 +286,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter";
holder.subject.setText(Html.fromHtml(subjectId + " " + notificationThread.getSubject().getTitle()));
- holder.repository.setText(notificationThread.getRepository().getFullname());
+ holder.repository.setText(notificationThread.getRepository().getFullName());
if(notificationThread.isPinned()) {
holder.pinned.setVisibility(View.VISIBLE);
@@ -120,7 +120,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter repositoriesDao.updateRepositoryOwnerAndName(repositoryOwner, repositoryName, repositoryId)).start();
+ }
+
public static void deleteRepositoriesByAccount(final int repoAccountId) {
new Thread(() -> repositoriesDao.deleteRepositoriesByAccount(repoAccountId)).start();
diff --git a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetRepoFragment.java b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetRepoFragment.java
index 3be94f4d..dd097632 100644
--- a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetRepoFragment.java
+++ b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetRepoFragment.java
@@ -41,6 +41,8 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
TextView unWatchRepository = v.findViewById(R.id.unWatchRepository);
TextView shareRepository = v.findViewById(R.id.shareRepository);
TextView copyRepoUrl = v.findViewById(R.id.copyRepoUrl);
+ View repoSettingsDivider = v.findViewById(R.id.repoSettingsDivider);
+ TextView repoSettings = v.findViewById(R.id.repoSettings);
createLabel.setOnClickListener(v112 -> {
@@ -49,6 +51,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
});
if(tinyDb.getBoolean("hasIssues")) {
+
createIssue.setVisibility(View.VISIBLE);
createIssue.setOnClickListener(v12 -> {
@@ -57,6 +60,7 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
});
}
else {
+
createIssue.setVisibility(View.GONE);
}
@@ -67,13 +71,24 @@ public class BottomSheetRepoFragment extends BottomSheetDialogFragment {
});
if (tinyDb.getBoolean("isRepoAdmin")) {
+
+ repoSettings.setOnClickListener(repoSettingsView -> {
+
+ bmListener.onButtonClicked("repoSettings");
+ dismiss();
+ });
+
addCollaborator.setOnClickListener(v1 -> {
bmListener.onButtonClicked("addCollaborator");
dismiss();
});
- } else {
+ }
+ else {
+
addCollaborator.setVisibility(View.GONE);
+ repoSettingsDivider.setVisibility(View.GONE);
+ repoSettings.setVisibility(View.GONE);
}
createRelease.setOnClickListener(v14 -> {
diff --git a/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java
index 59c8d783..a07f442a 100644
--- a/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java
+++ b/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java
@@ -337,7 +337,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap
tinyDB.putString("issueNumber", issueUrl.substring(issueUrl.lastIndexOf("/") + 1));
tinyDB.putString("issueType", notificationThread.getSubject().getType());
- tinyDB.putString("repoFullName", notificationThread.getRepository().getFullname());
+ tinyDB.putString("repoFullName", notificationThread.getRepository().getFullName());
startActivity(intent);
diff --git a/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java b/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java
index d978200f..bdf79e30 100644
--- a/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java
+++ b/app/src/main/java/org/mian/gitnex/fragments/RepoInfoFragment.java
@@ -16,7 +16,6 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import org.mian.gitnex.R;
@@ -35,7 +34,6 @@ import org.mian.gitnex.models.UserRepositories;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
-import java.util.Objects;
import io.noties.markwon.AbstractMarkwonPlugin;
import io.noties.markwon.Markwon;
import io.noties.markwon.core.CorePlugin;
@@ -44,7 +42,6 @@ import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.ext.tables.TablePlugin;
import io.noties.markwon.ext.tasklist.TaskListPlugin;
import io.noties.markwon.html.HtmlPlugin;
-import io.noties.markwon.image.AsyncDrawable;
import io.noties.markwon.image.DefaultMediaDecoder;
import io.noties.markwon.image.ImageItem;
import io.noties.markwon.image.ImagesPlugin;
@@ -164,17 +161,9 @@ public class RepoInfoFragment extends Fragment {
toggleExpandViewMeta();
}
- fileContentsFrameHeader.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- toggleExpandView();
- }
- });
+ fileContentsFrameHeader.setOnClickListener(v1 -> toggleExpandView());
- repoMetaFrameHeader.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- toggleExpandViewMeta();
- }
- });
+ repoMetaFrameHeader.setOnClickListener(v12 -> toggleExpandViewMeta());
repoMetaStarsFrame.setOnClickListener(metaStars -> {
@@ -404,46 +393,37 @@ public class RepoInfoFragment extends Fragment {
if (response.code() == 200) {
- final Markwon markwon = Markwon.builder(Objects.requireNonNull(getContext()))
+ final Markwon markwon = Markwon.builder(requireContext())
.usePlugin(CorePlugin.create())
- .usePlugin(ImagesPlugin.create(new ImagesPlugin.ImagesConfigure() {
- @Override
- public void configureImages(@NonNull ImagesPlugin plugin) {
- plugin.addSchemeHandler(new SchemeHandler() {
- @NonNull
- @Override
- public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
+ .usePlugin(ImagesPlugin.create(plugin -> {
+ plugin.addSchemeHandler(new SchemeHandler() {
+ @NonNull
+ @Override
+ public ImageItem handle(@NonNull String raw, @NonNull Uri uri) {
- final int resourceId = getContext().getResources().getIdentifier(
- raw.substring("drawable://".length()),
- "drawable",
- getContext().getPackageName());
+ final int resourceId = requireContext().getResources().getIdentifier(
+ raw.substring("drawable://".length()),
+ "drawable",
+ requireContext().getPackageName());
- final Drawable drawable = getContext().getDrawable(resourceId);
+ final Drawable drawable = requireContext().getDrawable(resourceId);
- assert drawable != null;
- return ImageItem.withResult(drawable);
- }
+ assert drawable != null;
+ return ImageItem.withResult(drawable);
+ }
- @NonNull
- @Override
- public Collection supportedSchemes() {
- return Collections.singleton("drawable");
- }
- });
- plugin.placeholderProvider(new ImagesPlugin.PlaceholderProvider() {
- @Nullable
- @Override
- public Drawable providePlaceholder(@NonNull AsyncDrawable drawable) {
- return null;
- }
- });
- plugin.addMediaDecoder(GifMediaDecoder.create(false));
- plugin.addMediaDecoder(SvgMediaDecoder.create(getContext().getResources()));
- plugin.addMediaDecoder(SvgMediaDecoder.create());
- plugin.defaultMediaDecoder(DefaultMediaDecoder.create(getContext().getResources()));
- plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
- }
+ @NonNull
+ @Override
+ public Collection supportedSchemes() {
+ return Collections.singleton("drawable");
+ }
+ });
+ plugin.placeholderProvider(drawable -> null);
+ plugin.addMediaDecoder(GifMediaDecoder.create(false));
+ plugin.addMediaDecoder(SvgMediaDecoder.create(requireContext().getResources()));
+ plugin.addMediaDecoder(SvgMediaDecoder.create());
+ plugin.defaultMediaDecoder(DefaultMediaDecoder.create(requireContext().getResources()));
+ plugin.defaultMediaDecoder(DefaultMediaDecoder.create());
}))
.usePlugin(new AbstractMarkwonPlugin() {
@Override
@@ -454,8 +434,8 @@ public class RepoInfoFragment extends Fragment {
.linkColor(getResources().getColor(R.color.lightBlue));
}
})
- .usePlugin(TablePlugin.create(getContext()))
- .usePlugin(TaskListPlugin.create(getContext()))
+ .usePlugin(TablePlugin.create(requireContext()))
+ .usePlugin(TaskListPlugin.create(requireContext()))
.usePlugin(HtmlPlugin.create())
.usePlugin(StrikethroughPlugin.create())
.usePlugin(LinkifyPlugin.create())
diff --git a/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java b/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java
index 843614cf..34c1457a 100644
--- a/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java
+++ b/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java
@@ -127,6 +127,12 @@ public interface ApiInterface {
@GET("repos/{owner}/{repo}") // get repo information
Call getUserRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
+ @PATCH("repos/{owner}/{repo}") // patch/update repository properties
+ Call updateRepositoryProperties(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Body UserRepositories jsonStr);
+
+ @DELETE("repos/{owner}/{repo}") // delete repository
+ Call deleteRepository(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName);
+
@GET("repos/{owner}/{repo}/issues") // get issues by repo
Call> getIssues(@Header("Authorization") String token, @Path("owner") String owner, @Path("repo") String repo, @Query("page") int page, @Query("limit") int limit, @Query("type") String requestType, @Query("state") String issueState);
diff --git a/app/src/main/java/org/mian/gitnex/models/UserRepositories.java b/app/src/main/java/org/mian/gitnex/models/UserRepositories.java
index 440d6644..7fe82c0f 100644
--- a/app/src/main/java/org/mian/gitnex/models/UserRepositories.java
+++ b/app/src/main/java/org/mian/gitnex/models/UserRepositories.java
@@ -32,12 +32,134 @@ public class UserRepositories {
private Boolean has_issues;
private String avatar_url;
private boolean archived;
+ private boolean allow_merge_commits;
+ private boolean allow_rebase;
+ private boolean allow_rebase_explicit;
+ private boolean allow_squash_merge;
+ private boolean has_pull_requests;
+ private boolean has_wiki;
+ private boolean ignore_whitespace_conflicts;
+ private boolean template;
+
+ private permissionsObject permissions;
+ private externalIssueTrackerObject external_tracker;
+ private externalWikiObject external_wiki;
+ private internalTimeTrackerObject internal_tracker;
public UserRepositories(String body) {
this.name = name;
}
- private permissionsObject permissions;
+ public UserRepositories(String name, String website, String description,
+ boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues,
+ boolean repoEnableWiki, boolean repoEnablePr,
+ boolean repoEnableMerge, boolean repoEnableRebase, boolean repoEnableSquash, boolean repoEnableForceMerge) {
+
+ this.name = name;
+ this.website = website;
+ this.description = description;
+ this.privateFlag = repoPrivate;
+ this.template = repoAsTemplate;
+ this.has_issues = repoEnableIssues;
+ this.has_wiki = repoEnableWiki;
+ this.has_pull_requests = repoEnablePr;
+ this.allow_merge_commits = repoEnableMerge;
+ this.allow_rebase = repoEnableRebase;
+ this.allow_squash_merge = repoEnableSquash;
+ this.allow_rebase_explicit = repoEnableForceMerge;
+ }
+
+ public UserRepositories(String name, String website, String description,
+ boolean repoPrivate, boolean repoAsTemplate, boolean repoEnableIssues,
+ boolean repoEnableWiki, boolean repoEnablePr, internalTimeTrackerObject repoEnableTimer,
+ boolean repoEnableMerge, boolean repoEnableRebase, boolean repoEnableSquash, boolean repoEnableForceMerge) {
+
+ this.name = name;
+ this.website = website;
+ this.description = description;
+ this.privateFlag = repoPrivate;
+ this.template = repoAsTemplate;
+ this.has_issues = repoEnableIssues;
+ this.has_wiki = repoEnableWiki;
+ this.has_pull_requests = repoEnablePr;
+ this.internal_tracker = repoEnableTimer;
+ this.allow_merge_commits = repoEnableMerge;
+ this.allow_rebase = repoEnableRebase;
+ this.allow_squash_merge = repoEnableSquash;
+ this.allow_rebase_explicit = repoEnableForceMerge;
+ }
+
+ public static class internalTimeTrackerObject {
+
+ private boolean allow_only_contributors_to_track_time;
+ private boolean enable_issue_dependencies;
+ private boolean enable_time_tracker;
+
+ public internalTimeTrackerObject(boolean enable_time_tracker) {
+
+ this.enable_time_tracker = enable_time_tracker;
+ }
+
+ public boolean isAllow_only_contributors_to_track_time() {
+
+ return allow_only_contributors_to_track_time;
+ }
+
+ public boolean isEnable_issue_dependencies() {
+
+ return enable_issue_dependencies;
+ }
+
+ public boolean isEnable_time_tracker() {
+
+ return enable_time_tracker;
+ }
+
+ }
+
+ public static class externalWikiObject {
+
+ private String external_wiki_url;
+
+ public externalWikiObject(String external_wiki_url) {
+
+ this.external_wiki_url = external_wiki_url;
+ }
+
+ public String getExternal_wiki_url() {
+
+ return external_wiki_url;
+ }
+
+ }
+
+ public static class externalIssueTrackerObject {
+
+ private String external_tracker_format;
+ private String external_tracker_style;
+ private String external_tracker_url;
+
+ public externalIssueTrackerObject(String external_tracker_url) {
+
+ this.external_tracker_url = external_tracker_url;
+ }
+
+ public String getExternal_tracker_format() {
+
+ return external_tracker_format;
+ }
+
+ public String getExternal_tracker_style() {
+
+ return external_tracker_style;
+ }
+
+ public String getExternal_tracker_url() {
+
+ return external_tracker_url;
+ }
+
+ }
public static class permissionsObject {
@@ -72,7 +194,7 @@ public class UserRepositories {
return name;
}
- public String getFullname() {
+ public String getFullName() {
return full_name;
}
@@ -192,4 +314,64 @@ public class UserRepositories {
return archived;
}
+ public String getFull_name() {
+
+ return full_name;
+ }
+
+ public boolean isAllow_merge_commits() {
+
+ return allow_merge_commits;
+ }
+
+ public boolean isAllow_rebase() {
+
+ return allow_rebase;
+ }
+
+ public boolean isAllow_rebase_explicit() {
+
+ return allow_rebase_explicit;
+ }
+
+ public boolean isAllow_squash_merge() {
+
+ return allow_squash_merge;
+ }
+
+ public boolean isHas_pull_requests() {
+
+ return has_pull_requests;
+ }
+
+ public boolean isHas_wiki() {
+
+ return has_wiki;
+ }
+
+ public boolean isIgnore_whitespace_conflicts() {
+
+ return ignore_whitespace_conflicts;
+ }
+
+ public boolean isTemplate() {
+
+ return template;
+ }
+
+ public externalIssueTrackerObject getExternal_tracker() {
+
+ return external_tracker;
+ }
+
+ public externalWikiObject getExternal_wiki() {
+
+ return external_wiki;
+ }
+
+ public internalTimeTrackerObject getInternal_tracker() {
+
+ return internal_tracker;
+ }
+
}
diff --git a/app/src/main/res/drawable/ic_migrate.xml b/app/src/main/res/drawable/ic_migrate.xml
new file mode 100644
index 00000000..b5c43f59
--- /dev/null
+++ b/app/src/main/res/drawable/ic_migrate.xml
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/app/src/main/res/layout/activity_repository_settings.xml b/app/src/main/res/layout/activity_repository_settings.xml
new file mode 100644
index 00000000..d84f016c
--- /dev/null
+++ b/app/src/main/res/layout/activity_repository_settings.xml
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/bottom_sheet_repo.xml b/app/src/main/res/layout/bottom_sheet_repo.xml
index 54495a8b..877eafa9 100644
--- a/app/src/main/res/layout/bottom_sheet_repo.xml
+++ b/app/src/main/res/layout/bottom_sheet_repo.xml
@@ -189,6 +189,27 @@
android:textSize="16sp"
android:padding="12dp" />
+
+
+
+
diff --git a/app/src/main/res/layout/custom_repository_delete_dialog.xml b/app/src/main/res/layout/custom_repository_delete_dialog.xml
new file mode 100644
index 00000000..a16fe896
--- /dev/null
+++ b/app/src/main/res/layout/custom_repository_delete_dialog.xml
@@ -0,0 +1,109 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/custom_repository_edit_properties_dialog.xml b/app/src/main/res/layout/custom_repository_edit_properties_dialog.xml
new file mode 100644
index 00000000..47db4be1
--- /dev/null
+++ b/app/src/main/res/layout/custom_repository_edit_properties_dialog.xml
@@ -0,0 +1,231 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 437868aa..aaed2443 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -661,4 +661,24 @@
Read
Unread
+ Repository Settings
+ Edit Properties
+ Delete Repository
+ Be careful, this operation CANNOT be undone!
+ Set as Template
+ Enable Issues
+ External Issue Tracker Url
+ Enable Wiki
+ External Wiki Url
+ Enable Pull Requests
+ Enable Time Tracker
+ Enable Merge Commits
+ Enable Rebase
+ Enable Squash and Merge
+ Enable Rebase with Merge Commits (——no-ff)
+ Repository properties updated successfully
+ Things to know before deletion:\n\n- This operation CANNOT be undone.\n- This operation will permanently delete the repository including code, issues, comments, wiki data and collaborator settings.\n\nEnter the repository name as confirmation
+ Repository name does not match
+ Repository deleted successfully
+