kopia lustrzana https://github.com/olgamiller/SSTVEncoder2
Renamed "border" to "outline"
Renamed local variables in init*Spinner in EditTextActivitypull/3/head
rodzic
7371ada115
commit
b5915841fb
|
@ -38,11 +38,11 @@ public class EditTextActivity extends AppCompatActivity implements AdapterView.O
|
|||
public static final String EXTRA = "EDIT_TEXT_EXTRA";
|
||||
private EditText mEditText;
|
||||
private ColorPaletteView mColorPaletteView;
|
||||
private float mTextSize, mBorderSize;
|
||||
private float mTextSize, mOutlineSize;
|
||||
private FontFamilySet mFontFamilySet;
|
||||
private FontFamilySet.FontFamily mSelectedFontFamily;
|
||||
private List<String> mFontFamilyNameList;
|
||||
private CheckBox mEditItalic, mEditBold, mEditBorder;
|
||||
private CheckBox mEditItalic, mEditBold, mEditOutline;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -52,7 +52,7 @@ public class EditTextActivity extends AppCompatActivity implements AdapterView.O
|
|||
mColorPaletteView = (ColorPaletteView) findViewById(R.id.edit_color);
|
||||
mEditBold = (CheckBox) findViewById(R.id.edit_bold);
|
||||
mEditItalic = (CheckBox) findViewById(R.id.edit_italic);
|
||||
mEditBorder = (CheckBox) findViewById(R.id.edit_border);
|
||||
mEditOutline = (CheckBox) findViewById(R.id.edit_outline);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,39 +66,39 @@ public class EditTextActivity extends AppCompatActivity implements AdapterView.O
|
|||
mColorPaletteView.setColor(label.getForeColor());
|
||||
initFontFamilySpinner(label.getFamilyName());
|
||||
updateBoldAndItalic();
|
||||
mEditBorder.setChecked(label.getBorder());
|
||||
initBorderSizeSpinner(label.getBorderSize());
|
||||
mEditOutline.setChecked(label.getOutline());
|
||||
initOutlineSizeSpinner(label.getOutlineSize());
|
||||
}
|
||||
|
||||
private void initFontFamilySpinner(String familyName) {
|
||||
Spinner editFontFamily = (Spinner) findViewById(R.id.edit_font_family);
|
||||
editFontFamily.setOnItemSelectedListener(this);
|
||||
Spinner spinner = (Spinner) findViewById(R.id.edit_font_family);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
mFontFamilySet = new FontFamilySet();
|
||||
mSelectedFontFamily = mFontFamilySet.getFontFamily(familyName);
|
||||
mFontFamilyNameList = mFontFamilySet.getFontFamilyDisplayNameList();
|
||||
editFontFamily.setAdapter(new ArrayAdapter<>(this,
|
||||
spinner.setAdapter(new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, mFontFamilyNameList));
|
||||
editFontFamily.setSelection(mFontFamilyNameList.indexOf(mSelectedFontFamily.displayName));
|
||||
spinner.setSelection(mFontFamilyNameList.indexOf(mSelectedFontFamily.displayName));
|
||||
}
|
||||
|
||||
private void initTextSizeSpinner(float textSize) {
|
||||
mTextSize = textSize;
|
||||
Spinner editTextSize = (Spinner) findViewById(R.id.edit_text_size);
|
||||
editTextSize.setOnItemSelectedListener(this);
|
||||
String[] textSizeList = new String[]{"Small", "Normal", "Large", "Huge"};
|
||||
editTextSize.setAdapter(new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, textSizeList));
|
||||
editTextSize.setSelection(textSizeToPosition(textSize));
|
||||
Spinner spinner = (Spinner) findViewById(R.id.edit_text_size);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
String[] sizeList = new String[]{"Small", "Normal", "Large", "Huge"};
|
||||
spinner.setAdapter(new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, sizeList));
|
||||
spinner.setSelection(textSizeToPosition(textSize));
|
||||
}
|
||||
|
||||
private void initBorderSizeSpinner(float borderSize) {
|
||||
mBorderSize = borderSize;
|
||||
Spinner editBorderSize = (Spinner) findViewById(R.id.edit_border_size);
|
||||
editBorderSize.setOnItemSelectedListener(this);
|
||||
String[] borderSizeList = new String[]{"Thin", "Normal", "Thick"};
|
||||
editBorderSize.setAdapter(new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, borderSizeList));
|
||||
editBorderSize.setSelection(borderSizeToPosition(borderSize));
|
||||
private void initOutlineSizeSpinner(float outlineSize) {
|
||||
mOutlineSize = outlineSize;
|
||||
Spinner spinner = (Spinner) findViewById(R.id.edit_outline_size);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
String[] sizeList = new String[]{"Thin", "Normal", "Thick"};
|
||||
spinner.setAdapter(new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_spinner_dropdown_item, sizeList));
|
||||
spinner.setSelection(outlineSizeToPosition(outlineSize));
|
||||
}
|
||||
|
||||
private int textSizeToPosition(float textSize) {
|
||||
|
@ -113,16 +113,16 @@ public class EditTextActivity extends AppCompatActivity implements AdapterView.O
|
|||
return position + 1f;
|
||||
}
|
||||
|
||||
private int borderSizeToPosition(float borderSize) {
|
||||
int position = (int) (borderSize * 2f / Label.BORDER_SIZE_NORMAL - 1f);
|
||||
private int outlineSizeToPosition(float outlineSize) {
|
||||
int position = (int) (outlineSize * 2f / Label.OUTLINE_SIZE_NORMAL - 1f);
|
||||
if (0 <= position && position <= 2)
|
||||
return position;
|
||||
mBorderSize = Label.BORDER_SIZE_NORMAL;
|
||||
mOutlineSize = Label.OUTLINE_SIZE_NORMAL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
private float positionToBorderSize(int position) {
|
||||
return Label.BORDER_SIZE_NORMAL * 0.5f * (position + 1f);
|
||||
private float positionToOutlineSize(int position) {
|
||||
return Label.OUTLINE_SIZE_NORMAL * 0.5f * (position + 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,8 +131,8 @@ public class EditTextActivity extends AppCompatActivity implements AdapterView.O
|
|||
case R.id.edit_text_size:
|
||||
mTextSize = positionToTextSize(position);
|
||||
break;
|
||||
case R.id.edit_border_size:
|
||||
mBorderSize = positionToBorderSize(position);
|
||||
case R.id.edit_outline_size:
|
||||
mOutlineSize = positionToOutlineSize(position);
|
||||
break;
|
||||
case R.id.edit_font_family:
|
||||
String displayName = mFontFamilyNameList.get(position);
|
||||
|
@ -190,8 +190,8 @@ public class EditTextActivity extends AppCompatActivity implements AdapterView.O
|
|||
label.setItalic(mEditItalic.isChecked());
|
||||
label.setBold(mEditBold.isChecked());
|
||||
label.setForeColor(mColorPaletteView.getColor());
|
||||
label.setBorder(mEditBorder.isChecked());
|
||||
label.setBorderSize(mBorderSize);
|
||||
label.setOutline(mEditOutline.isChecked());
|
||||
label.setOutlineSize(mOutlineSize);
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ import java.io.Serializable;
|
|||
|
||||
public class Label implements Serializable {
|
||||
public static final float TEXT_SIZE_NORMAL = 2f;
|
||||
public static final float BORDER_SIZE_NORMAL = 0.05f;
|
||||
public static final float OUTLINE_SIZE_NORMAL = 0.05f;
|
||||
private String mText;
|
||||
private float mTextSize, mBorderSize;
|
||||
private float mTextSize, mOutlineSize;
|
||||
private String mFamilyName;
|
||||
private boolean mBold, mItalic, mBorder;
|
||||
private int mForeColor, mBackColor, mBorderColor;
|
||||
private boolean mBold, mItalic, mOutline;
|
||||
private int mForeColor, mBackColor, mOutlineColor;
|
||||
|
||||
public Label() {
|
||||
mText = "";
|
||||
|
@ -36,9 +36,9 @@ public class Label implements Serializable {
|
|||
mItalic = false;
|
||||
mForeColor = Color.BLACK;
|
||||
mBackColor = Color.TRANSPARENT;
|
||||
mBorder = true;
|
||||
mBorderSize = BORDER_SIZE_NORMAL;
|
||||
mBorderColor = Color.WHITE;
|
||||
mOutline = true;
|
||||
mOutlineSize = OUTLINE_SIZE_NORMAL;
|
||||
mOutlineColor = Color.WHITE;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
|
@ -99,27 +99,27 @@ public class Label implements Serializable {
|
|||
mBackColor = color;
|
||||
}
|
||||
|
||||
public boolean getBorder() {
|
||||
return mBorder;
|
||||
public boolean getOutline() {
|
||||
return mOutline;
|
||||
}
|
||||
|
||||
public void setBorder(boolean border) {
|
||||
mBorder = border;
|
||||
public void setOutline(boolean outline) {
|
||||
mOutline = outline;
|
||||
}
|
||||
|
||||
public float getBorderSize() {
|
||||
return mBorderSize;
|
||||
public float getOutlineSize() {
|
||||
return mOutlineSize;
|
||||
}
|
||||
|
||||
public void setBorderSize(float size) {
|
||||
mBorderSize = size;
|
||||
public void setOutlineSize(float size) {
|
||||
mOutlineSize = size;
|
||||
}
|
||||
|
||||
public int getBorderColor() {
|
||||
return mBorderColor;
|
||||
public int getOutlineColor() {
|
||||
return mOutlineColor;
|
||||
}
|
||||
|
||||
public void setBorderColor(int color) {
|
||||
mBorderColor = color;
|
||||
public void setOutlineColor(int color) {
|
||||
mOutlineColor = color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,9 +104,9 @@ class LabelContainer {
|
|||
writer.write("italic", label.getItalic());
|
||||
writer.write("fore_color", label.getForeColor());
|
||||
writer.write("back_color", label.getBackColor());
|
||||
writer.write("border", label.getBorder());
|
||||
writer.write("border_size", label.getBorderSize());
|
||||
writer.write("border_color", label.getBorderColor());
|
||||
writer.write("outline", label.getOutline());
|
||||
writer.write("outline_size", label.getOutlineSize());
|
||||
writer.write("outline_color", label.getOutlineColor());
|
||||
}
|
||||
|
||||
private void readLabel(IReader reader, Label label) throws IOException {
|
||||
|
@ -117,9 +117,9 @@ class LabelContainer {
|
|||
label.setItalic(reader.readBoolean());
|
||||
label.setForeColor(reader.readInt());
|
||||
label.setBackColor(reader.readInt());
|
||||
label.setBorder(reader.readBoolean());
|
||||
label.setBorderSize(reader.readFloat());
|
||||
label.setBorderColor(reader.readInt());
|
||||
label.setOutline(reader.readBoolean());
|
||||
label.setOutlineSize(reader.readFloat());
|
||||
label.setOutlineColor(reader.readInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ class LabelPainter {
|
|||
}
|
||||
|
||||
private void drawBorder(Canvas canvas, float x, float y) {
|
||||
if (mLabel.getBorder()) {
|
||||
if (mLabel.getOutline()) {
|
||||
setBorderPaintSettings();
|
||||
canvas.drawText(mLabel.getText(), x, y, mPaint);
|
||||
setTextPaintSettings();
|
||||
|
@ -134,7 +134,7 @@ class LabelPainter {
|
|||
|
||||
private void setBorderPaintSettings() {
|
||||
mPaint.setStyle(Paint.Style.STROKE);
|
||||
mPaint.setColor(mLabel.getBorderColor());
|
||||
mPaint.setColor(mLabel.getOutlineColor());
|
||||
}
|
||||
|
||||
private void setTextPaintSettings() {
|
||||
|
@ -145,7 +145,7 @@ class LabelPainter {
|
|||
private void setSizePaintSettings(float sizeFactor) {
|
||||
float textSize = mLabel.getTextSize() * sizeFactor;
|
||||
mPaint.setTextSize(textSize);
|
||||
mPaint.setStrokeWidth(mLabel.getBorderSize() * textSize);
|
||||
mPaint.setStrokeWidth(mLabel.getOutlineSize() * textSize);
|
||||
}
|
||||
|
||||
private int getTypeface() {
|
||||
|
|
|
@ -65,14 +65,14 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/edit_border"
|
||||
android:id="@+id/edit_outline"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.3"
|
||||
android:text="@string/border"/>
|
||||
android:text="@string/outline"/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/edit_border_size"
|
||||
android:id="@+id/edit_outline_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.7"
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
<string name="chooser_title">Send Bug Report:</string>
|
||||
<string name="bold">Bold</string>
|
||||
<string name="italic">Italic</string>
|
||||
<string name="border">Border</string>
|
||||
<string name="outline">Outline</string>
|
||||
</resources>
|
Ładowanie…
Reference in New Issue