Commit 87427db8 by Sebastián Collado Montañez

Merge branch 'develop' of http://gitlab.ujaen.es/yotta/pictogram into develop

parents 6113dffd 363cde93
Showing with 183 additions and 47 deletions
...@@ -8,7 +8,7 @@ android { ...@@ -8,7 +8,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 21 targetSdkVersion 21
versionCode 1 versionCode 1
versionName "1.2" versionName "1.3"
resValue "string", "db_name", "PCB.db" resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "8" resValue "integer", "db_version", "8"
//resValue "string", "app_version", "1.1" //resValue "string", "app_version", "1.1"
......
...@@ -31,7 +31,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -31,7 +31,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
final String LOG_TAG=this.getClass().getCanonicalName(); final String LOG_TAG=this.getClass().getCanonicalName();
User currentUser; User currentUser;
boolean user_online; //true if the given user logged into the server 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. * Create a helper object to create, open, and/or manage a database.
* *
...@@ -42,12 +42,16 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -42,12 +42,16 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public PCBDBHelper(CursorFactory factory, int version, User user) { public PCBDBHelper(CursorFactory factory, int version, User user) {
super(PCBcontext.getContext(), DeviceHelper.getDBName(PCBcontext.getContext()), factory, DeviceHelper.getDBVersion(PCBcontext.getContext())); super(PCBcontext.getContext(), DeviceHelper.getDBName(PCBcontext.getContext()), factory, DeviceHelper.getDBVersion(PCBcontext.getContext()));
this.user_online=false; this.user_online=false;
this.user_valid=true;
this.setCurrentUser(user == null ? this.getCurrentUser() : user); this.setCurrentUser(user == null ? this.getCurrentUser() : user);
} }
public boolean isUser_online() {return this.user_online;} public boolean isUser_online() {return this.user_online;}
public void user_online(boolean user_online) {this.user_online=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. * Save the current user of the PCB. It is required to retrieve the last user.
* *
......
...@@ -2,6 +2,7 @@ package com.yottacode.pictogram.dao; ...@@ -2,6 +2,7 @@ package com.yottacode.pictogram.dao;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.util.Log;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
...@@ -247,6 +248,7 @@ public class User { ...@@ -247,6 +248,7 @@ public class User {
} }
} }
/** /**
* @return The id of the active scene of this student * @return The id of the active scene of this student
*/ */
......
package com.yottacode.pictogram.net; package com.yottacode.pictogram.net;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.util.Log; import android.util.Log;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
...@@ -154,7 +155,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -154,7 +155,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
try { 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()) { if (PCBcontext.getActivityContext() != null && version > DeviceHelper.getAppVersion() && newVersionContext!=PCBcontext.getActivityContext()) {
newVersionContext=PCBcontext.getActivityContext(); // prevent from showing several times the alert newVersionContext=PCBcontext.getActivityContext(); // prevent from showing several times the alert
...@@ -292,7 +293,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -292,7 +293,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
void build(); void build();
void closeNotifyStatus(); void closeNotifyStatus();
void restart_app(boolean direct_login); void restart_app(boolean direct_login);
void updateUserConfig(User user); void updateUserConfig(User user, boolean valid_license);
} }
} }
...@@ -31,7 +31,7 @@ public class StudentTalk implements Emitter.Listener { ...@@ -31,7 +31,7 @@ public class StudentTalk implements Emitter.Listener {
if (PCBcontext.getPcbdb()!=null) if (PCBcontext.getPcbdb()!=null)
try { try {
JSONObject msg = ((JSONObject) args[0]).getJSONObject("student"); JSONObject msg = ((JSONObject) args[0]).getJSONObject("student");
Log.i(this.getClass().getName(), "raw Received message " +msg.toString()); Log.d(this.getClass().getName(), "raw Received message " +msg.toString());
int id=msg.getInt("id"); int id=msg.getInt("id");
String username=msg.getString("username"); String username=msg.getString("username");
String name=msg.getString("name"); String name=msg.getString("name");
...@@ -41,13 +41,13 @@ public class StudentTalk implements Emitter.Listener { ...@@ -41,13 +41,13 @@ public class StudentTalk implements Emitter.Listener {
String pic=msg.getString("pic"); String pic=msg.getString("pic");
String lang=msg.getString("lang"); String lang=msg.getString("lang");
String attributes=msg.getString("attributes"); String attributes=msg.getString("attributes");
JSONObject license=msg.getJSONObject("license");
User user=PCBcontext.getPcbdb().getCurrentUser(); User user=PCBcontext.getPcbdb().getCurrentUser();
User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname, id_active_scene, pic, gender, lang, attributes, User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname, id_active_scene, pic, gender, lang, attributes,
user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(), user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(),
user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office()); user.get_lang_sup(), user.get_tts_engine_sup(), user.get_office());
Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length);
for (iStudentListener listener: listeners) for (iStudentListener listener: listeners)
listener.change(updatedUser); listener.change(updatedUser,license);
} catch (JSONException e) { } catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + "--" + e); Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + "--" + e);
...@@ -61,6 +61,6 @@ public class StudentTalk implements Emitter.Listener { ...@@ -61,6 +61,6 @@ public class StudentTalk implements Emitter.Listener {
* @version 1.0 * @version 1.0
*/ */
public interface iStudentListener { public interface iStudentListener {
void change(User updatedStudent); void change(User updatedStudent, JSONObject license);
} }
} }
package com.yottacode.pictogram.tools; package com.yottacode.pictogram.tools;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.util.Log; import android.util.Log;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
...@@ -17,6 +19,9 @@ import com.yottacode.pictogram.net.NetService; ...@@ -17,6 +19,9 @@ import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.net.websockets.Room; import com.yottacode.pictogram.net.websockets.Room;
import com.yottacode.pictogram.net.websockets.StudentTalk; import com.yottacode.pictogram.net.websockets.StudentTalk;
import org.json.JSONException;
import org.json.JSONObject;
public final class PCBcontext { public final class PCBcontext {
private static Context context; private static Context context;
private static PCBDBHelper pcbdb; private static PCBDBHelper pcbdb;
...@@ -75,18 +80,38 @@ public final class PCBcontext { ...@@ -75,18 +80,38 @@ public final class PCBcontext {
studentTalk=new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() { studentTalk=new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() {
@Override @Override
public void change(User updatedStudent) { public void change(User updatedStudent, JSONObject license) {
boolean valid_license;
PCBcontext.getDevice().insertUser(updatedStudent); try {
valid_license=license.getBoolean("isValid");
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories() if (!license.getBoolean("isValid") && license.getBoolean("isTrial")) {
|| updatedStudent.get_active_scene() != PCBcontext.getPcbdb().getCurrentUser().get_active_scene()){ AlertDialog.Builder builder1 = new AlertDialog.Builder(activityContext);
builder1.setMessage(R.string.loginNoLicenseMsg);
builder1.setPositiveButton(
R.string.accept,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
PCBcontext.getNetService().restart_app(false);
}
});
AlertDialog alert11 = builder1.create();
alert11.show();
return;
}
} catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(),"No license attr! "+license.toString());
valid_license=true;
}
PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories()
|| updatedStudent.get_active_scene() != PCBcontext.getPcbdb().getCurrentUser().get_active_scene())
PCBcontext.getNetService().restart_app(false); PCBcontext.getNetService().restart_app(false);
else {
}else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent); PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent); PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent, valid_license);
} }
} }
...@@ -122,11 +147,7 @@ public final class PCBcontext { ...@@ -122,11 +147,7 @@ public final class PCBcontext {
* logged * logged
*/ */
public static boolean is_user_offline() { public static boolean is_user_offline() {
if (pcbdb == null) { return pcbdb == null ? false : !getPcbdb().isUser_online();
return false;
} else {
return !getPcbdb().isUser_online();
}
} }
public static boolean is_user_online() { public static boolean is_user_online() {
......
...@@ -79,4 +79,12 @@ ...@@ -79,4 +79,12 @@
<string name="titleCropper">New pictogram</string> <string name="titleCropper">New pictogram</string>
<string name="uploadingImage">Uploading image</string> <string name="uploadingImage">Uploading image</string>
<string name="toStudentList">Student list</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> </resources>
...@@ -75,7 +75,11 @@ ...@@ -75,7 +75,11 @@
<string name="default_tts_voice_male">es-es-x-ana#male_1-local</string> <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="default_tts_voice_female">es-es-x-ana#female_2-local</string>
<string name="toStudentList">Lista de estudiantes</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> </resources>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">Pictogram Tablet</string> <string name="app_name">Pictogram Tablet</string>
<string name="action_settings">Parámetros</string> <string name="action_settings">Parámetros</string>
<string name="title_activity_login">Entrada de usuarios</string> <string name="title_activity_login">Entrada de usuarios</string>
...@@ -85,5 +84,6 @@ ...@@ -85,5 +84,6 @@
<string name="fa_flask">&#xf0c3;</string> <string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string> <string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_user_plus">&#xf234;</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> </resources>
...@@ -26,7 +26,7 @@ public class VersionManager implements iVersionManager { ...@@ -26,7 +26,7 @@ public class VersionManager implements iVersionManager {
public void newVersionAlert(final float version, final Context context, final float vnew) { 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); final TextView tx1 = new TextView(context);
tx1.setText("\t"+context.getResources().getString(R.string.new_version_detail) + tx1.setText("\t"+context.getResources().getString(R.string.new_version_detail) +
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
<resources> <resources>
<string name="app_name">Pictogram Tablet Supervisor</string> <string name="app_name">Pictogram Tablet Supervisor</string>
<string name="new_version_detail">Please, go to Google Play to download the new version </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> </resources>
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
<resources> <resources>
<string name="app_name">Pictogram Tablet Supervisor</string> <string name="app_name">Pictogram Tablet Supervisor</string>
<string name="new_version_detail">Por favor, descargue la nueva versión en Google Play </string> <string name="new_version_detail">Por favor, descargue la nueva versión en Google Play </string>
</resources> </resources>
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
<resources> <resources>
<string name="app_name">Pictogram Tablet Supervisor</string> <string name="app_name">Pictogram Tablet Supervisor</string>
<string name="new_version_detail">Please, go to Google Play to download the new version </string> <string name="new_version_detail">Please, go to Google Play to download the new version </string>
</resources> </resources>
...@@ -777,9 +777,11 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -777,9 +777,11 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
} else if (firstTouchX > event.getX() + 150) { //derecha a izquierda } else if (firstTouchX > event.getX() + 150) { //derecha a izquierda
// Pasa de VocabularyManager a SessionActivity // Pasa de VocabularyManager a SessionActivity
if (!PCBcontext.getNetService().online()) { if (!PCBcontext.getNetService().online())
GUITools.show_alert(VocabularyManager.this, R.string.session_noinet); 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); nextActivity = new Intent(this, SessionActivity.class);
in = R.anim.leftin; in = R.anim.leftin;
out = R.anim.leftout; out = R.anim.leftout;
......
...@@ -101,7 +101,7 @@ public class StudentFragmentGrid extends Fragment { ...@@ -101,7 +101,7 @@ public class StudentFragmentGrid extends Fragment {
else { else {
// checks if license is valid for this user // checks if license is valid for this user
if(licenseStudents[i].equals("expired")){ if(licenseStudents[i].equals("expired_trial")){
AlertDialog.Builder builder1 = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder1 = new AlertDialog.Builder(getActivity());
builder1.setMessage(R.string.loginNoLicenseMsg); builder1.setMessage(R.string.loginNoLicenseMsg);
builder1.setPositiveButton( builder1.setPositiveButton(
...@@ -267,13 +267,14 @@ public class StudentFragmentGrid extends Fragment { ...@@ -267,13 +267,14 @@ public class StudentFragmentGrid extends Fragment {
imgs.add(new Img(st_id, st_pic, Img.STUDENT)); //it's required to download student's images imgs.add(new Img(st_id, st_pic, Img.STUDENT)); //it's required to download student's images
// Checks if license is trial or pro (not expired) // Checks if license is trial or pro (not expired)
if(!st.getJSONObject("license").getBoolean("isValid")) licenseStudents[i] = !st.getJSONObject("license").getBoolean("isValid")
licenseStudents[i] = "expired"; ? (st.getJSONObject("license").getBoolean("isTrial")
else if(st.getJSONObject("license").getBoolean("isTrial")) ? "expired_trial"
licenseStudents[i] = "trial"; : "expired_official")
else if(st.getJSONObject("license").getBoolean("isOfficial")) : st.getJSONObject("license").getBoolean("isTrial")
licenseStudents[i] = "pro"; ? "trial"
Log.i("Test", licenseStudents[i]); : "pro";
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -97,7 +97,8 @@ public class NetServiceTablet implements NetService.iNetServiceDevice { ...@@ -97,7 +97,8 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
} }
public void setVOCA(VOCA VOCA) {this.VOCA = VOCA;} 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(); if (this.VOCA !=null) this.VOCA.setConfig();
PCBcontext.getPcbdb().user_valid(valid_license);
} }
} }
...@@ -53,7 +53,7 @@ public class NetServiceWatch implements NetService.iNetServiceDevice { ...@@ -53,7 +53,7 @@ public class NetServiceWatch implements NetService.iNetServiceDevice {
} }
@Override @Override
public void updateUserConfig(User user) { public void updateUserConfig(User user, boolean valid_license) {
} }
......
package com.yottacode.pictogram.yotta_tablet.net; package com.yottacode.pictogram.yotta_tablet.net;
import android.app.AlertDialog;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.net.Uri; import android.net.Uri;
import android.os.Environment; import android.os.Environment;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent;
import android.widget.TextView;
import com.yottacode.pictogram.dao.DeviceHelper; import com.yottacode.pictogram.dao.DeviceHelper;
import com.yottacode.pictogram.net.iVersionManager; import com.yottacode.pictogram.net.iVersionManager;
...@@ -18,6 +25,8 @@ import com.yottacode.tools.GUITools; ...@@ -18,6 +25,8 @@ import com.yottacode.tools.GUITools;
import java.io.File; import java.io.File;
import static android.app.Activity.RESULT_OK;
/** /**
* Created by Fernando on 10/03/2017. * Created by Fernando on 10/03/2017.
*/ */
...@@ -26,6 +35,42 @@ public class VersionManager implements iVersionManager { ...@@ -26,6 +35,42 @@ public class VersionManager implements iVersionManager {
static final String LOG_TAG=VersionManager.class.getCanonicalName(); static final String LOG_TAG=VersionManager.class.getCanonicalName();
public void newVersionAlert(final float version, final Context context, final float vnew) { 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( GUITools.show_alert(
PCBcontext.getActivityContext(), R.string.new_version_title, PCBcontext.getActivityContext(), R.string.new_version_title,
PCBcontext.getContext().getResources().getString(R.string.new_version_detail)+" v" + version, new GUITools.iOKListener() { PCBcontext.getContext().getResources().getString(R.string.new_version_detail)+" v" + version, new GUITools.iOKListener() {
...@@ -78,5 +123,5 @@ public class VersionManager implements iVersionManager { ...@@ -78,5 +123,5 @@ public class VersionManager implements iVersionManager {
} }
} }
, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); , new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
} }*/
} }
package com.yottacode.pictogram.yotta_tablet.net.com.yottacode.pictogram.yotta_tablet.net; package com.yottacode.pictogram.yotta_tablet.net.com.yottacode.pictogram.yotta_tablet.net;
import android.app.AlertDialog;
import android.app.DownloadManager; import android.app.DownloadManager;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.net.Uri; import android.net.Uri;
import android.os.Environment; 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.dao.DeviceHelper;
import com.yottacode.pictogram.net.iVersionManager; import com.yottacode.pictogram.net.iVersionManager;
...@@ -17,13 +24,15 @@ import com.yottacode.tools.GUITools; ...@@ -17,13 +24,15 @@ import com.yottacode.tools.GUITools;
import java.io.File; import java.io.File;
import static android.app.Activity.RESULT_OK;
/** /**
* Created by Fernando on 10/03/2017. * Created by Fernando on 10/03/2017.
*/ */
public class VersionManager implements iVersionManager { public class VersionManager implements iVersionManager {
static final String LOG_TAG=VersionManager.class.getCanonicalName(); static final String LOG_TAG=VersionManager.class.getCanonicalName();
/*
public void newVersionAlert(final float version, final Context context, final float vnew) { public void newVersionAlert(final float version, final Context context, final float vnew) {
GUITools.show_alert( GUITools.show_alert(
PCBcontext.getActivityContext(), R.string.new_version_title, PCBcontext.getActivityContext(), R.string.new_version_title,
...@@ -76,5 +85,41 @@ public class VersionManager implements iVersionManager { ...@@ -76,5 +85,41 @@ public class VersionManager implements iVersionManager {
} }
} }
, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); , 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 @@ ...@@ -3,7 +3,7 @@
<string name="app_name">Pictogram Tablet</string> <string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</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_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> </resources>
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<string name="app_name">Pictogram Tablet</string> <string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user"> No existe ningún supervisor </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_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> </resources>
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<resources> <resources>
<string name="app_name">Pictogram Tablet</string> <string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</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_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> <!-- <string name="new_version_downloading">Por favor espere, descargando nueva versión </string> -->
</resources> </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