diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..a4763d1
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..ad77ac5
--- /dev/null
+++ b/.project
@@ -0,0 +1,33 @@
+
+
+ GaiaAndroid
+
+
+
+
+
+ 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..b080d2d
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..a97b3bb
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bin/AndroidManifest.xml b/bin/AndroidManifest.xml
new file mode 100644
index 0000000..a97b3bb
--- /dev/null
+++ b/bin/AndroidManifest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/bin/GaiaAndroid.apk b/bin/GaiaAndroid.apk
new file mode 100644
index 0000000..ff4bf73
Binary files /dev/null and b/bin/GaiaAndroid.apk differ
diff --git a/bin/classes.dex b/bin/classes.dex
new file mode 100644
index 0000000..f9dc90e
Binary files /dev/null and b/bin/classes.dex differ
diff --git a/bin/classes/it/gaiacri/mobile/Accesso$1.class b/bin/classes/it/gaiacri/mobile/Accesso$1.class
new file mode 100644
index 0000000..14e3771
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Accesso$1.class differ
diff --git a/bin/classes/it/gaiacri/mobile/Accesso$2.class b/bin/classes/it/gaiacri/mobile/Accesso$2.class
new file mode 100644
index 0000000..6aec405
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Accesso$2.class differ
diff --git a/bin/classes/it/gaiacri/mobile/Accesso$3.class b/bin/classes/it/gaiacri/mobile/Accesso$3.class
new file mode 100644
index 0000000..89cbb07
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Accesso$3.class differ
diff --git a/bin/classes/it/gaiacri/mobile/Accesso$4.class b/bin/classes/it/gaiacri/mobile/Accesso$4.class
new file mode 100644
index 0000000..ab32710
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Accesso$4.class differ
diff --git a/bin/classes/it/gaiacri/mobile/Accesso$RichiestaLogin.class b/bin/classes/it/gaiacri/mobile/Accesso$RichiestaLogin.class
new file mode 100644
index 0000000..733b1df
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Accesso$RichiestaLogin.class differ
diff --git a/bin/classes/it/gaiacri/mobile/Accesso$RichiestaWelcome.class b/bin/classes/it/gaiacri/mobile/Accesso$RichiestaWelcome.class
new file mode 100644
index 0000000..e1d4fe7
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Accesso$RichiestaWelcome.class differ
diff --git a/bin/classes/it/gaiacri/mobile/Accesso.class b/bin/classes/it/gaiacri/mobile/Accesso.class
new file mode 100644
index 0000000..e97e2e3
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Accesso.class differ
diff --git a/bin/classes/it/gaiacri/mobile/BuildConfig.class b/bin/classes/it/gaiacri/mobile/BuildConfig.class
new file mode 100644
index 0000000..75096ec
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/BuildConfig.class differ
diff --git a/bin/classes/it/gaiacri/mobile/MenuPrincipale.class b/bin/classes/it/gaiacri/mobile/MenuPrincipale.class
new file mode 100644
index 0000000..c2e4a91
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/MenuPrincipale.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R$attr.class b/bin/classes/it/gaiacri/mobile/R$attr.class
new file mode 100644
index 0000000..fe7a648
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R$attr.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R$drawable.class b/bin/classes/it/gaiacri/mobile/R$drawable.class
new file mode 100644
index 0000000..49f9b9b
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R$drawable.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R$id.class b/bin/classes/it/gaiacri/mobile/R$id.class
new file mode 100644
index 0000000..3748ced
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R$id.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R$layout.class b/bin/classes/it/gaiacri/mobile/R$layout.class
new file mode 100644
index 0000000..13e8edb
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R$layout.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R$menu.class b/bin/classes/it/gaiacri/mobile/R$menu.class
new file mode 100644
index 0000000..10b64e0
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R$menu.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R$string.class b/bin/classes/it/gaiacri/mobile/R$string.class
new file mode 100644
index 0000000..07ea94b
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R$string.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R$style.class b/bin/classes/it/gaiacri/mobile/R$style.class
new file mode 100644
index 0000000..c9f85a3
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R$style.class differ
diff --git a/bin/classes/it/gaiacri/mobile/R.class b/bin/classes/it/gaiacri/mobile/R.class
new file mode 100644
index 0000000..b4aae8c
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/R.class differ
diff --git a/bin/classes/it/gaiacri/mobile/Richiesta.class b/bin/classes/it/gaiacri/mobile/Richiesta.class
new file mode 100644
index 0000000..14cb921
Binary files /dev/null and b/bin/classes/it/gaiacri/mobile/Richiesta.class differ
diff --git a/bin/dexedLibs/android-support-v4-714a29c0173cb8382e9a364153c9eaf5.jar b/bin/dexedLibs/android-support-v4-714a29c0173cb8382e9a364153c9eaf5.jar
new file mode 100644
index 0000000..1732256
Binary files /dev/null and b/bin/dexedLibs/android-support-v4-714a29c0173cb8382e9a364153c9eaf5.jar differ
diff --git a/bin/res/drawable-hdpi/ic_launcher.png b/bin/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..55af74a
Binary files /dev/null and b/bin/res/drawable-hdpi/ic_launcher.png differ
diff --git a/bin/res/drawable-ldpi/ic_launcher.png b/bin/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..126ba84
Binary files /dev/null and b/bin/res/drawable-ldpi/ic_launcher.png differ
diff --git a/bin/res/drawable-mdpi/ic_launcher.png b/bin/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..7cbd792
Binary files /dev/null and b/bin/res/drawable-mdpi/ic_launcher.png differ
diff --git a/bin/res/drawable-xhdpi/ic_launcher.png b/bin/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..d5713d3
Binary files /dev/null and b/bin/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/bin/resources.ap_ b/bin/resources.ap_
new file mode 100644
index 0000000..9ecf3e9
Binary files /dev/null and b/bin/resources.ap_ differ
diff --git a/gen/it/gaiacri/mobile/BuildConfig.java b/gen/it/gaiacri/mobile/BuildConfig.java
new file mode 100644
index 0000000..6b2ff84
--- /dev/null
+++ b/gen/it/gaiacri/mobile/BuildConfig.java
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package it.gaiacri.mobile;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
\ No newline at end of file
diff --git a/gen/it/gaiacri/mobile/R.java b/gen/it/gaiacri/mobile/R.java
new file mode 100644
index 0000000..1e9a6c1
--- /dev/null
+++ b/gen/it/gaiacri/mobile/R.java
@@ -0,0 +1,86 @@
+/* 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 it.gaiacri.mobile;
+
+public final class R {
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int ic_launcher=0x7f020000;
+ }
+ public static final class id {
+ public static final int button1=0x7f07000a;
+ public static final int email=0x7f070004;
+ public static final int login=0x7f070006;
+ public static final int login_form=0x7f070002;
+ public static final int login_status=0x7f070000;
+ public static final int login_status_message=0x7f070001;
+ public static final int menu_forgot_password=0x7f07000b;
+ public static final int menu_settings=0x7f07000c;
+ public static final int password=0x7f070005;
+ public static final int sign_in_button=0x7f070007;
+ public static final int textView1=0x7f070008;
+ public static final int textView2=0x7f070009;
+ public static final int textView3=0x7f070003;
+ }
+ public static final class layout {
+ public static final int activity_accesso=0x7f030000;
+ public static final int activity_menu_principale=0x7f030001;
+ }
+ public static final class menu {
+ public static final int activity_accesso=0x7f060000;
+ public static final int activity_menu_principale=0x7f060001;
+ }
+ public static final class string {
+ public static final int action_sign_in_register=0x7f040006;
+ public static final int action_sign_in_short=0x7f040007;
+ public static final int app_name=0x7f040000;
+ public static final int error_field_required=0x7f04000d;
+ public static final int error_incorrect_password=0x7f04000c;
+ public static final int error_invalid_email=0x7f04000a;
+ public static final int error_invalid_password=0x7f04000b;
+ public static final int hello_world=0x7f040001;
+ public static final int login_progress_signing_in=0x7f040009;
+ public static final int menu_forgot_password=0x7f040008;
+ public static final int menu_settings=0x7f040002;
+ /** Strings related to login
+ */
+ public static final int prompt_email=0x7f040004;
+ public static final int prompt_password=0x7f040005;
+ public static final int title_activity_menu_principale=0x7f040003;
+ }
+ public static final class style {
+ /**
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+
+
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+
+
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+
+ API 11 theme customizations can go here.
+
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+
+ API 14 theme customizations can go here.
+ */
+ public static final int AppBaseTheme=0x7f050000;
+ /** Application theme.
+ All customizations that are NOT specific to a particular API-level can go here.
+ */
+ public static final int AppTheme=0x7f050001;
+ public static final int LoginFormContainer=0x7f050002;
+ }
+}
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
new file mode 100644
index 0000000..22660c6
Binary files /dev/null and b/ic_launcher-web.png differ
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
new file mode 100644
index 0000000..6080877
Binary files /dev/null and b/libs/android-support-v4.jar differ
diff --git a/proguard-project.txt b/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/project.properties b/project.properties
new file mode 100644
index 0000000..a3ee5ab
--- /dev/null
+++ b/project.properties
@@ -0,0 +1,14 @@
+# 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 edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-17
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..52cbae9
Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ
diff --git a/res/drawable-ldpi/ic_launcher.png b/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..79e725a
Binary files /dev/null and b/res/drawable-ldpi/ic_launcher.png differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c6df91c
Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..8d2d134
Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/res/layout/activity_accesso.xml b/res/layout/activity_accesso.xml
new file mode 100644
index 0000000..c58008e
--- /dev/null
+++ b/res/layout/activity_accesso.xml
@@ -0,0 +1,98 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/activity_menu_principale.xml b/res/layout/activity_menu_principale.xml
new file mode 100644
index 0000000..a777aa7
--- /dev/null
+++ b/res/layout/activity_menu_principale.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/menu/activity_accesso.xml b/res/menu/activity_accesso.xml
new file mode 100644
index 0000000..c13ef3c
--- /dev/null
+++ b/res/menu/activity_accesso.xml
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/res/menu/activity_menu_principale.xml b/res/menu/activity_menu_principale.xml
new file mode 100644
index 0000000..77f358b
--- /dev/null
+++ b/res/menu/activity_menu_principale.xml
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/res/values-large/styles.xml b/res/values-large/styles.xml
new file mode 100644
index 0000000..acd524d
--- /dev/null
+++ b/res/values-large/styles.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml
new file mode 100644
index 0000000..541752f
--- /dev/null
+++ b/res/values-v11/styles.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml
new file mode 100644
index 0000000..f20e015
--- /dev/null
+++ b/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..7e5075a
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,9 @@
+
+
+
+ Gaia Mobile
+ Hello world!
+ Settings
+ MenuPrincipale
+
+
\ No newline at end of file
diff --git a/res/values/strings_activity_accesso.xml b/res/values/strings_activity_accesso.xml
new file mode 100644
index 0000000..3a72265
--- /dev/null
+++ b/res/values/strings_activity_accesso.xml
@@ -0,0 +1,15 @@
+
+
+
+ Email
+ Password
+ Accedi a Gaia
+ Accedi
+ Password dimenticata
+ Accesso in corso…
+ Email non valida
+ Password troppo corta
+ Email o password non valida
+ Campo obbligatorio
+
+
\ No newline at end of file
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644
index 0000000..bd995f9
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/it/gaiacri/mobile/Accesso.java b/src/it/gaiacri/mobile/Accesso.java
new file mode 100644
index 0000000..f70f53e
--- /dev/null
+++ b/src/it/gaiacri/mobile/Accesso.java
@@ -0,0 +1,323 @@
+package it.gaiacri.mobile;
+
+import java.util.HashMap;
+
+import org.json.JSONException;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.TextView;
+
+/**
+ * Activity which displays a login screen to the user, offering registration as
+ * well.
+ */
+public class Accesso extends Activity {
+
+ /**
+ * The default email to populate the email field with.
+ */
+ public static final String EXTRA_EMAIL = "com.example.android.authenticatordemo.extra.EMAIL";
+
+ /**
+ * Keep track of the login task to ensure we can cancel it if requested.
+ */
+ private Richiesta rLogin = null;
+ private Richiesta hello = null;
+
+ // Values for email and password at the time of the login attempt.
+ private String mEmail;
+ private String mPassword;
+
+ // UI references.
+ private EditText mEmailView;
+ private EditText mPasswordView;
+ private View mLoginFormView;
+ private View mLoginStatusView;
+ private TextView mLoginStatusMessageView;
+
+ public Context contesto;
+
+ public SharedPreferences sharedPref;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setTitle("Entra in Gaia");
+ setContentView(R.layout.activity_accesso);
+
+ contesto = getBaseContext();
+
+ // Set up the login form.
+ mEmail = getIntent().getStringExtra(EXTRA_EMAIL);
+ mEmailView = (EditText) findViewById(R.id.email);
+ mEmailView.setText(mEmail);
+
+ mPasswordView = (EditText) findViewById(R.id.password);
+ mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
+ if (id == R.id.login || id == EditorInfo.IME_NULL) {
+ try {
+ attemptLogin();
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ Log.e("gaia", "Errore di JSON");
+
+ }
+
+ return true;
+ }
+ return false;
+ }
+ });
+
+
+ sharedPref = this.getSharedPreferences("LOGIN", Context.MODE_PRIVATE);
+ String sid;
+
+ try {
+ sid = sharedPref.getString("sid", null);
+ } catch (Exception e) {
+ sid = "";
+ }
+
+ HashMap data = new HashMap();
+ data.put("sid", sid);
+ RichiestaWelcome hello = new RichiestaWelcome(data);
+ hello.execute();
+
+
+
+
+
+
+ mLoginFormView = findViewById(R.id.login_form);
+ mLoginStatusView = findViewById(R.id.login_status);
+ mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);
+
+ findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ try {
+ attemptLogin();
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ Log.e("gaia", "Errore di JSON");
+
+ }
+ }
+ });
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+ getMenuInflater().inflate(R.menu.activity_accesso, menu);
+ return true;
+ }
+
+ /**
+ * Attempts to sign in or register the account specified by the login form.
+ * If there are form errors (invalid email, missing fields, etc.), the
+ * errors are presented and no actual login attempt is made.
+ * @throws JSONException
+ */
+ public void attemptLogin() throws JSONException {
+
+
+ // Reset errors.
+ mEmailView.setError(null);
+ mPasswordView.setError(null);
+
+ // Store values at the time of the login attempt.
+ mEmail = mEmailView.getText().toString();
+ mPassword = mPasswordView.getText().toString();
+
+ boolean cancel = false;
+ View focusView = null;
+
+ // Check for a valid password.
+ if (TextUtils.isEmpty(mPassword)) {
+ mPasswordView.setError(getString(R.string.error_field_required));
+ focusView = mPasswordView;
+ cancel = true;
+ } else if (mPassword.length() < 4) {
+ mPasswordView.setError(getString(R.string.error_invalid_password));
+ focusView = mPasswordView;
+ cancel = true;
+ }
+
+ // Check for a valid email address.
+ if (TextUtils.isEmpty(mEmail)) {
+ mEmailView.setError(getString(R.string.error_field_required));
+ focusView = mEmailView;
+ cancel = true;
+ } else if (!mEmail.contains("@")) {
+ mEmailView.setError(getString(R.string.error_invalid_email));
+ focusView = mEmailView;
+ cancel = true;
+ }
+
+ if (cancel) {
+ // There was an error; don't attempt login and focus the first
+ // form field with an error.
+ focusView.requestFocus();
+ } else {
+ // Show a progress spinner, and kick off a background task to
+ // perform the user login attempt.
+ mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
+ showProgress(true);
+
+ HashMap data = new HashMap();
+ data.put("email", mEmail);
+ data.put("password", mPassword);
+ RichiestaLogin rLogin = new RichiestaLogin(data);
+ rLogin.execute();
+
+ }
+ }
+
+ public class RichiestaLogin extends Richiesta {
+
+ public String metodo() { return "login"; }
+
+
+ public RichiestaLogin(HashMap data) {
+ super(data);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected void onPostExecute(String str) {
+
+ try {
+ if ( risposta.getBoolean("login") ) {
+ //showProgress(false);
+ Log.i("Login", "Riuscito");
+ Log.i("Utente", utente.getString("nome"));
+ SharedPreferences.Editor editor = sharedPref.edit();
+ editor.putString("sid", getSid());
+ editor.commit();
+ Intent myIntent = new Intent(contesto, MenuPrincipale.class);
+ myIntent.putExtra("sid", getSid());
+ startActivity(myIntent);
+
+ } else {
+ Log.i("Login", "Fallito");
+ erroreLogin();
+
+
+ }
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+ public class RichiestaWelcome extends Richiesta {
+
+ public String metodo() { return "welcome"; }
+
+ public RichiestaWelcome(HashMap data) {
+ super(data);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected void onPostExecute(String str) {
+
+ SharedPreferences.Editor editor = sharedPref.edit();
+ editor.putString("sid", getSid());
+ editor.commit();
+
+ if ( utente != null ) {
+ Log.e("Login", "Gia Identificato");
+
+ Intent myIntent = new Intent(contesto, MenuPrincipale.class);
+ myIntent.putExtra("sid", getSid());
+ startActivity(myIntent);
+ } else {
+ Log.e("Login", "Non gia Identificato");
+
+ }
+ }
+
+ }
+
+
+ public void erroreLogin() {
+ try {
+
+ if ( mPasswordView != null ) {
+ mPasswordView.setError(getString(R.string.error_incorrect_password));
+ mPasswordView.requestFocus();
+ }
+ showProgress(false);
+ } catch (Exception e) {
+ Log.e("Errore", "Generico");
+ }
+ }
+ /**
+ * Shows the progress UI and hides the login form.
+ */
+ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
+ public void showProgress(final boolean show) {
+ // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
+ // for very easy animations. If available, use these APIs to fade-in
+ // the progress spinner.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
+ int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
+
+ mLoginStatusView.setVisibility(View.VISIBLE);
+ mLoginStatusView.animate()
+ .setDuration(shortAnimTime)
+ .alpha(show ? 1 : 0)
+ .setListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
+ }
+ });
+
+ mLoginFormView.setVisibility(View.VISIBLE);
+ mLoginFormView.animate()
+ .setDuration(shortAnimTime)
+ .alpha(show ? 0 : 1)
+ .setListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
+ }
+ });
+ } else {
+ // The ViewPropertyAnimator APIs are not available, so simply show
+ // and hide the relevant UI components.
+ mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
+ mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
+ }
+ }
+
+
+}
diff --git a/src/it/gaiacri/mobile/MenuPrincipale.java b/src/it/gaiacri/mobile/MenuPrincipale.java
new file mode 100644
index 0000000..6f44c8b
--- /dev/null
+++ b/src/it/gaiacri/mobile/MenuPrincipale.java
@@ -0,0 +1,30 @@
+package it.gaiacri.mobile;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.util.Log;
+import android.view.Menu;
+
+public class MenuPrincipale extends Activity {
+
+ public String sid = "";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_menu_principale);
+
+ sid = getIntent().getExtras().getString("sid");
+
+ Log.i("sid", sid);
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.activity_menu_principale, menu);
+ return true;
+ }
+
+}
diff --git a/src/it/gaiacri/mobile/Richiesta.java b/src/it/gaiacri/mobile/Richiesta.java
new file mode 100644
index 0000000..2a0341c
--- /dev/null
+++ b/src/it/gaiacri/mobile/Richiesta.java
@@ -0,0 +1,119 @@
+package it.gaiacri.mobile;
+
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
+import android.util.Log;
+
+public class Richiesta extends AsyncTask {
+ private HashMap mData = null;// post data
+
+ private static String sid = "";
+ public static String base = "http://www.gaiacri.it/api.php?a=";
+ public JSONObject risposta = null;
+ public JSONObject utente = null;
+
+ /**
+ * constructor
+ */
+ public Richiesta(HashMap data) {
+ mData = data;
+ }
+
+
+ public String metodo() { return "welcome"; }
+
+ /**
+ * background
+ */
+ @Override
+ protected String doInBackground(String... params) {
+ byte[] result = null;
+ String str = "";
+ HttpClient client = new DefaultHttpClient();
+ HttpPost post = new HttpPost(base + metodo() );// in this case, params[0] is URL
+ try {
+
+
+ // set up post data
+ ArrayList nameValuePair = new ArrayList();
+ nameValuePair.add(new BasicNameValuePair("sid", getSid()));
+ Iterator it = mData.keySet().iterator();
+ while (it.hasNext()) {
+ String key = it.next();
+ nameValuePair.add(new BasicNameValuePair(key, mData.get(key)));
+ }
+ post.setEntity(new UrlEncodedFormEntity(nameValuePair, "UTF-8"));
+ HttpResponse response = client.execute(post);
+ StatusLine statusLine = response.getStatusLine();
+ if(statusLine.getStatusCode() == HttpURLConnection.HTTP_OK){
+ result = EntityUtils.toByteArray(response.getEntity());
+ str = new String(result, "UTF-8");
+ }
+ }
+ catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ }
+ catch (Exception e) {
+ Log.e("Gaia", "probabilmente non c'è internet");
+ }
+ try {
+ risposta = new JSONObject(str);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ Log.e("Gaia", "Errore di comunicazione col server");
+ }
+ try {
+ Log.e("Gaia", risposta.getJSONObject("session").getString("id"));
+ setSid(risposta.getJSONObject("session").getString("id"));
+
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ Log.i("Gaia", str);
+ try {
+ utente = risposta.getJSONObject("session").optJSONObject("user");
+ risposta = risposta.getJSONObject("response");
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //onPostExecute(str);
+ return str;
+ }
+
+ /**
+ * on getting result
+ */
+ @Override
+ protected void onPostExecute(String result) {
+ }
+
+ public static String getSid() {
+ return sid;
+ }
+
+ public static void setSid(String sid) {
+ Richiesta.sid = sid;
+ }
+
+}