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:
image: curlimages/curl:7.82.0
group: upload
environment:
WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk"
@ -37,7 +36,6 @@ steps:
upload-release:
image: curlimages/curl:7.82.0
group: upload
environment:
WEBDAV_USERNAME: "GitNexBot"
PLUGIN_FILE: "signed.apk"

View File

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

View File

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

View File

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

View File

@ -400,7 +400,7 @@ public class RepoInfoFragment extends Fragment {
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) {
binding.repoMetaPullRequests.setText(String.valueOf(repoInfo.getOpenPrCounter()));

View File

@ -1,5 +1,6 @@
package org.mian.gitnex.helpers;
import android.util.Log;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.List;
@ -55,7 +56,8 @@ public class Version {
}
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")) {
dev = true;

View File

@ -209,6 +209,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen12dp"
android:visibility="gone"
android:orientation="horizontal">
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
@ -226,7 +227,7 @@
app:iconTint="?attr/materialCardBackgroundColor"
android:backgroundTint="?attr/fabColor"
app:icon="@drawable/ic_feedback" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

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

View File

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