Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ayltai committed Nov 16, 2017
2 parents 6059b69 + c557e7d commit c1135d3
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 78 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Newspaper
=========

[![Release](https://img.shields.io/github/release/ayltai/Newspaper.svg?label=release&maxAge=1800)](https://1137-77390316-gh.circle-artifacts.com/0/apk/release/mobile-release.apk) [![Build Status](https://circleci.com/gh/ayltai/Newspaper.svg?style=shield)](https://circleci.com/gh/ayltai/Newspaper) [![Code Quality](https://api.codacy.com/project/badge/Grade/89d745ac9331474e9cf9f3203782a72f)](https://www.codacy.com/app/ayltai/Newspaper?utm_source=github.com&utm_medium=referral&utm_content=ayltai/Newspaper&utm_campaign=Badge_Grade) [![Code Coverage](https://api.codacy.com/project/badge/Coverage/89d745ac9331474e9cf9f3203782a72f)](https://www.codacy.com/app/ayltai/Newspaper?utm_source=github.com&utm_medium=referral&utm_content=ayltai/Newspaper&utm_campaign=Badge_Coverage) [![Code Coverage](https://codecov.io/gh/ayltai/Newspaper/branch/master/graph/badge.svg)](https://codecov.io/gh/ayltai/Newspaper) [![Android API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat&label=API&maxAge=300)](https://www.android.com/history/) [![License](https://img.shields.io/badge/License-apache%202.0-blue.svg?label=license&maxAge=1800)](https://github.com/ayltai/Newspaper/blob/master/LICENSE)
[![Release](https://img.shields.io/github/release/ayltai/Newspaper.svg?label=release&maxAge=1800)](https://1196-77390316-gh.circle-artifacts.com/0/apk/release/mobile-release.apk) [![Build Status](https://circleci.com/gh/ayltai/Newspaper.svg?style=shield)](https://circleci.com/gh/ayltai/Newspaper) [![Code Quality](https://api.codacy.com/project/badge/Grade/89d745ac9331474e9cf9f3203782a72f)](https://www.codacy.com/app/ayltai/Newspaper?utm_source=github.com&utm_medium=referral&utm_content=ayltai/Newspaper&utm_campaign=Badge_Grade) [![Code Coverage](https://api.codacy.com/project/badge/Coverage/89d745ac9331474e9cf9f3203782a72f)](https://www.codacy.com/app/ayltai/Newspaper?utm_source=github.com&utm_medium=referral&utm_content=ayltai/Newspaper&utm_campaign=Badge_Coverage) [![Code Coverage](https://codecov.io/gh/ayltai/Newspaper/branch/master/graph/badge.svg)](https://codecov.io/gh/ayltai/Newspaper) [![Android API](https://img.shields.io/badge/API-16%2B-blue.svg?style=flat&label=API&maxAge=300)](https://www.android.com/history/) [![License](https://img.shields.io/badge/License-apache%202.0-blue.svg?label=license&maxAge=1800)](https://github.com/ayltai/Newspaper/blob/master/LICENSE)

An aggregated news app containing news from 10+ local news publishers in Hong Kong. Made with ❤

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
classpath 'me.tatarka:gradle-retrolambda:3.7.0'
classpath 'io.realm:realm-gradle-plugin:4.1.1'
classpath 'com.google.gms:google-services:3.1.2'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
classpath 'com.google.firebase:firebase-plugins:1.1.4'
classpath 'io.fabric.tools:gradle:1.24.4'
classpath 'org.jacoco:org.jacoco.core:0.7.9'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-bin.zip
18 changes: 9 additions & 9 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
applicationId 'com.github.ayltai.newspaper'
minSdkVersion project.hasProperty('ciBuild') ? 16 : 21
targetSdkVersion 27
versionCode 24
versionName '3.6.' + VERSION_REVISION + '-' + VERSION_HASH
versionCode 25
versionName '3.7.' + VERSION_REVISION + '-' + VERSION_HASH

testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
testInstrumentationRunnerArguments disableAnalytics: 'true'
Expand Down Expand Up @@ -105,15 +105,15 @@ configurations {

ext {
multidexVersion = '1.0.2'
supportLibraryVersion = '27.0.0'
architectureVersion = '1.0.0-rc1'
firebaseSdkVersion = '11.4.2'
daggerVersion = '2.12'
supportLibraryVersion = '27.0.1'
architectureVersion = '1.0.0'
firebaseSdkVersion = '11.6.0'
daggerVersion = '2.13'
rxBindingVersion = '2.0.0'
okhttpVersion = '3.9.0'
retrofitVersion = '2.3.0'
frescoVersion = '1.5.0'
bigImageViewerVersion = '1.3.2'
bigImageViewerVersion = '1.4.2'
exoPlayerVersion = 'r2.5.4'
autoValueVersion = '1.5'
leakCanaryVersion = '1.5.4'
Expand Down Expand Up @@ -179,7 +179,7 @@ dependencies {
}

// Database
implementation 'io.realm:android-adapters:2.1.0'
implementation 'io.realm:android-adapters:2.1.1'

// Image processing
implementation "com.facebook.fresco:fresco:$frescoVersion"
Expand Down Expand Up @@ -231,7 +231,7 @@ dependencies {
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"

// Unit testing
testImplementation 'org.mockito:mockito-core:2.11.6'
testImplementation 'org.mockito:mockito-core:2.12.0'
testImplementation "org.powermock:powermock-module-junit4:$powerMockVersion"
testImplementation "org.powermock:powermock-module-junit4-rule:$powerMockVersion"
testImplementation "org.powermock:powermock-api-mockito2:$powerMockVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ public void bookmarkNewsTest() {
// Checks that there is a bookmarked news item
Espresso.onView(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3)), 0),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3),
ViewMatchers.isDisplayed()))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));

