├── Android Client
├── AndroidManifest.xml
├── java
│ ├── ServerRequest.java
│ └── com
│ │ └── virtualclassroom
│ │ └── main
│ │ └── virtualclassroom
│ │ ├── ForumActivity.java
│ │ ├── LectureActivity.java
│ │ ├── LoginActivity.java
│ │ ├── LoginActivityFragment.java
│ │ ├── MainActivity.java
│ │ ├── ProfileActivity.java
│ │ ├── Question.java
│ │ ├── RegisterActivity.java
│ │ ├── ResponseDetails.java
│ │ └── VideoShow.java
└── res
│ ├── layout
│ ├── activity_forum.xml
│ ├── activity_lecture.xml
│ ├── activity_login.xml
│ ├── activity_main.xml
│ ├── activity_profile.xml
│ ├── activity_question.xml
│ ├── activity_register.xml
│ ├── activity_response_details.xml
│ ├── activity_video_show.xml
│ ├── attend_lecture_option.xml
│ ├── chgpassword_frag.xml
│ ├── content_forum.xml
│ ├── content_lecture.xml
│ ├── content_login.xml
│ ├── content_main.xml
│ ├── content_profile.xml
│ ├── content_question.xml
│ ├── content_register.xml
│ ├── content_response_details.xml
│ ├── content_video_show.xml
│ ├── files_name.xml
│ ├── files_on_server.xml
│ ├── forum_answer.xml
│ ├── fragment_login.xml
│ ├── reset_pass_code.xml
│ ├── reset_pass_init.xml
│ ├── response_list_items.xml
│ └── simple_list_view.xml
│ ├── menu
│ └── menu_login.xml
│ ├── mipmap-hdpi
│ ├── d.png
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ ├── d.png
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ ├── d.png
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ ├── d.png
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ ├── d.png
│ └── ic_launcher.png
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── Database
└── New Text Document.txt
├── README.md
├── Screenshots
├── Screenshot_2016-05-14-09-23-18.png
├── Screenshot_2016-05-14-09-23-36.png
├── Screenshot_2016-05-14-09-23-41.png
├── Screenshot_2016-05-14-09-23-46.png
├── Screenshot_2016-05-14-09-24-09.png
├── Screenshot_2016-05-14-09-24-15.png
├── Screenshot_2016-05-14-09-24-20.png
├── Screenshot_2016-05-14-09-24-42.png
├── Screenshot_2016-05-14-09-24-48.png
├── Screenshot_2016-05-14-09-25-04.png
├── Screenshot_2016-05-14-09-25-33.png
├── Screenshot_2016-05-14-09-27-35.png
└── Screenshot_2016-05-14-09-28-01.png
├── app-debug-unaligned.apk
├── app-debug.apk
└── node JS Server
├── app.js
├── node_modules
└── config
│ ├── chgpass.js
│ ├── login.js
│ ├── loginFacutly.js
│ ├── models.js
│ └── register.js
├── package.json
├── routes
└── routes.js
└── webrtc-broadcasting
├── DetectRTC.js
├── README.md
├── RTCPeerConnection-v1.5.js
├── broadcast.js
├── firebase.js
└── index.html
/Android Client/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
19 |
23 |
26 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
43 |
47 |
51 |
55 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/Android Client/java/ServerRequest.java:
--------------------------------------------------------------------------------
1 | package com.virtualclassroom.main;
2 |
3 |
4 | import java.io.BufferedReader;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.InputStreamReader;
8 | import java.io.UnsupportedEncodingException;
9 | import java.util.List;
10 | import java.util.concurrent.ExecutionException;
11 | import org.apache.http.HttpEntity;
12 | import org.apache.http.HttpResponse;
13 | import org.apache.http.NameValuePair;
14 | import org.apache.http.client.ClientProtocolException;
15 | import org.apache.http.client.entity.UrlEncodedFormEntity;
16 | import org.apache.http.client.methods.HttpPost;
17 | import org.apache.http.impl.client.DefaultHttpClient;
18 | import org.json.JSONException;
19 | import org.json.JSONObject;
20 |
21 | import android.os.AsyncTask;
22 | import android.util.Log;
23 |
24 | public class ServerRequest {
25 |
26 | static InputStream is = null;
27 | static JSONObject jObj = null;
28 | static String json = "";
29 |
30 |
31 | public ServerRequest() {
32 |
33 | }
34 |
35 | public JSONObject getJSONFromUrl(String url, List params) {
36 |
37 |
38 | try {
39 |
40 | DefaultHttpClient httpClient = new DefaultHttpClient();
41 | HttpPost httpPost = new HttpPost(url);
42 | httpPost.setEntity(new UrlEncodedFormEntity(params));
43 |
44 | HttpResponse httpResponse = httpClient.execute(httpPost);
45 | HttpEntity httpEntity = httpResponse.getEntity();
46 | is = httpEntity.getContent();
47 |
48 | } catch (UnsupportedEncodingException e) {
49 | e.printStackTrace();
50 | } catch (ClientProtocolException e) {
51 | e.printStackTrace();
52 | } catch (IOException e) {
53 | e.printStackTrace();
54 | }
55 |
56 | try {
57 | BufferedReader reader = new BufferedReader(new InputStreamReader(
58 | is, "iso-8859-1"), 8);
59 | StringBuilder sb = new StringBuilder();
60 | String line = null;
61 | while ((line = reader.readLine()) != null) {
62 | sb.append(line + "n");
63 | }
64 | is.close();
65 | json = sb.toString();
66 | Log.e("JSON", json);
67 | } catch (Exception e) {
68 | Log.e("Buffer Error", "Error converting result " + e.toString());
69 | }
70 |
71 |
72 | try {
73 | jObj = new JSONObject(json);
74 | } catch (JSONException e) {
75 | Log.e("JSON Parser", "Error parsing data " + e.toString());
76 | }
77 |
78 |
79 | return jObj;
80 |
81 | }
82 | JSONObject jobj;
83 | public JSONObject getJSON(String url, List params) {
84 |
85 | Params param = new Params(url,params);
86 | Request myTask = new Request();
87 | try{
88 | jobj= myTask.execute(param).get();
89 | }catch (InterruptedException e) {
90 | e.printStackTrace();
91 | }catch (ExecutionException e){
92 | e.printStackTrace();
93 | }
94 | return jobj;
95 | }
96 |
97 |
98 | private static class Params {
99 | String url;
100 | List params;
101 |
102 |
103 | Params(String url, List params) {
104 | this.url = url;
105 | this.params = params;
106 |
107 | }
108 | }
109 |
110 | private class Request extends AsyncTask {
111 |
112 | @Override
113 | protected JSONObject doInBackground(Params... args) {
114 |
115 | ServerRequest request = new ServerRequest();
116 | JSONObject json = request.getJSONFromUrl(args[0].url,args[0].params);
117 |
118 | return json;
119 | }
120 |
121 | @Override
122 | protected void onPostExecute(JSONObject json) {
123 |
124 | super.onPostExecute(json);
125 |
126 | }
127 |
128 | }
129 |
130 |
131 | }
--------------------------------------------------------------------------------
/Android Client/java/com/virtualclassroom/main/virtualclassroom/ForumActivity.java:
--------------------------------------------------------------------------------
1 | package com.virtualclassroom.main.virtualclassroom;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 | import android.provider.Settings;
9 | import android.support.design.widget.FloatingActionButton;
10 | import android.support.design.widget.Snackbar;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.support.v7.widget.Toolbar;
13 | import android.util.Log;
14 | import android.view.LayoutInflater;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.AbsListView;
18 | import android.widget.AdapterView;
19 | import android.widget.ArrayAdapter;
20 | import android.widget.Button;
21 | import android.widget.EditText;
22 | import android.widget.ListView;
23 | import android.widget.TextView;
24 | import android.widget.Toast;
25 |
26 | import com.virtualclassroom.main.ServerRequest;
27 |
28 | import org.apache.http.NameValuePair;
29 | import org.apache.http.message.BasicNameValuePair;
30 | import org.json.JSONArray;
31 | import org.json.JSONException;
32 | import org.json.JSONObject;
33 |
34 | import java.util.ArrayList;
35 | import java.util.HashMap;
36 | import java.util.Iterator;
37 | import java.util.List;
38 | import java.util.Objects;
39 |
40 | public class ForumActivity extends AppCompatActivity {
41 | EditText text;
42 | Button upload, refresh;
43 | String emailtxt,result="",ques="";
44 | SharedPreferences pref;
45 | List params;
46 | HashMap data = new HashMap();
47 | ListView forumlist;
48 | ArrayAdapter arrayAdapter;
49 | ProgressDialog progressDialog;
50 | boolean records=false;
51 | Forum[] forums;
52 | public static String totalAnswers="",totalUsers="";
53 |
54 |
55 | @Override
56 | protected void onCreate(Bundle savedInstanceState) {
57 |
58 | super.onCreate(savedInstanceState);
59 | setContentView(R.layout.activity_forum);
60 |
61 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
62 | pref = getSharedPreferences("AppPref", MODE_PRIVATE);
63 | emailtxt = pref.getString("email", "Anonymous");
64 | setSupportActionBar(toolbar);
65 | text = (EditText) findViewById(R.id.ques);
66 | upload = (Button) findViewById(R.id.upload);
67 | forumlist = (ListView) findViewById(R.id.list);
68 | forumlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
69 | @Override
70 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
71 | SharedPreferences.Editor edit = pref.edit();
72 | Forum f = (Forum) parent.getItemAtPosition(parent.getCount() - 1 - position);
73 | edit.putString("emailFromForum", f.getQuesUser());
74 | edit.putString("quesFromForum", f.getQues());
75 | edit.putString("ansUserFromForum", f.getAnsUser());
76 | edit.putString("ansFromForum", f.getAns());
77 | edit.putString("email", emailtxt);
78 | edit.commit();
79 | Intent i = new Intent(ForumActivity.this, Question.class);
80 | startActivity(i);
81 |
82 | }
83 | });
84 | upload.setOnClickListener(new View.OnClickListener() {
85 | @Override
86 | public void onClick(View v) {
87 | if (text.getText().toString().trim().equals(""))
88 | Toast.makeText(getApplication(), "Plaese write something...", Toast.LENGTH_LONG).show();
89 | else
90 | uploadQuestion();
91 | }
92 | });
93 |
94 | refresh = (Button) findViewById(R.id.refresh);
95 | refresh.setOnClickListener(new View.OnClickListener() {
96 |
97 | @Override
98 | public void onClick(View v) {
99 | try {
100 |
101 | getQuestionsList(true);
102 |
103 | }
104 | catch (Exception e)
105 | {
106 | Toast.makeText(getApplicationContext(),e.getMessage(),Toast.LENGTH_LONG).show();
107 | }
108 | }
109 |
110 |
111 | });
112 |
113 |
114 | }
115 |
116 |
117 |
118 | class Forum {
119 | String quesUser, ques, ansUser, ans;
120 |
121 | public String getQuesUser() {
122 | return quesUser;
123 | }
124 |
125 | public void setQuesUser(String quesUser) {
126 | this.quesUser = quesUser;
127 | }
128 |
129 | public String getQues() {
130 | return ques;
131 | }
132 |
133 | public void setQues(String ques) {
134 | this.ques = ques;
135 | }
136 |
137 | public String getAnsUser() {
138 | return ansUser;
139 | }
140 |
141 | public void setAnsUser(String ansUser) {
142 | this.ansUser = ansUser;
143 | }
144 |
145 | public String getAns() {
146 | return ans;
147 | }
148 |
149 | public void setAns(String ans) {
150 | this.ans = ans;
151 | }
152 | }
153 |
154 | class ForumAdapter extends ArrayAdapter {
155 | ForumAdapter() {
156 | super(getApplicationContext(), R.layout.simple_list_view, forums);
157 | }
158 |
159 | @Override
160 | public int getCount() {
161 | return forums.length;
162 | }
163 |
164 |
165 | @Override
166 | public View getView(int position, View convertView, ViewGroup parent) {
167 | if (convertView == null) {
168 | LayoutInflater layoutInflater = ForumActivity.this.getLayoutInflater();
169 | convertView = layoutInflater.inflate(R.layout.simple_list_view, parent, false);
170 | }
171 | if (position < getCount()) {
172 | TextView firstLine = (TextView) convertView.findViewById(R.id.email);
173 | TextView secondLine = (TextView) convertView.findViewById(R.id.contents);
174 | firstLine.setText(String.valueOf(forums[getCount() - 1 - position].getQuesUser()));
175 | secondLine.setText(forums[getCount() - 1 - position].getQues());
176 | }
177 | return convertView;
178 | }
179 | }
180 |
181 |
182 | public String[] getRefreshedList(String email ,String ques)
183 | {
184 | getQuestionsList(false);
185 | String[] response=new String[2];
186 | for(int i=0;i();
212 | ServerRequest sr = new ServerRequest();
213 | // JSONObject json = sr.getJSON("http://192.168.56.1:8080/api/chgpass",params);
214 | JSONObject json = sr.getJSON("http://192.168.43.101:8080/forumList", params);
215 | if (json != null) {
216 | try {
217 | int i = 0;
218 | int len = json.length();
219 | forums = new Forum[len];
220 | Iterator iterator = json.keys();
221 | while (iterator.hasNext()) {
222 | JSONObject jsonObject = json.getJSONObject(iterator.next());
223 | Forum f = new Forum();
224 | f.setQuesUser(jsonObject.getString("quesUser"));
225 | f.setQues(jsonObject.getString("ques"));
226 | f.setAnsUser(jsonObject.getString("ansUser"));
227 | f.setAns(jsonObject.getString("ans"));
228 | forums[i] = f;
229 | i++;
230 | }
231 | result=len+" Records Fetched!!";
232 | records=true;
233 |
234 | } catch (JSONException e) {
235 | result=e.getMessage();
236 | records=false;
237 |
238 | }
239 |
240 | } else {
241 | result = "No Records!!";
242 | records=false;
243 |
244 | }
245 |
246 | if(value) {
247 | runOnUiThread(new Runnable() {
248 | @Override
249 | public void run() {
250 | Toast.makeText(getApplicationContext(), "Populating List...\n PLease Wait...", Toast.LENGTH_LONG);
251 | if (records) {
252 | setUpListView();
253 | records = false;
254 |
255 | }
256 | progressDialog.dismiss();
257 | Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG);
258 |
259 |
260 | }
261 | });
262 | }
263 |
264 | }
265 |
266 |
267 | };
268 | t.setDaemon(true);
269 | t.start();
270 |
271 |
272 |
273 | }
274 |
275 | public void setUpListView()
276 | {
277 | forumlist.setAdapter(new ForumAdapter());
278 |
279 | }
280 |
281 | public void uploadQuestion()
282 | {
283 | progressDialog = new ProgressDialog(this);
284 | progressDialog.setMessage("Uploading...");
285 | progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
286 | progressDialog.setIndeterminate(true);
287 | progressDialog.setCanceledOnTouchOutside(false);
288 |
289 | progressDialog.show();
290 |
291 | final Thread t = new Thread() {
292 |
293 | public void run() {
294 | params = new ArrayList();
295 | pref = getSharedPreferences("AppPref", MODE_PRIVATE);
296 | emailtxt = pref.getString("email", "");
297 | params.add(new BasicNameValuePair("quesUser", emailtxt));
298 | params.add(new BasicNameValuePair("ques", text.getText().toString().trim()));
299 | ServerRequest sr = new ServerRequest();
300 | // JSONObject json = sr.getJSON("http://192.168.56.1:8080/api/chgpass",params);
301 | JSONObject json = sr.getJSON("http://192.168.43.101:8080/registerForum", params);
302 | if (json != null) {
303 | try {
304 | String jsonstr = json.getString("response");
305 | result=jsonstr;
306 |
307 | } catch (JSONException e) {
308 | result=e.getMessage();
309 | }
310 | }
311 |
312 | runOnUiThread(new Runnable() {
313 | @Override
314 | public void run() {
315 | progressDialog.dismiss();
316 | text.setText("");
317 | Toast.makeText(getApplicationContext(),result,Toast.LENGTH_LONG).show();
318 | getQuestionsList(true);
319 | }
320 | });
321 |
322 | }
323 | };
324 | t.setDaemon(true);
325 | t.start();
326 |
327 |
328 |
329 | }
330 |
331 |
332 |
333 |
334 | }
--------------------------------------------------------------------------------
/Android Client/java/com/virtualclassroom/main/virtualclassroom/LectureActivity.java:
--------------------------------------------------------------------------------
1 | package com.virtualclassroom.main.virtualclassroom;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.webkit.WebChromeClient;
10 | import android.webkit.WebSettings;
11 | import android.webkit.WebView;
12 | import android.webkit.WebViewClient;
13 |
14 | public class LectureActivity extends AppCompatActivity {
15 | WebView webView;
16 | String url="192.168.43.101:8081";
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_lecture);
21 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
22 | setSupportActionBar(toolbar);
23 | webView=(WebView)findViewById(R.id.lecture);
24 |
25 | webView.setWebChromeClient(new WebChromeClient());
26 | webView.getSettings().setJavaScriptEnabled(true);
27 | webView.getSettings().setLoadWithOverviewMode(true);
28 | webView.getSettings().setUseWideViewPort(true);
29 | webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
30 | webView.setScrollbarFadingEnabled(false);
31 | webView.getSettings().setBuiltInZoomControls(true);
32 | webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
33 | webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
34 | webView.setWebViewClient(new MyLecture());
35 | webView.loadUrl(url);
36 | }
37 |
38 | class MyLecture extends WebViewClient{
39 | @Override
40 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
41 | view.loadUrl(url);
42 | return true;
43 | }
44 | }
45 |
46 | @Override
47 | public void onBackPressed() {
48 | super.onBackPressed();
49 | webView.clearSslPreferences();
50 | webView.clearCache(true);
51 | finish();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Android Client/java/com/virtualclassroom/main/virtualclassroom/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.virtualclassroom.main.virtualclassroom;
2 |
3 | import android.app.ProgressDialog;
4 | import android.inputmethodservice.KeyboardView;
5 | import android.os.AsyncTask;
6 | import android.os.Bundle;
7 | import android.support.design.widget.FloatingActionButton;
8 | import android.support.design.widget.Snackbar;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.support.v7.widget.Toolbar;
11 | import android.view.View;
12 | import android.view.Menu;
13 | import android.view.MenuItem;
14 |
15 | import android.app.Activity;
16 | import android.app.Dialog;
17 | import android.content.Intent;
18 | import android.content.SharedPreferences;
19 | import android.os.Bundle;
20 | import android.util.Log;
21 | import android.view.View;
22 | import android.widget.Button;
23 | import android.widget.EditText;
24 | import android.widget.Toast;
25 |
26 | import org.apache.http.NameValuePair;
27 | import org.apache.http.message.BasicNameValuePair;
28 | import org.json.JSONException;
29 | import org.json.JSONObject;
30 |
31 | import java.util.ArrayList;
32 | import java.util.List;
33 |
34 | import com.virtualclassroom.main.ServerRequest;
35 |
36 |
37 | public class LoginActivity extends AppCompatActivity {
38 | EditText email,password,res_email,code,newpass;
39 | Button login,cont,cont_code,cancel,cancel1,register,forpass;
40 | String emailtxt,passwordtxt,email_res_txt,code_txt,npass_txt;
41 | List params;
42 | SharedPreferences pref;
43 | Dialog reset;
44 | ServerRequest sr;
45 | String k,jsonstr=null;
46 | ProgressDialog progressDialog;
47 |
48 | @Override
49 | protected void onCreate(Bundle savedInstanceState) {
50 | super.onCreate(savedInstanceState);
51 | setContentView(R.layout.activity_login);
52 | pref = getSharedPreferences("AppPref", MODE_PRIVATE);
53 | sr = new ServerRequest();
54 | Intent i=getIntent();
55 | Bundle b=i.getExtras();
56 | if(b!=null) {
57 | k = (String) b.get("name");
58 | this.setTitle(k+" Login ");
59 | }
60 |
61 | email = (EditText)findViewById(R.id.email);
62 | password = (EditText)findViewById(R.id.password);
63 | login = (Button)findViewById(R.id.loginbtn);
64 | register = (Button)findViewById(R.id.register);
65 | forpass = (Button)findViewById(R.id.forgotpass);
66 |
67 | register.setOnClickListener(new View.OnClickListener() {
68 | @Override
69 | public void onClick(View view) {
70 | Intent regactivity = new Intent(LoginActivity.this,RegisterActivity.class);
71 | regactivity.putExtra("name",LoginActivity.this.k);
72 | startActivity(regactivity);
73 |
74 | }
75 | });
76 |
77 |
78 | login.setOnClickListener(new View.OnClickListener() {
79 |
80 |
81 | @Override
82 | public void onClick(View view) {
83 | try {
84 |
85 | Login();
86 |
87 | }catch (Exception e)
88 | {
89 | Toast.makeText(getApplication(),e.getMessage(),Toast.LENGTH_LONG).show();
90 | }
91 | }
92 | });
93 |
94 | forpass.setOnClickListener(new View.OnClickListener(){
95 | @Override
96 | public void onClick(View view) {
97 | reset = new Dialog(LoginActivity.this);
98 | reset.setTitle("Reset Password");
99 | reset.setContentView(R.layout.reset_pass_init);
100 | cont = (Button)reset.findViewById(R.id.resbtn);
101 | cancel = (Button)reset.findViewById(R.id.cancelbtn);
102 | cancel.setOnClickListener(new View.OnClickListener() {
103 | @Override
104 | public void onClick(View view) {
105 | reset.dismiss();
106 | }
107 | });
108 | res_email = (EditText)reset.findViewById(R.id.email);
109 |
110 | cont.setOnClickListener(new View.OnClickListener() {
111 | @Override
112 | public void onClick(View view) {
113 | email_res_txt = res_email.getText().toString();
114 |
115 | params = new ArrayList();
116 | params.add(new BasicNameValuePair("email", email_res_txt));
117 |
118 | // JSONObject json = sr.getJSON("http://192.168.56.1:8080/api/resetpass", params);
119 | JSONObject json = sr.getJSON("http://192.168.43.101:8080/api/resetpass", params);
120 |
121 | if (json != null) {
122 | try {
123 | String jsonstr = json.getString("response");
124 | if(json.getBoolean("res")){
125 | Log.e("JSON", jsonstr);
126 | Toast.makeText(getApplication(), jsonstr, Toast.LENGTH_LONG).show();
127 | reset.setContentView(R.layout.reset_pass_code);
128 | cont_code = (Button)reset.findViewById(R.id.conbtn);
129 | code = (EditText)reset.findViewById(R.id.code);
130 | newpass = (EditText)reset.findViewById(R.id.npass);
131 | cancel1 = (Button)reset.findViewById(R.id.cancel);
132 | cancel1.setOnClickListener(new View.OnClickListener() {
133 | @Override
134 | public void onClick(View view) {
135 | reset.dismiss();
136 | }
137 | });
138 | cont_code.setOnClickListener(new View.OnClickListener() {
139 | @Override
140 | public void onClick(View view) {
141 | code_txt = code.getText().toString();
142 | npass_txt = newpass.getText().toString();
143 | Log.e("Code",code_txt);
144 | Log.e("New pass",npass_txt);
145 | params = new ArrayList();
146 | params.add(new BasicNameValuePair("email", email_res_txt));
147 | params.add(new BasicNameValuePair("code", code_txt));
148 | params.add(new BasicNameValuePair("newpass", npass_txt));
149 |
150 | JSONObject json = sr.getJSON("http://192.168.43.101:8080/api/resetpass/chg", params);
151 | // JSONObject json = sr.getJSON("http://192.168.56.1:8080/api/resetpass/chg", params);
152 |
153 | if (json != null) {
154 | try {
155 |
156 | String jsonstr = json.getString("response");
157 | if(json.getBoolean("res")){
158 | reset.dismiss();
159 | Toast.makeText(getApplication(),jsonstr,Toast.LENGTH_LONG).show();
160 |
161 | }else{
162 | Toast.makeText(getApplication(),jsonstr,Toast.LENGTH_LONG).show();
163 |
164 | }
165 | } catch (JSONException e) {
166 | Toast.makeText(getApplication(), "Check Your Internet Connection - "+e.getMessage(), Toast.LENGTH_SHORT).show();
167 |
168 | }
169 | }
170 |
171 | }
172 | });
173 | }else{
174 |
175 | Toast.makeText(getApplication(),jsonstr,Toast.LENGTH_LONG).show();
176 |
177 | }
178 | } catch (JSONException e) {
179 | Toast.makeText(getApplication(), "Check Your Internet Connection - "+e.getMessage(), Toast.LENGTH_SHORT).show();
180 |
181 | }
182 | }
183 |
184 | }
185 | });
186 |
187 |
188 | reset.show();
189 | }
190 | });
191 | }
192 |
193 |
194 |
195 |
196 |
197 | public void Login() {
198 | emailtxt = email.getText().toString().trim();
199 | passwordtxt = password.getText().toString().trim();
200 | progressDialog=new ProgressDialog(LoginActivity.this);
201 | progressDialog.setMessage("Please Wait...");
202 | progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
203 | progressDialog.setIndeterminate(true);
204 | progressDialog.setCanceledOnTouchOutside(false);
205 | progressDialog.show();
206 |
207 | final Thread t = new Thread() {
208 | public void run() {
209 | JSONObject json;
210 | params = new ArrayList();
211 | params.add(new BasicNameValuePair("email", emailtxt));
212 | params.add(new BasicNameValuePair("password", passwordtxt));
213 | ServerRequest sr = new ServerRequest();
214 | if(LoginActivity.this.k.toUpperCase().equals("FACULTY"))
215 | json = sr.getJSON("http://192.168.43.101:8080/loginFaculty",params);
216 | else
217 | json = sr.getJSON("http://192.168.43.101:8080/login", params);
218 | if (json != null) {
219 | try {
220 | jsonstr = json.getString("response");
221 | } catch (JSONException e) {
222 | jsonstr=e.getMessage();
223 | }
224 | }
225 | try {
226 | if (json.getBoolean("res")) {
227 |
228 | String token = json.getString("token");
229 | String grav = json.getString("grav");
230 | String name = json.getString("name");
231 | String branch = json.getString("branch");
232 | String email = json.getString("email");
233 | SharedPreferences.Editor edit = pref.edit();
234 | edit.putString("token", token);
235 | edit.putString("grav", grav);
236 | edit.putString("email", email);
237 | edit.putString("name", name);
238 | edit.putString("branch", branch);
239 | edit.putString("owner", k);
240 | edit.commit();
241 | progressDialog.dismiss();
242 | Intent profactivity = new Intent(LoginActivity.this, ProfileActivity.class);
243 | startActivity(profactivity);
244 | finish();
245 | }
246 |
247 |
248 | } catch (Exception e) {
249 |
250 | jsonstr+=" "+e.getMessage();
251 | }
252 |
253 |
254 | runOnUiThread(new Runnable() {
255 | @Override
256 | public void run() {
257 | progressDialog.dismiss();
258 | Toast.makeText(getApplication(), jsonstr, Toast.LENGTH_SHORT).show();
259 | email.setText("");
260 | password.setText("");
261 | }
262 | });
263 |
264 |
265 | }
266 | };
267 | t.setDaemon(true);
268 | t.start();
269 |
270 |
271 |
272 | }
273 |
274 |
275 | }
276 |
--------------------------------------------------------------------------------
/Android Client/java/com/virtualclassroom/main/virtualclassroom/LoginActivityFragment.java:
--------------------------------------------------------------------------------
1 | package com.virtualclassroom.main.virtualclassroom;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | /**
10 | * A placeholder fragment containing a simple view.
11 | */
12 | public class LoginActivityFragment extends Fragment {
13 |
14 | public LoginActivityFragment() {
15 | }
16 |
17 | @Override
18 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
19 | Bundle savedInstanceState) {
20 | return inflater.inflate(R.layout.fragment_login, container, false);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Android Client/java/com/virtualclassroom/main/virtualclassroom/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.virtualclassroom.main.virtualclassroom;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.View;
10 | import android.widget.Button;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19 | setSupportActionBar(toolbar);
20 | Button b1=(Button)findViewById(R.id.button);
21 | Button b2=(Button)findViewById(R.id.button2);
22 | b1.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View v) {
25 |
26 | Intent i=new Intent(MainActivity.this,LoginActivity.class);
27 | i.putExtra("name","student");
28 | startActivity(i);
29 | finish();
30 | }
31 | });
32 | b2.setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View v) {
35 |
36 | Intent i=new Intent(MainActivity.this,LoginActivity.class);
37 | i.putExtra("name","faculty");
38 | startActivity(i);
39 | finish();
40 | }
41 | });
42 |
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Android Client/java/com/virtualclassroom/main/virtualclassroom/ProfileActivity.java:
--------------------------------------------------------------------------------
1 | package com.virtualclassroom.main.virtualclassroom;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 | import android.net.Uri;
6 | import android.os.AsyncTask;
7 | import android.os.Bundle;
8 |
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.support.v7.widget.Toolbar;
11 | import android.util.Log;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import java.io.FileOutputStream;
15 |
16 | import com.koushikdutta.ion.*;
17 |
18 | import java.io.BufferedInputStream;
19 | import java.io.FileOutputStream;
20 | import java.io.InputStream;
21 | import java.io.OutputStream;
22 | import java.net.URL;
23 | import java.net.URLConnection;
24 | import java.util.Iterator;
25 | import java.util.concurrent.Future;
26 | import com.koushikdutta.async.future.FutureCallback;
27 |
28 | import android.app.Activity;
29 | import android.app.Dialog;
30 | import android.content.Intent;
31 | import android.content.SharedPreferences;
32 | import android.os.Bundle;
33 | import android.view.View;
34 | import android.view.ViewGroup;
35 | import android.webkit.WebView;
36 | import android.widget.AdapterView;
37 | import android.widget.ArrayAdapter;
38 | import android.widget.Button;
39 | import android.widget.EditText;
40 | import android.widget.ListView;
41 | import android.widget.TextView;
42 | import android.widget.Toast;
43 |
44 | import com.virtualclassroom.main.ServerRequest;
45 |
46 | import org.apache.http.NameValuePair;
47 | import org.apache.http.message.BasicNameValuePair;
48 | import org.json.JSONArray;
49 | import org.json.JSONException;
50 | import org.json.JSONObject;
51 | import org.jsoup.Jsoup;
52 | import org.jsoup.nodes.Element;
53 | import org.jsoup.nodes.Document;
54 | import org.jsoup.select.Elements;
55 |
56 |
57 | import java.io.File;
58 | import java.util.ArrayList;
59 | import java.util.List;
60 |
61 | public class ProfileActivity extends AppCompatActivity {
62 |
63 |
64 | SharedPreferences pref;
65 |
66 | String token, grav, oldpasstxt, newpasstxt, emailtxt, nametxt, branchtxt, passwordtxt,owner,file_to_download="";
67 | WebView web;
68 | Button chgpass, chgpassfr, cancel, logout, forum, fileupload,lecture,livelecture,recordlecture;
69 | Dialog dlg,filesDialog,lectuedlg,lecturesDialog;
70 | EditText oldpass, newpass;
71 | TextView nameTextView, branchTV, emailTV, filename;
72 | List params;
73 | List filesOnServer;
74 | Object files[];
75 | ListView filesList;
76 | ProgressDialog progressDialog;
77 | @Override
78 | protected void onCreate(Bundle savedInstanceState) {
79 | super.onCreate(savedInstanceState);
80 | setContentView(R.layout.activity_profile);
81 | lecture=(Button)findViewById(R.id.lecture);
82 | lecture.setOnClickListener(new View.OnClickListener() {
83 | @Override
84 | public void onClick(View v) {
85 | Intent i = new Intent(ProfileActivity.this, LectureActivity.class);
86 | startActivity(i);
87 |
88 | }
89 | });
90 | // web = (WebView)findViewById(R.id.webView);
91 | lecture.setOnClickListener(new View.OnClickListener() {
92 | @Override
93 | public void onClick(View v) {
94 |
95 | lectuedlg=new Dialog(ProfileActivity.this);
96 | if(owner.trim().equals("faculty"))
97 | lectuedlg.setTitle("Options...");
98 | else
99 | lectuedlg.setTitle("You can Watch ...");
100 | lectuedlg.setContentView(R.layout.attend_lecture_option);
101 | livelecture=(Button)lectuedlg.findViewById(R.id.option1);
102 | recordlecture=(Button)lectuedlg.findViewById(R.id.option2);
103 | if(owner.trim().equals("faculty"))
104 | livelecture.setText("Take Lecture");
105 | lectuedlg.show();
106 | recordlecture.setOnClickListener(new View.OnClickListener() {
107 | @Override
108 | public void onClick(View v) {
109 | params = new ArrayList();
110 |
111 | ServerRequest sr = new ServerRequest();
112 | JSONObject json = sr.getJSON("http://192.168.43.101:8080/videoList", params);
113 | if (json != null) {
114 | try {
115 | int len = json.length();
116 | filesOnServer=new ArrayList(len);
117 | if(len==0)
118 | Toast.makeText(getApplication(), "No Vedios Available!", Toast.LENGTH_SHORT).show();
119 | else {
120 | JSONArray jsonArray=json.getJSONArray("Files");
121 | for(int i=0;i parent, View view, int position, long id) {
142 |
143 | String filename = (String) parent.getItemAtPosition(position);
144 | SharedPreferences.Editor edit = pref.edit();
145 | edit.putString("file", "http://192.168.43.101:8080/video?name="+filename);
146 | edit.commit();
147 | Intent i = new Intent(ProfileActivity.this, VideoShow.class);
148 | startActivity(i);
149 |
150 |
151 | }
152 |
153 | });
154 |
155 | }
156 | });
157 |
158 | livelecture.setOnClickListener(new View.OnClickListener() {
159 | @Override
160 | public void onClick(View v) {
161 | if (owner.trim().equals("faculty")) {
162 | Intent i = new Intent(Intent.ACTION_VIEW);
163 | i.setData(Uri.parse("https://www.webrtc-experiment.com/webrtc-broadcasting/"));
164 | startActivity(i);
165 | }
166 | else
167 | {
168 | SharedPreferences.Editor edit = pref.edit();
169 | edit.putString("file", "https://www.webrtc-experiment.com/webrtc-broadcasting/");
170 | edit.commit();
171 | Intent i = new Intent(ProfileActivity.this, VideoShow.class);
172 | startActivity(i);
173 | //new JP().execute("https://www.webrtc-experiment.com/webrtc-broadcasting/");
174 | }
175 |
176 | }
177 | });
178 |
179 | }
180 | });
181 | chgpass = (Button) findViewById(R.id.chgbtn);
182 | logout = (Button) findViewById(R.id.logout);
183 | nameTextView = (TextView) findViewById(R.id.name);
184 | branchTV = (TextView) findViewById(R.id.branch);
185 | emailTV = (TextView) findViewById(R.id.email);
186 | filename = (TextView) findViewById(R.id.filename);
187 | forum = (Button) findViewById(R.id.forum);
188 |
189 |
190 | forum.setOnClickListener(new View.OnClickListener() {
191 | @Override
192 | public void onClick(View v) {
193 | SharedPreferences.Editor edit = pref.edit();
194 | //Storing Data using SharedPreferences
195 | edit.putString("email", ProfileActivity.this.emailtxt);
196 | edit.commit();
197 | Intent loginactivity = new Intent(ProfileActivity.this, ForumActivity.class);
198 | startActivity(loginactivity);
199 |
200 | }
201 | });
202 |
203 | fileupload = (Button) findViewById(R.id.fileuplaod);
204 | fileupload.setOnClickListener(new View.OnClickListener() {
205 | @Override
206 | public void onClick(View v) {
207 | if (owner.trim().equals("faculty")) {
208 | ProfileActivity.this.showFiles();
209 | } else {
210 | params = new ArrayList();
211 |
212 | ServerRequest sr = new ServerRequest();
213 | JSONObject json = sr.getJSON("http://192.168.43.101:8080/filesList", params);
214 | if (json != null) {
215 | try {
216 | int len = json.length();
217 | filesOnServer=new ArrayList(len);
218 | if(len==0)
219 | Toast.makeText(getApplication(), "No files Available For Download!!", Toast.LENGTH_SHORT).show();
220 | else {
221 | JSONArray jsonArray=json.getJSONArray("Files");
222 | for(int i=0;i parent, View view, int position, long id) {
243 |
244 | String filename=(String)parent.getItemAtPosition(position);
245 |
246 | String url = "http://192.168.43.101:8080/download?name="+filename.trim();
247 | file_to_download=filename;
248 | new DownloadFileAsync().execute(url);
249 |
250 |
251 |
252 |
253 | }
254 |
255 | });
256 | }
257 |
258 | }
259 | });
260 |
261 | logout.setOnClickListener(new View.OnClickListener() {
262 | @Override
263 | public void onClick(View view) {
264 | SharedPreferences.Editor edit = pref.edit();
265 | //Storing Data using SharedPreferences
266 | edit.putString("token", "");
267 | edit.commit();
268 | Intent loginactivity = new Intent(ProfileActivity.this, LoginActivity.class);
269 | startActivity(loginactivity);
270 | finish();
271 |
272 | }
273 | });
274 |
275 | pref = getSharedPreferences("AppPref", MODE_PRIVATE);
276 | token = pref.getString("token", "");
277 | grav = pref.getString("grav", "");
278 | emailtxt = pref.getString("email", "no email");
279 | nametxt = pref.getString("name", "No name");
280 | branchtxt = pref.getString("branch", "");
281 | owner=pref.getString("owner","");
282 | emailTV.setText(emailtxt);
283 | branchTV.setText(branchtxt);
284 | nameTextView.setText(nametxt);
285 | if(owner.trim().equals("student"))
286 | fileupload.setText("File Download");
287 | else
288 | fileupload.setText("File Upload");
289 | chgpass.setOnClickListener(new View.OnClickListener() {
290 | @Override
291 | public void onClick(View view) {
292 | dlg = new Dialog(ProfileActivity.this);
293 | dlg.setContentView(R.layout.chgpassword_frag);
294 | dlg.setTitle("Change Password");
295 | chgpassfr = (Button) dlg.findViewById(R.id.chgbtn);
296 |
297 | chgpassfr.setOnClickListener(new View.OnClickListener() {
298 | @Override
299 | public void onClick(View view) {
300 | oldpass = (EditText) dlg.findViewById(R.id.oldpass);
301 | newpass = (EditText) dlg.findViewById(R.id.newpass);
302 | oldpasstxt = oldpass.getText().toString();
303 | newpasstxt = newpass.getText().toString();
304 | params = new ArrayList();
305 | params.add(new BasicNameValuePair("oldpass", oldpasstxt));
306 | params.add(new BasicNameValuePair("newpass", newpasstxt));
307 | params.add(new BasicNameValuePair("id", token));
308 | ServerRequest sr = new ServerRequest();
309 | // JSONObject json = sr.getJSON("http://192.168.56.1:8080/api/chgpass",params);
310 | JSONObject json = sr.getJSON("http://192.168.43.101:8080/api/chgpass", params);
311 | if (json != null) {
312 | try {
313 | String jsonstr = json.getString("response");
314 | if (json.getBoolean("res")) {
315 |
316 | dlg.dismiss();
317 | Toast.makeText(getApplication(), jsonstr, Toast.LENGTH_SHORT).show();
318 | } else {
319 | Toast.makeText(getApplication(), jsonstr, Toast.LENGTH_SHORT).show();
320 | }
321 | } catch (JSONException e) {
322 | Toast.makeText(getApplication(), "Check Your Internet Connection - "+e.getMessage(), Toast.LENGTH_SHORT).show();
323 |
324 | }
325 | }
326 |
327 | }
328 | });
329 | cancel = (Button) dlg.findViewById(R.id.cancelbtn);
330 | cancel.setOnClickListener(new View.OnClickListener() {
331 | @Override
332 | public void onClick(View view) {
333 | dlg.dismiss();
334 | }
335 | });
336 | dlg.show();
337 | }
338 | });
339 |
340 |
341 | }
342 |
343 | public void showFiles() {
344 | Intent intent = new Intent();
345 | intent.setType("*/*");
346 | intent.setAction(Intent.ACTION_GET_CONTENT);
347 | startActivityForResult(Intent.createChooser(intent, "Choose File"), 1);
348 | }
349 |
350 | @Override
351 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
352 | if (resultCode == RESULT_CANCELED) {
353 | // action cancelled
354 | }
355 | if (resultCode == RESULT_OK) {
356 |
357 | new UploadTask().execute(data);
358 | }
359 |
360 |
361 | }
362 |
363 |
364 |
365 | class UploadTask extends AsyncTask
366 | {
367 | String msg="";
368 | @Override
369 | protected String doInBackground(Intent... params) {
370 |
371 | Intent data=params[0];
372 | try {
373 |
374 | Uri selectedimg = data.getData();
375 |
376 | Ion.getDefault(ProfileActivity.this).setLogging("ion-logging", Log.DEBUG);
377 | File f = new File(selectedimg.getEncodedPath());
378 | Future uploading = Ion.with(ProfileActivity.this)
379 | .load("http://192.168.43.101:8080/upload")
380 | .setMultipartFile("image", f)
381 | .asString()
382 | .withResponse()
383 | .setCallback(new FutureCallback>() {
384 | @Override
385 | public void onCompleted(Exception e, Response result) {
386 |
387 | try {
388 | JSONObject jobj = new JSONObject(result.getResult());
389 | UploadTask.this.msg = jobj.getString("response");
390 | }
391 | catch (Exception e1)
392 | {
393 | UploadTask.this.msg= "Check Your Internet Connection - "+e1.getMessage();
394 | }
395 |
396 | }
397 | });
398 | } catch (Exception e1) {
399 |
400 | msg= "Check Your Internet Connection - "+e1.getMessage();
401 |
402 | }
403 | return msg;
404 | }
405 |
406 | @Override
407 | protected void onPreExecute() {
408 |
409 | progressDialog = new ProgressDialog(ProfileActivity.this);
410 | progressDialog.setMessage("Uploading...");
411 | progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
412 | progressDialog.setIndeterminate(true);
413 | progressDialog.setCanceledOnTouchOutside(false);
414 | progressDialog.show();
415 | }
416 |
417 | @Override
418 | protected void onPostExecute(String aVoid) {
419 | progressDialog.dismiss();
420 |
421 | Toast.makeText(getApplication(),aVoid, Toast.LENGTH_SHORT).show();
422 |
423 | }
424 | }
425 |
426 | class FilesAdapter extends ArrayAdapter