Initial commit
This commit is contained in:
49
app/src/main/AndroidManifest.xml
Normal file
49
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.masa.massiveattendancescannerapplication" >
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:name="com.example.masa.massiveattendancescannerapplication.MainActivity"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".CourseActivity"
|
||||
android:label="@string/title_course_activity"
|
||||
android:parentActivityName="com.example.masa.massiveattendancescannerapplication.MainActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.masa.massiveattendancescannerapplication.MainActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".SectionActivity"
|
||||
android:label="@string/title_section_activity"
|
||||
android:parentActivityName="com.example.masa.massiveattendancescannerapplication.CourseActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.masa.massiveattendancescannerapplication.CourseActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".StudentActivity"
|
||||
android:label="@string/title_student_activity"
|
||||
android:parentActivityName="com.example.masa.massiveattendancescannerapplication.CourseActivity" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.example.masa.massiveattendancescannerapplication.CourseActivity" />
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.example.masa.massiveattendancescannerapplication;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.masa.massiveattendancescannerapplication.Services.JSONParser;
|
||||
import com.example.masa.massiveattendancescannerapplication.Services.ServiceHandler;
|
||||
|
||||
public class CourseActivity extends ListActivity {
|
||||
|
||||
private ProgressDialog pDialog;
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
ArrayList<HashMap<String, String>> courseList;
|
||||
JSONArray course = null;
|
||||
private static final String URL = "http://192.168.0.101:3000/courses";
|
||||
// ALL JSON node names
|
||||
private static final String TAG_ID = "_id";
|
||||
private static final String TAG_NAME = "name";
|
||||
private static final String TAG_CODE = "code";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.course_activity);
|
||||
|
||||
|
||||
courseList = new ArrayList<HashMap<String, String>>();
|
||||
new LoadCourses().execute();
|
||||
|
||||
ListView lv = getListView();
|
||||
|
||||
/**
|
||||
* Listview item click listener
|
||||
* SectionActivity will be lauched by passing album id
|
||||
* */
|
||||
lv.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View view, int arg2,
|
||||
long arg3) {
|
||||
// on selecting a single album
|
||||
// SectionActivity will be launched to show tracks inside the album
|
||||
Intent i = new Intent(getApplicationContext(), SectionActivity.class);
|
||||
|
||||
// send album id to tracklist activity to get list of songs under that album
|
||||
String course_id = ((TextView) view.findViewById(R.id.course_id)).getText().toString();
|
||||
i.putExtra("course_id", course_id);
|
||||
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Background Async Task to Load all Courses by making http request
|
||||
* */
|
||||
class LoadCourses extends AsyncTask<String, String, String> {
|
||||
|
||||
/**
|
||||
* Before starting background thread Show Progress Dialog
|
||||
* */
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
pDialog = new ProgressDialog(CourseActivity.this);
|
||||
pDialog.setMessage("Cargando Materias ...");
|
||||
pDialog.setIndeterminate(false);
|
||||
pDialog.setCancelable(false);
|
||||
pDialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* getting Courses JSON
|
||||
* */
|
||||
protected String doInBackground(String... args) {
|
||||
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
ServiceHandler sh = new ServiceHandler();
|
||||
String JSONString = null;
|
||||
try {
|
||||
JSONString = sh.getServiceCall(URL);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
course = new JSONArray(JSONString);
|
||||
|
||||
// looping through All courses
|
||||
for (int i = 0; i < course.length(); i++) {
|
||||
JSONObject c = course.getJSONObject(i);
|
||||
|
||||
// Storing each json item values in variable
|
||||
String id = c.getString(TAG_ID);
|
||||
String name = c.getString(TAG_NAME);
|
||||
String code = c.getString(TAG_CODE);
|
||||
|
||||
// creating new HashMap
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
|
||||
// adding each child node to HashMap key => value
|
||||
map.put(TAG_ID, id);
|
||||
map.put(TAG_NAME, name);
|
||||
map.put(TAG_CODE, code);
|
||||
|
||||
// adding HashList to ArrayList
|
||||
courseList.add(map);
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* After completing background task Dismiss the progress dialog
|
||||
* **/
|
||||
protected void onPostExecute(String file_url) {
|
||||
// dismiss the dialog after getting all courses
|
||||
pDialog.dismiss();
|
||||
// updating UI from Background Thread
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
/**
|
||||
* Updating parsed JSON data into ListView
|
||||
* */
|
||||
ListAdapter adapter = new SimpleAdapter(
|
||||
CourseActivity.this, courseList,
|
||||
R.layout.list_item_courses, new String[] { TAG_ID,
|
||||
TAG_NAME, TAG_CODE }, new int[] {
|
||||
R.id.course_id, R.id.course_name, R.id.course_code });
|
||||
setListAdapter(adapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.example.masa.massiveattendancescannerapplication.Data;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Course{
|
||||
|
||||
public String name;
|
||||
public String code;
|
||||
public List<Section> section;
|
||||
|
||||
public Course (String _name, String _code, List<Section> _section){
|
||||
name = _name;
|
||||
code = _code;
|
||||
section = _section;
|
||||
}
|
||||
|
||||
public static Course createFromJSON(JSONObject json) throws JSONException {
|
||||
|
||||
List<Section> qSections = new ArrayList<>();
|
||||
String name = json.getString("name");
|
||||
String code = json.getString("code");
|
||||
|
||||
|
||||
if (json.has("Sections")){
|
||||
JSONArray sections = json.getJSONArray("Sections");
|
||||
|
||||
for (int k = 0; k < sections.length(); k++)
|
||||
{
|
||||
qSections.add(Section.createFromJSON(sections.getJSONObject(k)));
|
||||
}
|
||||
}
|
||||
return new Course(name, code,qSections);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.example.masa.massiveattendancescannerapplication.Data;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Section {
|
||||
|
||||
public String name;
|
||||
public String semester;
|
||||
public List<Student> student;
|
||||
|
||||
public Section (String _name, String _semester, List<Student> _student){
|
||||
name = _name;
|
||||
semester = _semester;
|
||||
student = _student;
|
||||
}
|
||||
|
||||
public static Section createFromJSON(JSONObject json) throws JSONException {
|
||||
|
||||
String name = json.getString("name");
|
||||
String semester = json.getString("semester");
|
||||
List<Student> qStudents = new ArrayList<Student>();
|
||||
|
||||
|
||||
if (json.has("Students")){
|
||||
JSONArray students = json.getJSONArray("Students");
|
||||
|
||||
for (int k = 0; k < students.length(); k++)
|
||||
{
|
||||
qStudents.add(Student.createFromJSON(students.getJSONObject(k)));
|
||||
}
|
||||
}
|
||||
return new Section(name, semester, qStudents);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.example.masa.massiveattendancescannerapplication.Data;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Student {
|
||||
|
||||
public String id;
|
||||
public String name;
|
||||
public String lastname;
|
||||
public String btAddress;
|
||||
|
||||
public Student (String _id, String _name, String _lastname, String _btAddress){
|
||||
id = _id;
|
||||
name = _name;
|
||||
lastname = _lastname;
|
||||
btAddress = _btAddress;
|
||||
}
|
||||
|
||||
public static Student createFromJSON(JSONObject json) throws JSONException {
|
||||
|
||||
String id = json.getString("id");
|
||||
String name = json.getString("name");
|
||||
String lastname = json.getString("lastname");
|
||||
String btAddress = json.getString("btAddress");
|
||||
|
||||
return new Student(id, name, lastname, btAddress);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.example.masa.massiveattendancescannerapplication;
|
||||
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.content.Intent;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
|
||||
|
||||
public class MainActivity extends ActionBarActivity {
|
||||
|
||||
public static final int REQUEST_ENABLE_BT = 1;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
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
|
||||
public void adminScreen (View view) {
|
||||
Intent intent = new Intent(this, CourseActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.example.masa.massiveattendancescannerapplication;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ScanActivity extends Activity {
|
||||
|
||||
private static final int REQUEST_ENABLE_BT = 1;
|
||||
|
||||
ListView listDevicesFound;
|
||||
Button btnScanDevice;
|
||||
TextView stateBluetooth;
|
||||
BluetoothAdapter bluetoothAdapter;
|
||||
|
||||
ArrayAdapter<String> btArrayAdapter;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_scan);
|
||||
|
||||
btnScanDevice = (Button)findViewById(R.id.scandevice);
|
||||
|
||||
stateBluetooth = (TextView)findViewById(R.id.bluetoothstate);
|
||||
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
listDevicesFound = (ListView)findViewById(R.id.devicesfound);
|
||||
btArrayAdapter = new ArrayAdapter<String>(ScanActivity.this, android.R.layout.simple_list_item_1);
|
||||
listDevicesFound.setAdapter(btArrayAdapter);
|
||||
|
||||
CheckBlueToothState();
|
||||
|
||||
btnScanDevice.setOnClickListener(btnScanDeviceOnClickListener);
|
||||
|
||||
registerReceiver(ActionFoundReceiver,
|
||||
new IntentFilter(BluetoothDevice.ACTION_FOUND));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onDestroy();
|
||||
unregisterReceiver(ActionFoundReceiver);
|
||||
}
|
||||
|
||||
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.");
|
||||
}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) {
|
||||
// TODO Auto-generated method stub
|
||||
btArrayAdapter.clear();
|
||||
bluetoothAdapter.startDiscovery();
|
||||
}};
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// TODO Auto-generated method stub
|
||||
if(requestCode == REQUEST_ENABLE_BT){
|
||||
CheckBlueToothState();
|
||||
}
|
||||
}
|
||||
|
||||
private final BroadcastReceiver ActionFoundReceiver = new BroadcastReceiver(){
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// TODO Auto-generated method stub
|
||||
String action = intent.getAction();
|
||||
if(BluetoothDevice.ACTION_FOUND.equals(action)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
Toast.makeText(getApplicationContext(), "FOUND THEM!", Toast.LENGTH_SHORT).show();
|
||||
btArrayAdapter.add(device.getName() + "\n" + device.getAddress());
|
||||
btArrayAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.example.masa.massiveattendancescannerapplication;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.masa.massiveattendancescannerapplication.Services.JSONParser;
|
||||
import com.example.masa.massiveattendancescannerapplication.Services.ServiceHandler;
|
||||
|
||||
public class SectionActivity extends ListActivity {
|
||||
|
||||
private ProgressDialog pDialog;
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
ArrayList<HashMap<String, String>> sectionList;
|
||||
JSONArray courses = null;
|
||||
String course_id, course_name;
|
||||
private static final String URL = "http://192.168.0.101:3000/sections";
|
||||
private static final String TAG_ID = "_id";
|
||||
private static final String TAG_NAME = "name";
|
||||
private static final String TAG_SEMESTER = "semester";
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.section_activity);
|
||||
|
||||
Intent i = getIntent();
|
||||
course_id = i.getStringExtra("course_id");
|
||||
sectionList = new ArrayList<HashMap<String, String>>();
|
||||
new LoadSections().execute();
|
||||
ListView lv = getListView();
|
||||
|
||||
/**
|
||||
* Listview on item click listener
|
||||
* StudentActivity will be lauched by passing album id, song id
|
||||
* */
|
||||
lv.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View view, int arg2,
|
||||
long arg3) {
|
||||
// On selecting single track get song information
|
||||
Intent i = new Intent(getApplicationContext(), StudentActivity.class);
|
||||
|
||||
// to get song information
|
||||
// both album id and song is needed
|
||||
String course_id = ((TextView) view.findViewById(R.id.course_id)).getText().toString();
|
||||
String section_id = ((TextView) view.findViewById(R.id.section_id)).getText().toString();
|
||||
|
||||
i.putExtra("course_id", course_id);
|
||||
i.putExtra("section_id", section_id);
|
||||
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
class LoadSections extends AsyncTask<String, String, String> {
|
||||
|
||||
/**
|
||||
* Before starting background thread Show Progress Dialog
|
||||
* */
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
pDialog = new ProgressDialog(SectionActivity.this);
|
||||
pDialog.setMessage("Cargando Secciones ...");
|
||||
pDialog.setIndeterminate(false);
|
||||
pDialog.setCancelable(false);
|
||||
pDialog.show();
|
||||
}
|
||||
|
||||
|
||||
protected String doInBackground(String... args) {
|
||||
// Building Parameters
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
ServiceHandler sh = new ServiceHandler();
|
||||
String JSONString = null;
|
||||
try {
|
||||
JSONString = sh.getServiceCall(URL);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
JSONArray sections = new JSONArray(JSONString);
|
||||
|
||||
for (int i = 0; i < sections.length(); i++) {
|
||||
JSONObject c = sections.getJSONObject(i);
|
||||
|
||||
String section_id = c.getString(TAG_ID);
|
||||
String section_no = String.valueOf(i + 1);
|
||||
String name = c.getString(TAG_NAME);
|
||||
String semester = c.getString(TAG_SEMESTER);
|
||||
|
||||
// creating new HashMap
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
|
||||
map.put("course_id", course_id);
|
||||
map.put(TAG_ID, section_id);
|
||||
map.put("section_no", section_no + ".");
|
||||
map.put(TAG_NAME, name);
|
||||
map.put(TAG_SEMESTER, semester);
|
||||
|
||||
// adding HashList to ArrayList
|
||||
sectionList.add(map);
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* After completing background task Dismiss the progress dialog
|
||||
* **/
|
||||
protected void onPostExecute(String file_url) {
|
||||
// dismiss the dialog after getting all tracks
|
||||
pDialog.dismiss();
|
||||
// updating UI from Background Thread
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
/**
|
||||
* Updating parsed JSON data into ListView
|
||||
* */
|
||||
ListAdapter adapter = new SimpleAdapter(
|
||||
SectionActivity.this, sectionList,
|
||||
R.layout.list_item_sections, new String[] { "course_id", TAG_ID, "track_no",
|
||||
TAG_NAME, TAG_SEMESTER }, new int[] {
|
||||
R.id.course_id, R.id.section_id, R.id.section_no, R.id.section_name, R.id.section_semester });
|
||||
setListAdapter(adapter);
|
||||
setTitle(course_name);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.example.masa.massiveattendancescannerapplication.Services;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.masa.massiveattendancescannerapplication.Data.Course;
|
||||
import com.example.masa.massiveattendancescannerapplication.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CourseAdapter extends ArrayAdapter<Course> {
|
||||
public CourseAdapter(Context context, ArrayList<Course> courses) {
|
||||
super(context, 0, courses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// Get the data item for this position
|
||||
Course course = getItem(position);
|
||||
// Check if an existing view is being reused, otherwise inflate the view
|
||||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_course, parent, false);
|
||||
}
|
||||
// Lookup view for data population
|
||||
TextView Name = (TextView) convertView.findViewById(R.id.Name);
|
||||
TextView Code = (TextView) convertView.findViewById(R.id.Code);
|
||||
// Populate the data into the template view using the data object
|
||||
Name.setText(course.name);
|
||||
Code.setText(course.code);
|
||||
// Return the completed view to render on screen
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.example.masa.massiveattendancescannerapplication.Services;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Function that parses a file to get a URL direction. The text files must be placed inside the
|
||||
* \Android\data\com.smartmatic.sitesurvey\files\ folder to be able to read them.
|
||||
* </p>
|
||||
*
|
||||
* @author Reynaldo
|
||||
*/
|
||||
public class FileReader {
|
||||
|
||||
static String response;
|
||||
private static final String professors = "professors.txt";
|
||||
private static final String courses = "courses.txt";
|
||||
private static final String sections = "sections.txt";
|
||||
private static final String students = "students.txt";
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This function returns the URL direction parsed from the .txt file contained in the phone.
|
||||
* </p>
|
||||
* @param context Application Context.
|
||||
* @param method Method representing POST of GET methods.
|
||||
* @return String containing the URL.
|
||||
*/
|
||||
public static String getUrl(Context context, int method) {
|
||||
try {
|
||||
return parse(getConfigFile(context,method));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This function handles the type of method of connecting (POST and GET) returning the URL
|
||||
* direction for each type.
|
||||
* </p>
|
||||
* @param context Application Context.
|
||||
* @param method Method representing POST of GET methods.
|
||||
* @return BufferedReader containing the information inside the file.
|
||||
*/
|
||||
private static BufferedReader getConfigFile(Context context,int method) {
|
||||
if(isExternalStorageReadable()){
|
||||
// Get the directory for the app's private files
|
||||
File file = null;
|
||||
try {
|
||||
if(method == 1) file = new File(context.getExternalFilesDir(null), professors);
|
||||
if(method == 2) file = new File(context.getExternalFilesDir(null), courses);
|
||||
if(method == 3) file = new File(context.getExternalFilesDir(null), sections);
|
||||
if(method == 4) file = new File(context.getExternalFilesDir(null), students);
|
||||
|
||||
if (file!=null) {
|
||||
java.io.FileReader fr = new java.io.FileReader(file);
|
||||
return new BufferedReader(fr);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Checks if external storage is available to at least read
|
||||
private static boolean isExternalStorageReadable() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
return Environment.MEDIA_MOUNTED.equals(state) ||
|
||||
Environment.MEDIA_MOUNTED_READ_ONLY.equals(state);
|
||||
}
|
||||
|
||||
private static String parse(BufferedReader reader) throws IOException {
|
||||
try {
|
||||
String line = reader.readLine();
|
||||
while(line != null){
|
||||
response = line;
|
||||
line = reader.readLine();
|
||||
}
|
||||
return response;
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.example.masa.massiveattendancescannerapplication.Services;
|
||||
|
||||
import com.example.masa.massiveattendancescannerapplication.Data.Course;
|
||||
import com.example.masa.massiveattendancescannerapplication.Data.Section;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**<p>
|
||||
* This class parses a JSON Object which is received from the Main Activity.
|
||||
* The methods in this class are private except for GetQuestionary(),which is the main call for
|
||||
* this class to parse,fill the questions objects and return an ArrayList consisting of several
|
||||
* question objects that later are used to construct the survey.
|
||||
* </p>
|
||||
* @author Reynaldo
|
||||
*/
|
||||
|
||||
public class JSONParser {
|
||||
|
||||
public static ArrayList<Course> getCourses(String JSONString) {
|
||||
|
||||
try {
|
||||
return parse(JSONString);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ArrayList<Course> parse(String JSONString) throws JSONException {
|
||||
try {
|
||||
JSONArray json = new JSONArray(JSONString);
|
||||
return readFile(json);
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** <p>
|
||||
* This function receives a JSON object and parses trough all the elements until a Course
|
||||
* tag is reached. The JSON object contains various nested JSON Arrays that represent
|
||||
* different levels of the survey info, such as Courses, Sections, and Students,
|
||||
* these arrays must be parsed in order to reach the courses that are needed to construct
|
||||
* the list. Once the Course tag is reached, the function calls
|
||||
* readCourses(JSON Object).
|
||||
* </p>
|
||||
*
|
||||
* @param json a JsonObject containing Courses info.
|
||||
* @return an ArrayList containing various course objects.
|
||||
* @throws JSONException if JSON object is empty or null.
|
||||
*/
|
||||
|
||||
private static ArrayList<Course> readFile(JSONArray json) throws IOException, JSONException {
|
||||
|
||||
//final String DATA = "Courses";
|
||||
ArrayList<Course> qCourses = new ArrayList<>();
|
||||
//if (json.has(DATA)) {
|
||||
//JSONArray courses = json.getJSONArray(DATA);
|
||||
for (int h = 0; h < json.length(); h++) {
|
||||
qCourses.add(Course.createFromJSON(json.getJSONObject(h)));
|
||||
}
|
||||
//}
|
||||
return qCourses;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.example.masa.massiveattendancescannerapplication.Services;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.json.JSONArray;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class creates a URL connection to a host, and GETs or POSTs a JSON object containing
|
||||
* survey information.
|
||||
* </p>
|
||||
* @author Reynaldo
|
||||
*/
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public class ServiceHandler {
|
||||
|
||||
static String response;
|
||||
public ServiceHandler() {
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* This function receives a URL direction and a method of connection, connects to a host
|
||||
* through the url and receives a JSON Object.
|
||||
* </p>
|
||||
* @param url url to establish a connection.
|
||||
* @return a String response containing the JSON Object.
|
||||
* @throws IOException if the InputStream is null.
|
||||
* @author Reynaldo
|
||||
*/
|
||||
public String getServiceCall(String url) throws IOException {
|
||||
response = "";
|
||||
try {
|
||||
URL urlUp = new URL(url);
|
||||
URLConnection conn = urlUp.openConnection();
|
||||
InputStream is = conn.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
String data = "";
|
||||
|
||||
while ((data = reader.readLine()) != null) {
|
||||
response += data;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This function receives a URL direction and a JSON object, connects to a host
|
||||
* through the url and sends the JSON Object.
|
||||
* </p>
|
||||
* @param url url to establish a connection.
|
||||
* @return a boolean in case of successful POST.
|
||||
* @throws IOException if the InputStream is null.
|
||||
* @author Reynaldo
|
||||
*/
|
||||
|
||||
public boolean postServiceCall(String url, JSONArray jsonArray) throws IOException {
|
||||
int inputStream;
|
||||
response="";
|
||||
try {
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
|
||||
String json = jsonArray.toString();
|
||||
StringEntity se = new StringEntity(json);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d("InputStream", e.getLocalizedMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String convertInputStreamToString(InputStream inputStream) throws IOException{
|
||||
BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream));
|
||||
String line = "";
|
||||
String result = "";
|
||||
while((line = bufferedReader.readLine()) != null)
|
||||
result += line;
|
||||
|
||||
inputStream.close();
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.example.masa.massiveattendancescannerapplication;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
|
||||
import com.example.masa.massiveattendancescannerapplication.Services.ServiceHandler;
|
||||
|
||||
|
||||
public class StudentActivity extends ListActivity {
|
||||
|
||||
private ProgressDialog pDialog;
|
||||
ArrayList<HashMap<String, String>> studentList;
|
||||
private static final String URL = "http://192.168.0.101:3000/sections";
|
||||
private static final String TAG_ID = "_id";
|
||||
private static final String TAG_NO = "id";
|
||||
private static final String TAG_NAME = "name";
|
||||
private static final String TAG_LASTNAME = "lastname";
|
||||
private static final String TAG_STUDENTS = "students";
|
||||
JSONArray students = null;
|
||||
String section_id = null;
|
||||
String section_name = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.student_activity);
|
||||
Intent i = getIntent();
|
||||
section_id = i.getStringExtra("section_id");
|
||||
studentList = new ArrayList<>();
|
||||
new LoadStudents().execute();
|
||||
|
||||
ListView lv = getListView();
|
||||
}
|
||||
|
||||
class LoadStudents extends AsyncTask<String, String, String> {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
pDialog = new ProgressDialog(StudentActivity.this);
|
||||
pDialog.setMessage("Cargando Alumnos ...");
|
||||
pDialog.setIndeterminate(false);
|
||||
pDialog.setCancelable(false);
|
||||
pDialog.show();
|
||||
}
|
||||
|
||||
protected String doInBackground(String... args) {
|
||||
|
||||
Bundle b = getIntent().getExtras();
|
||||
String section_id = b.getString("section_id");
|
||||
ServiceHandler sh = new ServiceHandler();
|
||||
String JSONString = null;
|
||||
try {
|
||||
JSONString = sh.getServiceCall(URL);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Log.d("Section JSON: ", JSONString);
|
||||
|
||||
try {
|
||||
JSONArray sections = new JSONArray(JSONString);
|
||||
|
||||
for (int i = 0; i < sections.length(); i++) {
|
||||
JSONObject c = sections.getJSONObject(i);
|
||||
String section = c.getString(TAG_ID);
|
||||
assert section != null;
|
||||
if (section.equals(section_id)){
|
||||
section_name = c.getString(TAG_NAME);
|
||||
students = c.getJSONArray(TAG_STUDENTS);
|
||||
for (int x = 0; x < students.length(); x++) {
|
||||
JSONObject s = students.getJSONObject(x);
|
||||
String student_id = String.valueOf(x + 1);
|
||||
String student_no = s.getString(TAG_NO);
|
||||
String name = s.getString(TAG_NAME);
|
||||
String lastname = s.getString(TAG_LASTNAME);
|
||||
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(String file_url) {
|
||||
|
||||
pDialog.dismiss();
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
ListAdapter adapter = new SimpleAdapter(
|
||||
StudentActivity.this, studentList,
|
||||
R.layout.list_item_students, new String[] { "section_id", TAG_ID, TAG_NO,
|
||||
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 });
|
||||
setListAdapter(adapter);
|
||||
|
||||
setTitle(section_name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
29
app/src/main/res/layout/activity_main.xml
Normal file
29
app/src/main/res/layout/activity_main.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
<TextView
|
||||
android:text="@string/intro"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:id="@+id/textView" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/button_show_classes"
|
||||
android:id="@+id/button"
|
||||
android:layout_marginTop="50dp"
|
||||
android:onClick="adminScreen"
|
||||
android:layout_below="@+id/textView"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
24
app/src/main/res/layout/activity_scan.xml
Normal file
24
app/src/main/res/layout/activity_scan.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<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"
|
||||
android:enabled="false"
|
||||
/>
|
||||
<ListView
|
||||
android:id="@+id/devicesfound"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
/>
|
||||
</LinearLayout>
|
||||
16
app/src/main/res/layout/course_activity.xml
Normal file
16
app/src/main/res/layout/course_activity.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff">
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="#b5b5b5"
|
||||
android:dividerHeight="1dp"
|
||||
android:cacheColorHint="#00000000"/>
|
||||
|
||||
</LinearLayout>
|
||||
17
app/src/main/res/layout/item_course.xml
Normal file
17
app/src/main/res/layout/item_course.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Nombre: " />
|
||||
<TextView
|
||||
android:id="@+id/Code"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Codigo: " />
|
||||
|
||||
</LinearLayout>
|
||||
37
app/src/main/res/layout/list_item_courses.xml
Normal file
37
app/src/main/res/layout/list_item_courses.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- Album id / Hidden by default -->
|
||||
<TextView
|
||||
android:id="@+id/course_id"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Album Name -->
|
||||
<TextView
|
||||
android:id="@+id/course_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16dip"
|
||||
android:textColor="#000000"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="10dip"
|
||||
android:textStyle="bold"/>
|
||||
|
||||
<!-- Album Songs count -->
|
||||
<TextView android:id="@+id/course_code"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:textColor="#ffffff"
|
||||
android:textStyle="bold"
|
||||
android:background="#9ed321"
|
||||
android:paddingRight="3dip"
|
||||
android:paddingLeft="3dip"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
54
app/src/main/res/layout/list_item_sections.xml
Normal file
54
app/src/main/res/layout/list_item_sections.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<!-- Album id / Hidden by default -->
|
||||
<TextView
|
||||
android:id="@+id/course_id"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Song id / Hidden by default -->
|
||||
<TextView
|
||||
android:id="@+id/section_id"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Track serial no -->
|
||||
<TextView
|
||||
android:id="@+id/section_no"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingTop="15dip"
|
||||
android:textColor="#000000"
|
||||
android:textSize="16dip"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
|
||||
<!-- Song Name -->
|
||||
<TextView
|
||||
android:id="@+id/section_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingTop="15dip"
|
||||
android:textColor="#000000"
|
||||
android:textSize="16dip"
|
||||
android:layout_toRightOf="@+id/section_no"/>
|
||||
|
||||
<!-- Song duration -->
|
||||
<TextView
|
||||
android:id="@+id/section_semester"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="3dip"
|
||||
android:paddingRight="6dip"
|
||||
android:textColor="#9ed321" />
|
||||
|
||||
</RelativeLayout>
|
||||
55
app/src/main/res/layout/list_item_students.xml
Normal file
55
app/src/main/res/layout/list_item_students.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<!-- Album id / Hidden by default -->
|
||||
<TextView
|
||||
android:id="@+id/section_id"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Song id / Hidden by default -->
|
||||
<TextView
|
||||
android:id="@+id/student_id"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- Track serial no -->
|
||||
<TextView
|
||||
android:id="@+id/student_no"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingTop="15dip"
|
||||
android:textColor="#000000"
|
||||
android:textSize="16dip"
|
||||
android:layout_alignParentLeft="true"/>
|
||||
|
||||
<!-- Song Name -->
|
||||
<TextView
|
||||
android:id="@+id/student_lastname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingTop="15dip"
|
||||
android:textColor="#000000"
|
||||
android:textSize="16dip"
|
||||
android:layout_toRightOf="@+id/student_no"/>
|
||||
|
||||
<!-- Song duration -->
|
||||
<TextView
|
||||
android:id="@+id/student_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="5dip"
|
||||
android:paddingTop="15dip"
|
||||
android:textColor="#000000"
|
||||
android:textSize="16dip"
|
||||
android:layout_toRightOf="@+id/student_lastname"/>
|
||||
|
||||
</RelativeLayout>
|
||||
16
app/src/main/res/layout/section_activity.xml
Normal file
16
app/src/main/res/layout/section_activity.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff">
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="#b5b5b5"
|
||||
android:dividerHeight="1dp"
|
||||
android:cacheColorHint="#00000000"/>
|
||||
|
||||
</LinearLayout>
|
||||
16
app/src/main/res/layout/student_activity.xml
Normal file
16
app/src/main/res/layout/student_activity.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#ffffff">
|
||||
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:divider="#b5b5b5"
|
||||
android:dividerHeight="1dp"
|
||||
android:cacheColorHint="#00000000"/>
|
||||
|
||||
</LinearLayout>
|
||||
9
app/src/main/res/menu/add_class.xml
Normal file
9
app/src/main/res/menu/add_class.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.masa.massiveattendancescannerapplication.AddClassActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
app/src/main/res/menu/admin.xml
Normal file
9
app/src/main/res/menu/admin.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.masa.massiveattendancescannerapplication.AdminActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
app/src/main/res/menu/info.xml
Normal file
9
app/src/main/res/menu/info.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.masa.massiveattendancescannerapplication.InfoActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
app/src/main/res/menu/main.xml
Normal file
9
app/src/main/res/menu/main.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".MainActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
app/src/main/res/menu/remove_class.xml
Normal file
9
app/src/main/res/menu/remove_class.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.masa.massiveattendancescannerapplication.RemoveClassActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
app/src/main/res/menu/scan.xml
Normal file
9
app/src/main/res/menu/scan.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.masa.massiveattendancescannerapplication.ScanActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
9
app/src/main/res/menu/show_class.xml
Normal file
9
app/src/main/res/menu/show_class.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.example.masa.massiveattendancescannerapplication.showClassActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
||||
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
5
app/src/main/res/values/dimens.xml
Normal file
5
app/src/main/res/values/dimens.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
||||
37
app/src/main/res/values/strings.xml
Normal file
37
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Attendance Scanner Application</string>
|
||||
<string name="intro"><b> Universidad Central de Venezuela \n Facultad de Ciencias \n Escuela de Computación </b></string>
|
||||
<string name="button_scan">Escanear</string>
|
||||
<string name="button_show_classes">Listar Materias</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="title_activity_scan">Escaneando...</string>
|
||||
<string name="button_show_class">Mostrar Clases</string>
|
||||
<string name="button_add_class">Añadir Clases</string>
|
||||
<string name="button_rm_class">Eliminar Clases</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="title_activity_admin">Administración</string>
|
||||
<string name="title_activity_show_class">Clases</string>
|
||||
<string name="title_activity_add_class">Añadir Clase</string>
|
||||
<string name="title_activity_remove_class">Eliminar Clase</string>
|
||||
<string name="target_class">Nombre de la Clase a Eliminar</string>
|
||||
|
||||
<string name="classname">Nombre de la Clase a Añadir</string>
|
||||
<string name="startday">Dia Inicio de Clase</string>
|
||||
<string name="endday">Dia Fin de Clase</string>
|
||||
<string name="day">Dia de la Semana de Claser</string>
|
||||
<string name="starthour">Hora de Inicio de Clase</string>
|
||||
<string name="endhour">Hora de Fin de Clase</string>
|
||||
<string name="classcode">Codigo de Materia</string>
|
||||
|
||||
<string name="add_class">Añadir</string>
|
||||
<string name="remove_class">Eliminar</string>
|
||||
<string name="title_activity_info">Información</string>
|
||||
<string name="scanning">Escanear Dispositivos</string>
|
||||
|
||||
<string name="title_course_activity">Materias</string>
|
||||
<string name="title_section_activity">Secciones</string>
|
||||
<string name="title_student_activity">Estudiantes</string>
|
||||
|
||||
</resources>
|
||||
8
app/src/main/res/values/styles.xml
Normal file
8
app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user