Skip to content

Commit e9bb26d

Browse files
author
Burhanuddin Rashid
committed
Save Image dialog
1 parent 67a30b3 commit e9bb26d

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A Photo Editor library with simple, easy support for image editing using paints,
2626
## Getting Started
2727
To start with this , you need to just simply add the dependencies in gradle file of app module like this
2828
```
29-
implementation 'ja.burhanrashid52:photoeditor:0.0.5'
29+
implementation 'ja.burhanrashid52:photoeditor:0.1.0'
3030
```
3131
or your can also import the :photoeditor module from sample for customization
3232

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ dependencies {
2323
implementation 'com.android.support:appcompat-v7:27.0.2'
2424
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
2525
implementation 'com.android.support:design:27.0.2'
26-
//implementation 'ja.burhanrashid52:photoeditor:0.0.5'
27-
implementation project(':photoeditor')
26+
implementation 'ja.burhanrashid52:photoeditor:0.1.0'
27+
//implementation project(':photoeditor')
2828
implementation 'com.android.support:cardview-v7:27.0.2'
2929
}
3030

app/src/main/java/com/burhanrashid52/imageeditor/EditImageActivity.java

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.Manifest;
44
import android.annotation.SuppressLint;
55
import android.content.Context;
6+
import android.content.DialogInterface;
67
import android.content.Intent;
78
import android.graphics.Bitmap;
89
import android.graphics.Typeface;
@@ -14,6 +15,7 @@
1415
import android.support.v4.content.ContextCompat;
1516
import android.support.v4.content.res.ResourcesCompat;
1617
import android.support.v4.provider.FontsContractCompat;
18+
import android.support.v7.app.AlertDialog;
1719
import android.util.Log;
1820
import android.view.View;
1921
import android.widget.ImageView;
@@ -94,7 +96,7 @@ protected void onCreate(Bundle savedInstanceState) {
9496
mPhotoEditor = new PhotoEditor.Builder(this, mPhotoEditorView)
9597
.setPinchTextScalable(true) // set flag to make text scalable when pinch
9698
.setDefaultTextTypeface(mTextRobotoTf)
97-
.setDefaultEmojiTypeface(mEmojiTypeFace)
99+
// .setDefaultEmojiTypeface(mEmojiTypeFace)
98100
.build(); // build photo editor sdk
99101

100102
mPhotoEditor.setOnPhotoEditorListener(this);
@@ -111,6 +113,7 @@ private void initViews() {
111113
ImageView imgSticker;
112114
ImageView imgEmo;
113115
ImageView imgSave;
116+
ImageView imgClose;
114117

115118
mPhotoEditorView = findViewById(R.id.photoEditorView);
116119
mTxtCurrentTool = findViewById(R.id.txtCurrentTool);
@@ -144,6 +147,9 @@ private void initViews() {
144147

145148
imgSave = findViewById(R.id.imgSave);
146149
imgSave.setOnClickListener(this);
150+
151+
imgClose = findViewById(R.id.imgClose);
152+
imgClose.setOnClickListener(this);
147153
}
148154

149155
@Override
@@ -184,6 +190,7 @@ public void onClick(View view) {
184190
switch (view.getId()) {
185191
case R.id.imgPencil:
186192
mPhotoEditor.setBrushDrawingMode(true);
193+
mTxtCurrentTool.setText(R.string.label_brush);
187194
mPropertiesBSFragment.show(getSupportFragmentManager(), mPropertiesBSFragment.getTag());
188195
break;
189196
case R.id.btnEraser:
@@ -213,6 +220,14 @@ public void onDone(String inputText, int colorCode) {
213220
saveImage();
214221
break;
215222

223+
case R.id.imgClose:
224+
if (!mPhotoEditor.isCacheEmpty()) {
225+
showSaveDialog();
226+
} else {
227+
finishAffinity();
228+
}
229+
break;
230+
216231
case R.id.imgSticker:
217232
mStickerBSFragment.show(getSupportFragmentManager(), mStickerBSFragment.getTag());
218233
break;
@@ -324,4 +339,30 @@ public void isPermissionGranted(boolean isGranted, String permission) {
324339
saveImage();
325340
}
326341
}
342+
343+
private void showSaveDialog() {
344+
AlertDialog.Builder builder = new AlertDialog.Builder(this);
345+
builder.setMessage("Are you want to exit without saving image ?");
346+
builder.setPositiveButton("Save", new DialogInterface.OnClickListener() {
347+
@Override
348+
public void onClick(DialogInterface dialog, int which) {
349+
saveImage();
350+
}
351+
});
352+
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
353+
@Override
354+
public void onClick(DialogInterface dialog, int which) {
355+
dialog.dismiss();
356+
}
357+
});
358+
359+
builder.setNeutralButton("Discard", new DialogInterface.OnClickListener() {
360+
@Override
361+
public void onClick(DialogInterface dialog, int which) {
362+
finishAffinity();
363+
}
364+
});
365+
builder.create().show();
366+
367+
}
327368
}

photoeditor/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ext {
1515
siteUrl = 'https://github.com/burhanrashid52/PhotoEditor'
1616
gitUrl = 'https://github.com/burhanrashid52/PhotoEditor/issues'
1717

18-
libraryVersion = '0.0.5'
18+
libraryVersion = '0.1.0'
1919

2020
developerId = 'burhanrashid52'
2121
developerName = 'Burhanuddin Rashid'

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
include ':app', ':photoeditor'
2+
//Linese

0 commit comments

Comments
 (0)