From 8e588bbed7b3de7e7b936bfc870cd09fa26d1b4d Mon Sep 17 00:00:00 2001
From: darshanxyz <darshanxyz@gmail.com>
Date: Mon, 24 Apr 2017 00:38:01 +0530
Subject: [PATCH] Better UI

---
 .../odsystem/CustomListAdapter.java           | 13 +++-
 .../darshanbshah/odsystem/MainActivity.java   | 11 +--
 .../odsystem/TeacherActivity.java             | 49 ++++++++----
 app/src/main/res/layout/activity_teacher.xml  | 58 ++++++++------
 app/src/main/res/layout/list_item.xml         | 77 +++++++++++++++++--
 app/src/main/res/values/colors.xml            |  6 +-
 6 files changed, 154 insertions(+), 60 deletions(-)

diff --git a/app/src/main/java/com/darshanbshah/odsystem/CustomListAdapter.java b/app/src/main/java/com/darshanbshah/odsystem/CustomListAdapter.java
index 7e39b98..3fd6a20 100644
--- a/app/src/main/java/com/darshanbshah/odsystem/CustomListAdapter.java
+++ b/app/src/main/java/com/darshanbshah/odsystem/CustomListAdapter.java
@@ -23,7 +23,7 @@ public class CustomListAdapter extends ArrayAdapter {
 
 
     static class DataHandler {
-        TextView tv, tv1;
+        TextView tv, tv1, tv2, tv3, tv4;
     }
 
     List list = new ArrayList();
@@ -65,7 +65,9 @@ public class CustomListAdapter extends ArrayAdapter {
             row = inflater.inflate(R.layout.list_item, parent, false);
             handler = new DataHandler();
             handler.tv = (TextView)row.findViewById(R.id.listText);
-            handler.tv1 = (TextView)row.findViewById(R.id.listTextEmail);
+            handler.tv1 = (TextView)row.findViewById(R.id.listTextReason);
+            handler.tv2 = (TextView)row.findViewById(R.id.fromText);
+            handler.tv3 = (TextView)row.findViewById(R.id.toText);
             row.setTag(handler);
         }
         else {
@@ -76,8 +78,13 @@ public class CustomListAdapter extends ArrayAdapter {
         DataProvider provider = (DataProvider) this.getItem(position);
         handler.tv.setText(provider.getRollno());
         handler.tv1.setText(provider.getReason());
+        handler.tv2.setText(provider.getFrom());
+        handler.tv3.setText(provider.getTo());
 //        handler.tv.setTypeface(one);
-        handler.tv.setTextSize(20);
+        handler.tv.setTextSize(30);
+        handler.tv1.setTextSize(20);
+        handler.tv2.setTextSize(20);
+        handler.tv3.setTextSize(20);
         return row;
     }
 }
diff --git a/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java b/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java
index ece9905..90027b3 100644
--- a/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java
+++ b/app/src/main/java/com/darshanbshah/odsystem/MainActivity.java
@@ -260,16 +260,7 @@ public class MainActivity extends AppCompatActivity {
 
 //        recepient = list1.get(0);
 //
-//        Intent intent = new Intent(Intent.ACTION_SEND);
-//        intent.setData(Uri.parse("mailto:"));
-//
-//        Log.e("Recepient", recepient);
-//        intent.putExtra(Intent.EXTRA_EMAIL, recepient);
-//        intent.putExtra(Intent.EXTRA_SUBJECT, "OD Request");
-//        intent.putExtra(Intent.EXTRA_TEXT, "Reason: " + reasonString + '\n' + "From: " + fromDate + '\n' + "To: " + toDate + '\n' + "Full day: " + full);
-//        intent.setType("message/rfc822");
-//        Intent chooser = Intent.createChooser(intent, "Send email");
-//        startActivity(chooser);
+
 
 
         Log.e("DATA: ", reasonString + ", " + fromDate + ", " + toDate + ", " + full);
diff --git a/app/src/main/java/com/darshanbshah/odsystem/TeacherActivity.java b/app/src/main/java/com/darshanbshah/odsystem/TeacherActivity.java
index cf3744d..29bfd03 100644
--- a/app/src/main/java/com/darshanbshah/odsystem/TeacherActivity.java
+++ b/app/src/main/java/com/darshanbshah/odsystem/TeacherActivity.java
@@ -3,12 +3,15 @@ package com.darshanbshah.odsystem;
 import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.graphics.Color;
+import android.net.Uri;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.ListView;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.google.firebase.auth.FirebaseAuth;
@@ -38,6 +41,7 @@ public class TeacherActivity extends AppCompatActivity {
         }
 
     }
+    String []recepients = {};
     ODTable table;
     int i = 0;
     AlertDialog.Builder builder;
@@ -154,30 +158,34 @@ public class TeacherActivity extends AppCompatActivity {
                 }
                 for (DataSnapshot data : dataSnapshot.getChildren()) {
                     for (DataSnapshot d : data.getChildren()) {
-                        Log.e("DATA_KEY", dataSnapshot.getKey());
-                        if (dataSnapshot.getKey().equals(adv_name))
+                        if (dataSnapshot.getKey().equals(adv_name)) {
+                            Log.e("D_VAL", d.getValue().toString());
                             random.add(d.getValue().toString());
+                        }
+
                     }
 //                    for (int i = 0; i < random.size(); i++) {
 //                        Log.e("RANDOM_VALS", data.getKey() + ' ' + random.get(i));
 //
 //                    }
-                    if (random.size() != 0) {
-                        try {
-                            flag = random.get(0);
-                            from = random.get(1);
-                            fullday = random.get(2);
-                            reason = random.get(3);
-                            to = random.get(4);
-                            table = new ODTable(flag, reason, from, to, fullday);
-                            odtable.put(data.getKey(), table);
-                            random.clear();
-                        }
-                        catch (Exception e) {
+                    for (int i = 0; i < random.size(); i++) {
+                        if (random.size() != 0) {
+                            try {
+                                flag = random.get(0);
+                                from = random.get(1);
+                                fullday = random.get(2);
+                                reason = random.get(3);
+                                to = random.get(4);
+                                table = new ODTable(flag, reason, from, to, fullday);
+                                odtable.put(data.getKey(), table);
+                            }
+                            catch (Exception e) {
 
-                        }
+                            }
 
+                        }
                     }
+                    random.clear();
 
                 }
 
@@ -269,6 +277,17 @@ public class TeacherActivity extends AppCompatActivity {
 
                             }
                         });
