use of com.meisolsson.githubsdk.model.Repository in project gh4a by slapperwan.
the class SearchFragment method openFileViewer.
private void openFileViewer(SearchCode result, int matchIndex) {
Repository repo = result.repository();
Uri uri = Uri.parse(result.url());
String ref = uri.getQueryParameter("ref");
TextMatch textMatch = matchIndex >= 0 ? result.textMatches().get(matchIndex) : null;
startActivity(FileViewerActivity.makeIntentWithSearchMatch(getActivity(), repo.owner().login(), repo.name(), ref, result.path(), textMatch));
}
use of com.meisolsson.githubsdk.model.Repository in project gh4a by slapperwan.
the class NotificationsJob method showSummaryNotification.
private void showSummaryNotification(NotificationManagerCompat nm, List<List<NotificationThread>> notificationsPerRepo, boolean hasNewNotification) {
int totalCount = 0;
for (List<NotificationThread> list : notificationsPerRepo) {
totalCount += list.size();
}
String title = getContext().getString(R.string.unread_notifications_summary_title);
String text = getContext().getResources().getQuantityString(R.plurals.unread_notifications_summary_text, totalCount, totalCount);
Notification publicVersion = makeBaseBuilder().setContentTitle(title).setContentText(text).setNumber(totalCount).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).build();
PendingIntent contentIntent = PendingIntent.getActivity(getContext(), 0, HomeActivity.makeIntent(getContext(), R.id.notifications), 0);
PendingIntent deleteIntent = PendingIntent.getService(getContext(), 0, NotificationHandlingService.makeMarkNotificationsSeenIntent(getContext()), 0);
NotificationCompat.Builder builder = makeBaseBuilder().setGroup(GROUP_ID_GITHUB).setGroupSummary(true).setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY).setContentIntent(contentIntent).setDeleteIntent(deleteIntent).setContentTitle(title).setContentText(text).setPublicVersion(publicVersion).setVisibility(NotificationCompat.VISIBILITY_PRIVATE).setDefaults(NotificationCompat.DEFAULT_ALL).setNumber(totalCount);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(builder).setBigContentTitle(text);
for (List<NotificationThread> list : notificationsPerRepo) {
Repository repository = list.get(0).repository();
String repoName = repository.owner().login() + "/" + repository.name();
final TextAppearanceSpan notificationPrimarySpan = new TextAppearanceSpan(getContext(), R.style.TextAppearance_NotificationEmphasized);
final int emphasisEnd;
SpannableStringBuilder line = new SpannableStringBuilder(repoName).append(" ");
if (list.size() == 1) {
NotificationThread n = list.get(0);
line.append(determineNotificationTypeLabel(n));
emphasisEnd = line.length();
line.append(" ").append(n.subject().title());
} else {
emphasisEnd = line.length();
line.append(getContext().getResources().getQuantityString(R.plurals.notification, list.size(), list.size()));
}
line.setSpan(notificationPrimarySpan, 0, emphasisEnd, SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
inboxStyle.addLine(line);
}
builder.setStyle(inboxStyle);
if (!hasNewNotification) {
builder.setOnlyAlertOnce(true);
}
nm.notify(0, builder.build());
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class IssueFilterTest method testEqualFilter.
/**
* Verify {@link IssueFilter#equals(Object)}
*/
@Test
public void testEqualFilter() {
Repository repo = Repository.builder().id(1L).build();
IssueFilter filter1 = new IssueFilter(repo, UUID.randomUUID().toString());
assertFalse(filter1.equals(null));
assertFalse(filter1.equals(""));
assertTrue(filter1.equals(filter1));
IssueFilter filter2 = new IssueFilter(repo, UUID.randomUUID().toString());
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
User user = User.builder().id(2L).build();
filter1.setAssignee(user);
assertFalse(filter1.equals(filter2));
filter2.setAssignee(user);
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
filter1.setOpen(false);
assertFalse(filter1.equals(filter2));
filter2.setOpen(false);
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
Milestone milestone = Milestone.builder().number(3).build();
filter1.setMilestone(milestone);
assertFalse(filter1.equals(filter2));
filter2.setMilestone(milestone);
assertEquals(filter1, filter2);
assertEquals(filter1.hashCode(), filter2.hashCode());
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class ConvertUtilsTest method testNewRepoIsCreated.
@Test
public void testNewRepoIsCreated() {
Repository newRepo = ConvertUtils.eventRepoToRepo(event.repo());
assertThat(newRepo.owner().login(), equalTo(REPO_NAME_FIRST_PART));
assertThat(newRepo.name(), equalTo(REPO_NAME_SECOND_PART));
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class EditIssuesFilterActivityTest method setUp.
@Before
public void setUp() {
Repository repo = InfoUtils.createRepoFromData("owner", "name");
IssueFilter filter = new IssueFilter(repo, UUID.randomUUID().toString());
activityTestRule.launchActivity(EditIssuesFilterActivity.Companion.createIntent(filter));
}
Aggregations