diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f8c2367c..ddf3f31c 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/RepoForksActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoForksActivity.java
new file mode 100644
index 00000000..dc27b254
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/activities/RepoForksActivity.java
@@ -0,0 +1,295 @@
+package org.mian.gitnex.activities;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.Handler;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.SearchView;
+import androidx.appcompat.widget.Toolbar;
+import androidx.recyclerview.widget.DividerItemDecoration;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import org.mian.gitnex.R;
+import org.mian.gitnex.adapters.RepoForksAdapter;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.helpers.Authorization;
+import org.mian.gitnex.helpers.StaticGlobalVariables;
+import org.mian.gitnex.helpers.TinyDB;
+import org.mian.gitnex.helpers.Version;
+import org.mian.gitnex.models.UserRepositories;
+import java.util.ArrayList;
+import java.util.List;
+import retrofit2.Call;
+import retrofit2.Callback;
+import retrofit2.Response;
+
+/**
+ * Author M M Arif
+ */
+
+public class RepoForksActivity extends BaseActivity {
+
+ final Context ctx = this;
+ private Context appCtx;
+ private View.OnClickListener onClickListener;
+ private TextView noData;
+ private ProgressBar progressBar;
+ private String TAG = "RepositoryForks";
+ private int resultLimit = StaticGlobalVariables.resultLimitOldGiteaInstances;
+ private int pageSize = 1;
+
+ private RecyclerView recyclerView;
+ private List forksList;
+ private RepoForksAdapter adapter;
+
+ @Override
+ protected int getLayoutResourceId() {
+
+ return R.layout.activity_forks;
+ }
+
+ @SuppressLint("DefaultLocale")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ appCtx = getApplicationContext();
+ Toolbar toolbar = findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ TinyDB tinyDb = new TinyDB(appCtx);
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String loginUid = tinyDb.getString("loginUid");
+ final String instanceToken = "token " + tinyDb.getString(loginUid + "-token");
+
+ String repoFullNameForForks = getIntent().getStringExtra("repoFullNameForForks");
+ assert repoFullNameForForks != null;
+ String[] parts = repoFullNameForForks.split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ TextView toolbar_title = findViewById(R.id.toolbar_title);
+ toolbar_title.setMovementMethod(new ScrollingMovementMethod());
+ toolbar_title.setText(String.format("%s : %s", ctx.getResources().getString(R.string.infoTabRepoForksCount), repoName));
+
+ ImageView closeActivity = findViewById(R.id.close);
+ noData = findViewById(R.id.noData);
+ progressBar = findViewById(R.id.progress_bar);
+ SwipeRefreshLayout swipeRefresh = findViewById(R.id.pullToRefresh);
+
+ initCloseListener();
+ closeActivity.setOnClickListener(onClickListener);
+
+ // if gitea is 1.12 or higher use the new limit (resultLimitNewGiteaInstances)
+ if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12")) {
+ resultLimit = StaticGlobalVariables.resultLimitNewGiteaInstances;
+ }
+
+ recyclerView = findViewById(R.id.recyclerView);
+ forksList = new ArrayList<>();
+
+ DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
+ DividerItemDecoration.VERTICAL);
+ recyclerView.addItemDecoration(dividerItemDecoration);
+
+ swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
+
+ swipeRefresh.setRefreshing(false);
+ loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
+ adapter.notifyDataChanged();
+
+ }, 200));
+
+ adapter = new RepoForksAdapter(ctx, forksList);
+ adapter.setLoadMoreListener(() -> recyclerView.post(() -> {
+
+ if(forksList.size() == resultLimit || pageSize == resultLimit) {
+
+ int page = (forksList.size() + resultLimit) / resultLimit;
+ loadMore(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, page, resultLimit);
+
+ }
+
+ }));
+
+ recyclerView.setHasFixedSize(true);
+ recyclerView.setLayoutManager(new LinearLayoutManager(ctx));
+ recyclerView.setAdapter(adapter);
+
+ loadInitial(instanceUrl, Authorization.returnAuthentication(ctx, loginUid, instanceToken), repoOwner, repoName, pageSize, resultLimit);
+
+ }
+
+ private void loadInitial(String instanceUrl, String instanceToken, String repoOwner, String repoName, int pageSize, int resultLimit) {
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl, ctx)
+ .getApiInterface()
+ .getRepositoryForks(instanceToken, repoOwner, repoName, pageSize, resultLimit);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull Response> response) {
+
+ if(response.isSuccessful()) {
+
+ assert response.body() != null;
+ if(response.body().size() > 0) {
+
+ forksList.clear();
+ forksList.addAll(response.body());
+ adapter.notifyDataChanged();
+ noData.setVisibility(View.GONE);
+
+ }
+ else {
+ forksList.clear();
+ adapter.notifyDataChanged();
+ noData.setVisibility(View.VISIBLE);
+ }
+
+ progressBar.setVisibility(View.GONE);
+
+ }
+ else {
+
+ Log.e(TAG, String.valueOf(response.code()));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+
+ Log.e(TAG, t.toString());
+ }
+
+ });
+
+ }
+
+ private void loadMore(String instanceUrl, String instanceToken, String repoOwner, String repoName, int page, int resultLimit) {
+
+ //add loading progress view
+ forksList.add(new UserRepositories("load"));
+ adapter.notifyItemInserted((forksList.size() - 1));
+
+ Call> call = RetrofitClient
+ .getInstance(instanceUrl, ctx)
+ .getApiInterface()
+ .getRepositoryForks(instanceToken, repoOwner, repoName, page, resultLimit);
+
+ call.enqueue(new Callback>() {
+
+ @Override
+ public void onResponse(@NonNull Call> call, @NonNull Response> response) {
+
+ if(response.isSuccessful()) {
+
+ //remove loading view
+ forksList.remove(forksList.size() - 1);
+
+ List result = response.body();
+
+ assert result != null;
+ if(result.size() > 0) {
+
+ pageSize = result.size();
+ forksList.addAll(result);
+
+ }
+ else {
+
+ adapter.setMoreDataAvailable(false);
+
+ }
+
+ adapter.notifyDataChanged();
+
+ }
+ else {
+
+ Log.e(TAG, String.valueOf(response.code()));
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call> call, @NonNull Throwable t) {
+
+ Log.e(TAG, t.toString());
+
+ }
+
+ });
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.search_menu, menu);
+
+ MenuItem searchItem = menu.findItem(R.id.action_search);
+ SearchView searchView = (SearchView) searchItem.getActionView();
+ searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
+
+ searchView.setOnQueryTextListener(new androidx.appcompat.widget.SearchView.OnQueryTextListener() {
+
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+
+ return false;
+ }
+
+ @Override
+ public boolean onQueryTextChange(String newText) {
+
+ filter(newText);
+ return true;
+ }
+
+ });
+
+ return super.onCreateOptionsMenu(menu);
+
+ }
+
+ private void filter(String text) {
+
+ List arr = new ArrayList<>();
+
+ for(UserRepositories d : forksList) {
+ if(d.getName().toLowerCase().contains(text) || d.getDescription().toLowerCase().contains(text)) {
+ arr.add(d);
+ }
+ }
+
+ adapter.updateList(arr);
+ }
+
+ private void initCloseListener() {
+
+ onClickListener = view -> {
+ getIntent().removeExtra("repoFullNameForForks");
+ 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 c36482cb..8001b9c0 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/ExploreRepositoriesAdapter.java
@@ -21,6 +21,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
+import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi;
@@ -180,6 +181,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter {
+
+ Intent intentW = new Intent(context, RepoForksActivity.class);
+ intentW.putExtra("repoFullNameForForks", fullName.getText());
+ context.startActivity(intentW);
+ dialog.dismiss();
+
+ });
+
});
}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
index a15e611f..613794b9 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
@@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
+import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi;
@@ -177,6 +178,7 @@ public class MyReposListAdapter extends RecyclerView.Adapter {
+
+ Intent intentW = new Intent(context, RepoForksActivity.class);
+ intentW.putExtra("repoFullNameForForks", repoFullName.getText());
+ context.startActivity(intentW);
+ dialog.dismiss();
+
+ });
+
});
}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/RepoForksAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/RepoForksAdapter.java
new file mode 100644
index 00000000..82890a0a
--- /dev/null
+++ b/app/src/main/java/org/mian/gitnex/adapters/RepoForksAdapter.java
@@ -0,0 +1,396 @@
+package org.mian.gitnex.adapters;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Typeface;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+import com.amulyakhare.textdrawable.TextDrawable;
+import com.amulyakhare.textdrawable.util.ColorGenerator;
+import com.google.android.material.bottomsheet.BottomSheetDialog;
+import org.mian.gitnex.R;
+import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
+import org.mian.gitnex.activities.RepoDetailActivity;
+import org.mian.gitnex.activities.RepoForksActivity;
+import org.mian.gitnex.activities.RepoStargazersActivity;
+import org.mian.gitnex.activities.RepoWatchersActivity;
+import org.mian.gitnex.clients.PicassoService;
+import org.mian.gitnex.clients.RetrofitClient;
+import org.mian.gitnex.database.api.RepositoriesApi;
+import org.mian.gitnex.database.models.Repository;
+import org.mian.gitnex.helpers.RoundedTransformation;
+import org.mian.gitnex.helpers.TinyDB;
+import org.mian.gitnex.helpers.Toasty;
+import org.mian.gitnex.models.UserRepositories;
+import org.mian.gitnex.models.WatchInfo;
+import java.util.List;
+import retrofit2.Call;
+import retrofit2.Callback;
+
+/**
+ * Author M M Arif
+ */
+
+public class RepoForksAdapter extends RecyclerView.Adapter {
+
+ private Context ctx;
+ private final int TYPE_LOAD = 0;
+ private List forksList;
+ private OnLoadMoreListener loadMoreListener;
+ private boolean isLoading = false;
+ private boolean isMoreDataAvailable = true;
+
+ public RepoForksAdapter(Context ctx, List forksListMain) {
+
+ this.ctx = ctx;
+ this.forksList = forksListMain;
+
+ }
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+
+ LayoutInflater inflater = LayoutInflater.from(ctx);
+
+ if(viewType == TYPE_LOAD) {
+ return new RepoForksAdapter.ForksHolder(inflater.inflate(R.layout.list_repositories, parent, false));
+ }
+ else {
+ return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false));
+ }
+
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+
+ if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) {
+
+ isLoading = true;
+ loadMoreListener.onLoadMore();
+
+ }
+
+ if(getItemViewType(position) == TYPE_LOAD) {
+
+ ((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position));
+
+ }
+
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+
+ if(forksList.get(position).getName() != null) {
+ return TYPE_LOAD;
+ }
+ else {
+ return 1;
+ }
+
+ }
+
+ @Override
+ public int getItemCount() {
+
+ return forksList.size();
+
+ }
+
+ class ForksHolder extends RecyclerView.ViewHolder {
+
+ private ImageView image;
+ private TextView repoName;
+ private TextView repoDescription;
+ private TextView fullName;
+ private CheckBox isRepoAdmin;
+ private ImageView repoPrivatePublic;
+ private TextView repoStars;
+ private TextView repoForks;
+ private TextView repoOpenIssuesCount;
+ private TextView repoType;
+ private LinearLayout archiveRepo;
+ private TextView repoBranch;
+ private ImageView reposDropdownMenu;
+
+ ForksHolder(View itemView) {
+
+ super(itemView);
+
+ repoName = itemView.findViewById(R.id.repoName);
+ repoDescription = itemView.findViewById(R.id.repoDescription);
+ isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
+ image = itemView.findViewById(R.id.imageAvatar);
+ fullName = itemView.findViewById(R.id.repoFullName);
+ repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
+ repoStars = itemView.findViewById(R.id.repoStars);
+ repoForks = itemView.findViewById(R.id.repoForks);
+ repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
+ reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
+ repoType = itemView.findViewById(R.id.repoType);
+ archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
+ repoBranch = itemView.findViewById(R.id.repoBranch);
+
+ }
+
+ @SuppressLint("SetTextI18n")
+ void bindData(UserRepositories forksModel) {
+
+ repoDescription.setVisibility(View.GONE);
+ repoBranch.setText(forksModel.getDefault_branch());
+
+ ColorGenerator generator = ColorGenerator.MATERIAL;
+ int color = generator.getColor(forksModel.getName());
+ String firstCharacter = String.valueOf(forksModel.getName().charAt(0));
+
+ TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28)
+ .endConfig().buildRoundRect(firstCharacter, color, 3);
+
+ if(forksModel.getAvatar_url() != null) {
+ if(!forksModel.getAvatar_url().equals("")) {
+ PicassoService.getInstance(ctx).get().load(forksModel.getAvatar_url()).placeholder(R.drawable.loader_animated)
+ .transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(image);
+ }
+ else {
+ image.setImageDrawable(drawable);
+ }
+ }
+ else {
+ image.setImageDrawable(drawable);
+ }
+
+ repoName.setText(forksModel.getName());
+
+ if(!forksModel.getDescription().equals("")) {
+ repoDescription.setVisibility(View.VISIBLE);
+ repoDescription.setText(forksModel.getDescription());
+ }
+ fullName.setText(forksModel.getFullname());
+
+ if(forksModel.getPrivateFlag()) {
+ repoPrivatePublic.setImageResource(R.drawable.ic_lock);
+ repoType.setText(R.string.strPrivate);
+ }
+ else {
+ repoPrivatePublic.setVisibility(View.GONE);
+ repoType.setText(R.string.strPublic);
+ }
+
+ repoStars.setText(forksModel.getStars_count());
+ repoForks.setText(forksModel.getForks_count());
+ repoOpenIssuesCount.setText(forksModel.getOpen_issues_count());
+
+ if(isRepoAdmin == null) {
+ isRepoAdmin = new CheckBox(ctx);
+ }
+ isRepoAdmin.setChecked(forksModel.getPermissions().isAdmin());
+
+ if(forksModel.isArchived()) {
+ archiveRepo.setVisibility(View.VISIBLE);
+ }
+ else {
+ archiveRepo.setVisibility(View.GONE);
+ }
+
+ itemView.setOnClickListener(v -> {
+
+ Context context = v.getContext();
+ TextView repoFullName = v.findViewById(R.id.repoFullName);
+ TextView repoType_ = v.findViewById(R.id.repoType);
+
+ Intent intent = new Intent(context, RepoDetailActivity.class);
+ intent.putExtra("repoFullName", repoFullName.getText().toString());
+
+ TinyDB tinyDb = new TinyDB(context);
+ tinyDb.putString("repoFullName", repoFullName.getText().toString());
+ tinyDb.putString("repoType", repoType_.getText().toString());
+ //tinyDb.putBoolean("resumeIssues", true);
+ tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
+ tinyDb.putString("repoBranch", repoBranch.getText().toString());
+
+ String[] parts = repoFullName.getText().toString().split("/");
+ final String repoOwner = parts[0];
+ final String repoName = parts[1];
+
+ int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
+ RepositoriesApi repositoryData = new RepositoriesApi(context);
+
+ //RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
+ Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
+
+ if(count == 0) {
+
+ long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
+ tinyDb.putLong("repositoryId", id);
+
+ }
+ else {
+
+ Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
+ tinyDb.putLong("repositoryId", data.getRepositoryId());
+
+ }
+
+ //store if user is watching this repo
+ {
+
+ final String instanceUrl = tinyDb.getString("instanceUrl");
+ final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
+
+ WatchInfo watch = new WatchInfo();
+
+ Call call;
+
+ call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
+
+ call.enqueue(new Callback() {
+
+ @Override
+ public void onResponse(@NonNull Call call, @NonNull retrofit2.Response response) {
+
+ if(response.isSuccessful()) {
+
+ assert response.body() != null;
+ tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
+
+ }
+ else {
+
+ tinyDb.putBoolean("repoWatch", false);
+
+ if(response.code() != 404) {
+
+ Toasty.info(context, context.getString(R.string.genericApiStatusError));
+
+ }
+
+ }
+
+ }
+
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull Throwable t) {
+
+ tinyDb.putBoolean("repoWatch", false);
+ Toasty.info(context, context.getString(R.string.genericApiStatusError));
+
+ }
+ });
+
+ }
+
+ context.startActivity(intent);
+
+ });
+
+ reposDropdownMenu.setOnClickListener(v -> {
+
+ final Context context = v.getContext();
+
+ @SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
+
+ TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
+ TextView repoStargazers = view.findViewById(R.id.repoStargazers);
+ TextView repoWatchers = view.findViewById(R.id.repoWatchers);
+ TextView repoForksList = view.findViewById(R.id.repoForksList);
+ TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
+
+ bottomSheetHeader
+ .setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
+ BottomSheetDialog dialog = new BottomSheetDialog(context);
+ dialog.setContentView(view);
+ dialog.show();
+
+ repoOpenInBrowser.setOnClickListener(openInBrowser -> {
+
+ Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
+ intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
+ context.startActivity(intentOpenInBrowser);
+ dialog.dismiss();
+
+ });
+
+ repoStargazers.setOnClickListener(stargazers -> {
+
+ Intent intent = new Intent(context, RepoStargazersActivity.class);
+ intent.putExtra("repoFullNameForStars", fullName.getText());
+ context.startActivity(intent);
+ dialog.dismiss();
+
+ });
+
+ repoWatchers.setOnClickListener(watchers -> {
+
+ Intent intentW = new Intent(context, RepoWatchersActivity.class);
+ intentW.putExtra("repoFullNameForWatchers", fullName.getText());
+ context.startActivity(intentW);
+ dialog.dismiss();
+
+ });
+
+ repoForksList.setOnClickListener(watchers -> {
+
+ Intent intentW = new Intent(context, RepoForksActivity.class);
+ intentW.putExtra("repoFullNameForForks", fullName.getText());
+ context.startActivity(intentW);
+ dialog.dismiss();
+
+ });
+
+ });
+
+ }
+
+ }
+
+ static class LoadHolder extends RecyclerView.ViewHolder {
+
+ LoadHolder(View itemView) {
+
+ super(itemView);
+ }
+
+ }
+
+ public void setMoreDataAvailable(boolean moreDataAvailable) {
+
+ isMoreDataAvailable = moreDataAvailable;
+
+ }
+
+ public void notifyDataChanged() {
+
+ notifyDataSetChanged();
+ isLoading = false;
+
+ }
+
+ public interface OnLoadMoreListener {
+
+ void onLoadMore();
+
+ }
+
+ public void setLoadMoreListener(RepoForksAdapter.OnLoadMoreListener loadMoreListener) {
+
+ this.loadMoreListener = loadMoreListener;
+
+ }
+
+ public void updateList(List list) {
+
+ forksList = list;
+ notifyDataSetChanged();
+ }
+
+}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java
index c3317f01..0cc9280d 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java
@@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
+import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi;
@@ -178,6 +179,7 @@ public class ReposListAdapter extends RecyclerView.Adapter {
+
+ Intent intentW = new Intent(context, RepoForksActivity.class);
+ intentW.putExtra("repoFullNameForForks", fullName.getText());
+ context.startActivity(intentW);
+ dialog.dismiss();
+
+ });
+
});
}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/RepositoriesByOrgAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/RepositoriesByOrgAdapter.java
index ccbe6e88..84e819f0 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/RepositoriesByOrgAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/RepositoriesByOrgAdapter.java
@@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
+import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi;
@@ -173,6 +174,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter {
+ repoStargazers.setOnClickListener(stargazers -> {
Intent intent = new Intent(context, RepoStargazersActivity.class);
intent.putExtra("repoFullNameForStars", fullName.getText());
@@ -198,7 +200,7 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter {
+ repoWatchers.setOnClickListener(watchers -> {
Intent intentW = new Intent(context, RepoWatchersActivity.class);
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
@@ -207,6 +209,15 @@ public class RepositoriesByOrgAdapter extends RecyclerView.Adapter {
+
+ Intent intentW = new Intent(context, RepoForksActivity.class);
+ intentW.putExtra("repoFullNameForForks", fullName.getText());
+ context.startActivity(intentW);
+ dialog.dismiss();
+
+ });
+
});
}
diff --git a/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java
index 0121d27e..f0c9f161 100644
--- a/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java
+++ b/app/src/main/java/org/mian/gitnex/adapters/StarredReposListAdapter.java
@@ -23,6 +23,7 @@ import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
import org.mian.gitnex.activities.RepoDetailActivity;
import org.mian.gitnex.activities.RepoStargazersActivity;
import org.mian.gitnex.activities.RepoWatchersActivity;
+import org.mian.gitnex.activities.RepoForksActivity;
import org.mian.gitnex.clients.PicassoService;
import org.mian.gitnex.clients.RetrofitClient;
import org.mian.gitnex.database.api.RepositoriesApi;
@@ -176,6 +177,7 @@ public class StarredReposListAdapter extends RecyclerView.Adapter {
+
+ Intent intentW = new Intent(context, RepoForksActivity.class);
+ intentW.putExtra("repoFullNameForForks", fullName.getText());
+ context.startActivity(intentW);
+ dialog.dismiss();
+
+ });
+
});
}
diff --git a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java
index 218f90c0..9c4746c9 100644
--- a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java
+++ b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesFragment.java
@@ -75,14 +75,10 @@ public class RepositoriesFragment extends Fragment {
createNewRepo = v.findViewById(R.id.addNewRepo);
- createNewRepo.setOnClickListener(new View.OnClickListener() {
-
- @Override
- public void onClick(View view) {
- Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
- startActivity(intent);
- }
+ createNewRepo.setOnClickListener(view -> {
+ Intent intent = new Intent(view.getContext(), CreateRepoActivity.class);
+ startActivity(intent);
});
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@@ -102,18 +98,11 @@ public class RepositoriesFragment extends Fragment {
}
});
- swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
- @Override
- public void onRefresh() {
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- swipeRefresh.setRefreshing(false);
- RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit);
- }
- }, 50);
- }
- });
+ swipeRefresh.setOnRefreshListener(() -> new Handler().postDelayed(() -> {
+
+ swipeRefresh.setRefreshing(false);
+ RepositoriesListViewModel.loadReposList(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), getContext(), pageSize, resultLimit);
+ }, 50));
fetchDataAsync(instanceUrl, Authorization.returnAuthentication(getContext(), loginUid, instanceToken), pageSize, resultLimit);
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 f03520ce..74f6adf3 100644
--- a/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java
+++ b/app/src/main/java/org/mian/gitnex/interfaces/ApiInterface.java
@@ -321,4 +321,7 @@ public interface ApiInterface {
@DELETE("repos/{owner}/{repo}/branches/{branch}") // delete branch
Call deleteBranch(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Path("branch") String branchName);
+
+ @GET("repos/{owner}/{repo}/forks") // get all repo forks
+ Call> getRepositoryForks(@Header("Authorization") String token, @Path("owner") String ownerName, @Path("repo") String repoName, @Query("page") int page, @Query("limit") int limit);
}
diff --git a/app/src/main/java/org/mian/gitnex/models/Issues.java b/app/src/main/java/org/mian/gitnex/models/Issues.java
index d6fa0d4b..73e60d32 100644
--- a/app/src/main/java/org/mian/gitnex/models/Issues.java
+++ b/app/src/main/java/org/mian/gitnex/models/Issues.java
@@ -31,7 +31,7 @@ public class Issues {
this.body = body;
}
- public class userObject {
+ public static class userObject {
private int id;
private String login;
@@ -71,7 +71,7 @@ public class Issues {
}
- public class labelsObject {
+ public static class labelsObject {
private int id;
private String name;
@@ -95,7 +95,7 @@ public class Issues {
}
}
- public class pullRequestObject {
+ public static class pullRequestObject {
private boolean merged;
private String merged_at;
@@ -109,7 +109,7 @@ public class Issues {
}
}
- public class milestoneObject {
+ public static class milestoneObject {
private int id;
private String title;
@@ -153,7 +153,7 @@ public class Issues {
}
}
- public class assigneesObject {
+ public static class assigneesObject {
private int id;
private String login;
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 7013acad..440d6644 100644
--- a/app/src/main/java/org/mian/gitnex/models/UserRepositories.java
+++ b/app/src/main/java/org/mian/gitnex/models/UserRepositories.java
@@ -33,9 +33,13 @@ public class UserRepositories {
private String avatar_url;
private boolean archived;
+ public UserRepositories(String body) {
+ this.name = name;
+ }
+
private permissionsObject permissions;
- public class permissionsObject {
+ public static class permissionsObject {
private boolean admin;
private boolean push;
diff --git a/app/src/main/res/layout/activity_forks.xml b/app/src/main/res/layout/activity_forks.xml
new file mode 100644
index 00000000..373acba5
--- /dev/null
+++ b/app/src/main/res/layout/activity_forks.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/bottom_sheet_repository_in_list.xml b/app/src/main/res/layout/bottom_sheet_repository_in_list.xml
index ef64ee52..12a17b0b 100644
--- a/app/src/main/res/layout/bottom_sheet_repository_in_list.xml
+++ b/app/src/main/res/layout/bottom_sheet_repository_in_list.xml
@@ -71,6 +71,18 @@
android:textSize="16sp"
android:padding="12dp" />
+
+