diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ead3a25..86e33d4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,16 +6,14 @@
-
+
+
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/com/luxlunaris/noadpadlight/ui/DoodleActivity.java b/app/src/main/java/com/luxlunaris/noadpadlight/ui/DoodleActivity.java
new file mode 100644
index 0000000..36c2b29
--- /dev/null
+++ b/app/src/main/java/com/luxlunaris/noadpadlight/ui/DoodleActivity.java
@@ -0,0 +1,63 @@
+package com.luxlunaris.noadpadlight.ui;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
+
+import android.content.Intent;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+
+import com.luxlunaris.noadpadlight.R;
+
+import java.io.File;
+
+public class DoodleActivity extends AppCompatActivity {
+
+
+ DoodleView doodleView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_doodle);
+
+ ConstraintLayout l = findViewById(R.id.doodle_activity_layout);
+
+ doodleView = new DoodleView(this);
+
+ l.addView(doodleView);
+
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+
+ //inflate the menu's layout xml
+ getMenuInflater().inflate(R.menu.doodle_activity_toolbar, menu);
+
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
+
+ switch (item.getItemId()){
+ case R.id.done_doodling:
+ File doodleFile = doodleView.getSnapshot();
+ Intent resultIntent = new Intent();
+ resultIntent.putExtra("DOODLE_FILE", doodleFile);
+ setResult(RESULT_OK, resultIntent);
+ finish();
+ break;
+
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/luxlunaris/noadpadlight/ui/DoodleView.java b/app/src/main/java/com/luxlunaris/noadpadlight/ui/DoodleView.java
new file mode 100644
index 0000000..ffc73d7
--- /dev/null
+++ b/app/src/main/java/com/luxlunaris/noadpadlight/ui/DoodleView.java
@@ -0,0 +1,112 @@
+package com.luxlunaris.noadpadlight.ui;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+public class DoodleView extends View {
+
+
+ Paint paint;
+
+ Path path;
+
+
+ public DoodleView(Context context) {
+ super(context);
+ paint = new Paint();
+ setColor(Color.BLACK);
+ setStrokeWidth(20);
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeCap(Paint.Cap.ROUND);
+ path =new Path();
+ }
+
+
+
+ public void setColor(int color){
+ paint.setColor(color);
+ }
+
+ public void setStrokeWidth(int width){
+ paint.setStrokeWidth(width);
+ }
+
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ setBackgroundColor(Color.WHITE);
+ canvas.drawPath(path, paint);
+ }
+
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+
+ float x = event.getX();
+ float y = event.getY();
+ Log.d("TOUCH_EVENT", "x: "+x+" y: "+y);
+
+
+ switch(event.getAction()){
+
+ case MotionEvent.ACTION_MOVE:
+ path.lineTo(x, y);
+ break;
+ case MotionEvent.ACTION_DOWN:
+ path.moveTo(x, y);
+ break;
+
+ }
+
+ //trigger onDraw
+ invalidate();
+
+ //very important
+ return true;
+ }
+
+
+ public File getSnapshot(){
+
+ File doodleFile = new File(getContext().getFilesDir(), "doodle.png");
+
+ try {
+ FileOutputStream fos = new FileOutputStream(doodleFile);
+ setDrawingCacheEnabled(true);///
+ Bitmap b = Bitmap.createBitmap( getDrawingCache());
+ setDrawingCacheEnabled(false);///
+
+ b.compress(Bitmap.CompressFormat.PNG, 100, fos);
+ fos.flush();
+ fos.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return doodleFile;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/app/src/main/java/com/luxlunaris/noadpadlight/ui/ReaderActivity.java b/app/src/main/java/com/luxlunaris/noadpadlight/ui/ReaderActivity.java
index 9bf5aac..a29821f 100644
--- a/app/src/main/java/com/luxlunaris/noadpadlight/ui/ReaderActivity.java
+++ b/app/src/main/java/com/luxlunaris/noadpadlight/ui/ReaderActivity.java
@@ -1,6 +1,11 @@
package com.luxlunaris.noadpadlight.ui;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
@@ -16,6 +21,7 @@
import com.luxlunaris.noadpadlight.control.classes.SETTINGS_TAGS;
import com.luxlunaris.noadpadlight.control.classes.Settings;
import com.luxlunaris.noadpadlight.model.interfaces.Page;
+import com.luxlunaris.noadpadlight.model.services.FileIO;
import java.io.File;
@@ -253,6 +259,13 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
String currentMode = HTML_EDIT_MODE? getString(R.string.editing_html_mode_ON) : getString(R.string.editing_html_mode_OFF);
Toast.makeText(this, currentMode, Toast.LENGTH_LONG).show();
break;
+ case R.id.make_doodle:
+
+ Intent intent = new Intent(this, DoodleActivity.class);
+ startActivityForResult(intent, 1);
+
+ break;
+
case R.id.make_bold:
applyTag("b");
break;
@@ -320,6 +333,34 @@ public void onFileObtained(File file) {
reloadText();
}
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ //halt if result code is not "ok"
+ if(resultCode != Activity.RESULT_OK){
+ return;
+ }
+
+ //halt if "data" is null
+ if(data==null){
+ return;
+ }
+
+ switch (requestCode){
+
+ case 1:
+ Uri uri = data.getData();
+ File doodleFile = (File)data.getSerializableExtra("DOODLE_FILE");
+ saveToPage();
+ page.addImage(doodleFile.getPath(), textView.getSelectionStart());
+ reloadText();
+ break;
+
+ }
+
+ }
+
/**
* Save progress if page isn't empty.
* Delete page if it's empty.
@@ -342,5 +383,4 @@ public void onBackPressed() {
finish();
}
-
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_doodle.xml b/app/src/main/res/layout/activity_doodle.xml
new file mode 100644
index 0000000..185aec7
--- /dev/null
+++ b/app/src/main/res/layout/activity_doodle.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/doodle_activity_toolbar.xml b/app/src/main/res/menu/doodle_activity_toolbar.xml
new file mode 100644
index 0000000..ccae51f
--- /dev/null
+++ b/app/src/main/res/menu/doodle_activity_toolbar.xml
@@ -0,0 +1,12 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/reader_activity_toolbar.xml b/app/src/main/res/menu/reader_activity_toolbar.xml
index 8019e54..121fc6e 100644
--- a/app/src/main/res/menu/reader_activity_toolbar.xml
+++ b/app/src/main/res/menu/reader_activity_toolbar.xml
@@ -28,6 +28,14 @@
app:showAsAction="always" />
+
+
+
+
-