mirror of
https://github.com/olgamiller/SSTVEncoder2.git
synced 2025-12-06 06:52:01 +01:00
Re-organized activity_edit_text
This commit is contained in:
parent
f53c75cf26
commit
ea1eb2775e
|
|
@ -16,6 +16,8 @@ limitations under the License.
|
||||||
package om.sstvencoder;
|
package om.sstvencoder;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.support.annotation.ColorInt;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -76,6 +78,7 @@ public class EditTextActivity extends AppCompatActivity
|
||||||
initOutlineSizeSpinner(mLabel.getOutlineSize());
|
initOutlineSizeSpinner(mLabel.getOutlineSize());
|
||||||
findViewById(R.id.edit_color).setBackgroundColor(mLabel.getForeColor());
|
findViewById(R.id.edit_color).setBackgroundColor(mLabel.getForeColor());
|
||||||
findViewById(R.id.edit_outline_color).setBackgroundColor(mLabel.getOutlineColor());
|
findViewById(R.id.edit_outline_color).setBackgroundColor(mLabel.getOutlineColor());
|
||||||
|
enableOutline(mEditOutline.isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initText() {
|
private void initText() {
|
||||||
|
|
@ -171,19 +174,33 @@ public class EditTextActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBoldAndItalic() {
|
private void updateBoldAndItalic() {
|
||||||
mEditBold.setEnabled(mSelectedFontFamily.bold);
|
boolean bold = mSelectedFontFamily.bold;
|
||||||
|
mEditBold.setEnabled(bold);
|
||||||
|
findViewById(R.id.text_bold).setEnabled(bold);
|
||||||
if (!mEditBold.isEnabled()) {
|
if (!mEditBold.isEnabled()) {
|
||||||
mEditBold.setChecked(false);
|
mEditBold.setChecked(false);
|
||||||
mLabel.setBold(false);
|
mLabel.setBold(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mEditItalic.setEnabled(mSelectedFontFamily.italic);
|
boolean italic = mSelectedFontFamily.italic;
|
||||||
|
mEditItalic.setEnabled(italic);
|
||||||
|
findViewById(R.id.text_italic).setEnabled(italic);
|
||||||
if (!mEditItalic.isEnabled()) {
|
if (!mEditItalic.isEnabled()) {
|
||||||
mEditItalic.setChecked(false);
|
mEditItalic.setChecked(false);
|
||||||
mLabel.setItalic(false);
|
mLabel.setItalic(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enableOutline(boolean enabled) {
|
||||||
|
findViewById(R.id.text_outline_size).setEnabled(enabled);
|
||||||
|
findViewById(R.id.edit_outline_size).setEnabled(enabled);
|
||||||
|
findViewById(R.id.text_outline_color).setEnabled(enabled);
|
||||||
|
findViewById(R.id.edit_outline_color).setEnabled(enabled);
|
||||||
|
@ColorInt
|
||||||
|
int color = enabled ? mLabel.getOutlineColor() : Color.DKGRAY;
|
||||||
|
findViewById(R.id.edit_outline_color).setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +230,11 @@ public class EditTextActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onOutlineClick(View view) {
|
public void onOutlineClick(View view) {
|
||||||
mLabel.setOutline(mEditOutline.isChecked());
|
if (view.getId() == R.id.text_outline)
|
||||||
|
mEditOutline.setChecked(!mEditOutline.isChecked());
|
||||||
|
boolean outline = mEditOutline.isChecked();
|
||||||
|
mLabel.setOutline(outline);
|
||||||
|
enableOutline(outline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onColorClick(View view) {
|
public void onColorClick(View view) {
|
||||||
|
|
@ -222,8 +243,10 @@ public class EditTextActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onOutlineColorClick(View view) {
|
public void onOutlineColorClick(View view) {
|
||||||
showColorDialog(R.string.outline_color, mLabel.getOutlineColor());
|
if (mEditOutline.isChecked()) {
|
||||||
mEditColor = EditColorMode.Outline;
|
showColorDialog(R.string.outline_color, mLabel.getOutlineColor());
|
||||||
|
mEditColor = EditColorMode.Outline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showColorDialog(int title, int color) {
|
private void showColorDialog(int title, int color) {
|
||||||
|
|
|
||||||
|
|
@ -1,139 +1,147 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<ScrollView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/activity_edit_text"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".EditTextActivity">
|
tools:context=".EditTextActivity">
|
||||||
|
|
||||||
<EditText
|
<TableLayout
|
||||||
android:id="@+id/edit_text"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:imeOptions="actionDone|flagNoExtractUi"
|
android:stretchColumns="1,4">
|
||||||
android:inputType="text"
|
|
||||||
android:textSize="32sp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<TableRow>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/edit_font_family"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.7"
|
|
||||||
android:minHeight="32sp"/>
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/edit_text_size"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.3"
|
|
||||||
android:minHeight="32sp"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/edit_italic"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.3"
|
|
||||||
android:onClick="onItalicClick"
|
|
||||||
android:text="@string/italic"/>
|
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/edit_bold"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.3"
|
|
||||||
android:onClick="onBoldClick"
|
|
||||||
android:text="@string/bold"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.4"
|
|
||||||
android:clickable="true"
|
|
||||||
android:onClick="onColorClick"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/edit_color"
|
|
||||||
android:layout_width="32sp"
|
|
||||||
android:layout_height="32sp"
|
|
||||||
android:background="@android:color/white"
|
|
||||||
android:onClick="onColorClick"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/color"
|
android:text="@string/text"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginLeft="6sp"
|
|
||||||
android:clickable="true"
|
|
||||||
android:onClick="onColorClick"
|
|
||||||
android:text="@string/color"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
<EditText
|
||||||
|
android:id="@+id/edit_text"
|
||||||
|
android:layout_span="4"
|
||||||
|
android:imeOptions="actionDone|flagNoExtractUi"
|
||||||
|
android:inputType="text"
|
||||||
|
android:textSize="32sp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</TableRow>
|
||||||
|
|
||||||
<LinearLayout
|
<TableRow>
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/edit_outline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.3"
|
|
||||||
android:onClick="onOutlineClick"
|
|
||||||
android:text="@string/outline"/>
|
|
||||||
|
|
||||||
<Spinner
|
|
||||||
android:id="@+id/edit_outline_size"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.3"
|
|
||||||
android:minHeight="32sp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0.4"
|
|
||||||
android:clickable="true"
|
|
||||||
android:onClick="onOutlineColorClick"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/edit_outline_color"
|
|
||||||
android:layout_width="32sp"
|
|
||||||
android:layout_height="32sp"
|
|
||||||
android:background="@android:color/white"
|
|
||||||
android:onClick="onOutlineColorClick"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/outline_color"
|
android:text="@string/font"/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
<Spinner
|
||||||
android:layout_marginLeft="6sp"
|
android:id="@+id/edit_font_family"
|
||||||
|
android:layout_span="4"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_italic"
|
||||||
|
android:text="@string/italic"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/edit_italic"
|
||||||
|
android:onClick="onItalicClick"
|
||||||
|
android:text=""/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_bold"
|
||||||
|
android:text="@string/bold"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/edit_bold"
|
||||||
|
android:onClick="onBoldClick"
|
||||||
|
android:text=""/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/edit_outline"
|
||||||
|
android:onClick="onOutlineClick"
|
||||||
|
android:text=""/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_outline"
|
||||||
|
style="?android:attr/listSeparatorTextViewStyle"
|
||||||
|
android:layout_span="2"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:onClick="onOutlineColorClick"
|
android:onClick="onOutlineClick"
|
||||||
android:text="@string/outline_color"
|
android:text="@string/outline"/>
|
||||||
android:textColor="?android:attr/textColorPrimary"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</TableRow>
|
||||||
|
|
||||||
</LinearLayout>
|
<TableRow>
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:text="@string/size"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/edit_text_size"
|
||||||
|
android:layout_width="50dp"/>
|
||||||
|
|
||||||
|
<android.support.v4.widget.Space
|
||||||
|
android:layout_width="0dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_outline_size"
|
||||||
|
android:text="@string/size"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/edit_outline_size"
|
||||||
|
android:layout_width="50dp"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/color"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:clickable="true"
|
||||||
|
android:onClick="onColorClick">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/edit_color"
|
||||||
|
android:layout_width="24sp"
|
||||||
|
android:layout_height="24sp"
|
||||||
|
android:layout_margin="6sp"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:clickable="true"
|
||||||
|
android:onClick="onColorClick"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<android.support.v4.widget.Space
|
||||||
|
android:layout_width="0dp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_outline_color"
|
||||||
|
android:text="@string/color"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:clickable="true"
|
||||||
|
android:onClick="onOutlineColorClick">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/edit_outline_color"
|
||||||
|
android:layout_width="24sp"
|
||||||
|
android:layout_height="24sp"
|
||||||
|
android:layout_margin="6sp"
|
||||||
|
android:background="@android:color/white"
|
||||||
|
android:clickable="true"
|
||||||
|
android:onClick="onOutlineColorClick"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
|
||||||
|
|
@ -38,4 +38,7 @@
|
||||||
<string name="outline">Outline</string>
|
<string name="outline">Outline</string>
|
||||||
<string name="color">Color</string>
|
<string name="color">Color</string>
|
||||||
<string name="outline_color">Outline Color</string>
|
<string name="outline_color">Outline Color</string>
|
||||||
|
<string name="size">Size</string>
|
||||||
|
<string name="font">Font</string>
|
||||||
|
<string name="text">Text</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in a new issue