/*
* File: control_area.java
* This file is part of Tico, an application to create and perform
* interactive communication boards to be used by people with
* severe motor disabilities.
*
* Author: Eduardo Ferrer
*
* Date: Sep, 2012
*
* Company: Dept. of Computer Sciences and Systems Engineering, Universidad de Zaragoza, Spain
*
*
* License:
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package android.TICO;
import android.content.Context;
import android.os.Handler;
import android.widget.RelativeLayout;
/**
* Defines a control_area
and its attributes. The control_area
contains the estandard control cells
*
* @author Eduardo Ferrer
*/
public class control_area extends RelativeLayout{
private cell inicio;
//private cell inicioLandscape;
private cell volver;
//private cell volverLandscape;
private cell leer;
//private cell leerLandscape;
private cell borrar1;
//private cell borrar1Landscape;
private cell borrarTodas;
//private cell borrarTodasLandscape;
/**
* Creates the control_area and its cells
*
* @param context The context
that contains the control_area
* @param controlSize LayoutParams
that contains the height and width for the
*/
public control_area(Context context,LayoutParams controlSize) {
super(context);
// TODO Auto-generated constructor stub
setLayoutParams(controlSize);
setBackgroundColor(TICO.res.getColor(R.color.bars_background_color));
//creamos las imagenes de control y las anyadimos en el orden especificado en config.xml
for(int i=0;i<5;i++){
//inicio
if(i==TICO.res.getInteger(R.integer.control_home_order_0_to_4)){
inicio=new cell(context,
(TICO.res.getInteger(R.integer.control_home_order_0_to_4)*20 + 1)*this.getLayoutParams().width/100,
2*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100/*19*this.getLayoutParams().width/100*/,
R.drawable.controller_home,
"",
6);
inicio.setColorFrame(TICO.res.getColor(R.color.frame_control_color));
inicio.setColorFrameAlternate(TICO.res.getColor(R.color.frame_alternate_color));
this.addView(inicio);
}
//volver
if(i==TICO.res.getInteger(R.integer.control_back_order_0_to_4)){
volver=new cell(context,
(TICO.res.getInteger(R.integer.control_back_order_0_to_4)*20+ 1)*this.getLayoutParams().width/100,
2*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100/*19*this.getLayoutParams().width/100*/,
R.drawable.controller_return,
"",
6);
volver.setColorFrame(TICO.res.getColor(R.color.frame_control_color));
volver.setColorFrameAlternate(TICO.res.getColor(R.color.frame_alternate_color));
this.addView(volver);
}
//borrar1
if(i==TICO.res.getInteger(R.integer.control_delete1_order_0_to_4)){
borrar1=new cell(context,
(TICO.res.getInteger(R.integer.control_delete1_order_0_to_4)*20 + 1)*this.getLayoutParams().width/100,
2*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100 /*19*this.getLayoutParams().width/100*/,
R.drawable.controller_undo,
"",
6);
borrar1.setColorFrame(TICO.res.getColor(R.color.frame_control_color));
borrar1.setColorFrameAlternate(TICO.res.getColor(R.color.frame_alternate_color));
this.addView(borrar1);
}
//borrar todas
if(i==TICO.res.getInteger(R.integer.control_deleteall_order_0_to_4)){
borrarTodas=new cell(context,
(TICO.res.getInteger(R.integer.control_deleteall_order_0_to_4)*20 +1)*this.getLayoutParams().width/100,
2*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100/*19*this.getLayoutParams().width/100*/,
R.drawable.controller_undo_all,
"",
6);
borrarTodas.setColorFrame(TICO.res.getColor(R.color.frame_control_color));
borrarTodas.setColorFrameAlternate(TICO.res.getColor(R.color.frame_alternate_color));
this.addView(borrarTodas);
}
//leer
if(i==TICO.res.getInteger(R.integer.control_read_order_0_to_4)){
leer=new cell(context,
(TICO.res.getInteger(R.integer.control_read_order_0_to_4)*20 + 1)*this.getLayoutParams().width/100,
2*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100,
97*this.getLayoutParams().height/100/*19*this.getLayoutParams().width/100*/,
R.drawable.controller_read,
"",
6);
leer.setColorFrame(TICO.res.getColor(R.color.frame_control_color));
leer.setColorFrameAlternate(TICO.res.getColor(R.color.frame_alternate_color));
this.addView(leer);
}
}
}
/**
* returns the home control cell
* @return home control cell
*/
public cell inicio(){
return inicio;
}
/**
* returns the back control cell;
* @return back control cell
*/
public cell volver(){
return volver;
}
/**
* returns read control cell
* @return read control cell
*/
public cell leer(){
return leer;
}
/**
* returns erase one cell control cell
* @return erase one cell control cell
*/
public cell borrar1(){
return borrar1;
}
/**
* returns erase all cells control cell
* @return erase all cells control cell
*/
public cell borrarTodas(){
return borrarTodas;
}
/**
* Make the control cells non clickables
*/
public void listenersOff(){
// backEnabled=false;
if(inicio!=null) inicio.setClickable(false);
if(volver!=null) volver.setClickable(false);
if(leer!=null) leer.setClickable(false);
if(borrar1!=null) borrar1.setClickable(false);
if(borrarTodas!=null) borrarTodas.setClickable(false);
}
/**
* Make the control cells clickables with a little delay
*/
public void listenersOn(){
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
if(inicio!=null) inicio.setClickable(true);
if(volver!=null) volver.setClickable(true);
if(leer!=null) leer.setClickable(true);
if(borrar1!=null) borrar1.setClickable(true);
if(borrarTodas!=null) borrarTodas.setClickable(true);
//backEnabled=true;
}
}, 100L);//tiempo minimo de espera al cargar un panel para la siguiente orden de control
}
}