Show org fullname and other improvements (#1324)

Closes #1323

Closes #1319

Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1324
Co-authored-by: M M Arif <mmarif@swatian.com>
Co-committed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
M M Arif 2024-02-22 14:38:21 +00:00 committed by M M Arif
parent f3b8719d02
commit 51d0e31adc
9 changed files with 43 additions and 45 deletions

View File

@ -22,7 +22,6 @@ steps:
upload: upload:
image: curlimages/curl:7.82.0 image: curlimages/curl:7.82.0
group: upload
environment: environment:
WEBDAV_USERNAME: "GitNexBot" WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk" PLUGIN_FILE: "signed.apk"
@ -37,7 +36,6 @@ steps:
upload-release: upload-release:
image: curlimages/curl:7.82.0 image: curlimages/curl:7.82.0
group: upload
environment: environment:
WEBDAV_USERNAME: "GitNexBot" WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk" PLUGIN_FILE: "signed.apk"

View File

@ -1,7 +1,6 @@
steps: steps:
author-header: author-header:
image: qwerty287/woodpecker-regex-check image: qwerty287/woodpecker-regex-check
group: check
settings: settings:
pattern: "*.java" pattern: "*.java"
regex: " \\\\* \\\\@author [\\\\S\\\\s]+" regex: " \\\\* \\\\@author [\\\\S\\\\s]+"
@ -9,7 +8,6 @@ steps:
style: style:
image: alvrme/alpine-android:android-32-jdk17 image: alvrme/alpine-android:android-32-jdk17
group: check
commands: commands:
- ./gradlew :app:spotlessCheck - ./gradlew :app:spotlessCheck

View File

@ -124,7 +124,7 @@ public class MostVisitedReposFragment extends Fragment {
MenuItem searchItem = menu.findItem(R.id.action_search); MenuItem searchItem = menu.findItem(R.id.action_search);
SearchView searchView = (SearchView) searchItem.getActionView(); SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setImeOptions(EditorInfo.IME_ACTION_DONE); Objects.requireNonNull(searchView).setImeOptions(EditorInfo.IME_ACTION_DONE);
searchView.setOnQueryTextListener( searchView.setOnQueryTextListener(
new SearchView.OnQueryTextListener() { new SearchView.OnQueryTextListener() {

View File

@ -6,10 +6,6 @@ import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import org.gitnex.tea4j.v2.models.Organization; import org.gitnex.tea4j.v2.models.Organization;
@ -27,15 +23,10 @@ import retrofit2.Callback;
*/ */
public class OrganizationInfoFragment extends Fragment { public class OrganizationInfoFragment extends Fragment {
FragmentOrganizationInfoBinding fragmentOrganizationInfoBinding;
private static final String orgNameF = "param1"; private static final String orgNameF = "param1";
private Context ctx; private Context ctx;
private ProgressBar mProgressBar;
private String orgName; private String orgName;
private ImageView orgAvatar;
private TextView orgDescInfo;
private TextView orgWebsiteInfo;
private TextView orgLocationInfo;
private LinearLayout orgInfoLayout;
public OrganizationInfoFragment() {} public OrganizationInfoFragment() {}
@ -59,21 +50,11 @@ public class OrganizationInfoFragment extends Fragment {
public View onCreateView( public View onCreateView(
@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
FragmentOrganizationInfoBinding fragmentOrganizationInfoBinding = fragmentOrganizationInfoBinding =
FragmentOrganizationInfoBinding.inflate(inflater, container, false); FragmentOrganizationInfoBinding.inflate(inflater, container, false);
ctx = getContext(); ctx = getContext();
mProgressBar = fragmentOrganizationInfoBinding.progressBar;
orgAvatar = fragmentOrganizationInfoBinding.orgAvatar;
TextView orgNameInfo = fragmentOrganizationInfoBinding.orgNameInfo;
orgDescInfo = fragmentOrganizationInfoBinding.orgDescInfo;
orgWebsiteInfo = fragmentOrganizationInfoBinding.orgWebsiteInfo;
orgLocationInfo = fragmentOrganizationInfoBinding.orgLocationInfo;
orgInfoLayout = fragmentOrganizationInfoBinding.orgInfoLayout;
orgNameInfo.setText(orgName);
getOrgInfo(orgName); getOrgInfo(orgName);
return fragmentOrganizationInfoBinding.getRoot(); return fragmentOrganizationInfoBinding.getRoot();
@ -84,7 +65,7 @@ public class OrganizationInfoFragment extends Fragment {
Call<Organization> call = RetrofitClient.getApiInterface(getContext()).orgGet(owner); Call<Organization> call = RetrofitClient.getApiInterface(getContext()).orgGet(owner);
call.enqueue( call.enqueue(
new Callback<Organization>() { new Callback<>() {
@Override @Override
public void onResponse( public void onResponse(
@ -95,7 +76,8 @@ public class OrganizationInfoFragment extends Fragment {
if (response.code() == 200) { if (response.code() == 200) {
orgInfoLayout.setVisibility(View.VISIBLE); fragmentOrganizationInfoBinding.orgInfoLayout.setVisibility(
View.VISIBLE);
assert orgInfo != null; assert orgInfo != null;
@ -106,31 +88,49 @@ public class OrganizationInfoFragment extends Fragment {
.transform(new RoundedTransformation(8, 0)) .transform(new RoundedTransformation(8, 0))
.resize(230, 230) .resize(230, 230)
.centerCrop() .centerCrop()
.into(orgAvatar); .into(fragmentOrganizationInfoBinding.orgAvatar);
if (orgInfo.getFullName() != null && !orgInfo.getFullName().isEmpty()) {
fragmentOrganizationInfoBinding.orgNameInfo.setText(
getString(
R.string.organizationFullname,
orgInfo.getFullName(),
orgName));
} else {
fragmentOrganizationInfoBinding.orgNameInfo.setText(orgName);
}
if (!orgInfo.getDescription().isEmpty()) { if (!orgInfo.getDescription().isEmpty()) {
Markdown.render(ctx, orgInfo.getDescription(), orgDescInfo); Markdown.render(
ctx,
orgInfo.getDescription(),
fragmentOrganizationInfoBinding.orgDescInfo);
} else { } else {
orgDescInfo.setText(getString(R.string.noDataDescription)); fragmentOrganizationInfoBinding.orgDescInfo.setText(
getString(R.string.noDataDescription));
} }
if (!orgInfo.getWebsite().isEmpty()) { if (!orgInfo.getWebsite().isEmpty()) {
orgWebsiteInfo.setText(orgInfo.getWebsite()); fragmentOrganizationInfoBinding.orgWebsiteInfo.setText(
orgInfo.getWebsite());
} else { } else {
orgWebsiteInfo.setText(getString(R.string.noDataWebsite)); fragmentOrganizationInfoBinding.orgWebsiteInfo.setText(
getString(R.string.noDataWebsite));
} }
if (!orgInfo.getLocation().isEmpty()) { if (!orgInfo.getLocation().isEmpty()) {
orgLocationInfo.setText(orgInfo.getLocation()); fragmentOrganizationInfoBinding.orgLocationInfo.setText(
orgInfo.getLocation());
} else { } else {
orgLocationInfo.setText(getString(R.string.noDataLocation)); fragmentOrganizationInfoBinding.orgLocationInfo.setText(
getString(R.string.noDataLocation));
} }
mProgressBar.setVisibility(View.GONE); fragmentOrganizationInfoBinding.progressBar.setVisibility(View.GONE);
} else if (response.code() == 404) { } else if (response.code() == 404) {
mProgressBar.setVisibility(View.GONE); fragmentOrganizationInfoBinding.progressBar.setVisibility(View.GONE);
} else { } else {
Log.e("onFailure", String.valueOf(response.code())); Log.e("onFailure", String.valueOf(response.code()));
@ -138,9 +138,7 @@ public class OrganizationInfoFragment extends Fragment {
} }
@Override @Override
public void onFailure(@NonNull Call<Organization> call, @NonNull Throwable t) { public void onFailure(@NonNull Call<Organization> call, @NonNull Throwable t) {}
Log.e("onFailure", t.toString());
}
}); });
} }
} }

View File

@ -400,7 +400,7 @@ public class RepoInfoFragment extends Fragment {
binding.repoMetaDescription.setText(getString(R.string.noDataDescription)); binding.repoMetaDescription.setText(getString(R.string.noDataDescription));
} }
binding.repoMetaStars.setText(String.valueOf(repoInfo.getStarsCount())); binding.repoMetaStars.setText(AppUtil.numberFormatter(repoInfo.getStarsCount()));
if (repoInfo.getOpenPrCounter() != null) { if (repoInfo.getOpenPrCounter() != null) {
binding.repoMetaPullRequests.setText(String.valueOf(repoInfo.getOpenPrCounter())); binding.repoMetaPullRequests.setText(String.valueOf(repoInfo.getOpenPrCounter()));

View File

@ -1,5 +1,6 @@
package org.mian.gitnex.helpers; package org.mian.gitnex.helpers;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -55,7 +56,8 @@ public class Version {
} }
if (!valid(raw)) { if (!valid(raw)) {
throw new IllegalArgumentException("Invalid version format: " + raw); // throw new IllegalArgumentException("Invalid version format: " + raw);
Log.e("Version", "Invalid version format: " + raw);
} }
if (raw.equals("main")) { if (raw.equals("main")) {
dev = true; dev = true;

View File

@ -209,6 +209,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp" android:layout_marginTop="@dimen/dimen12dp"
android:visibility="gone"
android:orientation="horizontal"> android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton

View File

@ -79,6 +79,7 @@
<string name="newOrgTintCopy">Organization Name</string> <string name="newOrgTintCopy">Organization Name</string>
<string name="newOrgDescTintCopy">Organization Description</string> <string name="newOrgDescTintCopy">Organization Description</string>
<string name="organizationFullname">%1$s - %2$s</string>
<string name="userName">Username</string> <string name="userName">Username</string>
<string name="passWord">Password</string> <string name="passWord">Password</string>

View File

@ -9,10 +9,10 @@ import org.junit.Test;
*/ */
public class VersionTest { public class VersionTest {
@Test /*@Test
public void invalid() { public void invalid() {
assertThrows(IllegalArgumentException.class, () -> new Version("abcd")); assertThrows(IllegalArgumentException.class, () -> new Version("abcd"));
} }*/
@Test @Test
public void equal() { public void equal() {