Skip to content

Commit

Permalink
Tons of updates.
Browse files Browse the repository at this point in the history
Expanded details implementation.
Added ProGuard rules.
New resources.
Introduced Java 8.
Updated gradle.
  • Loading branch information
andrewvora committed Jan 19, 2018
1 parent 363df07 commit c63b7cb
Show file tree
Hide file tree
Showing 51 changed files with 1,065 additions and 436 deletions.
3 changes: 0 additions & 3 deletions .idea/codeStyleSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 55 additions & 59 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'jacoco'
apply plugin: 'kotlin-kapt'

repositories {
maven { url 'https://maven.fabric.io/public' }
Expand All @@ -10,10 +11,10 @@ repositories {

android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.andrewvora.apps.rideatlanta"
minSdkVersion 16
minSdkVersion 21
targetSdkVersion 26
versionCode 2
versionName "1.1.0"
Expand All @@ -24,6 +25,8 @@ android {
debug {
minifyEnabled false
shrinkResources false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

buildConfigField "String", "MARTA_API_KEY", "\"$System.env.RIDEATLANTA_MARTA_API_KEY\""
buildConfigField "String", "FABRIC_API_KEY", "\"$System.env.RIDEATLANTA_FABRIC_API_KEY\""
Expand All @@ -43,78 +46,71 @@ android {
}
}

testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])

def app_compat_version = '26.0.0'
def app_compat_version = '26.1.0'
def dagger_version = '2.11'
def butter_knife_version = '8.4.0'
def butter_knife_version = '8.5.1'
def retrofit_version = '2.3.0'
def leak_canary_version = '1.5.4'

// System Dependencies
compile "com.android.support:appcompat-v7:$app_compat_version"
compile "com.android.support:design:$app_compat_version"
compile "com.android.support:cardview-v7:$app_compat_version"
compile "com.android.support:recyclerview-v7:$app_compat_version"
compile('com.twitter.sdk.android:twitter:2.2.0@aar') {
transitive = true;
implementation "com.android.support:appcompat-v7:$app_compat_version"
implementation "com.android.support:design:$app_compat_version"
implementation "com.android.support:cardview-v7:$app_compat_version"
implementation "com.android.support:recyclerview-v7:$app_compat_version"
implementation('com.twitter.sdk.android:twitter:2.2.0@aar') {
transitive = true
}

compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'

compile "com.jakewharton:butterknife:$butter_knife_version"
annotationProcessor "com.jakewharton:butterknife-compiler:$butter_knife_version"

compile "com.google.dagger:dagger:$dagger_version"
compile "com.google.dagger:dagger-android:$dagger_version"
compile "com.google.dagger:dagger-android-support:$dagger_version"
compile "com.google.code.findbugs:jsr305:3.0.2"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
compile 'com.android.volley:volley:1.0.0'
compile 'com.google.code.gson:gson:2.7'

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation 'io.reactivex.rxjava2:rxjava:2.1.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

implementation "com.jakewharton:butterknife:$butter_knife_version"
kapt "com.jakewharton:butterknife-compiler:$butter_knife_version"

implementation "com.google.dagger:dagger:$dagger_version"
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
implementation "com.google.code.findbugs:jsr305:3.0.2"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.google.code.gson:gson:2.8.0'

// dev
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// debugCompile "com.squareup.leakcanary:leakcanary-android:$leak_canary_version"
debugImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary_version"

// test
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})

testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.8.47'
}

jacoco {
toolVersion '0.7.9'
reportsDir = file("$buildDir/jacocoReports")
}

task jacocoTestReport(type: JacocoReport, dependsOn: ['test']) {

reports {
xml.enabled = true
html.enabled = true
// LeakCanary - ensure the no-op dependency is always used in JVM tests.
configurations.all { config ->
if (config.name.contains('UnitTest')) {
config.resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.squareup.leakcanary' && details.requested.name == 'leakcanary-android') {
details.useTarget(group: details.requested.group, name: 'leakcanary-android-no-op', version: details.requested.version)
}
}
}

def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "${buildDir}/intermediates/classes/debug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"

sourceDirectories = files([mainSrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: "$buildDir", includes: [
"jacoco/testDebugUnitTest.exec"
])
}
}
48 changes: 37 additions & 11 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,49 @@
#}

## ButterKnife Rules
# Retain generated class which implement ViewBinder.
-keep public class * implements butterknife.internal.ViewBinder { public <init>(); }
# Retain generated class which implement Unbinder.
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }

# Prevent obfuscation of types which use ButterKnife annotations since the simple name
# is used to reflectively look up the generated ViewBinder.
# is used to reflectively look up the generated ViewBinding.
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }

## Firebase Rules
## OkHttp
-dontnote okhttp3.internal.Platform
-dontnote com.squareup.okhttp.internal.Platform
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

