Add login screen
[unical.git] / src / ro / ieval / unical / mainActivity.java
index 8faac6623bf56904f70b673b3c3760dce2f8e8b3..e65b571f5160e9bedcd8d4bb9b5eef3dc66e2cee 100644 (file)
@@ -15,10 +15,14 @@ import ro.ieval.unical.R;
 import com.google.gson.Gson;
 
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.graphics.Color;
 import android.os.Bundle;
 import android.os.Handler;
+import android.preference.PreferenceManager;
 import android.util.Base64;
+import android.view.View;
+import android.widget.Button;
 import android.widget.EditText;
 import android.widget.TextView;
 
@@ -27,69 +31,19 @@ import com.facebook.*;
 import com.facebook.model.*;
 
 public class mainActivity extends android.app.Activity {
-       Event[] getEventList() {
-               Event events[];
-               URL hostUrlJson;
-               InputStreamReader in;
-               try {
-                       hostUrlJson=new URL(Constants.searchUrl);
-                       HttpsURLConnection calConnection = (HttpsURLConnection) hostUrlJson.openConnection();
-                       calConnection.setDoOutput(true);
-                       calConnection.setUseCaches(false);
-                       calConnection.setRequestProperty("Authorization", "Basic "+Base64.encodeToString( (Constants.user+':'+Constants.password).getBytes(), Base64.NO_WRAP));
-                       //calConnection.setRequestMethod("POST");
-                       //calConnection.setDoInput(true);
-                       //calConnection.connect();
-
-                       final PrintWriter ps=new PrintWriter(calConnection.getOutputStream());
-                       ps.print("{}");
-                       ps.close();
-
-                       in = new InputStreamReader(calConnection.getInputStream());
-                       Gson gson=new Gson();
-                       events=gson.fromJson(in,Event[].class);
-                       in.close();
-
-                       return events;
-               } catch (MalformedURLException e) {
-                       // TODO Auto-generated catch block
-                       System.err.println("catch1");
-                       e.printStackTrace();
-               } catch (IOException e) {
-                       // TODO Auto-generated catch block
-                       System.err.println("catch2");
-                       e.printStackTrace();
-               }
-               throw new AssertionError();
-       }
        
        @Override
        protected void onCreate(Bundle savedInstanceState) {
                // All Begins here :)
                // And here it began the olympic app that does olympic thing
-               super.onCreate(savedInstanceState);
-               setContentView(R.layout.login);
                
-               /*setContentView(R.layout.eventview);
-               final TextView eventTitle= (TextView) findViewById(R.id.eventTitle);
-               final TextView date=(TextView) findViewById(R.id.date);
-               final TextView description=(TextView) findViewById(R.id.description);
-
-               final Handler h=new Handler();
-               new Thread(new Runnable() {
-                       public void run() {
-                               final Event events[]=getEventList();
-                               h.post(new Runnable() {
-                                       public void run() {
-                                               // aici incepe
-                                               
-                                               eventTitle.setText(events[0].title);
-                                               date.setText((new Date(events[0].date)).toString());
-                                               description.setText(events[0].description);
-                                               DatabaseInteract db=new DatabaseInteract(mainActivity.this);
-                                       }
-                               });
-                       }
-               }).start();*/
+               //log in
+               super.onCreate(savedInstanceState);
+               final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this);
+               if(prefs.getBoolean("FirstTime", true)) {
+                       prefs.edit().putBoolean("FirstTime", false).commit();
+                       Intent i=new Intent(this,loginActivity.class);
+                       startActivity(i);
+               }
        }
 }
This page took 0.011291 seconds and 4 git commands to generate.