PCB v1.3 beta

parent ab62fca5
Showing with 137 additions and 26 deletions
......@@ -8,7 +8,7 @@ android {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.2"
versionName "1.3"
resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "8"
//resValue "string", "app_version", "1.1"
......
......@@ -31,7 +31,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
final String LOG_TAG=this.getClass().getCanonicalName();
User currentUser;
boolean user_online; //true if the given user logged into the server
boolean user_valid; //true if the given user has a valid license
/**
* Create a helper object to create, open, and/or manage a database.
*
......@@ -42,12 +42,16 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public PCBDBHelper(CursorFactory factory, int version, User user) {
super(PCBcontext.getContext(), DeviceHelper.getDBName(PCBcontext.getContext()), factory, DeviceHelper.getDBVersion(PCBcontext.getContext()));
this.user_online=false;
this.user_valid=true;
this.setCurrentUser(user == null ? this.getCurrentUser() : user);
}
public boolean isUser_online() {return this.user_online;}
public void user_online(boolean user_online) {this.user_online=user_online;}
public boolean isUser_valid() {return this.user_valid;}
public void user_valid(boolean user_valid) {this.user_valid=user_valid;}
/**
* Save the current user of the PCB. It is required to retrieve the last user.
*
......
package com.yottacode.pictogram.net;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.yottacode.net.RestapiWrapper;
......@@ -154,7 +155,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
@Override
public void result(JSONObject result) {
try {
final float version = Float.valueOf(result.getString("version"));
final float version = ((float)(Float.valueOf(result.getString("version")).intValue()*10))/10;
if (PCBcontext.getActivityContext() != null && version > DeviceHelper.getAppVersion() && newVersionContext!=PCBcontext.getActivityContext()) {
newVersionContext=PCBcontext.getActivityContext(); // prevent from showing several times the alert
......@@ -292,7 +293,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
void build();
void closeNotifyStatus();
void restart_app(boolean direct_login);
void updateUserConfig(User user);
void updateUserConfig(User user, boolean valid_license);
}
}
......@@ -81,7 +81,9 @@ public final class PCBcontext {
studentTalk=new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() {
@Override
public void change(User updatedStudent, JSONObject license) {
boolean valid_license;
try {
valid_license=license.getBoolean("isValid");
if (!license.getBoolean("isValid") && license.getBoolean("isTrial")) {
AlertDialog.Builder builder1 = new AlertDialog.Builder(activityContext);
builder1.setMessage(R.string.loginNoLicenseMsg);
......@@ -100,6 +102,7 @@ public final class PCBcontext {
} catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(),"No license attr! "+license.toString());
valid_license=true;
}
PCBcontext.getDevice().insertUser(updatedStudent);
......@@ -108,7 +111,7 @@ public final class PCBcontext {
PCBcontext.getNetService().restart_app(false);
else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent, valid_license);
}
}
......@@ -144,11 +147,7 @@ public final class PCBcontext {
* logged
*/
public static boolean is_user_offline() {
if (pcbdb == null) {
return false;
} else {
return !getPcbdb().isUser_online();
}
return pcbdb == null ? false : !getPcbdb().isUser_online();
}
public static boolean is_user_online() {
......
......@@ -79,4 +79,12 @@
<string name="titleCropper">New pictogram</string>
<string name="uploadingImage">Uploading image</string>
<string name="toStudentList">Student list</string>
<string name="fa_certificate">&#xf0a3;</string>
<string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_user_plus">&#xf234;</string>
<string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string>
<string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string>
</resources>
......@@ -75,7 +75,11 @@
<string name="default_tts_voice_male">es-es-x-ana#male_1-local</string>
<string name="default_tts_voice_female">es-es-x-ana#female_2-local</string>
<string name="toStudentList">Lista de estudiantes</string>
<string name="fa_certificate">&#xf0a3;</string>
<string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_user_plus">&#xf234;</string>
<string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string>
<string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="action_settings">Parámetros</string>
<string name="title_activity_login">Entrada de usuarios</string>
......@@ -85,5 +84,6 @@
<string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_user_plus">&#xf234;</string>
<string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string>
<string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string>
</resources>
......@@ -26,7 +26,7 @@ public class VersionManager implements iVersionManager {
public void newVersionAlert(final float version, final Context context, final float vnew) {
final SpannableString s = new SpannableString(context.getResources().getString(R.string.google_play_apk));
final SpannableString s = new SpannableString(context.getResources().getString(R.string.google_play_supervisor_apk));
final TextView tx1 = new TextView(context);
tx1.setText("\t"+context.getResources().getString(R.string.new_version_detail) +
......
......@@ -2,5 +2,6 @@
<resources>
<string name="app_name">Pictogram Tablet Supervisor</string>
<string name="new_version_detail">Please, go to Google Play to download the new version </string>
https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet
</resources>
......@@ -2,5 +2,6 @@
<resources>
<string name="app_name">Pictogram Tablet Supervisor</string>
<string name="new_version_detail">Por favor, descargue la nueva versión en Google Play </string>
</resources>
......@@ -2,4 +2,5 @@
<resources>
<string name="app_name">Pictogram Tablet Supervisor</string>
<string name="new_version_detail">Please, go to Google Play to download the new version </string>
</resources>
......@@ -777,9 +777,11 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
} else if (firstTouchX > event.getX() + 150) { //derecha a izquierda
// Pasa de VocabularyManager a SessionActivity
if (!PCBcontext.getNetService().online()) {
if (!PCBcontext.getNetService().online())
GUITools.show_alert(VocabularyManager.this, R.string.session_noinet);
} else {
else if (!PCBcontext.getPcbdb().isUser_valid())
GUITools.show_alert(VocabularyManager.this,R.string.loginExpiredLicenseMsg);
else {
nextActivity = new Intent(this, SessionActivity.class);
in = R.anim.leftin;
out = R.anim.leftout;
......
......@@ -97,7 +97,8 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
}
public void setVOCA(VOCA VOCA) {this.VOCA = VOCA;}
public void updateUserConfig(User user) {
public void updateUserConfig(User user, boolean valid_license) {
if (this.VOCA !=null) this.VOCA.setConfig();
PCBcontext.getPcbdb().user_valid(valid_license);
}
}
......@@ -53,7 +53,7 @@ public class NetServiceWatch implements NetService.iNetServiceDevice {
}
@Override
public void updateUserConfig(User user) {
public void updateUserConfig(User user, boolean valid_license) {
}
......
package com.yottacode.pictogram.yotta_tablet.net;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Environment;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.TextView;
import com.yottacode.pictogram.dao.DeviceHelper;
import com.yottacode.pictogram.net.iVersionManager;
......@@ -18,6 +25,8 @@ import com.yottacode.tools.GUITools;
import java.io.File;
import static android.app.Activity.RESULT_OK;
/**
* Created by Fernando on 10/03/2017.
*/
......@@ -26,6 +35,42 @@ public class VersionManager implements iVersionManager {
static final String LOG_TAG=VersionManager.class.getCanonicalName();
public void newVersionAlert(final float version, final Context context, final float vnew) {
final SpannableString s = new SpannableString(context.getResources().getString(R.string.google_play_student_apk));
final TextView tx1 = new TextView(context);
tx1.setText("\t"+context.getResources().getString(R.string.new_version_detail) +
"\n\t\t"+ s);
tx1.setTextSize(16);
tx1.setAutoLinkMask(RESULT_OK);
tx1.setMovementMethod(LinkMovementMethod.getInstance());
Linkify.addLinks(s, Linkify.WEB_URLS);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getResources().getString(R.string.app_name)+": "+context.getResources().getString(R.string.new_version_title)+" v"+vnew)
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
DeviceHelper.setAppVersion(vnew);
}
})
.setView(tx1).setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return false;
}
}).show();
PCBcontext.setActivityContext(null);
}
/*
public void newVersionAlert(final float version, final Context context, final float vnew) {
GUITools.show_alert(
PCBcontext.getActivityContext(), R.string.new_version_title,
PCBcontext.getContext().getResources().getString(R.string.new_version_detail)+" v" + version, new GUITools.iOKListener() {
......@@ -78,5 +123,5 @@ public class VersionManager implements iVersionManager {
}
}
, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
}*/
}
package com.yottacode.pictogram.yotta_tablet.net.com.yottacode.pictogram.yotta_tablet.net;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Environment;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.KeyEvent;
import android.widget.TextView;
import com.yottacode.pictogram.dao.DeviceHelper;
import com.yottacode.pictogram.net.iVersionManager;
......@@ -17,13 +24,15 @@ import com.yottacode.tools.GUITools;
import java.io.File;
import static android.app.Activity.RESULT_OK;
/**
* Created by Fernando on 10/03/2017.
*/
public class VersionManager implements iVersionManager {
static final String LOG_TAG=VersionManager.class.getCanonicalName();
/*
public void newVersionAlert(final float version, final Context context, final float vnew) {
GUITools.show_alert(
PCBcontext.getActivityContext(), R.string.new_version_title,
......@@ -76,5 +85,41 @@ public class VersionManager implements iVersionManager {
}
}
, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}*/
public void newVersionAlert(final float version, final Context context, final float vnew) {
final SpannableString s = new SpannableString(context.getResources().getString(R.string.google_play_student_apk));
final TextView tx1 = new TextView(context);
tx1.setText("\t"+context.getResources().getString(R.string.new_version_detail) +
"\n\t\t"+ s);
tx1.setTextSize(16);
tx1.setAutoLinkMask(RESULT_OK);
tx1.setMovementMethod(LinkMovementMethod.getInstance());
Linkify.addLinks(s, Linkify.WEB_URLS);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(context.getResources().getString(R.string.app_name)+": "+context.getResources().getString(R.string.new_version_title)+" v"+vnew)
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
DeviceHelper.setAppVersion(vnew);
}
})
.setView(tx1).setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return false;
}
}).show();
PCBcontext.setActivityContext(null);
}
}
......@@ -3,7 +3,7 @@
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</string>
<string name="new_version_detail">Pulse OK para proceder con la instalación</string>
<string name="new_version_downloading">Please wait, downloading new version </string>
<!-- <string name="new_version_downloading">Please wait, downloading new version </string> -->
</resources>
......@@ -3,7 +3,7 @@
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user"> No existe ningún supervisor </string>
<string name="new_version_detail">Pulse OK para proceder con la instalación</string>
<string name="new_version_downloading">Por favor espere, descargando nueva versión </string>
<!-- <string name="new_version_downloading">Por favor espere, descargando nueva versión </string> -->
</resources>
......@@ -2,7 +2,6 @@
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</string>
<string name="new_version_detail">Pulse OK para proceder con la instalación</string>
<string name="new_version_downloading">Por favor espere, descargando nueva versión </string>
<string name="new_version_detail">Por favor, visite Google Play para instalar la nueva versión</string>
<!-- <string name="new_version_downloading">Por favor espere, descargando nueva versión </string> -->
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment