Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flip (emoji only) #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class PhotoEditorActivity extends Activity implements ColorPickerDialogLi
private static final int MOVE = 0;
private static final int SCALE = 1;
private static final int ROLL = 2;
private static final int V_FLIP = 3;
private static final int H_FLIP = 4;
private int mode = NONE;

private static final int DIALOG_TEXT = 2000;
Expand All @@ -94,6 +96,8 @@ public class PhotoEditorActivity extends Activity implements ColorPickerDialogLi
private ImageButton moveButton;
private ImageButton scaleButton;
private ImageButton rollButton;
private ImageButton vFlipButton;
private ImageButton hFlipButton;

private EditText editText;
private TextWatcher textWatcher;
Expand Down Expand Up @@ -137,6 +141,8 @@ private void initialize()
moveButton = findViewById(R.id.photo_editor_move_button);
scaleButton = findViewById(R.id.photo_editor_scale_button);
rollButton = findViewById(R.id.photo_editor_roll_button);
vFlipButton = findViewById(R.id.photo_editor_v_flip_button);
hFlipButton = findViewById(R.id.photo_editor_h_flip_button);

textWatcher = new TextWatcher() {
@Override
Expand Down Expand Up @@ -453,6 +459,26 @@ public void setModeToRoll(View v)
setButtonBackGround();
}

/**
* Set mode - V_FLIP
* @param v button.
*/
public void setModeToVerticalFlip(View v)
{
mode = mode == V_FLIP ? NONE : V_FLIP;
setButtonBackGround();
}

/**
* Set mode - H_FLIP
* @param v button.
*/
public void setModeToHorizontalFlip(View v)
{
mode = mode == H_FLIP ? NONE : H_FLIP;
setButtonBackGround();
}

/**
* Set buttons background color.
*/
Expand All @@ -461,9 +487,13 @@ private void setButtonBackGround()
moveButton.setBackgroundColor(Color.TRANSPARENT);
scaleButton.setBackgroundColor(Color.TRANSPARENT);
rollButton.setBackgroundColor(Color.TRANSPARENT);
vFlipButton.setBackgroundColor(Color.TRANSPARENT);
hFlipButton.setBackgroundColor(Color.TRANSPARENT);
if (mode == MOVE) moveButton.setBackgroundColor(getResources().getColor(R.color.primary));
if (mode == SCALE) scaleButton.setBackgroundColor(getResources().getColor(R.color.primary));
if (mode == ROLL) rollButton.setBackgroundColor(getResources().getColor(R.color.primary));
if (mode == V_FLIP) vFlipButton.setBackgroundColor(getResources().getColor(R.color.primary));
if (mode == H_FLIP) hFlipButton.setBackgroundColor(getResources().getColor(R.color.primary));
}

