[UI] Add Pull & Release Counter Badge to TabLable #350
@ -52,6 +52,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
|
||||
private TextView textViewBadgeIssue;
|
||||
private TextView textViewBadgePull;
|
||||
private TextView textViewBadgeRelease;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResourceId(){
|
||||
@ -138,22 +139,38 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
@SuppressLint("InflateParams") View tabHeader4 = LayoutInflater.from(this).inflate(R.layout.badge_pull, null);
|
||||
textViewBadgePull = tabHeader4.findViewById(R.id.counterBadgePull);
|
||||
|
||||
@SuppressLint("InflateParams") View tabHeader6 = LayoutInflater.from(this).inflate(R.layout.badge_release, null);
|
||||
textViewBadgeRelease = tabHeader6.findViewById(R.id.counterBadgeRelease);
|
||||
|
||||
if(!tinyDb.getString("issuesCounter").isEmpty()) {
|
||||
|
||||
getRepoInfo(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName1);
|
||||
}
|
||||
Objects.requireNonNull(tabLayout.getTabAt(2)).setCustomView(tabHeader2);
|
||||
|
||||
// issue count
|
||||
TabLayout.Tab tabOpenIssues = tabLayout.getTabAt(2);
|
||||
ColorStateList textColor = tabLayout.getTabTextColors();
|
||||
assert tabOpenIssues != null;
|
||||
TextView openIssueTabView = Objects.requireNonNull(tabOpenIssues.getCustomView()).findViewById(R.id.counterBadgeIssueText);
|
||||
openIssueTabView.setTextColor(textColor);
|
||||
|
||||
Objects.requireNonNull(tabLayout.getTabAt(4)).setCustomView(tabHeader4);
|
||||
TabLayout.Tab tabOpenPulls = tabLayout.getTabAt(4);
|
||||
assert tabOpenPulls != null;
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
// pull count
|
||||
if (textViewBadgePull.getText() != "") { // only show if API returned a number
|
||||
Objects.requireNonNull(tabLayout.getTabAt(4)).setCustomView(tabHeader4);
|
||||
TabLayout.Tab tabOpenPulls = tabLayout.getTabAt(4);
|
||||
assert tabOpenPulls != null;
|
||||
TextView openPullTabView = Objects.requireNonNull(tabOpenPulls.getCustomView()).findViewById(R.id.counterBadgePullText);
|
||||
openPullTabView.setTextColor(textColor);
|
||||
}
|
||||
|
||||
// release count
|
||||
if (textViewBadgeRelease.getText() != "") { // only show if API returned a number
|
||||
Objects.requireNonNull(tabLayout.getTabAt(6)).setCustomView(tabHeader6);
|
||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(6);
|
||||
assert tabOpenRelease != null;
|
||||
TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText);
|
||||
openReleaseTabView.setTextColor(textColor);
|
||||
}
|
||||
}
|
||||
|
||||
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName1);
|
||||
@ -323,6 +340,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
||||
assert repoInfo != null;
|
||||
textViewBadgeIssue.setText(repoInfo.getOpen_issues_count());
|
||||
textViewBadgePull.setText(repoInfo.getOpen_pull_count());
|
||||
textViewBadgeRelease.setText(repoInfo.getRelease_count());
|
||||
|
||||
}
|
||||
|
||||
|
30
app/src/main/res/layout/badge_release.xml
Normal file
30
app/src/main/res/layout/badge_release.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/counterBadgeReleaseText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textSize="16sp"
|
||||
app:textAllCaps="true"
|
||||
android:text="@string/tab_text_releases"
|
||||
android:textColor="@color/lightGray" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/counterBadgeRelease"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:layout_toEndOf="@id/counterBadgeReleaseText"
|
||||
android:background="@drawable/badge_background"
|
||||
android:gravity="center"
|
||||
android:text="@string/infoTabRepoZero"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</RelativeLayout>
|
Reference in New Issue
Block a user
No idea where is this value set?
It was there before ...