Refactorización a Pictogram Communicator y Pictogram Supervisor

working in several issues
parent b65ee2bb
Showing with 79 additions and 47 deletions
......@@ -300,7 +300,7 @@ public class Picto extends Img {
public boolean is_invisible() {
try {
return this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.INVISIBLE) ||
(this.is_category() && !PCBcontext.getVocabulary().isVisibleCategory(this.get_id()));
(PCBcontext.getVocabulary().is_category(this) && !PCBcontext.getVocabulary().isVisibleCategory(this.get_id()));
} catch (JSONException e) {
return false;
}
......@@ -464,13 +464,14 @@ public class Picto extends Img {
* (i) it has not got category
* (ii) it is not an uncategorized concept (such as "yes","no","thank you")
* @return
*/
public boolean is_category() {
return this.get_category()==Picto.NO_CATEGORY &&
this.get_row() != Picto.COL_UNCATEGORIZED_CONCEPTS &&
this.getFreeColumn() == -1 &&
this.getFreeRow() == -1;
}
}*/
/**
*
* @overide
......
......@@ -268,7 +268,7 @@ public class Vocabulary implements Iterable<Picto> {
ImgDownloader downloader = new ImgDownloader(PCBcontext.getContext(), imgListener,ImgDownloader.tsource.remote);
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
}
public boolean is_category(Picto p) {Log.e("=","8354"+this.pictos.containsKey(8354));return this.pictos.containsKey(p.get_id()); }
public int size() { return this.pictos.size();}
/**
* It includes/updates a new picto to the user collection: download the image from remote or local storage, add the picto to the current vocabulary and update the database
......@@ -335,7 +335,7 @@ public class Vocabulary implements Iterable<Picto> {
* @return
*/
public Picto get_picto(int pic_cat, int pic_id) {
Picto picto=null; Log.e(LOG_TAG,"GET_PICTO:"+pic_cat+":"+Picto.NO_CATEGORY);
Picto picto=null;
LinkedList<Picto> pictos_cat=this.pictos.get(pic_cat);
for (int i=0; i<pictos_cat.size() && picto==null; i++)
if (pictos_cat.get(i).get_id()==pic_id) picto=pictos_cat.get(i);
......@@ -385,7 +385,19 @@ public class Vocabulary implements Iterable<Picto> {
* @seealso com.yottacode.pictogram.dao.PCBDBHelper.getStudentVocabulary
*/
public void addPicto(Picto picto) {
LinkedList<Picto> pictos_cat;
Log.e("ADD","P"+picto.get_id()+";cat:"+picto.get_category()+":"+picto.get_translation());
if (picto.get_id()==8354) {
pictos_cat = new LinkedList();
Picto p=get_picto(52366,11039);
pictos_cat.add(p);
this.pictos.put(picto.get_id(), pictos_cat);
Log.e("ADDADD","P"+picto.get_id()+";"+picto.get_translation()+":"+this.pictos.containsKey(picto.get_id())+":"+is_category(picto));
return;
}
Log.e("ADDADD","P"+picto.get_id()+";"+picto.get_translation()+":"+this.pictos.containsKey(8354)+":"+is_category(picto));
if (this.pictos.containsKey(picto.get_category()))
pictos_cat = pictos.get(picto.get_category());
else {
......@@ -492,7 +504,7 @@ public class Vocabulary implements Iterable<Picto> {
* @return set of pictos which should be selectable in a given sentence state
*/
public LinkedList<Picto> next(Picto picto){
return picto.is_category() ? this.pictos.get(picto.get_id()) : startSentence() ;
return PCBcontext.getVocabulary().is_category(picto) ? this.pictos.get(picto.get_id()) : startSentence() ;
}
......
......@@ -46,7 +46,7 @@
android:screenOrientation="landscape" />
<activity
android:name="com.yottacode.pictogram.tabletlibrary.gui.communicator.VOCA"
android:name="com.yottacode.pictogram.communicator.gui.VOCAC"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:exported="true"
android:label="@string/app_name"
......@@ -59,6 +59,12 @@
</intent-filter>
</receiver>
<activity
android:name="com.yottacode.pictogram.communicator.gui.EmptySceneActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="landscape" />
</application>
</manifest>
package com.yottacode.pictogram.tabletlibrary.gui.communicator;
package com.yottacode.pictogram.communicator.gui;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.communicator.R;
import com.yottacode.pictogram.tools.PCBcontext;
public class EmptySceneActivity extends Activity {
......
package com.yottacode.pictogram.communicator.gui;
import android.content.Intent;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.VOCA;
/**
* Created by Fernando on 09/10/2017.
*/
public class VOCAC extends VOCA {
@Override
public void onResumeWhenEmptyScene() {
finish();
Intent activity = new Intent(getBaseContext(), EmptySceneActivity.class);
startActivity(activity);
}
}
......@@ -3,6 +3,6 @@
<string name="app_name">Pictogram Communicator</string>
<string name="ilegal_user">There is not any supervisor named</string>
<string name="login_ilegaluser">Please, login as student or use Pictogram Supervisor </string>
<string name="activityAfterLogin" translatable="false">com.yottacode.pictogram.tabletlibrary.gui.communicator.VOCA</string>
<string name="activityAfterLogin" translatable="false">com.yottacode.pictogram.communicator.gui.VOCAC</string>
</resources>
......@@ -162,7 +162,7 @@ public class PictoItemViewGenerator {
if (picto.is_disabled())
redCrossImage.setVisibility(View.VISIBLE);
if (picto.is_category())
if (PCBcontext.getVocabulary().is_category(picto))
layout.setBackgroundColor(picto.get_color());
if (picto.is_mirror() && !preventMirror) {
......
......@@ -165,7 +165,7 @@ public class PictoMenu {
PieMenu.addMenuEntry(new UnlockPictoMenu(picto));
PieMenu.addMenuEntry(new DisablePictoMenu(picto));
PieMenu.addMenuEntry(new SetInvisibleMenu(picto));
if (!picto.is_category()) PieMenu.addMenuEntry(new EditMenu(picto));
if (!PCBcontext.getVocabulary().is_category(picto)) PieMenu.addMenuEntry(new EditMenu(picto));
ll.addView(PieMenu);
......
......@@ -2,7 +2,9 @@ package com.yottacode.pictogram.supervisor.gui;
import android.content.Intent;
import android.view.MotionEvent;
import android.widget.Toast;
import com.yottacode.pictogram.supervisor.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.VOCA;
import com.yottacode.pictogram.tools.PCBcontext;
......@@ -19,7 +21,7 @@ public class VOCAS extends VOCA {
Intent nextActivity = null;
Intent intent = getIntent();
if (PCBcontext.getPcbdb() != null && PCBcontext.getPcbdb().getCurrentUser().is_supervisor()) {
if (PCBcontext.getPcbdb() != null ) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
......@@ -27,15 +29,9 @@ public class VOCAS extends VOCA {
break;
case MotionEvent.ACTION_UP:
if (event.getX() > firstTouchX + 150) { // izquierda a derecha
if (firstTouchX > event.getX() + 150) //derecha a izquierda
nextActivity = new Intent(this, VocabularyManager.class); // Pasa de voca a VocabularyManager
// No action
} else if (firstTouchX > event.getX() + 150) { //derecha a izquierda
// Pasa de voca a VocabularyManager
nextActivity = new Intent(this, VocabularyManager.class);
}
in = com.yottacode.pictogram.tabletlibrary.R.anim.leftin;
out = com.yottacode.pictogram.tabletlibrary.R.anim.leftout;
if (nextActivity != null) {
......@@ -51,4 +47,13 @@ public class VOCAS extends VOCA {
return super.dispatchTouchEvent(event);
}
@Override
public void onResumeWhenEmptyScene() {
Toast.makeText(this, R.string.emptyVocabulary_msg,Toast.LENGTH_LONG).show();
finish();
Intent activity = new Intent(getBaseContext(), VocabularyManager.class);
startActivity(activity);
}
}
......@@ -567,7 +567,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
p.set_mirror(false, false);
// If the picto is a category
if (p.is_category()) {
if (VocabularyManager.this.vocabulary.is_category(p)) {
currentCategory = p;
PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p));
hidePictoMainGridView();
......@@ -668,12 +668,13 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
case MotionEvent.ACTION_UP:
if (event.getX() > firstTouchX + 150) { // izquierda a derecha
// Pasa de VocabularyManager a voca
nextActivity = new Intent(this, VOCAS.class);
if (PCBcontext.getVocabulary().isVisibleAnyPicto())
Toast.makeText(this, R.string.emptyVocabulary_msg,Toast.LENGTH_LONG).show();
else
nextActivity = new Intent(this, VOCAS.class);
in = R.anim.rightin;
out = R.anim.rightout;
} else if (firstTouchX > event.getX() + 150) { //derecha a izquierda
// Pasa de VocabularyManager a SessionActivity
......
......@@ -5,13 +5,7 @@
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
<activity
android:name="com.yottacode.pictogram.tabletlibrary.gui.communicator.EmptySceneActivity"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="landscape" />
</application>
</manifest>
......@@ -2,7 +2,6 @@ package com.yottacode.pictogram.tabletlibrary.gui.communicator;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -163,7 +162,7 @@ public class PictoItemViewGenerator {
if (picto.is_disabled())
redCrossImage.setVisibility(View.VISIBLE);
if (picto.is_category())
if (PCBcontext.getVocabulary().is_category(picto))
layout.setBackgroundColor(picto.get_color());
if (picto.is_mirror() && !preventMirror) {
......
......@@ -8,7 +8,6 @@ import android.content.ClipData;
import android.content.ClipDescription;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
......@@ -62,7 +61,7 @@ import java.util.Locale;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener {
public abstract class VOCA extends Activity implements VocabularyTalk.iVocabularyListener {
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
......@@ -114,7 +113,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
protected boolean tape_delivered = false;
public boolean inserting = false;
public abstract void onResumeWhenEmptyScene();
@TargetApi(Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -303,9 +302,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
onWindowFocusChanged(true);
if (!PCBcontext.getVocabulary().isVisibleAnyPicto()) {
finish();
Intent activity = new Intent(getBaseContext(), EmptySceneActivity.class);
startActivity(activity);
onResumeWhenEmptyScene();
}else {
if (!PCBcontext.getPcbdb().getCurrentUser().is_supervisor() && !isAppInLockTaskMode())
......@@ -713,7 +710,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
if (v == findViewById(R.id.tape_grid_view) && (viewgroup == findViewById(R.id.picto_category_grid_view) || viewgroup == findViewById(R.id.picto_main_grid_view))) {
Picto p = viewgroup == findViewById(R.id.picto_category_grid_view) ? pictoCategoryGridAdapter.getItem(position)
: pictoMainGridAdapter.getItem(position);
if (!p.is_category()) addPictoWord(view, p);
if (PCBcontext.getVocabulary().is_category(p)) addPictoWord(view, p);
}
// Si el destino es el panel y el origen la cinta de frase
......@@ -752,7 +749,8 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
p.set_mirror(false, false);
// If the picto is a category
if (p.is_category()) {
Log.e("VOCA",p.get_translation()+":"+p.get_id()+":"+PCBcontext.getVocabulary().is_category(p));
if (PCBcontext.getVocabulary().is_category(p)) {
currentCategory = p;
PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p));
hidePictoMainGridView();
......@@ -785,7 +783,7 @@ public class VOCA extends Activity implements VocabularyTalk.iVocabularyListener
tapeAdapter.notifyDataSetChanged();
showPictoMainGridView();
PCBcontext.getActionLog().log(new TalkAction(TalkAction.ADD, p));
if (VOCA.this.feedback_read && !VOCA.this.tapeAdapter.play() && !p.is_category()) {
if (VOCA.this.feedback_read && !VOCA.this.tapeAdapter.play() && !PCBcontext.getVocabulary().is_category(p)) {
File audioFile = p.get_audioFile();
Log.e(LOG_TAG, "AUDIO:" + (audioFile != null) + ":" + p.get_audioPath());
if (audioFile != null)
......
......@@ -85,7 +85,7 @@ public class SerialActivity extends Activity {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SharedPreferences settings = getSharedPreferences(Device.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("username", users.elementAt(position).is_supervisor() ? users.elementAt(position).get_name_sup() : users.elementAt(position).get_name_stu());
editor.putString("username", users.elementAt(position).is_supervisor() ? users.elementAt(position).get_email_sup() : users.elementAt(position).get_nickname_stu());
editor.putString("password", users.elementAt(position).is_supervisor() ? users.elementAt(position).get_pwd_sup() : users.elementAt(position).get_pwd_stu());
editor.commit();
Class activityAfterLogin = null;
......
......@@ -45,12 +45,10 @@
android:layout_height="@dimen/tape_big_height"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:background="@android:color/holo_red_light"
android:clickable="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:scaleType="fitCenter"
android:src="@drawable/send_tape" />
<ImageButton
......
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