diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 988043d..edcc9b1 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,40 +1,42 @@
+
+ android:versionCode="9"
+ android:versionName="1.4" >
-
+
+
+ android:theme="@style/CustomActionBarTheme" >
+ android:configChanges="keyboard|keyboardHidden|orientation" >
diff --git a/README.md b/README.md
index 1fbf019..f121c38 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,38 @@
Acrylic Paint
=============
Acrylic Paint is a coloring app for Android which helps you to share your imagination.
Made some changes from FingerPaint project taken from API demos.
Credits
-------
* [Anupam Shrivastava](https://github.com/anupam1525) - Original author (disappeared)
* [Valerio Bozzolan](https://github.com/valerio-bozzolan) - Revival of the project
-* Marco Gagino - Icons and support
+* [Marco Gagino](https://github.com/marcogagino-22) - Icons, graphics and support
And thanks to all the contributors!
Licenses
--------
* [Androidâ„¢ API demos](http://developer.android.com/samples/index.html) - Originally released under the Apache 2.0 license
* [Acrylic Paint anupam1525](https://github.com/anupam1525/AcrylicPaint) - Originally released under the Apache 2.0 license
* [Acrylic Paint valerio-bozzolan](https://github.com/valerio-bozzolan/AcrylicPaint) - Upgraded to the GNU General Public License
Every line of this app it's "upgraded" from the Apache 2.0 license to the **GPLv3+ license**! Read more about "license upgrading" [here](https://www.gnu.org/licenses/quick-guide-gplv3.html#new-compatible-licenses)". (If I have done some errors during the license upgrade process, please tell me about how to upgrade the license of this app in the bug report...)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Disclaimer
----------
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
diff --git a/res/drawable-hdpi/about.png b/res/drawable-hdpi/about.png
index fa3059c..f92af44 100644
Binary files a/res/drawable-hdpi/about.png and b/res/drawable-hdpi/about.png differ
diff --git a/res/drawable-hdpi/blur.png b/res/drawable-hdpi/blur.png
index 101a17a..3f6ae20 100644
Binary files a/res/drawable-hdpi/blur.png and b/res/drawable-hdpi/blur.png differ
diff --git a/res/drawable-hdpi/clear_all.png b/res/drawable-hdpi/clear_all.png
index 9d759b5..2b525fb 100644
Binary files a/res/drawable-hdpi/clear_all.png and b/res/drawable-hdpi/clear_all.png differ
diff --git a/res/drawable-hdpi/color.png b/res/drawable-hdpi/color.png
index 9ecbb76..0b4203d 100644
Binary files a/res/drawable-hdpi/color.png and b/res/drawable-hdpi/color.png differ
diff --git a/res/drawable-hdpi/emboss.png b/res/drawable-hdpi/emboss.png
index bd6b919..81d3eca 100644
Binary files a/res/drawable-hdpi/emboss.png and b/res/drawable-hdpi/emboss.png differ
diff --git a/res/drawable-hdpi/erase.png b/res/drawable-hdpi/erase.png
index 28fa797..277b040 100644
Binary files a/res/drawable-hdpi/erase.png and b/res/drawable-hdpi/erase.png differ
diff --git a/res/drawable-hdpi/save.png b/res/drawable-hdpi/save.png
index a208aaa..30d0dd2 100644
Binary files a/res/drawable-hdpi/save.png and b/res/drawable-hdpi/save.png differ
diff --git a/res/drawable-hdpi/share.png b/res/drawable-hdpi/share.png
index f83ecba..d4782a5 100644
Binary files a/res/drawable-hdpi/share.png and b/res/drawable-hdpi/share.png differ
diff --git a/res/drawable-hdpi/size.png b/res/drawable-hdpi/size.png
index 8e06511..ea423a1 100644
Binary files a/res/drawable-hdpi/size.png and b/res/drawable-hdpi/size.png differ
diff --git a/res/drawable-mdpi/about.png b/res/drawable-mdpi/about.png
new file mode 100644
index 0000000..4174936
Binary files /dev/null and b/res/drawable-mdpi/about.png differ
diff --git a/res/drawable-mdpi/blur.png b/res/drawable-mdpi/blur.png
new file mode 100644
index 0000000..ff288ae
Binary files /dev/null and b/res/drawable-mdpi/blur.png differ
diff --git a/res/drawable-mdpi/clear_all.png b/res/drawable-mdpi/clear_all.png
new file mode 100644
index 0000000..8921447
Binary files /dev/null and b/res/drawable-mdpi/clear_all.png differ
diff --git a/res/drawable-mdpi/color.png b/res/drawable-mdpi/color.png
new file mode 100644
index 0000000..dc48dc9
Binary files /dev/null and b/res/drawable-mdpi/color.png differ
diff --git a/res/drawable-mdpi/emboss.png b/res/drawable-mdpi/emboss.png
new file mode 100644
index 0000000..641a4e5
Binary files /dev/null and b/res/drawable-mdpi/emboss.png differ
diff --git a/res/drawable-mdpi/erase.png b/res/drawable-mdpi/erase.png
new file mode 100644
index 0000000..24d221d
Binary files /dev/null and b/res/drawable-mdpi/erase.png differ
diff --git a/res/drawable-mdpi/save.png b/res/drawable-mdpi/save.png
new file mode 100644
index 0000000..e4c5adc
Binary files /dev/null and b/res/drawable-mdpi/save.png differ
diff --git a/res/drawable-mdpi/share.png b/res/drawable-mdpi/share.png
new file mode 100644
index 0000000..2e98e51
Binary files /dev/null and b/res/drawable-mdpi/share.png differ
diff --git a/res/drawable-mdpi/size.png b/res/drawable-mdpi/size.png
new file mode 100644
index 0000000..d9921b9
Binary files /dev/null and b/res/drawable-mdpi/size.png differ
diff --git a/res/drawable-xhdpi/about.png b/res/drawable-xhdpi/about.png
new file mode 100644
index 0000000..82f68cd
Binary files /dev/null and b/res/drawable-xhdpi/about.png differ
diff --git a/res/drawable-xhdpi/blur.png b/res/drawable-xhdpi/blur.png
new file mode 100644
index 0000000..2a84a1a
Binary files /dev/null and b/res/drawable-xhdpi/blur.png differ
diff --git a/res/drawable-xhdpi/clear_all.png b/res/drawable-xhdpi/clear_all.png
new file mode 100644
index 0000000..8927f9a
Binary files /dev/null and b/res/drawable-xhdpi/clear_all.png differ
diff --git a/res/drawable-xhdpi/color.png b/res/drawable-xhdpi/color.png
new file mode 100644
index 0000000..16f2deb
Binary files /dev/null and b/res/drawable-xhdpi/color.png differ
diff --git a/res/drawable-xhdpi/emboss.png b/res/drawable-xhdpi/emboss.png
new file mode 100644
index 0000000..e01c5ce
Binary files /dev/null and b/res/drawable-xhdpi/emboss.png differ
diff --git a/res/drawable-xhdpi/erase.png b/res/drawable-xhdpi/erase.png
new file mode 100644
index 0000000..3ae2b80
Binary files /dev/null and b/res/drawable-xhdpi/erase.png differ
diff --git a/res/drawable-xhdpi/save.png b/res/drawable-xhdpi/save.png
new file mode 100644
index 0000000..8ed5ac9
Binary files /dev/null and b/res/drawable-xhdpi/save.png differ
diff --git a/res/drawable-xhdpi/share.png b/res/drawable-xhdpi/share.png
new file mode 100644
index 0000000..1b784b0
Binary files /dev/null and b/res/drawable-xhdpi/share.png differ
diff --git a/res/drawable-xhdpi/size.png b/res/drawable-xhdpi/size.png
new file mode 100644
index 0000000..b82770b
Binary files /dev/null and b/res/drawable-xhdpi/size.png differ
diff --git a/res/drawable-xxhdpi/about.png b/res/drawable-xxhdpi/about.png
new file mode 100644
index 0000000..b90961a
Binary files /dev/null and b/res/drawable-xxhdpi/about.png differ
diff --git a/res/drawable-xxhdpi/blur.png b/res/drawable-xxhdpi/blur.png
new file mode 100644
index 0000000..f9902fc
Binary files /dev/null and b/res/drawable-xxhdpi/blur.png differ
diff --git a/res/drawable-xxhdpi/clear_all.png b/res/drawable-xxhdpi/clear_all.png
new file mode 100644
index 0000000..9c056c2
Binary files /dev/null and b/res/drawable-xxhdpi/clear_all.png differ
diff --git a/res/drawable-xxhdpi/color.png b/res/drawable-xxhdpi/color.png
new file mode 100644
index 0000000..6e0fbd4
Binary files /dev/null and b/res/drawable-xxhdpi/color.png differ
diff --git a/res/drawable-xxhdpi/emboss.png b/res/drawable-xxhdpi/emboss.png
new file mode 100644
index 0000000..eca88e9
Binary files /dev/null and b/res/drawable-xxhdpi/emboss.png differ
diff --git a/res/drawable-xxhdpi/erase.png b/res/drawable-xxhdpi/erase.png
new file mode 100644
index 0000000..d3ecefd
Binary files /dev/null and b/res/drawable-xxhdpi/erase.png differ
diff --git a/res/drawable-xxhdpi/save.png b/res/drawable-xxhdpi/save.png
new file mode 100644
index 0000000..5ff06a3
Binary files /dev/null and b/res/drawable-xxhdpi/save.png differ
diff --git a/res/drawable-xxhdpi/share.png b/res/drawable-xxhdpi/share.png
new file mode 100644
index 0000000..395ac79
Binary files /dev/null and b/res/drawable-xxhdpi/share.png differ
diff --git a/res/drawable-xxhdpi/size.png b/res/drawable-xxhdpi/size.png
new file mode 100644
index 0000000..bd3b6eb
Binary files /dev/null and b/res/drawable-xxhdpi/size.png differ
diff --git a/res/drawable-xxxhdpi/about.png b/res/drawable-xxxhdpi/about.png
new file mode 100644
index 0000000..e7d5690
Binary files /dev/null and b/res/drawable-xxxhdpi/about.png differ
diff --git a/res/drawable-xxxhdpi/actionbar_background.png b/res/drawable-xxxhdpi/actionbar_background.png
new file mode 100644
index 0000000..7de242e
Binary files /dev/null and b/res/drawable-xxxhdpi/actionbar_background.png differ
diff --git a/res/drawable-xxxhdpi/blur.png b/res/drawable-xxxhdpi/blur.png
new file mode 100644
index 0000000..968fb00
Binary files /dev/null and b/res/drawable-xxxhdpi/blur.png differ
diff --git a/res/drawable-xxxhdpi/clear_all.png b/res/drawable-xxxhdpi/clear_all.png
new file mode 100644
index 0000000..72dbd22
Binary files /dev/null and b/res/drawable-xxxhdpi/clear_all.png differ
diff --git a/res/drawable-xxxhdpi/color.png b/res/drawable-xxxhdpi/color.png
new file mode 100644
index 0000000..5f0728d
Binary files /dev/null and b/res/drawable-xxxhdpi/color.png differ
diff --git a/res/drawable-xxxhdpi/emboss.png b/res/drawable-xxxhdpi/emboss.png
new file mode 100644
index 0000000..1b6a82e
Binary files /dev/null and b/res/drawable-xxxhdpi/emboss.png differ
diff --git a/res/drawable-xxxhdpi/erase.png b/res/drawable-xxxhdpi/erase.png
new file mode 100644
index 0000000..878d319
Binary files /dev/null and b/res/drawable-xxxhdpi/erase.png differ
diff --git a/res/drawable-xxxhdpi/save.png b/res/drawable-xxxhdpi/save.png
new file mode 100644
index 0000000..c18fe09
Binary files /dev/null and b/res/drawable-xxxhdpi/save.png differ
diff --git a/res/drawable-xxxhdpi/share.png b/res/drawable-xxxhdpi/share.png
new file mode 100644
index 0000000..0f6d7f6
Binary files /dev/null and b/res/drawable-xxxhdpi/share.png differ
diff --git a/res/drawable-xxxhdpi/size.png b/res/drawable-xxxhdpi/size.png
new file mode 100644
index 0000000..aad755e
Binary files /dev/null and b/res/drawable-xxxhdpi/size.png differ
diff --git a/res/layout-large/brush.xml b/res/layout-large/brush.xml
index bb95989..759bcb0 100644
--- a/res/layout-large/brush.xml
+++ b/res/layout-large/brush.xml
@@ -1,47 +1,47 @@
\ No newline at end of file
diff --git a/res/layout-large/brush.xml b/res/layout-large/eraser.xml
similarity index 94%
copy from res/layout-large/brush.xml
copy to res/layout-large/eraser.xml
index bb95989..2ec5bd8 100644
--- a/res/layout-large/brush.xml
+++ b/res/layout-large/eraser.xml
@@ -1,47 +1,47 @@
\ No newline at end of file
diff --git a/res/layout-large/brush.xml b/res/layout/eraser.xml
similarity index 94%
copy from res/layout-large/brush.xml
copy to res/layout/eraser.xml
index bb95989..2ec5bd8 100644
--- a/res/layout-large/brush.xml
+++ b/res/layout/eraser.xml
@@ -1,47 +1,47 @@
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 925dcf6..76e47e0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,34 +1,34 @@
Acrylic PaintAcrylic Paint is a coloring tool which helps you to make anything of your imagination.\nPick the color you want and start painting.\n\nPress menu for more options!\n\nHappy painting :)\n\nThis software is released under the terms of the GNU General Public License Version 3+.\nThanks to Anupam Shrivastava for the idea, and to Valerio Bozzolan for reviving the project. Thanks to all the contributors!Here is your canvas. Start to paint!ColorBoldBlurBrush sizeEraseErase allSaveShareAboutDefault brush size is: %1$sYour selected brush size is: %1$sPlease select at least "1" as brush size.Choose your Brush widthSaved your artwork to %1$sSelectContinueOKPick a ColorShareLook at what I painted with Acrylic Paint! --- Acrylic Paint (Simple finger painting) - https://f-droid.org/app/anupam.acrylicShare as textCan\'t locate an app to share with…PencilYour selected eraser size is: %1$s
- Default erase size is: %1$s
+ Default eraser size is: %1$sPlease select at least "1" as eraser size.Choose your Eraser width
\ No newline at end of file
diff --git a/res/values/theme.xml b/res/values/theme.xml
new file mode 100644
index 0000000..a29ea9f
--- /dev/null
+++ b/res/values/theme.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/anupam/acrylic/ColorPickerDialog.java b/src/anupam/acrylic/ColorPickerDialog.java
index c4ea671..39c676f 100644
--- a/src/anupam/acrylic/ColorPickerDialog.java
+++ b/src/anupam/acrylic/ColorPickerDialog.java
@@ -1,240 +1,240 @@
/*
* Copyright (C) 2014 Valerio Bozzolan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package anupam.acrylic;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
public class ColorPickerDialog extends Dialog {
private OnColorChangedListener mListener;
private int mInitialColor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OnColorChangedListener l = new OnColorChangedListener() {
public void colorChanged(int color) {
mListener.colorChanged(color);
dismiss();
}
};
setContentView(new ColorPickerView(getContext(), l, mInitialColor));
setTitle(R.string.pick_color);
}
public interface OnColorChangedListener {
void colorChanged(int color);
}
private static class ColorPickerView extends View {
- private static final int CENTER_X = 150;
- private static final int CENTER_Y = 150;
- private static final int CENTER_RADIUS = 60;
+ private static final int CENTER_X = 200;
+ private static final int CENTER_Y = 200;
+ private static final int CENTER_RADIUS = 100;
private Paint mPaint;
private Paint mCenterPaint;
private final int[] mColors;
private OnColorChangedListener mListener;
private boolean mTrackingCenter;
private boolean mHighlightCenter;
ColorPickerView(Context c, OnColorChangedListener l, int color) {
super(c);
mListener = l;
mColors = new int[] {
0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
0xFFFFFF00, 0xFFFF0000
};
Shader s = new SweepGradient(0, 0, mColors, null);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setShader(s);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(32);
mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCenterPaint.setColor(color);
- mCenterPaint.setStrokeWidth(5);
+ mCenterPaint.setStrokeWidth(10);
}
@Override
protected void onDraw(Canvas canvas) {
float r = CENTER_X - mPaint.getStrokeWidth()*0.5f;
canvas.translate(CENTER_X, CENTER_X);
canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);
if (mTrackingCenter) {
int c = mCenterPaint.getColor();
mCenterPaint.setStyle(Paint.Style.STROKE);
if (mHighlightCenter) {
mCenterPaint.setAlpha(0xFF);
} else {
mCenterPaint.setAlpha(0x80);
}
canvas.drawCircle(0, 0,
CENTER_RADIUS + mCenterPaint.getStrokeWidth(),
mCenterPaint);
mCenterPaint.setStyle(Paint.Style.FILL);
mCenterPaint.setColor(c);
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(CENTER_X*2, CENTER_Y*2);
}
private int floatToByte(float x) {
int n = java.lang.Math.round(x);
return n;
}
private int pinToByte(int n) {
if (n < 0) {
n = 0;
} else if (n > 255) {
n = 255;
}
return n;
}
private int ave(int s, int d, float p) {
return s + java.lang.Math.round(p * (d - s));
}
private int interpColor(int colors[], float unit) {
if (unit <= 0) {
return colors[0];
}
if (unit >= 1) {
return colors[colors.length - 1];
}
float p = unit * (colors.length - 1);
int i = (int)p;
p -= i;
// now p is just the fractional part [0...1) and i is the index
int c0 = colors[i];
int c1 = colors[i+1];
int a = ave(Color.alpha(c0), Color.alpha(c1), p);
int r = ave(Color.red(c0), Color.red(c1), p);
int g = ave(Color.green(c0), Color.green(c1), p);
int b = ave(Color.blue(c0), Color.blue(c1), p);
return Color.argb(a, r, g, b);
}
@SuppressWarnings("unused")
private int rotateColor(int color, float rad) {
float deg = rad * 180 / 3.1415927f;
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
ColorMatrix cm = new ColorMatrix();
ColorMatrix tmp = new ColorMatrix();
cm.setRGB2YUV();
tmp.setRotate(0, deg);
cm.postConcat(tmp);
tmp.setYUV2RGB();
cm.postConcat(tmp);
final float[] a = cm.getArray();
int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b);
int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b);
int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);
return Color.argb(Color.alpha(color), pinToByte(ir),
pinToByte(ig), pinToByte(ib));
}
private static final float PI = 3.1415926f;
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX() - CENTER_X;
float y = event.getY() - CENTER_Y;
boolean inCenter = java.lang.Math.sqrt(x*x + y*y) <= CENTER_RADIUS;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mTrackingCenter = inCenter;
if (inCenter) {
mHighlightCenter = true;
invalidate();
break;
}
case MotionEvent.ACTION_MOVE:
if (mTrackingCenter) {
if (mHighlightCenter != inCenter) {
mHighlightCenter = inCenter;
invalidate();
}
} else {
float angle = (float)java.lang.Math.atan2(y, x);
// need to turn angle [-PI ... PI] into unit [0....1]
float unit = angle/(2*PI);
if (unit < 0) {
unit += 1;
}
mCenterPaint.setColor(interpColor(mColors, unit));
invalidate();
}
break;
case MotionEvent.ACTION_UP:
if (mTrackingCenter) {
if (inCenter) {
mListener.colorChanged(mCenterPaint.getColor());
}
mTrackingCenter = false; // so we draw w/o halo
invalidate();
}
break;
}
return true;
}
}
public ColorPickerDialog(Context context,
OnColorChangedListener listener,
int initialColor) {
super(context);
mListener = listener;
mInitialColor = initialColor;
}
}
diff --git a/src/anupam/acrylic/EasyPaint.java b/src/anupam/acrylic/EasyPaint.java
index 191aee2..1e64a9a 100644
--- a/src/anupam/acrylic/EasyPaint.java
+++ b/src/anupam/acrylic/EasyPaint.java
@@ -1,516 +1,525 @@
/*
* Copyright (C) 2014 Valerio Bozzolan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package anupam.acrylic;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
-
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.EmbossMaskFilter;
import android.graphics.MaskFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.view.WindowManager;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
public class EasyPaint extends GraphicsActivity implements
ColorPickerDialog.OnColorChangedListener {
private Paint mPaint;
private MaskFilter mEmboss;
private MaskFilter mBlur;
+
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ //it removes the title from the actionbar(more space for icons?)
+ //this.getActionBar().setDisplayShowTitleEnabled(false);
+
+ this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
+
+ //this.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
+ //it removes the navigation bar, but you can't paint without it and once it is shown again, it doesn't hide again
+
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
setContentView(new MyView(this));
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setDither(true);
- mPaint.setColor(0xFFF00000);
+ mPaint.setColor(Color.GREEN);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND);
mPaint.setStrokeCap(Paint.Cap.ROUND);
- mPaint.setStrokeWidth(5);
+ mPaint.setStrokeWidth(10);
mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 }, 0.4f, 6, 3.5f);
mBlur = new BlurMaskFilter(5, BlurMaskFilter.Blur.NORMAL);
if (isFirstTime()) {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle(R.string.app_name + " - " + R.string.about);
+ alert.setTitle(R.string.app_name);
alert.setMessage(R.string.app_description);
alert.setNegativeButton(R.string.continue_fuck,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
Toast.makeText(getApplicationContext(),
R.string.here_is_your_canvas,
Toast.LENGTH_SHORT).show();
}
});
alert.show();
}
if (isSecondTime()) {
Toast.makeText(getApplicationContext(),
R.string.here_is_your_canvas, Toast.LENGTH_SHORT).show();
}
}
public void colorChanged(int color) {
mPaint.setColor(color);
}
public class MyView extends View {
private Bitmap mBitmap;
private Canvas mCanvas;
private Path mPath;
private Paint mBitmapPaint;
public MyView(Context c) {
super(c);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
mBitmap = Bitmap.createBitmap(width, height,
Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap);
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFFFFFFF);
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
canvas.drawPath(mPath, mPaint);
}
private float mX, mY;
private static final float TOUCH_TOLERANCE = 4;
private void touch_start(float x, float y) {
mPath.reset();
mPath.moveTo(x, y);
mX = x;
mY = y;
}
private void touch_move(float x, float y) {
float dx = Math.abs(x - mX);
float dy = Math.abs(y - mY);
if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2);
mX = x;
mY = y;
}
}
private void touch_up() {
mPath.lineTo(mX, mY);
// commit the path to our offscreen
mCanvas.drawPath(mPath, mPaint);
// kill this so we don't double draw
mPath.reset();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
touch_start(x, y);
invalidate();
break;
case MotionEvent.ACTION_MOVE:
touch_move(x, y);
invalidate();
break;
case MotionEvent.ACTION_UP:
touch_up();
invalidate();
break;
}
return true;
}
}
private static final int COLOR_MENU_ID = Menu.FIRST;
private static final int SIZE_MENU_ID = Menu.FIRST + 1;
private static final int ERASE_MENU_ID = Menu.FIRST + 2;
private static final int CLEAR_ALL = Menu.FIRST + 3;
private static final int NORMAL_BRUSH = Menu.FIRST + 4;
private static final int EMBOSS_MENU_ID = Menu.FIRST + 5;
private static final int BLUR_MENU_ID = Menu.FIRST + 6;
private static final int SAVE = Menu.FIRST + 7;
private static final int SHARE = Menu.FIRST + 8;
private static final int ABOUT = Menu.FIRST + 9;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, COLOR_MENU_ID, 0, R.string.color).setIcon(R.drawable.color).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- menu.add(0, SIZE_MENU_ID, 0, R.string.brush_size).setIcon(
- R.drawable.size);
- menu.add(0, ERASE_MENU_ID, 0, R.string.erase).setIcon(R.drawable.erase);
- menu.add(0, CLEAR_ALL, 0, R.string.clear_all);
- menu.add(0, NORMAL_BRUSH, 0, R.string.normal).setIcon(
- R.drawable.size);
- menu.add(0, EMBOSS_MENU_ID, 0, R.string.emboss).setIcon(
- R.drawable.emboss);
- menu.add(0, BLUR_MENU_ID, 0, R.string.blur).setIcon(R.drawable.blur);
- menu.add(0, SAVE, 0, R.string.save);
+ menu.add(0, SIZE_MENU_ID, 0, R.string.brush_size).setIcon(R.drawable.size).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, ERASE_MENU_ID, 0, R.string.erase).setIcon(R.drawable.erase).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, CLEAR_ALL, 0, R.string.clear_all).setIcon(R.drawable.clear_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, NORMAL_BRUSH, 0, R.string.normal).setIcon(R.drawable.size).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, EMBOSS_MENU_ID, 0, R.string.emboss).setIcon(R.drawable.emboss).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, BLUR_MENU_ID, 0, R.string.blur).setIcon(R.drawable.blur).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, SAVE, 0, R.string.save).setIcon(R.drawable.save).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
menu.add(0, SHARE, 0, R.string.share).setIcon(R.drawable.share).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- menu.add(0, ABOUT, 0, R.string.about);
+ menu.add(0, ABOUT, 0, R.string.about).setIcon(R.drawable.about).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
/****
* Is this the mechanism to extend with filter effects? Intent intent =
* new Intent(null, getIntent().getData());
* intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
* menu.addIntentOptions( Menu.ALTERNATIVE, 0, new ComponentName(this,
* NotesList.class), null, intent, 0, null);
*****/
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
mPaint.setXfermode(null);
mPaint.setAlpha(0xFF);
switch (item.getItemId()) {
case NORMAL_BRUSH:
mPaint.setMaskFilter(null);
return true;
case COLOR_MENU_ID:
new ColorPickerDialog(this, this, mPaint.getColor()).show();
return true;
case EMBOSS_MENU_ID:
mPaint.setMaskFilter(mEmboss);
return true;
case BLUR_MENU_ID:
mPaint.setMaskFilter(mBlur);
return true;
case SIZE_MENU_ID:
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.brush,
(ViewGroup) findViewById(R.id.root));
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setView(layout);
final AlertDialog alertDialog = builder.create();
alertDialog.show();
SeekBar sb = (SeekBar) layout.findViewById(R.id.seekBar1);
- sb.setProgress(5);
+ sb.setProgress(10);
final Button done = (Button) layout.findViewById(R.id.select_size);
final TextView txt = (TextView) layout
.findViewById(R.id.size_value);
txt.setText(String
.format(getResources().getString(
- R.string.default_brush_size_is), 5));
+ R.string.default_brush_size_is), 10));
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar,
final int progress, boolean fromUser) {
// Do something here with new value
txt.setText(String.format(getResources().getString(R.string.your_selected_brush_size_is), progress));
mPaint.setStrokeWidth(progress);
done.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (progress == 0) {
Toast.makeText(
getApplicationContext(),
R.string.error_brush_size,
Toast.LENGTH_SHORT).show();
} else {
alertDialog.dismiss();
}
}
});
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
});
return true;
case ERASE_MENU_ID:
LayoutInflater inflater_e = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View layout_e = inflater_e.inflate(R.layout.brush,
+ View layout_e = inflater_e.inflate(R.layout.eraser,
(ViewGroup) findViewById(R.id.root));
AlertDialog.Builder builder_e = new AlertDialog.Builder(this)
.setView(layout_e);
final AlertDialog alertDialog_e = builder_e.create();
alertDialog_e.show();
SeekBar sb_e = (SeekBar) layout_e.findViewById(R.id.seekBar1);
- sb_e.setProgress(5);
+ sb_e.setProgress(10);
final Button done_e = (Button) layout_e.findViewById(R.id.select_size);
final TextView txt_e = (TextView) layout_e
.findViewById(R.id.size_value);
txt_e.setText(String
.format(getResources().getString(
- R.string.default_eraser_size_is), 5));
+ R.string.default_eraser_size_is), 10));
sb_e.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar,
final int progress, boolean fromUser) {
// Do something here with new value
txt_e.setText(String.format(getResources().getString(R.string.your_selected_eraser_size_is), progress));
mPaint.setStrokeWidth(progress);
done_e.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if (progress == 0) {
Toast.makeText(
getApplicationContext(),
R.string.error_eraser_size,
Toast.LENGTH_SHORT).show();
} else {
alertDialog_e.dismiss();
}
}
});
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
});
// mPaint.setColor(bgColor);
mPaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
return true;
case CLEAR_ALL:
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
return true;
case SAVE:
takeScreenshot(true);
break;
case SHARE:
File screenshotPath = takeScreenshot(false);
Intent i = new Intent();
i.setAction(Intent.ACTION_SEND);
i.setType("image/png");
i.putExtra(Intent.EXTRA_SUBJECT,
getString(anupam.acrylic.R.string.share_title_template));
i.putExtra(Intent.EXTRA_TEXT,
getString(anupam.acrylic.R.string.share_text_template));
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(screenshotPath));
try {
startActivity(Intent.createChooser(i,
getString(anupam.acrylic.R.string.toolbox_share_title)));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this.getApplicationContext(),
anupam.acrylic.R.string.no_way_to_share,
Toast.LENGTH_LONG).show();
}
break;
case ABOUT:
try {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle(R.string.app_name + " - " + R.string.about);
+ alert.setTitle(R.string.about);
alert.setMessage(R.string.app_description);
alert.setPositiveButton(R.string.ok, null);
alert.show();
} catch (Exception e) {
// TODO: handle exception
}
}
return super.onOptionsItemSelected(item);
}
/**
* This takes the screenshot of the whole screen.
* Is this a good thing?
*/
private File takeScreenshot(boolean showToast) {
View v = getWindow().getDecorView();
v.setDrawingCacheEnabled(true);
Bitmap cachedBitmap = v.getDrawingCache();
Bitmap copyBitmap = cachedBitmap.copy(Bitmap.Config.RGB_565, true);
FileOutputStream output = null;
File file = null;
try {
File path = Places.getScreenshotFolder();
Calendar cal = Calendar.getInstance();
file = new File(path,
cal.get(Calendar.YEAR) + "_" + (1 + cal.get(Calendar.MONTH)) + "_"
+ cal.get(Calendar.DAY_OF_MONTH) + "_"
+ cal.get(Calendar.HOUR_OF_DAY) + "_"
+ cal.get(Calendar.MINUTE) + "_" + cal.get(Calendar.SECOND)
+ ".png");
output = new FileOutputStream(file);
copyBitmap.compress(CompressFormat.PNG, 100, output);
} catch (FileNotFoundException e) {
file = null;
e.printStackTrace();
} finally {
if (output != null) {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if (file != null) {
if (showToast)
Toast.makeText(
getApplicationContext(),
String.format(
getResources().getString(
R.string.saved_your_location_to),
file.getAbsolutePath()), Toast.LENGTH_LONG)
.show();
// sending a broadcast to the media scanner so it will scan the new
// screenshot.
Intent requestScan = new Intent(
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
requestScan.setData(Uri.fromFile(file));
sendBroadcast(requestScan);
return file;
} else {
return null;
}
}
private boolean isFirstTime() {
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
boolean ranBefore = preferences.getBoolean("RanBefore", false);
if (!ranBefore) {
// first time
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("RanBefore", true);
editor.commit();
}
return !ranBefore;
}
private boolean isSecondTime() {
SharedPreferences preferences = getPreferences(MODE_PRIVATE);
boolean ranBefore = preferences.getBoolean("SecondRun", true);
if (ranBefore) {
// second time
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("SecondRun", false);
editor.commit();
}
return !ranBefore;
}
public boolean connectionAvailable() {
boolean connected = false;
@SuppressWarnings("static-access")
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(getApplicationContext().CONNECTIVITY_SERVICE);
if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)
.getState() == NetworkInfo.State.CONNECTED
|| connectivityManager.getNetworkInfo(
ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
connected = true;
}
return connected;
}
}