diff --git a/app/build.gradle b/app/build.gradle index 669000b4..0f625a26 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -71,13 +71,13 @@ dependencies { implementation "com.squareup.picasso:picasso:2.71828" implementation 'jp.wasabeef:picasso-transformations:2.4.0' implementation 'jp.co.cyberagent.android:gpuimage:2.1.0' - implementation "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1" + implementation 'com.github.amulyakhare:TextDrawable:558677ea31' implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2' implementation 'org.ocpsoft.prettytime:prettytime:5.0.2.Final' - implementation "com.pes.materialcolorpicker:library:1.2.5" + implementation 'com.github.Pes8:android-material-color-picker-dialog:master' implementation "io.noties.markwon:core:$markwon_version" implementation "io.noties.markwon:ext-latex:$markwon_version" implementation "io.noties.markwon:ext-strikethrough:$markwon_version" diff --git a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java index 1b4c249d..e7564a76 100644 --- a/app/src/main/java/org/mian/gitnex/actions/IssueActions.java +++ b/app/src/main/java/org/mian/gitnex/actions/IssueActions.java @@ -1,9 +1,7 @@ package org.mian.gitnex.actions; -import android.app.Activity; import android.content.Context; import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; import com.google.gson.JsonElement; import org.gitnex.tea4j.models.IssueComments; import org.gitnex.tea4j.models.Issues; diff --git a/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java b/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java index ac5aec67..2c472905 100644 --- a/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/CommitsActivity.java @@ -25,7 +25,6 @@ import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.databinding.ActivityCommitsBinding; import org.mian.gitnex.helpers.Constants; import org.mian.gitnex.helpers.Toasty; -import org.mian.gitnex.helpers.Version; import org.mian.gitnex.helpers.contexts.RepositoryContext; import java.util.ArrayList; import java.util.List; diff --git a/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java b/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java index 71328e3a..ee5f1223 100644 --- a/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/CreatePullRequestActivity.java @@ -25,7 +25,6 @@ import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding; import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.Constants; import org.mian.gitnex.helpers.Toasty; -import org.mian.gitnex.helpers.Version; import org.mian.gitnex.helpers.contexts.RepositoryContext; import java.util.ArrayList; import java.util.Calendar; diff --git a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java index 8f10429b..d63dd8c9 100644 --- a/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/IssueDetailActivity.java @@ -6,7 +6,6 @@ import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.ColorDrawable; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -24,13 +23,13 @@ import android.widget.ScrollView; import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; import androidx.core.text.HtmlCompat; import androidx.core.widget.ImageViewCompat; -import androidx.core.widget.NestedScrollView; import androidx.lifecycle.ViewModelProvider; -import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import com.amulyakhare.textdrawable.TextDrawable; import com.google.gson.JsonElement; import com.vdurmont.emoji.EmojiParser; @@ -54,10 +53,12 @@ import org.mian.gitnex.databinding.CustomAssigneesSelectionDialogBinding; import org.mian.gitnex.databinding.CustomLabelsSelectionDialogBinding; import org.mian.gitnex.fragments.BottomSheetReplyFragment; import org.mian.gitnex.fragments.BottomSheetSingleIssueFragment; +import org.mian.gitnex.fragments.IssuesFragment; import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.ClickListener; import org.mian.gitnex.helpers.ColorInverter; +import org.mian.gitnex.helpers.DividerItemDecorator; import org.mian.gitnex.helpers.LabelWidthCalculator; import org.mian.gitnex.helpers.Markdown; import org.mian.gitnex.helpers.RoundedTransformation; @@ -81,7 +82,7 @@ import retrofit2.Callback; import retrofit2.Response; /** - * Author M M Arif + * @author M M Arif */ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapter.LabelsListAdapterListener, AssigneesListAdapter.AssigneesListAdapterListener, BottomSheetListener { @@ -153,7 +154,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt viewBinding.recyclerView.setNestedScrollingEnabled(false); viewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(ctx)); - DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(viewBinding.recyclerView.getContext(), DividerItemDecoration.VERTICAL); + RecyclerView.ItemDecoration dividerItemDecoration = new DividerItemDecorator(ContextCompat.getDrawable(this, R.drawable.shape_list_divider)); viewBinding.recyclerView.addItemDecoration(dividerItemDecoration); viewBinding.addNewComment.setOnClickListener(v -> { @@ -161,7 +162,6 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt BottomSheetReplyFragment bottomSheetReplyFragment = BottomSheetReplyFragment.newInstance(new Bundle(), issue); bottomSheetReplyFragment.setOnInteractedListener(this::onResume); bottomSheetReplyFragment.show(getSupportFragmentManager(), "replyBottomSheet"); - }); labelsAdapter = new LabelsListAdapter(labelsList, IssueDetailActivity.this, currentLabelsIds); @@ -169,29 +169,6 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds); AssigneesActions.getCurrentIssueAssignees(ctx, repoOwner, repoName, issueIndex, currentAssignees); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - - viewBinding.scrollViewComments.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> { - - if((scrollY - oldScrollY) > 0 && viewBinding.addNewComment.isShown()) { - viewBinding.addNewComment.setVisibility(View.GONE); - } - else if((scrollY - oldScrollY) < 0) { - viewBinding.addNewComment.setVisibility(View.VISIBLE); - } - - if(!viewBinding.scrollViewComments.canScrollVertically(1)) { // bottom - viewBinding.addNewComment.setVisibility(View.GONE); - } - - if(!viewBinding.scrollViewComments.canScrollVertically(-1)) { // top - viewBinding.addNewComment.setVisibility(View.VISIBLE); - } - - }); - - } - viewBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> { viewBinding.pullToRefresh.setRefreshing(false); @@ -420,6 +397,7 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt getSingleIssue(repoOwner, repoName, issueIndex); currentLabelsIds.clear(); new Handler(Looper.getMainLooper()).postDelayed(() -> LabelsActions.getCurrentIssueLabels(ctx, repoOwner, repoName, issueIndex, currentLabelsIds), 1000); + IssuesFragment.resumeIssues = true; } else if(response.code() == 401) { @@ -755,13 +733,13 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt viewBinding.frameLabels.setGravity(Gravity.START | Gravity.TOP); labelsView.setLayoutParams(params); - int height = AppUtil.getPixelsFromDensity(ctx, 25); - int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 15); + int height = AppUtil.getPixelsFromDensity(ctx, 20); + int textSize = AppUtil.getPixelsFromScaledDensity(ctx, 12); TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT) .textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize) .width(LabelWidthCalculator.calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(ctx, 10))) - .height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 5)); + .height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(ctx, 18)); labelsView.setImageDrawable(drawable); viewBinding.frameLabels.addView(labelsView); 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 ab6a6806..53058a91 100644 --- a/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/LoginActivity.java @@ -20,7 +20,12 @@ import org.mian.gitnex.database.api.BaseApi; import org.mian.gitnex.database.api.UserAccountsApi; import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.databinding.ActivityLoginBinding; -import org.mian.gitnex.helpers.*; +import org.mian.gitnex.helpers.AppUtil; +import org.mian.gitnex.helpers.NetworkStatusObserver; +import org.mian.gitnex.helpers.PathsHelper; +import org.mian.gitnex.helpers.Toasty; +import org.mian.gitnex.helpers.UrlHelper; +import org.mian.gitnex.helpers.Version; import org.mian.gitnex.structs.Protocol; import java.net.URI; import java.nio.charset.StandardCharsets; 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 701020a3..4a2d9206 100644 --- a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java @@ -36,9 +36,6 @@ import org.gitnex.tea4j.models.UserRepositories; import org.gitnex.tea4j.models.WatchInfo; import org.mian.gitnex.R; import org.mian.gitnex.clients.RetrofitClient; -import org.mian.gitnex.database.api.BaseApi; -import org.mian.gitnex.database.api.UserAccountsApi; -import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.fragments.BottomSheetIssuesFilterFragment; import org.mian.gitnex.fragments.BottomSheetMilestonesFilterFragment; import org.mian.gitnex.fragments.BottomSheetPullRequestFilterFragment; @@ -53,8 +50,8 @@ import org.mian.gitnex.fragments.PullRequestsFragment; import org.mian.gitnex.fragments.ReleasesFragment; import org.mian.gitnex.fragments.RepoInfoFragment; import org.mian.gitnex.helpers.AppUtil; -import org.mian.gitnex.helpers.contexts.RepositoryContext; import org.mian.gitnex.helpers.Toasty; +import org.mian.gitnex.helpers.contexts.RepositoryContext; import org.mian.gitnex.structs.BottomSheetListener; import org.mian.gitnex.structs.FragmentRefreshListener; import java.util.ArrayList; diff --git a/app/src/main/java/org/mian/gitnex/activities/SettingsAppearanceActivity.java b/app/src/main/java/org/mian/gitnex/activities/SettingsAppearanceActivity.java index 1dcb0c3d..f06e15a1 100644 --- a/app/src/main/java/org/mian/gitnex/activities/SettingsAppearanceActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/SettingsAppearanceActivity.java @@ -100,6 +100,16 @@ public class SettingsAppearanceActivity extends BaseActivity { }); activitySettingsAppearanceBinding.counterBadgeFrame.setOnClickListener(v -> counterBadgesSwitch.setChecked(!counterBadgesSwitch.isChecked())); + // show labels in lists(issues, pr) - default is color dots + activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(tinyDB.getBoolean("showLabelsInList", false)); + + activitySettingsAppearanceBinding.switchLabelsInListBadge.setOnCheckedChangeListener((buttonView, isChecked) -> { + + tinyDB.putBoolean("showLabelsInList", isChecked); + Toasty.success(appCtx, getResources().getString(R.string.settingsSave)); + }); + activitySettingsAppearanceBinding.labelsInListFrame.setOnClickListener(v -> activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(!activitySettingsAppearanceBinding.switchLabelsInListBadge.isChecked())); + // theme selection dialog themeFrame.setOnClickListener(view -> { diff --git a/app/src/main/java/org/mian/gitnex/activities/SettingsSecurityActivity.java b/app/src/main/java/org/mian/gitnex/activities/SettingsSecurityActivity.java index c41d387e..86ccdb01 100644 --- a/app/src/main/java/org/mian/gitnex/activities/SettingsSecurityActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/SettingsSecurityActivity.java @@ -2,7 +2,6 @@ package org.mian.gitnex.activities; import android.app.KeyguardManager; import android.content.Context; -import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.util.Log; diff --git a/app/src/main/java/org/mian/gitnex/activities/SettingsTranslationActivity.java b/app/src/main/java/org/mian/gitnex/activities/SettingsTranslationActivity.java index abf87396..0a3e0d43 100644 --- a/app/src/main/java/org/mian/gitnex/activities/SettingsTranslationActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/SettingsTranslationActivity.java @@ -1,7 +1,5 @@ package org.mian.gitnex.activities; -import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.ImageView; @@ -15,7 +13,6 @@ import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.Toasty; import java.util.LinkedHashMap; import java.util.Locale; -import java.util.TreeMap; /** * Author M M Arif diff --git a/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java index 41c2abb6..759a1772 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/CommitsAdapter.java @@ -1,5 +1,6 @@ package org.mian.gitnex.adapters; +import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; import android.view.LayoutInflater; @@ -16,7 +17,6 @@ import org.mian.gitnex.R; import org.mian.gitnex.activities.CommitDetailActivity; import org.mian.gitnex.activities.CommitsActivity; import org.mian.gitnex.clients.PicassoService; -import org.mian.gitnex.fragments.CommitDetailFragment; import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TimeHelper; @@ -24,13 +24,12 @@ import java.util.List; import java.util.Objects; /** - * Author M M Arif + * @author M M Arif */ public class CommitsAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List commitsList; private Runnable loadMoreListener; private boolean isLoading = false; @@ -45,14 +44,8 @@ public class CommitsAdapter extends RecyclerView.Adapter list) { commitsList = list; - notifyDataSetChanged(); + notifyDataChanged(); } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/ExploreIssuesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ExploreIssuesAdapter.java index 8c1f9fd7..d5bd8191 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ExploreIssuesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ExploreIssuesAdapter.java @@ -3,15 +3,22 @@ package org.mian.gitnex.adapters; import android.annotation.SuppressLint; import android.content.Context; import android.content.Intent; +import android.graphics.Color; +import android.graphics.Typeface; +import android.os.Handler; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.HorizontalScrollView; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.res.ResourcesCompat; import androidx.core.text.HtmlCompat; import androidx.recyclerview.widget.RecyclerView; +import com.amulyakhare.textdrawable.TextDrawable; import org.gitnex.tea4j.models.Issues; import org.mian.gitnex.R; import org.mian.gitnex.activities.BaseActivity; @@ -23,6 +30,8 @@ import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.models.Repository; import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.ClickListener; +import org.mian.gitnex.helpers.ColorInverter; +import org.mian.gitnex.helpers.LabelWidthCalculator; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TimeHelper; import org.mian.gitnex.helpers.TinyDB; @@ -35,13 +44,12 @@ import java.util.List; import java.util.Locale; /** - * Author M M Arif + * @author M M Arif */ public class ExploreIssuesAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List searchedList; private OnLoadMoreListener loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -57,12 +65,7 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter { - itemView.setOnClickListener(v -> { String[] parts = issue.getRepository().getFull_name().split("/"); final String repoOwner = parts[0]; final String repoName = parts[1]; - - int currentActiveAccountId = ((BaseActivity) context).getAccount().getAccount().getAccountId(); RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class); @@ -130,13 +136,13 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter context.startActivity(intentIssueDetail)); + frameLabels.setOnClickListener(v -> context.startActivity(intentIssueDetail)); + frameLabelsDots.setOnClickListener(v -> context.startActivity(intentIssueDetail)); + }, 200); issueAssigneeAvatar.setOnClickListener(v -> { Intent intent = new Intent(context, ProfileActivity.class); @@ -150,8 +156,8 @@ public class ExploreIssuesAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List organizationsList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -39,12 +38,7 @@ public class ExplorePublicOrganizationsAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List reposList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -56,12 +55,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List issuesList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; + TinyDB tinyDb; public IssuesAdapter(Context ctx, List issuesListMain) { this.context = ctx; this.issuesList = issuesListMain; + tinyDb = TinyDB.getInstance(context); } @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - LayoutInflater inflater = LayoutInflater.from(context); - - if(viewType == TYPE_LOAD) { - return new IssuesHolder(inflater.inflate(R.layout.list_issues, parent, false)); - } - else { - return new LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); - } + return new IssuesHolder(inflater.inflate(R.layout.list_issues, parent, false)); } @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if(position >= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) { - isLoading = true; loadMoreListener.run(); } - if(getItemViewType(position) == TYPE_LOAD) { - - ((IssuesHolder) holder).bindData(issuesList.get(position)); - } + ((IssuesHolder) holder).bindData(issuesList.get(position)); } @Override public int getItemViewType(int position) { - - if(issuesList.get(position).getTitle() != null) { - return TYPE_LOAD; - } - else { - return 1; - } + return position; } @Override @@ -97,12 +90,16 @@ public class IssuesAdapter extends RecyclerView.Adapter class IssuesHolder extends RecyclerView.ViewHolder { - private Issues issue; + private Issues issueObject; private final ImageView issueAssigneeAvatar; private final TextView issueTitle; private final TextView issueCreatedTime; private final TextView issueCommentsCount; + private final HorizontalScrollView labelsScrollViewWithText; + private final LinearLayout frameLabels; + private final HorizontalScrollView labelsScrollViewDots; + private final LinearLayout frameLabelsDots; IssuesHolder(View itemView) { @@ -111,31 +108,38 @@ public class IssuesAdapter extends RecyclerView.Adapter issueTitle = itemView.findViewById(R.id.issueTitle); issueCommentsCount = itemView.findViewById(R.id.issueCommentsCount); issueCreatedTime = itemView.findViewById(R.id.issueCreatedTime); + labelsScrollViewWithText = itemView.findViewById(R.id.labelsScrollViewWithText); + frameLabels = itemView.findViewById(R.id.frameLabels); + labelsScrollViewDots = itemView.findViewById(R.id.labelsScrollViewDots); + frameLabelsDots = itemView.findViewById(R.id.frameLabelsDots); - itemView.setOnClickListener(layoutView -> { - Intent intent = new IssueContext( - issue, - ((RepoDetailActivity) context).repository - ).getIntent(context, IssueDetailActivity.class); - context.startActivity(intent); + issueAssigneeAvatar.setOnLongClickListener(loginId -> { + AppUtil.copyToClipboard(context, issueObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, issueObject.getUser().getLogin())); + return true; }); + new Handler().postDelayed(() -> { + + Intent intentIssueDetail = new IssueContext(issueObject, ((RepoDetailActivity) context).repository).getIntent(context, IssueDetailActivity.class); + + itemView.setOnClickListener(layoutView -> { + context.startActivity(intentIssueDetail); + }); + frameLabels.setOnClickListener(v -> context.startActivity(intentIssueDetail)); + frameLabelsDots.setOnClickListener(v -> context.startActivity(intentIssueDetail)); + + }, 200); + issueAssigneeAvatar.setOnClickListener(v -> { Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", issue.getUser().getLogin()); + intent.putExtra("username", issueObject.getUser().getLogin()); context.startActivity(intent); }); - - issueAssigneeAvatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, issue.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, issue.getUser().getLogin())); - return true; - }); } @SuppressLint("SetTextI18n") void bindData(Issues issue) { - TinyDB tinyDb = TinyDB.getInstance(context); Locale locale = context.getResources().getConfiguration().locale; String timeFormat = tinyDb.getString("dateFormat", "pretty"); @@ -152,9 +156,66 @@ public class IssuesAdapter extends RecyclerView.Adapter String issueNumber_ = "" + context.getResources().getString(R.string.hash) + issue.getNumber() + ""; issueTitle.setText(HtmlCompat.fromHtml(issueNumber_ + " " + EmojiParser.parseToUnicode(issue.getTitle()), HtmlCompat.FROM_HTML_MODE_LEGACY)); - this.issue = issue; + this.issueObject = issue; this.issueCommentsCount.setText(String.valueOf(issue.getComments())); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.WRAP_CONTENT); + params.setMargins(0, 0, 15, 0); + + if(issue.getLabels() != null) { + + if(!tinyDb.getBoolean("showLabelsInList", false)) { // default + + labelsScrollViewWithText.setVisibility(View.GONE); + labelsScrollViewDots.setVisibility(View.VISIBLE); + frameLabelsDots.removeAllViews(); + + for(int i = 0; i < issue.getLabels().size(); i++) { + + String labelColor = issue.getLabels().get(i).getColor(); + int color = Color.parseColor("#" + labelColor); + + ImageView labelsView = new ImageView(context); + frameLabelsDots.setOrientation(LinearLayout.HORIZONTAL); + frameLabelsDots.setGravity(Gravity.START | Gravity.TOP); + labelsView.setLayoutParams(params); + + TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).width(54).height(54).endConfig().buildRound("", color); + + labelsView.setImageDrawable(drawable); + frameLabelsDots.addView(labelsView); + } + } + else { + + labelsScrollViewDots.setVisibility(View.GONE); + labelsScrollViewWithText.setVisibility(View.VISIBLE); + frameLabels.removeAllViews(); + + for(int i = 0; i < issue.getLabels().size(); i++) { + + String labelColor = issue.getLabels().get(i).getColor(); + String labelName = issue.getLabels().get(i).getName(); + int color = Color.parseColor("#" + labelColor); + + ImageView labelsView = new ImageView(context); + frameLabels.setOrientation(LinearLayout.HORIZONTAL); + frameLabels.setGravity(Gravity.START | Gravity.TOP); + labelsView.setLayoutParams(params); + + int height = AppUtil.getPixelsFromDensity(context, 20); + int textSize = AppUtil.getPixelsFromScaledDensity(context, 12); + + TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).textColor(new ColorInverter().getContrastColor(color)).fontSize(textSize).width(LabelWidthCalculator + .calculateLabelWidth(labelName, Typeface.DEFAULT, textSize, AppUtil.getPixelsFromDensity(context, 8))).height(height).endConfig().buildRoundRect(labelName, color, AppUtil.getPixelsFromDensity(context, 18)); + + labelsView.setImageDrawable(drawable); + frameLabels.addView(labelsView); + } + } + } + switch(timeFormat) { case "pretty": { PrettyTime prettyTime = new PrettyTime(locale); @@ -181,34 +242,22 @@ public class IssuesAdapter extends RecyclerView.Adapter } - 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 void setLoadMoreListener(Runnable loadMoreListener) { - this.loadMoreListener = loadMoreListener; } public void updateList(List list) { - issuesList = list; - notifyDataSetChanged(); + notifyDataChanged(); } - } diff --git a/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java index df3a04d6..2365d693 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/MilestonesAdapter.java @@ -32,13 +32,12 @@ import java.util.List; import java.util.Locale; /** - * Author M M Arif + * @author M M Arif */ public class MilestonesAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List dataList; private Runnable loadMoreListener; private boolean isLoading = false; @@ -54,15 +53,8 @@ public class MilestonesAdapter extends RecyclerView.Adapter list) { - dataList = list; - notifyDataSetChanged(); + notifyDataChanged(); } - } diff --git a/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java index 2126f29c..47b15606 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/NotificationsAdapter.java @@ -21,14 +21,12 @@ import org.mian.gitnex.helpers.AppUtil; import java.util.List; /** - * Author opyale - * Modified M M Arif + * @author opyale */ public class NotificationsAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List notificationThreads; private final OnMoreClickedListener onMoreClickedListener; private final OnNotificationClickedListener onNotificationClickedListener; @@ -46,12 +44,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter= getItemCount() - 1 && isMoreDataAvailable && !isLoading) { isLoading = true; } - - if(getItemViewType(position) == TYPE_LOAD) { - ((NotificationsAdapter.NotificationsHolder) holder).bindData(notificationThreads.get(position)); - } + ((NotificationsAdapter.NotificationsHolder) holder).bindData(notificationThreads.get(position)); } @Override public int getItemViewType(int position) { - if(notificationThreads.get(position).getSubject() != null) { - return TYPE_LOAD; - } - else { - return 1; - } + return position; } @Override @@ -168,12 +153,6 @@ public class NotificationsAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List prList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -48,40 +55,23 @@ public class PullRequestsAdapter extends RecyclerView.Adapter= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) { - isLoading = true; loadMoreListener.run(); } - - if(getItemViewType(position) == TYPE_LOAD) { - ((PullRequestsAdapter.PullRequestsHolder) holder).bindData(prList.get(position)); - } + ((PullRequestsAdapter.PullRequestsHolder) holder).bindData(prList.get(position)); } @Override public int getItemViewType(int position) { - - if(prList.get(position).getTitle() != null) { - return TYPE_LOAD; - } - else { - return 1; - } + return position; } @Override @@ -91,12 +81,16 @@ public class PullRequestsAdapter extends RecyclerView.Adapter { Intent intent = new IssueContext( - pullRequest, - new RepositoryContext(pullRequest.getBase().getRepo().getFull_name().split("/")[0], pullRequest.getBase().getRepo().getName(), context) + pullRequestObject, + new RepositoryContext(pullRequestObject.getBase().getRepo().getFull_name().split("/")[0], pullRequestObject.getBase().getRepo().getName(), context) ) .getIntent(context, IssueDetailActivity.class); @@ -119,12 +117,12 @@ public class PullRequestsAdapter extends RecyclerView.Adapter { Intent intent = new Intent(context, ProfileActivity.class); - intent.putExtra("username", pullRequest.getUser().getLogin()); + intent.putExtra("username", pullRequestObject.getUser().getLogin()); context.startActivity(intent); }); assigneeAvatar.setOnLongClickListener(loginId -> { - AppUtil.copyToClipboard(context, pullRequest.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, pullRequest.getUser().getLogin())); + AppUtil.copyToClipboard(context, pullRequestObject.getUser().getLogin(), context.getString(R.string.copyLoginIdToClipBoard, pullRequestObject.getUser().getLogin())); return true; }); } @@ -145,7 +143,68 @@ public class PullRequestsAdapter extends RecyclerView.Adapter" + context.getResources().getString(R.string.hash) + pullRequest.getNumber() + ""; @@ -159,18 +218,11 @@ public class PullRequestsAdapter extends RecyclerView.Adapter list) { prList = list; - notifyDataSetChanged(); + notifyDataChanged(); } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java index 15de1174..61fbda53 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ReleasesAdapter.java @@ -118,7 +118,8 @@ public class ReleasesAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List forksList; private Runnable loadMoreListener; private boolean isLoading = false; @@ -55,45 +54,27 @@ public class RepoForksAdapter extends RecyclerView.Adapter= getItemCount() - 1 && isMoreDataAvailable && !isLoading && loadMoreListener != null) { - isLoading = true; loadMoreListener.run(); } - - if(getItemViewType(position) == TYPE_LOAD) { - - ((RepoForksAdapter.ForksHolder) holder).bindData(forksList.get(position)); - } + ((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; - } + return position; } @Override public int getItemCount() { - return forksList.size(); } @@ -226,34 +207,22 @@ public class RepoForksAdapter extends RecyclerView.Adapter list) { - forksList = list; - notifyDataSetChanged(); + notifyDataChanged(); } - } 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 8f94e87c..050879a9 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/ReposListAdapter.java @@ -16,11 +16,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; import org.gitnex.tea4j.models.UserRepositories; -import org.gitnex.tea4j.models.WatchInfo; import org.mian.gitnex.R; import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.clients.PicassoService; -import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.database.api.BaseApi; import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.models.Repository; @@ -29,7 +27,6 @@ import org.mian.gitnex.helpers.ClickListener; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TimeHelper; import org.mian.gitnex.helpers.TinyDB; -import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.contexts.RepositoryContext; import org.ocpsoft.prettytime.PrettyTime; import java.text.DateFormat; @@ -37,8 +34,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import retrofit2.Call; -import retrofit2.Callback; /** * Author M M Arif 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 351ed0b2..51df00cd 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/RepositoriesByOrgAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/RepositoriesByOrgAdapter.java @@ -16,11 +16,9 @@ import androidx.recyclerview.widget.RecyclerView; import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; import org.gitnex.tea4j.models.UserRepositories; -import org.gitnex.tea4j.models.WatchInfo; import org.mian.gitnex.R; import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.clients.PicassoService; -import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.database.api.BaseApi; import org.mian.gitnex.database.api.RepositoriesApi; import org.mian.gitnex.database.models.Repository; @@ -29,7 +27,6 @@ import org.mian.gitnex.helpers.ClickListener; import org.mian.gitnex.helpers.RoundedTransformation; import org.mian.gitnex.helpers.TimeHelper; import org.mian.gitnex.helpers.TinyDB; -import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.contexts.RepositoryContext; import org.ocpsoft.prettytime.PrettyTime; import java.text.DateFormat; @@ -37,8 +34,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import retrofit2.Call; -import retrofit2.Callback; /** * Author M M Arif diff --git a/app/src/main/java/org/mian/gitnex/adapters/TagsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/TagsAdapter.java index ffedd15f..e1ced076 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/TagsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/TagsAdapter.java @@ -18,7 +18,6 @@ import org.mian.gitnex.R; import org.mian.gitnex.activities.RepoDetailActivity; import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.Markdown; -import org.mian.gitnex.helpers.TinyDB; import java.util.List; /** diff --git a/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java index 8ff6ca89..1b4f9628 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UserAccountsAdapter.java @@ -16,7 +16,6 @@ import androidx.appcompat.content.res.AppCompatResources; import androidx.recyclerview.widget.RecyclerView; import org.mian.gitnex.R; import org.mian.gitnex.activities.AddNewAccountActivity; -import org.mian.gitnex.activities.LoginActivity; import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.database.api.BaseApi; import org.mian.gitnex.database.api.UserAccountsApi; diff --git a/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java index 9dfc5916..43b5deab 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UserSearchForTeamMemberAdapter.java @@ -19,7 +19,6 @@ import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.helpers.AlertDialogs; import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.helpers.RoundedTransformation; -import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.Toasty; import java.util.List; import retrofit2.Call; diff --git a/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java index 4130af97..16b17878 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/UsersAdapter.java @@ -26,7 +26,6 @@ import java.util.List; public class UsersAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List followersList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -40,12 +39,7 @@ public class UsersAdapter extends RecyclerView.Adapter @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(context); - if(viewType == TYPE_LOAD) { - return new UsersAdapter.UsersHolder(inflater.inflate(R.layout.list_users, parent, false)); - } - else { - return new UsersAdapter.LoadHolder(inflater.inflate(R.layout.row_load, parent, false)); - } + return new UsersAdapter.UsersHolder(inflater.inflate(R.layout.list_users, parent, false)); } @Override @@ -54,20 +48,12 @@ public class UsersAdapter extends RecyclerView.Adapter isLoading = true; loadMoreListener.run(); } - - if(getItemViewType(position) == TYPE_LOAD) { - ((UsersAdapter.UsersHolder) holder).bindData(followersList.get(position)); - } + ((UsersAdapter.UsersHolder) holder).bindData(followersList.get(position)); } @Override public int getItemViewType(int position) { - if(followersList.get(position).getUsername() != null) { - return TYPE_LOAD; - } - else { - return 1; - } + return position; } @Override @@ -118,12 +104,6 @@ public class UsersAdapter extends RecyclerView.Adapter } } - static class LoadHolder extends RecyclerView.ViewHolder { - LoadHolder(View itemView) { - super(itemView); - } - } - public void setMoreDataAvailable(boolean moreDataAvailable) { isMoreDataAvailable = moreDataAvailable; } diff --git a/app/src/main/java/org/mian/gitnex/adapters/profile/OrganizationsAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/profile/OrganizationsAdapter.java index 768c8a3d..39af1aa8 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/profile/OrganizationsAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/profile/OrganizationsAdapter.java @@ -19,13 +19,12 @@ import org.mian.gitnex.helpers.RoundedTransformation; import java.util.List; /** - * Author M M Arif + * @author M M Arif */ public class OrganizationsAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List organizationsList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -38,15 +37,8 @@ public class OrganizationsAdapter extends RecyclerView.Adapter list) { organizationsList = list; - notifyDataSetChanged(); + notifyDataChanged(); } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/profile/RepositoriesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/profile/RepositoriesAdapter.java index 6ae99bad..e13364f2 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/profile/RepositoriesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/profile/RepositoriesAdapter.java @@ -31,13 +31,12 @@ import java.util.List; import java.util.Locale; /** - * Author M M Arif + * @author M M Arif */ public class RepositoriesAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List reposList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -52,13 +51,7 @@ public class RepositoriesAdapter extends RecyclerView.Adapter list) { reposList = list; - notifyDataSetChanged(); + notifyDataChanged(); } } diff --git a/app/src/main/java/org/mian/gitnex/adapters/profile/StarredRepositoriesAdapter.java b/app/src/main/java/org/mian/gitnex/adapters/profile/StarredRepositoriesAdapter.java index 3aad4a6f..f6c04f53 100644 --- a/app/src/main/java/org/mian/gitnex/adapters/profile/StarredRepositoriesAdapter.java +++ b/app/src/main/java/org/mian/gitnex/adapters/profile/StarredRepositoriesAdapter.java @@ -31,13 +31,12 @@ import java.util.List; import java.util.Locale; /** - * Author M M Arif + * @author M M Arif */ public class StarredRepositoriesAdapter extends RecyclerView.Adapter { private final Context context; - private final int TYPE_LOAD = 0; private List reposList; private Runnable loadMoreListener; private boolean isLoading = false, isMoreDataAvailable = true; @@ -52,13 +51,7 @@ public class StarredRepositoriesAdapter extends RecyclerView.Adapter list) { reposList = list; - notifyDataSetChanged(); + notifyDataChanged(); } } diff --git a/app/src/main/java/org/mian/gitnex/core/MainApplication.java b/app/src/main/java/org/mian/gitnex/core/MainApplication.java index 91823840..e3cc6edd 100644 --- a/app/src/main/java/org/mian/gitnex/core/MainApplication.java +++ b/app/src/main/java/org/mian/gitnex/core/MainApplication.java @@ -3,7 +3,6 @@ package org.mian.gitnex.core; import android.annotation.SuppressLint; import android.app.Application; import android.content.Context; -import androidx.core.content.res.ResourcesCompat; import org.acra.ACRA; import org.acra.BuildConfig; import org.acra.ReportField; @@ -16,7 +15,6 @@ import org.acra.data.StringFormat; import org.mian.gitnex.R; import org.mian.gitnex.database.models.UserAccount; import org.mian.gitnex.helpers.AppUtil; -import org.mian.gitnex.helpers.Constants; import org.mian.gitnex.helpers.FontsOverride; import org.mian.gitnex.helpers.TinyDB; import org.mian.gitnex.helpers.contexts.AccountContext; diff --git a/app/src/main/java/org/mian/gitnex/database/api/BaseApi.java b/app/src/main/java/org/mian/gitnex/database/api/BaseApi.java index ac5beaa8..5c60c429 100644 --- a/app/src/main/java/org/mian/gitnex/database/api/BaseApi.java +++ b/app/src/main/java/org/mian/gitnex/database/api/BaseApi.java @@ -3,13 +3,9 @@ package org.mian.gitnex.database.api; import android.content.Context; import androidx.annotation.NonNull; import org.mian.gitnex.database.db.GitnexDatabase; -import org.mian.gitnex.helpers.Constants; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; diff --git a/app/src/main/java/org/mian/gitnex/database/api/UserAccountsApi.java b/app/src/main/java/org/mian/gitnex/database/api/UserAccountsApi.java index 2dc45180..f2f1a1c5 100644 --- a/app/src/main/java/org/mian/gitnex/database/api/UserAccountsApi.java +++ b/app/src/main/java/org/mian/gitnex/database/api/UserAccountsApi.java @@ -2,7 +2,6 @@ package org.mian.gitnex.database.api; import android.content.Context; import androidx.lifecycle.LiveData; -import androidx.room.Query; import org.mian.gitnex.database.dao.UserAccountsDao; import org.mian.gitnex.database.models.UserAccount; import java.util.List; diff --git a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetIssuesFilterFragment.java b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetIssuesFilterFragment.java index 049cf9e2..397fa7c4 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetIssuesFilterFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetIssuesFilterFragment.java @@ -10,8 +10,6 @@ import androidx.annotation.Nullable; import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import org.mian.gitnex.activities.BaseActivity; import org.mian.gitnex.databinding.BottomSheetIssuesFilterBinding; -import org.mian.gitnex.helpers.TinyDB; -import org.mian.gitnex.helpers.Version; import org.mian.gitnex.structs.BottomSheetListener; /** 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 5a8dc875..e221c961 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/BottomSheetSingleIssueFragment.java @@ -16,8 +16,8 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment; import org.mian.gitnex.R; import org.mian.gitnex.actions.IssueActions; import org.mian.gitnex.actions.PullRequestActions; -import org.mian.gitnex.activities.DiffActivity; import org.mian.gitnex.activities.BaseActivity; +import org.mian.gitnex.activities.DiffActivity; import org.mian.gitnex.activities.EditIssueActivity; import org.mian.gitnex.activities.IssueDetailActivity; import org.mian.gitnex.activities.MergePullRequestActivity; diff --git a/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java b/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java index 25c95c28..8c78fdd4 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/CommitDetailFragment.java @@ -23,7 +23,14 @@ import org.mian.gitnex.clients.PicassoService; import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.databinding.CustomCommitHeaderBinding; import org.mian.gitnex.databinding.FragmentCommitDetailsBinding; -import org.mian.gitnex.helpers.*; +import org.mian.gitnex.helpers.AlertDialogs; +import org.mian.gitnex.helpers.AppUtil; +import org.mian.gitnex.helpers.ParseDiff; +import org.mian.gitnex.helpers.RoundedTransformation; +import org.mian.gitnex.helpers.TimeHelper; +import org.mian.gitnex.helpers.TinyDB; +import org.mian.gitnex.helpers.Toasty; +import org.mian.gitnex.helpers.Version; import org.mian.gitnex.helpers.contexts.RepositoryContext; import java.io.IOException; import java.util.List; diff --git a/app/src/main/java/org/mian/gitnex/fragments/DiffFilesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/DiffFilesFragment.java index f1f83e86..e6cb372a 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/DiffFilesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/DiffFilesFragment.java @@ -13,7 +13,9 @@ import org.mian.gitnex.activities.BaseActivity; import org.mian.gitnex.adapters.DiffFilesAdapter; import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.databinding.FragmentDiffFilesBinding; -import org.mian.gitnex.helpers.*; +import org.mian.gitnex.helpers.AlertDialogs; +import org.mian.gitnex.helpers.ParseDiff; +import org.mian.gitnex.helpers.Toasty; import org.mian.gitnex.helpers.contexts.IssueContext; import java.io.IOException; import java.util.List; 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 376c680e..ee3a67c6 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/ExploreRepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/ExploreRepositoriesFragment.java @@ -4,7 +4,6 @@ import android.app.Dialog; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/fragments/LabelsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/LabelsFragment.java index e40e3c9b..b8d1aaa4 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/LabelsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/LabelsFragment.java @@ -1,6 +1,5 @@ package org.mian.gitnex.fragments; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/fragments/MembersByOrgFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MembersByOrgFragment.java index ddbcba90..a07a6a77 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MembersByOrgFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MembersByOrgFragment.java @@ -1,6 +1,5 @@ package org.mian.gitnex.fragments; -import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -21,7 +20,6 @@ import org.mian.gitnex.adapters.UserGridAdapter; import org.mian.gitnex.databinding.FragmentMembersByOrgBinding; import org.mian.gitnex.helpers.AppUtil; import org.mian.gitnex.viewmodels.MembersByOrgViewModel; -import java.util.Objects; /** * Author M M Arif diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyIssuesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyIssuesFragment.java index baf34222..aa1195a4 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyIssuesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyIssuesFragment.java @@ -39,6 +39,7 @@ public class MyIssuesFragment extends Fragment { fragmentIssuesBinding.pullToRefresh.setOnRefreshListener(() -> new Handler(Looper.getMainLooper()).postDelayed(() -> { + page = 1; fragmentIssuesBinding.pullToRefresh.setRefreshing(false); IssuesViewModel.loadIssuesList(((BaseActivity) requireActivity()).getAccount().getAuthorization(), null, "issues", true, "open", getContext()); fragmentIssuesBinding.progressBar.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java index 37d34611..6be263f7 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyProfileEmailsFragment.java @@ -1,6 +1,5 @@ package org.mian.gitnex.fragments; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java index 392933f5..4d192db5 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/MyRepositoriesFragment.java @@ -1,7 +1,6 @@ package org.mian.gitnex.fragments; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/fragments/OrganizationInfoFragment.java b/app/src/main/java/org/mian/gitnex/fragments/OrganizationInfoFragment.java index 9f08608d..230fb282 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/OrganizationInfoFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/OrganizationInfoFragment.java @@ -1,7 +1,6 @@ package org.mian.gitnex.fragments; import android.content.Context; -import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; diff --git a/app/src/main/java/org/mian/gitnex/fragments/OrganizationLabelsFragment.java b/app/src/main/java/org/mian/gitnex/fragments/OrganizationLabelsFragment.java index c96ab2ed..c59abdaa 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/OrganizationLabelsFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/OrganizationLabelsFragment.java @@ -1,6 +1,5 @@ package org.mian.gitnex.fragments; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java index 258f07e7..9e3b09c7 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/RepositoriesByOrgFragment.java @@ -1,6 +1,5 @@ package org.mian.gitnex.fragments; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java b/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java index e319db72..f232728e 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/StarredRepositoriesFragment.java @@ -1,7 +1,6 @@ package org.mian.gitnex.fragments; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/fragments/TeamsByOrgFragment.java b/app/src/main/java/org/mian/gitnex/fragments/TeamsByOrgFragment.java index a3001478..0aea4a3e 100644 --- a/app/src/main/java/org/mian/gitnex/fragments/TeamsByOrgFragment.java +++ b/app/src/main/java/org/mian/gitnex/fragments/TeamsByOrgFragment.java @@ -1,6 +1,5 @@ package org.mian.gitnex.fragments; -import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; diff --git a/app/src/main/java/org/mian/gitnex/helpers/AlertDialogs.java b/app/src/main/java/org/mian/gitnex/helpers/AlertDialogs.java index b5755f26..1488f328 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/AlertDialogs.java +++ b/app/src/main/java/org/mian/gitnex/helpers/AlertDialogs.java @@ -1,6 +1,5 @@ package org.mian.gitnex.helpers; -import android.annotation.SuppressLint; import android.app.Dialog; import android.content.Context; import android.content.Intent; @@ -15,9 +14,8 @@ import org.mian.gitnex.actions.PullRequestActions; import org.mian.gitnex.actions.TeamActions; import org.mian.gitnex.activities.BaseActivity; import org.mian.gitnex.activities.CreateLabelActivity; -import org.mian.gitnex.activities.LoginActivity; -import org.mian.gitnex.helpers.contexts.RepositoryContext; import org.mian.gitnex.clients.RetrofitClient; +import org.mian.gitnex.helpers.contexts.RepositoryContext; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; diff --git a/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java b/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java index 05eae160..55c9944d 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java +++ b/app/src/main/java/org/mian/gitnex/helpers/AppUtil.java @@ -17,16 +17,10 @@ import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.View; import androidx.annotation.ColorInt; -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; import androidx.browser.customtabs.CustomTabColorSchemeParams; import androidx.browser.customtabs.CustomTabsIntent; import androidx.core.content.pm.PackageInfoCompat; -import androidx.lifecycle.Lifecycle; -import androidx.lifecycle.LifecycleOwner; -import androidx.lifecycle.LiveData; import org.mian.gitnex.R; -import org.mian.gitnex.activities.BaseActivity; import org.mian.gitnex.activities.LoginActivity; import org.mian.gitnex.activities.MainActivity; import org.mian.gitnex.core.MainApplication; diff --git a/app/src/main/java/org/mian/gitnex/helpers/DividerItemDecorator.java b/app/src/main/java/org/mian/gitnex/helpers/DividerItemDecorator.java new file mode 100644 index 00000000..11758712 --- /dev/null +++ b/app/src/main/java/org/mian/gitnex/helpers/DividerItemDecorator.java @@ -0,0 +1,40 @@ +package org.mian.gitnex.helpers; + +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.view.View; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +/** + * @author M M Arif + */ + +public class DividerItemDecorator extends RecyclerView.ItemDecoration { + + private final Drawable rvDivider; + + public DividerItemDecorator(Drawable divider) { + rvDivider = divider; + } + + @Override + public void onDrawOver(@NonNull Canvas canvas, RecyclerView parent, @NonNull RecyclerView.State state) { + + int dividerLeft = parent.getPaddingLeft(); + int dividerRight = parent.getWidth() - parent.getPaddingRight(); + + int childCount = parent.getChildCount(); + for (int i = 0; i <= childCount - 2; i++) { + View child = parent.getChildAt(i); + + RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); + + int dividerTop = child.getBottom() + params.bottomMargin; + int dividerBottom = dividerTop + rvDivider.getIntrinsicHeight(); + + rvDivider.setBounds(dividerLeft, dividerTop, dividerRight, dividerBottom); + rvDivider.draw(canvas); + } + } +} diff --git a/app/src/main/java/org/mian/gitnex/helpers/Markdown.java b/app/src/main/java/org/mian/gitnex/helpers/Markdown.java index 4220ce0b..33e5a3db 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/Markdown.java +++ b/app/src/main/java/org/mian/gitnex/helpers/Markdown.java @@ -35,6 +35,10 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import de.qwerty287.markwonprism4j.Prism4jTheme; +import de.qwerty287.markwonprism4j.Prism4jThemeDarkula; +import de.qwerty287.markwonprism4j.Prism4jThemeDefault; +import de.qwerty287.markwonprism4j.SyntaxHighlightPlugin; import io.noties.markwon.AbstractMarkwonPlugin; import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; @@ -55,10 +59,6 @@ import io.noties.markwon.recycler.MarkwonAdapter; import io.noties.markwon.recycler.SimpleEntry; import io.noties.markwon.recycler.table.TableEntry; import io.noties.markwon.recycler.table.TableEntryPlugin; -import de.qwerty287.markwonprism4j.Prism4jTheme; -import de.qwerty287.markwonprism4j.Prism4jThemeDarkula; -import de.qwerty287.markwonprism4j.Prism4jThemeDefault; -import de.qwerty287.markwonprism4j.SyntaxHighlightPlugin; import io.noties.prism4j.Prism4j; import stormpot.Allocator; import stormpot.BlazePool; diff --git a/app/src/main/java/org/mian/gitnex/helpers/contexts/IssueContext.java b/app/src/main/java/org/mian/gitnex/helpers/contexts/IssueContext.java index 48ea69cc..18fbc144 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/contexts/IssueContext.java +++ b/app/src/main/java/org/mian/gitnex/helpers/contexts/IssueContext.java @@ -6,7 +6,6 @@ import android.os.Bundle; import org.gitnex.tea4j.models.Issues; import org.gitnex.tea4j.models.PullRequests; import org.gitnex.tea4j.models.UserRepositories; -import org.mian.gitnex.R; import org.mian.gitnex.activities.BaseActivity; import java.io.Serializable; diff --git a/app/src/main/java/org/mian/gitnex/helpers/views/SyntaxHighlightedArea.java b/app/src/main/java/org/mian/gitnex/helpers/views/SyntaxHighlightedArea.java index 3311df6a..ddda8829 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/views/SyntaxHighlightedArea.java +++ b/app/src/main/java/org/mian/gitnex/helpers/views/SyntaxHighlightedArea.java @@ -19,7 +19,6 @@ import androidx.annotation.Nullable; import org.mian.gitnex.R; import org.mian.gitnex.core.MainGrammarLocator; import org.mian.gitnex.helpers.AppUtil; -import org.mian.gitnex.helpers.TinyDB; import de.qwerty287.markwonprism4j.Prism4jSyntaxHighlight; import de.qwerty287.markwonprism4j.Prism4jTheme; import de.qwerty287.markwonprism4j.Prism4jThemeDarkula; diff --git a/app/src/main/java/org/mian/gitnex/views/ReactionList.java b/app/src/main/java/org/mian/gitnex/views/ReactionList.java index 46610f9d..c4b29a12 100644 --- a/app/src/main/java/org/mian/gitnex/views/ReactionList.java +++ b/app/src/main/java/org/mian/gitnex/views/ReactionList.java @@ -19,8 +19,8 @@ import com.vdurmont.emoji.EmojiManager; import org.gitnex.tea4j.models.IssueReaction; import org.gitnex.tea4j.models.UserInfo; import org.mian.gitnex.R; -import org.mian.gitnex.adapters.ReactionAuthorsAdapter; import org.mian.gitnex.activities.BaseActivity; +import org.mian.gitnex.adapters.ReactionAuthorsAdapter; import org.mian.gitnex.clients.RetrofitClient; import org.mian.gitnex.helpers.AppUtil; import java.io.IOException; diff --git a/app/src/main/res/drawable/shape_draft_release.xml b/app/src/main/res/drawable/shape_draft_release.xml new file mode 100644 index 00000000..65501306 --- /dev/null +++ b/app/src/main/res/drawable/shape_draft_release.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/app/src/main/res/drawable/shape_list_divider.xml b/app/src/main/res/drawable/shape_list_divider.xml index ff307019..5269b123 100644 --- a/app/src/main/res/drawable/shape_list_divider.xml +++ b/app/src/main/res/drawable/shape_list_divider.xml @@ -1,5 +1,5 @@ - - + + diff --git a/app/src/main/res/layout/activity_issue_detail.xml b/app/src/main/res/layout/activity_issue_detail.xml index c82cbc6c..804d17c3 100644 --- a/app/src/main/res/layout/activity_issue_detail.xml +++ b/app/src/main/res/layout/activity_issue_detail.xml @@ -62,7 +62,6 @@ android:textColor="@color/colorWhite" android:backgroundTint="?attr/fabColor" android:layout_gravity="bottom|end" - app:layout_behavior="com.google.android.material.behavior.HideBottomViewOnScrollBehavior" app:iconTint="@color/colorWhite" app:icon="@drawable/ic_reply" /> @@ -256,6 +255,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="?attr/primaryBackgroundColor" + android:paddingBottom="64dp" + android:clipToPadding="false" android:scrollbars="vertical" /> diff --git a/app/src/main/res/layout/activity_settings_appearance.xml b/app/src/main/res/layout/activity_settings_appearance.xml index 7e3e3b63..17ad1a3b 100644 --- a/app/src/main/res/layout/activity_settings_appearance.xml +++ b/app/src/main/res/layout/activity_settings_appearance.xml @@ -246,4 +246,47 @@ + + + + + + + + + + diff --git a/app/src/main/res/layout/list_issues.xml b/app/src/main/res/layout/list_issues.xml index 4cc3ceeb..6fbfd5f0 100644 --- a/app/src/main/res/layout/list_issues.xml +++ b/app/src/main/res/layout/list_issues.xml @@ -14,7 +14,6 @@ android:id="@+id/infoSection" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="8dp" android:orientation="horizontal" tools:ignore="UseCompoundDrawables"> @@ -26,19 +25,65 @@ android:contentDescription="@string/generalImgContentText" tools:src="@tools:sample/avatars" /> - + android:orientation="vertical"> + + + + + + + + + + + + + + + + - diff --git a/app/src/main/res/layout/list_pr.xml b/app/src/main/res/layout/list_pr.xml index 9c4014c9..5ba6d136 100644 --- a/app/src/main/res/layout/list_pr.xml +++ b/app/src/main/res/layout/list_pr.xml @@ -27,18 +27,62 @@ android:contentDescription="@string/generalImgContentText" android:src="@drawable/ic_android" /> - + android:orientation="vertical"> + + + + + + + + + + + + + + + + - - - - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 321493d9..9b7e8abe 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -246,6 +246,8 @@ N/A Select Default Link Handler Screen Biometric Support + Labels With Text Support + Enabling this will show labels with text in issues and pr lists, default are color dots No more data available diff --git a/build.gradle b/build.gradle index eeace649..7c354f61 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ buildscript { repositories { google() mavenCentral() - jcenter() } dependencies { classpath 'com.android.tools.build:gradle:7.1.2' @@ -17,7 +16,6 @@ allprojects { repositories { google() mavenCentral() - jcenter() maven { url 'https://jitpack.io' } } }