diff --git a/android/src/main/java/com/ahmedadeltito/photoeditor/ColorPickerAdapter.java b/android/src/main/java/com/ahmedadeltito/photoeditor/ColorPickerAdapter.java index c0bc4430..811c1c72 100755 --- a/android/src/main/java/com/ahmedadeltito/photoeditor/ColorPickerAdapter.java +++ b/android/src/main/java/com/ahmedadeltito/photoeditor/ColorPickerAdapter.java @@ -62,9 +62,9 @@ private void buildColorPickerView(View view, int colorCode) { smallerCircle.setIntrinsicHeight(5); smallerCircle.setIntrinsicWidth(5); smallerCircle.setBounds(new Rect(0, 0, 5, 5)); - smallerCircle.getPaint().setColor(Color.WHITE); + smallerCircle.getPaint().setColor(Color.BLACK); smallerCircle.setPadding(10, 10, 10, 10); - Drawable[] drawables = {smallerCircle, biggerCircle}; + Drawable[] drawables = { smallerCircle, biggerCircle }; LayerDrawable layerDrawable = new LayerDrawable(drawables); @@ -85,7 +85,8 @@ public ViewHolder(View itemView) { @Override public void onClick(View v) { if (onColorPickerClickListener != null) - onColorPickerClickListener.onColorPickerClickListener(colorPickerColors.get(getAdapterPosition())); + onColorPickerClickListener + .onColorPickerClickListener(colorPickerColors.get(getAdapterPosition())); } }); } diff --git a/android/src/main/java/com/ahmedadeltito/photoeditor/PhotoEditorActivity.java b/android/src/main/java/com/ahmedadeltito/photoeditor/PhotoEditorActivity.java index 9bf2eb71..a27ec1e2 100755 --- a/android/src/main/java/com/ahmedadeltito/photoeditor/PhotoEditorActivity.java +++ b/android/src/main/java/com/ahmedadeltito/photoeditor/PhotoEditorActivity.java @@ -99,7 +99,6 @@ public class PhotoEditorActivity extends AppCompatActivity implements View.OnCli private ImageView photoEditImageView; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -107,7 +106,7 @@ protected void onCreate(Bundle savedInstanceState) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); - selectedImagePath = getIntent().getExtras().getString("selectedImagePath"); + selectedImagePath = getIntent().getExtras().getString("selectedImagePath"); if (selectedImagePath.contains("content://")) { selectedImagePath = getPath(Uri.parse(selectedImagePath)); } @@ -129,7 +128,6 @@ protected void onCreate(Bundle savedInstanceState) { e.printStackTrace(); } - Typeface newFont = getFontFromRes(R.raw.eventtusicons); Typeface fontAwesome = getFontFromRes(R.raw.font_awesome_solid); @@ -201,8 +199,10 @@ protected void onCreate(Bundle savedInstanceState) { photoEditorSDK = new PhotoEditorSDK.PhotoEditorSDKBuilder(PhotoEditorActivity.this) .parentView(parentImageRelativeLayout) // add parent image view .childView(photoEditImageView) // add the desired image view - .deleteView(deleteRelativeLayout) // add the deleted view that will appear during the movement of the views - .brushDrawingView(brushDrawingView) // add the brush drawing view that is responsible for drawing on the image view + .deleteView(deleteRelativeLayout) // add the deleted view that will appear during the movement of the + // views + .brushDrawingView(brushDrawingView) // add the brush drawing view that is responsible for drawing on the + // image view .buildPhotoEditorSDK(); // build photo editor sdk photoEditorSDK.setOnPhotoEditorSDKListener(this); @@ -242,7 +242,8 @@ public void onPageScrollStateChanged(int state) { clearAllTextTextView.setOnClickListener(this); goToNextTextView.setOnClickListener(this); - ArrayList intentColors = (ArrayList) getIntent().getExtras().getSerializable("colorPickerColors"); + ArrayList intentColors = (ArrayList) getIntent().getExtras() + .getSerializable("colorPickerColors"); colorPickerColors = new ArrayList<>(); if (intentColors != null) { @@ -262,7 +263,6 @@ public void onPageScrollStateChanged(int state) { colorPickerColors.add(getResources().getColor(R.color.yellow_green_color_picker)); } - new CountDownTimer(500, 100) { public void onTick(long millisUntilFinished) { @@ -275,7 +275,7 @@ public void onFinish() { }.start(); ArrayList hiddenControls = (ArrayList) getIntent().getExtras().getSerializable("hiddenControls"); - for (int i = 0;i < hiddenControls.size();i++) { + for (int i = 0; i < hiddenControls.size(); i++) { if (hiddenControls.get(i).toString().equalsIgnoreCase("text")) { addTextView.setVisibility(View.INVISIBLE); } @@ -342,8 +342,10 @@ private void openAddTextPopupWindow(String text, int colorCode) { View addTextPopupWindowRootView = inflater.inflate(R.layout.add_text_popup_window, null); final EditText addTextEditText = (EditText) addTextPopupWindowRootView.findViewById(R.id.add_text_edit_text); TextView addTextDoneTextView = (TextView) addTextPopupWindowRootView.findViewById(R.id.add_text_done_tv); - RecyclerView addTextColorPickerRecyclerView = (RecyclerView) addTextPopupWindowRootView.findViewById(R.id.add_text_color_picker_recycler_view); - LinearLayoutManager layoutManager = new LinearLayoutManager(PhotoEditorActivity.this, LinearLayoutManager.HORIZONTAL, false); + RecyclerView addTextColorPickerRecyclerView = (RecyclerView) addTextPopupWindowRootView + .findViewById(R.id.add_text_color_picker_recycler_view); + LinearLayoutManager layoutManager = new LinearLayoutManager(PhotoEditorActivity.this, + LinearLayoutManager.HORIZONTAL, false); addTextColorPickerRecyclerView.setLayoutManager(layoutManager); addTextColorPickerRecyclerView.setHasFixedSize(true); ColorPickerAdapter colorPickerAdapter = new ColorPickerAdapter(PhotoEditorActivity.this, colorPickerColors); @@ -393,7 +395,8 @@ private void updateBrushDrawingView(boolean brushDrawingMode) { drawingViewColorPickerRecyclerView.setVisibility(View.VISIBLE); doneDrawingTextView.setVisibility(View.VISIBLE); eraseDrawingTextView.setVisibility(View.VISIBLE); - LinearLayoutManager layoutManager = new LinearLayoutManager(PhotoEditorActivity.this, LinearLayoutManager.HORIZONTAL, false); + LinearLayoutManager layoutManager = new LinearLayoutManager(PhotoEditorActivity.this, + LinearLayoutManager.HORIZONTAL, false); drawingViewColorPickerRecyclerView.setLayoutManager(layoutManager); drawingViewColorPickerRecyclerView.setHasFixedSize(true); ColorPickerAdapter colorPickerAdapter = new ColorPickerAdapter(PhotoEditorActivity.this, colorPickerColors); @@ -434,7 +437,9 @@ public void onFinish() { if (isSDCARDMounted()) { String folderName = "PhotoEditorSDK"; - File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), folderName); + File mediaStorageDir = new File( + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), + folderName); if (!mediaStorageDir.exists() && !mediaStorageDir.mkdirs()) { Log.d("PhotoEditorSDK", "Failed to create directory"); } @@ -459,7 +464,8 @@ public void onFinish() { try { ExifInterface exifDest = new ExifInterface(file.getAbsolutePath()); - exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, Integer.toString(imageOrientation)); + exifDest.setAttribute(ExifInterface.TAG_ORIENTATION, + Integer.toString(imageOrientation)); exifDest.saveAttributes(); } catch (IOException e) { e.printStackTrace(); @@ -479,7 +485,6 @@ public void onFinish() { } } - private void returnBackWithUpdateImage() { updateView(View.GONE); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( @@ -495,10 +500,10 @@ public void onFinish() { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageName = "/IMG_" + timeStamp + ".jpg"; - String selectedImagePath = getIntent().getExtras().getString("selectedImagePath"); - File file = new File(selectedImagePath); -// String newPath = getCacheDir() + imageName; -// File file = new File(newPath); + String selectedImagePath = getIntent().getExtras().getString("selectedImagePath"); + File file = new File(selectedImagePath); + // String newPath = getCacheDir() + imageName; + // File file = new File(newPath); try { FileOutputStream out = new FileOutputStream(file); @@ -543,21 +548,23 @@ public void showPermissionRequest() { @Override public void onClick(DialogInterface dialogInterface, int i) { ActivityCompat.requestPermissions(PhotoEditorActivity.this, - new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, + new String[] { android.Manifest.permission.WRITE_EXTERNAL_STORAGE }, MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_GALLERY); } }); builder.setNegativeButton(getString(R.string.not_now), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - Toast.makeText(PhotoEditorActivity.this, getString(R.string.media_access_denied_msg), Toast.LENGTH_SHORT).show(); + Toast.makeText(PhotoEditorActivity.this, getString(R.string.media_access_denied_msg), + Toast.LENGTH_SHORT).show(); } }); builder.show(); } @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, + @NonNull int[] grantResults) { if (requestCode == MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE_GALLERY) { // If request is cancelled, the result arrays are empty. int permissionCheck = PermissionChecker.checkCallingOrSelfPermission(this, @@ -579,7 +586,7 @@ public void onClick(View v) { onBackPressed(); } else if (v.getId() == R.id.add_image_emoji_tv) { mLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED); - } else if(v.getId() == R.id.add_crop_tv) { + } else if (v.getId() == R.id.add_crop_tv) { System.out.println("CROP IMAGE DUD"); startCropping(); } else if (v.getId() == R.id.add_text_tv) { @@ -608,10 +615,6 @@ public void onEditTextChangeListener(String text, int colorCode) { @Override public void onAddViewListener(ViewType viewType, int numberOfAddedViews) { - if (numberOfAddedViews > 0) { - undoTextView.setVisibility(View.VISIBLE); - undoTextTextView.setVisibility(View.VISIBLE); - } switch (viewType) { case BRUSH_DRAWING: Log.i("BRUSH_DRAWING", "onAddViewListener"); @@ -695,26 +698,23 @@ public int getCount() { } } - private Typeface getFontFromRes(int resource) - { + private Typeface getFontFromRes(int resource) { Typeface tf = null; InputStream is = null; try { is = getResources().openRawResource(resource); - } - catch(Resources.NotFoundException e) { + } catch (Resources.NotFoundException e) { Log.e(TAG, "Could not find font in resources!"); } String outPath = getCacheDir() + "/tmp" + System.currentTimeMillis() + ".raw"; - try - { + try { byte[] buffer = new byte[is.available()]; BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outPath)); int l = 0; - while((l = is.read(buffer)) > 0) + while ((l = is.read(buffer)) > 0) bos.write(buffer, 0, l); bos.close(); @@ -723,9 +723,7 @@ private Typeface getFontFromRes(int resource) // clean up new File(outPath).delete(); - } - catch (IOException e) - { + } catch (IOException e) { Log.e(TAG, "Error reading in font!"); return null; } @@ -748,10 +746,9 @@ private void startCropping() { options.setAllowedGestures( UCropActivity.ALL, // When 'scale'-tab active UCropActivity.ALL, // When 'rotate'-tab active - UCropActivity.ALL // When 'aspect ratio'-tab active + UCropActivity.ALL // When 'aspect ratio'-tab active ); - UCrop uCrop = UCrop .of(uri, Uri.fromFile(new File(this.getTmpDir(this), UUID.randomUUID().toString() + ".jpg"))) .withOptions(options); @@ -759,7 +756,6 @@ private void startCropping() { uCrop.start(this); } - private String getTmpDir(Activity activity) { String tmpDir = activity.getCacheDir() + "/react-native-photo-editor"; new File(tmpDir).mkdir(); @@ -775,7 +771,7 @@ public void onActivityResult(final int requestCode, final int resultCode, final if (resultUri != null) { try { selectedImagePath = resultUri.toString(); - Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver() , resultUri); + Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), resultUri); photoEditImageView.setImageBitmap(bitmap); } catch (Exception ex) { System.out.println("NO IMAGE DATA FOUND"); @@ -788,6 +784,7 @@ public void onActivityResult(final int requestCode, final int resultCode, final } } } + @TargetApi(Build.VERSION_CODES.KITKAT) protected String getPath(final Uri uri) { // DocumentProvider @@ -826,7 +823,7 @@ else if (GalleryUtils.isMediaDocument(uri)) { } final String selection = "_id=?"; - final String[] selectionArgs = new String[]{split[1]}; + final String[] selectionArgs = new String[] { split[1] }; return GalleryUtils.getDataColumn(this, contentUri, selection, selectionArgs); diff --git a/android/src/main/res/drawable/back_icon.xml b/android/src/main/res/drawable/back_icon.xml new file mode 100644 index 00000000..532cd4d6 --- /dev/null +++ b/android/src/main/res/drawable/back_icon.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/src/main/res/drawable/fading_shadow.xml b/android/src/main/res/drawable/fading_shadow.xml index 4453cdf0..c392200e 100644 --- a/android/src/main/res/drawable/fading_shadow.xml +++ b/android/src/main/res/drawable/fading_shadow.xml @@ -2,6 +2,6 @@ + android:endColor="#FFFFFF" + android:startColor="#FFFFFF" /> \ No newline at end of file diff --git a/android/src/main/res/drawable/pen_icon.xml b/android/src/main/res/drawable/pen_icon.xml new file mode 100644 index 00000000..e68adf22 --- /dev/null +++ b/android/src/main/res/drawable/pen_icon.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/src/main/res/drawable/submit_icon.xml b/android/src/main/res/drawable/submit_icon.xml new file mode 100644 index 00000000..570df715 --- /dev/null +++ b/android/src/main/res/drawable/submit_icon.xml @@ -0,0 +1,4 @@ + + + diff --git a/android/src/main/res/drawable/text_icon.xml b/android/src/main/res/drawable/text_icon.xml new file mode 100644 index 00000000..402a74b3 --- /dev/null +++ b/android/src/main/res/drawable/text_icon.xml @@ -0,0 +1,12 @@ + + + + diff --git a/android/src/main/res/layout/activity_photo_editor.xml b/android/src/main/res/layout/activity_photo_editor.xml index 3114aa2c..2e55c167 100644 --- a/android/src/main/res/layout/activity_photo_editor.xml +++ b/android/src/main/res/layout/activity_photo_editor.xml @@ -19,7 +19,7 @@ @@ -70,17 +69,16 @@ android:id="@+id/erase_drawing_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_alignParentStart="true" android:layout_marginEnd="20dp" android:layout_marginStart="20dp" - android:layout_marginTop="10dp" - android:layout_toStartOf="@+id/done_drawing_tv" android:padding="10dp" - android:shadowColor="#000000" + android:shadowColor="#FFFFFF" android:shadowDx="1" android:shadowDy="1" android:shadowRadius="2" android:text="@string/erase" - android:textColor="#FFFFFF" + android:textColor="#000000" android:textSize="20sp" android:visibility="gone" /> @@ -101,60 +99,90 @@ android:id="@+id/top_parent_rl" android:layout_width="match_parent" android:layout_height="wrap_content" + android:gravity="center_horizontal" android:layout_alignBottom="@+id/top_shadow" android:layout_alignTop="@+id/top_shadow" android:paddingLeft="5dp" android:paddingRight="5dp"> + android:textColor="#000000" + android:textSize="30sp" + android:visibility="gone" /> + android:drawableStart="@drawable/text_icon" + android:textColor="#000000" + android:textSize="25sp" /> + android:layout_toEndOf="@+id/add_text_tv" + android:layout_alignParentTop="true" + android:drawableStart="@drawable/pen_icon" + android:textSize="25sp" + android:padding="15dp" /> + android:layout_toEndOf="@+id/add_pencil_tv" + android:layout_alignParentTop="true" + android:textSize="0sp" /> + + + + + + + android:drawableStart="@drawable/submit_icon" /> @@ -164,7 +192,7 @@ android:layout_width="match_parent" android:layout_height="100dp" android:layout_alignParentBottom="true" - android:background="@drawable/below_shadow" /> + android:background="@drawable/fading_shadow" /> - + + + android:textSize="0sp" /> + - - + android:textSize="0sp" + android:visibility="gone" /> + + android:textSize="15sp" /> + - diff --git a/android/src/main/res/layout/add_text_popup_window.xml b/android/src/main/res/layout/add_text_popup_window.xml index b0747b22..858c3137 100644 --- a/android/src/main/res/layout/add_text_popup_window.xml +++ b/android/src/main/res/layout/add_text_popup_window.xml @@ -11,7 +11,8 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" - android:layout_margin="20dp" + android:layout_marginRight="20dp" + android:layout_marginTop="40dp" android:background="@drawable/rounded_border_text_view" android:padding="10dp" android:text="@string/done" @@ -22,6 +23,7 @@ PhotoEditor PhotoEditorActivity - Done - Save - Clear All + Zatwierdź + Zapisz + Zapisz + Wyczyść Camera Gallery Upload Image @@ -13,7 +14,7 @@ Continue NOT NOW You denied storage access, no photos will be added. - Image saved + Zapisano "\ue918" "\ue945" @@ -26,7 +27,7 @@ Choose From Gallery Choose From Camera - Undo - Erase + Cofnij + Gumka \ No newline at end of file