]> iEval git - unical.git/commitdiff
Add login screen
authorPetru Trimbitas <l3asketballplayer@yahoo.com>
Tue, 28 May 2013 16:10:43 +0000 (19:10 +0300)
committerPetru Trimbitas <l3asketballplayer@yahoo.com>
Tue, 28 May 2013 16:10:43 +0000 (19:10 +0300)
AndroidManifest.xml
res/layout/login.xml
res/menu/options.xml [new file with mode: 0644]
src/ro/ieval/unical/Utils.java [new file with mode: 0644]
src/ro/ieval/unical/loginActivity.java [new file with mode: 0644]
src/ro/ieval/unical/mainActivity.java

index bb15f7194847bec06b62d30d0cad33e6da6bcce0..9d72139cb125589287b30451c604daa322ceab23 100644 (file)
@@ -23,6 +23,7 @@
         </activity>
         <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
         <activity android:name="com.facebook.LoginActivity"></activity>
+        <activity android:name="loginActivity"></activity>
     </application>
 
 </manifest>
\ No newline at end of file
index d629a53f71c0a02cd63886c274481f41cd62fd1b..0a9ac6103d9575159f0450145d60fddd8d619877 100644 (file)
@@ -5,9 +5,60 @@
     android:orientation="vertical" >
 
     <TextView
-        android:id="@+id/welcome"
-        android:layout_width="122dp"
+        android:id="@+id/textView1"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:text="TextView" />
+        android:text="Log in"
+        android:textAlignment="center"
+        android:textAppearance="?android:attr/textAppearanceLarge" />
 
-</LinearLayout>
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0.00" >
+
+        <TextView
+            android:id="@+id/textView2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="User:"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
+        <EditText
+            android:id="@+id/editText1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:ems="10" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" >
+
+        <TextView
+            android:id="@+id/textView3"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="Pass:"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
+        <EditText
+            android:id="@+id/editText2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.62"
+            android:ems="10"
+            android:inputType="textPassword" >
+
+            <requestFocus />
+        </EditText>
+    </LinearLayout>
+
+    <Button
+        android:id="@+id/button1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Log In" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/menu/options.xml b/res/menu/options.xml
new file mode 100644 (file)
index 0000000..04f173f
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:id="@+id/item1" android:title="New Event" android:visible="true"></item>
+    
+
+</menu>
diff --git a/src/ro/ieval/unical/Utils.java b/src/ro/ieval/unical/Utils.java
new file mode 100644 (file)
index 0000000..4976605
--- /dev/null
@@ -0,0 +1,8 @@
+package ro.ieval.unical;
+
+public class Utils {
+       public static boolean loginSuccess(String user, String pass) {
+               // TODO Auto-generated method stub
+               return true;
+       }
+}
diff --git a/src/ro/ieval/unical/loginActivity.java b/src/ro/ieval/unical/loginActivity.java
new file mode 100644 (file)
index 0000000..a4ac90b
--- /dev/null
@@ -0,0 +1,31 @@
+package ro.ieval.unical;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+
+public class loginActivity extends Activity {
+       
+       @Override
+       protected void onCreate(Bundle savedInstanceState) {
+               super.onCreate(savedInstanceState);
+               setContentView(R.layout.login);
+               
+               final EditText user=(EditText) findViewById(R.id.editText1);
+               final EditText pass=(EditText) findViewById(R.id.editText2);
+               final Button logIn=(Button) findViewById(R.id.button1);
+       
+               logIn.setOnClickListener(new View.OnClickListener() {
+                       
+                       @Override
+                       public void onClick(View v) {
+                               // TODO Auto-generated method stub
+                               if(Utils.loginSuccess(user.getText().toString(),pass.getText().toString())) {
+                                       setContentView(R.layout.eventview);
+                               }
+                       }
+               });
+       }
+}
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.037755 seconds and 4 git commands to generate.