Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements #8

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f705ce7
added google-services.json
davidka95 Apr 19, 2017
1cbbfae
Added travis.yml file
biharygergo Apr 19, 2017
42688b7
Rename .travis.yml.txt to .travis.yml
biharygergo Apr 19, 2017
b4867dd
Debugging travis
biharygergo Apr 19, 2017
c5ca592
Update gradlew
biharygergo Apr 19, 2017
8308263
Update .travis.yml
biharygergo Apr 19, 2017
76af229
Update .travis.yml
biharygergo Apr 19, 2017
6f75f79
Move travis.yml file
biharygergo Apr 19, 2017
9b3f3cc
Move travis
biharygergo Apr 19, 2017
081f430
Update .travis.yml
biharygergo Apr 19, 2017
21b973a
changed libaries version number
davidka95 Apr 19, 2017
528cd64
Update .travis.yml
biharygergo Apr 19, 2017
0b3ec80
Merge remote-tracking branch 'origin/improvements' into improvements
davidka95 Apr 19, 2017
958e97e
Update .travis.yml
biharygergo Apr 19, 2017
4204266
changed deprecated resources
davidka95 Apr 19, 2017
14ec79b
Merge remote-tracking branch 'origin/improvements' into improvements
davidka95 Apr 19, 2017
3e2f07d
using sp instead of dp
davidka95 Apr 19, 2017
934beff
Don't build release version, only debug
biharygergo Apr 19, 2017
9a055e1
extracted string resources
davidka95 Apr 19, 2017
bb0f8cf
Merge remote-tracking branch 'origin/improvements' into improvements
davidka95 Apr 19, 2017
a672350
changed deprecated API
davidka95 Apr 19, 2017
dc2e7fc
Inlined redundant local variable
davidka95 Apr 19, 2017
1542e22
removed unused assignment
davidka95 Apr 19, 2017
f81db95
removed unused local variable
davidka95 Apr 19, 2017
1fefe89
replaced lambda with method reference
davidka95 Apr 19, 2017
138e923
added null checks
davidka95 Apr 19, 2017
d7f9d9c
removed statement with empty body
davidka95 Apr 19, 2017
cf674c8
removed unused xml schema declaration
davidka95 Apr 19, 2017
e1af2c4
Removed XML tag empty body
deritamas Apr 20, 2017
3eeed4f
Added missing NonNull annotations
deritamas Apr 20, 2017
f408005
Fixed Javadoc references
deritamas Apr 20, 2017
6d8c75a
Restricted access modifiers where possible
deritamas Apr 20, 2017
8daf218
Added SuppressWarnings annotation
deritamas Apr 20, 2017
010fe3b
Removed unnecessary layout params
deritamas Apr 20, 2017
386327a
Added SonarQube plugin to Gradle
deritamas Apr 20, 2017
2978b10
Added new variable instead of reusing parameter
deritamas Apr 20, 2017
fc687eb
Edited code to comply with conventions
deritamas Apr 20, 2017
51ef4c8
Removed duplicated blocks
deritamas Apr 20, 2017
1ef5b7a
Merge pull request #3 from biharygergo/sonarqube
deritamas Apr 20, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
language: android
jdk: oraclejdk8
android:
components:
- tools # to get the new `repository-11.xml`
- tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
- platform-tools
- build-tools-25.0.2
- android-25
- extra-android-m2repository
- extra-google-m2repository
before_script: cd outlay
script:
- ./gradlew assembleDebug

