Skip to content

Commit 94ba91e

Browse files
committed
Merge branch 'master' into fix-threadSafeServerRequest
2 parents 8617042 + 09e66f6 commit 94ba91e

82 files changed

Lines changed: 2893 additions & 627 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE.txt

Lines changed: 621 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ AuthInfo auth = new GoogleLogin(httpClient).login("token");
4747
PokemonGo go = new PokemonGo(auth,httpClient);
4848
Log.v(go.getPlayerProfile());
4949
```
50+
##Android Dev FAQ
51+
52+
- I can't use the sample code! It just throws a login exception!
53+
54+
You're running the sample code on the UI thread. Strict mode policy will throw an exception in that case and its being caught by the network client and treating it as a login failed exception. Run the sample code on a background thread in AsyncTask or RXJava and it will work.
55+
56+
- I want to submit a refactor so that this library will use Google Volley
57+
58+
This library is meant to be a Java implementation of the API. Google Volley is specific to Android and should not be introduced in this library. However, if you still want to refactor it, you should create it as a separate project.
59+
5060

5161
## Contributing
5262
- Fork it!

build.gradle

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ buildscript {
88
dependencies {
99
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.7'
1010
}
11+
12+
1113
}
1214

1315
apply plugin: 'idea'
1416
apply plugin: 'java'
1517
apply plugin: 'maven'
1618
apply plugin: 'com.google.protobuf'
19+
apply plugin: 'checkstyle'
1720

1821
description = """Pokemon Go Java API"""
1922

@@ -42,11 +45,11 @@ processResources {
4245
// Run this task to bundle all needed dependency
4346
task bundle(type: Jar) {
4447
baseName = project.name + '_bundle'
45-
48+
4649
from {
47-
configurations.compile.collect {
48-
it.isDirectory() && !it.isEmpty() ? it : zipTree(it)
49-
}
50+
configurations.compile.collect {
51+
it.isDirectory() && !it.isEmpty() ? it : zipTree(it)
52+
}
5053
}
5154
with jar
5255
}
@@ -59,6 +62,37 @@ protobuf {
5962
}
6063
}
6164

65+
def checkstyleOutputDir = "${project.rootDir}/build/reports/checkstyle/"
66+
67+
checkstyle {
68+
toolVersion = '7.0'
69+
configFile = file("${project.rootDir}/config/checkstyle.xml")
70+
reportsDir = file(checkstyleOutputDir)
71+
72+
ignoreFailures = false
73+
74+
checkstyleMain {
75+
source = sourceSets.main.allSource
76+
}
77+
78+
configurations {
79+
checkstyle
80+
}
81+
82+
83+
dependencies {
84+
checkstyle "com.puppycrawl.tools:checkstyle:${toolVersion}"
85+
}
86+
}
87+
88+
//Abort if any checkstyle warnings
89+
checkstyleMain.doLast {
90+
def outputFile = file(checkstyleOutputDir + "main.xml")
91+
if (outputFile.exists() && outputFile.text.contains("<error ")) {
92+
throw new GradleException("There were checkstyle warnings! For more info check $outputFile")
93+
}
94+
}
95+
6296
dependencies {
6397
compile 'com.google.code.gson:gson:2.7'
6498
compile 'net.sourceforge.streamsupport:streamsupport:1.5'
@@ -71,4 +105,4 @@ idea {
71105
module {
72106
sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java");
73107
}
74-
}
108+
}

config/checkstyle.xml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4+
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
Checkstyle configuration that checks the Google coding conventions from:
8+
- Google Java Style
9+
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html
10+
Checkstyle is very configurable. Be sure to read the documentation at
11+
http://checkstyle.sf.net (or in your downloaded distribution).
12+
Most Checks are configurable, be sure to consult the documentation.
13+
To completely disable a check, just comment it out or delete it from the file.
14+
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
15+
-->
16+
17+
<module name = "Checker">
18+
<module name="SuppressionFilter">
19+
<property name="file" value="config/suppressions.xml"/>
20+
</module>
21+
22+
<property name="charset" value="UTF-8"/>
23+
24+
<property name="severity" value="warning"/>
25+
26+
<property name="fileExtensions" value="java, properties, xml"/>
27+
28+
29+
<module name="SuppressWarningsFilter"/>
30+
<module name="TreeWalker">
31+
<module name="SuppressWarningsHolder"/>
32+
<property name="tabWidth" value="2"/>
33+
<module name="RegexpSinglelineJava">
34+
<property name="format" value="^\t* "/>
35+
<property name="message" value="Indent must use tab characters"/>
36+
<property name="ignoreComments" value="true"/>
37+
</module>
38+
<module name="OuterTypeFilename"/>
39+
<module name="IllegalTokenText">
40+
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
41+
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
42+
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
43+
</module>
44+
<module name="AvoidEscapedUnicodeCharacters">
45+
<property name="allowEscapesForControlCharacters" value="true"/>
46+
<property name="allowByTailComment" value="true"/>
47+
<property name="allowNonPrintableEscapes" value="true"/>
48+
</module>
49+
<module name="LineLength">
50+
<property name="max" value="120"/>
51+
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
52+
</module>
53+
<module name="AvoidStarImport"/>
54+
<module name="OneTopLevelClass"/>
55+
<module name="NoLineWrap"/>
56+
<module name="EmptyBlock">
57+
<property name="option" value="TEXT"/>
58+
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
59+
</module>
60+
<module name="NeedBraces"/>
61+
<module name="LeftCurly">
62+
<property name="maxLineLength" value="120"/>
63+
</module>
64+
<module name="RightCurly"/>
65+
<module name="RightCurly">
66+
<property name="option" value="alone"/>
67+
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
68+
</module>
69+
<module name="WhitespaceAround">
70+
<property name="allowEmptyConstructors" value="true"/>
71+
<property name="allowEmptyMethods" value="true"/>
72+
<property name="allowEmptyTypes" value="true"/>
73+
<property name="allowEmptyLoops" value="true"/>
74+
<message key="ws.notFollowed"
75+
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
76+
<message key="ws.notPreceded"
77+
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
78+
</module>
79+
<module name="OneStatementPerLine"/>
80+
<module name="MultipleVariableDeclarations"/>
81+
<module name="ArrayTypeStyle"/>
82+
<module name="MissingSwitchDefault"/>
83+
<module name="FallThrough"/>
84+
<module name="UpperEll"/>
85+
<module name="ModifierOrder"/>
86+
<module name="EmptyLineSeparator">
87+
<property name="allowNoEmptyLineBetweenFields" value="true"/>
88+
</module>
89+
<module name="SeparatorWrap">
90+
<property name="tokens" value="DOT"/>
91+
<property name="option" value="nl"/>
92+
</module>
93+
<module name="SeparatorWrap">
94+
<property name="tokens" value="COMMA"/>
95+
<property name="option" value="EOL"/>
96+
</module>
97+
<module name="PackageName">
98+
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
99+
<message key="name.invalidPattern"
100+
value="Package name ''{0}'' must match pattern ''{1}''."/>
101+
</module>
102+
<module name="TypeName">
103+
<message key="name.invalidPattern"
104+
value="Type name ''{0}'' must match pattern ''{1}''."/>
105+
</module>
106+
<module name="MemberName">
107+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
108+
<message key="name.invalidPattern"
109+
value="Member name ''{0}'' must match pattern ''{1}''."/>
110+
</module>
111+
<module name="ParameterName">
112+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
113+
<message key="name.invalidPattern"
114+
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
115+
</module>
116+
<module name="LocalVariableName">
117+
<property name="tokens" value="VARIABLE_DEF"/>
118+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
119+
<property name="allowOneCharVarInForLoop" value="true"/>
120+
<message key="name.invalidPattern"
121+
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
122+
</module>
123+
<module name="ClassTypeParameterName">
124+
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
125+
<message key="name.invalidPattern"
126+
value="Class type name ''{0}'' must match pattern ''{1}''."/>
127+
</module>
128+
<module name="MethodTypeParameterName">
129+
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
130+
<message key="name.invalidPattern"
131+
value="Method type name ''{0}'' must match pattern ''{1}''."/>
132+
</module>
133+
<module name="NoFinalizer"/>
134+
<module name="GenericWhitespace">
135+
<message key="ws.followed"
136+
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
137+
<message key="ws.preceded"
138+
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
139+
<message key="ws.illegalFollow"
140+
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
141+
<message key="ws.notPreceded"
142+
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
143+
</module>
144+
<module name="Indentation">
145+
<property name="basicOffset" value="2"/>
146+
<property name="braceAdjustment" value="0"/>
147+
<property name="caseIndent" value="2"/>
148+
<property name="throwsIndent" value="4"/>
149+
<property name="lineWrappingIndentation" value="4"/>
150+
<property name="arrayInitIndent" value="2"/>
151+
</module>
152+
<module name="AbbreviationAsWordInName">
153+
<property name="ignoreFinal" value="false"/>
154+
<property name="allowedAbbreviationLength" value="1"/>
155+
</module>
156+
<module name="OverloadMethodsDeclarationOrder"/>
157+
<module name="VariableDeclarationUsageDistance"/>
158+
<module name="CustomImportOrder">
159+
<property name="specialImportsRegExp" value="com.google"/>
160+
<property name="sortImportsInGroupAlphabetically" value="true"/>
161+
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
162+
</module>
163+
<module name="MethodParamPad"/>
164+
<module name="OperatorWrap">
165+
<property name="option" value="NL"/>
166+
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
167+
</module>
168+
<module name="AnnotationLocation">
169+
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
170+
</module>
171+
<module name="AnnotationLocation">
172+
<property name="tokens" value="VARIABLE_DEF"/>
173+
<property name="allowSamelineMultipleAnnotations" value="true"/>
174+
</module>
175+
<module name="NonEmptyAtclauseDescription"/>
176+
<module name="JavadocTagContinuationIndentation"/>
177+
<module name="SummaryJavadocCheck">
178+
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
179+
</module>
180+
<module name="JavadocParagraph"/>
181+
<module name="AtclauseOrder">
182+
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
183+
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
184+
</module>
185+
<module name="JavadocMethod">
186+
<property name="scope" value="public"/>
187+
<property name="allowMissingParamTags" value="true"/>
188+
<property name="allowMissingThrowsTags" value="true"/>
189+
<property name="allowMissingReturnTag" value="true"/>
190+
<property name="minLineCount" value="2"/>
191+
<property name="allowedAnnotations" value="Override, Test"/>
192+
<property name="allowThrowsTagsForSubclasses" value="true"/>
193+
</module>
194+
<module name="MethodName">
195+
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
196+
<message key="name.invalidPattern"
197+
value="Method name ''{0}'' must match pattern ''{1}''."/>
198+
</module>
199+
<module name="SingleLineJavadoc">
200+
<property name="ignoreInlineTags" value="false"/>
201+
</module>
202+
<module name="EmptyCatchBlock">
203+
<property name="exceptionVariableName" value="expected"/>
204+
</module>
205+
<module name="CommentsIndentation"/>
206+
</module>
207+
</module>

config/suppressions.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
4+
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
5+
6+
<!--
7+
~ Copyright 2015 Goldman Sachs.
8+
~
9+
~ Licensed under the Apache License, Version 2.0 (the "License");
10+
~ you may not use this file except in compliance with the License.
11+
~ You may obtain a copy of the License at
12+
~
13+
~ http://www.apache.org/licenses/LICENSE-2.0
14+
~
15+
~ Unless required by applicable law or agreed to in writing, software
16+
~ distributed under the License is distributed on an "AS IS" BASIS,
17+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
~ See the License for the specific language governing permissions and
19+
~ limitations under the License.
20+
-->
21+
22+
<suppressions>
23+
<suppress checks="." files="com[\\/]pokegoapi[\\/]google[\\/]common[\\/]geometry[\\/]"/>
24+
<suppress checks="." files="[\\/]build[\\/]"/>
25+
</suppressions>

project_code_style.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<code_scheme name="Project">
2+
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
3+
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="99" />
4+
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
5+
<value />
6+
</option>
7+
<XML>
8+
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
9+
</XML>
10+
<codeStyleSettings language="JAVA">
11+
<indentOptions>
12+
<option name="USE_TAB_CHARACTER" value="true" />
13+
</indentOptions>
14+
</codeStyleSettings>
15+
</code_scheme>

0 commit comments

Comments
 (0)