Expand Down Expand Up @@ -140,9 +138,7 @@ public void bookmarkNewsTest() {
// Checks that no search results returned
Espresso.onView(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3)), 0),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3),
ViewMatchers.isDisplayed()))
.check(ViewAssertions.doesNotExist());

Expand Down Expand Up @@ -170,9 +166,7 @@ public void bookmarkNewsTest() {
// Checks that there is a bookmarked news item
Espresso.onView(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3)), 0),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3),
ViewMatchers.isDisplayed()))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public void featuredItemTest() {
// Checks that the news image is displayed within the toolbar
Espresso.onView(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.image_container), 0), 0)), 0),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.image_container), 0), 0),
ViewMatchers.isDisplayed()))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public void historicalNewsTest() {
// Checks that there is a historical news item
Espresso.onView(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3)), 0),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3),
ViewMatchers.isDisplayed()))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));

Expand Down Expand Up @@ -131,9 +129,7 @@ public void historicalNewsTest() {
// Checks that no search results returned
Espresso.onView(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3)), 0),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3),
ViewMatchers.isDisplayed()))
.check(ViewAssertions.doesNotExist());

Expand Down Expand Up @@ -161,9 +157,7 @@ public void historicalNewsTest() {
// Checks that there is a bookmarked news item
Espresso.onView(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(Matchers.allOf(
ViewMatchers.withId(R.id.image),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3)), 0),
MoreTestUtils.childAtPosition(MoreTestUtils.childAtPosition(ViewMatchers.withId(R.id.container), 0), 3),
ViewMatchers.isDisplayed()))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,25 @@ private void dispatch(@NonNull final View toView, @NonNull final State incomingS
if (direction == Direction.FORWARD) {
container.addView(toView);

toView.startAnimation(Animations.getAnimation(this.activity, R.anim.reveal_enter, android.R.integer.config_mediumAnimTime, null, () -> {
if (fromView != null) container.removeView(fromView);
}));
if (fromView != null) {
if (Animations.isEnabled()) {
toView.startAnimation(Animations.getAnimation(this.activity, R.anim.reveal_enter, android.R.integer.config_mediumAnimTime, null, () -> {
if (fromView != null) container.removeView(fromView);
}));
} else {
container.removeView(fromView);
}
}
} else if (direction == Direction.BACKWARD) {
container.addView(toView, 0);

if (fromView != null) fromView.startAnimation(Animations.getAnimation(this.activity, R.anim.reveal_exit, android.R.integer.config_mediumAnimTime, null, () -> container.removeView(fromView)));
if (fromView != null) {
if (Animations.isEnabled()) {
fromView.startAnimation(Animations.getAnimation(this.activity, R.anim.reveal_exit, android.R.integer.config_mediumAnimTime, null, () -> container.removeView(fromView)));
} else {
container.removeView(fromView);
}
}
} else if (direction == Direction.REPLACE) {
container.addView(toView);
if (fromView != null) container.removeView(fromView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ static MainScreen.Key create() {

public MainScreen(@NonNull final Context context) {
super(context);

this.init();
}

Expand Down Expand Up @@ -283,7 +284,7 @@ public void settings() {
.getAnalyticsComponent(this.getContext())
.eventLogger()
.logEvent(new ClickEvent()
.setElementName("FAB - Filter"));
.setElementName("FAB - Settings"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,105 @@
package com.github.ayltai.newspaper.app.view;

import java.io.File;
import java.util.concurrent.TimeUnit;

import android.app.Activity;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.OnLifecycleEvent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import com.github.ayltai.newspaper.Constants;
import com.github.ayltai.newspaper.app.data.model.FeaturedItem;
import com.github.ayltai.newspaper.app.widget.FeaturedView;
import com.github.ayltai.newspaper.media.FrescoImageLoader;
import com.github.ayltai.newspaper.media.DaggerImageComponent;
import com.github.ayltai.newspaper.media.ImageModule;
import com.github.ayltai.newspaper.util.RxUtils;
import com.github.ayltai.newspaper.util.TestUtils;
import com.github.ayltai.newspaper.util.ViewUtils;
import com.github.piasy.biv.loader.ImageLoader;

import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;

public class FeaturedPresenter extends ItemPresenter<FeaturedView> {
@Override
public void onViewAttached(@NonNull final FeaturedView view, final boolean isFirstTimeAttachment) {
this.manageDisposable(Observable.interval(Constants.FEATURED_IMAGE_ROTATION, TimeUnit.SECONDS)
public class FeaturedPresenter extends ItemPresenter<FeaturedView> implements LifecycleObserver {
private Disposable disposable;

@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
protected void onResume() {
this.disposable = Observable.interval(Constants.FEATURED_IMAGE_ROTATION, TimeUnit.SECONDS)
.compose(RxUtils.applyObservableBackgroundToMainSchedulers())
.subscribe(time -> {
if (this.getModel() instanceof FeaturedItem) {
if (this.getModel() instanceof FeaturedItem && this.getView() != null) {
((FeaturedItem)this.getModel()).next();

if (!this.getModel().getImages().isEmpty()) FrescoImageLoader.loadImage(this.getModel().getImages().get(0).getUrl())
.compose(RxUtils.applyMaybeBackgroundToMainSchedulers())
.subscribe(
bitmap -> {
view.setImages(this.getModel().getImages());
view.setTitle(this.getModel().getTitle());
},
error -> {
DaggerImageComponent.builder()
.imageModule(new ImageModule(this.getView().getContext()))
.build()
.imageLoader()
.loadImage(Uri.parse(this.getModel().getImages().get(0).getUrl()), new ImageLoader.Callback() {
@Override
public void onCacheHit(final File image) {
}

@Override
public void onCacheMiss(final File image) {
}

@Override
public void onStart() {
}

@Override
public void onProgress(final int progress) {
}

@Override
public void onFinish() {
}

@Override
public void onSuccess(final File image) {
if (FeaturedPresenter.this.getView() != null) {
FeaturedPresenter.this.getView().setImages(FeaturedPresenter.this.getModel().getImages());
FeaturedPresenter.this.getView().setTitle(FeaturedPresenter.this.getModel().getTitle());
}
}

@Override
public void onFail(final Exception error) {
if (TestUtils.isLoggable()) Log.e(this.getClass().getSimpleName(), error.getMessage(), error);
}
);
});

this.bindModel(this.getModel());
}
}));
});
}

@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
protected void onPause() {
if (this.disposable != null && !this.disposable.isDisposed()) this.disposable.dispose();
}

@Override
public void onViewAttached(@NonNull final FeaturedView view, final boolean isFirstTimeAttachment) {
super.onViewAttached(view, isFirstTimeAttachment);

final Activity activity = ViewUtils.getActivity(view);
if (activity instanceof AppCompatActivity) ((AppCompatActivity)activity).getLifecycle().addObserver(this);
}

@Override
public void onViewDetached() {
super.onViewDetached();

if (this.getView() != null) {
final Activity activity = ViewUtils.getActivity(this.getView());
if (activity instanceof AppCompatActivity) ((AppCompatActivity)activity).getLifecycle().removeObserver(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class ItemListPresenter extends ListPresenter<Item, ListPresenter.View<Item>> {
protected final List<String> categories;

private boolean forceRefresh = false;
private boolean forceRefresh;

public ItemListPresenter(@NonNull final List<String> categories) {
this.categories = categories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class ItemListView extends ListView<Item> implements ListPresent

//endregion

public ItemListView(@NonNull final Context context) {
protected ItemListView(@NonNull final Context context) {
super(context);
this.init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class ItemView extends ObservableView implements ItemPresenter.V

protected View container;

public ItemView(@NonNull final Context context) {
protected ItemView(@NonNull final Context context) {
super(context);
}

Expand Down Expand Up @@ -76,7 +76,7 @@ public void setIsRead(final boolean isRead) {

//region Events

@Nullable
@NonNull
@Override
public Flowable<Irrelevant> clicks() {
return this.clicks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ public abstract class NewsView extends ObservableView implements NewsPresenterVi
protected List<String> categories;
protected Set<String> sources;

public NewsView(@NonNull final Context context) {
protected NewsView(@NonNull final Context context) {
super(context);

this.init();
}

Expand Down
Loading

0 comments on commit c1135d3

Please sign in to comment.