Formatting applied
This commit is contained in:
parent
41ccd6668c
commit
3bda012fba
@ -1,17 +1,17 @@
|
|||||||
package org.solovyev.android.views; /**
|
package org.solovyev.android.views; /**
|
||||||
* DO WHAT YOU WANT TO PUBLIC LICENSE
|
* DO WHAT YOU WANT TO PUBLIC LICENSE
|
||||||
* Version 2, December 2004
|
* Version 2, December 2004
|
||||||
*
|
* <p/>
|
||||||
* Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
* Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||||
*
|
* <p/>
|
||||||
* Everyone is permitted to copy and distribute verbatim or modified
|
* Everyone is permitted to copy and distribute verbatim or modified
|
||||||
* copies of this license document, and changing it is allowed as long
|
* copies of this license document, and changing it is allowed as long
|
||||||
* as the name is changed.
|
* as the name is changed.
|
||||||
*
|
* <p/>
|
||||||
* DO WHAT YOU WANT TO PUBLIC LICENSE
|
* DO WHAT YOU WANT TO PUBLIC LICENSE
|
||||||
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
*
|
* <p/>
|
||||||
* 0. You just DO WHAT YOU WANT TO.
|
* 0. You just DO WHAT YOU WANT TO.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -34,36 +34,22 @@ public class AutoResizeTextView extends TextView {
|
|||||||
|
|
||||||
// Minimum text size for this text view
|
// Minimum text size for this text view
|
||||||
public static final float MIN_TEXT_SIZE = 20;
|
public static final float MIN_TEXT_SIZE = 20;
|
||||||
|
|
||||||
// Interface for resize notifications
|
|
||||||
public interface OnTextResizeListener {
|
|
||||||
public void onTextResize(TextView textView, float oldSize, float newSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Our ellipse string
|
// Our ellipse string
|
||||||
private static final String mEllipsis = "...";
|
private static final String mEllipsis = "...";
|
||||||
|
|
||||||
// Registered resize listener
|
// Registered resize listener
|
||||||
private OnTextResizeListener mTextResizeListener;
|
private OnTextResizeListener mTextResizeListener;
|
||||||
|
|
||||||
// Flag for text and/or size changes to force a resize
|
// Flag for text and/or size changes to force a resize
|
||||||
private boolean mNeedsResize = false;
|
private boolean mNeedsResize = false;
|
||||||
|
|
||||||
// Text size that is set from code. This acts as a starting point for resizing
|
// Text size that is set from code. This acts as a starting point for resizing
|
||||||
private float mTextSize;
|
private float mTextSize;
|
||||||
|
|
||||||
// Temporary upper bounds on the starting text size
|
// Temporary upper bounds on the starting text size
|
||||||
private float mMaxTextSize = 0;
|
private float mMaxTextSize = 0;
|
||||||
|
|
||||||
// Lower bounds for text size
|
// Lower bounds for text size
|
||||||
private float mMinTextSize = MIN_TEXT_SIZE;
|
private float mMinTextSize = MIN_TEXT_SIZE;
|
||||||
|
|
||||||
// Text view line spacing multiplier
|
// Text view line spacing multiplier
|
||||||
private float mSpacingMult = 1.0f;
|
private float mSpacingMult = 1.0f;
|
||||||
|
|
||||||
// Text view additional line spacing
|
// Text view additional line spacing
|
||||||
private float mSpacingAdd = 0.0f;
|
private float mSpacingAdd = 0.0f;
|
||||||
|
|
||||||
// Add ellipsis to text that overflows at the smallest text size
|
// Add ellipsis to text that overflows at the smallest text size
|
||||||
private boolean mAddEllipsis = true;
|
private boolean mAddEllipsis = true;
|
||||||
|
|
||||||
@ -139,16 +125,6 @@ public class AutoResizeTextView extends TextView {
|
|||||||
mSpacingAdd = add;
|
mSpacingAdd = add;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the upper text size limit and invalidate the view
|
|
||||||
* @param maxTextSize
|
|
||||||
*/
|
|
||||||
public void setMaxTextSize(float maxTextSize) {
|
|
||||||
mMaxTextSize = maxTextSize;
|
|
||||||
requestLayout();
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return upper text size limit
|
* Return upper text size limit
|
||||||
* @return
|
* @return
|
||||||
@ -158,11 +134,11 @@ public class AutoResizeTextView extends TextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the lower text size limit and invalidate the view
|
* Set the upper text size limit and invalidate the view
|
||||||
* @param minTextSize
|
* @param maxTextSize
|
||||||
*/
|
*/
|
||||||
public void setMinTextSize(float minTextSize) {
|
public void setMaxTextSize(float maxTextSize) {
|
||||||
mMinTextSize = minTextSize;
|
mMaxTextSize = maxTextSize;
|
||||||
requestLayout();
|
requestLayout();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
@ -176,11 +152,13 @@ public class AutoResizeTextView extends TextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set flag to add ellipsis to text that overflows at the smallest text size
|
* Set the lower text size limit and invalidate the view
|
||||||
* @param addEllipsis
|
* @param minTextSize
|
||||||
*/
|
*/
|
||||||
public void setAddEllipsis(boolean addEllipsis) {
|
public void setMinTextSize(float minTextSize) {
|
||||||
mAddEllipsis = addEllipsis;
|
mMinTextSize = minTextSize;
|
||||||
|
requestLayout();
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -191,6 +169,14 @@ public class AutoResizeTextView extends TextView {
|
|||||||
return mAddEllipsis;
|
return mAddEllipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set flag to add ellipsis to text that overflows at the smallest text size
|
||||||
|
* @param addEllipsis
|
||||||
|
*/
|
||||||
|
public void setAddEllipsis(boolean addEllipsis) {
|
||||||
|
mAddEllipsis = addEllipsis;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the text to the original size
|
* Reset the text to the original size
|
||||||
*/
|
*/
|
||||||
@ -316,4 +302,9 @@ public class AutoResizeTextView extends TextView {
|
|||||||
return layout.getHeight();
|
return layout.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Interface for resize notifications
|
||||||
|
public interface OnTextResizeListener {
|
||||||
|
public void onTextResize(TextView textView, float oldSize, float newSize);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user