dynamic content; loading status app-wide; reload button; bugfixes;

This commit is contained in:
Tobias Klika
2011-07-10 06:42:10 +02:00
parent d250749dd0
commit bb2e4ff43a
87 changed files with 880 additions and 729 deletions
BIN
View File
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.
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.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+63 -59
View File
@@ -42,73 +42,76 @@ public final class R {
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 int reload_button=0x7f020014;
public static final int search=0x7f020015;
public static final int tab_bg_selected=0x7f020016;
public static final int tab_bg_selector=0x7f020017;
public static final int tab_bg_unselected=0x7f020018;
public static final int tab_divider=0x7f020019;
public static final int tab_text_selector=0x7f02001a;
public static final int top_bg=0x7f02001b;
public static final int user=0x7f02001c;
public static final int user_big=0x7f02001d;
}
public static final class id {
public static final int ButtonLoginUser=0x7f080015;
public static final int ButtonRegisterUser=0x7f08002c;
public static final int ButtonLoginUser=0x7f080014;
public static final int ButtonRegisterUser=0x7f08002d;
public static final int ButtonUserRegistration=0x7f080017;
public static final int EditTextLoginMail=0x7f080011;
public static final int EditTextLoginPassword=0x7f080012;
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 EditTextLoginMail=0x7f080010;
public static final int EditTextLoginPassword=0x7f080011;
public static final int EditTextRegistrationMail=0x7f08002b;
public static final int EditTextRegistrationName=0x7f08002a;
public static final int EditTextRegistrationPassword=0x7f08002c;
public static final int SearchInput=0x7f080031;
public static final int SpinnerLoginUserStatus=0x7f080013;
public static final int TextViewTitle=0x7f080012;
public static final int add=0x7f080038;
public static final int circlecc=0x7f080000;
public static final int circlecc_image=0x7f080001;
public static final int conversation=0x7f080002;
public static final int findmemenu=0x7f080005;
public static final int findmemenuItems=0x7f080006;
public static final int friends=0x7f080008;
public static final int friendslist=0x7f08000f;
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 findmemenu=0x7f080004;
public static final int findmemenuItems=0x7f080005;
public static final int friends=0x7f080007;
public static final int friendslist=0x7f08000e;
public static final int homebutton=0x7f080036;
public static final int logo=0x7f080015;
public static final int logout=0x7f08000b;
public static final int mapView=0x7f080026;
public static final int me=0x7f08000a;
public static final int message=0x7f080039;
public static final int messageInputLayout=0x7f080018;
public static final int messageOverview=0x7f08001b;
public static final int messageOverviewList=0x7f080003;
public static final int message_item=0x7f080020;
public static final int message_overview_item=0x7f08001d;
public static final int message_overview_text=0x7f08001f;
public static final int message_text=0x7f080021;
public static final int messageinput=0x7f080018;
public static final int messageinputview=0x7f080004;
public static final int messages=0x7f080009;
public static final int messagesubmit=0x7f080019;
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=0x7f08002e;
public static final int search_dialog=0x7f08002f;
public static final int tabhost=0x7f08000e;
public static final int tabsLayout=0x7f080031;
public static final int tabsText=0x7f080032;
public static final int message_item=0x7f080021;
public static final int message_overview_item=0x7f08001e;
public static final int message_overview_text=0x7f080020;
public static final int message_text=0x7f080022;
public static final int messageinput=0x7f080019;
public static final int messages=0x7f080008;
public static final int messagesubmit=0x7f08001a;
public static final int nearby=0x7f080006;
public static final int nearby_list_text=0x7f080025;
public static final int nearbylist=0x7f080024;
public static final int profile=0x7f080027;
public static final int profilemail=0x7f080029;
public static final int profilename=0x7f080028;
public static final int reloadbutton=0x7f080037;
public static final int request_dialog=0x7f08002e;
public static final int requests=0x7f08000f;
public static final int search=0x7f080009;
public static final int searchList=0x7f08002f;
public static final int search_dialog=0x7f080030;
public static final int tabhost=0x7f08000d;
public static final int tabsLayout=0x7f080032;
public static final int tabsText=0x7f080033;
public static final int test_image=0x7f080016;
public static final int title=0x7f080033;
public static final int title2138=0x7f08001c;
public static final int titleText=0x7f080034;
public static final int topbb=0x7f080022;
public static final int topbb2=0x7f08000d;
public static final int topbb9864=0x7f08001b;
public static final int user_image=0x7f08001e;
public static final int title=0x7f080034;
public static final int title2138=0x7f08001d;
public static final int titleText=0x7f080035;
public static final int topbb=0x7f080023;
public static final int topbb2=0x7f08000c;
public static final int topbb9864=0x7f08001c;
public static final int user_image=0x7f08001f;
}
public static final class layout {
public static final int circle_counter=0x7f030000;
@@ -133,6 +136,7 @@ public final class R {
public static final int tabs_bg=0x7f030013;
public static final int title=0x7f030014;
public static final int topbar=0x7f030015;
public static final int topbar_noreload=0x7f030016;
}
public static final class menu {
public static final int map=0x7f070000;
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

+3 -4
View File
@@ -11,16 +11,15 @@
<include layout="@layout/title" />
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/messageOverviewList"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/white"
android:fadingEdge="none"
android:divider="@color/lightdiv"
android:dividerHeight="1dip">
</ListView>
<include android:id="@+id/messageinputview" layout="@layout/message_input"
android:layout_gravity="bottom" />
<include layout="@layout/message_input" />
</LinearLayout>
+1 -2
View File
@@ -4,14 +4,13 @@
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="@+id/findmemenu"
android:background="@drawable/dark"
android:background="@drawable/background"
android:layout_height="fill_parent"
android:padding="20dip">
<include layout="@layout/logo" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent"
+26 -13
View File
@@ -6,35 +6,48 @@
android:background="@color/white"
android:id="@+id/friends">
<include android:id="@+id/topbb2" layout="@layout/topbar" />
<include android:id="@+id/topbb2" layout="@layout/topbar_noreload" />
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
<TabHost
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<View android:layout_width="fill_parent" android:layout_height="0.5dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<View android:layout_width="fill_parent"
android:layout_height="0.5dip"
android:background="#000" />
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginLeft="0dip" android:layout_marginRight="0dip" />
<View android:layout_width="fill_parent" android:layout_height="2dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip" />
<View android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#696969" />
<View android:layout_width="fill_parent" android:layout_height="2dip"
<View android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#000" />
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="-6dip">
<ListView android:id="@+id/friendslist" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
<ListView android:id="@+id/friendslist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:divider="@color/lightdiv"
android:fadingEdge="none"
android:dividerHeight="1dip"
android:visibility="invisible">
</ListView>
<ListView android:id="@+id/requests" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
<ListView android:id="@+id/requests"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:divider="@color/lightdiv"
android:fadingEdge="none"
android:dividerHeight="1dip"
android:visibility="invisible">
</ListView>
+1 -1
View File
@@ -5,7 +5,7 @@
android:orientation="vertical"
android:background="@drawable/dark"
android:layout_height="fill_parent"
android:padding="20dip">
android:padding="20dip">
<include layout="@layout/logo" />
+6 -9
View File
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="@color/transparent"
android:layout_height="wrap_content"
android:paddingTop="20dip"
android:paddingBottom="35dip">
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/findme_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
/>
</FrameLayout>
android:paddingTop="20dip"
android:paddingBottom="35dip"
android:id="@+id/logo"
/>
+2
View File
@@ -3,8 +3,10 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="@color/white"
android:id="@+id/messageInputLayout"
android:layout_height="wrap_content"
android:paddingTop="10dip"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingBottom="10dip"
android:paddingLeft="20dip"
-1
View File
@@ -11,7 +11,6 @@
<include android:id="@+id/title2138" layout="@layout/title" />
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/messageOverviewList"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
+3 -2
View File
@@ -18,17 +18,18 @@
android:layout_marginRight="10dip"
android:layout_gravity="center_vertical"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/transparent">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Name"
android:id="@+id/message_overview_text"
android:textSize="16sp"
android:background="@color/transparent"
android:textColor="@color/contentdark"
/>
</LinearLayout>
+3 -2
View File
@@ -10,17 +10,18 @@
android:paddingRight="20dp"
android:textColor="@color/contentdark"
android:id="@+id/message_item">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/transparent">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Name"
android:id="@+id/message_text"
android:textSize="16sp"
android:background="@color/transparent"
android:textColor="@color/contentdark"
/>
</LinearLayout>
-1
View File
@@ -10,7 +10,6 @@
<include android:id="@+id/topbb" layout="@layout/topbar" />
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/nearbylist"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
+1 -1
View File
@@ -17,7 +17,7 @@
android:layout_marginRight="5dip"
android:layout_gravity="center_vertical"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/nearby_list_text"
+1 -3
View File
@@ -5,16 +5,14 @@
android:background="@color/white"
android:id="@+id/profile">
<include layout="@layout/topbar" />
<include layout="@layout/topbar_noreload" />
<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"
+2 -2
View File
@@ -7,13 +7,13 @@
android:background="@color/white"
android:id="@+id/search">
<include layout="@layout/topbar" />
<include layout="@layout/topbar_noreload" />
<include layout="@layout/title" />
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/searchList"
android:layout_width="fill_parent"
android:fadingEdge="none"
android:layout_height="wrap_content" android:layout_weight="1"
android:background="@color/white"
android:divider="@color/lightdiv"
+19 -5
View File
@@ -6,20 +6,34 @@
android:layout_height="wrap_content"
android:paddingTop="10dip"
android:paddingBottom="10dip">
<ImageView
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:paddingLeft="20dip"
android:layout_gravity="left|center_vertical"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/findme_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:paddingLeft="20dip"
android:paddingRight="15dip"
android:paddingTop="6dip"
/>
<ImageButton android:id="@+id/homebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:onClick="enterMenuHandler"
android:src="@drawable/home_button"
android:layout_gravity="right|center_vertical"
android:paddingRight="20dip"
android:background="@null" />
</LinearLayout>
<ImageButton android:id="@+id/reloadbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="20dip"
android:layout_gravity="right|center_vertical"
android:onClick="reloadHandler"
android:src="@drawable/reload_button"
android:background="@null" />
</FrameLayout>
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="@drawable/top_bg"
android:layout_height="wrap_content"
android:paddingTop="10dip"
android:paddingBottom="10dip">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:paddingLeft="20dip"
android:layout_gravity="left|center_vertical"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/findme_light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="15dip"
android:paddingTop="6dip"
/>
<ImageButton android:id="@+id/homebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:onClick="enterMenuHandler"
android:src="@drawable/home_button"
android:background="@null" />
</LinearLayout>
</FrameLayout>
+70 -56
View File
@@ -1,50 +1,39 @@
package com.architects.findme;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONObject;
import com.architects.helper.*;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.Html;
import android.text.Spanned;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class Conversation extends Activity {
public static final String PREFS_NAME = "LoginCredentials";
private static final String TAG = "findme";
private String sender;
private String receiver;
private ListView messageOverview;
private ProgressDialog loadingDialog = null;
private ArrayAdapter<Spanned> adapter;
ArrayList<Spanned> list=new ArrayList<Spanned>();
ArrayList<Spanned> list= null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -53,56 +42,81 @@ public class Conversation extends Activity {
// get conversation partner
Bundle bundle = this.getIntent().getExtras();
String partnerMail = bundle.getString("mail");
receiver = partnerMail;
String partnerName = bundle.getString("name");
receiver = bundle.getString("mail");
// set title bar
TextView title = (TextView) findViewById(R.id.titleText);
title.setText(Html.fromHtml("Conversation with <b>" + partnerName + "</b>"));
title.setText(Html.fromHtml("Conversation with <b>" + bundle.getString("name") + "</b>"));
// get mail
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
String mail = preferences.getString("mail", "");
sender = mail;
sender = preferences.getString("mail", "");
// search results to string
JSONObject j = MessagesHelper.getConversation(mail, partnerMail);
try {
JSONObject json_data = null;
String x;
for(int i=0;i<j.length();i++)
{
x = (new Integer(j.length()-i-1)).toString();
json_data = j.getJSONObject(x);
if(json_data.getString("sendermail").compareTo(mail) == 0)
list.add(Html.fromHtml("<font color='#9fa6b3'><small>Ich:</small></font><br />"
+ json_data.getString("message")));
else
list.add(Html.fromHtml("<font color='#9fa6b3'><small>"+json_data.getString("name")
+":</small></font><br />" +
"<font color='#2a78b9'>" + json_data.getString("message") + "</font>"));
}
}
catch(Exception e) {}
messageOverview = (ListView) findViewById(R.id.messageOverviewList);
adapter = new ArrayAdapter<Spanned>
(this, R.layout.messsage_item, R.id.message_text, list);
messageOverview.setAdapter(adapter);
load();
}
public void reloadHandler(View v)
{
load();
}
private void load()
{
loadingDialog = ProgressDialog.show(this, null, " Loading ...", true);
new Thread(new Runnable(){
public void run(){
list = new ArrayList<Spanned>();
// search results to string
JSONObject j = MessagesHelper.getConversation(sender, receiver, Conversation.this);
try {
JSONObject json_data = null;
String x;
for(int i=0;i<j.length();i++)
{
x = (new Integer(j.length()-i-1)).toString();
json_data = j.getJSONObject(x);
if(json_data.getString("sendermail").compareTo(sender) == 0)
list.add(Html.fromHtml("<font color='#9fa6b3'><small>Ich:</small></font><br />"
+ json_data.getString("message")));
else
list.add(Html.fromHtml("<font color='#9fa6b3'><small>"+json_data.getString("name")
+":</small></font><br />" +
"<font color='#2a78b9'>" + json_data.getString("message") + "</font>"));
}
}
catch(Exception e) {}
Looper.prepare();
uiCallback.sendEmptyMessage(0);
}
}).start();
}
private Handler uiCallback = new Handler() {
@Override
public void handleMessage(Message msg) {
messageOverview = (ListView) findViewById(R.id.messageOverviewList);
adapter = new ArrayAdapter<Spanned>
(Conversation.this, R.layout.messsage_item, R.id.message_text, list);
messageOverview.setAdapter(adapter);
loadingDialog.dismiss();
}
};
public void messageSubmitHandler(View v)
{
View form = (View) v.getParent();
//v.getId();
// get the input value
EditText mText = (EditText) form.findViewById(R.id.messageinput);
String text = mText.getText().toString();
@@ -111,7 +125,7 @@ public class Conversation extends Activity {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mText.getWindowToken(), 0);
String response = MessagesHelper.insertMessage(this.sender, this.receiver, text);
String response = MessagesHelper.insertMessage(this.sender, this.receiver, text, this);
// handle response
if(response.trim().compareTo("01") != 0)
+1 -13
View File
@@ -1,28 +1,16 @@
package com.architects.findme;
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 FindMe 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)
@@ -30,7 +18,7 @@ public class FindMe extends Activity
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
this.setContentView(R.layout.main);
}
// VIEWS
+4 -4
View File
@@ -26,7 +26,7 @@ public class FindMeMenu extends Activity
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.findmemenu);
this.setContentView(R.layout.findmemenu);
}
// Handler
@@ -99,16 +99,16 @@ public class FindMeMenu extends Activity
logoutData[0] = preferences.getString("mail", "");
logoutData[1] = preferences.getString("password", "");
String response = Login.logout(logoutData).trim();
String response = AccountHelper.logout(logoutData, this).trim();
Log.v(TAG, response);
if(response.compareTo("06") == 0)
{
if(AccountHelper.clearLoginPreferences(this))
{
Toast.makeText(button.getContext(), "Logout successful", Toast.LENGTH_LONG).show();
Intent myIntent = new Intent(button.getContext(), Main.class);
finish();
Intent myIntent = new Intent(button.getContext(), Main.class);
startActivity(myIntent);
finish();
}
}
else Toast.makeText(this, "Logout failed. Try again!", Toast.LENGTH_LONG).show();
+110 -52
View File
@@ -1,21 +1,31 @@
package com.architects.findme;
import java.util.ArrayList;
import org.json.JSONException;
import org.json.JSONObject;
import com.architects.findme.R;
import com.architects.helper.*;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.Html;
import android.text.Spanned;
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;
@@ -26,14 +36,16 @@ import android.widget.Toast;
public class Friends extends Activity {
private TabHost mTabHost;
// The two views in our tabbed example
private ListView friends;
private ListView requests;
public static final String PREFS_NAME = "LoginCredentials";
private String mail = null;
public ProgressDialog loadingDialog;
private ArrayAdapter<Spanned> friendsAdapter;
private ArrayAdapter<Spanned> requestsAdapter;
private ArrayList<Spanned> friendslist = null;
private ArrayList<Spanned> requestslist = null;
public String mymail;
//private static final String TAG = "findme";
private void setupTabHost() {
mTabHost = (TabHost) findViewById(R.id.tabhost);
mTabHost.setup();
@@ -45,62 +57,108 @@ public class Friends extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.friends);
setupTabHost();
// setup list views
friends = (ListView) findViewById(R.id.friendslist);
requests = (ListView) findViewById(R.id.requests);
// get mail
// 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);
friends.setAdapter(new ArrayAdapter<String>
(this, R.layout.nearby_list_item, R.id.nearby_list_text, friendslist));
requests.setAdapter(new ArrayAdapter<String>
(this, R.layout.nearby_list_item,R.id.nearby_list_text, requestslist));
setupTab(friends, "Friends");
setupTab(requests, "Requests");
mail = preferences.getString("mail", "");
load();
}
private void load()
{
loadingDialog = ProgressDialog.show(this, null, " Loading ...", true);
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);
new Thread(new Runnable(){
public void run(){
setupTabHost();
// setup list views
friends = (ListView) findViewById(R.id.friendslist);
requests = (ListView) findViewById(R.id.requests);
friendslist = FriendsHelper.getFriendsList(mail, Friends.this);
requestslist = FriendsHelper.getRequestsList(mail, Friends.this);
Looper.prepare();
uiCallback.sendEmptyMessage(0);
}
}).start();
}
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",
private Handler uiCallback = new Handler() {
@Override
public void handleMessage(Message msg) {
friendsAdapter = new ArrayAdapter<Spanned>
(Friends.this, R.layout.nearby_list_item, R.id.nearby_list_text, friendslist);
friends.setAdapter(friendsAdapter);
requestsAdapter = new ArrayAdapter<Spanned>
(Friends.this, R.layout.nearby_list_item, R.id.nearby_list_text, requestslist);
requests.setAdapter(requestsAdapter);
setupTab(friends, "Friends");
setupTab(requests, "Requests");
requests.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
final String mymail = FriendsHelper.mails[position];
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) {
String response = FriendsHelper.request("add", mymail, mail, Friends.this).trim();
if(response.compareTo("01") == 0)
{
requestslist.remove(position);
requestsAdapter.notifyDataSetChanged();
JSONObject userInfo = FriendsHelper.getUserInfo(mymail, Friends.this);
try {
friendslist.add(Html.fromHtml
(userInfo.getString("name") + "<br>" + userInfo.getString("uid")));
} catch (JSONException e) {}
friendsAdapter.notifyDataSetChanged();
Toast.makeText(Friends.this, "Friend successfully added!", Toast.LENGTH_LONG).show();
}
else
Toast.makeText(Friends.this, "Error", Toast.LENGTH_LONG).show();
}
});
alertbox.setNegativeButton("Decline",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
FriendsHelper.request("decline", mail, mymail);
String response = FriendsHelper.request("decline", mymail, mail, Friends.this).trim();
Toast.makeText(Friends.this, "Friend request declined!", Toast.LENGTH_LONG).show();
if(response.compareTo("01") == 0)
{
requestslist.remove(position);
requestsAdapter.notifyDataSetChanged();
Toast.makeText(Friends.this, "Friend request declined!", Toast.LENGTH_LONG).show();
}
else
Toast.makeText(Friends.this, "Error", Toast.LENGTH_LONG).show();
}
});
alertbox.show();
}
});
}
alertbox.show();
}
});
loadingDialog.dismiss();
}
};
private void setupTab(final View view, final String tag) {
View tabview = createTabView(mTabHost.getContext(), tag);
+52 -71
View File
@@ -1,16 +1,16 @@
package com.architects.findme;
import org.json.JSONException;
import org.json.JSONObject;
import com.architects.findme.R;
import com.architects.helper.AccountHelper;
import com.architects.helper.*;
import android.app.Activity;
import android.content.Context;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.Window;
@@ -22,60 +22,22 @@ public class Login extends Activity
{
public static final String PREFS_NAME = "LoginCredentials";
private static final String TAG = "test";
private String[] loginData;
public ProgressDialog loadingDialog;
private String response;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.onCreate(null);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Login.this.setContentView(R.layout.login);
setContentView(R.layout.login);
}
public static String login(String[] str)
{
JSONObject j = new JSONObject();
try
{
j.put("mail", str[0]);
j.put("password", AccountHelper.createHashMd5(str[1]));
j.put("status", str[2]);
j.put("longitude", -122.084095);
j.put("latitude", 37.422006);
return AccountHelper.doHttpPost("login_user.php", j);
}
catch (JSONException e)
{
e.printStackTrace();
return "";
}
}
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)
{
String loginData[] = new String[3];
loginData = new String[3];
final EditText mailField = (EditText) findViewById(R.id.EditTextLoginMail);
loginData[0] = mailField.getText().toString();
@@ -86,26 +48,45 @@ public class Login extends Activity
final Spinner statusSpinner = (Spinner) findViewById(R.id.SpinnerLoginUserStatus);
loginData[2] = statusSpinner.getSelectedItem().toString();
String response = login(loginData).trim();
Log.v(TAG, response);
// 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();
}
loadingDialog = ProgressDialog.show(this, null, " Loading ...", true);
new Thread(new Runnable(){
public void run(){
response = AccountHelper.login(loginData, Login.this).trim();
Log.v(TAG, response);
// check if login was successful
if(response.compareTo("01") == 0)
{
// save login credentials to storage
SharedPreferences preferences = Login.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();
}
Looper.prepare();
uiCallback.sendEmptyMessage(0);
}
}).start();
}
private Handler uiCallback = new Handler() {
@Override
public void handleMessage(Message msg) {
if(response.compareTo("01") == 0)
{
Intent myIntent = new Intent(Login.this.getApplicationContext(), FindMeMenu.class);
startActivity(myIntent);
finish();
}
else
Toast.makeText(Login.this, response, Toast.LENGTH_LONG).show();
loadingDialog.dismiss();
}
};
}
+3 -40
View File
@@ -1,29 +1,17 @@
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;
private static final String TAG = "findme";
@Override
public void onCreate(Bundle savedInstanceState)
@@ -31,42 +19,17 @@ public class Main extends Activity
super.onCreate(savedInstanceState);
boolean isLogged = AccountHelper.isLogged(this);
Log.i(TAG, "isLogged: " + isLogged);
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
} 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);
}
}
+1 -1
View File
@@ -83,7 +83,7 @@ public class MapNearby extends MapActivity
// show people marker
itemizedoverlay = new PeopleItemizedOverlay(marker, MapNearby.this);
JSONObject json = AccountHelper.doHttpGet("get_online_user.php");
JSONObject json = RequestHelper.doHttpGet("get_online_user.php", this);
//String[] onlineUser = new String[json.length()];
+87 -67
View File
@@ -1,107 +1,127 @@
package com.architects.findme;
import java.util.List;
import org.json.JSONObject;
import com.architects.helper.*;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.Html;
import android.text.Spanned;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class Messages extends Activity {
public static final String PREFS_NAME = "LoginCredentials";
private static final String TAG = "findme";
public ProgressDialog loadingDialog;
private String mail = null;
private ListView messageOverview = null;
private Spanned[] list = null;
private String[] mails;
private String[] names;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.message_overview);
// set title bar
TextView title = (TextView) findViewById(R.id.titleText);
title.setText("Conversations");
// get mail
SharedPreferences preferences = this.getSharedPreferences(PREFS_NAME, MODE_WORLD_READABLE);
String mail = preferences.getString("mail", "");
// search results to string
JSONObject j = MessagesHelper.getConversationOverview(mail);
Spanned[] list = new Spanned[j.length()];
final String[] mails = new String[j.length()];
final String[] names = new String[j.length()];
try {
JSONObject json_data = null;
String x;
String text;
for(int i=0;i<j.length();i++)
{
x = (new Integer(j.length()-i-1)).toString();
json_data = j.getJSONObject(x);
mails[i] = json_data.getString("mail");
names[i] = json_data.getString("name");
text = json_data.getString("message");//.substring(0, 20);
list[i] = Html.fromHtml("<b>" + names[i] + "</b>" + "<br />" +
"<small>@ " + json_data.getString("date") + "</small>");
}
}
catch(Exception e) {}
ListView messageOverview = (ListView) findViewById(R.id.messageOverviewList);
messageOverview.setAdapter(new ArrayAdapter<Spanned>
(this, R.layout.message_overview_item, R.id.message_overview_text, list));
messageOverview.setTextFilterEnabled(true);
messageOverview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Bundle bundle = new Bundle();
bundle.putString("mail", mails[position]);
bundle.putString("name", names[position]);
Intent newIntent = new Intent(getApplicationContext(), Conversation.class);
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
});
load();
}
public void enterMenuHandler(View button)
public void enterMenuHandler(View v)
{
Intent myIntent = new Intent(button.getContext(), FindMeMenu.class);
Intent myIntent = new Intent(v.getContext(), FindMeMenu.class);
startActivity(myIntent);
}
public void reloadHandler(View v)
{
load();
}
private void load()
{
loadingDialog = ProgressDialog.show(this, null, " Loading ...", true);
new Thread(new Runnable(){
public void run(){
// get mail
String[] logPref = AccountHelper.getLoginPreferences(Messages.this);
mail = logPref[0];
messageOverview = (ListView) findViewById(R.id.messageOverviewList);
// search results to string
Log.v(TAG, "XXX 00");
JSONObject j = MessagesHelper.getConversationOverview(mail, Messages.this);
list = new Spanned[j.length()];
mails = new String[j.length()];
names = new String[j.length()];
try {
JSONObject json_data = null;
String x;
for(int i=0;i<j.length();i++)
{
x = (new Integer(j.length()-i-1)).toString();
json_data = j.getJSONObject(x);
mails[i] = json_data.getString("mail");
names[i] = json_data.getString("name");
list[i] = Html.fromHtml("<b>" + names[i] + "</b>" + "<br />" +
"<small>" + json_data.getString("date") + "</small>");
}
}
catch(Exception e) {}
Looper.prepare();
uiCallback.sendEmptyMessage(0);
}
}).start();
}
private Handler uiCallback = new Handler() {
@Override
public void handleMessage(Message msg) {
messageOverview.setAdapter(new ArrayAdapter<Spanned>
(Messages.this, R.layout.message_overview_item, R.id.message_overview_text, list));
messageOverview.setTextFilterEnabled(true);
messageOverview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Bundle bundle = new Bundle();
bundle.putString("mail", mails[position]);
bundle.putString("name", names[position]);
Intent newIntent = new Intent(getApplicationContext(), Conversation.class);
newIntent.putExtras(bundle);
startActivityForResult(newIntent, 0);
}
});
loadingDialog.dismiss();
}
};
}
+15 -4
View File
@@ -5,6 +5,7 @@ import org.json.JSONObject;
import com.architects.findme.R;
import com.architects.helper.*;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -46,7 +47,19 @@ public class Nearby extends Activity {
new MyLocationListener()
);
JSONObject json = AccountHelper.doHttpGet("get_online_user.php");
load();
}
public void reloadHandler(View v)
{
load();
}
private void load()
{
String[] logPref = AccountHelper.getLoginPreferences(this);
String params = "?mail=" + logPref[0];
JSONObject json = RequestHelper.doHttpGet("get_online_user.php", this, params);
String[] onlineUser = new String[json.length()];
final String[] mails = new String[json.length()];
@@ -68,8 +81,7 @@ public class Nearby extends Activity {
Location location2 = new Location("");
location2.setLatitude(json_data.getDouble("latitude"));
location2.setLongitude(json_data.getDouble("longitude"));
Log.v(TAG, "X: "+json_data.getDouble("latitude"));
location2.setLongitude(json_data.getDouble("longitude"));;
float distance = location.distanceTo(location2);
String me = null;
@@ -81,7 +93,6 @@ 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");
@@ -2,17 +2,10 @@ 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;
@@ -21,7 +14,6 @@ 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));
@@ -41,7 +33,7 @@ public class PeopleItemizedOverlay extends ItemizedOverlay
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
//OverlayItem item = mOverlays.get(index);
Bundle bundle = new Bundle();
bundle.putString("mail", "klika@live.at");
+3 -10
View File
@@ -1,10 +1,7 @@
package com.architects.findme;
import org.json.JSONObject;
import com.architects.helper.*;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
@@ -31,17 +28,13 @@ public class Profile extends Activity
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");
@@ -82,7 +75,7 @@ public class Profile extends Activity
public void addHandler(String title)
{
String[] logPref = AccountHelper.getLoginPreferences(this);
String response = FriendsHelper.request("request", logPref[0], userMail).trim();
String response = FriendsHelper.request("request", logPref[0], userMail, this).trim();
if(response.compareTo("01") == 0)
response = "Request sent!";
+58 -60
View File
@@ -1,18 +1,16 @@
package com.architects.findme;
import org.json.JSONException;
import org.json.JSONObject;
import com.architects.findme.R;
import com.architects.findme.R.id;
import com.architects.findme.R.layout;
import com.architects.helper.AccountHelper;
import com.architects.helper.*;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
@@ -21,6 +19,10 @@ import android.widget.Toast;
public class Registration extends Activity
{
public static final String PREFS_NAME = "LoginCredentials";
private String[] registrationData;
public ProgressDialog loadingDialog;
private String response;
private String response0;
@Override
public void onCreate(Bundle savedInstanceState)
@@ -30,30 +32,10 @@ public class Registration extends Activity
Registration.this.setContentView(R.layout.registration);
}
public String register(String[] str)
{
JSONObject j = new JSONObject();
try
{
j.put("name", str[0]);
j.put("mail", str[1]);
j.put("password", AccountHelper.createHashMd5(str[2]));
return AccountHelper.doHttpPost("register_user.php", j);
}
catch (JSONException e)
{
e.printStackTrace();
return "";
}
}
public void registerUserHandler(View button)
{
String registrationData[] = new String[3];
registrationData = new String[3];
final EditText nameField = (EditText) findViewById(R.id.EditTextRegistrationName);
registrationData[0] = nameField.getText().toString();
@@ -64,39 +46,55 @@ public class Registration extends Activity
final EditText passwordField = (EditText) findViewById(R.id.EditTextRegistrationPassword);
registrationData[2] = passwordField.getText().toString();
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();
loadingDialog = ProgressDialog.show(this, null, " Loading ...", true);
new Thread(new Runnable(){
public void run(){
String loginData[] = new String[3];
loginData[0] = registrationData[1];
loginData[1] = registrationData[2];
loginData[2] = "online";
response = AccountHelper.register(registrationData, Registration.this).trim();
response0 = AccountHelper.login(loginData, Registration.this).trim();
if(response.compareTo("01") == 0 && response0.compareTo("01") == 0)
{
// save login credentials to storage
SharedPreferences preferences = Registration.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();
}
Looper.prepare();
uiCallback.sendEmptyMessage(0);
}
}).start();
}
private Handler uiCallback = new Handler() {
@Override
public void handleMessage(Message msg) {
loadingDialog.dismiss();
// check if login was successful
if(response.compareTo("01") == 0)
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();
Toast.makeText(Registration.this, response, Toast.LENGTH_LONG).show();
return;
}
else
Toast.makeText(this, response, Toast.LENGTH_LONG).show();
}
else
Toast.makeText(this, response, Toast.LENGTH_LONG).show();
}
if(response0.compareTo("01") != 0)
{
Toast.makeText(Registration.this, response0, Toast.LENGTH_LONG).show();
return;
}
Intent myIntent = new Intent(Registration.this.getApplicationContext(), FindMeMenu.class);
startActivity(myIntent);
finish();
}
};
}
+48 -60
View File
@@ -1,35 +1,30 @@
package com.architects.findme;
import org.json.JSONObject;
import com.architects.helper.*;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class Search extends Activity {
private ListView resultsList;
public static final String PREFS_NAME = "LoginCredentials";
private static final String TAG = "findme";
private String query = null;
private ProgressDialog loadingDialog = null;
private String[] results = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -38,61 +33,54 @@ public class Search extends Activity {
// get search query
Bundle bundle = this.getIntent().getExtras();
String query = bundle.getString("query");
query = bundle.getString("query");
// set title bar
TextView title = (TextView) findViewById(R.id.titleText);
title.setText(Html.fromHtml("Results for <b>"+query+"</b>"));
// get results list view
resultsList = (ListView) findViewById(R.id.searchList);
loadingDialog = ProgressDialog.show(this, null, " Loading ...", true);
// search results to string
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));
resultsList.setTextFilterEnabled(true);
resultsList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
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);
}
});
new Thread(new Runnable(){
public void run(){
String[] logPref = AccountHelper.getLoginPreferences(Search.this);
results = SearchHelper.getResults(query, logPref[0], Search.this);
Looper.prepare();
uiCallback.sendEmptyMessage(0);
}
}).start();
}
private Handler uiCallback = new Handler() {
@Override
public void handleMessage(Message msg) {
// get results list view
resultsList = (ListView) findViewById(R.id.searchList);
resultsList.setAdapter(new ArrayAdapter<String>
(Search.this, R.layout.nearby_list_item, R.id.nearby_list_text, results));
resultsList.setTextFilterEnabled(true);
// view Profile if list item clicked
resultsList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Bundle bundle = new Bundle();
bundle.putString("mail", SearchHelper.mails[position]);
bundle.putString("name", SearchHelper.names[position]);
Intent newIntent = new Intent(getApplicationContext(), Profile.class);
newIntent.putExtras(bundle);
startActivity(newIntent);
}
});
loadingDialog.dismiss();
}
};
public void enterMenuHandler(View button)
{
Intent myIntent = new Intent(button.getContext(), FindMeMenu.class);
+53 -138
View File
@@ -1,100 +1,15 @@
package com.architects.helper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.protocol.HTTP;
import org.json.JSONException;
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)
{
String url = "http://www.artistandarchitects.at/findme/" + url_end;
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpResponse response;
try
{
HttpPost post = new HttpPost(url);
post.setHeader("json", j.toString());
StringEntity se = new StringEntity(j.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(se);
response = client.execute(post);
if (response != null)
{
InputStream in = response.getEntity().getContent();
return convertStreamToString(in);
}
}
catch (Exception e)
{
e.printStackTrace();
}
return "";
}
public static JSONObject doHttpGet(String url_end)
{
return doHttpGet(url_end, "");
}
public static JSONObject doHttpGet(String url_end, String params)
{
String url = "http://www.artistandarchitects.at/findme/" + url_end;
if(params != "") url += params;
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpResponse response;
try
{
HttpGet httpGet = new HttpGet(url);
response = client.execute(httpGet);
if (response != null)
{
InputStream in = response.getEntity().getContent();
JSONObject json=new JSONObject(convertStreamToString(in));
Log.i("HttpGet Response: ",convertStreamToString(in));
return json;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return new JSONObject();
}
public static Boolean isLogged(Context c)
{
SharedPreferences preferences = c.getSharedPreferences(PREFS_NAME, 0);
@@ -128,62 +43,62 @@ public class AccountHelper
return (isLogged(c)) ? false : true;
}
public static String login(String[] str, Context context)
{
JSONObject j = new JSONObject();
try
{
j.put("mail", str[0]);
j.put("password", StandardHelper.createHashMd5(str[1]));
j.put("status", str[2]);
j.put("longitude", -122.084095);
j.put("latitude", 37.422006);
return RequestHelper.doHttpPost("login_user.php", context, j);
}
catch (JSONException e)
{
e.printStackTrace();
return "";
}
}
public static String logout(String[] str, Context context)
{
JSONObject j = new JSONObject();
try
{
j.put("mail", str[0]);
j.put("password", StandardHelper.createHashMd5(str[1]));
j.put("logout", "01");
return RequestHelper.doHttpPost("login_user.php", context, j);
}
catch (JSONException e)
{
e.printStackTrace();
return "";
}
}
public static String createHashMd5(String str)
{
try
public static String register(String[] str, Context context)
{
JSONObject j = new JSONObject();
try
{
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(str.getBytes());
byte messageDigest[] = digest.digest();
// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i=0; i<messageDigest.length; i++)
{
hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
}
return hexString.toString();
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
j.put("name", str[0]);
j.put("mail", str[1]);
j.put("password", StandardHelper.createHashMd5(str[2]));
return RequestHelper.doHttpPost("register_user.php", context, j);
}
return "";
}
public static String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try
catch (JSONException e)
{
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
is.close();
}
catch (IOException e)
{
e.printStackTrace();
}
e.printStackTrace();
return "";
}
return sb.toString();
}
}
}
+29 -18
View File
@@ -1,25 +1,28 @@
package com.architects.helper;
import java.util.ArrayList;
import org.json.JSONException;
import org.json.JSONObject;
import com.architects.findme.R;
import android.content.SharedPreferences;
import android.content.Context;
import android.text.Html;
import android.text.Spanned;
import android.util.Log;
import android.widget.ArrayAdapter;
public class FriendsHelper
{
private static final String TAG = "test";
public static String[] mails = null;
public static String[] getFriendsList(String user)
public static ArrayList<Spanned> getFriendsList(String user, Context context)
{
JSONObject j = new JSONObject();
String params = "?user="+user+"&type=friends";
j = AccountHelper.doHttpGet("get_friends.php", params);
j = RequestHelper.doHttpGet("get_friends.php", context, params);
String[] friends = new String[j.length()];
ArrayList<Spanned> friends = new ArrayList<Spanned>();
mails = new String[j.length()];
try {
JSONObject json_data = null;
@@ -30,21 +33,21 @@ 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.add(Html.fromHtml(json_data.getString("name") + "<br>" + json_data.getString("id")));
}
return friends;
}
catch(Exception e) { return new String[0];}
catch(Exception e) { return new ArrayList<Spanned>();}
}
public static String[] getRequestsList(String user)
public static ArrayList<Spanned> getRequestsList(String user, Context context)
{
JSONObject j = new JSONObject();
String params = "?user="+user+"&type=requests";
j = AccountHelper.doHttpGet("get_friends.php", params);
j = RequestHelper.doHttpGet("get_friends.php", context, params);
Log.v(TAG, j.toString());
String[] friends = new String[j.length()];
ArrayList<Spanned> friends = new ArrayList<Spanned>();
Log.v(TAG, "Länge:"+j.length());
try {
@@ -55,15 +58,20 @@ public class FriendsHelper
{
x = (new Integer(i)).toString();
json_data = j.getJSONObject(x);
mails[i] = json_data.getString("mail");
friends[i] = json_data.getString("mail");
friends.add(Html.fromHtml(json_data.getString("mail")));
}
return friends;
}
catch(Exception e) { return new String[0];}
catch(Exception e) {
e.printStackTrace();
return new ArrayList<Spanned>();
}
}
public static String request(String type, String sender, String receiver)
public static String request(String type, String sender, String receiver, Context context)
{
JSONObject j = new JSONObject();
try
@@ -72,7 +80,7 @@ public class FriendsHelper
j.put("receiver", receiver);
j.put("type", type);
return AccountHelper.doHttpPost("friend.php", j);
return RequestHelper.doHttpPost("friend.php", context, j);
}
catch (JSONException e)
{
@@ -81,9 +89,12 @@ public class FriendsHelper
}
}
public static JSONObject getUserInfo(String user)
public static JSONObject getUserInfo(String user, Context context)
{
String params = "?user="+user;
return AccountHelper.doHttpGet("get_user_info.php", params);
JSONObject j = RequestHelper.doHttpGet("get_user_info.php", context, params);
Log.v(TAG, j.toString());
return j;
//return j.g;
}
}
@@ -1,18 +1,13 @@
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;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class LocationHelper
@@ -21,7 +16,6 @@ public class LocationHelper
private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 100; // in Milliseconds
private static final String TAG = "test";
protected LocationManager locationManager;
protected Context myContext;
+8 -10
View File
@@ -3,35 +3,33 @@ package com.architects.helper;
import org.json.JSONException;
import org.json.JSONObject;
import com.architects.findme.R;
import android.content.SharedPreferences;
import android.content.Context;
import android.util.Log;
import android.widget.ArrayAdapter;
public class MessagesHelper
{
private static final String TAG = "test";
public static JSONObject getConversationOverview(String user)
public static JSONObject getConversationOverview(String user, Context context)
{
JSONObject j = new JSONObject();
String params = "?type=overview&sender="+user;
j = AccountHelper.doHttpGet("get_message.php", params);
Log.v(TAG, "XXX 0.5");
j = RequestHelper.doHttpGet("get_message.php", context, params);
return j;
}
public static JSONObject getConversation(String user, String partner)
public static JSONObject getConversation(String user, String partner, Context context)
{
JSONObject j = new JSONObject();
String params = "?type=conversation&sender="+user+"&receiver="+partner;
j = AccountHelper.doHttpGet("get_message.php", params);
j = RequestHelper.doHttpGet("get_message.php", context, params);
return j;
}
public static String insertMessage(String sender, String receiver, String message)
public static String insertMessage(String sender, String receiver, String message, Context context)
{
JSONObject j = new JSONObject();
try
@@ -40,7 +38,7 @@ public class MessagesHelper
j.put("receiver", receiver);
j.put("message", message);
return AccountHelper.doHttpPost("message.php", j);
return RequestHelper.doHttpPost("message.php", context, j);
}
catch (JSONException e)
{
@@ -0,0 +1,96 @@
package com.architects.helper;
import java.io.InputStream;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;
import android.content.Context;
import android.net.ConnectivityManager;
import android.util.Log;
public class RequestHelper
{
public static final String PREFS_NAME = "LoginCredentials";
public static String doHttpPost(String url_end, Context context, JSONObject j)
{
String url = "http://www.artistandarchitects.at/findme/" + url_end;
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpResponse response;
try
{
HttpPost post = new HttpPost(url);
post.setHeader("json", j.toString());
StringEntity se = new StringEntity(j.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(se);
response = client.execute(post);
if (response != null)
{
InputStream in = response.getEntity().getContent();
return StandardHelper.convertStreamToString(in);
}
}
catch (Exception e)
{
e.printStackTrace();
}
return "";
}
public static JSONObject doHttpGet(String url_end, Context context)
{
return doHttpGet(url_end, context, "");
}
public static JSONObject doHttpGet(String url_end, Context context, String params)
{
String url = "http://www.artistandarchitects.at/findme/" + url_end;
if(params != "") url += params;
HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpResponse response;
try
{
HttpGet httpGet = new HttpGet(url);
response = client.execute(httpGet);
if (response != null)
{
InputStream in = response.getEntity().getContent();
JSONObject json=new JSONObject(StandardHelper.convertStreamToString(in));
Log.i("HttpGet Response: ", StandardHelper.convertStreamToString(in));
return json;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return new JSONObject();
}
public boolean isOnline(Context c) {
ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo().isConnectedOrConnecting();
}
}
+16 -5
View File
@@ -2,20 +2,25 @@ package com.architects.helper;
import org.json.JSONObject;
import android.content.Context;
import android.util.Log;
public class SearchHelper
{
private static final String TAG = "test";
private static final String TAG = "findme";
public static String[] mails = null;
public static String[] names = null;
public static String[] getResults(String query)
public static String[] getResults(String query, String mail, Context context)
{
JSONObject j = new JSONObject();
String params = "?query="+query;
j = AccountHelper.doHttpGet("search.php", params);
String params = "?query="+query+"&mail="+mail;
j = RequestHelper.doHttpGet("search.php", context, params);
Log.v(TAG, j.toString());
String[] results = new String[j.length()];
mails = new String[j.length()];
names = new String[j.length()];
try {
JSONObject json_data = null;
@@ -26,10 +31,16 @@ public class SearchHelper
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");
}
return results;
}
catch(Exception e) { return new String[0];}
catch(Exception e) {
e.printStackTrace();
return new String[0];
}
}
}
@@ -0,0 +1,64 @@
package com.architects.helper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class StandardHelper
{
public static String createHashMd5(String str)
{
try
{
// Create MD5 Hash
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(str.getBytes());
byte messageDigest[] = digest.digest();
// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i=0; i<messageDigest.length; i++)
{
hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
}
return hexString.toString();
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
return "";
}
public static String convertStreamToString(InputStream is)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try
{
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
}
catch (IOException e)
{}
finally
{
try
{
is.close();
}
catch (IOException e)
{}
}
return sb.toString();
}
}