Logout funtionality;
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,7 @@
|
||||
<ImageButton android:id="@+id/nearby"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="nearbyMenuHandler"
|
||||
android:src="@drawable/nearby"
|
||||
android:paddingTop="80px"
|
||||
android:paddingBottom="10px"
|
||||
@@ -17,28 +18,33 @@
|
||||
<ImageButton android:id="@+id/friends"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="friendsMenuHandler"
|
||||
android:src="@drawable/friends"
|
||||
android:paddingBottom="10px"
|
||||
android:background="@null" />
|
||||
<ImageButton android:id="@+id/messages"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="messagesMenuHandler"
|
||||
android:src="@drawable/messages"
|
||||
android:paddingBottom="10px"
|
||||
android:background="@null" />
|
||||
<ImageButton android:id="@+id/search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="searchMenuHandler"
|
||||
android:src="@drawable/search"
|
||||
android:paddingBottom="10px"
|
||||
android:background="@null" />
|
||||
<ImageButton android:id="@+id/me"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="meMenuHandler"
|
||||
android:src="@drawable/me"
|
||||
android:paddingBottom="10px"
|
||||
android:background="@null" />
|
||||
<ImageButton android:id="@+id/logout"
|
||||
android:onClick="logoutMenuHandler"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/logout"
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class FindMeMenu extends Activity
|
||||
{
|
||||
public static final String PREFS_NAME = "LoginCredentials";
|
||||
private static final String TAG = "findMe";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
@@ -14,4 +22,54 @@ public class FindMeMenu extends Activity
|
||||
|
||||
setContentView(R.layout.findmemenu);
|
||||
}
|
||||
|
||||
// Handler
|
||||
public void nearbyMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Nearby.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
public void friendsMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Friends.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
public void messagesMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Search.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
public void meMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Search.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
public void searchMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Search.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
public void logoutMenuHandler(View button)
|
||||
{
|
||||
String logoutData[] = new String[2];
|
||||
|
||||
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
|
||||
logoutData[0] = preferences.getString("mail", "");
|
||||
logoutData[1] = preferences.getString("password", "");
|
||||
|
||||
String response = Login.logout(logoutData).trim();
|
||||
Log.v(TAG, response);
|
||||
if(response.compareTo("06") == 0)
|
||||
{
|
||||
// remove login credentials
|
||||
SharedPreferences.Editor prefsEditor = preferences.edit();
|
||||
prefsEditor.clear();
|
||||
prefsEditor.commit();
|
||||
|
||||
Intent myIntent = new Intent(button.getContext(), FindMe.class);
|
||||
startActivity(myIntent);
|
||||
Toast.makeText(button.getContext(), "Logout successful", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else Toast.makeText(this, "Logout failed. Try again!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,25 @@ public class Login extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
public static String logout(String[] str)
|
||||
{
|
||||
JSONObject j = new JSONObject();
|
||||
|
||||
try
|
||||
{
|
||||
j.put("mail", str[0]);
|
||||
j.put("password", AccountHelper.createHashMd5(str[1]));
|
||||
j.put("logout", "01");
|
||||
|
||||
return AccountHelper.doHttpPost("login_user.php", j);
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loginUserHandler(View button)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user