Skip to content

Commit

Permalink
Merge pull request #1149 from Meisolsson/master
Browse files Browse the repository at this point in the history
Whole lot of changes
  • Loading branch information
Meisolsson committed Jan 17, 2018
2 parents f1b947d + 071fcdf commit 1228869
Show file tree
Hide file tree
Showing 246 changed files with 6,714 additions and 7,936 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Expand Up @@ -4,9 +4,11 @@ android:
- tools
- tools #Running this twice get's the latest build tools (https://github.com/codepath/android_guides/wiki/Setting-up-Travis-CI)
- platform-tools
- android-25
- build-tools-25.0.2
- android-27
- build-tools-27.0.3
- extra
licenses:
- 'android-sdk-license-.+'

jdk: oraclejdk8

Expand All @@ -15,5 +17,8 @@ notifications:

sudo: required #The build runs out of memory and is killed if we use the container system

before_install:
- yes | sdkmanager "platforms;android-27"

script:
- ./gradlew clean build
55 changes: 32 additions & 23 deletions app/build.gradle
@@ -1,5 +1,4 @@
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.github.ben-manes.versions' // ./gradlew dependencyUpdates -Drevision=release
apply from: 'quality.gradle'

Expand All @@ -21,13 +20,13 @@ def clientIdIsNotSet = true;
def clientSecretIsNotSet = true;

android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
compileSdkVersion 27
buildToolsVersion '27.0.3'

