2019-06-03 23:25:05 +02:00
|
|
|
package org.mian.gitnex.adapters;
|
|
|
|
|
|
|
|
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;
|
|
|
|
import android.widget.TextView;
|
2020-07-07 19:15:01 +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;
|
2021-02-11 11:23:35 +01:00
|
|
|
import org.gitnex.tea4j.models.UserRepositories;
|
|
|
|
import org.gitnex.tea4j.models.WatchInfo;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.R;
|
|
|
|
import org.mian.gitnex.activities.RepoDetailActivity;
|
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;
|
2021-04-13 20:56:50 +02:00
|
|
|
import org.mian.gitnex.database.api.BaseApi;
|
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;
|
2021-04-13 16:19:42 +02:00
|
|
|
import org.mian.gitnex.helpers.AppUtil;
|
|
|
|
import org.mian.gitnex.helpers.ClickListener;
|
2019-10-01 15:56:20 +02:00
|
|
|
import org.mian.gitnex.helpers.RoundedTransformation;
|
2021-04-13 16:19:42 +02:00
|
|
|
import org.mian.gitnex.helpers.TimeHelper;
|
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;
|
2021-04-13 16:19:42 +02:00
|
|
|
import org.ocpsoft.prettytime.PrettyTime;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
2019-06-03 23:25:05 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2021-04-13 16:19:42 +02:00
|
|
|
import java.util.Locale;
|
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 RepositoriesByOrgAdapter extends RecyclerView.Adapter<RepositoriesByOrgAdapter.OrgReposViewHolder> implements Filterable {
|
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
private final List<UserRepositories> reposList;
|
|
|
|
private final Context context;
|
|
|
|
private final List<UserRepositories> reposListFull;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
static class OrgReposViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
private UserRepositories userRepositories;
|
|
|
|
|
|
|
|
private final ImageView image;
|
|
|
|
private final TextView repoName;
|
|
|
|
private final TextView orgName;
|
|
|
|
private final TextView repoDescription;
|
|
|
|
private CheckBox isRepoAdmin;
|
|
|
|
private final TextView repoStars;
|
|
|
|
private final TextView repoLastUpdated;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
private OrgReposViewHolder(View itemView) {
|
2021-04-13 16:19:42 +02:00
|
|
|
|
|
|
|
super(itemView);
|
|
|
|
repoName = itemView.findViewById(R.id.repoName);
|
|
|
|
orgName = itemView.findViewById(R.id.orgName);
|
|
|
|
repoDescription = itemView.findViewById(R.id.repoDescription);
|
|
|
|
isRepoAdmin = itemView.findViewById(R.id.repoIsAdmin);
|
|
|
|
image = itemView.findViewById(R.id.imageAvatar);
|
|
|
|
repoStars = itemView.findViewById(R.id.repoStars);
|
|
|
|
repoLastUpdated = itemView.findViewById(R.id.repoLastUpdated);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-01 08:38:14 +02:00
|
|
|
itemView.setOnClickListener(v -> {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-01 08:38:14 +02:00
|
|
|
Context context = v.getContext();
|
2021-04-13 16:19:42 +02:00
|
|
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-01 08:38:14 +02:00
|
|
|
Intent intent = new Intent(context, RepoDetailActivity.class);
|
2021-04-13 16:19:42 +02:00
|
|
|
intent.putExtra("repoFullName", userRepositories.getFullName());
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
tinyDb.putString("repoFullName", userRepositories.getFullName());
|
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());
|
2021-04-13 16:19:42 +02:00
|
|
|
tinyDb.putString("repoBranch", userRepositories.getDefault_branch());
|
|
|
|
|
|
|
|
if(userRepositories.getPrivateFlag()) {
|
|
|
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPrivate));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tinyDb.putString("repoType", context.getResources().getString(R.string.strPublic));
|
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
String[] parts = userRepositories.getFullName().split("/");
|
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
|
|
|
final String repoOwner = parts[0];
|
|
|
|
final String repoName = parts[1];
|
|
|
|
|
|
|
|
int currentActiveAccountId = tinyDb.getInt("currentActiveAccountId");
|
2021-04-13 20:56:50 +02:00
|
|
|
RepositoriesApi repositoryData = BaseApi.getInstance(context, RepositoriesApi.class);
|
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
|
|
|
|
|
|
|
//RepositoriesRepository.deleteRepositoriesByAccount(currentActiveAccountId);
|
2021-04-15 17:05:56 +02:00
|
|
|
assert repositoryData != null;
|
|
|
|
Integer count = repositoryData.checkRepository(currentActiveAccountId, repoOwner, repoName);
|
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
|
|
|
|
|
|
|
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-05 11:54:34 +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-05 11:54:34 +02:00
|
|
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
Call<WatchInfo> call;
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-11-02 16:17:00 +01:00
|
|
|
call = RetrofitClient.getApiInterface(context).checkRepoWatchStatus(token, repoOwner, repoName);
|
2020-04-05 11:54:34 +02:00
|
|
|
|
2020-05-21 20:58:00 +02:00
|
|
|
call.enqueue(new Callback<WatchInfo>() {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
|
|
|
@Override
|
2020-05-21 20:58:00 +02:00
|
|
|
public void onResponse(@NonNull Call<WatchInfo> call, @NonNull retrofit2.Response<WatchInfo> response) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
|
|
|
if(response.isSuccessful()) {
|
|
|
|
|
2020-04-15 00:41:40 +02:00
|
|
|
assert response.body() != null;
|
2020-04-05 11:54:34 +02:00
|
|
|
tinyDb.putBoolean("repoWatch", response.body().getSubscribed());
|
|
|
|
|
2020-04-15 00:41:40 +02:00
|
|
|
} else {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
|
|
|
tinyDb.putBoolean("repoWatch", false);
|
2020-04-15 00:41:40 +02:00
|
|
|
|
|
|
|
if(response.code() != 404) {
|
|
|
|
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
2020-04-15 00:41:40 +02:00
|
|
|
|
|
|
|
}
|
2020-04-05 11:54:34 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-05-21 20:58:00 +02:00
|
|
|
public void onFailure(@NonNull Call<WatchInfo> call, @NonNull Throwable t) {
|
2020-04-05 11:54:34 +02:00
|
|
|
|
|
|
|
tinyDb.putBoolean("repoWatch", false);
|
2020-08-06 17:16:51 +02:00
|
|
|
Toasty.error(context, context.getString(R.string.genericApiStatusError));
|
2020-04-05 11:54:34 +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-05 11:54:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
context.startActivity(intent);
|
2019-06-03 23:25:05 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
public RepositoriesByOrgAdapter(Context ctx, List<UserRepositories> reposListMain) {
|
|
|
|
|
|
|
|
this.context = ctx;
|
2019-06-03 23:25:05 +02:00
|
|
|
this.reposList = reposListMain;
|
|
|
|
reposListFull = new ArrayList<>(reposList);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public RepositoriesByOrgAdapter.OrgReposViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
2021-04-13 16:19:42 +02:00
|
|
|
|
2020-05-29 21:30:04 +02:00
|
|
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_repositories, parent, false);
|
2019-06-03 23:25:05 +02:00
|
|
|
return new RepositoriesByOrgAdapter.OrgReposViewHolder(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(@NonNull RepositoriesByOrgAdapter.OrgReposViewHolder holder, int position) {
|
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
TinyDB tinyDb = TinyDB.getInstance(context);
|
|
|
|
UserRepositories currentItem = reposList.get(position);
|
|
|
|
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
|
|
|
|
|
|
|
|
String locale = tinyDb.getString("locale");
|
|
|
|
String timeFormat = tinyDb.getString("dateFormat");
|
|
|
|
holder.userRepositories = currentItem;
|
|
|
|
holder.orgName.setText(currentItem.getFullName().split("/")[0]);
|
|
|
|
holder.repoName.setText(currentItem.getFullName().split("/")[1]);
|
|
|
|
holder.repoStars.setText(currentItem.getStars_count());
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
ColorGenerator generator = ColorGenerator.MATERIAL;
|
|
|
|
int color = generator.getColor(currentItem.getName());
|
2021-04-15 17:05:56 +02:00
|
|
|
String firstCharacter = String.valueOf(currentItem.getFullName().charAt(0));
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
TextDrawable drawable = TextDrawable.builder()
|
|
|
|
.beginConfig()
|
|
|
|
.useFont(Typeface.DEFAULT)
|
2019-09-30 19:39:33 +02:00
|
|
|
.fontSize(18)
|
2019-06-03 23:25:05 +02:00
|
|
|
.toUpperCase()
|
|
|
|
.width(28)
|
|
|
|
.height(28)
|
|
|
|
.endConfig()
|
2019-10-01 15:56:20 +02:00
|
|
|
.buildRoundRect(firstCharacter, color, 3);
|
|
|
|
|
2019-10-03 18:43:33 +02:00
|
|
|
if (currentItem.getAvatar_url() != null) {
|
|
|
|
if (!currentItem.getAvatar_url().equals("")) {
|
2021-04-13 16:19:42 +02:00
|
|
|
PicassoService.getInstance(context).get().load(currentItem.getAvatar_url()).placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(holder.image);
|
2019-10-03 18:43:33 +02:00
|
|
|
} else {
|
|
|
|
holder.image.setImageDrawable(drawable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2019-10-01 15:56:20 +02:00
|
|
|
holder.image.setImageDrawable(drawable);
|
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
if(currentItem.getUpdated_at() != null) {
|
|
|
|
|
|
|
|
switch(timeFormat) {
|
|
|
|
case "pretty": {
|
|
|
|
PrettyTime prettyTime = new PrettyTime(new Locale(locale));
|
|
|
|
String createdTime = prettyTime.format(currentItem.getUpdated_at());
|
|
|
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
|
|
|
holder.repoLastUpdated.setOnClickListener(new ClickListener(TimeHelper.customDateFormatForToastDateFormat(currentItem.getUpdated_at()), context));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "normal": {
|
|
|
|
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
|
|
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
|
|
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "normal1": {
|
|
|
|
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy '" + context.getResources().getString(R.string.timeAtText) + "' HH:mm", new Locale(locale));
|
|
|
|
String createdTime = formatter.format(currentItem.getUpdated_at());
|
|
|
|
holder.repoLastUpdated.setText(context.getString(R.string.lastUpdatedAt, createdTime));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-06-06 21:41:19 +02:00
|
|
|
}
|
|
|
|
else {
|
2021-04-13 16:19:42 +02:00
|
|
|
holder.repoLastUpdated.setVisibility(View.GONE);
|
2020-06-06 21:41:19 +02:00
|
|
|
}
|
|
|
|
|
2021-04-13 16:19:42 +02:00
|
|
|
if(!currentItem.getDescription().equals("")) {
|
|
|
|
holder.repoDescription.setText(currentItem.getDescription());
|
|
|
|
}
|
2021-04-15 17:05:56 +02:00
|
|
|
else {
|
|
|
|
holder.repoDescription.setText(context.getString(R.string.noDataDescription));
|
|
|
|
}
|
2021-04-13 16:19:42 +02:00
|
|
|
|
|
|
|
if(holder.isRepoAdmin == null) {
|
|
|
|
holder.isRepoAdmin = new CheckBox(context);
|
|
|
|
}
|
|
|
|
holder.isRepoAdmin.setChecked(currentItem.getPermissions().isAdmin());
|
2019-06-03 23:25:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
return reposList.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Filter getFilter() {
|
|
|
|
return orgReposFilter;
|
|
|
|
}
|
|
|
|
|
2021-01-26 16:10:31 +01:00
|
|
|
private final Filter orgReposFilter = new Filter() {
|
2019-06-03 23:25:05 +02:00
|
|
|
@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) {
|
2020-09-13 06:54:05 +02:00
|
|
|
if (item.getFullName().toLowerCase().contains(filterPattern) || item.getDescription().toLowerCase().contains(filterPattern)) {
|
2019-06-03 23:25:05 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|