## Okio
# java.nio.file.* usage which cannot be used at runtime. Animal sniffer annotation.
-dontwarn okio.Okio
# JDK 7-only method which is @hide on Android. Animal sniffer annotation.
-dontwarn okio.DeflaterSink

## Kotlin
-keepattributes *Annotation*

-keep class kotlin.** { *; }
-keep class org.jetbrains.** { *; }

## Kotlin Reflect
-dontwarn kotlin.reflect.jvm.internal.**

# Retrofit 2.X
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepclassmembers class com.andrewvora.apps.rideatlanta.data.models.** {
*;
}
-keepattributes Exceptions

## Design Support Library
-keep class android.support.design.widget.** { *; }
-keep interface android.support.design.widget.** { *; }
-dontwarn android.support.design.**
-keepclasseswithmembers class * {
@retrofit2.http.* <methods>;
}

## Project
-keep class com.andrewvora.apps.rideatlanta.** { *; }
-dontwarn com.google.errorprone.annotations.**
-dontnote org.apache.http.**
-dontnote android.net.http.*
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class MainActivity extends AppCompatActivity implements HasFragmentInject
@Inject
RoutePollingHelper pollingHelper;

private MenuItem sortMenuItem;
private FavoriteRoutesLoadingCache favRouteDataManager;
private SharedPrefsManager prefManager;

Expand All @@ -98,7 +99,9 @@ protected void onCreate(Bundle savedInstanceState) {
}

prefManager = new SharedPrefsManager(getApplication());
applySelectedTab(prefManager.getSelectedTab());

final int tabId = prefManager.getSelectedTab() == 0 ? R.id.tab_home : prefManager.getSelectedTab();
applySelectedTab(tabId);

bottomBar.setSelectedItemId(prefManager.getSelectedTab());
bottomBar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
Expand Down Expand Up @@ -134,11 +137,16 @@ private void applySelectedTab(@IdRes int tabId) {
}

prefManager.setSelectedTab(tabId);
updateMenu();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_home, menu);

sortMenuItem = menu.findItem(R.id.menu_sort);
updateMenu();

return super.onCreateOptionsMenu(menu);
}

Expand Down Expand Up @@ -314,6 +322,16 @@ private void startFragment(@IdRes int parentId, @NonNull Fragment fragment,
ft.commit();
}

private void updateMenu() {
if (sortMenuItem != null && bottomBar != null) {
// TODO: enable this logic after sort is completed
//final boolean showSortOption =
// bottomBar.getSelectedItemId() == R.id.tab_trains ||
// bottomBar.getSelectedItemId() == R.id.tab_buses;
//sortMenuItem.setVisible(showSortOption);
}
}

@Override
public AndroidInjector<Fragment> fragmentInjector() {
return fragmentInjector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import com.andrewvora.apps.rideatlanta.data.RoutePollingHelper;
import com.andrewvora.apps.rideatlanta.di.components.DaggerAppComponent;
import com.twitter.sdk.android.Twitter;
import com.twitter.sdk.android.core.TwitterAuthConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface View extends BaseView<BusRoutesContract.Presenter> {
void onBusRoutesLoaded(List<Bus> routesList);
void applyFavorites(@NonNull List<FavoriteRouteDataObject> favRoutes);
void updateFavoriteStatusOf(@NonNull Bus bus);
void refreshError(Throwable e);

Context getViewContext();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.andrewvora.apps.rideatlanta.BuildConfig;
import com.andrewvora.apps.rideatlanta.R;
import com.andrewvora.apps.rideatlanta.data.contracts.FavoriteRouteDataObject;
import com.andrewvora.apps.rideatlanta.data.models.Bus;
Expand Down Expand Up @@ -51,7 +54,7 @@ interface BusItemListener {
private BusItemListener busItemListener = new BusItemListener() {
@Override
public void onItemClicked(Bus bus) {
final Intent detailIntent = RouteDetailsActivity.start(bus);
final Intent detailIntent = RouteDetailsActivity.start(getActivity(), bus);
startActivityForResult(detailIntent, 0);
}

Expand Down Expand Up @@ -96,26 +99,20 @@ public void onRefresh() {
busesRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
busesRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(getViewContext()));

if(presenter != null) {
presenter.onRestoreState(savedInstanceState);
}

return view;
}

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

public void onStart() {
super.onStart();
if(presenter != null) {
presenter.start();
}
}

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

public void onStop() {
super.onStop();
if(presenter != null) {
presenter.stop();
}
Expand Down Expand Up @@ -168,4 +165,12 @@ public void setPresenter(BusRoutesContract.Presenter presenter) {
public Context getViewContext() {
return getActivity().getApplication();
}

@Override
public void refreshError(@NonNull Throwable e) {
if (BuildConfig.DEBUG) {
Log.d(BusRoutesFragment.class.getSimpleName(), e.getMessage());
}
Toast.makeText(getViewContext(), R.string.error_refresh_buses, Toast.LENGTH_SHORT).show();
}
}
Loading

0 comments on commit c63b7cb

Please sign in to comment.