defaultConfig {
applicationId 'com.github.pockethub.android'
minSdkVersion 15
targetSdkVersion 25
targetSdkVersion 27
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -80,6 +79,12 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests {
includeAndroidResources = true
}
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
Expand Down Expand Up @@ -109,7 +114,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

def supportVersion = '25.3.1'
def supportVersion = '27.0.2'
compile "com.android.support:appcompat-v7:$supportVersion"
compile "com.android.support:support-v4:$supportVersion"
compile "com.android.support:design:$supportVersion"
Expand All @@ -118,27 +123,31 @@ dependencies {
compile 'com.squareup.okhttp3:okhttp:3.8.1'

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'io.reactivex.rxjava2:rxjava:2.0.7'
compile 'com.trello.rxlifecycle2:rxlifecycle:2.0.1'
compile 'com.trello.rxlifecycle2:rxlifecycle-android:2.0.1'
compile 'com.bugsnag:bugsnag-android:3.2.7'
compile 'org.roboguice:roboguice:2.0'
compile 'io.reactivex.rxjava2:rxjava:2.1.7'
compile 'com.uber.autodispose:autodispose:0.5.1'
compile 'com.uber.autodispose:autodispose-android-archcomponents:0.5.1'

compile 'com.github.meisolsson:githubsdk:0.4.5'
compile 'com.bugsnag:bugsnag-android:3.6.0'

compile ('com.google.inject.extensions:guice-assistedinject:3.0'){
exclude group: 'com.google.inject'
}
compile 'com.afollestad.material-dialogs:core:0.9.4.4'
compile 'com.google.dagger:dagger:2.13'
compile 'com.google.dagger:dagger-android:2.13'
compile 'com.google.dagger:dagger-android-support:2.13'

//Self compiled .aar version of wishlist
compile (name:'lib', ext:'aar')
annotationProcessor 'com.google.dagger:dagger-compiler:2.13'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.13'

provided 'com.episode6.hackit.auto.factory:auto-factory-annotations:1.0-beta5'
annotationProcessor 'com.google.auto.factory:auto-factory:1.0-beta5'

compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

compile 'com.github.meisolsson:githubsdk:0.4.5'
compile 'com.afollestad.material-dialogs:core:0.9.6.0'
compile 'com.xwray:groupie:2.0.3'

//Libs for testing
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile('org.robolectric:robolectric:3.3.2') {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:1.9.5"
testImplementation "org.robolectric:robolectric:3.6.1"
}
Binary file removed app/libs/lib.aar
Binary file not shown.
Expand Up @@ -22,6 +22,8 @@
import android.view.View;
import android.widget.TextView;

import com.github.pockethub.android.ui.item.news.GistEventItem;
import com.github.pockethub.android.ui.item.news.NewsItem;
import com.meisolsson.githubsdk.model.Gist;
import com.meisolsson.githubsdk.model.GitHubEvent;
import com.meisolsson.githubsdk.model.GitHubEventType;
Expand All @@ -30,7 +32,6 @@
import com.meisolsson.githubsdk.model.Team;
import com.meisolsson.githubsdk.model.User;
import com.github.pockethub.android.R.id;
import com.github.pockethub.android.ui.user.NewsListAdapter;
import com.github.pockethub.android.util.AvatarLoader;
import com.meisolsson.githubsdk.model.payload.CommitCommentPayload;
import com.meisolsson.githubsdk.model.payload.CreatePayload;
Expand All @@ -44,35 +45,40 @@
import com.meisolsson.githubsdk.model.payload.PullRequestPayload;
import com.meisolsson.githubsdk.model.payload.PushPayload;
import com.meisolsson.githubsdk.model.payload.TeamAddPayload;
import com.xwray.groupie.GroupAdapter;

import java.util.Collections;
import java.util.Date;

/**
* Tests of the news text rendering
*/
public class NewsEventTextTest extends InstrumentationTestCase {

private NewsListAdapter adapter;

private TextView text;

private User actor;

private Repository repo;

private AvatarLoader avatarLoader;

private LayoutInflater layoutInflater;

@Override
protected void setUp() throws Exception {
super.setUp();

actor = User.builder().login("user").build();
repo = Repository.builder().name("user/repo").build();

Context context = getInstrumentation().getTargetContext();
adapter = new NewsListAdapter(LayoutInflater.from(context),
new AvatarLoader(context));
avatarLoader = new AvatarLoader(context);
layoutInflater = LayoutInflater.from(context);
}

private GitHubEvent createEvent(GitHubEventType type, GitHubPayload payload) {
return GitHubEvent.builder()
.id("test")
.createdAt(new Date())
.type(type)
.payload(payload)
Expand All @@ -88,10 +94,13 @@ private void verify(String expected) {
}

private void updateView(GitHubEvent event) {
adapter.setItems(new Object[] { event });
View view = adapter.getView(0, null, null);
assertNotNull(view);
text = (TextView) view.findViewById(id.tv_event);
NewsItem item = NewsItem.createNewsItem(avatarLoader, event);

View itemView = layoutInflater.inflate(item.getLayout(), null);
NewsItem.ViewHolder viewHolder = item.createViewHolder(itemView);
item.bind(viewHolder, 0);

text = viewHolder.event;
assertNotNull(text);
}

Expand Down Expand Up @@ -307,6 +316,7 @@ public void testPullRequest() {
public void testPush() {
PushPayload payload = PushPayload.builder()
.ref("refs/heads/master")
.commits(Collections.emptyList())
.build();

GitHubEvent event = createEvent(GitHubEventType.PushEvent, payload);
Expand Down
Expand Up @@ -43,7 +43,7 @@ public CreateGistActivityTest() {
public void testCreateWithInitialText() {
setActivityIntent(new Intent().putExtra(EXTRA_TEXT, "gist content"));

View createMenu = view(id.m_apply);
View createMenu = view(id.create_gist);
assertTrue(createMenu.isEnabled());
EditText content = editText(id.et_gist_content);
assertEquals("gist content", content.getText().toString());
Expand All @@ -55,7 +55,7 @@ public void testCreateWithInitialText() {
* @throws Throwable
*/
public void testCreateWithNoInitialText() throws Throwable {
View createMenu = view(id.m_apply);
View createMenu = view(id.create_gist);
assertFalse(createMenu.isEnabled());
EditText content = editText(id.et_gist_content);
focus(content);
Expand Down
Expand Up @@ -15,29 +15,34 @@
*/
package com.github.pockethub.android.tests.gist;

import android.app.Application;
import android.app.Instrumentation;
import android.content.Context;
import android.support.v4.util.ArrayMap;
import android.support.v4.view.ViewPager;

import com.github.pockethub.android.GitHubModule;
import com.github.pockethub.android.PocketHub;
import com.github.pockethub.android.PocketHubModule;
import com.github.pockethub.android.R.id;
import com.github.pockethub.android.core.gist.GistStore;
import com.github.pockethub.android.tests.ActivityTest;
import com.github.pockethub.android.ui.gist.GistFilesViewActivity;
import com.meisolsson.githubsdk.model.Gist;
import com.meisolsson.githubsdk.model.GistFile;
import com.google.inject.Inject;
import javax.inject.Inject;
import javax.inject.Singleton;

import java.util.Map;

import roboguice.RoboGuice;
import dagger.Component;

/**
* Tests of {@link GistFilesViewActivity}
*/
public class GistFilesViewActivityTest extends
ActivityTest<GistFilesViewActivity> {
public class GistFilesViewActivityTest extends ActivityTest<GistFilesViewActivity> {

@Inject
private GistStore store;
protected GistStore store;

private Gist gist;

Expand All @@ -52,8 +57,9 @@ public GistFilesViewActivityTest() {
protected void setUp() throws Exception {
super.setUp();

RoboGuice.injectMembers(getInstrumentation().getTargetContext()
.getApplicationContext(), this);
Context context = getInstrumentation().getTargetContext();
PocketHub pocketHub = (PocketHub) context.getApplicationContext();
store = pocketHub.applicationComponent().gistStore();

Map<String, GistFile> files = new ArrayMap<>();

Expand Down
Expand Up @@ -31,7 +31,7 @@ public class GistStoreTest extends AndroidTestCase {
* Verify issue is updated when re-added
*/
public void testReuseIssue() {
GistStore store = new GistStore(mContext);
GistStore store = new GistStore();
assertNull(store.getGist("abcd"));

Gist gist = Gist.builder()
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class IssueStoreTest extends AndroidTestCase {
* Verify issue is updated when re-added
*/
public void testReuseIssue() {
IssueStore store = new IssueStore(mContext);
IssueStore store = new IssueStore();
Repository repo = InfoUtils.createRepoFromData("owner", "name");

assertNull(store.getIssue(repo, 1));
Expand Down
@@ -0,0 +1,40 @@
package com.github.pockethub.android;

import android.app.Application;

import com.github.pockethub.android.core.gist.GistStore;
import com.github.pockethub.android.dagger.ActivityBuilder;
import com.github.pockethub.android.dagger.DialogFragmentBuilder;
import com.github.pockethub.android.dagger.ServiceBuilder;

import javax.inject.Singleton;

import dagger.BindsInstance;
import dagger.Component;
import dagger.android.AndroidInjector;
import dagger.android.support.AndroidSupportInjectionModule;

@Singleton
@Component(modules = {
AndroidSupportInjectionModule.class,
ApplicationModule.class,
PocketHubModule.class,
ActivityBuilder.class,
ServiceBuilder.class,
DialogFragmentBuilder.class,
GitHubModule.class
})
public interface ApplicationComponent extends AndroidInjector<PocketHub> {

GistStore gistStore();

@Component.Builder
abstract class Builder extends AndroidInjector.Builder<PocketHub> {

@BindsInstance
abstract Builder application(Application application);

@Override
public abstract ApplicationComponent build();
}
}
@@ -0,0 +1,18 @@
package com.github.pockethub.android;

import android.app.Application;
import android.content.Context;

import javax.inject.Singleton;

import dagger.Binds;
import dagger.BindsInstance;
import dagger.Module;

@Module
abstract class ApplicationModule {

@Binds
@Singleton
abstract Context provideApplicationContext(Application application);
}

0 comments on commit 1228869

Please sign in to comment.