55 changes: 55 additions & 0 deletions outlay/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"project_info": {
"project_number": "493988397268",
"firebase_url": "https://outlay-c8db8.firebaseio.com",
"project_id": "outlay-c8db8",
"storage_bucket": "outlay-c8db8.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:493988397268:android:95649c21a8bc6266",
"android_client_info": {
"package_name": "app.outlay"
}
},
"oauth_client": [
{
"client_id": "493988397268-1thsbh8c2rtbbc38hd9opj2d4ggpff7s.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "app.outlay",
"certificate_hash": "90e14b32ea082f18eccd422a24e9b40b7cb18a03"
}
},
{
"client_id": "493988397268-d8h6qppkcq2r87coobac4pl7rigsd5j3.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyDjc1HdmPnYw74rY4tQyZLzQTvXPwsdXRM"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 2,
"other_platform_oauth_client": [
{
"client_id": "493988397268-d8h6qppkcq2r87coobac4pl7rigsd5j3.apps.googleusercontent.com",
"client_type": 3
}
]
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
2 changes: 1 addition & 1 deletion outlay/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:theme="@style/Theme.Material.Custom">
<activity
android:name="app.outlay.view.activity.MainActivity"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />

<activity
android:name="app.outlay.view.activity.SingleFragmentActivity"
Expand Down
3 changes: 1 addition & 2 deletions outlay/app/src/main/java/app/outlay/di/module/AppModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ List<Category> defaultCategories() {
@Provides
@Singleton
Gson providerGson() {
Gson gson = new GsonBuilder().create();
return gson;
return new GsonBuilder().create();
}

private static Category category(String title, String icon, int color, int order) {
Expand Down
6 changes: 4 additions & 2 deletions outlay/app/src/main/java/app/outlay/executor/JobExecutor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app.outlay.executor;


import android.support.annotation.NonNull;

import app.outlay.core.executor.ThreadExecutor;

import java.util.concurrent.BlockingQueue;
Expand Down Expand Up @@ -39,7 +41,7 @@ public JobExecutor() {
}

@Override
public void execute(Runnable runnable) {
public void execute(@NonNull Runnable runnable) {
if (runnable == null) {
throw new IllegalArgumentException("Runnable to execute cannot be null");
}
Expand All @@ -51,7 +53,7 @@ private static class JobThreadFactory implements ThreadFactory {
private int counter = 0;

@Override
public Thread newThread(Runnable runnable) {
public Thread newThread(@NonNull Runnable runnable) {
return new Thread(runnable, THREAD_NAME + counter++);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void onCancelled(DatabaseError databaseError) {
}
return categoryMap;
}).switchMap(categoryMap ->
listObservable.flatMap(expenses -> Observable.from(expenses))
listObservable.flatMap(Observable::from)
.map(expense -> {
String currentCatId = expense.getCategory().getId();
return expense.setCategory(categoryMap.get(currentCatId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,67 +41,44 @@ public Observable<String> getUserToken(FirebaseUser firebaseUser) {
});
}

private void addListener(Task<AuthResult> task, rx.Subscriber<? super AuthResult> subscriber) {
task.addOnCompleteListener(resultTask -> {
if (task.isSuccessful()) {
AuthResult authResult = task.getResult();
subscriber.onNext(authResult);
subscriber.onCompleted();
} else {
Exception e = task.getException();
subscriber.onError(e);
}
});
}

public Observable<AuthResult> signUp(String email, String password) {
return Observable.create(subscriber -> {
Task<AuthResult> task = firebaseAuth.createUserWithEmailAndPassword(email, password);
task.addOnCompleteListener(resultTask -> {
if (task.isSuccessful()) {
AuthResult authResult = task.getResult();
subscriber.onNext(authResult);
subscriber.onCompleted();
} else {
Exception e = task.getException();
subscriber.onError(e);
}
});
addListener(task, subscriber);
});
}

public Observable<AuthResult> signIn(String email, String password) {
return Observable.create(subscriber -> {
Task<AuthResult> task = firebaseAuth.signInWithEmailAndPassword(email, password);
task.addOnCompleteListener(resultTask -> {
if (task.isSuccessful()) {
AuthResult authResult = task.getResult();
subscriber.onNext(authResult);
subscriber.onCompleted();
} else {
Exception e = task.getException();
subscriber.onError(e);
}
});
addListener(task, subscriber);
});
}

public Observable<AuthResult> signInAnonymously() {
return Observable.create(subscriber -> {
Task<AuthResult> task = firebaseAuth.signInAnonymously();
task.addOnCompleteListener(resultTask -> {
if (task.isSuccessful()) {
AuthResult authResult = task.getResult();
subscriber.onNext(authResult);
subscriber.onCompleted();
} else {
Exception e = task.getException();
subscriber.onError(e);
}
});
addListener(task, subscriber);
});
}

public Observable<AuthResult> linkAccount(AuthCredential credentials) {
return Observable.create(subscriber -> {
Task<AuthResult> task = firebaseAuth.getCurrentUser().linkWithCredential(credentials);
task.addOnCompleteListener(resultTask -> {
if (task.isSuccessful()) {
AuthResult authResult = task.getResult();
subscriber.onNext(authResult);
subscriber.onCompleted();
} else {
Exception e = task.getException();
subscriber.onError(e);
}
});
addListener(task, subscriber);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.outlay.firebase;

import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.EmailAuthProvider;
import app.outlay.domain.model.Credentials;
import app.outlay.domain.model.User;
Expand All @@ -26,30 +27,30 @@ public FirebaseAuthService(FirebaseAuthRxWrapper firebaseWrapper) {
@Override
public Observable<User> signIn(Credentials credentials) {
return firebaseWrapper.signIn(credentials.getEmail(), credentials.getPassword())
.map(authResult -> authResult.getUser())
.map(firebaseUser -> UserAdapter.fromFirebaseUser(firebaseUser));
.map(AuthResult::getUser)
.map(UserAdapter::fromFirebaseUser);
}

@Override
public Observable<User> signUp(Credentials credentials) {
return firebaseWrapper.signUp(credentials.getEmail(), credentials.getPassword())
.map(authResult -> authResult.getUser())
.map(firebaseUser -> UserAdapter.fromFirebaseUser(firebaseUser));
.map(AuthResult::getUser)
.map(UserAdapter::fromFirebaseUser);
}

@Override
public Observable<User> linkCredentials(Credentials credentials) {
AuthCredential emailCredentials = EmailAuthProvider.getCredential(credentials.getEmail(), credentials.getPassword());
return firebaseWrapper.linkAccount(emailCredentials)
.map(authResult -> authResult.getUser())
.map(firebaseUser -> UserAdapter.fromFirebaseUser(firebaseUser));
.map(AuthResult::getUser)
.map(UserAdapter::fromFirebaseUser);
}

@Override
public Observable<User> signInAnonymously() {
return firebaseWrapper.signInAnonymously()
.map(authResult -> authResult.getUser())
.map(firebaseUser -> UserAdapter.fromFirebaseUser(firebaseUser));
.map(AuthResult::getUser)
.map(UserAdapter::fromFirebaseUser);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public void getCategories() {
@Override
public void onNext(List<Category> categories) {
super.onNext(categories);
getView().setCategories(categories);
if (getView()!=null){
getView().setCategories(categories);
}
}
});
}
Expand All @@ -47,7 +49,7 @@ public void getExpenses(Date startDate, Date endDate, Category category) {
@Override
public void onNext(Report report) {
super.onNext(report);
if (isViewAttached()) {
if (isViewAttached() && getView()!=null) {
getView().showAnalysis(report);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public void getCategories() {
getCategoriesUseCase.execute(new DefaultSubscriber<List<Category>>() {
@Override
public void onNext(List<Category> categories) {
getView().showCategories(categories);
if (getView()!=null){
getView().showCategories(categories);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public void getCategory(String id) {
getCategoryUseCase.execute(id, new DefaultSubscriber<Category>() {
@Override
public void onNext(Category category) {
getView().showCategory(category);
if (getView()!=null){
getView().showCategory(category);
}
}
});
}
Expand All @@ -42,7 +44,9 @@ public void updateCategory(Category category) {
updateCategoryUseCase.execute(category, new DefaultSubscriber<Category>() {
@Override
public void onCompleted() {
getView().finish();
if (getView()!=null){
getView().finish();
}
}
});

Expand All @@ -52,7 +56,9 @@ public void deleteCategory(Category category) {
deleteCategoryUseCase.execute(category, new DefaultSubscriber<Category>() {
@Override
public void onCompleted() {
getView().finish();
if (getView()!=null){
getView().finish();
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public void getCategories() {
getCategoriesUseCase.execute(new DefaultSubscriber<List<Category>>() {
@Override
public void onNext(List<Category> categories) {
getView().showCategories(categories);
if (getView()!=null){
getView().showCategories(categories);
}
}
});
}
Expand All @@ -52,7 +54,9 @@ public void createExpense(Expense expense) {
createExpenseUseCase.execute(expense, new DefaultSubscriber<Expense>() {
@Override
public void onNext(Expense expense) {
getView().alertExpenseSuccess(expense);
if (getView()!=null){
getView().alertExpenseSuccess(expense);
}

}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public void findExpense(String expenseId, Date date) {
getExpenseUseCase.execute(new GetExpenseUseCase.Input(expenseId, date), new DefaultSubscriber<Expense>() {
@Override
public void onNext(Expense expense) {
getView().showExpense(expense);
if (getView()!=null){
getView().showExpense(expense);
}
}
});

Expand All @@ -52,7 +54,9 @@ public void getCategories() {
@Override
public void onNext(List<Category> categories) {
super.onNext(categories);
getView().showCategories(categories);
if (getView()!=null){
getView().showCategories(categories);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public void findExpenses(Date dateFrom, Date dateTo, String categoryId) {
loadReportUseCase.execute(input, new DefaultSubscriber<Report>() {
@Override
public void onNext(Report report) {
getView().showReport(report);
if (getView()!=null){
getView().showReport(report);
}
}
});
}
Expand Down
Loading