Skip to content

Commit

Permalink
initial codebase commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shardul Prabhu committed Apr 2, 2018
1 parent fe8bfcb commit ae9cbe6
Show file tree
Hide file tree
Showing 89 changed files with 2,236 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
122 changes: 122 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "github.shardul.cats"

minSdkVersion 17

targetSdkVersion 27

versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}

dataBinding {
enabled = true
}

buildTypes {
release {

// Load signing config, we keep release signing credentials out of build file
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

def keystoreFile = properties.getProperty('keystore.file')
def keystorePassword = properties.getProperty('keystore.password')
def keystoreAlias = properties.getProperty('keystore.alias')
def validConfig = keystoreFile != null && keystorePassword != null && keystoreAlias != null;

if (validConfig) {
System.out.println("Release signing configured with " + keystoreFile)
signingConfigs {
release {
storeFile project.rootProject.file(keystoreFile)
storePassword keystorePassword
keyAlias keystoreAlias
keyPassword keystorePassword
v1SigningEnabled true
v2SigningEnabled true
}
}
} else {
System.out.println("Specify keystore.file, keystore.alias and keystore.password in local.properties to enable release signing.")
}

if (validConfig) {
signingConfig signingConfigs.release
}

minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

flavorDimensions "all"

productFlavors {
cats {
buildConfigField "String", "CAT_CATEGORY", "\"clothes\""
dimension "all"
}
kittens {
buildConfigField "String", "CAT_CATEGORY", "\"caturday\""
dimension "all"
applicationIdSuffix ".kittens"
}
}

compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

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

// support libraries
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:recyclerview-v7:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:design:$support_version"

implementation "com.android.support.constraint:constraint-layout:$constraint_layout_version"

// network
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
implementation "com.google.code.gson:gson:$google_gson_version"
implementation "com.github.bumptech.glide:glide:$glide_version"
implementation("com.squareup.retrofit2:converter-simplexml:$simple_xml_version"){
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'stax', module: 'stax-api'
exclude group: 'stax', module: 'stax'
}

// di
implementation "com.google.dagger:dagger:$dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"

// Architecture components
implementation "android.arch.lifecycle:extensions:$arch_version"
implementation "android.arch.lifecycle:runtime:$arch_version"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"


testImplementation "junit:junit:$junit_version"
androidTestImplementation "com.android.support.test:runner:$runner_version"
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espresso_version"

// Misc
implementation "com.jakewharton.timber:timber:$timber_version"


}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package github.shardul.cats;

import android.app.Activity;
import android.support.test.espresso.IdlingRegistry;
import android.support.test.espresso.IdlingResource;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.view.View;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;


@RunWith(AndroidJUnit4.class)
/**
* Checks when refresh is tapped progress view is shown,
* and when refresh is complete refresh button is visible again.
* */
public class LoadCatsInstrumentedTest {

@Rule
public ActivityTestRule<MainActivity> mMainActivityRule
= new ActivityTestRule<>(MainActivity.class);

@Test
public void loadCats() {

final int progressId = R.id.cats_fragment_progress;
final int buttonId = R.id.cats_fragment_refresh;

onView(withId(buttonId)).perform(click());

onView(withId(progressId)).check(matches(isDisplayed()));

final VisibilityIdlingResource progressIdlingResource = new VisibilityIdlingResource(
mMainActivityRule.getActivity() , progressId);


IdlingRegistry.getInstance().register(progressIdlingResource);

onView(withId(buttonId)).check(matches(isDisplayed()));
}

}

class VisibilityIdlingResource implements IdlingResource {

final Activity mActivity;
final int mResource;
ResourceCallback mResourceCallback;

public VisibilityIdlingResource(Activity activity, int resource) {
this.mActivity = activity;
this.mResource = resource;
}

@Override
public String getName() {
return "loading progress";
}

@Override
public boolean isIdleNow() {
final boolean idleNow = mActivity.findViewById(mResource).getVisibility() == View.GONE;
if (idleNow) {
if (mResourceCallback != null) {
mResourceCallback.onTransitionToIdle();
}
}
return idleNow;
}

@Override
public void registerIdleTransitionCallback(ResourceCallback callback) {
mResourceCallback = callback;
}
}
Loading

0 comments on commit ae9cbe6

Please sign in to comment.