+                        TextView textView = (TextView)findViewById(R.id.listText);
+                        textView.setTextColor(Color.parseColor("#12bfac"));
+                        Intent intent = new Intent(Intent.ACTION_SEND);
+                        intent.setData(Uri.parse("mailto:"));
+
+                        intent.putExtra(Intent.EXTRA_EMAIL, recepients);
+                        intent.putExtra(Intent.EXTRA_SUBJECT, "OD Request");
+                        intent.putExtra(Intent.EXTRA_TEXT, "Reason: " + reason + '\n' + "From: " + from + '\n' + "To: " + to + '\n' + "Full day: " + fullday);
+                        intent.setType("message/rfc822");
+                        Intent chooser = Intent.createChooser(intent, "Send email");
+                        startActivity(chooser);
                     }
                 });
                 itemValue = (DataProvider) adapter.getItem(position);
diff --git a/app/src/main/res/layout/activity_teacher.xml b/app/src/main/res/layout/activity_teacher.xml
index 9e00d13..7ec6d4e 100644
--- a/app/src/main/res/layout/activity_teacher.xml
+++ b/app/src/main/res/layout/activity_teacher.xml
@@ -6,24 +6,48 @@
     android:layout_height="match_parent"
     tools:context="com.darshanbshah.odsystem.TeacherActivity">
 
