Commit 1766cdf9 by German Callejas

Cambiado dibujar sobre bitmap si la leyenda es full por un TextView en el layout…

Cambiado dibujar sobre bitmap si la leyenda es full por un TextView en el layout del pictograma (Falta terminar redimensionado de palabras)
parent 6b3f867a
......@@ -11,6 +11,7 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
......@@ -20,6 +21,8 @@ import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.PCBcontext;
import org.w3c.dom.Text;
import java.io.IOException;
/**
......@@ -43,8 +46,42 @@ public class PictoItemViewGenerator {
StringBuffer txt = new StringBuffer();
if(picto.get_legend().equals("full")){
/**TODO: Codigo para cortar las palabras si superan 6 caracteres */
/*for (int i = 0; i < words.length; i++) {
if (words[i].length() >= 6) {
int mitad = words[i].length()/2 - 1;
char r = words[i].charAt(mitad);
char r2 = words[i].charAt(mitad + 1);
while ((r2 == 'A' || r2 == 'E' || r2 == 'I' || r2 == 'O' || r2 == 'U') && (r != 'A' || r != 'E' || r != 'I' || r != 'O' || r != 'U')) {
mitad++;
r = words[i].charAt(mitad);
r2 = words[i].charAt(mitad + 1);
}
int index = 0;
while (index <= mitad) {
txt.append(words[i].charAt(index));
index++;
}
int diff = 6 - mitad;
diff -= 1;
txt.append("-");
while (diff != 6) {
txt.append(" ");
diff++;
}
while (index < words[i].length()) {
txt.append(words[i].charAt(index));
index++;
}
texto = txt.toString();
}else{
texto += "\n"+words[i];
}
}*/
return texto;
}else{
if (words.length == 1) {
......@@ -54,36 +91,7 @@ public class PictoItemViewGenerator {
texto += words[0].charAt(i);
if(i==10) break;
}
/*int mitad = (words[0].length() / 2) - 1;
char r = words[0].charAt(mitad);
char r2 = words[0].charAt(mitad + 1);
while ((r2 == 'A' || r2 == 'E' || r2 == 'I' || r2 == 'O' || r2 == 'U') && (r != 'A' || r != 'E' || r != 'I' || r != 'O' || r != 'U')) {
mitad++;
r = words[0].charAt(mitad);
r2 = words[0].charAt(mitad + 1);
}
int i = 0;
while (i <= mitad) {
txt.append(words[0].charAt(i));
i++;
}
int diff = 10 - mitad;
diff -= 1;
txt.append("-");
while (diff != 10) {
txt.append(" ");
diff++;
}
while (i < words[0].length()) {
txt.append(words[0].charAt(i));
i++;
}
texto = txt.toString();*/
}
}else{
texto = words[0];
}
......@@ -152,9 +160,9 @@ public class PictoItemViewGenerator {
textView.layout(0, 0, 100, 100);
textView.setPadding(0, 0, 0, 0);
textView.setTextSize(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? 13 : 11);
textView.setTextColor(Color.BLACK);
textView.setTextColor(Color.rgb(0,0,0));
textView.setWidth(100);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setGravity(Gravity.CENTER);
textView.setMaxLines(3);
textView.setText(texto);
textView.setDrawingCacheEnabled(true);
......@@ -178,13 +186,15 @@ public class PictoItemViewGenerator {
FrameLayout layout ;
final ImageView pictoImage ;
ImageView redCrossImage ;
TextView legend;
TextView legend;
TextView legend_full;
if (PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big()) {
layoutWrapper = (RelativeLayout) convertView.findViewById(R.id.picto_grid_item_layout_wrapper_big);
layout = (FrameLayout) convertView.findViewById(R.id.picto_grid_item_layout_big);
pictoImage = (ImageView) convertView.findViewById(R.id.picto_grid_item_image_big);
redCrossImage = (ImageView) convertView.findViewById(R.id.picto_grid_item_redcross_big);
legend = (TextView) convertView.findViewById(R.id.legend_text_big);
legend_full = (TextView) convertView.findViewById(R.id.legend_text_big_full);
} else
{
layoutWrapper = (RelativeLayout) convertView.findViewById(R.id.picto_grid_item_layout_wrapper);
......@@ -192,7 +202,7 @@ public class PictoItemViewGenerator {
pictoImage = (ImageView) convertView.findViewById(R.id.picto_grid_item_image);
redCrossImage = (ImageView) convertView.findViewById(R.id.picto_grid_item_redcross);
legend = (TextView) convertView.findViewById(R.id.legend_text);
//legend.setHeight((int) legend.getTextSize() + 2);
legend_full = (TextView) convertView.findViewById(R.id.legend_text_full);
}
layoutWrapper.setBackground(null);
layoutWrapper.setAlpha(PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? 0.25f : 0);
......@@ -210,7 +220,11 @@ public class PictoItemViewGenerator {
}
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.GONE);
} else {
legend.setText(format_legend(picto));
legend_full.setText(format_legend(picto));
if (!picto.is_invisible()) {
layoutWrapper.setAlpha(1.00f);
}
......@@ -220,14 +234,19 @@ public class PictoItemViewGenerator {
Bitmap bm = picto.get_bitmap(PCBcontext.getContext());
if(!picto.get_legend().equals("none")) {
if(picto.get_legend().equals("normal")){
legend.setText(format_legend(picto));
legend.setVisibility(View.VISIBLE);
legend_full.setVisibility(View.GONE);
}else {
bm = set_legend(PCBcontext.getContext(), bm, picto);
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.VISIBLE);
}
}else{
legend.setVisibility(View.GONE);
legend_full.setVisibility(View.GONE);
}
pictoImage.setImageBitmap(bm);
......
......@@ -26,8 +26,22 @@
android:id="@+id/legend_text"
android:textSize="11sp"
android:textColor="@android:color/black"
android:textAlignment="center"
android:layout_gravity="bottom"
android:visibility="gone"
android:background="@android:color/white" />
<TextView
android:text="Legend"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/legend_text_full"
android:textSize="18sp"
android:textColor="@android:color/black"
android:textAlignment="center"
android:maxLines="5"
android:gravity="center"
android:layout_gravity="center"
android:visibility="gone"
android:background="@android:color/white" />
......
......@@ -26,8 +26,21 @@
android:id="@+id/legend_text_big"
android:textSize="13sp"
android:textColor="@android:color/black"
android:textAlignment="center"
android:layout_gravity="bottom"
android:visibility="gone"
android:background="@android:color/white" />
<TextView
android:text="Legend"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/legend_text_big_full"
android:textColor="@android:color/black"
android:textAlignment="center"
android:gravity="center"
android:layout_gravity="center"
android:visibility="gone"
android:background="@android:color/white" />
......
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