/**
Expand Down Expand Up @@ -1016,6 +1046,22 @@ public boolean onTouchEvent(MotionEvent event)
setRotation(getRotation() + (roll * 0.1f));

break;

case V_FLIP:
if (newY - oldY < 0)
setScaleY(Math.abs(getScaleY()));
else
setScaleY(-Math.abs(getScaleY()));

break;

case H_FLIP:
if (newX - oldX < 0)
setScaleX(Math.abs(getScaleX()));
else
setScaleX(-Math.abs(getScaleX()));

break;
}

break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M10,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h5v2h2L12,1h-2v2zM10,18L5,18l5,-6v6zM19,3h-5v2h5v13l-5,-6v9h5c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2z"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<group android:name="rotationGroup"
android:pivotX="12"
android:pivotY="12"
android:rotation="270" >
<path
android:fillColor="#FF000000"
android:pathData="M10,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h5v2h2L12,1h-2v2zM10,18L5,18l5,-6v6zM19,3h-5v2h5v13l-5,-6v9h5c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2z"/>
</group>
</vector>
55 changes: 35 additions & 20 deletions EmojidexAndroid/src/main/res/layout/activity_photo_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,41 @@
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:src="@drawable/ic_help_black_24dp"
android:background="@drawable/button_state"
android:src="@drawable/ic_photo_filter_black_24dp"
android:background="@null"
android:contentDescription="@null"
android:onClick="showHelp" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
android:onClick="addEffect" />

<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:src="@drawable/ic_photo_filter_black_24dp"
android:background="@null"
android:src="@drawable/ic_clear_black_24dp"
android:background="@drawable/button_state"
android:contentDescription="@null"
android:onClick="addEffect" />
android:onClick="clearImage" />

<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />

<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:src="@drawable/ic_help_black_24dp"
android:background="@drawable/button_state"
android:contentDescription="@null"
android:onClick="showHelp" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
Expand Down Expand Up @@ -112,19 +121,25 @@
android:contentDescription="@null"
android:onClick="setModeToRoll" />

<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageButton
android:id="@+id/photo_editor_v_flip_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:src="@drawable/ic_compare_rotate_black_24dp"
android:background="@null"
android:contentDescription="@null"
android:onClick="setModeToVerticalFlip" />

<ImageButton
android:id="@+id/photo_editor_h_flip_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="5dp"
android:src="@drawable/ic_clear_black_24dp"
android:background="@drawable/button_state"
android:src="@drawable/ic_compare_black_24dp"
android:background="@null"
android:contentDescription="@null"
android:onClick="clearImage" />
android:onClick="setModeToHorizontalFlip" />

<EditText
android:id="@+id/photo_editor_text"
Expand Down
28 changes: 21 additions & 7 deletions EmojidexAndroid/src/main/res/layout/popup_photo_editor_help.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@
android:drawableLeft="@drawable/ic_save_black_24dp"
android:drawablePadding="10dp"
android:text="@string/photo_editor_help_save" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:drawableLeft="@drawable/ic_photo_filter_black_24dp"
android:drawablePadding="5dp"
android:text="@string/photo_editor_help_effect" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -76,6 +69,27 @@
android:drawableLeft="@drawable/ic_roll_black_24dp"
android:drawablePadding="10dp"
android:text="@string/photo_editor_help_roll" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:drawableLeft="@drawable/ic_compare_rotate_black_24dp"
android:drawablePadding="10dp"
android:text="@string/photo_editor_help_v_flip" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:drawableLeft="@drawable/ic_compare_black_24dp"
android:drawablePadding="10dp"
android:text="@string/photo_editor_help_h_flip" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:drawableLeft="@drawable/ic_photo_filter_black_24dp"
android:drawablePadding="5dp"
android:text="@string/photo_editor_help_effect" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down
2 changes: 2 additions & 0 deletions EmojidexAndroid/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
<string name="photo_editor_help_move">このボタンがアクティブの時、絵文字をドラッグで移動できます。</string>
<string name="photo_editor_help_scale">このボタンがアクティブの時、絵文字をドラッグで拡大縮小できます。</string>
<string name="photo_editor_help_roll">このボタンがアクティブの時、絵文字をドラッグで回転できます。</string>
<string name="photo_editor_help_v_flip">このボタンがアクティブの時、絵文字を上下ドラッグで上下に反転できます。</string>
<string name="photo_editor_help_h_flip">このボタンがアクティブの時、絵文字を左右ドラッグで左右に反転できます。</string>
<string name="photo_editor_help_clear">全ての絵文字をクリアします。</string>
<string name="photo_editor_help_close">閉じる</string>

Expand Down
2 changes: 2 additions & 0 deletions EmojidexAndroid/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@
<string name="photo_editor_help_move">This tool lets you move emoji by dragging them.</string>
<string name="photo_editor_help_scale">This tool lets you change the size of emoji.</string>
<string name="photo_editor_help_roll">This tool lets you rotate emoji.</string>
<string name="photo_editor_help_v_flip">This tool lets you flip vertical emoji.</string>
<string name="photo_editor_help_h_flip">This tool lets you flip horizontal emoji.</string>
<string name="photo_editor_help_clear">Clear all emoji.</string>
<string name="photo_editor_help_close">Close</string>

Expand Down