Create M.A.S.A. Mobile version 1.0

This commit is contained in:
Reynaldo Reyes
2016-04-11 00:07:15 -04:30
parent 65363449e3
commit 7c08da98e2
12 changed files with 431 additions and 125 deletions

View File

@@ -64,13 +64,11 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/.git" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />

View File

@@ -23,12 +23,16 @@ public class CourseActivity extends ListActivity {
private ProgressDialog pDialog; private ProgressDialog pDialog;
ArrayList<HashMap<String, String>> courseList; ArrayList<HashMap<String, String>> courseList;
JSONArray course = null; JSONArray courses;
private static final String URL = "http://192.168.0.101:3000/courses"; JSONObject professor;
String JSONString;
private static final String COURSE = "courses";
private static final String URL = "http://192.168.0.106:3000/professors/56f5fd3a20047f3c15b05f0e";
private static final String TAG_ID = "_id"; private static final String TAG_ID = "_id";
private static final String TAG_NAME = "name"; private static final String TAG_NAME = "name";
private static final String TAG_CODE = "code"; private static final String TAG_CODE = "code";
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -66,7 +70,6 @@ public class CourseActivity extends ListActivity {
protected String doInBackground(String... args) { protected String doInBackground(String... args) {
ServiceHandler sh = new ServiceHandler(); ServiceHandler sh = new ServiceHandler();
String JSONString = null;
try { try {
JSONString = sh.getServiceCall(URL); JSONString = sh.getServiceCall(URL);
} catch (IOException e) { } catch (IOException e) {
@@ -74,20 +77,20 @@ public class CourseActivity extends ListActivity {
} }
try { try {
course = new JSONArray(JSONString); professor = new JSONObject(JSONString);
if (professor.has(COURSE)) {
for (int i = 0; i < course.length(); i++) { courses = professor.getJSONArray(COURSE);
JSONObject c = course.getJSONObject(i); for (int i = 0; i < courses.length(); i++) {
String id = c.getString(TAG_ID); JSONObject c = courses.getJSONObject(i);
String name = c.getString(TAG_NAME); String id = c.getString(TAG_ID);
String code = c.getString(TAG_CODE); String name = c.getString(TAG_NAME);
String code = c.getString(TAG_CODE);
HashMap<String, String> map = new HashMap<String, String>(); HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_ID, id); map.put(TAG_ID, id);
map.put(TAG_NAME, name); map.put(TAG_NAME, name);
map.put(TAG_CODE, code); map.put(TAG_CODE, code);
courseList.add(map);
courseList.add(map); }
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -6,13 +6,9 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.content.Intent; import android.content.Intent;
import android.bluetooth.BluetoothAdapter;
public class MainActivity extends ActionBarActivity { public class MainActivity extends ActionBarActivity {
public static final int REQUEST_ENABLE_BT = 1;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -38,23 +34,8 @@ public class MainActivity extends ActionBarActivity {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
//Called when the user clicks on Scan
public void scanPhones (View view) {
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
Intent intent = new Intent(this, ScanActivity.class);
startActivity(intent);
}
//Called when the user clicks on Listar Materias //Called when the user clicks on Listar Materias
public void adminScreen (View view) { public void courseScreen (View view) {
Intent intent = new Intent(this, CourseActivity.class); Intent intent = new Intent(this, CourseActivity.class);
startActivity(intent); startActivity(intent);
} }

View File

@@ -23,8 +23,12 @@ public class SectionActivity extends ListActivity {
private ProgressDialog pDialog; private ProgressDialog pDialog;
ArrayList<HashMap<String, String>> sectionList; ArrayList<HashMap<String, String>> sectionList;
String course_id, course_name; JSONArray courses,sections;
private static final String URL = "http://192.168.0.101:3000/sections"; JSONObject professor;
String JSONString, course_id, course_name;
private static final String COURSE = "courses";
private static final String SECTION = "sections";
private static final String URL = "http://192.168.0.106:3000/professors/56f5fd3a20047f3c15b05f0e";
private static final String TAG_ID = "_id"; private static final String TAG_ID = "_id";
private static final String TAG_NAME = "name"; private static final String TAG_NAME = "name";
private static final String TAG_SEMESTER = "semester"; private static final String TAG_SEMESTER = "semester";
@@ -72,7 +76,6 @@ public class SectionActivity extends ListActivity {
protected String doInBackground(String... args) { protected String doInBackground(String... args) {
ServiceHandler sh = new ServiceHandler(); ServiceHandler sh = new ServiceHandler();
String JSONString = null;
try { try {
JSONString = sh.getServiceCall(URL); JSONString = sh.getServiceCall(URL);
} catch (IOException e) { } catch (IOException e) {
@@ -80,29 +83,40 @@ public class SectionActivity extends ListActivity {
} }
try { try {
JSONArray sections = new JSONArray(JSONString); professor = new JSONObject(JSONString);
for (int i = 0; i < sections.length(); i++) { if (professor.has(COURSE)) {
JSONObject c = sections.getJSONObject(i); courses = professor.getJSONArray(COURSE);
for (int i = 0; i < courses.length(); i++) {
JSONObject c = courses.getJSONObject(i);
String course = c.getString(TAG_ID);
assert course != null;
if (course.equals(course_id)){
if (c.has(SECTION)){
sections = c.getJSONArray(SECTION);
for (int j = 0; j < sections.length(); j++) {
JSONObject s = sections.getJSONObject(j);
String section_id = c.getString(TAG_ID); String section_id = s.getString(TAG_ID);
String section_no = String.valueOf(i + 1); String section_no = String.valueOf(j + 1);
String name = c.getString(TAG_NAME); String name = s.getString(TAG_NAME);
String semester = c.getString(TAG_SEMESTER); String semester = s.getString(TAG_SEMESTER);
HashMap<String, String> map = new HashMap<String, String>();
HashMap<String, String> map = new HashMap<String, String>(); map.put("course_id", course_id);
map.put("course_id", course_id); map.put(TAG_ID, section_id);
map.put(TAG_ID, section_id); map.put("section_no", section_no + ".");
map.put("section_no", section_no + "."); map.put(TAG_NAME, name);
map.put(TAG_NAME, name); map.put(TAG_SEMESTER, semester);
map.put(TAG_SEMESTER, semester); sectionList.add(map);
}
sectionList.add(map); }
}
}
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
@@ -110,7 +124,6 @@ public class SectionActivity extends ListActivity {
pDialog.dismiss(); pDialog.dismiss();
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
ListAdapter adapter = new SimpleAdapter( ListAdapter adapter = new SimpleAdapter(
SectionActivity.this, sectionList, SectionActivity.this, sectionList,
R.layout.list_item_sections, new String[] { "course_id", TAG_ID, "track_no", R.layout.list_item_sections, new String[] { "course_id", TAG_ID, "track_no",

View File

@@ -5,9 +5,10 @@ import android.util.Log;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray; import org.json.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@@ -70,31 +71,25 @@ public class ServiceHandler {
* @author Reynaldo * @author Reynaldo
*/ */
public boolean postServiceCall(String url, JSONArray jsonArray) throws IOException { public boolean postServiceCall(String url, JSONObject jsonobject) throws IOException {
int inputStream; int inputStream;
response=""; response="";
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
String json = jsonArray.toString(); HttpClient httpclient = new DefaultHttpClient();
StringEntity se = new StringEntity(json); HttpPut httpPut = new HttpPut(url);
httpPost.setEntity(se);
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
HttpResponse httpResponse = httpclient.execute(httpPost);
inputStream = httpResponse.getStatusLine().getStatusCode();
if (inputStream == 200){
return true;
}else {
return false;
}
String json = jsonobject.toString();
} catch (Exception e) { StringEntity se = new StringEntity(json);
Log.d("InputStream", e.getLocalizedMessage()); httpPut.setEntity(se);
httpPut.setHeader("Accept", "application/json");
httpPut.setHeader("Content-type", "application/json");
HttpResponse httpResponse = httpclient.execute(httpPut);
inputStream = httpResponse.getStatusLine().getStatusCode();
if (inputStream == 200){
return true;
}else {
return false;
} }
return false;
} }
private static String convertInputStreamToString(InputStream inputStream) throws IOException{ private static String convertInputStreamToString(InputStream inputStream) throws IOException{

View File

@@ -0,0 +1,45 @@
package massiveattendancescannerapplication.Services;
import org.json.JSONObject;
import android.os.AsyncTask;
import android.os.Handler;
/**
* <p>
* This is an AsyncTask that handles the construction of the Answer object and the AnswerArray
* which is the JSON object containing a JSON array of JSON objects. After the final JSON object
* is created this function invokes the POST method to send the information o the corresponding
* service.
* </p>
*
* @author Reynaldo
*/
public class TransmitterTask extends AsyncTask<JSONObject, Void, Void> {
private static final String URL = "http://192.168.0.106:3000/professors/56f5fd3a20047f3c15b05f0e";
boolean result;
final Handler myHandler = new Handler();
public TransmitterTask() {
}
protected Void doInBackground(JSONObject... professor) {
while (true){
ServiceHandler pt = new ServiceHandler();
try{
result = pt.postServiceCall(URL,professor[0]);
if(result){
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
}

View File

@@ -1,45 +1,100 @@
package massiveattendancescannerapplication; package massiveattendancescannerapplication;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import android.app.ListActivity; import android.app.ListActivity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListAdapter; import android.widget.ListAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.SimpleAdapter; import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import massiveattendancescannerapplication.Services.ServiceHandler; import massiveattendancescannerapplication.Services.ServiceHandler;
import massiveattendancescannerapplication.Services.TransmitterTask;
public class StudentActivity extends ListActivity { public class StudentActivity extends ListActivity {
private ProgressDialog pDialog; private ProgressDialog pDialog;
ArrayList<HashMap<String, String>> studentList; ArrayList<HashMap<String, String>> studentList;
private static final String URL = "http://192.168.0.101:3000/sections"; JSONArray courses,sections,students;
JSONObject professor;
String course_id, section_name, section_id, currentDate;
private static final String COURSE = "courses";
private static final String SECTION = "sections";
private static final String STUDENT = "students";
private static final String URL = "http://192.168.0.106:3000/professors/56f5fd3a20047f3c15b05f0e";
private static final String TAG_ID = "_id"; private static final String TAG_ID = "_id";
private static final String TAG_NO = "id"; private static final String TAG_NO = "id";
private static final String TAG_NAME = "name"; private static final String TAG_NAME = "name";
private static final String TAG_LASTNAME = "lastname"; private static final String TAG_LASTNAME = "lastname";
private static final String TAG_STUDENTS = "students"; private static final String TAG_STUDENTS = "students";
JSONArray students = null; private static final String BT_ADDRESS = "btaddress";
String section_id = null; private static final int REQUEST_ENABLE_BT = 1;
String section_name = null; SimpleDateFormat SDF = new SimpleDateFormat("dd/MM/yyyy");
TextView stateBluetooth;
BluetoothAdapter bluetoothAdapter;
ListView listDevicesFound;
Button btnScanDevice,btnEndClass;
TransmitterTask transmitterTask;
ArrayAdapter<String> btArrayAdapter;
int assist = 0;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.student_activity); setContentView(R.layout.student_activity);
Intent i = getIntent(); Intent i = getIntent();
stateBluetooth = (TextView)findViewById(R.id.bluetoothstate);
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
listDevicesFound = (ListView)findViewById(R.id.devicesfound);
btArrayAdapter = new ArrayAdapter<>(StudentActivity.this,
android.R.layout.simple_list_item_1);
listDevicesFound.setAdapter(btArrayAdapter);
btnScanDevice = (Button)findViewById(R.id.scandevice);
btnScanDevice.setOnClickListener(btnScanDeviceOnClickListener);
btnEndClass = (Button)findViewById(R.id.terminate);
btnEndClass.setOnClickListener(btnEndClassOnClickListener);
CheckBlueToothState();
registerReceiver(ActionFoundReceiver,
new IntentFilter(BluetoothDevice.ACTION_FOUND));
course_id = i.getStringExtra("course_id");
section_id = i.getStringExtra("section_id"); section_id = i.getStringExtra("section_id");
studentList = new ArrayList<>(); studentList = new ArrayList<>();
new LoadStudents().execute(); new LoadStudents().execute();
ListView lv = getListView(); }
@Override
protected void onStop()
{
unregisterReceiver(ActionFoundReceiver);
super.onStop();
} }
class LoadStudents extends AsyncTask<String, String, String> { class LoadStudents extends AsyncTask<String, String, String> {
@@ -67,49 +122,61 @@ public class StudentActivity extends ListActivity {
} }
try { try {
JSONArray sections = new JSONArray(JSONString); professor = new JSONObject(JSONString);
if (professor.has(COURSE)) {
for (int i = 0; i < sections.length(); i++) { courses = professor.getJSONArray(COURSE);
JSONObject c = sections.getJSONObject(i); for (int i = 0; i < courses.length(); i++) {
String section = c.getString(TAG_ID); JSONObject c = courses.getJSONObject(i);
assert section != null; String course = c.getString(TAG_ID);
if (section.equals(section_id)){ assert course != null;
section_name = c.getString(TAG_NAME); if (course.equals(course_id)){
students = c.getJSONArray(TAG_STUDENTS); if (c.has(SECTION)) {
for (int x = 0; x < students.length(); x++) { sections = c.getJSONArray(SECTION);
JSONObject s = students.getJSONObject(x); for (int j = 0; j < sections.length(); j++) {
String student_id = String.valueOf(x + 1); JSONObject s = sections.getJSONObject(j);
String student_no = s.getString(TAG_NO); String section = s.getString(TAG_ID);
String name = s.getString(TAG_NAME); assert section != null;
String lastname = s.getString(TAG_LASTNAME); if (section.equals(section_id)) {
if(s.has(STUDENT)) {
HashMap<String, String> map = new HashMap<String, String>(); section_name = s.getString(TAG_NAME);
map.put("student_id", student_id); students = s.getJSONArray(TAG_STUDENTS);
map.put(TAG_ID, student_id); for (int x = 0; x < students.length(); x++) {
map.put("student_no", student_no); JSONObject st = students.getJSONObject(x);
map.put(TAG_NAME, name); String student_id = String.valueOf(x + 1);
map.put(TAG_LASTNAME, lastname); String student_no = st.getString(TAG_NO);
String name = st.getString(TAG_NAME);
studentList.add(map); String lastname = st.getString(TAG_LASTNAME);
HashMap<String, String> map = new HashMap<>();
map.put("student_id", student_id);
map.put(TAG_ID, student_id);
map.put("student_no", student_no);
map.put(TAG_NAME, name);
map.put(TAG_LASTNAME, lastname);
studentList.add(map);
}
}
}
}
}
} }
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
protected void onPostExecute(String file_url) { protected void onPostExecute(String file_url) {
pDialog.dismiss(); pDialog.dismiss();
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
ListAdapter adapter = new SimpleAdapter( ListAdapter adapter = new SimpleAdapter(
StudentActivity.this, studentList, StudentActivity.this, studentList,
R.layout.list_item_students, new String[] { "section_id", TAG_ID, TAG_NO, R.layout.list_item_students, new String[]{"section_id", TAG_ID, TAG_NO,
TAG_NAME, TAG_LASTNAME }, new int[] { TAG_NAME, TAG_LASTNAME}, new int[]{
R.id.section_id, R.id.student_id, R.id.student_no, R.id.student_name, R.id.student_lastname }); R.id.section_id, R.id.student_id, R.id.student_no, R.id.student_name, R.id.student_lastname});
setListAdapter(adapter); setListAdapter(adapter);
setTitle(section_name); setTitle(section_name);
@@ -117,4 +184,174 @@ public class StudentActivity extends ListActivity {
}); });
} }
} }
private void CheckBlueToothState(){
if (bluetoothAdapter == null){
stateBluetooth.setText("Bluetooth NOT supported");
}else{
if (bluetoothAdapter.isEnabled()){
if(bluetoothAdapter.isDiscovering()){
stateBluetooth.setText("Bluetooth is currently in device discovery process.");
btnScanDevice.setEnabled(false);
}else{
stateBluetooth.setText("Bluetooth is Enabled.");
btnScanDevice.setEnabled(true);
}
}else{
stateBluetooth.setText("Bluetooth is NOT Enabled!");
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
}
private Button.OnClickListener btnScanDeviceOnClickListener
= new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
btArrayAdapter.clear();
bluetoothAdapter.startDiscovery();
}};
private Button.OnClickListener btnEndClassOnClickListener
= new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
try {
for (int x = 0; x < students.length(); x++) {
JSONObject st;
boolean scanned = false;
st = students.getJSONObject(x);
JSONArray assistance;
assistance = st.getJSONArray("assistanceTotal");
assert assistance != null;
currentDate = SDF.format(new Date());
for(int g=0; g<assistance.length(); g++) {
JSONObject cons = assistance.getJSONObject(g);
String consDay = cons.getString("day");
if (consDay.equals(currentDate)){
scanned = true;
}
}
if(!scanned){
assist = st.optInt("assistance");
st.put("assistance", assist+1);
JSONObject dayAssistance = new JSONObject();
dayAssistance.put("day", currentDate);
dayAssistance.put("assistance", false);
assistance.put(dayAssistance);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
transmitterTask = new TransmitterTask();
transmitterTask.execute(professor);
finish();
}};
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_ENABLE_BT){
CheckBlueToothState();
}
}
private final BroadcastReceiver ActionFoundReceiver = new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)) {
boolean scanned = false;
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
String device_name = device.getName();
String device_address = device.getAddress();
for (int x = 0; x < students.length(); x++) {
JSONObject st = null;
try {
st = students.getJSONObject(x);
} catch (JSONException e) {
e.printStackTrace();
}
String student_bt = null;
try {
assert st != null;
student_bt = st.getString(BT_ADDRESS);
} catch (JSONException e) {
e.printStackTrace();
}
if(student_bt != null) {
if (student_bt.equals(device_address)) {
Toast.makeText(getApplicationContext(), "FOUND DEVICE!", Toast.LENGTH_SHORT).show();
try {
JSONArray assistance;
assistance = st.getJSONArray("assistanceTotal");
currentDate = SDF.format(new Date());
for(int g=0; g<assistance.length(); g++) {
JSONObject cons = assistance.getJSONObject(g);
String consDay = cons.getString("day");
if (consDay.equals(currentDate)){
scanned = true;
}
}
if(!scanned){
assist = st.optInt("assistance");
st.put("assistance", assist+1);
JSONObject dayAssistance = new JSONObject();
dayAssistance.put("day", currentDate);
dayAssistance.put("assistance", true);
assistance.put(dayAssistance);
}
}catch (JSONException e) {
e.printStackTrace();
}
}
}else {
String student_no = null;
try {
student_no = st.getString(TAG_NO);
} catch (JSONException e) {
e.printStackTrace();
}
assert student_no != null;
if (device_name.equals(student_no)) {
Toast.makeText(getApplicationContext(), "FOUND ID!", Toast.LENGTH_SHORT).show();
try {
st.put("btaddress",device_address);
} catch (JSONException e) {
e.printStackTrace();
}
try {
JSONArray assistance;
assistance = st.getJSONArray("assistanceTotal");
currentDate = SDF.format(new Date());
for(int g=0; g<assistance.length(); g++) {
JSONObject cons = assistance.getJSONObject(g);
String consDay = cons.getString("day");
if (consDay.equals(currentDate)){
scanned = true;
}
}
if(!scanned){
assist = st.optInt("assistance");
st.put("assistance", assist+1);
JSONObject dayAssistance = new JSONObject();
dayAssistance.put("day", currentDate);
dayAssistance.put("assistance", true);
assistance.put(dayAssistance);
}
}catch (JSONException e) {
e.printStackTrace();
}
}
}
}
btArrayAdapter.add(device.getName() + "\n" + device.getAddress());
btArrayAdapter.notifyDataSetChanged();
}
}
};
} }

View File

@@ -21,7 +21,7 @@
android:text="@string/button_show_classes" android:text="@string/button_show_classes"
android:id="@+id/button" android:id="@+id/button"
android:layout_marginTop="50dp" android:layout_marginTop="50dp"
android:onClick="adminScreen" android:onClick="courseScreen"
android:layout_below="@+id/textView" android:layout_below="@+id/textView"
android:layout_centerHorizontal="true" /> android:layout_centerHorizontal="true" />

View File

@@ -16,6 +16,13 @@
android:text="@string/scanning" android:text="@string/scanning"
android:enabled="false" android:enabled="false"
/> />
<Button
android:id="@+id/terminate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/terminate"
android:enabled="false"
/>
<ListView <ListView
android:id="@+id/devicesfound" android:id="@+id/devicesfound"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View File

@@ -2,21 +2,21 @@
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
<!-- Album id / Hidden by default --> <!-- Section DB ID/ Hidden by default -->
<TextView <TextView
android:id="@+id/section_id" android:id="@+id/section_id"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" /> android:visibility="gone" />
<!-- Song id / Hidden by default --> <!-- Student DB ID/ Hidden by default -->
<TextView <TextView
android:id="@+id/student_id" android:id="@+id/student_id"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" /> android:visibility="gone" />
<!-- Track serial no --> <!-- Student ID number -->
<TextView <TextView
android:id="@+id/student_no" android:id="@+id/student_no"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -28,7 +28,7 @@
android:textSize="16dip" android:textSize="16dip"
android:layout_alignParentLeft="true"/> android:layout_alignParentLeft="true"/>
<!-- Song Name --> <!-- Student Last Name -->
<TextView <TextView
android:id="@+id/student_lastname" android:id="@+id/student_lastname"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -36,11 +36,11 @@
android:paddingBottom="15dip" android:paddingBottom="15dip"
android:paddingLeft="5dip" android:paddingLeft="5dip"
android:paddingTop="15dip" android:paddingTop="15dip"
android:textColor="#000000" android:textColor="#ff0000"
android:textSize="16dip" android:textSize="16dip"
android:layout_toRightOf="@+id/student_no"/> android:layout_toRightOf="@+id/student_no"/>
<!-- Song duration --> <!-- Student First Name -->
<TextView <TextView
android:id="@+id/student_name" android:id="@+id/student_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -48,7 +48,7 @@
android:paddingBottom="15dip" android:paddingBottom="15dip"
android:paddingLeft="5dip" android:paddingLeft="5dip"
android:paddingTop="15dip" android:paddingTop="15dip"
android:textColor="#000000" android:textColor="#ffff0000"
android:textSize="16dip" android:textSize="16dip"
android:layout_toRightOf="@+id/student_lastname"/> android:layout_toRightOf="@+id/student_lastname"/>

View File

@@ -5,12 +5,38 @@
android:orientation="vertical" android:orientation="vertical"
android:background="#ffffff"> android:background="#ffffff">
<TextView
android:id="@+id/bluetoothstate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/scandevice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/scanning"
/>
<Button
android:id="@+id/terminate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/terminate"
/>
<ListView
android:id="@+id/devicesfound"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<ListView <ListView
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:divider="#b5b5b5" android:divider="#b5b5b5"
android:dividerHeight="1dp" android:dividerHeight="1dp"
android:cacheColorHint="#00000000"/> android:cacheColorHint="#00000000"
/>
</LinearLayout> </LinearLayout>

View File

@@ -6,7 +6,7 @@
<string name="button_scan">Escanear</string> <string name="button_scan">Escanear</string>
<string name="button_show_classes">Listar Materias</string> <string name="button_show_classes">Listar Materias</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="title_activity_scan">Escaneando...</string> <string name="title_activity_scan">Escaneando</string>
<string name="button_show_class">Mostrar Clases</string> <string name="button_show_class">Mostrar Clases</string>
<string name="button_add_class">Añadir Clases</string> <string name="button_add_class">Añadir Clases</string>
<string name="button_rm_class">Eliminar Clases</string> <string name="button_rm_class">Eliminar Clases</string>
@@ -33,5 +33,6 @@
<string name="title_course_activity">Materias</string> <string name="title_course_activity">Materias</string>
<string name="title_section_activity">Secciones</string> <string name="title_section_activity">Secciones</string>
<string name="title_student_activity">Estudiantes</string> <string name="title_student_activity">Estudiantes</string>
<string name="terminate">Culminar Clase</string>
</resources> </resources>