Skip to content

Commit

Permalink
Release version 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Teester committed Mar 15, 2018
2 parents 36771b6 + 145cb6e commit d817b43
Show file tree
Hide file tree
Showing 143 changed files with 2,844 additions and 1,141 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ android:

before_install:
- yes | sdkmanager "platforms;android-$ANDROID_API_LEVEL"
- sudo apt-get install jq
- wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r .assets[0].browser_download_url)

# Emulator Management: Create, Start and Wait
before_script:
Expand All @@ -59,3 +61,5 @@ script:

after_success:
- bash <(curl -s https://codecov.io/bash)
- java -cp ~/codacy-coverage-reporter-assembly-latest.jar com.codacy.CodacyCoverageReporter -l Java -r ./app/build/reports/jacoco/jacocoTestDebugUnitTestReport/jacocoTestDebugUnitTestReport.xml

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Download the beta from Google Play.

## What's the build status?

[![Build Status](https://travis-ci.org/Teester/Whats-Nearby.svg?branch=master)](https://travis-ci.org/Teester/Whats-Nearby) [![codecov](https://codecov.io/gh/Teester/Whats-Nearby/branch/master/graph/badge.svg)](https://codecov.io/gh/Teester/Whats-Nearby)
[![Build Status](https://travis-ci.org/Teester/Whats-Nearby.svg?branch=master)](https://travis-ci.org/Teester/Whats-Nearby) [![codecov](https://codecov.io/gh/Teester/Whats-Nearby/branch/master/graph/badge.svg)](https://codecov.io/gh/Teester/Whats-Nearby) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/6635ff22c9b240f79c6472dfd66b594e)](https://www.codacy.com/app/Teester/Whats-Nearby?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Teester/Whats-Nearby&amp;utm_campaign=Badge_Grade)

## What's done
- Basic location determination and notification logic
Expand Down
14 changes: 9 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId 'com.teester.whatsnearby'
minSdkVersion 21
targetSdkVersion 27
versionCode 12
versionName "0.12"
versionCode 13
versionName "0.13"
setProperty("archivesBaseName", "whatsnearby-$versionName")
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand All @@ -34,13 +34,16 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'android.arch.lifecycle:extensions:1.1.0'
implementation 'android.arch.persistence.room:runtime:1.0.0'
Expand All @@ -57,6 +60,7 @@ dependencies {
}

androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation 'android.arch.core:core-testing:1.1.0'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.11.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.teester.whatsnearby;

import android.arch.core.executor.testing.InstantTaskExecutorRule;
import android.arch.persistence.room.Room;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import com.teester.whatsnearby.data.OsmObject;
import com.teester.whatsnearby.data.database.AppDatabase;
import com.teester.whatsnearby.data.database.VisitedLocation;
import com.teester.whatsnearby.data.database.VisitedLocationDao;

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

import java.util.List;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;

@RunWith(AndroidJUnit4.class)
public class DatabaseInstrumentedTest {

@Rule
public InstantTaskExecutorRule instantTaskExecutorRule = new InstantTaskExecutorRule();

private AppDatabase mDatabase;
private VisitedLocationDao visitedLocationDao;
private OsmObject osmObject = new OsmObject(1, "", "1", "", 1, 1, 1);
private OsmObject osmObject2 = new OsmObject(2, "", "2", "", 1, 1, 1);
private OsmObject osmObject3 = new OsmObject(3, "", "3", "", 1, 1, 1);
private OsmObject osmObject4 = new OsmObject(4, "", "4", "", 1, 1, 1);
private OsmObject osmObject5 = new OsmObject(5, "", "5", "", 1, 1, 1);

@Before
public void initDb() throws Exception {
mDatabase = Room.inMemoryDatabaseBuilder(InstrumentationRegistry.getContext(),
AppDatabase.class)
.allowMainThreadQueries()
.build();

visitedLocationDao = mDatabase.visitedLocationDao();
}

@After
public void closeDb() throws Exception {
mDatabase.close();
}

@Test
public void onFetchingLocationsShouldGetEmptyListIfTableIsEmpty() throws InterruptedException {
List<VisitedLocation> LocationList = visitedLocationDao.getAllVisitedLocations();
assertTrue(LocationList.isEmpty());
}

@Test
public void onInsertingLocationsCheckIfRowCountIsCorrect() throws InterruptedException {
visitedLocationDao.insert(new VisitedLocation(osmObject));
visitedLocationDao.insert(new VisitedLocation(osmObject2));
visitedLocationDao.insert(new VisitedLocation(osmObject3));
visitedLocationDao.insert(new VisitedLocation(osmObject4));
visitedLocationDao.insert(new VisitedLocation(osmObject5));

assertEquals(5, visitedLocationDao.getAllVisitedLocations().size());
}

@Test
public void onUpdatingALocationCheckIfUpdateHappensCorrectly() throws InterruptedException {
VisitedLocation visitedLocation = new VisitedLocation(osmObject);
visitedLocationDao.insert(visitedLocation);

visitedLocation = visitedLocationDao.findByOsmId(osmObject.getId());
visitedLocation.setName("New Name");
visitedLocationDao.update(visitedLocation);

assertEquals(1, visitedLocationDao.getAllVisitedLocations().size());
assertEquals("New Name", visitedLocationDao.findByOsmId(osmObject.getId()).getName());
}

@Test
public void onLocationDeletionCheckIfLocationIsDeletedFromTable() {
visitedLocationDao.insert(new VisitedLocation(osmObject));
visitedLocationDao.insert(new VisitedLocation(osmObject2));
visitedLocationDao.insert(new VisitedLocation(osmObject3));
visitedLocationDao.insert(new VisitedLocation(osmObject4));
visitedLocationDao.insert(new VisitedLocation(osmObject5));

visitedLocationDao.delete(visitedLocationDao.findByOsmId(osmObject2.getId()));
assertNull(visitedLocationDao.findByOsmId(osmObject2.getId()));
}
}
9 changes: 7 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.teester.whatsnearby">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Expand Down Expand Up @@ -31,18 +32,22 @@
android:scheme="mapquestions"/>
</intent-filter>
</activity>
<service android:name=".data.location.LocationService"/>

<activity
android:name="com.teester.whatsnearby.questions.QuestionsActivity"
android:label="@string/title_activity_questions"
android:theme="@style/AppTheme.NoActionBar">

</activity>
<receiver android:name="com.teester.whatsnearby.Startup">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".data.location.LocationJobServiceReceiver"/>

<service
android:name=".data.location.LocationJobService"
android:permission="android.permission.BIND_JOB_SERVICE"/>
</application>

</manifest>
9 changes: 0 additions & 9 deletions app/src/main/java/com/teester/whatsnearby/BasePresenter.java

This file was deleted.

6 changes: 0 additions & 6 deletions app/src/main/java/com/teester/whatsnearby/BaseView.java

This file was deleted.

13 changes: 11 additions & 2 deletions app/src/main/java/com/teester/whatsnearby/Startup.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package com.teester.whatsnearby;

import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

import com.teester.whatsnearby.data.location.LocationService;
import com.teester.whatsnearby.data.location.LocationJobService;

public class Startup extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() == Intent.ACTION_BOOT_COMPLETED) {
context.startService(new Intent(context, LocationService.class));

JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
ComponentName jobService = new ComponentName(context.getPackageName(), LocationJobService.class.getName());
JobInfo jobInfo = new JobInfo.Builder(1, jobService)
.setPeriodic(60000)
.build();
jobScheduler.schedule(jobInfo);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/com/teester/whatsnearby/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ public static Map<String, List<String>> splitQuery(URI url) throws UnsupportedEn
/**
* Calculates the distance, in metres, between two points
*
* @param lat1 - latitude of location 1
* @param lon1 - longitude of location 1
* @param lat2 - latitude of location 2
* @param lon2 - longitude of location 2
* @param latitude1 - latitude of location 1
* @param longitude1 - longitude of location 1
* @param latitude2 - latitude of location 2
* @param longitude2 - longitude of location 2
* @return - distance between location 1 and 2
*/
public static float computeDistance(double lat1, double lon1, double lat2, double lon2) {
public static float computeDistance(double latitude1, double longitude1, double latitude2, double longitude2) {
// Based on http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
// using the "Inverse Formula" (section 4)

int MAXITERS = 20;
// Convert lat/long to radians
lat1 *= Math.PI / 180.0;
lat2 *= Math.PI / 180.0;
lon1 *= Math.PI / 180.0;
lon2 *= Math.PI / 180.0;
double lat1 = latitude1 * (Math.PI / 180.0);
double lat2 = latitude2 * (Math.PI / 180.0);
double lon1 = longitude1 * (Math.PI / 180.0);
double lon2 = longitude2 * (Math.PI / 180.0);

double a = 6378137.0; // WGS84 major axis
double b = 6356752.3142; // WGS84 semi-major axis
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/teester/whatsnearby/data/Answers.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ public class Answers {

private static Answers INSTANCE;
private static OsmObject osmObject;
private static int id;
private static String name;
private static String objectType;
private static Map<String, String> answerMap = new HashMap<>();
private static Map<String, String> changesetTags;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.teester.whatsnearby.data;

import com.teester.whatsnearby.data.pois.PoiContract;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -61,7 +63,7 @@ public String getTag(String key) {
}

public int getDrawable() {
OsmObjectType objectType = PoiTypes.getPoiType(this.type);
PoiContract objectType = PoiTypes.getPoiType(this.type);
int drawable = objectType.getObjectIcon();
return drawable;
}
Expand Down
Loading

0 comments on commit d817b43

Please sign in to comment.