Skip to content

Commit

Permalink
Autosize text inside Element
Browse files Browse the repository at this point in the history
Text resizing is handled by `AutoSizeableTextView`, which `Element`
implements, so manual text resizing is unnecessary.
Fixes SecUSo#2, SecUSo#6 and SecUSo#12.
  • Loading branch information
p-davide committed Nov 5, 2022
1 parent b068d50 commit 3e96b25
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 29 deletions.
12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class Element extends android.support.v7.widget.AppCompatButton {
public int dPosY = 0;
public boolean activated;
public boolean animateMoving = false;
public float textSize = 24;
Context context;
int color;

Expand All @@ -59,7 +58,6 @@ public Element(Context c)
super(c);
context = c;
setAllCaps(false);
setTextSize(textSize);
setBackgroundResource(R.drawable.game_brick);
if(PreferenceManager.getDefaultSharedPreferences(context).getString("pref_color","1").equals("1"))
setColor(context.getResources().getColor(R.color.button_empty));
Expand Down Expand Up @@ -143,14 +141,10 @@ public void drawItem() {
case 16384:
setColor(ContextCompat.getColor(context,R.color.button16384));
setTextColor(ContextCompat.getColor(context,R.color.white));
textSize = textSize * 0.8f;
setTextSize(textSize);
break;
case 32768:
setColor(ContextCompat.getColor(context,R.color.button32768));
setTextColor(ContextCompat.getColor(context,R.color.white));
textSize = textSize * 0.8f;
setTextSize(textSize);
break;
}
}
Expand Down Expand Up @@ -216,14 +210,10 @@ public void drawItem() {
case 16384:
setColor(ContextCompat.getColor(context,R.color.button16384_2));
setTextColor(ContextCompat.getColor(context,R.color.white));
textSize = textSize * 0.8f;
setTextSize(textSize);
break;
case 32768:
setColor(ContextCompat.getColor(context,R.color.button32768_2));
setTextColor(ContextCompat.getColor(context,R.color.white));
textSize = textSize * 0.8f;
setTextSize(textSize);
break;
}
}
Expand Down Expand Up @@ -273,10 +263,7 @@ public int getPosX() {
public int getPosY() {
return posY;
}
public void updateFontSize(){
textSize=(float)(getLayoutParams().width/7.0);
setTextSize(textSize);
}

public Element copy()
{
Element temp = new Element(context);
Expand All @@ -288,9 +275,7 @@ public Element copy()
temp.dPosY = dPosY;
temp.activated = activated;
temp.animateMoving = animateMoving;
temp.textSize = textSize;
temp.color = color;
temp.setTextSize(textSize);
//temp.setBackgroundResource(backGroundResource);
temp.setColor(color);
temp.setVisibility(getVisibility());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ record = gameStatistics.getRecord();
elements[i][j].setDPosition(lp.getMarginStart(),lp.topMargin);
elements[i][j].setLayoutParams(lp);
backgroundElements[i][j].setLayoutParams(lp);
elements[i][j].updateFontSize();
backgroundElements[i][j].setLayoutParams(lp);
backgroundElements[i][j].setOnTouchListener(swipeListener);
elements[i][j].setOnTouchListener(swipeListener);
Expand Down

0 comments on commit 3e96b25

Please sign in to comment.