diff --git a/.classpath b/.classpath
index e2f51ca..41426a7 100644
--- a/.classpath
+++ b/.classpath
@@ -1,13 +1,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index a017afb..6718d14 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,5 @@
/smileplug-adm-test/target
/gen
/bin
+
+lint.xml
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f6cad67..48ea5d0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -26,6 +26,7 @@
+
diff --git a/project.properties b/project.properties
index 0840b4a..ce39f2d 100644
--- a/project.properties
+++ b/project.properties
@@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-15
+target=android-18
diff --git a/res/layout-large-land/session_values.xml b/res/layout-large-land/session_values.xml
new file mode 100644
index 0000000..60e982e
--- /dev/null
+++ b/res/layout-large-land/session_values.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout-xlarge-land/session_values.xml b/res/layout-xlarge-land/session_values.xml
new file mode 100644
index 0000000..aa13aaa
--- /dev/null
+++ b/res/layout-xlarge-land/session_values.xml
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/session_values.xml b/res/layout/session_values.xml
new file mode 100644
index 0000000..01e4490
--- /dev/null
+++ b/res/layout/session_values.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d925b36..4246555 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4,6 +4,13 @@
Server IP
Connect
Loading...
+
+ Information about teacher\'s session
+ Teacher name
+ Session title
+ Group name
+ Create
+ Creating session...
Start Making Questions
Use Prepared Questions
diff --git a/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java b/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java
index c732a9f..4afbaef 100644
--- a/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java
+++ b/src/main/java/org/smilec/smile/bu/SmilePlugServerManager.java
@@ -86,6 +86,24 @@ public void resetGame(String ip, Context context) throws NetworkErrorException {
}
+ public void createSession(String ip, String teacherName, String sessionTitle, String groupName, Context context) throws NetworkErrorException {
+
+ String url = SmilePlugUtil.createUrl(ip, SmilePlugUtil.CREATE_SESSION);
+ JSONObject jsonSessionValues = new JSONObject();
+
+ try {
+ jsonSessionValues.put("teacherName", teacherName);
+ jsonSessionValues.put("sessionName", sessionTitle);
+ jsonSessionValues.put("groupName", groupName);
+
+ } catch (Exception e) {
+ Log.e("SMILE_TEACHER:SmilePlugServerManager", "ERROR, reason: " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ put(ip,context,url,jsonSessionValues.toString());
+ }
+
public String currentMessageGame(String ip, Context context) throws NetworkErrorException {
String url = SmilePlugUtil.createUrl(ip, SmilePlugUtil.CURRENT_MESSAGE_URL);
diff --git a/src/main/java/org/smilec/smile/ui/ChooseActivityFlowDialog.java b/src/main/java/org/smilec/smile/ui/ChooseActivityFlowDialog.java
index 7a67039..45689de 100644
--- a/src/main/java/org/smilec/smile/ui/ChooseActivityFlowDialog.java
+++ b/src/main/java/org/smilec/smile/ui/ChooseActivityFlowDialog.java
@@ -85,7 +85,7 @@ protected void onResume() {
super.onResume();
ip = this.getIntent().getStringExtra(GeneralActivity.PARAM_IP);
-
+
btStart.setOnClickListener(new StartButtonListener());
btUse.setOnClickListener(new UsePreparedQuestionsButtonListener());
diff --git a/src/main/java/org/smilec/smile/ui/LoginActivity.java b/src/main/java/org/smilec/smile/ui/LoginActivity.java
index ec97413..531fff0 100644
--- a/src/main/java/org/smilec/smile/ui/LoginActivity.java
+++ b/src/main/java/org/smilec/smile/ui/LoginActivity.java
@@ -183,7 +183,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
}
private void loading() {
- Intent intent = new Intent(this, ChooseActivityFlowDialog.class);
+ Intent intent = new Intent(this, SessionValuesActivity.class);
intent.putExtra(GeneralActivity.PARAM_IP, tvIp.getText().toString());
intent.putExtra(GeneralActivity.PARAM_STATUS, status);
//ActivityUtil.showLongToast(this, R.string.connection_established);
@@ -194,7 +194,7 @@ private void loading() {
msg = mHandler.obtainMessage(MSG_OK, getResources().getString(R.string.connection_established));
mHandler.sendMessage(msg);
- //Starting ChooseActivityFlowDialog
+ //Starting SessionValuesActivity
startActivity(intent);
//Closing LoginActivity
diff --git a/src/main/java/org/smilec/smile/ui/SessionValuesActivity.java b/src/main/java/org/smilec/smile/ui/SessionValuesActivity.java
new file mode 100644
index 0000000..047b0bf
--- /dev/null
+++ b/src/main/java/org/smilec/smile/ui/SessionValuesActivity.java
@@ -0,0 +1,194 @@
+package org.smilec.smile.ui;
+
+import org.smilec.smile.R;
+import org.smilec.smile.bu.Constants;
+import org.smilec.smile.bu.NetworkManager;
+import org.smilec.smile.bu.SmilePlugServerManager;
+import org.smilec.smile.util.ActivityUtil;
+import org.smilec.smile.util.DialogUtil;
+import org.smilec.smile.util.ui.ProgressDialogAsyncTask;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.net.ConnectivityManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.util.Log;
+import android.view.Display;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class SessionValuesActivity extends Activity {
+
+ private String ip_smileplug;
+ private String status;
+
+ private TextView tv_teacherName;
+ private TextView tv_sessionTitle;
+ private TextView tv_groupName;
+ private Button btnCreateSession;
+
+ private Context context;
+ private static final int MSG_OK = 1;
+
+ private NetworkManager receiver;
+ public SessionValuesActivity() {
+ receiver = new NetworkManager();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ ip_smileplug = this.getIntent().getStringExtra(GeneralActivity.PARAM_IP);
+
+ status = this.getIntent().getStringExtra(GeneralActivity.PARAM_STATUS);
+
+ setContentView(R.layout.session_values);
+ Display displaySize = ActivityUtil.getDisplaySize(getApplicationContext());
+ getWindow().setLayout(displaySize.getWidth(), displaySize.getHeight());
+
+ context = this;
+ try {
+ PackageInfo pinfo = this.getPackageManager().getPackageInfo(getPackageName(), 0);
+ TextView title = (TextView) findViewById(R.id.tv_title);
+ title.setText(getText(R.string.app_name) + " " + pinfo.versionName);
+ } catch (NameNotFoundException e) {
+ Log.e(Constants.LOG_CATEGORY, "Error: ", e);
+ }
+
+ tv_teacherName = (TextView) findViewById(R.id.teacher_name);
+ tv_sessionTitle = (TextView) findViewById(R.id.session_title);
+ tv_groupName = (TextView) findViewById(R.id.group_name);
+ btnCreateSession = (Button) findViewById(R.id.btn_create_session);
+
+ registerReceiver(receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+
+ unregisterReceiver(receiver);
+ }
+
+ @Override
+ protected void onResume() {
+
+ super.onResume();
+
+ btnCreateSession.setEnabled(false);
+ btnCreateSession.setOnClickListener(new CreateSessionButtonListener());
+
+// tv_teacherName.addTextChangedListener(new TextChanged());
+// tv_sessionTitle.addTextChangedListener(new TextChanged());
+// tv_groupName.addTextChangedListener(new TextChanged());
+
+ this.setVisible(true);
+
+// if ( ) {
+// btnCreateSession.setEnabled(true);
+// } else {
+// btnCreateSession.setEnabled(false);
+// }
+ btnCreateSession.setEnabled(true); ///
+ }
+
+ private class CreateSessionButtonListener implements OnClickListener {
+
+ @Override
+ public void onClick(View v) {
+ new LoadTask(SessionValuesActivity.this).execute();
+ }
+ }
+
+ private void loading() {
+ Intent intent = new Intent(this, ChooseActivityFlowDialog.class);
+ intent.putExtra(GeneralActivity.PARAM_IP, ip_smileplug);
+ intent.putExtra(GeneralActivity.PARAM_STATUS, status);
+ //ActivityUtil.showLongToast(this, R.string.connection_established);
+ //this.setVisible(false);
+
+ // Display toast through the handler
+ Message msg = null;
+ msg = mHandler.obtainMessage(MSG_OK, getResources().getString(R.string.creating_session));
+ mHandler.sendMessage(msg);
+
+ //Starting ChooseActivityFlowDialog
+ startActivity(intent);
+ this.finish();
+
+ //Closing LoginActivity
+ this.setVisible(false);
+ }
+
+ // To manage messages outside onCreate() method
+ Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ String text2display = null;
+ switch (msg.what) {
+ case MSG_OK:
+ text2display = (String) msg.obj;
+ Toast.makeText(context, text2display, Toast.LENGTH_LONG).show();
+ break;
+ default: // should never happen
+ break;
+ }
+ }
+ };
+
+ private class LoadTask extends ProgressDialogAsyncTask {
+
+ public LoadTask(Activity context) {
+ super(context);
+ }
+
+ @Override
+ protected String doInBackground(Void... params) {
+
+ String teacherName = tv_teacherName.getText().toString();
+ String sessionTitle = tv_sessionTitle.getText().toString();
+ String groupName = tv_groupName.getText().toString();
+
+ if(teacherName.equals("")) teacherName = "Default Teacher";
+ if(sessionTitle.equals("")) sessionTitle = "Session-";
+ if(groupName.equals("")) groupName = "Default Group";
+
+ try {
+ SmilePlugServerManager spsm = new SmilePlugServerManager();
+
+ spsm.connect(ip_smileplug, context);
+ spsm.createSession(ip_smileplug,teacherName,sessionTitle,groupName,context);
+
+ return "";
+
+ } catch (Exception e) {
+ handleException(e);
+ return e.getMessage();
+ }
+ }
+
+ @Override
+ protected void onPostExecute(String message) {
+ super.onPostExecute(message);
+ if (!message.equals("")) {
+ DialogUtil.checkConnection(SessionValuesActivity.this, message);
+ } else {
+ SessionValuesActivity.this.loading();
+ }
+ }
+ }
+
+ private void checkingSessionValues() {
+ }
+
+}
diff --git a/src/main/java/org/smilec/smile/util/HttpUtil.java b/src/main/java/org/smilec/smile/util/HttpUtil.java
index 3838c21..2320bd7 100644
--- a/src/main/java/org/smilec/smile/util/HttpUtil.java
+++ b/src/main/java/org/smilec/smile/util/HttpUtil.java
@@ -110,6 +110,7 @@ public static final InputStream executeGet(String url) throws NetworkErrorExcept
return executeMethod(get);
}
+ // This method seems to be never used in smile_teacher_android
public static final HttpResponse executePost(String url, String json) throws NetworkErrorException {
try {
diff --git a/src/main/java/org/smilec/smile/util/SmilePlugUtil.java b/src/main/java/org/smilec/smile/util/SmilePlugUtil.java
index 477c32d..276eab1 100644
--- a/src/main/java/org/smilec/smile/util/SmilePlugUtil.java
+++ b/src/main/java/org/smilec/smile/util/SmilePlugUtil.java
@@ -33,6 +33,7 @@ public class SmilePlugUtil {
public static final String RESULTS_URL = "results";
public static final String RESET_URL = "reset";
public static final String CURRENT_MESSAGE_URL = "currentmessage";
+ public static final String CREATE_SESSION = "createsession";
public static final String JSON = "application/json";
public static final String FORM = "application/x-www-form-urlencoded";