Skip to content

Commit

Permalink
se recibe la contrasena correctamente
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesaurio committed Apr 28, 2015
1 parent 08611f3 commit 438dba3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ private void likePage() {
if (session != null) {
Request likeRequest = new Request(session,
"/me/likes/775396332498712",
//"/me",
null,
HttpMethod.GET,
new Request.Callback() {
Expand All @@ -165,7 +164,7 @@ public void onCompleted(Response response) {
if(albumArr.length()>0){
Utils.Toast(FacebookLoginActivity.this, getString(R.string.Pagina_liked), Toast.LENGTH_SHORT);

new GCM(FacebookLoginActivity.this).peticionContrasena();
new GCM(FacebookLoginActivity.this).peticionContrasena();

finish();
}
Expand Down
21 changes: 15 additions & 6 deletions app/src/main/java/com/citydevs/hazmeelparo/gcm/GCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -72,14 +75,11 @@ public void registerInBackground(final GoogleCloudMessaging gcm) {

@Override
protected void onPreExecute() {
Log.d("*******************", gcm+"");
pd = Utils.anillo(activity, pd);
pd.show();
if (gcm == null) {
Log.d("*******************", "gcm _nill");
gcm_ = GoogleCloudMessaging.getInstance(activity);
}else{
Log.d("*******************", "gcm _ NO nill");
gcm_ = gcm;
}
super.onPreExecute();
Expand Down Expand Up @@ -138,10 +138,19 @@ public static int getAppVersion(Context context) {
throw new RuntimeException("Could not get package name: " + e);
}
}



/**
*Regresa la contraseña en forma de notificación
*/
public void peticionContrasena(){
//Localiza al usuario y manda esta cosa :)
String return_password = new Utils(activity).getPasswordBus("https://cryptic-peak-2139.herokuapp.com/bus/password?email="+UserInfo.getEmail(activity));
try {
JSONObject jsonObject = new JSONObject(return_password);
String password = jsonObject.getString("password");
new Utils(activity).pushNotification("HazmeELParo","contraseña: "+password);
} catch (JSONException e) {
e.printStackTrace();
}
}


Expand Down
47 changes: 47 additions & 0 deletions app/src/main/java/com/citydevs/hazmeelparo/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@

import android.app.Activity;
import android.app.AlertDialog;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.StrictMode;
import android.support.v4.app.NotificationCompat;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.citydevs.hazmeelparo.HazmeElParoActivity;
import com.citydevs.hazmeelparo.R;
import com.citydevs.hazmeelparo.gcm.UserInfo;

Expand Down Expand Up @@ -287,4 +291,47 @@ public static boolean doHttpPostAltaUsuario(Activity act,String url){

}


/**
* metodo que hace la conexion al servidor con una url especifica
*
* @param url
* (String) ruta del web service
* @return (String) resultado del service
*/
public static String getPasswordBus(String url) {
HttpClient Client = new DefaultHttpClient();
try {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
HttpGet httpget = new HttpGet(url);
HttpResponse hhrpResponse = Client.execute(httpget);
HttpEntity httpentiti = hhrpResponse.getEntity();
//Log.d("RETURN HTTPCLIENT", EntityUtils.toString(httpentiti));
return EntityUtils.toString(httpentiti);
} catch (ParseException e) {

e.getStackTrace();

return null;
} catch (IOException e) {
e.getStackTrace();
return null;
}
}


public void pushNotification(String titulo, String contenido) {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(activity)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(titulo)
.setContentText(contenido);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(activity);
stackBuilder.addParentStack(HazmeElParoActivity.class);
NotificationManager mNotificationManager =
(NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());
}
}

0 comments on commit 438dba3

Please sign in to comment.