requests; maps; bugfixes; ...
This commit is contained in:
+22
-2
@@ -2,11 +2,14 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.architects.findme"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
android:versionName="0.1.8">
|
||||
|
||||
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name=".FindMe"
|
||||
|
||||
<uses-library android:name="com.google.android.maps" />
|
||||
|
||||
<activity android:name=".Main"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:screenOrientation="portrait">
|
||||
@@ -14,6 +17,11 @@
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".FindMe"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity android:name=".Registration"
|
||||
android:label="Registration"
|
||||
@@ -60,6 +68,18 @@
|
||||
android:label="Conversation"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity android:name=".MapNearby"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:label="Nearby"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.NoTitleBar">
|
||||
</activity>
|
||||
<activity android:name=".Profile"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
android:label="Profile"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.NoTitleBar">
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -8,4 +8,4 @@
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-8
|
||||
target=Google Inc.:Google APIs:8
|
||||
|
||||
@@ -37,30 +37,34 @@ public final class R {
|
||||
public static final int icon=0x7f02000c;
|
||||
public static final int logo=0x7f02000d;
|
||||
public static final int logout=0x7f02000e;
|
||||
public static final int me=0x7f02000f;
|
||||
public static final int messages=0x7f020010;
|
||||
public static final int nearby=0x7f020011;
|
||||
public static final int search=0x7f020012;
|
||||
public static final int tab_bg_selected=0x7f020013;
|
||||
public static final int tab_bg_selector=0x7f020014;
|
||||
public static final int tab_bg_unselected=0x7f020015;
|
||||
public static final int tab_divider=0x7f020016;
|
||||
public static final int tab_text_selector=0x7f020017;
|
||||
public static final int top_bg=0x7f020018;
|
||||
public static final int user=0x7f020019;
|
||||
public static final int marker=0x7f02000f;
|
||||
public static final int markerme=0x7f020010;
|
||||
public static final int me=0x7f020011;
|
||||
public static final int messages=0x7f020012;
|
||||
public static final int nearby=0x7f020013;
|
||||
public static final int search=0x7f020014;
|
||||
public static final int tab_bg_selected=0x7f020015;
|
||||
public static final int tab_bg_selector=0x7f020016;
|
||||
public static final int tab_bg_unselected=0x7f020017;
|
||||
public static final int tab_divider=0x7f020018;
|
||||
public static final int tab_text_selector=0x7f020019;
|
||||
public static final int top_bg=0x7f02001a;
|
||||
public static final int user=0x7f02001b;
|
||||
public static final int user_big=0x7f02001c;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int ButtonLoginUser=0x7f080015;
|
||||
public static final int ButtonRegisterUser=0x7f080028;
|
||||
public static final int ButtonRegisterUser=0x7f08002c;
|
||||
public static final int ButtonUserRegistration=0x7f080017;
|
||||
public static final int EditTextLoginMail=0x7f080011;
|
||||
public static final int EditTextLoginPassword=0x7f080012;
|
||||
public static final int EditTextRegistrationMail=0x7f080026;
|
||||
public static final int EditTextRegistrationName=0x7f080025;
|
||||
public static final int EditTextRegistrationPassword=0x7f080027;
|
||||
public static final int SearchInput=0x7f08002b;
|
||||
public static final int EditTextRegistrationMail=0x7f08002a;
|
||||
public static final int EditTextRegistrationName=0x7f080029;
|
||||
public static final int EditTextRegistrationPassword=0x7f08002b;
|
||||
public static final int SearchInput=0x7f080030;
|
||||
public static final int SpinnerLoginUserStatus=0x7f080014;
|
||||
public static final int TextViewTitle=0x7f080013;
|
||||
public static final int add=0x7f080036;
|
||||
public static final int circlecc=0x7f080000;
|
||||
public static final int circlecc_image=0x7f080001;
|
||||
public static final int conversation=0x7f080002;
|
||||
@@ -68,11 +72,11 @@ public final class R {
|
||||
public static final int findmemenuItems=0x7f080006;
|
||||
public static final int friends=0x7f080008;
|
||||
public static final int friendslist=0x7f08000f;
|
||||
public static final int homebutton=0x7f080030;
|
||||
public static final int icon=0x7f080031;
|
||||
public static final int icontext=0x7f080033;
|
||||
public static final int homebutton=0x7f080035;
|
||||
public static final int logout=0x7f08000c;
|
||||
public static final int mapView=0x7f080025;
|
||||
public static final int me=0x7f08000b;
|
||||
public static final int message=0x7f080037;
|
||||
public static final int messageOverview=0x7f08001a;
|
||||
public static final int messageOverviewList=0x7f080003;
|
||||
public static final int message_item=0x7f080020;
|
||||
@@ -86,18 +90,21 @@ public final class R {
|
||||
public static final int nearby=0x7f080007;
|
||||
public static final int nearby_list_text=0x7f080024;
|
||||
public static final int nearbylist=0x7f080023;
|
||||
public static final int profile=0x7f080026;
|
||||
public static final int profilemail=0x7f080028;
|
||||
public static final int profilename=0x7f080027;
|
||||
public static final int request_dialog=0x7f08002d;
|
||||
public static final int requests=0x7f080010;
|
||||
public static final int search=0x7f08000a;
|
||||
public static final int searchList=0x7f080029;
|
||||
public static final int search_dialog=0x7f08002a;
|
||||
public static final int searchList=0x7f08002e;
|
||||
public static final int search_dialog=0x7f08002f;
|
||||
public static final int tabhost=0x7f08000e;
|
||||
public static final int tabsLayout=0x7f08002c;
|
||||
public static final int tabsText=0x7f08002d;
|
||||
public static final int tabsLayout=0x7f080031;
|
||||
public static final int tabsText=0x7f080032;
|
||||
public static final int test_image=0x7f080016;
|
||||
public static final int text=0x7f080032;
|
||||
public static final int title=0x7f08002e;
|
||||
public static final int title=0x7f080033;
|
||||
public static final int title2138=0x7f08001c;
|
||||
public static final int titleText=0x7f08002f;
|
||||
public static final int titleText=0x7f080034;
|
||||
public static final int topbb=0x7f080022;
|
||||
public static final int topbb2=0x7f08000d;
|
||||
public static final int topbb9864=0x7f08001b;
|
||||
@@ -117,15 +124,19 @@ public final class R {
|
||||
public static final int messsage_item=0x7f03000a;
|
||||
public static final int nearby=0x7f03000b;
|
||||
public static final int nearby_list_item=0x7f03000c;
|
||||
public static final int registration=0x7f03000d;
|
||||
public static final int search=0x7f03000e;
|
||||
public static final int search_dialog=0x7f03000f;
|
||||
public static final int tabs_bg=0x7f030010;
|
||||
public static final int title=0x7f030011;
|
||||
public static final int topbar=0x7f030012;
|
||||
public static final int nearby_map=0x7f03000d;
|
||||
public static final int profile=0x7f03000e;
|
||||
public static final int registration=0x7f03000f;
|
||||
public static final int request_dialog=0x7f030010;
|
||||
public static final int search=0x7f030011;
|
||||
public static final int search_dialog=0x7f030012;
|
||||
public static final int tabs_bg=0x7f030013;
|
||||
public static final int title=0x7f030014;
|
||||
public static final int topbar=0x7f030015;
|
||||
}
|
||||
public static final class menu {
|
||||
public static final int menu=0x7f070000;
|
||||
public static final int map=0x7f070000;
|
||||
public static final int menu=0x7f070001;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f060000;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
@@ -16,6 +16,7 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:fadingEdge="none"
|
||||
android:divider="@color/lightdiv"
|
||||
android:dividerHeight="1dip">
|
||||
</ListView>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<include layout="@layout/topbar" />
|
||||
<include layout="@layout/title" />
|
||||
|
||||
<com.google.android.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:enabled="true"
|
||||
android:clickable="true"
|
||||
android:apiKey="0L4woGZ-uJszP_he3MWGuIxMJUpYIZ26yhqO1PQ"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@color/white"
|
||||
android:id="@+id/profile">
|
||||
|
||||
<include layout="@layout/topbar" />
|
||||
<include layout="@layout/title" />
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:fadingEdge="none"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/white"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="20dip">
|
||||
<ImageView
|
||||
android:src="@drawable/user_big"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:paddingTop="6dip"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/profilename"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:textSize="22sp"
|
||||
android:textColor="#39525f"
|
||||
android:layout_marginTop="15dip"
|
||||
android:layout_marginBottom="2dip">
|
||||
</TextView>
|
||||
<TextView
|
||||
android:id="@+id/profilemail"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Text"
|
||||
android:textSize="22sp"
|
||||
android:textColor="#39525f"
|
||||
android:layout_marginTop="15dip"
|
||||
android:layout_marginBottom="2dip">
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/request_dialog"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:padding="10dp">
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/me"
|
||||
android:title="MY LOCATION"
|
||||
android:icon="@drawable/ic_tab_artists_grey" />
|
||||
</menu>
|
||||
+6
-7
@@ -1,10 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/icon"
|
||||
android:icon="@drawable/icon" />
|
||||
<item android:id="@+id/text"
|
||||
android:title="Text" />
|
||||
<item android:id="@+id/icontext"
|
||||
android:title="Icon and text"
|
||||
android:icon="@drawable/icon" />
|
||||
<item android:id="@+id/add"
|
||||
android:title="ADD"
|
||||
android:icon="@drawable/ic_tab_artists_grey" />
|
||||
<item android:id="@+id/message"
|
||||
android:title="MESSAGE"
|
||||
android:icon="@drawable/ic_tab_artists_grey" />
|
||||
</menu>
|
||||
|
||||
@@ -119,8 +119,9 @@ public class Conversation extends Activity {
|
||||
else
|
||||
{
|
||||
Spanned mys = Html.fromHtml("<font color='#9fa6b3'><small>Ich:</small></font><br />" + text);
|
||||
list.add(mys);
|
||||
list.add(0, mys);
|
||||
adapter.notifyDataSetChanged();
|
||||
Toast.makeText(getApplicationContext(), "Successfully sent!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,47 +30,7 @@ public class FindMe extends Activity
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
FindMe.this.setContentView(R.layout.main);
|
||||
|
||||
String loginData[] = new String[3];
|
||||
|
||||
// save login credentials to storage
|
||||
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
|
||||
loginData[0] = preferences.getString("mail", "");
|
||||
loginData[1] = preferences.getString("password", "");
|
||||
loginData[2] = preferences.getString("status", "");
|
||||
|
||||
if (loginData[0].compareTo("") != 0)
|
||||
{
|
||||
String response = Login.login(loginData).trim();
|
||||
// check if login was successful
|
||||
Log.v(TAG, response);
|
||||
if(response.compareTo("01") == 0)
|
||||
{
|
||||
Intent myIntent = new Intent(this, FindMeMenu.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.icon: Toast.makeText(this, "You pressed the icon!", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case R.id.text: Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case R.id.icontext: Toast.makeText(this, "You pressed the icon and text!", Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
setContentView(R.layout.main);
|
||||
}
|
||||
|
||||
// VIEWS
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import com.architects.resources.*;
|
||||
import com.architects.helper.*;
|
||||
|
||||
import android.R.drawable;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class FindMeMenu extends Activity
|
||||
@@ -54,8 +47,15 @@ public class FindMeMenu extends Activity
|
||||
}
|
||||
public void meMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Search.class);
|
||||
startActivity(myIntent);
|
||||
String[] loginCredentials = AccountHelper.getLoginPreferences(this);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("mail", loginCredentials[0]);
|
||||
bundle.putString("name", "Tobias Klika");
|
||||
|
||||
Intent newIntent = new Intent(getApplicationContext(), Profile.class);
|
||||
newIntent.putExtras(bundle);
|
||||
startActivity(newIntent);
|
||||
}
|
||||
public void searchMenuHandler(View button)
|
||||
{
|
||||
@@ -103,15 +103,13 @@ public class FindMeMenu extends Activity
|
||||
Log.v(TAG, response);
|
||||
if(response.compareTo("06") == 0)
|
||||
{
|
||||
// remove login credentials
|
||||
SharedPreferences.Editor prefsEditor = preferences.edit();
|
||||
prefsEditor.clear();
|
||||
prefsEditor.commit();
|
||||
|
||||
Toast.makeText(button.getContext(), "Logout successful", Toast.LENGTH_LONG).show();
|
||||
Intent myIntent = new Intent(button.getContext(), FindMe.class);
|
||||
startActivity(myIntent);
|
||||
|
||||
if(AccountHelper.clearLoginPreferences(this))
|
||||
{
|
||||
Toast.makeText(button.getContext(), "Logout successful", Toast.LENGTH_LONG).show();
|
||||
Intent myIntent = new Intent(button.getContext(), Main.class);
|
||||
startActivity(myIntent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
else Toast.makeText(this, "Logout failed. Try again!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
@@ -4,19 +4,25 @@ import com.architects.findme.R;
|
||||
import com.architects.helper.*;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TextView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.TabHost.TabContentFactory;
|
||||
import android.widget.TabHost.TabSpec;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Friends extends Activity {
|
||||
private TabHost mTabHost;
|
||||
@@ -24,6 +30,8 @@ public class Friends extends Activity {
|
||||
private ListView friends;
|
||||
private ListView requests;
|
||||
public static final String PREFS_NAME = "LoginCredentials";
|
||||
|
||||
public String mymail;
|
||||
//private static final String TAG = "findme";
|
||||
|
||||
private void setupTabHost() {
|
||||
@@ -31,7 +39,6 @@ public class Friends extends Activity {
|
||||
mTabHost.setup();
|
||||
}
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -47,6 +54,7 @@ public class Friends extends Activity {
|
||||
// get mail
|
||||
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
|
||||
String mail = preferences.getString("mail", "");
|
||||
mymail = mail;
|
||||
|
||||
String[] friendslist = FriendsHelper.getFriendsList(mail);
|
||||
String[] requestslist = FriendsHelper.getRequestsList(mail);
|
||||
@@ -58,6 +66,40 @@ public class Friends extends Activity {
|
||||
|
||||
setupTab(friends, "Friends");
|
||||
setupTab(requests, "Requests");
|
||||
|
||||
|
||||
requests.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
TextView me = (TextView) view.findViewById(R.id.nearby_list_text);
|
||||
final String mail = (String) me.getText();
|
||||
|
||||
final AlertDialog.Builder alertbox = new AlertDialog.Builder(Friends.this);
|
||||
LayoutInflater factory = LayoutInflater.from(Friends.this);
|
||||
final View input = factory.inflate(R.layout.request_dialog, null);
|
||||
|
||||
alertbox.setTitle("Friend Request");
|
||||
alertbox.setView(input);
|
||||
|
||||
alertbox.setPositiveButton("Accept", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
FriendsHelper.request("add", mail, mymail);
|
||||
FriendsHelper.request("decline", mail, mymail);
|
||||
|
||||
Toast.makeText(Friends.this, "Friend successfully added!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
alertbox.setNegativeButton("Decline",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
FriendsHelper.request("decline", mail, mymail);
|
||||
|
||||
Toast.makeText(Friends.this, "Friend request declined!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
alertbox.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupTab(final View view, final String tag) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.architects.findme.R;
|
||||
import com.architects.helper.AccountHelper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import com.architects.helper.*;
|
||||
import com.architects.findme.R;
|
||||
import com.architects.helper.StateHelper;
|
||||
import com.architects.findme.Login;
|
||||
import com.architects.findme.FindMeMenu;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Main extends Activity
|
||||
{
|
||||
public static final String PREFS_NAME = "LoginCredentials";
|
||||
public StateHelper phoneState = new StateHelper();
|
||||
private static final String TAG = "test";
|
||||
private boolean showEntry = false;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
boolean isLogged = AccountHelper.isLogged(this);
|
||||
|
||||
if(isLogged)
|
||||
{
|
||||
String[] loginCredentials = AccountHelper.getLoginPreferences(this);
|
||||
/*
|
||||
String response = Login.login(loginCredentials).trim();
|
||||
// check if login was successful
|
||||
Log.v(TAG, response);
|
||||
if(response.compareTo("01") == 0)
|
||||
{
|
||||
Intent myIntent = new Intent(this, FindMeMenu.class);
|
||||
startActivity(myIntent);
|
||||
}*/
|
||||
Intent myIntent = new Intent(this, FindMeMenu.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Intent myIntent = new Intent(this, FindMe.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
// VIEWS
|
||||
public void drawRegistrationHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Registration.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
|
||||
public void drawLoginHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), Login.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.google.android.maps.GeoPoint;
|
||||
import com.google.android.maps.MapActivity;
|
||||
import com.google.android.maps.MapController;
|
||||
import com.google.android.maps.MapView;
|
||||
import com.google.android.maps.Overlay;
|
||||
import com.google.android.maps.OverlayItem;
|
||||
|
||||
import com.architects.helper.*;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MapNearby extends MapActivity
|
||||
{
|
||||
public int standardZoom = 12;
|
||||
private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 0; // in Meters
|
||||
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds
|
||||
private static final String TAG = "test";
|
||||
|
||||
private MapController mapController;
|
||||
private List<Overlay> mapOverlays;
|
||||
private MapView mapView;
|
||||
private GeoPoint geoPoint;
|
||||
private PeopleItemizedOverlay itemizedoverlay;
|
||||
protected LocationManager locationManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.nearby_map);
|
||||
|
||||
|
||||
// set title bar
|
||||
TextView title = (TextView) findViewById(R.id.titleText);
|
||||
title.setText(Html.fromHtml("Map"));
|
||||
|
||||
// initialize map view
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.setBuiltInZoomControls(true);
|
||||
mapView.setStreetView(true);
|
||||
|
||||
// get map mod vars
|
||||
mapOverlays = mapView.getOverlays();
|
||||
mapController = mapView.getController();
|
||||
|
||||
|
||||
|
||||
// go to my location
|
||||
String coordinates[] = new String[2];
|
||||
coordinates[0] = String.valueOf("30");
|
||||
coordinates[1] = String.valueOf("-122");
|
||||
geoPoint = LocationHelper.toGeoPoint(coordinates);
|
||||
mapController.animateTo(geoPoint);
|
||||
mapController.setZoom(standardZoom);
|
||||
mapView.invalidate();
|
||||
|
||||
// show my marker
|
||||
Drawable marker = MapNearby.this.getResources().getDrawable(R.drawable.marker);
|
||||
addMe(mapOverlays);
|
||||
|
||||
|
||||
// show people marker
|
||||
itemizedoverlay = new PeopleItemizedOverlay(marker, MapNearby.this);
|
||||
|
||||
JSONObject json = AccountHelper.doHttpGet("get_online_user.php");
|
||||
//String[] onlineUser = new String[json.length()];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String cood[] = new String[2];
|
||||
|
||||
try {
|
||||
JSONObject json_data = null;
|
||||
String x;
|
||||
|
||||
for(int i=0;i<json.length();i++)
|
||||
{
|
||||
x = (new Integer(i)).toString();
|
||||
json_data = json.getJSONObject(x);
|
||||
|
||||
cood[0] = String.valueOf(json_data.getDouble("longitude"));
|
||||
cood[1] = String.valueOf(json_data.getDouble("latitude"));
|
||||
addPerson(mapOverlays, cood);
|
||||
|
||||
|
||||
//mails[i] = json_data.getString("mail");
|
||||
//names[i] = json_data.getString("name");
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mapOverlays.add(itemizedoverlay);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isRouteDisplayed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void addMe(List<Overlay> mapOverlays) {
|
||||
Drawable markerme = this.getResources().getDrawable(R.drawable.markerme);
|
||||
|
||||
// add my position
|
||||
PeopleItemizedOverlay meitemizedoverlay = new PeopleItemizedOverlay(markerme, this);
|
||||
OverlayItem meoverlayitem = new OverlayItem(geoPoint, "Me", "This is me!");
|
||||
meitemizedoverlay.addOverlay(meoverlayitem);
|
||||
mapOverlays.add(meitemizedoverlay);
|
||||
}
|
||||
|
||||
|
||||
private void addPerson(List<Overlay> mapOverlays, String[] coord) {
|
||||
GeoPoint point = LocationHelper.toGeoPoint(coord);
|
||||
|
||||
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
|
||||
|
||||
itemizedoverlay.addOverlay(overlayitem);
|
||||
}
|
||||
|
||||
public void enterMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), FindMeMenu.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void updateLocationHandler(View button)
|
||||
{
|
||||
updateLocation();
|
||||
}
|
||||
public void updateLocation()
|
||||
{
|
||||
showCurrentLocation();
|
||||
}
|
||||
|
||||
protected String[] showCurrentLocation() {
|
||||
|
||||
String[] loc = new String[2];
|
||||
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
|
||||
if (location != null) {
|
||||
String message = String.format(
|
||||
"Current Location \n Longitude: %1$s \n Latitude: %2$s",
|
||||
location.getLongitude(), location.getLatitude()
|
||||
);
|
||||
loc[0] = String.valueOf(location.getLatitude());
|
||||
loc[1] = String.valueOf(location.getLongitude());
|
||||
// Toast.makeText(Nearby.this, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private class MyLocationListener implements LocationListener {
|
||||
|
||||
public void onLocationChanged(Location location) {
|
||||
String message = String.format(
|
||||
"New Location \n Longitude: %1$s \n Latitude: %2$s",
|
||||
location.getLongitude(), location.getLatitude()
|
||||
);
|
||||
Log.v(TAG, message);
|
||||
|
||||
|
||||
|
||||
|
||||
//Toast.makeText(Nearby.this, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void onStatusChanged(String s, int i, Bundle b) {
|
||||
//Toast.makeText(Nearby.this, "Provider status changed", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void onProviderDisabled(String s) {
|
||||
Toast.makeText(MapNearby.this,
|
||||
"Provider disabled by the user. GPS turned off",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void onProviderEnabled(String s) {
|
||||
Toast.makeText(MapNearby.this,
|
||||
"Provider enabled by the user. GPS turned on",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -95,29 +95,6 @@ public class Messages extends Activity {
|
||||
startActivityForResult(newIntent, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
resultsList.setAdapter(new ArrayAdapter<String>(this, R.layout.nearby_list_item, R.id.nearby_list_text, results));
|
||||
|
||||
resultsList.setTextFilterEnabled(true);
|
||||
|
||||
resultsList.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// When clicked, show a toast with the TextView text
|
||||
Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
public void enterMenuHandler(View button)
|
||||
|
||||
@@ -48,14 +48,18 @@ public class Nearby extends Activity {
|
||||
|
||||
JSONObject json = AccountHelper.doHttpGet("get_online_user.php");
|
||||
String[] onlineUser = new String[json.length()];
|
||||
|
||||
final String[] mails = new String[json.length()];
|
||||
final String[] names = new String[json.length()];
|
||||
|
||||
try {
|
||||
Log.v(TAG, "Länge:"+json.length());
|
||||
JSONObject json_data = null;
|
||||
String x;
|
||||
|
||||
Location location = new Location("");
|
||||
location.setLatitude(30);
|
||||
location.setLongitude(-122);
|
||||
location.setLatitude(13.0443);
|
||||
location.setLongitude(48.2557);
|
||||
|
||||
for(int i=0;i<json.length();i++)
|
||||
{
|
||||
@@ -77,13 +81,13 @@ public class Nearby extends Activity {
|
||||
me = dis + " km";
|
||||
}
|
||||
else me = distance + " m";
|
||||
Log.v(TAG, me);
|
||||
|
||||
mails[i] = json_data.getString("mail");
|
||||
names[i] = json_data.getString("name");
|
||||
|
||||
onlineUser[i] = json_data.getString("name") + "\n" + me;
|
||||
Log.v(TAG, json_data.getString("name"));
|
||||
}
|
||||
|
||||
Log.v(TAG, "DATA-Länge:"+json_data.length());
|
||||
|
||||
} catch (JSONException e) {
|
||||
// TODO Auto-generated catch block
|
||||
@@ -96,8 +100,13 @@ public class Nearby extends Activity {
|
||||
|
||||
nearby.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// When clicked, show a toast with the TextView text
|
||||
Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("mail", mails[position]);
|
||||
bundle.putString("name", names[position]);
|
||||
|
||||
Intent newIntent = new Intent(getApplicationContext(), Profile.class);
|
||||
newIntent.putExtras(bundle);
|
||||
startActivity(newIntent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.google.android.maps.ItemizedOverlay;
|
||||
import com.google.android.maps.OverlayItem;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class PeopleItemizedOverlay extends ItemizedOverlay
|
||||
{
|
||||
private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
|
||||
private Context mContext;
|
||||
private static final String TAG = "findMe";
|
||||
|
||||
public PeopleItemizedOverlay(Drawable defaultMarker, Context context) {
|
||||
super(boundCenterBottom(defaultMarker));
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OverlayItem createItem(int i) {
|
||||
return mOverlays.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mOverlays.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean onTap(int index) {
|
||||
OverlayItem item = mOverlays.get(index);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("mail", "klika@live.at");
|
||||
bundle.putString("name", "Tobias Klika");
|
||||
|
||||
Intent newIntent = new Intent(mContext.getApplicationContext(), Profile.class);
|
||||
newIntent.putExtras(bundle);
|
||||
mContext.startActivity(newIntent);
|
||||
|
||||
return true;
|
||||
|
||||
/*
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
|
||||
dialog.setTitle(item.getTitle());
|
||||
|
||||
LayoutInflater factory = LayoutInflater.from(mContext);
|
||||
final View input = factory.inflate(R.layout.map_dialog, null);
|
||||
dialog.setView(input);
|
||||
|
||||
|
||||
dialog.setPositiveButton("Profile", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
// get the input value
|
||||
EditText mText;
|
||||
mText = (EditText) input.findViewById(R.id.MapInput);
|
||||
String text = mText.getText().toString();
|
||||
|
||||
// redirect to search results
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("mail", text);
|
||||
|
||||
Log.v(TAG, "HI");
|
||||
Intent newIntent = new Intent(mContext.getApplicationContext(), Login.class);
|
||||
newIntent.putExtras(bundle);
|
||||
mContext.startActivity(newIntent);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setNegativeButton("Hide", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dialog.show();
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public void addOverlay(OverlayItem overlay) {
|
||||
mOverlays.add(overlay);
|
||||
populate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,109 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import android.app.Activity;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Profile extends Activity {
|
||||
import com.architects.helper.*;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Profile extends Activity
|
||||
{
|
||||
private static final String TAG = "findme";
|
||||
private String userName;
|
||||
private String userMail;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
setContentView(R.layout.profile);
|
||||
|
||||
|
||||
// get conversation partner
|
||||
Bundle bundle = this.getIntent().getExtras();
|
||||
userMail = bundle.getString("mail");
|
||||
userName = bundle.getString("name");
|
||||
|
||||
Log.v(TAG, userMail+" ---"+userName);
|
||||
|
||||
// JSONObject j = FriendsHelper.getUserInfo(mail);
|
||||
|
||||
|
||||
// set title bar
|
||||
TextView title = (TextView) findViewById(R.id.titleText);
|
||||
title.setText("Profile");
|
||||
|
||||
// set name and mail
|
||||
TextView name = (TextView) findViewById(R.id.profilename);
|
||||
TextView mail = (TextView) findViewById(R.id.profilemail);
|
||||
|
||||
name.setText(Html.fromHtml("<font color='#9fa6b3' size='12'><small>Name:</small></font><br />"
|
||||
+ userName));
|
||||
mail.setText(Html.fromHtml("<font color='#9fa6b3' size='12'><small>Mail:</small></font><br />"
|
||||
+ userMail));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
String title = item.getTitle().toString();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.add:
|
||||
addHandler(title);
|
||||
break;
|
||||
case R.id.message:
|
||||
messageHandler(title);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void addHandler(String title)
|
||||
{
|
||||
String[] logPref = AccountHelper.getLoginPreferences(this);
|
||||
String response = FriendsHelper.request("request", logPref[0], userMail).trim();
|
||||
|
||||
if(response.compareTo("01") == 0)
|
||||
response = "Request sent!";
|
||||
Toast.makeText(this, response, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public void messageHandler(String title)
|
||||
{
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("mail", userMail);
|
||||
bundle.putString("name", userName);
|
||||
|
||||
Intent newIntent = new Intent(getApplicationContext(), Conversation.class);
|
||||
newIntent.putExtras(bundle);
|
||||
startActivityForResult(newIntent, 0);
|
||||
}
|
||||
|
||||
|
||||
public void enterMenuHandler(View button)
|
||||
{
|
||||
Intent myIntent = new Intent(button.getContext(), FindMeMenu.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,10 @@ import com.architects.findme.R.layout;
|
||||
import com.architects.helper.AccountHelper;
|
||||
|
||||
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.EditText;
|
||||
@@ -17,6 +20,8 @@ import android.widget.Toast;
|
||||
|
||||
public class Registration extends Activity
|
||||
{
|
||||
public static final String PREFS_NAME = "LoginCredentials";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
@@ -59,8 +64,39 @@ public class Registration extends Activity
|
||||
final EditText passwordField = (EditText) findViewById(R.id.EditTextRegistrationPassword);
|
||||
registrationData[2] = passwordField.getText().toString();
|
||||
|
||||
String response = register(registrationData);
|
||||
Toast.makeText(this, response, Toast.LENGTH_LONG).show();
|
||||
String loginData[] = new String[3];
|
||||
|
||||
loginData[0] = registrationData[1];
|
||||
loginData[1] = registrationData[2];
|
||||
loginData[2] = "online";
|
||||
|
||||
String response = register(registrationData).trim();
|
||||
|
||||
if(response.compareTo("01") == 0)
|
||||
{
|
||||
response = Login.login(loginData).trim();
|
||||
|
||||
|
||||
// check if login was successful
|
||||
if(response.compareTo("01") == 0)
|
||||
{
|
||||
// save login credentials to storage
|
||||
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
|
||||
SharedPreferences.Editor prefsEditor = preferences.edit();
|
||||
prefsEditor.putString("mail", loginData[0]);
|
||||
prefsEditor.putString("password", loginData[1]);
|
||||
prefsEditor.putString("status", loginData[2]);
|
||||
prefsEditor.commit();
|
||||
|
||||
Intent myIntent = new Intent(button.getContext(), FindMeMenu.class);
|
||||
startActivity(myIntent);
|
||||
finish();
|
||||
}
|
||||
else
|
||||
Toast.makeText(this, response, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
Toast.makeText(this, response, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.architects.findme;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.architects.helper.*;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -10,6 +12,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -45,7 +48,33 @@ public class Search extends Activity {
|
||||
resultsList = (ListView) findViewById(R.id.searchList);
|
||||
|
||||
// search results to string
|
||||
String[] results = SearchHelper.getResults(query);
|
||||
JSONObject j = new JSONObject();
|
||||
String params = "?query="+query;
|
||||
j = AccountHelper.doHttpGet("search.php", params);
|
||||
Log.v(TAG, j.toString());
|
||||
|
||||
final String[] mails = new String[j.length()];
|
||||
final String[] names = new String[j.length()];
|
||||
|
||||
String[] results = new String[j.length()];
|
||||
|
||||
try {
|
||||
JSONObject json_data = null;
|
||||
String x;
|
||||
|
||||
for(int i=0;i<j.length();i++)
|
||||
{
|
||||
x = (new Integer(i)).toString();
|
||||
json_data = j.getJSONObject(x);
|
||||
|
||||
mails[i] = json_data.getString("mail");
|
||||
names[i] = json_data.getString("name");
|
||||
|
||||
results[i] = json_data.getString("name") + "\n" + json_data.getString("mail");
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception e) { }
|
||||
|
||||
resultsList.setAdapter(new ArrayAdapter<String>(this, R.layout.nearby_list_item, R.id.nearby_list_text, results));
|
||||
|
||||
@@ -53,8 +82,13 @@ public class Search extends Activity {
|
||||
|
||||
resultsList.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// When clicked, show a toast with the TextView text
|
||||
Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("mail", mails[position]);
|
||||
bundle.putString("name", names[position]);
|
||||
|
||||
Intent newIntent = new Intent(getApplicationContext(), Profile.class);
|
||||
newIntent.putExtras(bundle);
|
||||
startActivity(newIntent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,11 +18,14 @@ import org.apache.http.params.HttpConnectionParams;
|
||||
import org.apache.http.protocol.HTTP;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
public class AccountHelper
|
||||
{
|
||||
private static final String TAG = "findme";
|
||||
public static final String PREFS_NAME = "LoginCredentials";
|
||||
|
||||
public static String doHttpPost(String url_end, JSONObject j)
|
||||
{
|
||||
@@ -92,6 +95,41 @@ public class AccountHelper
|
||||
}
|
||||
|
||||
|
||||
public static Boolean isLogged(Context c)
|
||||
{
|
||||
SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);
|
||||
String mail = preferences.getString("mail", "");
|
||||
|
||||
if (mail.compareTo("") != 0) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public static String[] getLoginPreferences(Context c)
|
||||
{
|
||||
String[] loginPreferences = new String[3];
|
||||
|
||||
SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);
|
||||
|
||||
loginPreferences[0] = preferences.getString("mail", "");
|
||||
loginPreferences[1] = preferences.getString("password", "");
|
||||
loginPreferences[2] = preferences.getString("status", "");
|
||||
|
||||
return loginPreferences;
|
||||
}
|
||||
|
||||
public static Boolean clearLoginPreferences(Context c)
|
||||
{
|
||||
SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);
|
||||
SharedPreferences.Editor prefsEditor = preferences.edit();
|
||||
|
||||
prefsEditor.clear();
|
||||
prefsEditor.commit();
|
||||
|
||||
return (isLogged(c)) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String createHashMd5(String str)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -56,10 +56,34 @@ public class FriendsHelper
|
||||
x = (new Integer(i)).toString();
|
||||
json_data = j.getJSONObject(x);
|
||||
|
||||
friends[i] = json_data.getString("name") + "\n" + json_data.getString("id");
|
||||
friends[i] = json_data.getString("mail");
|
||||
}
|
||||
return friends;
|
||||
}
|
||||
catch(Exception e) { return new String[0];}
|
||||
}
|
||||
|
||||
public static String request(String type, String sender, String receiver)
|
||||
{
|
||||
JSONObject j = new JSONObject();
|
||||
try
|
||||
{
|
||||
j.put("sender", sender);
|
||||
j.put("receiver", receiver);
|
||||
j.put("type", type);
|
||||
|
||||
return AccountHelper.doHttpPost("friend.php", j);
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject getUserInfo(String user)
|
||||
{
|
||||
String params = "?user="+user;
|
||||
return AccountHelper.doHttpGet("get_user_info.php", params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.architects.helper;
|
||||
|
||||
import com.architects.findme.R;
|
||||
import com.google.android.maps.GeoPoint;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -54,7 +56,7 @@ public class LocationHelper
|
||||
);
|
||||
//Toast.makeText(myContext, message, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MyLocationListener implements LocationListener {
|
||||
|
||||
@@ -83,4 +85,14 @@ public class LocationHelper
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static GeoPoint toGeoPoint(String[] coord)
|
||||
{
|
||||
double lat = Double.parseDouble(coord[0]);
|
||||
double lng = Double.parseDouble(coord[1]);
|
||||
|
||||
return new GeoPoint(
|
||||
(int) (lat * 1E6),
|
||||
(int) (lng * 1E6));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user