2019-06-03 23:25:05 +02:00
|
|
|
package org.mian.gitnex.adapters;
|
|
|
|
|
2020-04-01 08:38:14 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2020-04-14 21:25:36 +02:00
|
|
|
import android.widget.CheckBox;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.widget.Filter;
|
|
|
|
import android.widget.Filterable;
|
|
|
|
import android.widget.ImageView;
|
2020-06-06 21:41:19 +02:00
|
|
|
import android.widget.LinearLayout;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.widget.TextView;
|
2020-04-14 21:25:36 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
2019-06-03 23:25:05 +02:00
|
|
|
import com.amulyakhare.textdrawable.TextDrawable;
|
|
|
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
2020-04-01 08:38:14 +02:00
|
|
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.R;
|
2019-09-14 09:38:41 +02:00
|
|
|
import org.mian.gitnex.activities.OpenRepoInBrowserActivity;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
2019-09-13 17:56:30 +02:00
|
|
|
import org.mian.gitnex.activities.RepoStargazersActivity;
|
2019-09-14 08:29:20 +02:00
|
|
|
import org.mian.gitnex.activities.RepoWatchersActivity;
|
2020-04-01 13:26:32 +02:00
|
|
|
import org.mian.gitnex.clients.PicassoService;
|
2020-04-05 11:54:34 +02:00
|
|
|
import org.mian.gitnex.clients.RetrofitClient;
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
import org.mian.gitnex.database.api.RepositoriesApi;
|
2020-07-07 19:15:01 +02:00
|
|
|
import org.mian.gitnex.database.models.Repository;
|
2019-10-01 15:56:20 +02:00
|
|
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
2020-07-07 19:15:01 +02:00
|
|
|
import org.mian.gitnex.helpers.TinyDB;
|
2020-04-05 11:54:34 +02:00
|
|
|
import org.mian.gitnex.helpers.Toasty;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.models.UserRepositories;
|
2020-05-21 20:58:00 +02:00
|
|
|
import org.mian.gitnex.models.WatchInfo;
|
2019-06-03 23:25:05 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2020-04-05 11:54:34 +02:00
|
|
|
import retrofit2.Call;
|
|
|
|
import retrofit2.Callback;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Author M M Arif
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class ReposListAdapter extends RecyclerView.Adapter<ReposListAdapter.ReposViewHolder> implements Filterable {
|
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
private List<UserRepositories> reposList;
|
|
|
|
private Context mCtx;
|
|
|
|
private List<UserRepositories> reposListFull;
|
|
|
|
|
|
|
|
static class ReposViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
|
|
|
|
private ImageView image;
|
|
|
|
private TextView repoName;
|
|
|
|
private TextView repoDescription;
|
|
|
|
private TextView fullName;
|
|
|
|
private CheckBox isRepoAdmin;
|
|
|
|
private ImageView repoPrivatePublic;
|
|
|
|
private TextView repoStars;
|
|
|
|
private TextView repoForks;
|
|
|
|
private TextView repoOpenIssuesCount;
|
|
|
|
private TextView repoType;
|
2020-06-06 21:41:19 +02:00
|
|
|
private LinearLayout archiveRepo;
|
2020-07-12 17:14:50 +02:00
|
|
|
private TextView repoBranch;
|
2020-04-14 21:25:36 +02:00
|
|
|
|
|
|
|
private ReposViewHolder(View itemView) {
|
|
|
|
|
|
|
|
super(itemView);
|
|
|
|
repoName = itemView.findViewById(R.id.repoName);
|
|
|
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
|
|
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
|
|
|
image = itemView.findViewById(R.id.imageAvatar);
|
|
|
|
fullName = itemView.findViewById(R.id.repoFullName);
|
|
|
|
repoPrivatePublic = itemView.findViewById(R.id.imageRepoType);
|
|
|
|
repoStars = itemView.findViewById(R.id.repoStars);
|
|
|
|
repoForks = itemView.findViewById(R.id.repoForks);
|
|
|
|
repoOpenIssuesCount = itemView.findViewById(R.id.repoOpenIssuesCount);
|
|
|
|
ImageView reposDropdownMenu = itemView.findViewById(R.id.reposDropdownMenu);
|
|
|
|
repoType = itemView.findViewById(R.id.repoType);
|
2020-06-06 21:41:19 +02:00
|
|
|
archiveRepo = itemView.findViewById(R.id.archiveRepoFrame);
|
2020-07-12 17:14:50 +02:00
|
|
|
repoBranch = itemView.findViewById(R.id.repoBranch);
|
2020-04-14 21:25:36 +02:00
|
|
|
|
|
|
|
itemView.setOnClickListener(v -> {
|
|
|
|
|
|
|
|
Context context = v.getContext();
|
|
|
|
TextView repoFullName = v.findViewById(R.id.repoFullName);
|
|
|
|
TextView repoType_ = v.findViewById(R.id.repoType);
|
|
|
|
|
|
|
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
|
|
|
intent.putExtra("repoFullName", repoFullName.getText().toString());
|
|
|
|
|
|
|
|
TinyDB tinyDb = new TinyDB(context);
|
|
|
|
tinyDb.putString("repoFullName", repoFullName.getText().toString());
|
|
|
|
tinyDb.putString("repoType", repoType_.getText().toString());
|
2020-04-14 22:55:04 +02:00
|
|
|
//tinyDb.putBoolean("resumeIssues", true);
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("isRepoAdmin", isRepoAdmin.isChecked());
|
2020-07-12 17:14:50 +02:00
|
|
|
tinyDb.putString("repoBranch", repoBranch.getText().toString());
|
2020-04-14 21:25:36 +02:00
|
|
|
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
String[] parts = repoFullName.getText().toString().split("/");
|
|
|
|
final String repoOwner = parts[0];
|
|
|
|
final String repoName = parts[1];
|
|
|
|
|
|
|
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
|
|
|
RepositoriesApi repositoryData = new RepositoriesApi(context);
|
|
|
|
|
|
|
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
|
|
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
|
|
|
|
|
|
|
if(count == 0) {
|
|
|
|
|
|
|
|
long id = repositoryData.insertRepository(currentActiveAccountId, repoOwner, repoName);
|
|
|
|
tinyDb.putLong("repositoryId", id);
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
Repository data = repositoryData.getRepository(currentActiveAccountId, repoOwner, repoName);
|
|
|
|
tinyDb.putLong("repositoryId", data.getRepositoryId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
//store if user is watching this repo
|
|
|
|
{
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
final String instanceUrl = tinyDb.getString("instanceUrl");
|
|
|
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
WatchInfo watch = new WatchInfo();
|
2020-04-14 21:25:36 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
Call<WatchInfo> call;
|
2020-04-14 21:25:36 +02:00
|
|
|
|
|
|
|
call = RetrofitClient.getInstance(instanceUrl, context).getApiInterface().checkRepoWatchStatus(token, repoOwner, repoName);
|
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
call.enqueue(new Callback<WatchInfo>() {
|
2020-04-14 21:25:36 +02:00
|
|
|
|
|
|
|
@Override
|
2020-05-21 20:58:00 +02:00
|
|
|
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
if(response.isSuccessful()) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-15 00:41:40 +02:00
|
|
|
assert response.body() != null;
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-15 00:41:40 +02:00
|
|
|
} else {
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("repoWatch", false);
|
2020-04-15 00:41:40 +02:00
|
|
|
|
|
|
|
if(response.code() != 404) {
|
|
|
|
|
|
|
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
|
|
|
|
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
@Override
|
2020-05-21 20:58:00 +02:00
|
|
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
tinyDb.putBoolean("repoWatch", false);
|
|
|
|
Toasty.info(context, context.getString(R.string.genericApiStatusError));
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
|
|
|
});
|
Implement drafts, introduce Room persistence library for db (#139)
Fix no draft message
translation updates
format improvements
typo update
some renaming refactors
Use better naming convention
remove duplicate source
arrange draft titles
enhance click listener area
Launch drafts from reply screen and clean up
Add message draft saved
update repositories tasks
Update user accounts repository with thread, remove async tasks
remove async task in drafts
update layout, change async to thread in drafts
Merge branch 'master' into pull_139
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
Merge branch 'pull_139' of codeberg.org:gitnex/GitNex into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139
Merge branch 'master' into pull_139 and fix conflicts
# Conflicts:
# app/build.gradle
# app/src/main/java/org/mian/gitnex/activities/LoginActivity.java
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/activities/ReplyToIssueActivity.java
# app/src/main/java/org/mian/gitnex/adapters/MyReposListAdapter.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
# app/src/main/res/values/strings.xml
Code Format
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/res/values/strings.xml
Go to draft, save on type and other fixes
delete all drafts, added messages where needed
delete draft
Force logout
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/src/main/java/org/mian/gitnex/activities/MainActivity.java
# app/src/main/java/org/mian/gitnex/helpers/StaticGlobalVariables.java
check if account data is null, we need to log the user out for the 1st time.
Merge branch 'master' into 15-comments-draft
fix repo owner, name sequence
Add comments for test, show drafts list
Add repos to db
Add account to db and other refactors to the code
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
Merge branch 'master' into 15-comments-draft
# Conflicts:
# app/build.gradle
# app/src/main/AndroidManifest.xml
Merge branch 'master' into 15-comments-draft
merge
more queries, added dao repositories, layout update
Added queries in dao
some refactor. added models, dao, entities (accounts, repositories, drafts)
WIP on implementing drafts, introduced Room persistence library for db.
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/139
Reviewed-by: opyale <opyale@noreply.codeberg.org>
2020-07-04 22:51:55 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
context.startActivity(intent);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
});
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
reposDropdownMenu.setOnClickListener(v -> {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
final Context context = v.getContext();
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
@SuppressLint("InflateParams") View view = LayoutInflater.from(context).inflate(R.layout.bottom_sheet_repository_in_list, null);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
TextView repoOpenInBrowser = view.findViewById(R.id.repoOpenInBrowser);
|
|
|
|
TextView repoStargazers = view.findViewById(R.id.repoStargazers);
|
|
|
|
TextView repoWatchers = view.findViewById(R.id.repoWatchers);
|
|
|
|
TextView bottomSheetHeader = view.findViewById(R.id.bottomSheetHeader);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-06-24 22:29:58 +02:00
|
|
|
bottomSheetHeader.setText(String.format("%s / %s", fullName.getText().toString().split("/")[0], fullName.getText().toString().split("/")[1]));
|
2020-04-14 21:25:36 +02:00
|
|
|
BottomSheetDialog dialog = new BottomSheetDialog(context);
|
|
|
|
dialog.setContentView(view);
|
|
|
|
dialog.show();
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
repoOpenInBrowser.setOnClickListener(openInBrowser -> {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
Intent intentOpenInBrowser = new Intent(context, OpenRepoInBrowserActivity.class);
|
|
|
|
intentOpenInBrowser.putExtra("repoFullNameBrowser", fullName.getText());
|
|
|
|
context.startActivity(intentOpenInBrowser);
|
|
|
|
dialog.dismiss();
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
});
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
repoStargazers.setOnClickListener(stargazers -> {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
Intent intent = new Intent(context, RepoStargazersActivity.class);
|
|
|
|
intent.putExtra("repoFullNameForStars", fullName.getText());
|
|
|
|
context.startActivity(intent);
|
|
|
|
dialog.dismiss();
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
});
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
repoWatchers.setOnClickListener(watchers -> {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
Intent intentW = new Intent(context, RepoWatchersActivity.class);
|
|
|
|
intentW.putExtra("repoFullNameForWatchers", fullName.getText());
|
|
|
|
context.startActivity(intentW);
|
|
|
|
dialog.dismiss();
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
});
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
});
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
public ReposListAdapter(Context mCtx, List<UserRepositories> reposListMain) {
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
this.mCtx = mCtx;
|
|
|
|
this.reposList = reposListMain;
|
|
|
|
reposListFull = new ArrayList<>(reposList);
|
|
|
|
}
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public ReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-05-29 21:30:04 +02:00
|
|
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
|
2020-04-14 21:25:36 +02:00
|
|
|
return new ReposViewHolder(v);
|
|
|
|
}
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(@NonNull ReposViewHolder holder, int position) {
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
UserRepositories currentItem = reposList.get(position);
|
|
|
|
holder.repoDescription.setVisibility(View.GONE);
|
2020-07-12 17:14:50 +02:00
|
|
|
holder.repoBranch.setText(currentItem.getDefault_branch());
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
|
|
|
int color = generator.getColor(currentItem.getName());
|
|
|
|
String firstCharacter = String.valueOf(currentItem.getName().charAt(0));
|
2019-09-14 09:38:41 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
TextDrawable drawable = TextDrawable.builder().beginConfig().useFont(Typeface.DEFAULT).fontSize(18).toUpperCase().width(28).height(28).endConfig().buildRoundRect(firstCharacter, color, 3);
|
2019-09-14 09:38:41 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
if(currentItem.getAvatar_url() != null) {
|
|
|
|
if(!currentItem.getAvatar_url().equals("")) {
|
|
|
|
PicassoService.getInstance(mCtx).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(8, 0)).resize(120, 120).centerCrop().into(holder.image);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
holder.image.setImageDrawable(drawable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
holder.image.setImageDrawable(drawable);
|
|
|
|
}
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
holder.repoName.setText(currentItem.getName());
|
|
|
|
if(!currentItem.getDescription().equals("")) {
|
|
|
|
holder.repoDescription.setVisibility(View.VISIBLE);
|
|
|
|
holder.repoDescription.setText(currentItem.getDescription());
|
|
|
|
}
|
|
|
|
holder.fullName.setText(currentItem.getFullname());
|
|
|
|
if(currentItem.getPrivateFlag()) {
|
2020-07-10 22:54:09 +02:00
|
|
|
holder.repoPrivatePublic.setImageResource(R.drawable.ic_lock);
|
2020-04-14 21:25:36 +02:00
|
|
|
holder.repoType.setText(R.string.strPrivate);
|
|
|
|
}
|
|
|
|
else {
|
2020-07-26 12:01:15 +02:00
|
|
|
holder.repoPrivatePublic.setVisibility(View.GONE);
|
2020-04-14 21:25:36 +02:00
|
|
|
holder.repoType.setText(R.string.strPublic);
|
|
|
|
}
|
|
|
|
holder.repoStars.setText(currentItem.getStars_count());
|
|
|
|
holder.repoForks.setText(currentItem.getForks_count());
|
|
|
|
holder.repoOpenIssuesCount.setText(currentItem.getOpen_issues_count());
|
|
|
|
if(holder.isRepoAdmin == null) {
|
|
|
|
holder.isRepoAdmin = new CheckBox(mCtx);
|
|
|
|
}
|
|
|
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-06-06 21:41:19 +02:00
|
|
|
if(currentItem.isArchived()) {
|
|
|
|
holder.archiveRepo.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
holder.archiveRepo.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
}
|
2019-09-13 17:56:30 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
return reposList.size();
|
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
@Override
|
|
|
|
public Filter getFilter() {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
return reposFilter;
|
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-14 21:25:36 +02:00
|
|
|
private Filter reposFilter = new Filter() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected FilterResults performFiltering(CharSequence constraint) {
|
|
|
|
|
|
|
|
List<UserRepositories> filteredList = new ArrayList<>();
|
|
|
|
|
|
|
|
if(constraint == null || constraint.length() == 0) {
|
|
|
|
filteredList.addAll(reposListFull);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
String filterPattern = constraint.toString().toLowerCase().trim();
|
|
|
|
|
|
|
|
for(UserRepositories item : reposListFull) {
|
|
|
|
if(item.getFullname().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
|
|
|
filteredList.add(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FilterResults results = new FilterResults();
|
|
|
|
results.values = filteredList;
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
|
|
|
|
|
|
|
reposList.clear();
|
|
|
|
reposList.addAll((List) results.values);
|
|
|
|
notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
};
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
}
|