Search in sources :

Example 26 with Repository

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));
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) TextMatch(com.meisolsson.githubsdk.model.TextMatch) Uri(android.net.Uri)

Example 27 with Repository

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());
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) NotificationThread(com.meisolsson.githubsdk.model.NotificationThread) TextAppearanceSpan(android.text.style.TextAppearanceSpan) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent) Paint(android.graphics.Paint) Notification(android.app.Notification) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 28 with Repository

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());
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) User(com.meisolsson.githubsdk.model.User) Milestone(com.meisolsson.githubsdk.model.Milestone) IssueFilter(com.github.pockethub.android.core.issue.IssueFilter) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test)

Example 29 with Repository

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));
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) Test(org.junit.Test)

Example 30 with Repository

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));
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) IssueFilter(com.github.pockethub.android.core.issue.IssueFilter) Before(org.junit.Before)

Aggregations

Repository (com.meisolsson.githubsdk.model.Repository)68 User (com.meisolsson.githubsdk.model.User)18 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)9 Issue (com.meisolsson.githubsdk.model.Issue)9 Intent (android.content.Intent)8 View (android.view.View)8 TextView (android.widget.TextView)6 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 LayoutInflater (android.view.LayoutInflater)4 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)4 Test (org.junit.Test)4 Uri (android.net.Uri)3 Menu (android.view.Menu)3 ViewGroup (android.view.ViewGroup)3 LinearLayout (android.widget.LinearLayout)3 R (com.gh4a.R)3 RepositoryActivity (com.gh4a.activities.RepositoryActivity)3 UserActivity (com.gh4a.activities.UserActivity)3 ApiHelpers (com.gh4a.utils.ApiHelpers)3