Bug fixes and improvements (#1360)

Fixes #1361

Fixes #1363

Closes #1376

Fixes #1374

Fixes #1375

Closes #1371

Closes #1369

Closes #1367

Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1360
This commit is contained in:
M M Arif 2024-09-19 17:18:28 +00:00
parent 51a4d1ec85
commit 13d68b9408
55 changed files with 602 additions and 180 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@
# Release dir
app/release/*
app/free/*
# Pro dir
app/pro/*

View File

@ -1,6 +1,6 @@
[![License: GPL v3](https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/license.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Pipeline status](https://ci.codeberg.org/api/badges/gitnex/GitNex/status.svg)](https://ci.codeberg.org/gitnex/GitNex) [![Release](https://img.shields.io/badge/dynamic/json.svg?label=release&url=https://codeberg.org/api/v1/repos/gitnex/GitNex/releases&query=$[0].tag_name)](https://codeberg.org/gitnex/GitNex/releases) [![Crowdin](https://badges.crowdin.net/gitnex/localized.svg)](https://crowdin.com/project/gitnex) [![Join the Discord chat at https://discord.gg/FbSS4rf](https://img.shields.io/discord/632219664587685908.svg)](https://discord.gg/FbSS4rf)
[<img alt="Become a Patreon" src="https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/patreon.png" height="40"/>](https://www.patreon.com/mmarif) [<img alt="Buy me a coffee" src="https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/buy-me-a-coffee.png" height="40"/>](https://www.buymeacoffee.com/mmarif)
[<img alt="Become a Patreon" src="https://codeberg.org/gitnex/GitNex/raw/branch/main/assets/patreon.png" height="40"/>](https://www.patreon.com/mmarif)
# GitNex - Android client for Forgejo and Gitea

View File

@ -1,5 +1,5 @@
plugins {
id "com.diffplug.spotless" version "6.11.0"
id "com.diffplug.spotless" version "6.25.0"
}
apply plugin: 'com.android.application'
@ -8,8 +8,8 @@ android {
applicationId "org.mian.gitnex"
minSdkVersion 23
targetSdkVersion 34
versionCode 550
versionName "5.5.0"
versionCode 595
versionName "6.0.0-dev"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
compileSdk 34
@ -56,25 +56,25 @@ configurations {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.compose.material3:material3:1.2.1'
implementation 'androidx.compose.material3:material3-window-size-class:1.2.1'
implementation 'androidx.compose.material3:material3:1.3.0'
implementation 'androidx.compose.material3:material3-window-size-class:1.3.0'
implementation 'androidx.viewpager2:viewpager2:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.7.0"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.12'
implementation 'com.google.code.gson:gson:2.10.1'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.14'
implementation 'com.google.code.gson:gson:2.11.0'
implementation "com.squareup.picasso:picasso:2.71828"
implementation 'com.github.ramseth001:TextDrawable:1.1.3'
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
implementation 'com.squareup.retrofit2:converter-gson:2.11.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.11.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.12'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.14'
implementation 'org.ocpsoft.prettytime:prettytime:5.0.7.Final'
implementation "com.github.skydoves:colorpickerview:2.3.0"
implementation "io.noties.markwon:core:4.6.2"
@ -89,8 +89,7 @@ dependencies {
implementation "io.noties.markwon:recycler:4.6.2"
implementation "io.noties.markwon:recycler-table:4.6.2"
implementation "io.noties.markwon:simple-ext:4.6.2"
implementation 'com.google.guava:guava:32.1.2-jre'
implementation "io.noties.markwon:image-picasso:4.6.2"
implementation 'com.google.guava:guava:32.1.3-jre'
implementation "com.github.HamidrezaAmz:BreadcrumbsView:0.2.9"
//noinspection GradleDependency
implementation 'commons-io:commons-io:2.5'
@ -101,7 +100,7 @@ dependencies {
implementation 'ch.acra:acra-notification:5.11.3'
implementation 'androidx.room:room-runtime:2.6.1'
annotationProcessor 'androidx.room:room-compiler:2.6.1'
implementation "androidx.work:work-runtime:2.9.0"
implementation "androidx.work:work-runtime:2.9.1"
implementation "io.mikael:urlbuilder:2.0.9"
implementation "org.codeberg.gitnex-garage:emoji-java:v5.1.2"
//noinspection GradleDependency

View File

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.biometric.BiometricManager;
import java.util.Locale;
import org.mian.gitnex.R;
import org.mian.gitnex.core.MainApplication;
@ -118,15 +119,20 @@ public abstract class BaseActivity extends AppCompatActivity {
public void onResume() {
super.onResume();
if (Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_BIOMETRIC_KEY))
&& !Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_BIOMETRIC_LIFE_CYCLE_KEY))) {
if (BiometricManager.from(ctx)
.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_WEAK)
== BiometricManager.BIOMETRIC_SUCCESS) {
Intent unlockIntent = new Intent(ctx, BiometricUnlock.class);
ctx.startActivity(unlockIntent);
if (Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_BIOMETRIC_KEY))
&& !Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_BIOMETRIC_LIFE_CYCLE_KEY))) {
Intent unlockIntent = new Intent(ctx, BiometricUnlock.class);
ctx.startActivity(unlockIntent);
}
}
}

View File

@ -45,7 +45,7 @@ public class BiometricUnlock extends AppCompatActivity {
super.onAuthenticationError(errorCode, errString);
// Authentication error, close the app
MainActivity.closeActivity = true;
finish();
}

View File

@ -507,6 +507,8 @@ public class CreateIssueActivity extends BaseActivity
String newIssueTitleForm,
String newIssueDueDateForm) {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(false);
ArrayList<Long> labelIds = new ArrayList<>();
for (Integer i : labelsIds) {
labelIds.add((long) i);
@ -562,9 +564,11 @@ public class CreateIssueActivity extends BaseActivity
} else if (response2.code() == 401) {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(true);
AlertDialogs.authorizationTokenRevokedDialog(ctx);
} else {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(true);
SnackBar.error(
ctx,
findViewById(android.R.id.content),
@ -575,6 +579,7 @@ public class CreateIssueActivity extends BaseActivity
@Override
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(true);
SnackBar.error(
ctx,
findViewById(android.R.id.content),

View File

@ -414,6 +414,8 @@ public class CreatePullRequestActivity extends BaseActivity
List<String> assignees,
String prDueDate) {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(false);
ArrayList<Long> labelIds = new ArrayList<>();
for (Integer i : labelsIds) {
labelIds.add((long) i);
@ -470,18 +472,21 @@ public class CreatePullRequestActivity extends BaseActivity
} else if (response.code() == 409
|| response.message().equals("Conflict")) {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(false);
SnackBar.error(
ctx,
findViewById(android.R.id.content),
getString(R.string.prAlreadyExists));
} else if (response.code() == 404) {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(false);
SnackBar.error(
ctx,
findViewById(android.R.id.content),
getString(R.string.apiNotFound));
} else {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(false);
SnackBar.error(
ctx,
findViewById(android.R.id.content),
@ -492,6 +497,7 @@ public class CreatePullRequestActivity extends BaseActivity
@Override
public void onFailure(@NonNull Call<PullRequest> call, @NonNull Throwable t) {
viewBinding.topAppBar.getMenu().getItem(2).setVisible(false);
SnackBar.error(
ctx,
findViewById(android.R.id.content),

View File

@ -119,10 +119,9 @@ public class DeepLinksActivity extends BaseActivity {
finish();
} else if (Objects.equals(
data.getLastPathSegment(),
getAccount().getAccount().getUserName())) { // your user profile
mainIntent.putExtra("launchFragmentByLinkHandler", "profile");
ctx.startActivity(mainIntent);
finish();
getAccount().getAccount().getUserName())) { // user profile
new Handler(Looper.getMainLooper())
.postDelayed(() -> getUserOrOrg(data.getLastPathSegment()), 500);
} else if (Objects.equals(data.getLastPathSegment(), "admin")) {
mainIntent.putExtra("launchFragmentByLinkHandler", "admin");
ctx.startActivity(mainIntent);
@ -577,7 +576,9 @@ public class DeepLinksActivity extends BaseActivity {
public void onResponse(
@NonNull Call<Organization> call,
@NonNull Response<Organization> response) {
if (response.code() == 404) { // org doesn't exist or it's a user user
if (response.code() == 404
|| response.code()
== 504) { // org doesn't exist or it's a user user
Log.d("getUserOrOrg-404", String.valueOf(response.code()));
getUser(userOrgName);
} else if (response.code() == 200) { // org

View File

@ -373,8 +373,6 @@ public class IssueDetailActivity extends BaseActivity
.setSoftInputMode(
WindowManager.LayoutParams
.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
viewBinding.commentReply.setSelection(
viewBinding.commentReply.length());
viewBinding.send.setAlpha(buttonAlphaStatEnabled);
viewBinding.send.setEnabled(true);
} else {

View File

@ -60,7 +60,6 @@ import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ChangeLog;
import org.mian.gitnex.helpers.RoundedTransformation;
import org.mian.gitnex.helpers.Toasty;
import org.mian.gitnex.structs.BottomSheetListener;
import org.mian.gitnex.structs.FragmentRefreshListener;
@ -87,6 +86,7 @@ public class MainActivity extends BaseActivity
private BottomSheetListener profileInitListener;
private FragmentRefreshListener fragmentRefreshListenerMyIssues;
private String username;
public static boolean closeActivity = false;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -168,11 +168,11 @@ public class MainActivity extends BaseActivity
Menu menu = navigationView.getMenu();
navNotifications = menu.findItem(R.id.nav_notifications);
MenuItem navDashboard = menu.findItem(R.id.nav_dashboard);
/*MenuItem navDashboard = menu.findItem(R.id.nav_dashboard);
navDashboard.getActionView().findViewById(R.id.betaBadge).setVisibility(View.VISIBLE);
TextView dashboardBetaView = navDashboard.getActionView().findViewById(R.id.betaBadge);
dashboardBetaView.setText(R.string.beta);
dashboardBetaView.setText(R.string.beta);*/
navigationView
.getViewTreeObserver()
@ -250,8 +250,16 @@ public class MainActivity extends BaseActivity
String userFullNameNav = getAccount().getFullName();
String userAvatarNav = getAccount().getUserInfo().getAvatarUrl();
if (!userEmailNav.isEmpty()) {
userEmail.setText(userEmailNav);
if (Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx,
AppDatabaseSettings.APP_USER_HIDE_EMAIL_IN_NAV_KEY))) {
userEmail.setVisibility(View.GONE);
} else {
userEmail.setVisibility(View.VISIBLE);
if (!userEmailNav.isEmpty()) {
userEmail.setText(userEmailNav);
}
}
if (!userFullNameNav.isEmpty()) {
@ -260,13 +268,10 @@ public class MainActivity extends BaseActivity
if (!userAvatarNav.isEmpty()) {
int avatarRadius = AppUtil.getPixelsFromDensity(ctx, 60);
PicassoService.getInstance(ctx)
.get()
.load(userAvatarNav)
.placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(avatarRadius, 0))
.resize(160, 160)
.centerCrop()
.into(userAvatar);
@ -582,6 +587,11 @@ public class MainActivity extends BaseActivity
public void onResume() {
super.onResume();
if (closeActivity) {
finishAndRemoveTask();
closeActivity = false;
}
if (refActivity) {
this.recreate();
this.overridePendingTransition(0, 0);

View File

@ -126,7 +126,7 @@ public class ProfileActivity extends BaseActivity implements BottomSheetListener
RetrofitClient.getApiInterface(this)
.userCurrentCheckFollowing(username)
.enqueue(
new Callback<Void>() {
new Callback<>() {
@Override
public void onResponse(

View File

@ -141,6 +141,53 @@ public class SettingsAppearanceActivity extends BaseActivity {
activitySettingsAppearanceBinding.switchCounterBadge.setChecked(
!activitySettingsAppearanceBinding.switchCounterBadge.isChecked()));
// hide email and language in user profile screen switcher
activitySettingsAppearanceBinding.switchHideEmailLangInProfile.setChecked(
Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx,
AppDatabaseSettings.APP_USER_PROFILE_HIDE_EMAIL_LANGUAGE_KEY)));
activitySettingsAppearanceBinding.switchHideEmailLangInProfile.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(isChecked),
AppDatabaseSettings.APP_USER_PROFILE_HIDE_EMAIL_LANGUAGE_KEY);
SnackBar.success(
ctx,
findViewById(android.R.id.content),
getString(R.string.settingsSave));
});
activitySettingsAppearanceBinding.hideEmailLangInProfileFrame.setOnClickListener(
v ->
activitySettingsAppearanceBinding.switchHideEmailLangInProfile.setChecked(
!activitySettingsAppearanceBinding.switchHideEmailLangInProfile
.isChecked()));
// hide email in app navigation drawer switcher
activitySettingsAppearanceBinding.switchHideEmailNavDrawer.setChecked(
Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
ctx, AppDatabaseSettings.APP_USER_HIDE_EMAIL_IN_NAV_KEY)));
activitySettingsAppearanceBinding.switchHideEmailNavDrawer.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
AppDatabaseSettings.updateSettingsValue(
ctx,
String.valueOf(isChecked),
AppDatabaseSettings.APP_USER_HIDE_EMAIL_IN_NAV_KEY);
SnackBar.success(
ctx,
findViewById(android.R.id.content),
getString(R.string.settingsSave));
});
activitySettingsAppearanceBinding.hideEmailNavDrawerFrame.setOnClickListener(
v ->
activitySettingsAppearanceBinding.switchHideEmailNavDrawer.setChecked(
!activitySettingsAppearanceBinding.switchHideEmailNavDrawer
.isChecked()));
// show labels in lists(issues, pr) - default is color dots
activitySettingsAppearanceBinding.switchLabelsInListBadge.setChecked(
Boolean.parseBoolean(

View File

@ -29,7 +29,7 @@ public class AdminCronTasksAdapter
private final List<Cron> tasksList;
static class CronTasksViewHolder extends RecyclerView.ViewHolder {
public static class CronTasksViewHolder extends RecyclerView.ViewHolder {
private Cron cronTasks;

View File

@ -181,7 +181,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
userLoginId = users.getLogin();
if (!users.getFullName().equals("")) {
if (!users.getFullName().isEmpty()) {
userFullName.setText(Html.fromHtml(users.getFullName()));
userName.setText(
@ -195,7 +195,7 @@ public class AdminGetUsersAdapter extends RecyclerView.Adapter<RecyclerView.View
userName.setVisibility(View.GONE);
}
if (!users.getEmail().equals("")) {
if (!users.getEmail().isEmpty()) {
userEmail.setText(users.getEmail());
} else {
userEmail.setVisibility(View.GONE);

View File

@ -182,7 +182,7 @@ public class AdminUnadoptedReposAdapter
isLoading = false;
}
class UnadoptedViewHolder extends RecyclerView.ViewHolder {
public class UnadoptedViewHolder extends RecyclerView.ViewHolder {
private final TextView name;
private String repoName;

View File

@ -61,7 +61,7 @@ public class AssigneesListAdapter
User currentItem = assigneesList.get(position);
int imgRadius = AppUtil.getPixelsFromDensity(context, 90);
if (currentItem.getFullName().equals("")) {
if (currentItem.getFullName().isEmpty()) {
holder.assigneesName.setText(currentItem.getLogin());
} else {
@ -132,7 +132,7 @@ public class AssigneesListAdapter
void assigneesInterface(List<String> data);
}
static class AssigneesViewHolder extends RecyclerView.ViewHolder {
public static class AssigneesViewHolder extends RecyclerView.ViewHolder {
private final CheckBox assigneesSelection;
private final TextView assigneesName;

View File

@ -64,7 +64,7 @@ public class CollaboratorSearchAdapter
int imgRadius = AppUtil.getPixelsFromDensity(context, 60);
holder.userInfo = currentItem;
if (!currentItem.getFullName().equals("")) {
if (!currentItem.getFullName().isEmpty()) {
holder.userFullName.setText(Html.fromHtml(currentItem.getFullName()));
} else {
@ -77,7 +77,7 @@ public class CollaboratorSearchAdapter
holder.userName.setText(
context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
if (!currentItem.getAvatarUrl().equals("")) {
if (!currentItem.getAvatarUrl().isEmpty()) {
PicassoService.getInstance(context)
.get()
.load(currentItem.getAvatarUrl())
@ -140,7 +140,7 @@ public class CollaboratorSearchAdapter
return usersSearchList.size();
}
class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
public class CollaboratorSearchViewHolder extends RecyclerView.ViewHolder {
private final ImageView userAvatar;
private final TextView userFullName;

View File

@ -83,7 +83,7 @@ public class CollaboratorsAdapter extends BaseAdapter {
viewHolder.userLoginId = currentItem.getLogin();
if (!currentItem.getFullName().equals("")) {
if (!currentItem.getFullName().isEmpty()) {
viewHolder.collaboratorName.setText(Html.fromHtml(currentItem.getFullName()));
viewHolder.userName.setText(

View File

@ -24,7 +24,7 @@ public class CommitStatusesAdapter
private final List<CommitStatus> statuses;
static class CommitStatusesViewHolder extends RecyclerView.ViewHolder {
public static class CommitStatusesViewHolder extends RecyclerView.ViewHolder {
private CommitStatus status;
@ -44,7 +44,7 @@ public class CommitStatusesAdapter
}
private void openUrl() {
if (status.getTargetUrl() != null && !status.getTargetUrl().equals("")) {
if (status.getTargetUrl() != null && !status.getTargetUrl().isEmpty()) {
AppUtil.openUrlInBrowser(itemView.getContext(), status.getTargetUrl());
} else {
Toasty.info(

View File

@ -147,7 +147,7 @@ public class DiffAdapter extends BaseAdapter {
private int getLineColor(String line) {
if (line.length() == 0) {
if (line.isEmpty()) {
return COLOR_NORMAL;
}

View File

@ -113,7 +113,7 @@ public class DraftsAdapter extends RecyclerView.Adapter<DraftsAdapter.DraftsView
notifyDataChanged();
}
class DraftsViewHolder extends RecyclerView.ViewHolder {
public class DraftsViewHolder extends RecyclerView.ViewHolder {
private final TextView draftText;
private final TextView repoInfo;

View File

@ -152,7 +152,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
.buildRoundRect(firstCharacter, color, 14);
if (userRepositories.getAvatarUrl() != null) {
if (!userRepositories.getAvatarUrl().equals("")) {
if (!userRepositories.getAvatarUrl().isEmpty()) {
PicassoService.getInstance(context)
.get()
.load(userRepositories.getAvatarUrl())
@ -182,7 +182,7 @@ public class ExploreRepositoriesAdapter extends RecyclerView.Adapter<RecyclerVie
repoLastUpdated.setVisibility(View.GONE);
}
if (!userRepositories.getDescription().equals("")) {
if (!userRepositories.getDescription().isEmpty()) {
repoDescription.setVisibility(View.VISIBLE);
repoDescription.setText(userRepositories.getDescription());
spacerView.setVisibility(View.GONE);

View File

@ -1,5 +1,6 @@
package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
@ -57,6 +58,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
return results;
}
@SuppressLint("NotifyDataSetChanged")
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
@ -77,6 +79,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
return originalFiles;
}
@SuppressLint("NotifyDataSetChanged")
public void notifyOriginalDataSetChanged() {
alteredFiles.clear();
@ -150,7 +153,7 @@ public class FilesAdapter extends RecyclerView.Adapter<FilesAdapter.FilesViewHol
void onClickFile(ContentsResponse file);
}
class FilesViewHolder extends RecyclerView.ViewHolder {
public class FilesViewHolder extends RecyclerView.ViewHolder {
private final ImageView fileTypeIs;
private final TextView fileName;

View File

@ -79,7 +79,7 @@ public class LabelsAdapter extends RecyclerView.Adapter<LabelsAdapter.LabelsView
notifyDataSetChanged();
}
class LabelsViewHolder extends RecyclerView.ViewHolder {
public class LabelsViewHolder extends RecyclerView.ViewHolder {
private final MaterialCardView labelView;
private final ImageView labelIcon;

View File

@ -1,5 +1,6 @@
package org.mian.gitnex.adapters;
import android.annotation.SuppressLint;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
@ -103,6 +104,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
return labels.size();
}
@SuppressLint("NotifyDataSetChanged")
public void updateList(List<Integer> list) {
currentLabelsIds = list;
@ -116,7 +118,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
void labelsIdsInterface(List<Integer> data);
}
static class LabelsViewHolder extends RecyclerView.ViewHolder {
public static class LabelsViewHolder extends RecyclerView.ViewHolder {
private final CheckBox labelSelection;
private final TextView labelText;

View File

@ -34,7 +34,7 @@ public class MostVisitedReposAdapter
private List<Repository> mostVisitedReposList;
private final Context ctx;
class MostVisitedViewHolder extends RecyclerView.ViewHolder {
public class MostVisitedViewHolder extends RecyclerView.ViewHolder {
private Repository repository;

View File

@ -63,7 +63,7 @@ public class OrganizationAddUserToTeamMemberAdapter
holder.userInfo = currentItem;
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
if (!currentItem.getFullName().equals("")) {
if (!currentItem.getFullName().isEmpty()) {
holder.userFullName.setText(Html.fromHtml(currentItem.getFullName()));
} else {
@ -76,7 +76,7 @@ public class OrganizationAddUserToTeamMemberAdapter
holder.userName.setText(
context.getResources().getString(R.string.usernameWithAt, currentItem.getLogin()));
if (!currentItem.getAvatarUrl().equals("")) {
if (!currentItem.getAvatarUrl().isEmpty()) {
PicassoService.getInstance(context)
.get()
.load(currentItem.getAvatarUrl())
@ -142,7 +142,7 @@ public class OrganizationAddUserToTeamMemberAdapter
return usersSearchList.size();
}
class UserSearchViewHolder extends RecyclerView.ViewHolder {
public class UserSearchViewHolder extends RecyclerView.ViewHolder {
private final ImageView userAvatar;
private final TextView userFullName;

View File

@ -55,7 +55,7 @@ public class OrganizationTeamMembersPreviewAdapter
return userData.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
public static class ViewHolder extends RecyclerView.ViewHolder {
private final ImageView avatar;

View File

@ -50,7 +50,7 @@ public class OrganizationTeamRepositoriesAdapter
reposArr = new ArrayList<>();
}
class TeamReposViewHolder extends RecyclerView.ViewHolder {
public class TeamReposViewHolder extends RecyclerView.ViewHolder {
private Repository repoInfo;
@ -75,7 +75,7 @@ public class OrganizationTeamRepositoriesAdapter
new Handler(Looper.getMainLooper())
.postDelayed(
() -> {
if (reposArr.size() > 0) {
if (!reposArr.isEmpty()) {
for (int i = 0; i < reposArr.size(); i++) {
if (!reposArr.get(i).getName().equals(repoInfo.getName())) {
addRepoButtonAdd.setVisibility(View.VISIBLE);
@ -144,7 +144,7 @@ public class OrganizationTeamRepositoriesAdapter
.getColor(currentItem.getName()),
14);
if (currentItem.getAvatarUrl() != null && !currentItem.getAvatarUrl().equals("")) {
if (currentItem.getAvatarUrl() != null && !currentItem.getAvatarUrl().isEmpty()) {
PicassoService.getInstance(context)
.get()
.load(currentItem.getAvatarUrl())

View File

@ -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;
@ -38,7 +39,7 @@ public class OrganizationTeamsAdapter
private final OrganizationPermissions permissions;
private final String orgName;
static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
public static class OrgTeamsViewHolder extends RecyclerView.ViewHolder {
private Team team;
@ -101,6 +102,7 @@ public class OrganizationTeamsAdapter
return new OrganizationTeamsAdapter.OrgTeamsViewHolder(v);
}
@SuppressLint("NotifyDataSetChanged")
@Override
public void onBindViewHolder(
@NonNull OrganizationTeamsAdapter.OrgTeamsViewHolder holder, int position) {
@ -126,7 +128,7 @@ public class OrganizationTeamsAdapter
@NonNull Response<List<User>> response) {
if (response.isSuccessful()
&& response.body() != null
&& response.body().size() > 0) {
&& !response.body().isEmpty()) {
holder.membersPreviewFrame.setVisibility(View.VISIBLE);
holder.userInfos.addAll(
@ -189,6 +191,7 @@ public class OrganizationTeamsAdapter
return results;
}
@SuppressLint("NotifyDataSetChanged")
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
teamList.clear();

View File

@ -182,7 +182,7 @@ public class OrganizationsListAdapter extends RecyclerView.Adapter<RecyclerView.
.centerCrop()
.into(image);
if (!org.getDescription().equals("")) {
if (!org.getDescription().isEmpty()) {
orgDescription.setVisibility(View.VISIBLE);
orgDescription.setText(org.getDescription());
} else {

View File

@ -64,7 +64,7 @@ public class ReactionAuthorsAdapter
return userInfos.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
public static class ViewHolder extends RecyclerView.ViewHolder {
private final ImageView authorAvatar;

View File

@ -125,7 +125,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
TimeHelper.customDateFormatForToastDateFormat(currentItem.getPublishedAt()),
context));
if (!currentItem.getBody().equals("")) {
if (!currentItem.getBody().isEmpty()) {
Markdown.render(context, currentItem.getBody(), holder.releaseBodyContent);
} else {
holder.releaseBodyContent.setText(R.string.noReleaseBodyContent);
@ -279,7 +279,7 @@ public class ReleasesAdapter extends RecyclerView.Adapter<ReleasesAdapter.Releas
void onLoadFinished();
}
protected class ReleasesViewHolder extends RecyclerView.ViewHolder {
public class ReleasesViewHolder extends RecyclerView.ViewHolder {
private final TextView releaseType;
private final TextView releaseName;

View File

@ -55,7 +55,7 @@ public class ReleasesDownloadsAdapter
return releasesDownloadsList.size();
}
static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
public static class ReleasesDownloadsViewHolder extends RecyclerView.ViewHolder {
private final TextView downloadName;

View File

@ -155,7 +155,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
void onLoadFinished();
}
class ForksHolder extends RecyclerView.ViewHolder {
public class ForksHolder extends RecyclerView.ViewHolder {
private final ImageView image;
private final TextView repoName;
@ -206,7 +206,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
.buildRoundRect(firstCharacter, color, 3);
if (forksModel.getAvatarUrl() != null) {
if (!forksModel.getAvatarUrl().equals("")) {
if (!forksModel.getAvatarUrl().isEmpty()) {
PicassoService.getInstance(context)
.get()
.load(forksModel.getAvatarUrl())
@ -236,7 +236,7 @@ public class RepoForksAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
repoLastUpdated.setVisibility(View.GONE);
}
if (!forksModel.getDescription().equals("")) {
if (!forksModel.getDescription().isEmpty()) {
repoDescription.setText(forksModel.getDescription());
} else {
repoDescription.setText(context.getString(R.string.noDataDescription));

View File

@ -153,7 +153,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
void onLoadFinished();
}
class ReposHolder extends RecyclerView.ViewHolder {
public class ReposHolder extends RecyclerView.ViewHolder {
private final ImageView image;
private final TextView repoName;
@ -217,7 +217,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
.buildRoundRect(firstCharacter, color, 14);
if (repositories.getAvatarUrl() != null) {
if (!repositories.getAvatarUrl().equals("")) {
if (!repositories.getAvatarUrl().isEmpty()) {
PicassoService.getInstance(context)
.get()
.load(repositories.getAvatarUrl())
@ -244,7 +244,7 @@ public class ReposListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
repoLastUpdated.setVisibility(View.GONE);
}
if (!repositories.getDescription().equals("")) {
if (!repositories.getDescription().isEmpty()) {
repoDescription.setVisibility(View.VISIBLE);
repoDescription.setText(repositories.getDescription());
spacerView.setVisibility(View.GONE);

View File

@ -44,7 +44,7 @@ public class SSHKeysAdapter extends RecyclerView.Adapter<SSHKeysAdapter.KeysView
return keysList.size();
}
static class KeysViewHolder extends RecyclerView.ViewHolder {
public static class KeysViewHolder extends RecyclerView.ViewHolder {
private final TextView keyName;
private final TextView key;

View File

@ -99,8 +99,7 @@ public class UserAccountsAdapter
}
@NonNull @Override
public UserAccountsAdapter.UserAccountsViewHolder onCreateViewHolder(
@NonNull ViewGroup parent, int viewType) {
public UserAccountsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v =
LayoutInflater.from(parent.getContext())
@ -110,8 +109,7 @@ public class UserAccountsAdapter
@SuppressLint("DefaultLocale")
@Override
public void onBindViewHolder(
@NonNull UserAccountsAdapter.UserAccountsViewHolder holder, int position) {
public void onBindViewHolder(@NonNull UserAccountsViewHolder holder, int position) {
UserAccount currentItem = userAccountsList.get(position);
@ -150,7 +148,7 @@ public class UserAccountsAdapter
return userAccountsList.size();
}
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
public class UserAccountsViewHolder extends RecyclerView.ViewHolder {
private final TextView accountUrl;
private final TextView userId;

View File

@ -101,7 +101,7 @@ public class UserAccountsNavAdapter
dialog.show();
}
class UserAccountsViewHolder extends RecyclerView.ViewHolder {
public class UserAccountsViewHolder extends RecyclerView.ViewHolder {
private final ImageView userAccountAvatar;

View File

@ -120,7 +120,7 @@ public class UserGridAdapter extends BaseAdapter implements Filterable {
viewHolder.userLoginId = currentItem.getLogin();
if (!currentItem.getFullName().equals("")) {
if (!currentItem.getFullName().isEmpty()) {
viewHolder.memberName.setText(Html.fromHtml(currentItem.getFullName()));
viewHolder.userName.setText(

View File

@ -129,7 +129,7 @@ public class UsersAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
this.userInfo = userInfo;
int imgRadius = AppUtil.getPixelsFromDensity(context, 3);
if (!userInfo.getFullName().equals("")) {
if (!userInfo.getFullName().isEmpty()) {
userFullName.setText(Html.fromHtml(userInfo.getFullName()));
userName.setText(
context.getResources()

View File

@ -35,6 +35,7 @@ import org.mian.gitnex.databinding.CustomEditAvatarDialogBinding;
import org.mian.gitnex.databinding.CustomEditProfileBinding;
import org.mian.gitnex.databinding.FragmentProfileDetailBinding;
import org.mian.gitnex.helpers.AlertDialogs;
import org.mian.gitnex.helpers.AppDatabaseSettings;
import org.mian.gitnex.helpers.AppUtil;
import org.mian.gitnex.helpers.ClickListener;
import org.mian.gitnex.helpers.Markdown;
@ -62,6 +63,7 @@ public class DetailFragment extends Fragment {
private int imgRadius;
private static Uri avatarUri = null;
public static boolean refProfile = false;
public boolean itsMe = false;
public DetailFragment() {}
@ -109,6 +111,7 @@ public class DetailFragment extends Fragment {
if (username.equals(((BaseActivity) context).getAccount().getAccount().getUserName())) {
binding.metaProfile.setVisibility(View.VISIBLE);
itsMe = true;
} else {
binding.metaProfile.setVisibility(View.GONE);
}
@ -366,7 +369,19 @@ public class DetailFragment extends Fragment {
getString(
R.string.usernameWithAt,
response.body().getLogin()));
binding.userEmail.setText(email);
if (Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
context,
AppDatabaseSettings
.APP_USER_PROFILE_HIDE_EMAIL_LANGUAGE_KEY))
&& itsMe) {
binding.userEmail.setText(
getString(R.string.strPrivate).toUpperCase());
binding.userEmail.setAlpha(.4F);
} else {
binding.userEmail.setText(email);
}
binding.userFollowersCount.setText(
String.format(
@ -389,13 +404,25 @@ public class DetailFragment extends Fragment {
String[] userLanguageCodes =
response.body().getLanguage().split("-");
if (userLanguageCodes.length >= 2) {
Locale locale =
new Locale(
userLanguageCodes[0], userLanguageCodes[1]);
binding.userLang.setText(locale.getDisplayLanguage());
if (Boolean.parseBoolean(
AppDatabaseSettings.getSettingsValue(
context,
AppDatabaseSettings
.APP_USER_PROFILE_HIDE_EMAIL_LANGUAGE_KEY))
&& itsMe) {
binding.userLang.setText(
getString(R.string.strPrivate).toUpperCase());
binding.userLang.setAlpha(.4F);
} else {
binding.userLang.setText(locale.getDisplayLanguage());
if (userLanguageCodes.length >= 2) {
Locale locale =
new Locale(
userLanguageCodes[0],
userLanguageCodes[1]);
binding.userLang.setText(locale.getDisplayLanguage());
} else {
binding.userLang.setText(locale.getDisplayLanguage());
}
}
PicassoService.getInstance(context)
@ -415,6 +442,30 @@ public class DetailFragment extends Fragment {
TimeHelper.customDateFormatForToastDateFormat(
response.body().getCreated()),
context));
if (!response.body().getWebsite().isEmpty()) {
binding.website.setText(response.body().getWebsite());
} else {
binding.website.setText(R.string.noDataWebsite);
binding.website.setAlpha(.4F);
}
if (!response.body().getLocation().isEmpty()) {
binding.location.setText(response.body().getLocation());
} else {
binding.location.setText(R.string.noDataLocation);
binding.location.setAlpha(.4F);
}