-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample module and simple search example activity (#57)
* Add sample module and simple search example activity * Circle jdk 8 * Make circle happy * update build tools and sdk to 25 * Rm dupe circle and gradle-mvn-push files * Set artifact name * Proper versions in circle file * Default tasks to root build file & useLibrary for rm'd apache http * Add checkstyle to app module and fix checkstyle errors * Upgrade to robolectric 3.2.1 * Update support libs to 25.1.0 and rm test classes
- Loading branch information
1 parent
44a08c5
commit 289ee46
Showing
62 changed files
with
511 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ classes/ | |
build | ||
*.iml | ||
local.properties | ||
*.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'checkstyle' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.1" | ||
defaultConfig { | ||
applicationId "com.mapzen.pelias" | ||
minSdkVersion 15 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
task checkstyle(type: Checkstyle) { | ||
configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") | ||
source 'src' | ||
include '**/*.java' | ||
exclude '**/gen/**' | ||
|
||
classpath = files() | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:25.0.1' | ||
compile project(path: ':lib') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/sarahlensing/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# 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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.mapzen.sample.pelias"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET"/> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
86 changes: 86 additions & 0 deletions
86
app/src/main/java/com/mapzen/sample/pelias/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.mapzen.sample.pelias; | ||
|
||
import com.mapzen.pelias.BoundingBox; | ||
import com.mapzen.pelias.Pelias; | ||
import com.mapzen.pelias.PeliasLocationProvider; | ||
import com.mapzen.pelias.gson.Result; | ||
import com.mapzen.pelias.widget.AutoCompleteAdapter; | ||
import com.mapzen.pelias.widget.AutoCompleteListView; | ||
import com.mapzen.pelias.widget.PeliasSearchView; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.ActionBar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.Callback; | ||
import retrofit2.Response; | ||
|
||
/** | ||
* Main entry point for Pelias sample. Displays a {@link PeliasSearchView} and allows user to view | ||
* autocomplete results. | ||
*/ | ||
public class MainActivity extends AppCompatActivity { | ||
|
||
private static final String TAG = MainActivity.class.getSimpleName(); | ||
|
||
AutoCompleteListView listView; | ||
Pelias pelias; | ||
|
||
//Hard code to NYC for simplicity | ||
PeliasLocationProvider peliasLocationProvider = new PeliasLocationProvider() { | ||
@Override public double getLat() { | ||
return 40.74433; | ||
} | ||
|
||
@Override public double getLon() { | ||
return -73.9903; | ||
} | ||
|
||
@Override public BoundingBox getBoundingBox() { | ||
return new BoundingBox(40.74433, -73.9903, 40.741050, -73.996142); | ||
} | ||
}; | ||
|
||
@Override protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
setupPelias(); | ||
setupListView(); | ||
setupPeliasSearchView(); | ||
} | ||
|
||
private void setupPelias() { | ||
pelias = new Pelias(); | ||
pelias.setLocationProvider(peliasLocationProvider); | ||
} | ||
|
||
private void setupListView() { | ||
listView = (AutoCompleteListView) findViewById(R.id.list_view); | ||
AutoCompleteAdapter autocompleteAdapter = new AutoCompleteAdapter(this, | ||
android.R.layout.simple_list_item_1); | ||
listView.setAdapter(autocompleteAdapter); | ||
} | ||
|
||
private void setupPeliasSearchView() { | ||
PeliasSearchView searchView = new PeliasSearchView(this); | ||
ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, | ||
ActionBar.LayoutParams.MATCH_PARENT); | ||
getSupportActionBar().setCustomView(searchView, lp); | ||
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); | ||
searchView.setAutoCompleteListView(listView); | ||
searchView.setPelias(pelias); | ||
searchView.setCallback(new Callback<Result>() { | ||
@Override public void onResponse(Call<Result> call, Response<Result> response) { | ||
Log.d(TAG, "Feature Count:" + response.body().getFeatures().size()); | ||
} | ||
|
||
@Override public void onFailure(Call<Result> call, Throwable t) { | ||
Log.d(TAG, "Failure:" + t.getMessage()); | ||
} | ||
}); | ||
searchView.setIconifiedByDefault(false); | ||
searchView.setQueryHint(this.getString(R.string.search_hint)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/activity_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
tools:context="com.mapzen.sample.pelias.MainActivity" | ||
> | ||
|
||
<com.mapzen.pelias.widget.AutoCompleteListView | ||
android:id="@+id/list_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="#FFFFFF" | ||
android:visibility="gone" | ||
/> | ||
|
||
</RelativeLayout> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<resources> | ||
<string name="app_name">Pelias Sample</string> | ||
<string name="search_hint">Search</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,25 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
maven { | ||
url 'https://plugins.gradle.org/m2/' | ||
} | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:1.2.3' | ||
classpath 'com.github.dcendents:android-maven-plugin:1.2' | ||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' | ||
classpath 'net.researchgate:gradle-release:2.4.0' | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.github.dcendents.android-maven' | ||
apply plugin: 'com.neenbedankt.android-apt' | ||
apply plugin: 'checkstyle' | ||
apply plugin: 'net.researchgate.release' | ||
|
||
group = GROUP | ||
version = VERSION_NAME | ||
|
||
release { | ||
versionProperties = ['VERSION_NAME'] | ||
} | ||
|
||
afterReleaseBuild.dependsOn uploadArchives | ||
|
||
defaultTasks = ['clean', 'assembleDebug', 'checkstyle', 'copyTask', 'testDebug', 'install'] | ||
|
||
task checkstyle(type: Checkstyle) { | ||
configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") | ||
source 'src' | ||
include '**/*.java' | ||
exclude '**/gen/**' | ||
|
||
classpath = files() | ||
} | ||
|
||
task copyTask(type: Copy) { | ||
println "Copying com/mapzen/pelias/R.java to android/support/v7/appcompat/R.java" | ||
from 'build/generated/source/r/debug/com/mapzen/pelias' | ||
into 'build/generated/source/r/debug/android/support/v7/appcompat' | ||
include 'R.java' | ||
filter { line -> line.contains('package com.mapzen.pelias;') ? 'package android.support.v7.appcompat;' : line } | ||
} | ||
classpath 'com.android.tools.build:gradle:2.2.2' | ||
|
||
android { | ||
compileSdkVersion 22 | ||
buildToolsVersion "22.0.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 22 | ||
versionCode 4 | ||
versionName version | ||
} | ||
sourceSets { | ||
test { | ||
java.srcDir file('src/test/java') | ||
java.srcDir file('build/generated/source/r/debug') | ||
} | ||
} | ||
packagingOptions { | ||
exclude 'META-INF/LICENSE.txt' | ||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
tasks.withType(Test) { | ||
testLogging { | ||
exceptionFormat "full" | ||
events "started", "skipped", "passed", "failed" | ||
showStandardStreams true | ||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
repositories { | ||
jcenter() | ||
maven { url 'http://repo.maven.apache.org/maven2' } | ||
} | ||
|
||
dependencies { | ||
compile 'com.android.support:appcompat-v7:22.2.1@aar' | ||
compile 'com.android.support:support-v4:22.2.1@aar' | ||
compile 'com.squareup.okhttp3:okhttp:3.5.0' | ||
compile 'com.squareup.okhttp3:logging-interceptor:3.5.0' | ||
compile 'com.squareup.retrofit2:retrofit:2.1.0' | ||
compile 'com.squareup.retrofit2:converter-gson:2.1.0' | ||
compile 'javax.annotation:javax.annotation-api:1.2' | ||
compile 'com.github.frankiesardo:auto-parcel:0.3.1' | ||
apt 'com.github.frankiesardo:auto-parcel-processor:0.3.1' | ||
|
||
testCompile 'junit:junit:4.12' | ||
testCompile 'org.easytesting:fest-assert-core:2.0M10' | ||
testCompile 'com.squareup.okhttp:mockwebserver:1.5.2' | ||
testCompile 'org.mockito:mockito-all:1.9.5' | ||
testCompile('org.robolectric:robolectric:3.0-rc2') { | ||
exclude group: 'commons-logging', module: 'commons-logging' | ||
exclude group: 'org.apache.httpcomponents', module: 'httpclient' | ||
} | ||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} | ||
|
||
apply from: file('gradle-mvn-push.gradle') | ||
defaultTasks = ['clean', 'assembleDebug', 'checkstyle', 'copyTask', 'testDebug', 'install'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.