diff --git a/app/build.gradle b/app/build.gradle index 215e589a..a09478c7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -19,7 +19,7 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { - minifyEnabled false + minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } diff --git a/app/src/main/java/com/omkarmoghe/pokemap/MainActivity.java b/app/src/main/java/com/omkarmoghe/pokemap/MainActivity.java index 09b53a56..106eb03a 100644 --- a/app/src/main/java/com/omkarmoghe/pokemap/MainActivity.java +++ b/app/src/main/java/com/omkarmoghe/pokemap/MainActivity.java @@ -128,7 +128,7 @@ public void credentialsIntroduced(String username, String password) { } - private NianticManager.NianticEventListener mEventListener = new AbstractNianticEventListener(){ + private NianticManager.Listener mEventListener = new AbstractNianticEventListener(){ @Override public void onOperationFailure(Exception ex) { super.onOperationFailure(ex); diff --git a/app/src/main/java/com/omkarmoghe/pokemap/common/AbstractNianticEventListener.java b/app/src/main/java/com/omkarmoghe/pokemap/common/AbstractNianticEventListener.java index 41f634c4..60e31afa 100644 --- a/app/src/main/java/com/omkarmoghe/pokemap/common/AbstractNianticEventListener.java +++ b/app/src/main/java/com/omkarmoghe/pokemap/common/AbstractNianticEventListener.java @@ -12,7 +12,7 @@ * Created by coreymann on 7/22/16. */ -public class AbstractNianticEventListener implements NianticManager.NianticEventListener { +public class AbstractNianticEventListener implements NianticManager.Listener { @Override public void onLogin(RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo info, PokemonGo pokemonGo) { diff --git a/app/src/main/java/com/omkarmoghe/pokemap/common/Notifier.java b/app/src/main/java/com/omkarmoghe/pokemap/common/Notifier.java index 86772489..27bb10c1 100644 --- a/app/src/main/java/com/omkarmoghe/pokemap/common/Notifier.java +++ b/app/src/main/java/com/omkarmoghe/pokemap/common/Notifier.java @@ -11,7 +11,6 @@ import java.util.ArrayList; import java.util.List; -import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass; import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo; @@ -32,18 +31,18 @@ public static Notifier instance(){ //region Members private Handler mHandler = new Handler(Looper.getMainLooper()); - private List mListeners = new ArrayList<>(); + private List mListeners = new ArrayList<>(); - public void addListener(NianticManager.NianticEventListener listener){ this.mListeners.add(listener); } - public void removeListener(NianticManager.NianticEventListener listener) { this.mListeners.remove(listener); } + public void addListener(NianticManager.Listener listener){ this.mListeners.add(listener); } + public void removeListener(NianticManager.Listener listener) { this.mListeners.remove(listener); } public void dispatchOnLogin(final AuthInfo info, final PokemonGo pokemonGo){ mHandler.post(new Runnable() { @Override public void run() { - for(NianticManager.NianticEventListener l : mListeners){ + for(NianticManager.Listener l : mListeners){ try{ l.onLogin(info, pokemonGo); }catch(Exception ex){ @@ -58,7 +57,7 @@ public void dispatchOnCatchablePokemonFound(final List pokemon mHandler.post(new Runnable() { @Override public void run() { - for(NianticManager.NianticEventListener l : mListeners){ + for(NianticManager.Listener l : mListeners){ l.onCatchablePokemonFound(pokemons); } } @@ -68,7 +67,7 @@ public void dispatchOnOperationFailure(final Exception ex){ mHandler.post(new Runnable() { @Override public void run() { - for(NianticManager.NianticEventListener l : mListeners){ + for(NianticManager.Listener l : mListeners){ try{ l.onOperationFailure(ex); }catch(Exception ex){ diff --git a/app/src/main/java/com/omkarmoghe/pokemap/network/LoginType.java b/app/src/main/java/com/omkarmoghe/pokemap/network/LoginType.java deleted file mode 100644 index 487adcf5..00000000 --- a/app/src/main/java/com/omkarmoghe/pokemap/network/LoginType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.omkarmoghe.pokemap.network; - -/** - * Created by coreymann on 7/22/16. - */ -public enum LoginType { -} diff --git a/app/src/main/java/com/omkarmoghe/pokemap/network/NianticManager.java b/app/src/main/java/com/omkarmoghe/pokemap/network/NianticManager.java index 2185fa8a..1603d4ac 100644 --- a/app/src/main/java/com/omkarmoghe/pokemap/network/NianticManager.java +++ b/app/src/main/java/com/omkarmoghe/pokemap/network/NianticManager.java @@ -1,12 +1,11 @@ package com.omkarmoghe.pokemap.network; import android.content.Context; -import android.location.Location; import android.os.Handler; import android.os.HandlerThread; +import android.support.annotation.NonNull; import android.telephony.TelephonyManager; import android.telephony.gsm.GsmCellLocation; -import android.util.Log; import com.omkarmoghe.pokemap.common.Notifier; import com.omkarmoghe.pokemap.utils.Varint; @@ -14,6 +13,7 @@ import com.pokegoapi.api.map.pokemon.CatchResult; import com.pokegoapi.api.map.pokemon.CatchablePokemon; import com.pokegoapi.api.map.pokemon.EncounterResult; +import com.pokegoapi.auth.GoogleLogin; import com.pokegoapi.auth.PtcLogin; import com.pokegoapi.exceptions.LoginFailedException; import com.pokegoapi.exceptions.RemoteServerException; @@ -22,7 +22,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.concurrent.TimeUnit; @@ -31,8 +30,6 @@ import POGOProtos.Networking.Envelopes.RequestEnvelopeOuterClass.RequestEnvelope.AuthInfo; import okhttp3.OkHttpClient; -import retrofit2.Retrofit; -import retrofit2.converter.gson.GsonConverterFactory; /** * Created by vanshilshah on 20/07/16. @@ -48,7 +45,7 @@ public class NianticManager { private static NianticManager instance; - private List listeners; + private List listeners; private Context context; private AuthInfo mAuthInfo; @@ -88,7 +85,27 @@ public boolean verify(String s, SSLSession sslSession) { .build(); } - public void login(final String username, final String password) { + /** + * Sets the google auth token for the auth info also invokes the onLogin callback. + * @param token - a valid google auth token. + */ + public void setGoogleAuthToken(@NonNull final String token) { + mHandler.post(new Runnable() { + @Override + public void run() { + try { + mAuthInfo = new GoogleLogin(client).login(token); + Notifier.instance().dispatchOnLogin(mAuthInfo, new PokemonGo(mAuthInfo, client)); + } catch (LoginFailedException e) { + e.printStackTrace(); + } catch (RemoteServerException e) { + e.printStackTrace(); + } + } + }); + } + + public void login(@NonNull final String username, @NonNull final String password) { mHandler.post(new Runnable() { @Override public void run() { @@ -194,7 +211,7 @@ private byte[] encode(ArrayList walk) { return mainBytes; } - public interface NianticEventListener { + public interface Listener { void onLogin(AuthInfo info, PokemonGo pokemonGo); void onOperationFailure(Exception ex);