Skip to content

Commit

Permalink
Update color dispay in text settings dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Nov 20, 2017
1 parent 48a92a6 commit 1d442c5
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
Expand Down Expand Up @@ -393,7 +392,7 @@ public boolean onImageTouched(View view, MotionEvent event) {
@OnClick(R.id.settings_caption)
public void openSettingsDialog() {
ActivityUtils.get(this).hideSoftKeyboard();
_dialogView = View.inflate(this, R.layout.text_settings, null);
_dialogView = View.inflate(this, R.layout.ui__memecreate__text_settings, null);

initDialogViews(_dialogView);

Expand Down Expand Up @@ -544,24 +543,20 @@ public void onFloatingButtonClicked(View view) {

private void initDialogViews(View view) {
SeekBar textSize = view.findViewById(R.id.meme_dialog__seek_font_size);
FloatingActionButton textBackGroundColor = view.findViewById
(R.id.meme_dialog__color_picker_for_text);
FloatingActionButton textBorderColor = view.findViewById
(R.id.meme_dialog__color_picker_for_border);
View textBackGroundColor = view.findViewById(R.id.meme_dialog__color_picker_for_text);
View textBorderColor = view.findViewById(R.id.meme_dialog__color_picker_for_border);
Switch allCapsSwitch = view.findViewById(R.id.meme_dialog__toggle_all_caps);
Spinner fontDropDown = view.findViewById(R.id.meme_dialog__dropdown_font);

FontItemAdapter fontAdapter = new FontItemAdapter(this,
android.R.layout.simple_list_item_1, MemeData.getFonts(),
true, getString(R.string.creator__font));
false, getString(R.string.creator__font));
fontDropDown.setAdapter(fontAdapter);
fontAdapter.setSelectedFont(fontDropDown, _memeEditorElements.getCaptionTop().getFont());

textBackGroundColor.setBackgroundTintList(ColorStateList.valueOf
(_memeEditorElements.getCaptionTop().getTextColor()));
textBackGroundColor.setBackgroundColor(_memeEditorElements.getCaptionTop().getTextColor());
textBorderColor.setBackgroundColor(_memeEditorElements.getCaptionTop().getBorderColor());

textBorderColor.setBackgroundTintList(ColorStateList.valueOf
(_memeEditorElements.getCaptionTop().getBorderColor()));
allCapsSwitch.setChecked(_memeEditorElements.getCaptionTop().isAllCaps());
textSize.setProgress(_memeEditorElements.getCaptionTop().getFontSize() - MemeLibConfig.FONT_SIZES.MIN);

Expand Down Expand Up @@ -711,32 +706,36 @@ private void showColorDialog(int id, @ColorInt int color) {
@Override
public void onColorSelected(int id, @ColorInt int colorInt) {
switch (id) {
case R.id.meme_dialog__color_picker_for_border:// border color
case R.id.meme_dialog__color_picker_for_border: {// border color
if (_isBottom) {
_memeEditorElements.getCaptionBottom().setBorderColor(colorInt);
} else {
_memeEditorElements.getCaptionTop().setBorderColor(colorInt);
}
FloatingActionButton fab = _dialogView.findViewById(R.id.meme_dialog__color_picker_for_border);
fab.setBackgroundTintList(ColorStateList.valueOf(colorInt));
View view = _dialogView.findViewById(R.id.meme_dialog__color_picker_for_border);
view.setBackgroundColor(colorInt);
break;
case R.id.meme_dialog__color_picker_for_text:// text background color
}
case R.id.meme_dialog__color_picker_for_text: {// text background color
if (_isBottom) {
_memeEditorElements.getCaptionBottom().setTextColor(colorInt);
} else {
_memeEditorElements.getCaptionTop().setTextColor(colorInt);
}
FloatingActionButton textFab = _dialogView.findViewById(R.id.meme_dialog__color_picker_for_text);
textFab.setBackgroundTintList(ColorStateList.valueOf(colorInt));
View view = _dialogView.findViewById(R.id.meme_dialog__color_picker_for_text);
view.setBackgroundColor(colorInt);
break;
case R.id.memecreate__moar_controls__color_picker_for_padding: // padding color
}
case R.id.memecreate__moar_controls__color_picker_for_padding: { // padding color
_memeEditorElements.getImageMain().setPaddingColor(colorInt);
_memeEditorElements.getImageMain().setPaddingColor(colorInt);
_paddingColor.setColor(colorInt);
break;
default:
}
default: {
Log.i(TAG, "Wrong selection");
break;
}
}
onMemeEditorObjectChanged();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">

<LinearLayout
Expand All @@ -18,15 +18,15 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:text="Font" />
android:text="All Caps" />

<Spinner
android:id="@+id/meme_dialog__dropdown_font"
<Switch
android:id="@+id/meme_dialog__toggle_all_caps"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_weight="70"
android:spinnerMode="dropdown" />
android:checked="true" />
</LinearLayout>

<LinearLayout
Expand All @@ -40,16 +40,16 @@
style="@style/AppTheme.MemeCreatorCaptionText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:text="@string/creator__size" />
android:layout_weight="34"
android:text="@string/creator__font" />

<SeekBar
android:id="@+id/meme_dialog__seek_font_size"
<Spinner
android:id="@+id/meme_dialog__dropdown_font"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="70"
android:max="30"
android:progress="18" />
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_weight="66"
android:spinnerMode="dropdown" />
</LinearLayout>

<LinearLayout
Expand All @@ -64,17 +64,23 @@
style="@style/AppTheme.MemeCreatorCaptionText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="90"
android:layout_weight="40"
android:text="@string/creator__background" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/meme_dialog__color_picker_for_text"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_weight="10"
app:fabSize="mini"
app:elevation="5dp"/>
android:layout_height="match_parent"
android:layout_weight="60"
android:background="@color/black"
android:padding="2dp">

<View
android:id="@+id/meme_dialog__color_picker_for_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:background="@color/white" />

</LinearLayout>
</LinearLayout>

<LinearLayout
Expand All @@ -89,17 +95,23 @@
style="@style/AppTheme.MemeCreatorCaptionText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="90"
android:layout_weight="40"
android:text="@string/creator__border" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/meme_dialog__color_picker_for_border"
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_weight="10"
app:fabSize="mini"
app:elevation="5dp"/>
android:layout_height="match_parent"
android:layout_weight="60"
android:background="@color/black"
android:padding="2dp">

<View
android:id="@+id/meme_dialog__color_picker_for_border"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:background="@color/comic_red" />

</LinearLayout>
</LinearLayout>

<LinearLayout
Expand All @@ -114,14 +126,14 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:text="All Caps" />
android:text="@string/creator__size" />

<Switch
android:id="@+id/meme_dialog__toggle_all_caps"
<SeekBar
android:id="@+id/meme_dialog__seek_font_size"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_weight="70"
android:checked="true" />
android:max="30"
android:progress="18" />
</LinearLayout>
</LinearLayout>

0 comments on commit 1d442c5

Please sign in to comment.