diff --git a/Android app/AndroidManifest.xml b/Android app/AndroidManifest.xml new file mode 100644 index 0000000..35ad939 --- /dev/null +++ b/Android app/AndroidManifest.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Android app/JAVA codes/Actiity03.java b/Android app/JAVA codes/Actiity03.java new file mode 100644 index 0000000..952897c --- /dev/null +++ b/Android app/JAVA codes/Actiity03.java @@ -0,0 +1,39 @@ +package com.example.tharushashehan.ermsapp04; + +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + + +public class Actiity03 extends ActionBarActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_actiity03); + }} + + /* @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_actiity03, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} +*/ \ No newline at end of file diff --git a/Android app/JAVA codes/HttpJsonParser.java b/Android app/JAVA codes/HttpJsonParser.java new file mode 100644 index 0000000..c77b2f3 --- /dev/null +++ b/Android app/JAVA codes/HttpJsonParser.java @@ -0,0 +1,77 @@ +package com.example.tharushashehan.ermsapp04; + +import android.util.Log; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; +import org.json.JSONObject; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; + +/** + * Created by Tharusha Shehan on 6/12/2016. + */ +public class HttpJsonParser { + + public static String getData(String url_select) { + + //This has been finalized no need to edit anymore. + + + ArrayList param = new ArrayList(); + InputStream inputStream = null; + StringBuilder sBuilder = new StringBuilder(); + + try { + // Set up HTTP post + // HttpClient is more then less deprecated. Need to change to URLConnection + HttpClient httpClient = new DefaultHttpClient(); + + HttpPost httpPost = new HttpPost(url_select); + httpPost.setEntity(new UrlEncodedFormEntity(param)); + HttpResponse httpResponse = httpClient.execute(httpPost); + HttpEntity httpEntity = httpResponse.getEntity(); + + // Read content & Log + inputStream = httpEntity.getContent(); + } catch (UnsupportedEncodingException e1) { + Log.e("UnsupportedEncodingException", e1.toString()); + e1.printStackTrace(); + } catch (ClientProtocolException e2) { + Log.e("ClientProtocolException", e2.toString()); + e2.printStackTrace(); + } catch (IllegalStateException e3) { + Log.e("IllegalStateException", e3.toString()); + e3.printStackTrace(); + } catch (IOException e4) { + Log.e("IOException", e4.toString()); + e4.printStackTrace(); + } + // Convert response to string using String Builder + try { + BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"), 8); + //StringBuilder sBuilder = new StringBuilder(); + + String line = null; + while ((line = bReader.readLine()) != null) { + sBuilder.append(line + "\n"); + } + inputStream.close(); + + } catch (Exception e) { + Log.e("StringBuilding & BufferedReader", "Error converting result " + e.toString()); + } + return sBuilder.toString(); +} +} \ No newline at end of file diff --git a/Android app/JAVA codes/HttpManager.java b/Android app/JAVA codes/HttpManager.java new file mode 100644 index 0000000..b1e8cf0 --- /dev/null +++ b/Android app/JAVA codes/HttpManager.java @@ -0,0 +1,51 @@ +package com.example.tharushashehan.ermsapp04; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * Created by Tharusha Shehan on 6/13/2016. + */ + /** + * Created by Tharusha Shehan on 5/7/2016. + */ + // public class HttpManager { + + public class HttpManager { + + public static String getData(String uri) { + BufferedReader reader = null; + + try { + URL url = new URL(uri); + + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + StringBuilder sb = new StringBuilder(); + reader = new BufferedReader(new InputStreamReader( + con.getInputStream())); + + String line; + while ((line = reader.readLine()) != null) { + sb.append(line + "\n"); + } + + return sb.toString(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } finally { + if (reader != null) { + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + } + } + } + diff --git a/Android app/JAVA codes/InterviewRecord.java b/Android app/JAVA codes/InterviewRecord.java new file mode 100644 index 0000000..fc1ba20 --- /dev/null +++ b/Android app/JAVA codes/InterviewRecord.java @@ -0,0 +1,75 @@ +package com.example.tharushashehan.ermsapp04; + +import android.content.Intent; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + + +public class InterviewRecord extends ActionBarActivity { + + private Button btnInterviewPerson01; + private Button btnInterviewPerson02; + private Button btnInterviewRecordBack; + + // startActivity(new Intent(getApplicationContext(), InterviewRecord.class)); + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_interview_record); + + btnInterviewRecordBack =(Button)findViewById(R.id.btnInterviewRecordBack); + + btnInterviewRecordBack.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),secondActivity.class)); + } + }); + + btnInterviewPerson01 = (Button)findViewById(R.id.btnInterviewPerson01); + btnInterviewPerson02 = (Button)findViewById(R.id.btnInterviewPerson02); + + //delete this + btnInterviewPerson01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),iterviewPerson.class)); + } + }); + + btnInterviewPerson02.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(), iterviewPerson.class)); + } + }); + // to this + + } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_interview_record, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/Android app/JAVA codes/MainActivityLogin.java b/Android app/JAVA codes/MainActivityLogin.java new file mode 100644 index 0000000..ebbe05b --- /dev/null +++ b/Android app/JAVA codes/MainActivityLogin.java @@ -0,0 +1,65 @@ +package com.example.tharushashehan.ermsapp04; + + +import android.content.Intent; +import android.os.AsyncTask; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +public class MainActivityLogin extends ActionBarActivity { + + private EditText username,password; + private Button btnLogin; + + String usernameText,passwordText; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main_activity_login); + + username = (EditText) findViewById(R.id.edtusername); + password = (EditText) findViewById(R.id.edtpassword); + btnLogin = (Button) findViewById(R.id.btnSign); + + + btnLogin.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + usernameText = username.getText().toString(); + passwordText = password.getText().toString(); + + if (!usernameText.equals("") && !passwordText.equals("")) { + new ToService().execute(""); + } else { + Toast.makeText(MainActivityLogin.this, "Please Insert Name and password", Toast.LENGTH_LONG).show(); + } + } + }); + } + private class ToService extends AsyncTask { + + @Override + protected String doInBackground(String... params) { + String content = HttpManager.getData("http://192.168.56.1:8080/Android/URLParse?name="+usernameText+"&password="+passwordText); + return content;} + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + if(s.compareTo("Login Failed")==1){ + Toast.makeText(MainActivityLogin.this, "Login fail", Toast.LENGTH_LONG).show(); + } + else{ + // startActivity(new Intent(getApplicationContext(), secondActivity.class)); + startActivity(new Intent(getApplicationContext(), JsonTestActivity.class)); + } + } + } +} + diff --git a/Android app/JAVA codes/iterviewPerson.java b/Android app/JAVA codes/iterviewPerson.java new file mode 100644 index 0000000..3489be8 --- /dev/null +++ b/Android app/JAVA codes/iterviewPerson.java @@ -0,0 +1,52 @@ +package com.example.tharushashehan.ermsapp04; + +import android.content.Intent; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; + + +public class iterviewPerson extends ActionBarActivity { + + private Button btnInterviewPersonResult01; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_iterview_person); + + btnInterviewPersonResult01 =(Button) findViewById(R.id.btnInterviewPersonResult01); + + btnInterviewPersonResult01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),InterviewRecord.class)); + } + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_iterview_person, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/Android app/JAVA codes/massageDisplay.java b/Android app/JAVA codes/massageDisplay.java new file mode 100644 index 0000000..bffc3fa --- /dev/null +++ b/Android app/JAVA codes/massageDisplay.java @@ -0,0 +1,53 @@ +package com.example.tharushashehan.ermsapp04; + +import android.content.Intent; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.text.Layout; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; + + +public class massageDisplay extends ActionBarActivity { + + private Button btnMassageSend01; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_massage_display); + + btnMassageSend01 =(Button) findViewById(R.id.btnMassageSend01); + + btnMassageSend01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(), secondActivity.class)); + } + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_massage_display, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/Android app/JAVA codes/searchResult.java b/Android app/JAVA codes/searchResult.java new file mode 100644 index 0000000..87ae03a --- /dev/null +++ b/Android app/JAVA codes/searchResult.java @@ -0,0 +1,65 @@ +package com.example.tharushashehan.ermsapp04; + +import android.content.Intent; +import android.support.annotation.StringDef; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; + + +public class searchResult extends ActionBarActivity { + + private EditText txtSearchName, txtSearchdegree, txtSearchPost; + private Button btnSearchResultBack; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_search_result); + btnSearchResultBack =(Button) findViewById(R.id.btnSearchResultBack); + + btnSearchResultBack.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),secondActivity.class)); + } + }); + + } + + protected String doInBackground(String... params){ + String content=HttpManager.getData("http://192.168.56.1:8080/android/"); + return content; + } + + protected void onPostExecute(String s){ + + String[] word = s.split(s); + txtSearchName.setText(s); + txtSearchdegree.setText(s); + txtSearchPost.setText(s); + } + + /** @Override + public boolean onCreateOptionsMenu(Menu menu) { + + getMenuInflater().inflate(R.menu.menu_search_result, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + int id = item.getItemId(); + + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + }**/ +} diff --git a/Android app/JAVA codes/secondActivity.java b/Android app/JAVA codes/secondActivity.java new file mode 100644 index 0000000..76d1bb5 --- /dev/null +++ b/Android app/JAVA codes/secondActivity.java @@ -0,0 +1,279 @@ +package com.example.tharushashehan.ermsapp04; + +import android.app.Activity; +import android.content.Intent; +import android.os.AsyncTask; +import android.support.v7.app.ActionBarActivity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.ListAdapter; +import android.widget.ListView; +import android.widget.TabHost; +import android.widget.TextView; +import android.widget.Toast; + +import org.json.JSONObject; + +import java.util.ArrayList; + + +public class secondActivity extends ActionBarActivity { + + + private ListView lstTest01; + + private Button btnSearch; + private Button btnActivity03; + private Button btnLogout; + + private LinearLayout layMassage01; + private LinearLayout layMassage02; + private LinearLayout layMassage03; + private LinearLayout layInterview01; + private LinearLayout layInterview02; + private LinearLayout layInterview03; + + private TextView txtHomeUpdate; + private TextView txtAcceptRejectPerson; + private TextView txtSearchResult; + + private EditText edtSearchQuery; + + boolean acceptOrReject; + + String usernameText ="Tharusha"; + String passwordText = "12"; + String search; + String acceptOrRejectState; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_second); + + lstTest01 = (ListView) findViewById(R.id.lstTest01); + + btnActivity03 = (Button) findViewById(R.id.btnActivity); + btnSearch =(Button) findViewById(R.id.btnSearch); + btnLogout =(Button) findViewById(R.id.btnLogout); + + txtHomeUpdate =(TextView) this.findViewById(R.id.txtHomeUpdate); + txtAcceptRejectPerson =(TextView) this.findViewById(R.id.txtAcceptRejectPerson); + txtSearchResult =(TextView) this.findViewById(R.id.txtSearchResult); + edtSearchQuery = (EditText) findViewById(R.id.edtSearchQuery); + + layMassage01 =(LinearLayout) findViewById(R.id.layMassage01); + layMassage02 =(LinearLayout) findViewById(R.id.layMassage02); + layMassage03 =(LinearLayout) findViewById(R.id.layMassage03); + layInterview01 =(LinearLayout) findViewById(R.id.layInterview01); + layInterview02 = (LinearLayout) findViewById(R.id.layInterview02); + layInterview03 = (LinearLayout) findViewById(R.id.layInterview03); + + TabHost host = (TabHost)findViewById(R.id.tabHost); + host.setup(); + + //Tab 1 + //TabHost.TabSpec spec = host.newTabSpec("Tab One"); + TabHost.TabSpec tab1 = host.newTabSpec("Tab One"); + tab1.setContent(R.id.layhome); + tab1.setIndicator("HOME"); + host.addTab(tab1); + + //Tab 2 + // spec = host.newTabSpec("Tab Two"); + TabHost.TabSpec tab2 = host.newTabSpec("Tab Two"); + tab2.setContent(R.id.layaccept); + // tab2.setContent(new Intent(this, secondActivity.class)); + tab2.setIndicator("MASSAGE"); + host.addTab(tab2); + + //Tab 3 + //spec = host.newTabSpec("Tab Three"); + TabHost.TabSpec tab3 = host.newTabSpec("Tab Three"); + tab3.setContent(R.id.laysearch); + tab3.setIndicator("SEARCH"); + host.addTab(tab3); + + new ToService01().execute(""); + new YourActivity().onCreate(null); + + btnLogout.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),MainActivityLogin.class)); + } + }); + + + btnActivity03.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(), Actiity03.class)); + } + }); + + + + //tab 01 layouts work starts here + layInterview02.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(), InterviewRecord.class)); + } + }); + layInterview01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(), InterviewRecord.class)); + } + }); + layInterview03.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(), InterviewRecord.class)); + } + }); + + + + + //tab 02 layouts work starts here + layMassage01.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),massageDisplay.class)); + } + }); + layMassage02.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),massageDisplay.class)); + } + }); + layMassage03.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivity(new Intent(getApplicationContext(),massageDisplay.class)); + } + }); + + + + //tab 03 button work starts here + btnSearch.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + search = edtSearchQuery.getText().toString(); + startActivity(new Intent(getApplicationContext(), searchResult.class)); + + // new ToService04().execute(""); + } + }); + } + + private class ToService01 extends AsyncTask { + @Override + protected String doInBackground(String... params) { + ArrayList content = new ArrayList(); + content = httpManagerJson.getData("http://192.168.56.1:8080/Android/URIParse?name=" + usernameText + "&password=" + passwordText); + return content.toString(); + } + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + //txtHomeUpdate.setText(s); + } + } + + private class ToService02 extends AsyncTask { + + @Override + protected String doInBackground(String... params) { + String content = HttpManager.getData("http://192.168.56.1:8080/Android/Tab02Parse?name="+acceptOrReject); + return content; + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + txtAcceptRejectPerson.setText(s); + } + } + + private class ToService03 extends AsyncTask { + + @Override + protected String doInBackground(String... params) { + String content = HttpManager.getData("http://192.168.56.1:8080/Android/Tab02Parse?result="+acceptOrRejectState); + return content; + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + txtAcceptRejectPerson.setText(s); //txtAcceptRejectPerson + } + } + + + private class YourActivity extends Activity{ + @Override + protected void onCreate(Bundle saveInstanceState){ + ArrayAdapter Arr = new ArrayAdapter(this,android.R.layout.simple_list_item_1, + httpManagerJson.getData("http://192.168.56.1:8080/Android/URIParse?name=" + usernameText + "&password=" + passwordText)); + lstTest01.setAdapter(Arr); + } + } + + + + //no need to look at + /** + private class ToService04 extends AsyncTask { + + @Override + protected String doInBackground(String... params) { + String content = HttpManager.getData("http://192.168.56.1:8080/Android/Tab03Parse?name="+search); + return content; + } + + @Override + protected void onPostExecute(String s) { + super.onPostExecute(s); + txtSearchResult.setText(s); + } + + + } + + + **/ + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_second, 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(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} \ No newline at end of file diff --git a/Android app/layout/activity_actiity03.xml b/Android app/layout/activity_actiity03.xml new file mode 100644 index 0000000..7a2fa9f --- /dev/null +++ b/Android app/layout/activity_actiity03.xml @@ -0,0 +1,33 @@ + + + + + + diff --git a/Android app/layout/activity_interview_record.xml b/Android app/layout/activity_interview_record.xml new file mode 100644 index 0000000..61972aa --- /dev/null +++ b/Android app/layout/activity_interview_record.xml @@ -0,0 +1,132 @@ + + + +