Navigation Menu

Skip to content

Commit

Permalink
size readjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlythe committed Feb 5, 2013
1 parent f47212c commit 311c990
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions res/layout/history_entry.xml
Expand Up @@ -8,12 +8,14 @@
android:layout_height="wrap_content"
android:textSize="@dimen/small_display_text_size"
android:textColor="@color/history_input"
android:layout_marginBottom="-5dp"
android:id="@+id/base" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/display_text_size"
android:textColor="@color/history_result"
android:gravity="right"
android:layout_marginBottom="-5dp"
android:id="@+id/edited" />
</com.android2.calculator3.view.HistoryLine>
3 changes: 2 additions & 1 deletion src/com/android2/calculator3/EquationFormatter.java
Expand Up @@ -39,7 +39,8 @@ public String insertSupscripts(String input) {
sub_open++;
if(i + 1 == input.length()) {
formattedInput.append(c);
sub_open--;
formattedInput.append("</sup>");
sub_closed++;
}
else {
formattedInput.append(PLACEHOLDER);
Expand Down
24 changes: 17 additions & 7 deletions src/com/android2/calculator3/view/ColorButton.java
Expand Up @@ -47,6 +47,7 @@ class ColorButton extends Button {
EventListener mListener;
Paint mFeedbackPaint;
Paint mHintPaint;
Paint mHintExponentPaint;
Rect bounds = new Rect();

public ColorButton(Context context, AttributeSet attrs) {
Expand All @@ -68,7 +69,10 @@ private void init(Calculator calc) {
getPaint().setColor(res.getColor(R.color.button_text));
mHintPaint = new Paint();
mHintPaint.setColor(res.getColor(R.color.grey));
mHintPaint.setTextSize((float) (getTextSize() * .8));
mHintPaint.setTextSize(getTextSize() * 0.8f);
mHintExponentPaint = new Paint();
mHintExponentPaint.setColor(res.getColor(R.color.grey));
mHintExponentPaint.setTextSize(getTextSize() * 0.64f);

mAnimStart = -1;
}
Expand Down Expand Up @@ -127,12 +131,18 @@ else if(isPressed()) {
if(hint != null) {
String[] exponents = hint.toString().split(Pattern.quote("^"));
int offsetX = LogicalDensity.convertDpToPixel(10, getContext());
int offsetY = (int) (LogicalDensity.convertDpToPixel(20, getContext()) + (mTextY - LogicalDensity.convertDpToPixel(20, getContext()) - getTextHeight(
mHintPaint, hint.toString())) / 2);
int offsetY = (int) ((mTextY + LogicalDensity.convertDpToPixel(20, getContext()) - getTextHeight(mHintPaint, hint.toString())) / 2);
for(String str : exponents) {
canvas.drawText(str, 0, str.length(), mTextX + offsetX, mTextY - offsetY, mHintPaint);
offsetY += LogicalDensity.convertDpToPixel(6, getContext());
offsetX += mHintPaint.measureText(str);
if(str == exponents[0]) {
canvas.drawText(str, 0, str.length(), mTextX + offsetX, mTextY - offsetY, mHintPaint);
offsetY += LogicalDensity.convertDpToPixel(8, getContext());
offsetX += mHintPaint.measureText(str);
}
else {
canvas.drawText(str, 0, str.length(), mTextX + offsetX, mTextY - offsetY, mHintExponentPaint);
offsetY += LogicalDensity.convertDpToPixel(8, getContext());
offsetX += mHintExponentPaint.measureText(str);
}
}
}

Expand All @@ -145,7 +155,7 @@ private int getTextHeight(Paint paint, String text) {
int height = bounds.height();
String[] exponents = text.split(Pattern.quote("^"));
for(int i = 1; i < exponents.length; i++) {
height += LogicalDensity.convertDpToPixel(6, getContext());
height += LogicalDensity.convertDpToPixel(8, getContext());
}
return height;
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/android2/calculator3/view/MatrixInverseView.java
Expand Up @@ -40,7 +40,7 @@ public MatrixInverseView(final AdvancedDisplay display) {
super(display.getContext());
setCustomSelectionActionModeCallback(new NoTextSelectionMode());
setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
setText(Html.fromHtml("<sup>-1</sup>"));
setText(Html.fromHtml("<sup><small>-1</small></sup>"));
setTextAppearance(display.getContext(), R.style.display_style);
setPadding(0, 0, 0, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/android2/calculator3/view/MatrixTransposeView.java
Expand Up @@ -39,7 +39,7 @@ public MatrixTransposeView(final AdvancedDisplay display) {
super(display.getContext());
setCustomSelectionActionModeCallback(new NoTextSelectionMode());
setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
setText(Html.fromHtml("<sup>T</sup>"));
setText(Html.fromHtml("<sup><small>T</small></sup>"));
setTextAppearance(display.getContext(), R.style.display_style);
setPadding(0, 0, 0, 0);
}
Expand Down

0 comments on commit 311c990

Please sign in to comment.