-    <Button
-        android:text="Logout"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:id="@+id/button2"
-        android:onClick="signOut"
-        android:layout_alignParentTop="true"
-        android:layout_alignParentEnd="true"
-        style="@style/Widget.AppCompat.Button.Borderless.Colored" />
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:background="@color/colorPrimary"
+        android:id="@+id/topHolder"
+        android:layout_height="55dp">
+
+        <TextView
+            android:text="Pending ODs"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="12dp"
+            android:id="@+id/pendingTitle"
+            android:textAppearance="@style/TextAppearance.AppCompat.Display1"
+            android:layout_alignBottom="@+id/button2"
+            android:layout_alignParentStart="true"
+            android:layout_weight="1"
+            android:textColor="#FFF"
+            android:layout_gravity="center_vertical"/>
+
+        <Button
+            android:text="Logout"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/button2"
+            android:onClick="signOut"
+            android:layout_alignParentTop="true"
+            android:layout_alignParentEnd="true"
+            style="@style/Widget.AppCompat.Button.Borderless.Colored"
+            android:layout_weight="1"
+            android:layout_gravity="center_vertical"/>
+
+    </LinearLayout>
 
     <ScrollView
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_below="@+id/button2"
-        android:layout_alignParentStart="true"
+
         android:layout_marginLeft="@dimen/activity_horizontal_margin"
         android:layout_marginRight="@dimen/activity_horizontal_margin"
-        android:layout_marginTop="41dp">
+        android:layout_below="@+id/topHolder"
+        android:layout_centerHorizontal="true">
 
         <LinearLayout
             android:layout_width="match_parent"
@@ -40,14 +64,4 @@
         </LinearLayout>
     </ScrollView>
 
-    <TextView
-        android:text="Pending ODs"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="12dp"
-        android:id="@+id/pendingTitle"
-        android:textAppearance="@style/TextAppearance.AppCompat.Display1"
-        android:layout_alignBottom="@+id/button2"
-        android:layout_alignParentStart="true" />
-
 </RelativeLayout>
diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml
index 0342242..55b7a51 100644
--- a/app/src/main/res/layout/list_item.xml
+++ b/app/src/main/res/layout/list_item.xml
@@ -2,19 +2,82 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:layout_marginTop="@dimen/activity_vertical_margin"
+    android:layout_marginTop="1dp"
+    android:layout_marginBottom="1dp"
     android:id="@+id/list_item">
-    
+
     <TextView
         android:id="@+id/listText"
         android:layout_width="match_parent"
-        android:layout_height="60dp"
+        android:layout_height="wrap_content"
         />
 
-    <TextView
-        android:id="@+id/listTextEmail"
+    <LinearLayout
+        android:orientation="horizontal"
         android:layout_width="match_parent"
-        android:layout_height="40dp"
-        />
+        android:layout_height="wrap_content">
+
+        <TextView
+            android:text="Reason: "
+            android:layout_height="wrap_content"
+            android:id="@+id/reasonLabel"
+            android:layout_weight="1"
+            android:textStyle="normal|bold"
+            android:textSize="20dp"
+            android:layout_width="150dp"
+            android:textAlignment="textStart" />
+
+        <TextView
+            android:id="@+id/listTextReason"
+            android:layout_height="wrap_content"
+            android:textAlignment="viewStart"
+            android:layout_width="200dp" />
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <TextView
+            android:text="From: "
+            android:layout_width="150dp"
+            android:layout_height="wrap_content"
+            android:id="@+id/fromLabel"
+            android:textStyle="normal|bold"
+            android:textSize="20dp"
+            android:textAlignment="viewStart" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/fromText"
+            android:layout_weight="1.82"
+            android:textAlignment="viewStart" />
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <TextView
+            android:text="To: "
+            android:layout_width="150dp"
+            android:layout_height="wrap_content"
+            android:id="@+id/toLabel"
+            android:textStyle="normal|bold"
+            android:textSize="20dp"
+            android:textAlignment="viewStart" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/toText"
+            android:layout_weight="1"
+            android:textAlignment="viewStart" />
+    </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index fbe1e87..ffb9e63 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <color name="colorPrimary">#3f51b5</color>
-    <color name="colorPrimaryDark">#303F9F</color>
-    <color name="colorAccent">#ff4081</color>
+    <color name="colorPrimary">#393939</color>
+    <color name="colorPrimaryDark">#393939</color>
+    <color name="colorAccent">#12bfac</color>
 </resources>
-- 
GitLab