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

Code quality improvements #6

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 52 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
language: android
sudo: required
jdk: oraclejdk8

before_cache:
-rm -f $HOME/outlay/.gradle/caches/modules-2/modules-2.lock
-rm -fr $HOME/outlay/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/outlay/.gradle/caches/
- $HOME/outlay/.gradle/wrapper/

env:
global:
- ANDROID_API=25
- EMULATOR_API=21
- ANDROID_BUILD_TOOLS=25.0.2
- ADB_INSTALL_TIMEOUT=10 # minutes

android:
components:
- tools
- platform-tools
- build-tools-$ANDROID_BUILD_TOOLS
- android-$ANDROID_API
# - android-$EMULATOR_API_LEVEL
- extra-google-m2repository
- extra-android-m2repository # for design library
# - sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+

before_install:
- cd outlay
- chmod +x gradlew

notifications:
email: false

before_script:
# - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
# - emulator -avd test -no-skin -no-audio -no-window &
# - android-wait-for-emulator
# - adb shell input keyevent 82 &

script:
- ./gradlew clean build -x test
#- ./gradlew test
#- ./gradlew connectedAndroidTest
9 changes: 8 additions & 1 deletion outlay/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ android {
release {
buildConfigField "boolean", "USE_ANALYTICS", "true"

signingConfig signingConfigs.release
if (propsFile.exists()) {
signingConfig signingConfigs.release
}

minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Expand All @@ -70,6 +72,11 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

dexOptions {
preDexLibraries true
javaMaxHeapSize "3g"
}

packagingOptions {
//<div>Icons made by <a href="http://www.flaticon.com/authors/gregor-cresnar" title="Gregor Cresnar">Gregor Cresnar</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
exclude 'META-INF/services/javax.annotation.processing.Processor'
Expand Down
42 changes: 42 additions & 0 deletions outlay/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"project_info": {
"project_number": "834201765141",
"firebase_url": "https://outlay-fd552.firebaseio.com",
"project_id": "outlay-fd552",
"storage_bucket": "outlay-fd552.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:834201765141:android:95649c21a8bc6266",
"android_client_info": {
"package_name": "app.outlay"
}
},
"oauth_client": [
{
"client_id": "834201765141-ueg7cmk78qi1pucd0oao4u6qcnaljrs8.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyARlbnnAaxhWAK2vNyUk50bZndCFdIULbA"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
1 change: 1 addition & 0 deletions outlay/app/src/main/java/app/outlay/executor/UIThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class UIThread implements PostExecutionThread {

@Inject
public UIThread() {
// @Inject ctor required by Dagger
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class CategoryFirebaseSource implements CategoryDataSource {
private DatabaseReference mDatabase;
private CategoryAdapter adapter;
private User currentUser;
private final String USERS = "users";
private final String CATEGORIES = "categories";

public CategoryFirebaseSource(
User currentUser,
Expand All @@ -40,7 +42,7 @@ public CategoryFirebaseSource(
@Override
public Observable<List<Category>> getAll() {
return Observable.create(subscriber -> {
mDatabase.child("users").child(currentUser.getId()).child("categories").orderByChild("order")
mDatabase.child(USERS).child(currentUser.getId()).child(CATEGORIES).orderByChild("order")
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Expand Down Expand Up @@ -70,7 +72,7 @@ public Observable<Category> getById(String id) {

protected Observable<CategoryDto> getDtoById(String id) {
return Observable.create(subscriber -> {
mDatabase.child("users").child(currentUser.getId()).child("categories").child(id)
mDatabase.child(USERS).child(currentUser.getId()).child(CATEGORIES).child(id)
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Expand All @@ -95,7 +97,7 @@ public Observable<List<Category>> updateOrder(List<Category> categories) {
childUpdates.put(c.getId() + "/order", c.getOrder());
}

DatabaseReference categoriesRef = mDatabase.child("users").child(currentUser.getId()).child("categories");
DatabaseReference categoriesRef = mDatabase.child(USERS).child(currentUser.getId()).child(CATEGORIES);
categoriesRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Expand All @@ -117,7 +119,7 @@ public Observable<Category> save(Category category) {
Observable<Category> saveCategory = Observable.create(subscriber -> {
String key = category.getId();
if (TextUtils.isEmpty(key)) {
key = mDatabase.child("users").child(currentUser.getId()).child("categories").push().getKey();
key = mDatabase.child(USERS).child(currentUser.getId()).child(CATEGORIES).push().getKey();
category.setId(key);
}

Expand All @@ -130,9 +132,9 @@ public Observable<Category> save(Category category) {
childUpdates.put("order", category.getOrder());

DatabaseReference dbRef = mDatabase
.child("users")
.child(USERS)
.child(currentUser.getId())
.child("categories").child(key);
.child(CATEGORIES).child(key);

dbRef.addValueEventListener(new ValueEventListener() {
@Override
Expand All @@ -158,8 +160,8 @@ public void onCancelled(DatabaseError databaseError) {
@Override
public Observable<Category> remove(Category category) {
final Observable<Category> deleteCategory = Observable.create(subscriber -> {
DatabaseReference catReference = mDatabase.child("users").child(currentUser.getId())
.child("categories").child(category.getId());
DatabaseReference catReference = mDatabase.child(USERS).child(currentUser.getId())
.child(USERS).child(category.getId());
catReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ public void onNext(Expense expense) {
}

public void deleteExpense(Expense expense) {
deleteExpenseUseCase.execute(expense, new DefaultSubscriber<Expense>() {
@Override
public void onCompleted() {
}
});
deleteExpenseUseCase.execute(expense, new DefaultSubscriber<Expense>());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public void setupDrawer(User currentUser) {
case ITEM_CREATE_USER:
createUser();
break;
default:
break;
}

mainDrawer.setSelection(-1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void onValueSelected(Entry e, Highlight h) {

@Override
public void onNothingSelected() {
// We don't want to do anything
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
case app.outlay.R.id.action_list:
analytics().trackViewExpensesList();
goToExpensesList(selectedDate, selectedPeriod);
default:
break;
}
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -144,6 +146,8 @@ public void onTabSelected(TabLayout.Tab tab) {
case ReportFragment.PERIOD_MONTH:
analytics().trackViewMonthlyExpenses();
break;
default:
break;
}
updateTitle();
presenter.getExpenses(selectedDate, selectedPeriod);
Expand Down Expand Up @@ -183,6 +187,8 @@ private void updateTitle() {
endDate = DateUtils.getMonthEnd(selectedDate);
setTitle(DateUtils.toShortString(startDate) + " - " + DateUtils.toShortString(endDate));
break;
default:
break;
}
}

Expand All @@ -191,22 +197,26 @@ public void goToExpensesList(Date date, int selectedPeriod) {
}

public void goToExpensesList(Date date, int selectedPeriod, String category) {
date = DateUtils.fillCurrentTime(date);
Date startDate = date;
Date endDate = date;
Date filledDate = DateUtils.fillCurrentTime(date);
Date startDate;
Date endDate;

switch (selectedPeriod) {
case ReportFragment.PERIOD_DAY:
startDate = DateUtils.getDayStart(date);
endDate = DateUtils.getDayEnd(date);
startDate = DateUtils.getDayStart(filledDate);
endDate = DateUtils.getDayEnd(filledDate);
break;
case ReportFragment.PERIOD_WEEK:
startDate = DateUtils.getWeekStart(date);
endDate = DateUtils.getWeekEnd(date);
startDate = DateUtils.getWeekStart(filledDate);
endDate = DateUtils.getWeekEnd(filledDate);
break;
case ReportFragment.PERIOD_MONTH:
startDate = DateUtils.getMonthStart(date);
endDate = DateUtils.getMonthEnd(date);
startDate = DateUtils.getMonthStart(filledDate);
endDate = DateUtils.getMonthEnd(filledDate);
break;
default:
startDate = filledDate;
endDate = filledDate;
break;
}
Navigator.goToExpensesList(getActivity(), startDate, endDate, category);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
case android.R.id.home:
getActivity().onBackPressed();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
case android.R.id.home:
getActivity().onBackPressed();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,17 @@ public void onAnimationEnd(Animator animator) {

@Override
public void onAnimationStart(Animator animator) {
// We don't want to do anything
}

@Override
public void onAnimationCancel(Animator animator) {
// We don't want to do anything
}

@Override
public void onAnimationRepeat(Animator animator) {
// We don't want to do anything
}
});
mAnimator.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
public class OnTabSelectedListenerAdapter implements TabLayout.OnTabSelectedListener {
@Override
public void onTabSelected(TabLayout.Tab tab) {

// Empty default implementation
// To be overriden depending on the context it is used in
}

@Override
public void onTabUnselected(TabLayout.Tab tab) {

// Empty default implementation
// To be overriden depending on the context it is used in
}

@Override
public void onTabReselected(TabLayout.Tab tab) {

// Empty default implementation
// To be overriden depending on the context it is used in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
public class TextWatcherAdapter implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {

// Empty default implementation
// To be overriden depending on the context it is used in
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

// Empty default implementation
// To be overriden depending on the context it is used in
}

@Override
public void afterTextChanged(Editable s) {

// Empty default implementation
// To be overriden depending on the context it is used in
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public boolean valid(String value) {

@Override
public void onInvalidInput(String value) {

// Empty default implementation
// To be overriden depending on the context it is used in
}
}
Loading