From 22cd23525eff0762821f1cdecabd43db4fd3a5b3 Mon Sep 17 00:00:00 2001 From: M M Arif Date: Mon, 4 Oct 2021 15:35:34 +0200 Subject: [PATCH] Explore users (#972) Closes #960 Co-authored-by: M M Arif Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/972 Reviewed-by: qwerty287 Co-authored-by: M M Arif Co-committed-by: M M Arif --- app/build.gradle | 2 +- .../activities/AddNewAccountActivity.java | 2 +- .../mian/gitnex/activities/LoginActivity.java | 2 +- .../gitnex/activities/RepoDetailActivity.java | 14 +- .../ExplorePublicOrganizationsAdapter.java | 3 +- .../gitnex/adapters/ExploreUsersAdapter.java | 154 +++++++++++++++ .../gitnex/adapters/IssueCommentsAdapter.java | 14 +- .../BottomSheetSingleIssueFragment.java | 21 ++- .../gitnex/fragments/ExploreFragment.java | 77 +++----- .../fragments/ExploreIssuesFragment.java | 4 +- .../ExplorePublicOrganizationsFragment.java | 4 +- .../ExploreRepositoriesFragment.java | 4 +- .../fragments/ExploreUsersFragment.java | 176 ++++++++++++++++++ .../mian/gitnex/fragments/IssuesFragment.java | 8 +- .../fragments/MyProfileFollowersFragment.java | 4 +- .../fragments/MyProfileFollowingFragment.java | 4 +- .../fragments/NotificationsFragment.java | 6 +- .../fragments/PullRequestsFragment.java | 108 +++-------- .../fragments/profile/FollowersFragment.java | 4 +- .../fragments/profile/FollowingFragment.java | 4 +- .../profile/OrganizationsFragment.java | 4 +- .../profile/RepositoriesFragment.java | 4 +- .../profile/StarredRepositoriesFragment.java | 4 +- .../org/mian/gitnex/helpers/Constants.java | 3 +- .../main/res/layout/activity_deeplinks.xml | 2 +- app/src/main/res/layout/fragment_explore.xml | 32 +--- .../main/res/layout/fragment_explore_repo.xml | 9 - .../res/layout/fragment_explore_users.xml | 81 ++++++++ app/src/main/res/layout/fragment_issues.xml | 11 +- app/src/main/res/layout/fragment_labels.xml | 2 +- .../res/layout/fragment_notifications.xml | 9 - .../res/layout/fragment_organizations.xml | 11 +- .../fragment_profile_followers_following.xml | 9 - .../res/layout/fragment_pull_requests.xml | 11 +- .../main/res/layout/fragment_repositories.xml | 11 +- .../res/layout/fragment_search_issues.xml | 11 +- .../layout/fragment_starred_repositories.xml | 2 +- .../main/res/layout/fragment_teams_by_org.xml | 2 +- .../main/res/layout/layout_reaction_badge.xml | 2 +- .../res/layout/layout_reaction_button.xml | 2 +- .../main/res/layout/list_explore_users.xml | 41 ++++ app/src/main/res/menu/drawer_menu.xml | 2 +- app/src/main/res/values/settings.xml | 2 +- app/src/main/res/values/strings.xml | 10 +- 44 files changed, 591 insertions(+), 301 deletions(-) create mode 100644 app/src/main/java/org/mian/gitnex/adapters/ExploreUsersAdapter.java create mode 100644 app/src/main/java/org/mian/gitnex/fragments/ExploreUsersFragment.java create mode 100644 app/src/main/res/layout/fragment_explore_users.xml create mode 100644 app/src/main/res/layout/list_explore_users.xml diff --git a/app/build.gradle b/app/build.gradle index ce12f266..a9f16b62 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -62,7 +62,7 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'androidx.appcompat:appcompat:1.4.0-alpha03' implementation 'com.google.android.material:material:1.4.0' - implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01' + implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01' implementation 'androidx.constraintlayout:constraintlayout:2.1.0' implementation "androidx.legacy:legacy-support-v4:1.0.0" implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycle_version" diff --git a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java index 196f8904..e78fb260 100644 --- a/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/AddNewAccountActivity.java @@ -143,7 +143,7 @@ public class AddNewAccountActivity extends BaseActivity { .setMessage(getResources().getString(R.string.versionUnsupportedOld, version.getVersion())).setIcon(R.drawable.ic_warning) .setCancelable(true); - alertDialogBuilder.setNegativeButton(getString(R.string.cancelButton), (dialog, which) -> { + alertDialogBuilder.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> { dialog.dismiss(); }); diff --git a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java index 8a776067..b4a08d08 100644 --- a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java @@ -280,7 +280,7 @@ public class LoginActivity extends BaseActivity { .setIcon(R.drawable.ic_warning) .setCancelable(true); - alertDialogBuilder.setNegativeButton(getString(R.string.cancelButton), (dialog, which) -> { + alertDialogBuilder.setNeutralButton(getString(R.string.cancelButton), (dialog, which) -> { dialog.dismiss(); enableProcessButton(); 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 bd70e623..024f2dbc 100644 --- a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java @@ -542,28 +542,22 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF tinyDB.putString("issueMilestoneFilterId", milestonesList.get(i)); if(getFragmentRefreshListenerFilterIssuesByMilestone() != null) { - getFragmentRefreshListenerFilterIssuesByMilestone().onRefresh(milestonesList.get(i)); } dialogInterface.dismiss(); }); + pBuilder.setNeutralButton(R.string.cancelButton, null); - pBuilder.create().show(); - } - } @Override public void onFailure(@NonNull Call> call, @NonNull Throwable t) { - progressDialog.hide(); Log.e("onFailure", t.toString()); } - }); - } private void chooseBranch() { @@ -594,7 +588,6 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF branchesList.add(branches.getName()); if(tinyDB.getString("repoBranch").equals(branches.getName())) { - selectedBranch = i; } } @@ -607,25 +600,22 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF tinyDB.putString("repoBranch", branchesList.get(i)); if(getFragmentRefreshListenerFiles() != null) { - getFragmentRefreshListenerFiles().onRefresh(branchesList.get(i)); } dialogInterface.dismiss(); }); - pBuilder.setNeutralButton(R.string.cancelButton, null); + pBuilder.setNeutralButton(R.string.cancelButton, null); pBuilder.create().show(); } } @Override public void onFailure(@NonNull Call> call, @NonNull Throwable t) { - progressDialog.hide(); Log.e("onFailure", t.toString()); } }); - } public class SectionsPagerAdapter extends FragmentStatePagerAdapter { diff --git a/app/src/main/java/org/mian/gitnex/adapters/ExplorePublicOrganizationsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ExplorePublicOrganizationsAdapter.java index 6b66a625..b0997770 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ExplorePublicOrganizationsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ExplorePublicOrganizationsAdapter.java @@ -128,6 +128,7 @@ public class ExplorePublicOrganizationsAdapter extends RecyclerView.Adapter list) { organizationsList = list; - notifyDataSetChanged(); + notifyDataChanged(); } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/ExploreUsersAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ExploreUsersAdapter.java new file mode 100644 index 00000000..092f7eb4 --- /dev/null +++ b/app/src/main/java/org/mian/gitnex/adapters/ExploreUsersAdapter.java @@ -0,0 +1,154 @@ +package org.mian.gitnex.adapters; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.Intent; +import android.text.Html; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import org.gitnex.tea4j.models.UserInfo; +import org.mian.gitnex.R; +import org.mian.gitnex.activities.ProfileActivity; +import org.mian.gitnex.clients.PicassoService; +import org.mian.gitnex.helpers.AppUtil; +import org.mian.gitnex.helpers.RoundedTransformation; +import java.util.List; + +/** + * Author M M Arif + */ + +public class ExploreUsersAdapter extends RecyclerView.Adapter { + + private final Context context; + private final int TYPE_LOAD = 0; + private List usersList; + private OnLoadMoreListener loadMoreListener; + private boolean isLoading = false, isMoreDataAvailable = true; + + public ExploreUsersAdapter(Context ctx, List usersListMain) { + this.context = ctx; + this.usersList = usersListMain; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + LayoutInflater inflater = LayoutInflater.from(context); + if(viewType == TYPE_LOAD) { + return new ExploreUsersAdapter.UsersHolder(inflater.inflate(R.layout.list_explore_users, parent, false)); + } + else { + return new ExploreUsersAdapter.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) { + ((ExploreUsersAdapter.UsersHolder) holder).bindData(usersList.get(position)); + } + } + + @Override + public int getItemViewType(int position) { + if(usersList.get(position).getUsername() != null) { + return TYPE_LOAD; + } + else { + return 1; + } + } + + @Override + public int getItemCount() { + return usersList.size(); + } + + class UsersHolder extends RecyclerView.ViewHolder { + private UserInfo userInfo; + private final ImageView userAvatar; + private final TextView userFullName; + private final TextView userName; + + UsersHolder(View itemView) { + super(itemView); + userAvatar = itemView.findViewById(R.id.userAvatar); + userFullName = itemView.findViewById(R.id.userFullName); + userName = itemView.findViewById(R.id.userName); + + itemView.setOnClickListener(loginId -> { + Intent intent = new Intent(context, ProfileActivity.class); + intent.putExtra("username", userInfo.getLogin()); + context.startActivity(intent); + }); + + itemView.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, userInfo.getLogin(), context.getString(R.string.copyLoginIdToClipBoard, userInfo.getLogin())); + return true; + }); + } + + @SuppressLint("SetTextI18n") + void bindData(UserInfo userInfo) { + this.userInfo = userInfo; + int imgRadius = AppUtil.getPixelsFromDensity(context, 3); + userName.setText(userInfo.getUsername()); + PicassoService.getInstance(context).get() + .load(userInfo.getAvatar()) + .placeholder(R.drawable.loader_animated) + .transform(new RoundedTransformation(imgRadius, 0)) + .resize(120, 120) + .centerCrop() + .into(userAvatar); + + if(!userInfo.getFullname().equals("")) { + userFullName.setText(Html.fromHtml(userInfo.getFullname())); + userName.setText(context.getResources().getString(R.string.usernameWithAt, userInfo.getUsername())); + } + else { + userFullName.setText(userInfo.getUsername()); + userName.setVisibility(View.GONE); + } + } + } + + static class LoadHolder extends RecyclerView.ViewHolder { + LoadHolder(View itemView) { + super(itemView); + } + } + + public void setMoreDataAvailable(boolean moreDataAvailable) { + isMoreDataAvailable = moreDataAvailable; + } + + @SuppressLint("NotifyDataSetChanged") + public void notifyDataChanged() { + notifyDataSetChanged(); + isLoading = false; + } + + public interface OnLoadMoreListener { + void onLoadMore(); + } + + public void setLoadMoreListener(OnLoadMoreListener loadMoreListener) { + this.loadMoreListener = loadMoreListener; + } + + public void updateList(List list) { + usersList = list; + notifyDataChanged(); + } +} diff --git a/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java index 218984ac..f16d54d4 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/IssueCommentsAdapter.java @@ -6,6 +6,8 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -113,6 +115,11 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter { + linearLayout.removeView(loadReactions); + reactionSpinner.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 160)); + linearLayout.addView(reactionSpinner); + }, 2500); commentMenuEdit.setOnClickListener(v1 -> { Bundle bundle = new Bundle(); diff --git a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java index fa7bd4b0..7f4daac1 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java @@ -5,6 +5,8 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,24 +15,19 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; -import com.google.gson.JsonElement; import org.mian.gitnex.R; import org.mian.gitnex.actions.IssueActions; import org.mian.gitnex.actions.PullRequestActions; import org.mian.gitnex.activities.EditIssueActivity; import org.mian.gitnex.activities.FileDiffActivity; import org.mian.gitnex.activities.MergePullRequestActivity; -import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.databinding.BottomSheetSingleIssueBinding; import org.mian.gitnex.helpers.AlertDialogs; -import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.Version; import org.mian.gitnex.views.ReactionSpinner; import java.util.Objects; -import retrofit2.Call; -import retrofit2.Callback; /** * Author M M Arif @@ -74,6 +71,12 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { bundle1.putString("repoName", parts[1]); bundle1.putInt("issueId", Integer.parseInt(tinyDB.getString("issueNumber"))); + TextView loadReactions = new TextView(ctx); + loadReactions.setText(Objects.requireNonNull(ctx).getString(R.string.genericWaitFor)); + loadReactions.setGravity(Gravity.CENTER); + loadReactions.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 160)); + linearLayout.addView(loadReactions); + ReactionSpinner reactionSpinner = new ReactionSpinner(ctx, bundle1); reactionSpinner.setOnInteractedListener(() -> { @@ -81,10 +84,14 @@ public class BottomSheetSingleIssueFragment extends BottomSheetDialogFragment { bmListener.onButtonClicked("onResume"); dismiss(); - }); - linearLayout.addView(reactionSpinner); + Handler handler = new Handler(); + handler.postDelayed(() -> { + linearLayout.removeView(loadReactions); + reactionSpinner.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 160)); + linearLayout.addView(reactionSpinner); + }, 2500); if(tinyDB.getString("issueType").equalsIgnoreCase("Pull")) { diff --git a/app/src/main/java/org/mian/gitnex/fragments/ExploreFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ExploreFragment.java index d9f2629c..cce6929e 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ExploreFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ExploreFragment.java @@ -10,10 +10,10 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentPagerAdapter; -import androidx.viewpager.widget.ViewPager; +import androidx.viewpager2.adapter.FragmentStateAdapter; +import androidx.viewpager2.widget.ViewPager2; import com.google.android.material.tabs.TabLayout; +import com.google.android.material.tabs.TabLayoutMediator; import org.mian.gitnex.R; import org.mian.gitnex.activities.MainActivity; import org.mian.gitnex.helpers.TinyDB; @@ -24,9 +24,6 @@ import org.mian.gitnex.helpers.TinyDB; public class ExploreFragment extends Fragment { - private int tabsCount; - public ViewPager mViewPager; - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -36,101 +33,81 @@ public class ExploreFragment extends Fragment { Context ctx = getContext(); TinyDB tinyDB = TinyDB.getInstance(ctx); - ((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navExplore)); + ((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.pageTitleExplore)); + ViewPager2 viewPager = view.findViewById(R.id.containerExplore); + viewPager.setOffscreenPageLimit(1); TabLayout tabLayout = view.findViewById(R.id.tabsExplore); - ViewGroup viewGroup = (ViewGroup) tabLayout.getChildAt(0); - tabsCount = viewGroup.getChildCount(); + ViewGroup vg = (ViewGroup) tabLayout.getChildAt(0); Typeface myTypeface; switch(tinyDB.getInt("customFontId", -1)) { case 0: - myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/roboto.ttf"); + myTypeface = Typeface.createFromAsset(ctx != null ? ctx.getAssets() : null, "fonts/roboto.ttf"); break; case 2: - myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/sourcecodeproregular.ttf"); + myTypeface = Typeface.createFromAsset(ctx != null ? ctx.getAssets() : null, "fonts/sourcecodeproregular.ttf"); break; default: - myTypeface = Typeface.createFromAsset(ctx.getAssets(), "fonts/manroperegular.ttf"); + myTypeface = Typeface.createFromAsset(ctx != null ? ctx.getAssets() : null, "fonts/manroperegular.ttf"); break; - } - for(int j = 0; j < tabsCount; j++) { + viewPager.setAdapter(new ViewPagerAdapter(this)); - ViewGroup vgTab = (ViewGroup) viewGroup.getChildAt(j); + String[] tabTitles = {getResources().getString(R.string.pageTitleRepositories), getResources().getString(R.string.pageTitleIssues), getResources().getString(R.string.pageTitleOrganizations), getResources().getString(R.string.pageTitleUsers)}; + new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabTitles[position])).attach(); + + for (int j = 0; j < tabTitles.length; j++) { + + ViewGroup vgTab = (ViewGroup) vg.getChildAt(j); int tabChildCount = vgTab.getChildCount(); - for(int i = 0; i < tabChildCount; i++) { - + for (int i = 0; i < tabChildCount; i++) { View tabViewChild = vgTab.getChildAt(i); - - if(tabViewChild instanceof TextView) { + if (tabViewChild instanceof TextView) { ((TextView) tabViewChild).setTypeface(myTypeface); } } } - mViewPager = view.findViewById(R.id.containerExplore); - - mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); - tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager)); - - SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager()); - mViewPager.setAdapter(mSectionsPagerAdapter); - - if(requireActivity().getIntent().getBooleanExtra("exploreOrgs", false)) { - mViewPager.setCurrentItem(2); - } - return view; - } - public class SectionsPagerAdapter extends FragmentPagerAdapter { + public static class ViewPagerAdapter extends FragmentStateAdapter { - SectionsPagerAdapter(FragmentManager fm) { - - super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); - } + public ViewPagerAdapter(@NonNull ExploreFragment fa) { super(fa); } @NonNull @Override - public Fragment getItem(int position) { - + public Fragment createFragment(int position) { Fragment fragment = null; - switch(position) { - case 0: // Repositories fragment = new ExploreRepositoriesFragment(); break; - case 1: // Issues fragment = new ExploreIssuesFragment(); break; - case 2: // Organizations fragment = new ExplorePublicOrganizationsFragment(); break; + case 3: // Users + fragment = new ExploreUsersFragment(); + break; } - assert fragment != null; return fragment; - } @Override - public int getCount() { - - return tabsCount; + public int getItemCount() { + return 4; } - } - } diff --git a/app/src/main/java/org/mian/gitnex/fragments/ExploreIssuesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ExploreIssuesFragment.java index 38b90855..badb245a 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ExploreIssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ExploreIssuesFragment.java @@ -136,7 +136,7 @@ public class ExploreIssuesFragment extends Fragment { private void loadMore(String searchKeyword, int resultLimit, int page) { - viewBinding.loadingMoreView.setVisibility(View.VISIBLE); + viewBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context) .queryIssues(Authorization.get(getContext()), searchKeyword, "issues", "open", resultLimit, page); call.enqueue(new Callback>() { @@ -154,7 +154,7 @@ public class ExploreIssuesFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - viewBinding.loadingMoreView.setVisibility(View.GONE); + viewBinding.progressBar.setVisibility(View.GONE); } else { Log.e(TAG, String.valueOf(response.code())); diff --git a/app/src/main/java/org/mian/gitnex/fragments/ExplorePublicOrganizationsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ExplorePublicOrganizationsFragment.java index 6733f5c8..113ed8ba 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ExplorePublicOrganizationsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ExplorePublicOrganizationsFragment.java @@ -122,7 +122,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment { private void loadMore(String token, int page, int resultLimit) { - fragmentPublicOrgBinding.progressLoadMore.setVisibility(View.VISIBLE); + fragmentPublicOrgBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context).getAllOrgs(token, page, resultLimit); call.enqueue(new Callback>() { @Override @@ -140,7 +140,7 @@ public class ExplorePublicOrganizationsFragment extends Fragment { } } adapter.notifyDataChanged(); - fragmentPublicOrgBinding.progressLoadMore.setVisibility(View.GONE); + fragmentPublicOrgBinding.progressBar.setVisibility(View.GONE); } else { Log.e(TAG, String.valueOf(response.code())); diff --git a/app/src/main/java/org/mian/gitnex/fragments/ExploreRepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ExploreRepositoriesFragment.java index 5e8013df..64c906d1 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ExploreRepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ExploreRepositoriesFragment.java @@ -165,7 +165,7 @@ public class ExploreRepositoriesFragment extends Fragment { private void loadMore(String searchKeyword, boolean exploreRepoIncludeTopic, boolean exploreRepoIncludeDescription, boolean exploreRepoIncludeTemplate, boolean exploreRepoOnlyArchived, int resultLimit, int page) { - viewBinding.loadingMoreView.setVisibility(View.VISIBLE); + viewBinding.progressBar.setVisibility(View.VISIBLE); Call call = RetrofitClient.getApiInterface(context) .queryRepos(Authorization.get(getContext()), searchKeyword, repoTypeInclude, sort, order, exploreRepoIncludeTopic, exploreRepoIncludeDescription, exploreRepoIncludeTemplate, exploreRepoOnlyArchived, resultLimit, page); call.enqueue(new Callback() { @@ -183,7 +183,7 @@ public class ExploreRepositoriesFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - viewBinding.loadingMoreView.setVisibility(View.GONE); + viewBinding.progressBar.setVisibility(View.GONE); } else { Log.e(TAG, String.valueOf(response.code())); diff --git a/app/src/main/java/org/mian/gitnex/fragments/ExploreUsersFragment.java b/app/src/main/java/org/mian/gitnex/fragments/ExploreUsersFragment.java new file mode 100644 index 00000000..f2c37f50 --- /dev/null +++ b/app/src/main/java/org/mian/gitnex/fragments/ExploreUsersFragment.java @@ -0,0 +1,176 @@ +package org.mian.gitnex.fragments; + +import android.content.Context; +import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.LinearLayoutManager; +import org.gitnex.tea4j.models.UserInfo; +import org.gitnex.tea4j.models.UserSearch; +import org.mian.gitnex.R; +import org.mian.gitnex.adapters.ExploreUsersAdapter; +import org.mian.gitnex.clients.RetrofitClient; +import org.mian.gitnex.databinding.FragmentExploreUsersBinding; +import org.mian.gitnex.helpers.Authorization; +import org.mian.gitnex.helpers.Constants; +import org.mian.gitnex.helpers.SnackBar; +import org.mian.gitnex.helpers.TinyDB; +import org.mian.gitnex.helpers.Version; +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 + */ + +public class ExploreUsersFragment extends Fragment { + + private FragmentExploreUsersBinding viewBinding; + private Context context; + + private List usersList; + private ExploreUsersAdapter adapter; + private int pageSize; + private final String TAG = Constants.exploreUsers; + private int resultLimit; + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + viewBinding = FragmentExploreUsersBinding.inflate(inflater, container, false); + context = getContext(); + + resultLimit = Constants.getCurrentResultLimit(context); + + usersList = new ArrayList<>(); + adapter = new ExploreUsersAdapter(context, usersList); + + viewBinding.searchKeyword.setOnEditorActionListener((v1, actionId, event) -> { + if(actionId == EditorInfo.IME_ACTION_SEND) { + if(!Objects.requireNonNull(viewBinding.searchKeyword.getText()).toString().equals("")) { + InputMethodManager imm = (InputMethodManager) requireActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(viewBinding.searchKeyword.getWindowToken(), 0); + + viewBinding.progressBar.setVisibility(View.VISIBLE); + loadInitial(Authorization.get(context), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit); + + adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> { + if(usersList.size() == resultLimit || pageSize == resultLimit) { + int page = (usersList.size() + resultLimit) / resultLimit; + loadMore(Authorization.get(context), String.valueOf(viewBinding.searchKeyword.getText()), resultLimit, page); + } + })); + } + } + return false; + }); + + viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> { + viewBinding.pullToRefresh.setRefreshing(false); + loadInitial(Authorization.get(context), "", resultLimit); + adapter.notifyDataChanged(); + }, 200)); + + adapter.setLoadMoreListener(() -> viewBinding.recyclerViewExploreUsers.post(() -> { + if(usersList.size() == resultLimit || pageSize == resultLimit) { + int page = (usersList.size() + resultLimit) / resultLimit; + loadMore(Authorization.get(context), "", resultLimit, page); + } + })); + + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, DividerItemDecoration.VERTICAL); + viewBinding.recyclerViewExploreUsers.setHasFixedSize(true); + viewBinding.recyclerViewExploreUsers.addItemDecoration(dividerItemDecoration); + viewBinding.recyclerViewExploreUsers.setLayoutManager(new LinearLayoutManager(context)); + viewBinding.recyclerViewExploreUsers.setAdapter(adapter); + + loadInitial(Authorization.get(context), "", resultLimit); + + return viewBinding.getRoot(); + } + + private void loadInitial(String token, String searchKeyword, int resultLimit) { + + Call call = RetrofitClient + .getApiInterface(context).getUserBySearch(token, searchKeyword, resultLimit, 1); + call.enqueue(new Callback() { + @Override + public void onResponse(@NonNull Call call, @NonNull Response response) { + if(response.isSuccessful()) { + if(response.body() != null && response.body().getData().size() > 0) { + usersList.clear(); + usersList.addAll(response.body().getData()); + adapter.notifyDataChanged(); + viewBinding.noData.setVisibility(View.GONE); + } + else { + usersList.clear(); + adapter.notifyDataChanged(); + viewBinding.noData.setVisibility(View.VISIBLE); + } + viewBinding.progressBar.setVisibility(View.GONE); + } + else if(response.code() == 404) { + viewBinding.noData.setVisibility(View.VISIBLE); + viewBinding.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 token, String searchKeyword, int resultLimit, int page) { + + viewBinding.progressBar.setVisibility(View.VISIBLE); + Call call = RetrofitClient.getApiInterface(context).getUserBySearch(token, searchKeyword, resultLimit, page); + call.enqueue(new Callback() { + @Override + public void onResponse(@NonNull Call call, @NonNull Response response) { + if(response.isSuccessful()) { + assert response.body() != null; + List result = response.body().getData(); + if(result != null) { + if(result.size() > 0) { + pageSize = result.size(); + usersList.addAll(result); + } + else { + SnackBar.info(context, viewBinding.getRoot(), getString(R.string.noMoreData)); + adapter.setMoreDataAvailable(false); + } + } + adapter.notifyDataChanged(); + viewBinding.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()); + } + }); + } +} diff --git a/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java index 2808760a..51ba72af 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/IssuesFragment.java @@ -142,7 +142,7 @@ public class IssuesFragment extends Fragment { fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE); fragmentIssuesBinding.noDataIssues.setVisibility(View.GONE); - loadInitial(Authorization.get(context), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"), tinyDb.getString("issueMilestoneFilterId")); + loadInitial(Authorization.get(context), repoOwner, repoName, resultLimit, requestType, tinyDb.getString("repoIssuesState"), filterIssueByMilestone); fragmentIssuesBinding.recyclerView.setAdapter(adapter); }); @@ -209,7 +209,7 @@ public class IssuesFragment extends Fragment { private void loadMore(String token, String repoOwner, String repoName, int page, int resultLimit, String requestType, String issueState, String filterByMilestone) { - fragmentIssuesBinding.progressLoadMore.setVisibility(View.VISIBLE); + fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context).getIssues(token, repoOwner, repoName, page, resultLimit, requestType, issueState, filterByMilestone); @@ -229,7 +229,7 @@ public class IssuesFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - fragmentIssuesBinding.progressLoadMore.setVisibility(View.GONE); + fragmentIssuesBinding.progressBar.setVisibility(View.GONE); } else { Log.e(TAG, String.valueOf(response.code())); @@ -287,7 +287,7 @@ public class IssuesFragment extends Fragment { if(d == null || d.getTitle() == null || d.getBody() == null) { continue; } - if(d.getTitle().toLowerCase().contains(text) || d.getBody().toLowerCase().contains(text)) { + if(d.getTitle().toLowerCase().contains(text) || d.getBody().toLowerCase().contains(text) || d.getNumber() == Integer.parseInt(text)) { arr.add(d); } } diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java index 4688a2b8..d31eafd6 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowersFragment.java @@ -116,7 +116,7 @@ public class MyProfileFollowersFragment extends Fragment { private void loadMore(int resultLimit, int page) { - viewBinding.progressLoadMore.setVisibility(View.VISIBLE); + viewBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context) .getFollowers(Authorization.get(getContext()), page, resultLimit); call.enqueue(new Callback>() { @@ -134,7 +134,7 @@ public class MyProfileFollowersFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - viewBinding.progressLoadMore.setVisibility(View.GONE); + viewBinding.progressBar.setVisibility(View.GONE); } else { Log.e(TAG, String.valueOf(response.code())); diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java index 6d70df08..574ce585 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyProfileFollowingFragment.java @@ -115,7 +115,7 @@ public class MyProfileFollowingFragment extends Fragment { private void loadMore(int resultLimit, int page) { - viewBinding.progressLoadMore.setVisibility(View.VISIBLE); + viewBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context) .getFollowing(Authorization.get(getContext()), page, resultLimit); call.enqueue(new Callback>() { @@ -133,7 +133,7 @@ public class MyProfileFollowingFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - viewBinding.progressLoadMore.setVisibility(View.GONE); + viewBinding.progressBar.setVisibility(View.GONE); } else { Log.e(TAG, String.valueOf(response.code())); 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 11d5ade6..44e16da6 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/NotificationsFragment.java @@ -215,7 +215,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap new String[]{"pinned", "read"} : new String[]{"pinned", "unread"}; - viewBinding.loadingMoreView.setVisibility(View.VISIBLE); + viewBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context) .getNotificationThreads(instanceToken, false, filter, Constants.defaultOldestTimestamp, "", @@ -236,7 +236,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap notificationsAdapter.setMoreDataAvailable(false); } notificationsAdapter.notifyDataChanged(); - viewBinding.loadingMoreView.setVisibility(View.GONE); + viewBinding.progressBar.setVisibility(View.GONE); } else { Log.e(TAG, String.valueOf(response.code())); @@ -254,7 +254,7 @@ public class NotificationsFragment extends Fragment implements NotificationsAdap private void onCleanup() { - AppUtil.setMultiVisibility(View.GONE, viewBinding.loadingMoreView, viewBinding.progressBar); + AppUtil.setMultiVisibility(View.GONE, viewBinding.progressBar, viewBinding.progressBar); viewBinding.pullToRefresh.setRefreshing(false); if(currentFilterMode.equalsIgnoreCase("unread")) { diff --git a/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java index 0e30006a..01466ee4 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/PullRequestsFragment.java @@ -12,14 +12,11 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; -import android.widget.ProgressBar; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import org.gitnex.tea4j.models.PullRequests; import org.mian.gitnex.R; @@ -31,7 +28,6 @@ import org.mian.gitnex.helpers.Authorization; import org.mian.gitnex.helpers.Constants; import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.Toasty; -import org.mian.gitnex.helpers.Version; import java.util.ArrayList; import java.util.List; import retrofit2.Call; @@ -44,24 +40,21 @@ import retrofit2.Response; public class PullRequestsFragment extends Fragment { + private FragmentPullRequestsBinding fragmentPullRequestsBinding; private Menu menu; - private ProgressBar mProgressBar; - private RecyclerView recyclerView; + private List prList; private PullRequestsAdapter adapter; - private String TAG = Constants.tagPullRequestsList; + private final String TAG = Constants.tagPullRequestsList; private Context context; private int pageSize = Constants.prPageInit; - private TextView noData; - private int resultLimit = Constants.resultLimitOldGiteaInstances; - private ProgressBar progressLoadMore; + private int resultLimit; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - FragmentPullRequestsBinding fragmentPullRequestsBinding = FragmentPullRequestsBinding.inflate(inflater, container, false); - + fragmentPullRequestsBinding = FragmentPullRequestsBinding.inflate(inflater, container, false); setHasOptionsMenu(true); context = getContext(); @@ -75,43 +68,30 @@ public class PullRequestsFragment extends Fragment { final SwipeRefreshLayout swipeRefresh = fragmentPullRequestsBinding.pullToRefresh; - // if gitea is 1.12 or higher use the new limit - if(new Version(tinyDb.getString("giteaVersion")).higherOrEqual("1.12.0")) { - resultLimit = Constants.resultLimitNewGiteaInstances; - } - - recyclerView = fragmentPullRequestsBinding.recyclerView; + resultLimit = Constants.getCurrentResultLimit(context); prList = new ArrayList<>(); - progressLoadMore = fragmentPullRequestsBinding.progressLoadMore; - mProgressBar = fragmentPullRequestsBinding.progressBar; - noData = fragmentPullRequestsBinding.noData; - swipeRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> { - swipeRefresh.setRefreshing(false); loadInitial(instanceToken, repoOwner, repoName, pageSize, tinyDb.getString("repoPrState"), resultLimit); adapter.notifyDataChanged(); - }, 200)); adapter = new PullRequestsAdapter(getContext(), prList); - adapter.setLoadMoreListener(() -> recyclerView.post(() -> { + adapter.setLoadMoreListener(() -> fragmentPullRequestsBinding.recyclerView.post(() -> { if(prList.size() == resultLimit || pageSize == resultLimit) { - int page = (prList.size() + resultLimit) / resultLimit; loadMore(Authorization.get(getContext()), repoOwner, repoName, page, tinyDb.getString("repoPrState"), resultLimit); - } })); - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL); - recyclerView.setHasFixedSize(true); - recyclerView.addItemDecoration(dividerItemDecoration); - recyclerView.setLayoutManager(new LinearLayoutManager(context)); - recyclerView.setAdapter(adapter); + DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(fragmentPullRequestsBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL); + fragmentPullRequestsBinding.recyclerView.setHasFixedSize(true); + fragmentPullRequestsBinding.recyclerView.addItemDecoration(dividerItemDecoration); + fragmentPullRequestsBinding.recyclerView.setLayoutManager(new LinearLayoutManager(context)); + fragmentPullRequestsBinding.recyclerView.setAdapter(adapter); ((RepoDetailActivity) requireActivity()).setFragmentRefreshListenerPr(prState -> { @@ -125,31 +105,27 @@ public class PullRequestsFragment extends Fragment { prList.clear(); adapter = new PullRequestsAdapter(context, prList); - adapter.setLoadMoreListener(() -> recyclerView.post(() -> { + adapter.setLoadMoreListener(() -> fragmentPullRequestsBinding.recyclerView.post(() -> { if(prList.size() == resultLimit || pageSize == resultLimit) { - int page = (prList.size() + resultLimit) / resultLimit; loadMore(Authorization.get(getContext()), repoOwner, repoName, page, tinyDb.getString("repoPrState"), resultLimit); - } })); tinyDb.putString("repoPrState", prState); - mProgressBar.setVisibility(View.VISIBLE); - noData.setVisibility(View.GONE); + fragmentPullRequestsBinding.progressBar.setVisibility(View.VISIBLE); + fragmentPullRequestsBinding.noData.setVisibility(View.GONE); loadInitial(Authorization.get(context), repoOwner, repoName, pageSize, prState, resultLimit); - recyclerView.setAdapter(adapter); - + fragmentPullRequestsBinding.recyclerView.setAdapter(adapter); }); loadInitial(Authorization.get(getContext()), repoOwner, repoName, pageSize, tinyDb.getString("repoPrState"), resultLimit); return fragmentPullRequestsBinding.getRoot(); - } @Override @@ -164,13 +140,10 @@ public class PullRequestsFragment extends Fragment { final String repoName = parts[1]; if(tinyDb.getBoolean("resumePullRequests")) { - loadInitial(Authorization.get(getContext()), repoOwner, repoName, pageSize, tinyDb.getString("repoPrState"), resultLimit); tinyDb.putBoolean("resumePullRequests", false); tinyDb.putBoolean("prMerged", false); - } - } private void loadInitial(String token, String repoOwner, String repoName, int page, String prState, int resultLimit) { @@ -186,38 +159,26 @@ public class PullRequestsFragment extends Fragment { assert response.body() != null; if(response.body().size() > 0) { - prList.clear(); prList.addAll(response.body()); adapter.notifyDataChanged(); - noData.setVisibility(View.GONE); - + fragmentPullRequestsBinding.noData.setVisibility(View.GONE); } else { - prList.clear(); adapter.notifyDataChanged(); - noData.setVisibility(View.VISIBLE); - + fragmentPullRequestsBinding.noData.setVisibility(View.VISIBLE); } - - mProgressBar.setVisibility(View.GONE); - + fragmentPullRequestsBinding.progressBar.setVisibility(View.GONE); } else if(response.code() == 404) { - - noData.setVisibility(View.VISIBLE); - mProgressBar.setVisibility(View.GONE); - + fragmentPullRequestsBinding.noData.setVisibility(View.VISIBLE); + fragmentPullRequestsBinding.progressBar.setVisibility(View.GONE); } else { - Log.i(TAG, String.valueOf(response.code())); - } - Log.i(TAG, String.valueOf(response.code())); - } @Override @@ -225,14 +186,12 @@ public class PullRequestsFragment extends Fragment { Log.e(TAG, t.toString()); } - }); - } private void loadMore(String token, String repoOwner, String repoName, int page, String prState, int resultLimit) { - progressLoadMore.setVisibility(View.VISIBLE); + fragmentPullRequestsBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context).getPullRequests(token, repoOwner, repoName, page, prState, resultLimit); @@ -245,42 +204,30 @@ public class PullRequestsFragment extends Fragment { //remove loading view prList.remove(prList.size() - 1); - List result = response.body(); assert result != null; if(result.size() > 0) { - pageSize = result.size(); prList.addAll(result); - } else { - Toasty.info(context, getString(R.string.noMoreData)); adapter.setMoreDataAvailable(false); - } - adapter.notifyDataChanged(); - progressLoadMore.setVisibility(View.GONE); - + fragmentPullRequestsBinding.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()); - } - }); } @@ -309,20 +256,15 @@ public class PullRequestsFragment extends Fragment { @Override public boolean onQueryTextSubmit(String query) { - return false; } @Override public boolean onQueryTextChange(String newText) { - filter(newText); return false; - } - }); - } private void filter(String text) { @@ -333,12 +275,10 @@ public class PullRequestsFragment extends Fragment { if(d == null || d.getTitle() == null || d.getBody() == null) { continue; } - if(d.getTitle().toLowerCase().contains(text) || d.getBody().toLowerCase().contains(text)) { + if(d.getTitle().toLowerCase().contains(text) || d.getBody().toLowerCase().contains(text) || d.getNumber() == Integer.parseInt(text)) { arr.add(d); } } - adapter.updateList(arr); } - } diff --git a/app/src/main/java/org/mian/gitnex/fragments/profile/FollowersFragment.java b/app/src/main/java/org/mian/gitnex/fragments/profile/FollowersFragment.java index fa77db3a..372d4d31 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/profile/FollowersFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/profile/FollowersFragment.java @@ -164,7 +164,7 @@ public class FollowersFragment extends Fragment { private void loadMore(String token, String username, int page, int resultLimit) { - fragmentProfileFollowersFollowingBinding.progressLoadMore.setVisibility(View.VISIBLE); + fragmentProfileFollowersFollowingBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient .getApiInterface(context) @@ -190,7 +190,7 @@ public class FollowersFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - fragmentProfileFollowersFollowingBinding.progressLoadMore.setVisibility(View.GONE); + fragmentProfileFollowersFollowingBinding.progressBar.setVisibility(View.GONE); break; case 401: diff --git a/app/src/main/java/org/mian/gitnex/fragments/profile/FollowingFragment.java b/app/src/main/java/org/mian/gitnex/fragments/profile/FollowingFragment.java index dd101818..ee297106 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/profile/FollowingFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/profile/FollowingFragment.java @@ -164,7 +164,7 @@ public class FollowingFragment extends Fragment { private void loadMore(String token, String username, int page, int resultLimit) { - fragmentProfileFollowersFollowingBinding.progressLoadMore.setVisibility(View.VISIBLE); + fragmentProfileFollowersFollowingBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient .getApiInterface(context) @@ -190,7 +190,7 @@ public class FollowingFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - fragmentProfileFollowersFollowingBinding.progressLoadMore.setVisibility(View.GONE); + fragmentProfileFollowersFollowingBinding.progressBar.setVisibility(View.GONE); break; case 401: diff --git a/app/src/main/java/org/mian/gitnex/fragments/profile/OrganizationsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/profile/OrganizationsFragment.java index 61bfae59..33c80a86 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/profile/OrganizationsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/profile/OrganizationsFragment.java @@ -166,7 +166,7 @@ public class OrganizationsFragment extends Fragment { private void loadMore(String token, String username, int page, int resultLimit) { - fragmentOrganizationsBinding.progressLoadMore.setVisibility(View.VISIBLE); + fragmentOrganizationsBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient .getApiInterface(context) @@ -192,7 +192,7 @@ public class OrganizationsFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - fragmentOrganizationsBinding.progressLoadMore.setVisibility(View.GONE); + fragmentOrganizationsBinding.progressBar.setVisibility(View.GONE); break; case 401: diff --git a/app/src/main/java/org/mian/gitnex/fragments/profile/RepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/profile/RepositoriesFragment.java index a2a96777..1fe433a3 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/profile/RepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/profile/RepositoriesFragment.java @@ -165,7 +165,7 @@ public class RepositoriesFragment extends Fragment { private void loadMore(String token, String username, int page, int resultLimit) { - fragmentRepositoriesBinding.progressLoadMore.setVisibility(View.VISIBLE); + fragmentRepositoriesBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient.getApiInterface(context).getUserProfileRepositories(token, username, page, resultLimit); @@ -189,7 +189,7 @@ public class RepositoriesFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - fragmentRepositoriesBinding.progressLoadMore.setVisibility(View.GONE); + fragmentRepositoriesBinding.progressBar.setVisibility(View.GONE); break; case 401: diff --git a/app/src/main/java/org/mian/gitnex/fragments/profile/StarredRepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/profile/StarredRepositoriesFragment.java index ae97c37f..b7f7b6a5 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/profile/StarredRepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/profile/StarredRepositoriesFragment.java @@ -166,7 +166,7 @@ public class StarredRepositoriesFragment extends Fragment { private void loadMore(String token, String username, int page, int resultLimit) { - fragmentRepositoriesBinding.progressLoadMore.setVisibility(View.VISIBLE); + fragmentRepositoriesBinding.progressBar.setVisibility(View.VISIBLE); Call> call = RetrofitClient .getApiInterface(context) @@ -192,7 +192,7 @@ public class StarredRepositoriesFragment extends Fragment { adapter.setMoreDataAvailable(false); } adapter.notifyDataChanged(); - fragmentRepositoriesBinding.progressLoadMore.setVisibility(View.GONE); + fragmentRepositoriesBinding.progressBar.setVisibility(View.GONE); break; case 401: diff --git a/app/src/main/java/org/mian/gitnex/helpers/Constants.java b/app/src/main/java/org/mian/gitnex/helpers/Constants.java index 8c8dca85..8a4ffff9 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/Constants.java +++ b/app/src/main/java/org/mian/gitnex/helpers/Constants.java @@ -20,7 +20,7 @@ public class Constants { // tags public static final String tagMilestonesFragment = "MilestonesFragment"; - public static final String tagPullRequestsList = "PullRequestsListFragment"; + public static final String tagPullRequestsList = "PullRequestFragment"; public static final String tagIssuesList = "IssuesListFragment"; public static final String tagMilestonesAdapter = "MilestonesAdapter"; public static final String draftsApi = "DraftsApi"; @@ -28,6 +28,7 @@ public class Constants { public static final String tagDraftsBottomSheet = "BottomSheetDraftsFragment"; public static final String userAccountsApi = "UserAccountsApi"; public static final String publicOrganizations = "PublicOrganizations"; + public static final String exploreUsers = "ExploreUsers"; public static final String exploreIssues = "ExploreIssues"; public static final String exploreRepositories = "ExploreRepositories"; public static final String tagNotifications = "TagNotifications"; diff --git a/app/src/main/res/layout/activity_deeplinks.xml b/app/src/main/res/layout/activity_deeplinks.xml index b7fd3376..d57a633c 100644 --- a/app/src/main/res/layout/activity_deeplinks.xml +++ b/app/src/main/res/layout/activity_deeplinks.xml @@ -122,7 +122,7 @@ android:id="@+id/explore" android:layout_width="match_parent" android:layout_height="60dp" - android:text="@string/navExplore" + android:text="@string/pageTitleExplore" android:textColor="@color/btnTextColor" android:textSize="16sp" android:layout_marginTop="8dp" /> diff --git a/app/src/main/res/layout/fragment_explore.xml b/app/src/main/res/layout/fragment_explore.xml index 813ff573..ce381c04 100644 --- a/app/src/main/res/layout/fragment_explore.xml +++ b/app/src/main/res/layout/fragment_explore.xml @@ -16,40 +16,20 @@ - - - - - - - - + android:layout_width="match_parent" + android:layout_height="wrap_content" /> - diff --git a/app/src/main/res/layout/fragment_explore_repo.xml b/app/src/main/res/layout/fragment_explore_repo.xml index a705f046..b9ac515a 100644 --- a/app/src/main/res/layout/fragment_explore_repo.xml +++ b/app/src/main/res/layout/fragment_explore_repo.xml @@ -6,15 +6,6 @@ android:background="?attr/primaryBackgroundColor" android:orientation="vertical"> - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_issues.xml b/app/src/main/res/layout/fragment_issues.xml index fb1aa9ec..f8a8d3ac 100644 --- a/app/src/main/res/layout/fragment_issues.xml +++ b/app/src/main/res/layout/fragment_issues.xml @@ -21,22 +21,13 @@ - - - - - - - - - - - - - - + android:hint="@string/exploreIssues"> diff --git a/app/src/main/res/layout/layout_reaction_button.xml b/app/src/main/res/layout/layout_reaction_button.xml index 3fe143a9..9e5df599 100644 --- a/app/src/main/res/layout/layout_reaction_button.xml +++ b/app/src/main/res/layout/layout_reaction_button.xml @@ -16,7 +16,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:textColor="?attr/primaryTextColor" - android:textSize="20sp" + android:textSize="18sp" tools:text="👍" /> diff --git a/app/src/main/res/layout/list_explore_users.xml b/app/src/main/res/layout/list_explore_users.xml new file mode 100644 index 00000000..e00b9c1a --- /dev/null +++ b/app/src/main/res/layout/list_explore_users.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/menu/drawer_menu.xml b/app/src/main/res/menu/drawer_menu.xml index bf084a1e..d0b66fd3 100644 --- a/app/src/main/res/menu/drawer_menu.xml +++ b/app/src/main/res/menu/drawer_menu.xml @@ -32,7 +32,7 @@ + android:title="@string/pageTitleExplore" /> @string/navRepos @string/navOrg @string/pageTitleNotifications - @string/navExplore + @string/pageTitleExplore diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a73f9a13..6595bcb7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,9 +28,7 @@ About Rate GitNex Logout - Explore Administration - Search Issues @@ -58,6 +56,7 @@ Gitea Administration Manage Accounts New Pull Request + Users Demo repo @@ -525,8 +524,11 @@ Closed We cannot reach the server at the moment, please check your server status and try again Copy URL + Hold on ☕ + Explore users + Explore issues Explore repositories Star Repository Unstar Repository @@ -539,7 +541,7 @@ Drafts Root - Unsupported old version(%1$s) of Gitea detected. Please update to latest stable version. If you continue, the app may not function properly + Unsupported old version(%1$s) of Gitea detected. Please update to latest stable version. If you continue, some features may not work. New Gitea version detected! Please UPDATE GitNex! No Gitea detected! Unsupported Version of Gitea @@ -664,7 +666,7 @@ Notifications - No notifications found + All caught up 🚀 Notifications Polling Delay %d Minutes Select Polling Delay