Crop feature
This commit is contained in:
parent
c7847a3238
commit
2e9f0e4c33
|
@ -103,4 +103,5 @@ dependencies {
|
|||
implementation 'jp.wasabeef:glide-transformations:4.0.0'
|
||||
playstoreImplementation "io.github.kobakei:ratethisapp:$ratethisappLibraryVersion"
|
||||
implementation 'ja.burhanrashid52:photoeditor:0.3.3'
|
||||
implementation 'com.github.yalantis:ucrop:2.2.3'
|
||||
}
|
||||
|
|
|
@ -165,6 +165,11 @@
|
|||
android:label="@string/app_name"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
/>
|
||||
<activity
|
||||
android:name="com.yalantis.ucrop.UCropActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
||||
|
||||
<activity android:name="app.fedilab.android.activities.WebviewActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
|
|
|
@ -59,8 +59,13 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
|
||||
import com.yalantis.ucrop.UCrop;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import ja.burhanrashid52.photoeditor.OnPhotoEditorListener;
|
||||
import ja.burhanrashid52.photoeditor.SaveSettings;
|
||||
|
@ -74,7 +79,6 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
StickerBSFragment.StickerListener, EditingToolsAdapter.OnItemSelected, FilterListener {
|
||||
|
||||
|
||||
public static final String EXTRA_IMAGE_PATHS = "extra_image_paths";
|
||||
private static final int CAMERA_REQUEST = 52;
|
||||
private static final int PICK_REQUEST = 53;
|
||||
private PhotoEditor mPhotoEditor;
|
||||
|
@ -83,7 +87,6 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
private EmojiBSFragment mEmojiBSFragment;
|
||||
private StickerBSFragment mStickerBSFragment;
|
||||
private TextView mTxtCurrentTool;
|
||||
private Typeface mWonderFont;
|
||||
private RecyclerView mRvTools, mRvFilters;
|
||||
private EditingToolsAdapter mEditingToolsAdapter = new EditingToolsAdapter(this);
|
||||
private FilterViewAdapter mFilterViewAdapter = new FilterViewAdapter(this);
|
||||
|
@ -91,6 +94,7 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
private ConstraintSet mConstraintSet = new ConstraintSet();
|
||||
private boolean mIsFilterVisible;
|
||||
private Uri uri;
|
||||
private String tempname;
|
||||
private boolean exit;
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
|
@ -133,7 +137,7 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
|
||||
initViews();
|
||||
|
||||
mWonderFont = Typeface.createFromAsset(getAssets(), "beyond_wonderland.ttf");
|
||||
Typeface mWonderFont = Typeface.createFromAsset(getAssets(), "beyond_wonderland.ttf");
|
||||
|
||||
mPropertiesBSFragment = new PropertiesBSFragment();
|
||||
mEmojiBSFragment = new EmojiBSFragment();
|
||||
|
@ -157,7 +161,11 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
mPhotoEditor = new PhotoEditor.Builder(this, mPhotoEditorView)
|
||||
.setPinchTextScalable(true) // set flag to make text scalable when pinch
|
||||
.setDefaultEmojiTypeface(mEmojiTypeFace)
|
||||
.setDefaultTextTypeface(mWonderFont)
|
||||
.build(); // build photo editor sdk
|
||||
|
||||
|
||||
|
||||
mPhotoEditor.setOnPhotoEditorListener(this);
|
||||
|
||||
//Set Image Dynamically
|
||||
|
@ -323,6 +331,7 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
|
||||
if (resultCode == RESULT_OK) {
|
||||
switch (requestCode) {
|
||||
case CAMERA_REQUEST:
|
||||
|
@ -340,6 +349,20 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case UCrop.REQUEST_CROP:
|
||||
final Uri resultUri = UCrop.getOutput(data);
|
||||
if( resultUri != null) {
|
||||
mPhotoEditorView.getSource().setImageURI(resultUri);
|
||||
File fdelete = new File(uri.getPath());
|
||||
if (fdelete.exists()) {
|
||||
fdelete.delete();
|
||||
}
|
||||
uri = resultUri;
|
||||
String filename = System.currentTimeMillis()+"_"+Helper.getFileName(PhotoEditorActivity.this, uri);
|
||||
tempname = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date()) + filename;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -445,10 +468,18 @@ public class PhotoEditorActivity extends BaseActivity implements OnPhotoEditorL
|
|||
case STICKER:
|
||||
mStickerBSFragment.show(getSupportFragmentManager(), mStickerBSFragment.getTag());
|
||||
break;
|
||||
case CROP:
|
||||
String filename = System.currentTimeMillis()+"_"+Helper.getFileName(PhotoEditorActivity.this, uri);
|
||||
tempname = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date()) + filename;
|
||||
UCrop.of(uri, Uri.fromFile(new File(getCacheDir(),tempname)))
|
||||
.start(PhotoEditorActivity.this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void showFilter(boolean isVisible) {
|
||||
mIsFilterVisible = isVisible;
|
||||
mConstraintSet.clone(mRootView);
|
||||
|
|
|
@ -17,6 +17,8 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
|
||||
public class StickerBSFragment extends BottomSheetDialogFragment {
|
||||
|
@ -60,7 +62,7 @@ public class StickerBSFragment extends BottomSheetDialogFragment {
|
|||
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
|
||||
CoordinatorLayout.Behavior behavior = params.getBehavior();
|
||||
|
||||
if (behavior != null && behavior instanceof BottomSheetBehavior) {
|
||||
if (behavior instanceof BottomSheetBehavior) {
|
||||
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
|
||||
}
|
||||
((View) contentView.getParent()).setBackgroundColor(getResources().getColor(android.R.color.transparent));
|
||||
|
@ -82,14 +84,15 @@ public class StickerBSFragment extends BottomSheetDialogFragment {
|
|||
|
||||
int[] stickerList = new int[]{R.drawable.aa, R.drawable.bb};
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
public ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_sticker, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NotNull ViewHolder holder, int position) {
|
||||
holder.imgSticker.setImageResource(stickerList[position]);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ import android.view.inputmethod.InputMethodManager;
|
|||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
|
||||
/**
|
||||
|
@ -76,12 +78,12 @@ public class TextEditorDialogFragment extends DialogFragment {
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
public View onCreateView(@NotNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.add_text_dialog, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mAddTextEditText = view.findViewById(R.id.add_text_edit_text);
|
||||
mInputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
|
|
@ -30,6 +30,7 @@ public class EditingToolsAdapter extends RecyclerView.Adapter<EditingToolsAdapte
|
|||
mToolList.add(new ToolModel("Text", R.drawable.ic_text, ToolType.TEXT));
|
||||
// mToolList.add(new ToolModel("Eraser", R.drawable.ic_eraser, ToolType.ERASER));
|
||||
mToolList.add(new ToolModel("Filter", R.drawable.ic_photo_filter, ToolType.FILTER));
|
||||
mToolList.add(new ToolModel("Crop", R.drawable.ic_crop, ToolType.CROP));
|
||||
mToolList.add(new ToolModel("Emoji", R.drawable.ic_insert_emoticon_media, ToolType.EMOJI));
|
||||
//mToolList.add(new ToolModel("Sticker", R.drawable.ic_sticker, ToolType.STICKER));
|
||||
}
|
||||
|
|
|
@ -11,5 +11,6 @@ public enum ToolType {
|
|||
ERASER,
|
||||
FILTER,
|
||||
EMOJI,
|
||||
STICKER
|
||||
STICKER,
|
||||
CROP
|
||||
}
|
||||
|
|
|
@ -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="#606984"
|
||||
android:pathData="M17,15h2V7c0,-1.1 -0.9,-2 -2,-2H9v2h8v8zM7,17V1H5v4H1v2h4v10c0,1.1 0.9,2 2,2h10v4h2v-4h4v-2H7z"/>
|
||||
</vector>
|
|
@ -135,4 +135,14 @@
|
|||
<color name="yellow_color_picker">#FBE870</color>
|
||||
<color name="yellow_green_color_picker">#C5E17A</color>
|
||||
<color name="tool_bg">#151414</color>
|
||||
|
||||
|
||||
<color name="ucrop_color_toolbar">#000000</color>
|
||||
<color name="ucrop_color_statusbar" tools:ignore="MissingDefaultResource">#000000</color>
|
||||
<color name="ucrop_color_toolbar_widget">#f5f5f5</color>
|
||||
|
||||
<color name="ucrop_color_widget_active">#f5f5f5</color>
|
||||
<color name="ucrop_color_active_controls_color">#FFFFFF</color>
|
||||
<color name="ucrop_color_widget_rotate_mid_line">#000000</color>
|
||||
<color name="ucrop_color_widget_background">#000000</color>
|
||||
</resources>
|
||||
|
|
|
@ -976,6 +976,7 @@
|
|||
<string name="image_saved">Image Saved Successfully!</string>
|
||||
<string name="save_image_failed">Failed to save Image</string>
|
||||
<string name="opacity">Opacity</string>
|
||||
<string name="label_crop">Crop</string>
|
||||
<plurals name="number_of_vote">
|
||||
<item quantity="one">%d vote</item>
|
||||
<item quantity="other">%d votes</item>
|
||||
|
|
Loading…
Reference in New Issue