commit be6cac6dfbd0b15635e61c612cdb6cfc3d148231 Author: Tobias Klika Date: Sun May 22 18:28:21 2011 +0200 ADDED: Login, Registration, Navigation, Location-Retrieving diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..609aa00 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..e50730d --- /dev/null +++ b/.project @@ -0,0 +1,33 @@ + + + findMe + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..04f47e9 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Sun Mar 20 19:06:34 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..b0e07a6 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bin/classes.dex b/bin/classes.dex new file mode 100644 index 0000000..61024ad Binary files /dev/null and b/bin/classes.dex differ diff --git a/bin/com/architects/findme/Chat.class b/bin/com/architects/findme/Chat.class new file mode 100644 index 0000000..d907aaa Binary files /dev/null and b/bin/com/architects/findme/Chat.class differ diff --git a/bin/com/architects/findme/FindMe.class b/bin/com/architects/findme/FindMe.class new file mode 100644 index 0000000..a048d45 Binary files /dev/null and b/bin/com/architects/findme/FindMe.class differ diff --git a/bin/com/architects/findme/Friends.class b/bin/com/architects/findme/Friends.class new file mode 100644 index 0000000..5bd4668 Binary files /dev/null and b/bin/com/architects/findme/Friends.class differ diff --git a/bin/com/architects/findme/Login.class b/bin/com/architects/findme/Login.class new file mode 100644 index 0000000..38d84c9 Binary files /dev/null and b/bin/com/architects/findme/Login.class differ diff --git a/bin/com/architects/findme/Nearby$MyLocationListener.class b/bin/com/architects/findme/Nearby$MyLocationListener.class new file mode 100644 index 0000000..4ddd919 Binary files /dev/null and b/bin/com/architects/findme/Nearby$MyLocationListener.class differ diff --git a/bin/com/architects/findme/Nearby.class b/bin/com/architects/findme/Nearby.class new file mode 100644 index 0000000..1f41b95 Binary files /dev/null and b/bin/com/architects/findme/Nearby.class differ diff --git a/bin/com/architects/findme/R$array.class b/bin/com/architects/findme/R$array.class new file mode 100644 index 0000000..fe22e93 Binary files /dev/null and b/bin/com/architects/findme/R$array.class differ diff --git a/bin/com/architects/findme/R$attr.class b/bin/com/architects/findme/R$attr.class new file mode 100644 index 0000000..1d63b57 Binary files /dev/null and b/bin/com/architects/findme/R$attr.class differ diff --git a/bin/com/architects/findme/R$drawable.class b/bin/com/architects/findme/R$drawable.class new file mode 100644 index 0000000..f37c8b0 Binary files /dev/null and b/bin/com/architects/findme/R$drawable.class differ diff --git a/bin/com/architects/findme/R$id.class b/bin/com/architects/findme/R$id.class new file mode 100644 index 0000000..6fbc480 Binary files /dev/null and b/bin/com/architects/findme/R$id.class differ diff --git a/bin/com/architects/findme/R$layout.class b/bin/com/architects/findme/R$layout.class new file mode 100644 index 0000000..0fc1066 Binary files /dev/null and b/bin/com/architects/findme/R$layout.class differ diff --git a/bin/com/architects/findme/R$menu.class b/bin/com/architects/findme/R$menu.class new file mode 100644 index 0000000..0e1a783 Binary files /dev/null and b/bin/com/architects/findme/R$menu.class differ diff --git a/bin/com/architects/findme/R$string.class b/bin/com/architects/findme/R$string.class new file mode 100644 index 0000000..186a8f3 Binary files /dev/null and b/bin/com/architects/findme/R$string.class differ diff --git a/bin/com/architects/findme/R.class b/bin/com/architects/findme/R.class new file mode 100644 index 0000000..3325893 Binary files /dev/null and b/bin/com/architects/findme/R.class differ diff --git a/bin/com/architects/findme/Registration.class b/bin/com/architects/findme/Registration.class new file mode 100644 index 0000000..2b5f598 Binary files /dev/null and b/bin/com/architects/findme/Registration.class differ diff --git a/bin/com/architects/findme/Search.class b/bin/com/architects/findme/Search.class new file mode 100644 index 0000000..b09f96c Binary files /dev/null and b/bin/com/architects/findme/Search.class differ diff --git a/bin/com/architects/findme/TabView.class b/bin/com/architects/findme/TabView.class new file mode 100644 index 0000000..917e7e6 Binary files /dev/null and b/bin/com/architects/findme/TabView.class differ diff --git a/bin/com/architects/findme/Tabs.class b/bin/com/architects/findme/Tabs.class new file mode 100644 index 0000000..89536dd Binary files /dev/null and b/bin/com/architects/findme/Tabs.class differ diff --git a/bin/com/architects/helper/AccountHelper.class b/bin/com/architects/helper/AccountHelper.class new file mode 100644 index 0000000..6c3c6a5 Binary files /dev/null and b/bin/com/architects/helper/AccountHelper.class differ diff --git a/bin/com/architects/helper/LocationCalculation$1.class b/bin/com/architects/helper/LocationCalculation$1.class new file mode 100644 index 0000000..4785af8 Binary files /dev/null and b/bin/com/architects/helper/LocationCalculation$1.class differ diff --git a/bin/com/architects/helper/LocationCalculation$2.class b/bin/com/architects/helper/LocationCalculation$2.class new file mode 100644 index 0000000..bd021a8 Binary files /dev/null and b/bin/com/architects/helper/LocationCalculation$2.class differ diff --git a/bin/com/architects/helper/LocationCalculation$GetLastLocation.class b/bin/com/architects/helper/LocationCalculation$GetLastLocation.class new file mode 100644 index 0000000..860b921 Binary files /dev/null and b/bin/com/architects/helper/LocationCalculation$GetLastLocation.class differ diff --git a/bin/com/architects/helper/LocationCalculation$LocationResult.class b/bin/com/architects/helper/LocationCalculation$LocationResult.class new file mode 100644 index 0000000..ce2e29a Binary files /dev/null and b/bin/com/architects/helper/LocationCalculation$LocationResult.class differ diff --git a/bin/com/architects/helper/LocationCalculation.class b/bin/com/architects/helper/LocationCalculation.class new file mode 100644 index 0000000..1848f50 Binary files /dev/null and b/bin/com/architects/helper/LocationCalculation.class differ diff --git a/bin/com/architects/helper/LocationHelper$MyLocationListener.class b/bin/com/architects/helper/LocationHelper$MyLocationListener.class new file mode 100644 index 0000000..77a4232 Binary files /dev/null and b/bin/com/architects/helper/LocationHelper$MyLocationListener.class differ diff --git a/bin/com/architects/helper/LocationHelper.class b/bin/com/architects/helper/LocationHelper.class new file mode 100644 index 0000000..8da19e8 Binary files /dev/null and b/bin/com/architects/helper/LocationHelper.class differ diff --git a/bin/com/architects/helper/StateHelper.class b/bin/com/architects/helper/StateHelper.class new file mode 100644 index 0000000..04125ac Binary files /dev/null and b/bin/com/architects/helper/StateHelper.class differ diff --git a/bin/findMe.apk b/bin/findMe.apk new file mode 100644 index 0000000..a91e925 Binary files /dev/null and b/bin/findMe.apk differ diff --git a/bin/resources.ap_ b/bin/resources.ap_ new file mode 100644 index 0000000..c1839bc Binary files /dev/null and b/bin/resources.ap_ differ diff --git a/default.properties b/default.properties new file mode 100644 index 0000000..e2e8061 --- /dev/null +++ b/default.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 diff --git a/gen/com/architects/findme/R.java b/gen/com/architects/findme/R.java new file mode 100644 index 0000000..c2de293 --- /dev/null +++ b/gen/com/architects/findme/R.java @@ -0,0 +1,74 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.architects.findme; + +public final class R { + public static final class array { + public static final int userStatusList=0x7f040000; + } + public static final class attr { + } + public static final class drawable { + public static final int background=0x7f020000; + public static final int background_dark=0x7f020001; + public static final int background_row=0x7f020002; + public static final int background_row_dark=0x7f020003; + public static final int ic_tab_artists_grey=0x7f020004; + public static final int ic_tab_artists_white=0x7f020005; + public static final int ic_tab_friends=0x7f020006; + public static final int icon=0x7f020007; + public static final int logo=0x7f020008; + } + public static final class id { + public static final int ButtonFriends=0x7f070008; + public static final int ButtonLoginUser=0x7f070004; + public static final int ButtonNearby=0x7f070007; + public static final int ButtonRegisterUser=0x7f07000e; + public static final int ButtonSearch=0x7f070009; + public static final int ButtonUpdate=0x7f07000a; + public static final int ButtonUserRegistration=0x7f070006; + public static final int EditTextLoginMail=0x7f070000; + public static final int EditTextLoginPassword=0x7f070001; + public static final int EditTextRegistrationMail=0x7f07000c; + public static final int EditTextRegistrationName=0x7f07000b; + public static final int EditTextRegistrationPassword=0x7f07000d; + public static final int SpinnerLoginUserStatus=0x7f070003; + public static final int TextViewTitle=0x7f070002; + public static final int icon=0x7f07000f; + public static final int icontext=0x7f070011; + public static final int test_image=0x7f070005; + public static final int text=0x7f070010; + } + public static final class layout { + public static final int login=0x7f030000; + public static final int main=0x7f030001; + public static final int nearby=0x7f030002; + public static final int registration=0x7f030003; + public static final int tabs=0x7f030004; + } + public static final class menu { + public static final int menu=0x7f060000; + } + public static final class string { + public static final int app_name=0x7f050000; + public static final int main_login=0x7f050001; + public static final int main_register=0x7f050002; + public static final int navigation_chat=0x7f05000a; + public static final int navigation_friends=0x7f050008; + /** Navigation + */ + public static final int navigation_nearby=0x7f050007; + public static final int navigation_search=0x7f050009; + /** Current User Status + */ + public static final int userStatus1=0x7f050003; + public static final int userStatus2=0x7f050004; + public static final int userStatus3=0x7f050005; + public static final int userStatus4=0x7f050006; + } +} diff --git a/proguard.cfg b/proguard.cfg new file mode 100644 index 0000000..12dd039 --- /dev/null +++ b/proguard.cfg @@ -0,0 +1,36 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembernames class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembernames class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/res/drawable-hdpi/background.png b/res/drawable-hdpi/background.png new file mode 100644 index 0000000..03a4fc1 Binary files /dev/null and b/res/drawable-hdpi/background.png differ diff --git a/res/drawable-hdpi/background_dark.png b/res/drawable-hdpi/background_dark.png new file mode 100644 index 0000000..a82fbe3 Binary files /dev/null and b/res/drawable-hdpi/background_dark.png differ diff --git a/res/drawable-hdpi/background_row.png b/res/drawable-hdpi/background_row.png new file mode 100644 index 0000000..d42eecf Binary files /dev/null and b/res/drawable-hdpi/background_row.png differ diff --git a/res/drawable-hdpi/background_row_dark.png b/res/drawable-hdpi/background_row_dark.png new file mode 100644 index 0000000..569ce11 Binary files /dev/null and b/res/drawable-hdpi/background_row_dark.png differ diff --git a/res/drawable-hdpi/ic_tab_artists_grey.png b/res/drawable-hdpi/ic_tab_artists_grey.png new file mode 100644 index 0000000..9baa30e Binary files /dev/null and b/res/drawable-hdpi/ic_tab_artists_grey.png differ diff --git a/res/drawable-hdpi/ic_tab_artists_white.png b/res/drawable-hdpi/ic_tab_artists_white.png new file mode 100644 index 0000000..3b010d5 Binary files /dev/null and b/res/drawable-hdpi/ic_tab_artists_white.png differ diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png new file mode 100644 index 0000000..8074c4c Binary files /dev/null and b/res/drawable-hdpi/icon.png differ diff --git a/res/drawable-hdpi/logo.png b/res/drawable-hdpi/logo.png new file mode 100644 index 0000000..9f618b5 Binary files /dev/null and b/res/drawable-hdpi/logo.png differ diff --git a/res/drawable-ldpi/icon.png b/res/drawable-ldpi/icon.png new file mode 100644 index 0000000..1095584 Binary files /dev/null and b/res/drawable-ldpi/icon.png differ diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png new file mode 100644 index 0000000..a07c69f Binary files /dev/null and b/res/drawable-mdpi/icon.png differ diff --git a/res/drawable/ic_tab_friends.xml b/res/drawable/ic_tab_friends.xml new file mode 100644 index 0000000..ebb714b --- /dev/null +++ b/res/drawable/ic_tab_friends.xml @@ -0,0 +1,8 @@ + + + + + + + \ No newline at end of file diff --git a/res/layout/login.xml b/res/layout/login.xml new file mode 100644 index 0000000..72af5af --- /dev/null +++ b/res/layout/login.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/main.xml b/res/layout/main.xml new file mode 100644 index 0000000..140ec36 --- /dev/null +++ b/res/layout/main.xml @@ -0,0 +1,41 @@ + + + + + + + + + \ No newline at end of file diff --git a/res/layout/nearby.xml b/res/layout/nearby.xml new file mode 100644 index 0000000..16e7c12 --- /dev/null +++ b/res/layout/nearby.xml @@ -0,0 +1,55 @@ + + + + + + + + + diff --git a/res/layout/registration.xml b/res/layout/registration.xml new file mode 100644 index 0000000..adfd90b --- /dev/null +++ b/res/layout/registration.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/tabs.xml b/res/layout/tabs.xml new file mode 100644 index 0000000..c1d832d --- /dev/null +++ b/res/layout/tabs.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file diff --git a/res/menu/menu.xml b/res/menu/menu.xml new file mode 100644 index 0000000..4079cbb --- /dev/null +++ b/res/menu/menu.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/res/values/arrays.xml b/res/values/arrays.xml new file mode 100644 index 0000000..a8d036f --- /dev/null +++ b/res/values/arrays.xml @@ -0,0 +1,9 @@ + + + + @string/userStatus1 + @string/userStatus2 + @string/userStatus3 + @string/userStatus4 + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..085446e --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,18 @@ + + + findMe + I\'m already a findMe user + I\'m new to findMe + + + Online + Busy + Away + Invisible + + + Nearby + Friends + Search + Chat + \ No newline at end of file diff --git a/src/com/architects/findme/Chat.java b/src/com/architects/findme/Chat.java new file mode 100644 index 0000000..9927ed3 --- /dev/null +++ b/src/com/architects/findme/Chat.java @@ -0,0 +1,15 @@ +package com.architects.findme; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + +public class Chat extends Activity { + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + TextView textview = new TextView(this); + textview.setText("Chat"); + setContentView(textview); + } +} diff --git a/src/com/architects/findme/FindMe.java b/src/com/architects/findme/FindMe.java new file mode 100644 index 0000000..151c63a --- /dev/null +++ b/src/com/architects/findme/FindMe.java @@ -0,0 +1,63 @@ +package com.architects.findme; + +import com.architects.findme.R; +import com.architects.findme.R.id; +import com.architects.findme.R.layout; +import com.architects.findme.R.menu; +import com.architects.helper.StateHelper; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; +import android.widget.Toast; + +public class FindMe extends Activity +{ + public StateHelper phoneState = new StateHelper(); + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + } + + @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; + } + + // 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); + } + + +} \ No newline at end of file diff --git a/src/com/architects/findme/Friends.java b/src/com/architects/findme/Friends.java new file mode 100644 index 0000000..ba6829d --- /dev/null +++ b/src/com/architects/findme/Friends.java @@ -0,0 +1,17 @@ +package com.architects.findme; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; + +public class Friends extends Activity { + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + TextView textview = new TextView(this); + textview.setText("Friends"); + setContentView(textview); + } +} diff --git a/src/com/architects/findme/Login.java b/src/com/architects/findme/Login.java new file mode 100644 index 0000000..0c66cbc --- /dev/null +++ b/src/com/architects/findme/Login.java @@ -0,0 +1,72 @@ +package com.architects.findme; + +import org.json.JSONException; +import org.json.JSONObject; + +import com.architects.findme.R; +import com.architects.helper.AccountHelper; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.EditText; +import android.widget.Spinner; +import android.widget.Toast; + +public class Login extends Activity +{ + private static final String TAG = "test"; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.login); + } + + public 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]); + + return AccountHelper.doHttpPost("login_user.php", j); + } + catch (JSONException e) + { + e.printStackTrace(); + return ""; + } + } + + + public void loginUserHandler(View button) + { + String loginData[] = new String[3]; + + final EditText mailField = (EditText) findViewById(R.id.EditTextLoginMail); + loginData[0] = mailField.getText().toString(); + + final EditText passwordField = (EditText) findViewById(R.id.EditTextLoginPassword); + loginData[1] = passwordField.getText().toString(); + + final Spinner statusSpinner = (Spinner) findViewById(R.id.SpinnerLoginUserStatus); + loginData[2] = statusSpinner.getSelectedItem().toString(); + + String response = login(loginData).trim(); + Log.v(TAG, response); + + if(response.compareTo("01") == 0) + { + Intent myIntent = new Intent(button.getContext(), Nearby.class); + startActivity(myIntent); + } + else Toast.makeText(this, response, Toast.LENGTH_LONG).show(); + } + +} diff --git a/src/com/architects/findme/Nearby.java b/src/com/architects/findme/Nearby.java new file mode 100644 index 0000000..694e971 --- /dev/null +++ b/src/com/architects/findme/Nearby.java @@ -0,0 +1,110 @@ +package com.architects.findme; + +import com.architects.findme.R; +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 Nearby extends Activity { + + 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; + + @Override + public void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + setContentView(R.layout.nearby); + + locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MINIMUM_TIME_BETWEEN_UPDATES, + MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, + new MyLocationListener() + ); + } + + public void updateLocationHandler(View button) + { + showCurrentLocation(); + } + + protected void showCurrentLocation() { + + 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() + ); + Toast.makeText(Nearby.this, message, + Toast.LENGTH_LONG).show(); + } + } + + 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() + ); + 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(Nearby.this, + "Provider disabled by the user. GPS turned off", + Toast.LENGTH_LONG).show(); + } + + public void onProviderEnabled(String s) { + Toast.makeText(Nearby.this, + "Provider enabled by the user. GPS turned on", + Toast.LENGTH_LONG).show(); + } + + } + + + // VIEWS + public void drawNearbyHandler(View button) + { + Intent myIntent = new Intent(button.getContext(), Nearby.class); + startActivity(myIntent); + } + public void drawFriendsHandler(View button) + { + Intent myIntent = new Intent(button.getContext(), Friends.class); + startActivity(myIntent); + } + public void drawChatHandler(View button) + { + Intent myIntent = new Intent(button.getContext(), Chat.class); + startActivity(myIntent); + } + public void drawSearchHandler(View button) + { + Intent myIntent = new Intent(button.getContext(), Search.class); + startActivity(myIntent); + } +} diff --git a/src/com/architects/findme/Registration.java b/src/com/architects/findme/Registration.java new file mode 100644 index 0000000..7cac476 --- /dev/null +++ b/src/com/architects/findme/Registration.java @@ -0,0 +1,63 @@ +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 android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.widget.EditText; +import android.widget.Toast; + +public class Registration extends Activity +{ + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + 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]; + + final EditText nameField = (EditText) findViewById(R.id.EditTextRegistrationName); + registrationData[0] = nameField.getText().toString(); + + final EditText mailField = (EditText) findViewById(R.id.EditTextRegistrationMail); + registrationData[1] = mailField.getText().toString(); + + 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(); + } + +} diff --git a/src/com/architects/findme/Search.java b/src/com/architects/findme/Search.java new file mode 100644 index 0000000..34d6f95 --- /dev/null +++ b/src/com/architects/findme/Search.java @@ -0,0 +1,15 @@ +package com.architects.findme; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.TextView; + +public class Search extends Activity { + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + TextView textview = new TextView(this); + textview.setText("Search"); + setContentView(textview); + } +} diff --git a/src/com/architects/findme/TabView.java b/src/com/architects/findme/TabView.java new file mode 100644 index 0000000..8659660 --- /dev/null +++ b/src/com/architects/findme/TabView.java @@ -0,0 +1,13 @@ +package com.architects.findme; + +import android.app.Activity; +import android.os.Bundle; + +public class TabView extends Activity { + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + setContentView(R.layout.tabs); + } +} \ No newline at end of file diff --git a/src/com/architects/findme/Tabs.java b/src/com/architects/findme/Tabs.java new file mode 100644 index 0000000..f74cf0a --- /dev/null +++ b/src/com/architects/findme/Tabs.java @@ -0,0 +1,50 @@ +package com.architects.findme; + +import android.app.TabActivity; +import android.content.Intent; +import android.content.res.Resources; +import android.os.Bundle; +import android.text.Html.TagHandler; +import android.util.Log; +import android.widget.TabHost; +import android.widget.TabWidget; + +public class Tabs extends TabActivity { + private static final String TAG = "test"; + + public void onCreate(Bundle savedInstanceState) { + Log.v(TAG, "sicher"); + super.onCreate(savedInstanceState); + setContentView(R.layout.tabs); + Resources res = getResources(); // Resource object to get Drawables + TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); // The activity TabHost + TabHost.TabSpec spec; // Resusable TabSpec for each tab + Intent intent; // Reusable Intent for each tab + + Log.v(TAG, "01"); + + // Create an Intent to launch an Activity for the tab (to be reused) + intent = new Intent().setClass(this, Friends.class); + + // Initialize a TabSpec for each tab and add it to the TabHost + spec = tabHost.newTabSpec("friends").setIndicator("Friends").setContent(intent); + tabHost.addTab(spec); + + Log.v(TAG, "01.5"); + + // Do the same for the other tabs + intent = new Intent().setClass(this, Chat.class); + spec = tabHost.newTabSpec("chat").setIndicator("Chat").setContent(intent); + tabHost.addTab(spec); + + intent = new Intent().setClass(this, Search.class); + spec = tabHost.newTabSpec("search").setIndicator("Search").setContent(intent); + tabHost.addTab(spec); + + Log.v(TAG, "02"); + + tabHost.setCurrentTab(2); + + Log.v(TAG, "03"); + } +} diff --git a/src/com/architects/helper/AccountHelper.java b/src/com/architects/helper/AccountHelper.java new file mode 100644 index 0000000..d137515 --- /dev/null +++ b/src/com/architects/helper/AccountHelper.java @@ -0,0 +1,110 @@ +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.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; + +public class AccountHelper +{ + 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 AccountHelper.convertStreamToString(in); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + return ""; + } + + 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; inet_loc.getTime()) + locationResult.gotLocation(gps_loc); + else + locationResult.gotLocation(net_loc); + return; + } + + if(gps_loc!=null){ + locationResult.gotLocation(gps_loc); + return; + } + if(net_loc!=null){ + locationResult.gotLocation(net_loc); + return; + } + locationResult.gotLocation(null); + } + } + + public static abstract class LocationResult{ + public abstract void gotLocation(Location location); + } +} diff --git a/src/com/architects/helper/LocationHelper.java b/src/com/architects/helper/LocationHelper.java new file mode 100644 index 0000000..d43ecdd --- /dev/null +++ b/src/com/architects/helper/LocationHelper.java @@ -0,0 +1,89 @@ +package com.architects.helper; + +import com.architects.findme.Nearby; + +import android.R; +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 extends Activity { + + private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters + private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds + + protected LocationManager locationManager; + + @Override + public void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + //setContentView(R.layout.main); + + locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); + + locationManager.requestLocationUpdates( + LocationManager.GPS_PROVIDER, + MINIMUM_TIME_BETWEEN_UPDATES, + MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, + new MyLocationListener() + ); + } + + public void updateLocationHandler(View button) + { + showCurrentLocation(); + } + + protected void showCurrentLocation() { + + 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() + ); + Toast.makeText(LocationHelper.this, message, + Toast.LENGTH_LONG).show(); + } + } + + 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() + ); + Toast.makeText(LocationHelper.this, message, Toast.LENGTH_LONG).show(); + } + + public void onStatusChanged(String s, int i, Bundle b) { + Toast.makeText(LocationHelper.this, "Provider status changed", + Toast.LENGTH_LONG).show(); + } + + public void onProviderDisabled(String s) { + Toast.makeText(LocationHelper.this, + "Provider disabled by the user. GPS turned off", + Toast.LENGTH_LONG).show(); + } + + public void onProviderEnabled(String s) { + Toast.makeText(LocationHelper.this, + "Provider enabled by the user. GPS turned on", + Toast.LENGTH_LONG).show(); + } + + } + +} diff --git a/src/com/architects/helper/StateHelper.java b/src/com/architects/helper/StateHelper.java new file mode 100644 index 0000000..d3fab32 --- /dev/null +++ b/src/com/architects/helper/StateHelper.java @@ -0,0 +1,17 @@ +package com.architects.helper; + +import android.app.Activity; +import android.content.Context; +import android.net.ConnectivityManager; + + +public class StateHelper extends Activity +{ + public String isOnline() + { + ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + if (cm.getActiveNetworkInfo().isConnectedOrConnecting()) + return "CONNECTED"; + else return "NOT CONNECTED"; + } +}