8 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Tue May 05 20:39:57 CST 2015
11 | sdk.dir=/opt/android-sdk
12 |
--------------------------------------------------------------------------------
/src/main/raw/color.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | BTN_PRE='\
4 | \|" \
11 | | sed "s#^ *
# #" \
12 | | sed "s#^ *
# #" \
13 | | sed "s#^ *
#$BTN_PRE\#\1$BTN_POST#"
14 |
15 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-19
15 |
--------------------------------------------------------------------------------
/src/main/res/values/backgrounds.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | #c0000000
19 |
20 |
--------------------------------------------------------------------------------
/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/widget/Progress.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.androidsoft.coloring.ui.widget;
18 |
19 | import android.os.Handler;
20 | import android.os.Message;
21 |
22 | public final class Progress {
23 | public static final int MAX = 100;
24 |
25 | public static final int MESSAGE_INCREMENT_PROGRESS = 1;
26 | public static final int MESSAGE_DONE_OK = 2;
27 | public static final int MESSAGE_DONE_ERROR = 3;
28 |
29 | public static final void sendIncrementProgress(Handler h, int diff) {
30 | Message m = Message.obtain(h, Progress.MESSAGE_INCREMENT_PROGRESS, diff, 0);
31 | h.sendMessage(m);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/res/layout/start_new.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/sign.gradle:
--------------------------------------------------------------------------------
1 | final Console console = System.console();
2 |
3 | if (console != null) {
4 |
5 | android.signingConfigs {
6 | release {
7 | project.ext.keyStorePath = System.getenv("ANDROID_KEYSTORE")
8 | if( project.keyStorePath != null )
9 | {
10 | storeFile file( keyStorePath )
11 | keyAlias System.getenv("ANDROID_KEY_ALIAS")
12 | }
13 | storePassword "password"
14 | keyPassword "password"
15 | }
16 | }
17 |
18 | task askForPasswords << {
19 | // Must create String because System.readPassword() returns char[]
20 | // (and assigning that below fails silently)
21 | def storePw = new String(System.console().readPassword("\nKeystore password: "))
22 | def keyPw = new String(System.console().readPassword("Key password: "))
23 |
24 | android.signingConfigs.release.storePassword = storePw
25 | android.signingConfigs.release.keyPassword = keyPw
26 | }
27 |
28 | tasks.whenTaskAdded { theTask ->
29 | if (theTask.name.equals("packageRelease")) {
30 | theTask.dependsOn "askForPasswords"
31 | }
32 | }
33 |
34 | android.buildTypes {
35 | release {
36 | signingConfig android.signingConfigs.release
37 | }
38 | }
39 | } else {
40 |
41 | // Building from IDE's "Run" button
42 | android.signingConfigs {
43 | release {
44 |
45 | }
46 | }
47 |
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/src/main/res/menu/paint_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
45 |
--------------------------------------------------------------------------------
/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
21 |
27 |
43 |
44 |
46 |
47 |
50 |
51 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/activity/PickColorActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.androidsoft.coloring.ui.activity;
17 |
18 | import org.androidsoft.coloring.ui.widget.ColorButton;
19 |
20 | import android.os.Bundle;
21 | import android.view.View;
22 | import android.view.WindowManager;
23 | import java.util.ArrayList;
24 | import java.util.List;
25 | import org.androidsoft.coloring.R;
26 |
27 | public class PickColorActivity extends AbstractColoringActivity implements
28 | View.OnClickListener
29 | {
30 |
31 | @Override
32 | public void onCreate(Bundle savedInstanceState)
33 | {
34 | super.onCreate(savedInstanceState);
35 |
36 | // Apparently this cannot be set from the style.
37 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
38 | WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
39 |
40 | setContentView(R.layout.pick_color);
41 |
42 | List colorButtons = new ArrayList();
43 | findAllColorButtons(colorButtons);
44 | for (int i = 0; i < colorButtons.size(); i++)
45 | {
46 | colorButtons.get(i).setOnClickListener(this);
47 | }
48 |
49 | }
50 |
51 | public void onClick(View view)
52 | {
53 | if (view instanceof ColorButton)
54 | {
55 | ColorButton button = (ColorButton) view;
56 | setResult(button.getColor());
57 | finish();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 | Coloring for Kids
19 |
20 | New
21 | Save
22 | Share
23 | About
24 |
25 | Saving to Pictures…
26 | OK!
27 | Error!
28 | Share image using
29 |
30 | /dcim/Coloring for Kids/
31 |
32 |
33 | Version 1.0.1
34 | Coloring for Kids
35 |
36 | Go
37 |
38 |
39 | Welcome to Coloring for Kids!
40 | Thanks for downloading Coloring for Kids\n\n
41 | Quick start instructions :\n
42 | \t• Select color and paint template with your finger.\n
43 | \n\n Enjoy it!\n
44 |
45 | What\'s new in Coloring for Kids
46 | Thanks for upgrading Coloring for Kids\n\n
47 | New in version 1.0.1:\n
48 | \t• Minor bugs fixes (uninstall synchronization).\n
49 | \n\nEnjoy it and don\'t forget to rate it to support the development.
50 |
51 |
52 |
--------------------------------------------------------------------------------
/src/main/res/layout/splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
21 |
22 |
27 |
28 |
32 |
37 |
38 |
42 |
43 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2011-2012 Pierre Levy
2 | http://www.androidsoft.org
3 |
4 | This program is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 |
17 | =======================================================================
18 |
19 | Copyright (C) 2009-2012, Peter Dornbach
20 | This project includes software developed by Peter Dornbach
21 | http://www.zebra4me.com/
22 |
23 | Licensed under the Apache License, Version 2.0 (the "License");
24 | you may not use this software except in compliance with the License.
25 | You may obtain a copy of the License at:
26 |
27 | http://www.apache.org/licenses/LICENSE-2.0
28 |
29 | Unless required by applicable law or agreed to in writing, software
30 | distributed under the License is distributed on an "AS IS" BASIS,
31 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 | See the License for the specific language governing permissions and
33 | limitations under the License.
34 |
35 | =======================================================================
36 |
37 | Copyright (C) 2009-2012, Everaldo Coelho
38 | This program includes icons realized by Everaldo Coelho
39 | http://www.everaldo.com/
40 |
41 |
42 | This library is free software: you can redistribute it and/or modify
43 | it under the terms of the GNU Lesser General Public License as
44 | published by the Free Software Foundation, either version 3 of the
45 | License, or (at your option) any later version.
46 |
47 | This library is distributed in the hope that it will be useful,
48 | but WITHOUT ANY WARRANTY; without even the implied warranty of
49 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 | GNU General Public License for more details.
51 |
52 | You should have received a copy of the GNU General Public License
53 | along with this program. If not, see .
54 |
55 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/util/DrawUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.androidsoft.coloring.util;
18 |
19 | import android.graphics.Bitmap;
20 | import android.graphics.Canvas;
21 | import android.graphics.Matrix;
22 | import android.graphics.Paint;
23 | import android.graphics.RectF;
24 |
25 | public final class DrawUtils {
26 | // Make dest a resized copy of src. This maintains the aspect ratio. and cuts
27 | // along edges of the image if src and dest have a different aspect ratio.
28 | public static void convertSizeClip(Bitmap src, Bitmap dest) {
29 | Canvas canvas = new Canvas(dest);
30 | RectF srcRect = new RectF(0, 0, src.getWidth(), src.getHeight());
31 | RectF destRect = new RectF(0, 0, dest.getWidth(), dest.getHeight());
32 |
33 | // Because the current SDK does not directly support the "dest fits
34 | // inside src" mode, we calculate the reverse matrix and invert to
35 | // get what we want.
36 | Matrix mDestSrc = new Matrix();
37 | mDestSrc.setRectToRect(destRect, srcRect, Matrix.ScaleToFit.CENTER);
38 | Matrix mSrcDest = new Matrix();
39 | mDestSrc.invert(mSrcDest);
40 |
41 | canvas.drawBitmap(src, mSrcDest, new Paint(Paint.DITHER_FLAG));
42 | }
43 |
44 | public static void convertSizeFill(Bitmap src, Bitmap dest) {
45 | Canvas canvas = new Canvas(dest);
46 | RectF srcRect = new RectF(0, 0, src.getWidth(), src.getHeight());
47 | RectF destRect = new RectF(0, 0, dest.getWidth(), dest.getHeight());
48 |
49 | Matrix m = new Matrix();
50 | m.setRectToRect(srcRect, destRect, Matrix.ScaleToFit.CENTER);
51 |
52 | canvas.drawBitmap(src, m, new Paint(Paint.DITHER_FLAG));
53 | }
54 |
55 | public static int brightness(int color) {
56 | // Because this should be fast, we cheat: simply return the green channel.
57 | return (color >> 16) & 0xff;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/activity/SplashActivity.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010-2011 Pierre LEVY androidsoft.org
2 | * This program is free software: you can redistribute it and/or modify
3 | * it under the terms of the GNU General Public License as published by
4 | * the Free Software Foundation, either version 3 of the License, or
5 | * (at your option) any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * GNU General Public License for more details.
11 | *
12 | * You should have received a copy of the GNU General Public License
13 | * along with this program. If not, see .
14 | */
15 | package org.androidsoft.coloring.ui.activity;
16 |
17 | import android.content.Intent;
18 | import android.os.Bundle;
19 | import android.view.View;
20 | import android.view.View.OnClickListener;
21 | import android.widget.Button;
22 | import android.widget.ImageView;
23 | import org.androidsoft.coloring.R;
24 | import org.androidsoft.utils.ui.WhatsNewActivity;
25 |
26 | /**
27 | * Splash activity
28 | * @author Pierre Levy
29 | */
30 | public class SplashActivity extends WhatsNewActivity implements OnClickListener
31 | {
32 |
33 | private Button mButtonPlay;
34 |
35 | @Override
36 | public void onCreate(Bundle icicle)
37 | {
38 | super.onCreate(icicle);
39 |
40 | setContentView(R.layout.splash);
41 |
42 | mButtonPlay = (Button) findViewById(R.id.button_go);
43 | mButtonPlay.setOnClickListener(this);
44 |
45 | ImageView image = (ImageView) findViewById(R.id.image_splash);
46 | image.setImageResource(R.drawable.splash);
47 |
48 | }
49 |
50 | /**
51 | * {@inheritDoc }
52 | */
53 | public void onClick(View v)
54 | {
55 | if (v == mButtonPlay)
56 | {
57 | Intent intent = new Intent(this, PaintActivity.class);
58 | startActivity(intent);
59 | }
60 | }
61 |
62 | @Override
63 | public int getFirstRunDialogTitleRes()
64 | {
65 | return R.string.first_run_dialog_title;
66 | }
67 |
68 | @Override
69 | public int getFirstRunDialogMsgRes()
70 | {
71 | return R.string.first_run_dialog_message;
72 | }
73 |
74 | @Override
75 | public int getWhatsNewDialogTitleRes()
76 | {
77 | return R.string.whats_new_dialog_title;
78 | }
79 |
80 | @Override
81 | public int getWhatsNewDialogMsgRes()
82 | {
83 | return R.string.whats_new_dialog_message;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/widget/ColoringImageButton.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.androidsoft.coloring.ui.widget;
17 |
18 | import org.androidsoft.coloring.util.DrawUtils;
19 | import android.content.Context;
20 | import android.graphics.Bitmap;
21 | import android.graphics.BitmapFactory;
22 | import android.graphics.Canvas;
23 | import android.graphics.Paint;
24 | import android.util.AttributeSet;
25 | import org.androidsoft.coloring.R;
26 |
27 | public class ColoringImageButton extends ColoringButton
28 | {
29 |
30 | public static final int PADDING_NORMAL_PERCENT = 15;
31 | public static final int PADDING_PUSHED_PERCENT = 5;
32 |
33 | public ColoringImageButton(Context context, AttributeSet attrs, int defStyle)
34 | {
35 | super(context, attrs, defStyle);
36 |
37 | _originalBitmap = BitmapFactory.decodeResource(context.getResources(),
38 | R.drawable.palette);
39 | _paint = new Paint(Paint.DITHER_FLAG);
40 | }
41 |
42 | public ColoringImageButton(Context context, AttributeSet attrs)
43 | {
44 | this(context, attrs, R.attr.coloringButtonStyle);
45 | }
46 |
47 | public ColoringImageButton(Context context)
48 | {
49 | this(context, null);
50 | }
51 |
52 | @Override
53 | protected void onDraw(Canvas canvas)
54 | {
55 | int w = getWidth();
56 | int h = getHeight();
57 | int p = Math.min(w, h)
58 | * (isPushedDown() ? PADDING_PUSHED_PERCENT : PADDING_NORMAL_PERCENT)
59 | / 100;
60 |
61 | w -= 2 * p;
62 | h -= 2 * p;
63 | if ((_resizedBitmap == null) || (_resizedBitmap.getWidth() != w)
64 | || (_resizedBitmap.getHeight() != h))
65 | {
66 | _resizedBitmap = Bitmap.createBitmap(w, h, _originalBitmap.getConfig());
67 | DrawUtils.convertSizeFill(_originalBitmap, _resizedBitmap);
68 | }
69 |
70 | canvas.drawBitmap(_resizedBitmap, p, p, _paint);
71 | }
72 | private Bitmap _originalBitmap;
73 | private Bitmap _resizedBitmap;
74 | private Paint _paint;
75 | }
76 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/activity/AbstractColoringActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.androidsoft.coloring.ui.activity;
18 |
19 | import org.androidsoft.coloring.ui.widget.ColorButton;
20 | import java.util.List;
21 |
22 | import android.os.Bundle;
23 | import android.view.Display;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 | import android.view.WindowManager;
27 | import org.androidsoft.utils.ui.NoTitleActivity;
28 |
29 | public abstract class AbstractColoringActivity extends NoTitleActivity
30 | {
31 |
32 | public static final String INTENT_START_NEW = "org.androidsoft.coloring.paint.START_NEW";
33 | public static final String INTENT_PICK_COLOR = "org.androidsoft.coloring.paint.PICK_COLOR";
34 | public static final String INTENT_ABOUT = "org.androidsoft.coloring.paint.ABOUT";
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState)
38 | {
39 | super.onCreate(savedInstanceState);
40 |
41 | WindowManager w = getWindowManager();
42 | Display d = w.getDefaultDisplay();
43 | _displayWidth = d.getWidth();
44 | _displayHeight = d.getHeight();
45 |
46 | }
47 |
48 | public static int getDisplayWitdh()
49 | {
50 | return _displayWidth;
51 | }
52 |
53 | public static int getDisplayHeight()
54 | {
55 | return _displayHeight;
56 | }
57 |
58 | protected void findAllColorButtons(List result)
59 | {
60 | findAllColorButtons((ViewGroup) getWindow().getDecorView(), result);
61 | }
62 |
63 | protected void findAllColorButtons(ViewGroup g, List result)
64 | {
65 | for (int i = 0; i < g.getChildCount(); i++)
66 | {
67 | View v = g.getChildAt(i);
68 | if (v instanceof ViewGroup)
69 | {
70 | findAllColorButtons((ViewGroup) v, result);
71 | }
72 | if (v instanceof ColorButton)
73 | {
74 | result.add((ColorButton) v);
75 | }
76 | }
77 | }
78 | protected static int _displayWidth;
79 | protected static int _displayHeight;
80 | }
--------------------------------------------------------------------------------
/src/main/res/values/credits.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 | *by androidsoft.org
22 | *
23 | *
24 | *
25 | *
26 | License
27 | *
28 | *This program is free software:
29 | *you can redistribute it and/or
30 | *modify it under the terms of the
31 | *GNU General Public License
32 | *as published by the Free Software
33 | *Foundation, either version 3
34 | *of the License, or (at your option)
35 | *any later version.
36 | *
37 | *The original version was published
38 | *by Peter Dornbach
39 | *under Apache License 2.0
40 | *for more information see
41 | *http://www.zebra4me.com/
42 | *
43 | *Icons are published
44 | *by Everaldo Coelho
45 | *under the terms of the GNU
46 | *Lesser General Public License.
47 | *
48 | *Drawings provided by kind
49 | *courtesy of Peter Dornbach
50 | *
51 | *
52 | *
53 | Credits
54 | *
55 | */* Main developer */
56 | *
57 | *Peter Dornbach
58 | *
59 | */* GNU version contributor */
60 | *
61 | *Pierre Levy
62 | *
63 | *
64 | *
65 | *
66 | *http://www.androidsoft.org
67 | *Copyright (c) 2010-2011 P. Dornbach, P. Levy
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/activity/CreditsActivity.java:
--------------------------------------------------------------------------------
1 | /* Copyright (c) 2010-2011 Pierre LEVY androidsoft.org
2 | * This program is free software: you can redistribute it and/or modify
3 | * it under the terms of the GNU General Public License as published by
4 | * the Free Software Foundation, either version 3 of the License, or
5 | * (at your option) any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * GNU General Public License for more details.
11 | *
12 | * You should have received a copy of the GNU General Public License
13 | * along with this program. If not, see .
14 | */
15 | package org.androidsoft.coloring.ui.activity;
16 |
17 | import android.graphics.Typeface;
18 | import android.os.Bundle;
19 | import android.view.View;
20 | import org.androidsoft.coloring.R;
21 | import org.androidsoft.utils.credits.CreditsParams;
22 | import org.androidsoft.utils.credits.CreditsView;
23 | import org.androidsoft.utils.ui.BasicActivity;
24 |
25 | /**
26 | * Credits activity
27 | * @author Pierre Levy
28 | */
29 | public class CreditsActivity extends BasicActivity
30 | {
31 |
32 | @Override
33 | public void onCreate(Bundle icicle)
34 | {
35 | super.onCreate(icicle);
36 |
37 | View view = new CreditsView(this, getCreditsParams());
38 | setContentView(view);
39 |
40 | }
41 |
42 | /**
43 | * {@inheritDoc }
44 | */
45 | @Override
46 | public int getMenuResource()
47 | {
48 | return R.menu.menu_close;
49 | }
50 |
51 | /**
52 | * {@inheritDoc }
53 | */
54 | @Override
55 | public int getMenuCloseId()
56 | {
57 | return R.id.menu_close;
58 | }
59 |
60 | private CreditsParams getCreditsParams()
61 | {
62 | CreditsParams p = new CreditsParams();
63 | p.setAppNameRes(R.string.credits_app_name);
64 | p.setAppVersionRes(R.string.credits_current_version);
65 | p.setBitmapBackgroundRes(R.drawable.background);
66 | p.setBitmapBackgroundLandscapeRes(R.drawable.background_land);
67 | p.setArrayCreditsRes(R.array.credits);
68 |
69 | p.setColorDefault(0xCCCEA757);
70 | p.setTextSizeDefault(32);
71 | p.setTypefaceDefault(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
72 | p.setSpacingBeforeDefault(10);
73 | p.setSpacingAfterDefault(18);
74 |
75 | p.setColorCategory(0xCCFFFFFF);
76 | p.setTextSizeCategory(20);
77 | p.setTypefaceCategory(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));
78 | p.setSpacingBeforeCategory(12);
79 | p.setSpacingAfterCategory(12);
80 |
81 | return p;
82 |
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
21 |
22 |
23 |
24 |
25 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/widget/ColoringButton.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.androidsoft.coloring.ui.widget;
17 |
18 | import android.content.Context;
19 | import android.util.AttributeSet;
20 | import android.view.MotionEvent;
21 | import android.view.View;
22 | import org.androidsoft.coloring.R;
23 | import org.androidsoft.coloring.ui.activity.AbstractColoringActivity;
24 |
25 | // A button that is proportional to the screen size.
26 | public class ColoringButton extends View
27 | {
28 |
29 | public ColoringButton(Context context, AttributeSet attrs, int defStyle)
30 | {
31 | super(context, attrs, defStyle);
32 | setClickable(true);
33 | }
34 |
35 | public ColoringButton(Context context, AttributeSet attrs)
36 | {
37 | this(context, attrs, R.attr.coloringButtonStyle);
38 | }
39 |
40 | public ColoringButton(Context context)
41 | {
42 | this(context, null);
43 | }
44 |
45 | public static int getPreferredWidth()
46 | {
47 | return AbstractColoringActivity.getDisplayWitdh() / 8;
48 | }
49 |
50 | public static int getPreferredHeight()
51 | {
52 | return AbstractColoringActivity.getDisplayHeight() / 8;
53 | }
54 |
55 | @Override
56 | public boolean onTouchEvent(MotionEvent e)
57 | {
58 | _touchPushed = isPushed(e, _touchPushed);
59 | return super.onTouchEvent(e);
60 | }
61 |
62 | public boolean isPushedDown()
63 | {
64 | return _touchPushed;
65 | }
66 |
67 | @Override
68 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
69 | {
70 | setMeasuredDimension(measureWidth(widthMeasureSpec),
71 | measureHeight(heightMeasureSpec));
72 | }
73 |
74 | private boolean isPushed(MotionEvent e, boolean original)
75 | {
76 | switch (e.getAction())
77 | {
78 | case MotionEvent.ACTION_DOWN:
79 | invalidate();
80 | return true;
81 | case MotionEvent.ACTION_UP:
82 | invalidate();
83 | return false;
84 | default:
85 | return original;
86 | }
87 | }
88 |
89 | private int measureWidth(int measureSpec)
90 | {
91 | return getMeasurement(measureSpec, getPreferredWidth());
92 | }
93 |
94 | private int measureHeight(int measureSpec)
95 | {
96 | return getMeasurement(measureSpec, getPreferredHeight());
97 | }
98 |
99 | private int getMeasurement(int measureSpec, int preferred)
100 | {
101 | int specSize = MeasureSpec.getSize(measureSpec);
102 | int measurement = 0;
103 | switch (MeasureSpec.getMode(measureSpec))
104 | {
105 | case MeasureSpec.EXACTLY:
106 | measurement = specSize;
107 | break;
108 | case MeasureSpec.AT_MOST:
109 | measurement = Math.min(preferred, specSize);
110 | break;
111 | default:
112 | measurement = preferred;
113 | break;
114 | }
115 | return measurement;
116 | }
117 | private boolean _touchPushed;
118 | }
--------------------------------------------------------------------------------
/src/main/raw/colors.html:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
Dark red
11 |
Red
12 |
Salmon
13 |
Pink
14 |
15 |
Navajo white
16 |
Sandy brown
17 |
Chocolate
18 |
Saddle brown
19 |
20 |
21 |
Purple
22 |
Medium violet red
23 |
Deep pink
24 |
Hot pink
25 |
26 |
Yellow
27 |
Gold
28 |
Orange
29 |
Orange red
30 |
31 |
32 |
Indigo
33 |
Dark violet
34 |
Magenta
35 |
Violet
36 |
37 |
Khaki
38 |
Dark khaki
39 |
Olive
40 |
Dark olive green
41 |
42 |
43 |
Dark slate blue
44 |
Slate blue
45 |
Steel blue
46 |
Light steel blue
47 |
48 |
Pale green
49 |
Lime green
50 |
Forest green
51 |
Dark green
52 |
53 |
54 |
Navy
55 |
Blue
56 |
Deep sky blue
57 |
Sky blue
58 |
59 |
Green yellow
60 |
Lime
61 |
Slate gray
62 |
Dark slate gray
63 |
64 |
65 |
Teal
66 |
Dark turqoise
67 |
Aqua
68 |
Aquamarine
69 |
70 |
Gray
71 |
Silver
72 |
Gainsboro
73 |
White
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/src/main/res/layout/paint.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
22 |
23 |
27 |
28 |
29 |
32 |
35 |
38 |
41 |
44 |
47 |
51 |
56 |
57 |
58 |
59 |
63 |
66 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/util/FloodFill.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.androidsoft.coloring.util;
18 |
19 | import java.util.Arrays;
20 | import java.util.LinkedList;
21 | import java.util.Queue;
22 |
23 | public class FloodFill {
24 | public interface PixelMatcher {
25 | // Return true if the pixel at x,y should be filled. It must be prepared
26 | // to handle x < 0, y < 0. It must return false for a pixel already set.
27 | boolean match(int x, int y);
28 | }
29 |
30 | public interface PixelSetter {
31 | // Set the a row of pixels from x1 until x2 in row y.
32 | // x1 included, x2 excluded.
33 | void set(int x1, int x2, int y);
34 | }
35 |
36 | // The "nice" fill that works with any PixelMatcher and PixelSetter.
37 | public static void fill(int x, int y, PixelMatcher matcher, PixelSetter setter) {
38 | Queue queue = new LinkedList();
39 | queue.add(new Pixel(x, y));
40 | while (!queue.isEmpty()) {
41 | Pixel p = queue.remove();
42 | int px1 = p._x;
43 | int px2 = p._x;
44 | int py = p._y;
45 | if (matcher.match(px1, py)) {
46 | while (matcher.match(px1, py))
47 | px1--;
48 | px1++;
49 | while (matcher.match(px2, py))
50 | px2++;
51 | boolean prevMatchUp = false;
52 | boolean prevMatchDn = false;
53 | setter.set(px1, px2, py);
54 | for (int px = px1; px < px2; px++) {
55 | boolean matchUp = matcher.match(px, py - 1);
56 | if (matchUp && !prevMatchUp)
57 | queue.add(new Pixel(px, py - 1));
58 | boolean matchDn = matcher.match(px, py + 1);
59 | if (matchDn && !prevMatchDn)
60 | queue.add(new Pixel(px, py + 1));
61 | prevMatchUp = matchUp;
62 | prevMatchDn = matchDn;
63 | }
64 | }
65 | }
66 | }
67 |
68 | // The plain dumb ugly fill - but because it's fast we use this one.
69 | // @param mask 1 if the pixel can be filled, 0 if it cannot. Must contain
70 | // exactly width * height pixels.
71 | // @param pixels the array where we fill matching pixels with color.
72 | // @param x, y we start the fill here.
73 | public static void fillRaw(int x, int y, int width, int height, byte[] mask,
74 | int[] pixels, int color) {
75 | Queue queue = new LinkedList();
76 | queue.add(new Pixel(x, y));
77 | while (!queue.isEmpty()) {
78 | Pixel p = queue.remove();
79 | int px1 = p._x;
80 | int px2 = p._x;
81 | int py = p._y;
82 | int pp = py * width;
83 |
84 | if (mask[pp + px1] != 0) {
85 | while (px1 >= 0 && mask[pp + px1] != 0)
86 | px1--;
87 | px1++;
88 | while (px2 < width && mask[pp + px2] != 0)
89 | px2++;
90 | Arrays.fill(pixels, pp + px1, pp + px2, color);
91 | Arrays.fill(mask, pp + px1, pp + px2, (byte) 0);
92 | boolean prevMatchUp = false;
93 | boolean prevMatchDn = false;
94 | int ppUp = pp - width;
95 | int ppDn = pp + width;
96 | for (int px = px1; px < px2; px++) {
97 | if (py > 0) {
98 | boolean matchUp = mask[ppUp + px] != 0;
99 | if (matchUp && !prevMatchUp)
100 | queue.add(new Pixel(px, py - 1));
101 | prevMatchUp = matchUp;
102 | }
103 | if (py + 1 < height) {
104 | boolean matchDn = mask[ppDn + px] != 0;
105 | if (matchDn && !prevMatchDn)
106 | queue.add(new Pixel(px, py + 1));
107 | prevMatchDn = matchDn;
108 | }
109 | }
110 | }
111 | }
112 | }
113 |
114 | private static class Pixel {
115 | public Pixel(int x, int y) {
116 | _x = x;
117 | _y = y;
118 | }
119 |
120 | public int _x;
121 | public int _y;
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/widget/ColorButton.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.androidsoft.coloring.ui.widget;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.graphics.Canvas;
21 | import android.graphics.Color;
22 | import android.graphics.drawable.GradientDrawable;
23 | import android.graphics.drawable.GradientDrawable.Orientation;
24 | import android.util.AttributeSet;
25 | import org.androidsoft.coloring.R;
26 |
27 | public class ColorButton extends ColoringButton
28 | {
29 |
30 | public static final int PADDING_NORMAL_PERCENT = 20;
31 | public static final int PADDING_PUSHED_PERCENT = 10;
32 | public static final int PADDING_SELECTED_PERCENT = 12;
33 | public static final int INSET_HIGHLIGHT_PERCENT = 5;
34 |
35 | public ColorButton(Context context, AttributeSet attrs, int defStyle)
36 | {
37 | super(context, attrs, defStyle);
38 |
39 | TypedArray a = context.obtainStyledAttributes(attrs,
40 | R.styleable.ColorButton, defStyle, 0);
41 | _color = a.getColor(R.styleable.ColorButton_color, Color.RED);
42 | a.recycle();
43 |
44 | _highlightDrawable = new GradientDrawable(Orientation.TOP_BOTTOM,
45 | new int[]
46 | {
47 | Color.WHITE, Color.TRANSPARENT, Color.TRANSPARENT
48 | });
49 | _highlightDrawable.setShape(GradientDrawable.OVAL);
50 | _colorDrawable = new GradientDrawable();
51 | _colorDrawable.setColor(_color);
52 | _colorDrawable.setShape(GradientDrawable.OVAL);
53 | }
54 |
55 | public ColorButton(Context context, AttributeSet attrs)
56 | {
57 | this(context, attrs, R.attr.colorButtonStyle);
58 | }
59 |
60 | public ColorButton(Context context)
61 | {
62 | this(context, null);
63 | }
64 |
65 | @Override
66 | public void setSelected(boolean selected)
67 | {
68 | if (_selected != selected)
69 | {
70 | _selected = selected;
71 | invalidate();
72 | }
73 | }
74 |
75 | public int getColor()
76 | {
77 | return _color;
78 | }
79 |
80 | public void setColor(int color)
81 | {
82 | if (color != _color)
83 | {
84 | _color = color;
85 | _colorDrawable.setColor(_color);
86 | invalidate();
87 | }
88 | }
89 |
90 | @Override
91 | protected void onDraw(Canvas canvas)
92 | {
93 | boolean pushedDown = isPushedDown();
94 |
95 | final int w = getWidth();
96 | final int h = getHeight();
97 | final int minwh = Math.min(w, h);
98 |
99 | int i = minwh * INSET_HIGHLIGHT_PERCENT / 100;
100 | int p = 0;
101 | if (pushedDown)
102 | {
103 | p = minwh * PADDING_PUSHED_PERCENT / 100;
104 | }
105 | else
106 | {
107 | if (_selected)
108 | {
109 | p = minwh * PADDING_SELECTED_PERCENT / 100;
110 | }
111 | else
112 | {
113 | p = minwh * PADDING_NORMAL_PERCENT / 100;
114 | }
115 | }
116 |
117 | _colorDrawable.setBounds(p, p, w - p, h - p);
118 | _colorDrawable.draw(canvas);
119 | _highlightDrawable.setBounds(p + i, p + i, w - p - i, h - p - i);
120 | _highlightDrawable.draw(canvas);
121 | }
122 | private boolean _selected;
123 | private int _color;
124 | private GradientDrawable _colorDrawable;
125 | private GradientDrawable _highlightDrawable;
126 | }
127 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/activity/StartNewActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.androidsoft.coloring.ui.activity;
17 |
18 | import java.lang.reflect.Field;
19 | import java.util.Iterator;
20 | import java.util.Map;
21 | import java.util.Random;
22 | import java.util.Set;
23 | import java.util.TreeMap;
24 |
25 | import android.content.Context;
26 | import android.os.Bundle;
27 | import android.view.View;
28 | import android.view.ViewGroup;
29 | import android.view.WindowManager;
30 | import android.widget.BaseAdapter;
31 | import android.widget.GridView;
32 | import android.widget.ImageView;
33 | import org.androidsoft.coloring.R;
34 | import org.androidsoft.utils.ui.NoTitleActivity;
35 |
36 | public class StartNewActivity extends NoTitleActivity implements View.OnClickListener
37 | {
38 | // This is an expensive operation.
39 |
40 | public static int randomOutlineId()
41 | {
42 | return new ResourceLoader().randomOutlineId();
43 | }
44 |
45 | @Override
46 | public void onCreate(Bundle savedInstanceState)
47 | {
48 | super.onCreate(savedInstanceState);
49 |
50 | // Apparently this cannot be set from the style.
51 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
52 | WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
53 |
54 | setContentView(R.layout.start_new);
55 |
56 | GridView gridview = (GridView) findViewById(R.id.start_new_grid);
57 | gridview.setAdapter(new ImageAdapter(this));
58 | }
59 |
60 | public void onClick(View view)
61 | {
62 | setResult(view.getId());
63 | finish();
64 | }
65 |
66 | private static class ResourceLoader
67 | {
68 |
69 | ResourceLoader()
70 | {
71 | // Use reflection to list resource ids of thumbnails and outline
72 | // images.First, we list all the drawables starting with the proper
73 | // prefixes into 2 maps.
74 | Map outlineMap = new TreeMap();
75 | Map thumbMap = new TreeMap();
76 | Field[] drawables = R.drawable.class.getDeclaredFields();
77 | for (int i = 0; i < drawables.length; i++)
78 | {
79 | String name = drawables[i].getName();
80 | try
81 | {
82 | if (name.startsWith(PREFIX_OUTLINE))
83 | {
84 | outlineMap.put(name.substring(PREFIX_OUTLINE.length()),
85 | drawables[i].getInt(null));
86 | }
87 | if (name.startsWith(PREFIX_THUMB))
88 | {
89 | thumbMap.put(name.substring(PREFIX_THUMB.length()),
90 | drawables[i].getInt(null));
91 | }
92 | }
93 | catch (IllegalAccessException e)
94 | {
95 | }
96 | }
97 | Set keys = outlineMap.keySet();
98 | keys.retainAll(thumbMap.keySet());
99 | _outlineIds = new Integer[keys.size()];
100 | _thumbIds = new Integer[keys.size()];
101 | int j = 0;
102 | Iterator i = keys.iterator();
103 | while (i.hasNext())
104 | {
105 | String key = i.next();
106 | _outlineIds[j] = outlineMap.get(key);
107 | _thumbIds[j] = thumbMap.get(key);
108 | j++;
109 | }
110 | }
111 |
112 | public Integer[] getThumbIds()
113 | {
114 | return _thumbIds;
115 | }
116 |
117 | public Integer[] getOutlineIds()
118 | {
119 | return _outlineIds;
120 | }
121 |
122 | public int randomOutlineId()
123 | {
124 | return _outlineIds[new Random().nextInt(_outlineIds.length)];
125 | }
126 | private static final String PREFIX_OUTLINE = "outline";
127 | private static final String PREFIX_THUMB = "thumb";
128 | private Integer[] _thumbIds;
129 | private Integer[] _outlineIds;
130 | }
131 |
132 | private class ImageAdapter extends BaseAdapter
133 | {
134 |
135 | ImageAdapter(Context c)
136 | {
137 | _context = c;
138 | _resourceLoader = new ResourceLoader();
139 | }
140 |
141 | public int getCount()
142 | {
143 | return _resourceLoader.getThumbIds().length;
144 | }
145 |
146 | public Object getItem(int i)
147 | {
148 | return null;
149 | }
150 |
151 | public long getItemId(int i)
152 | {
153 | return 0;
154 | }
155 |
156 | public View getView(int position, View convertView, ViewGroup parent)
157 | {
158 | ImageView imageView;
159 | if (convertView == null)
160 | {
161 | // If it's not recycled, initialize some attributes
162 | imageView = new ImageView(_context);
163 | imageView.setLayoutParams(new GridView.LayoutParams(145, 145));
164 | imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
165 | imageView.setPadding(8, 8, 8, 8);
166 | imageView.setOnClickListener(StartNewActivity.this);
167 | }
168 | else
169 | {
170 | imageView = (ImageView) convertView;
171 | }
172 |
173 | imageView.setImageResource(_resourceLoader.getThumbIds()[position]);
174 | imageView.setId(_resourceLoader.getOutlineIds()[position]);
175 | return imageView;
176 | }
177 | private Context _context;
178 | private ResourceLoader _resourceLoader;
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/src/main/res/layout/pick_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
22 |
23 |
27 |
28 |
29 |
32 |
35 |
38 |
41 |
44 |
47 |
50 |
53 |
54 |
55 |
56 |
59 |
62 |
65 |
68 |
71 |
74 |
77 |
80 |
81 |
82 |
83 |
86 |
89 |
92 |
95 |
98 |
101 |
104 |
107 |
108 |
109 |
112 |
115 |
118 |
121 |
124 |
127 |
130 |
133 |
134 |
135 |
138 |
141 |
144 |
147 |
150 |
153 |
156 |
159 |
160 |
161 |
164 |
167 |
170 |
173 |
176 |
179 |
182 |
185 |
186 |
187 |
188 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/widget/PaintView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.androidsoft.coloring.ui.widget;
17 |
18 | import org.androidsoft.coloring.util.FloodFill;
19 | import org.androidsoft.coloring.util.DrawUtils;
20 | import java.io.File;
21 | import java.io.IOException;
22 | import java.io.OutputStream;
23 | import java.util.Arrays;
24 |
25 | import android.content.Context;
26 | import android.graphics.Bitmap;
27 | import android.graphics.Canvas;
28 | import android.graphics.Color;
29 | import android.graphics.Paint;
30 | import android.graphics.Rect;
31 | import android.os.Handler;
32 | import android.util.AttributeSet;
33 | import android.view.MotionEvent;
34 | import android.view.View;
35 | import java.io.FileOutputStream;
36 |
37 | public class PaintView extends View
38 | {
39 |
40 | public interface LifecycleListener
41 | {
42 | // After this method it is allowed to load resources.
43 |
44 | public void onPreparedToLoad();
45 | }
46 |
47 | public PaintView(Context context, AttributeSet attrs)
48 | {
49 | super(context, attrs);
50 | _state = new State();
51 | _paint = new Paint();
52 |
53 | }
54 |
55 | public PaintView(Context context)
56 | {
57 | this(context, null);
58 | }
59 |
60 | public synchronized void setLifecycleListener(LifecycleListener l)
61 | {
62 | _lifecycleListener = l;
63 |
64 | }
65 |
66 | public synchronized Object getState()
67 | {
68 | return _state;
69 | }
70 |
71 | public synchronized void setState(Object o)
72 | {
73 | _state = (State) o;
74 | }
75 |
76 | public void loadFromBitmap(Bitmap originalOutlineBitmap,
77 | Handler progressHandler)
78 | {
79 | // Proportion of progress in various places.
80 | // The sum of all progress should be 100.
81 | final int PROGRESS_RESIZE = 10;
82 | final int PROGRESS_SCAN = 90;
83 |
84 | int w = 0;
85 | int h = 0;
86 | State newState = new State();
87 | synchronized (this)
88 | {
89 | w = _state._width;
90 | h = _state._height;
91 | newState._color = _state._color;
92 | newState._width = w;
93 | newState._height = h;
94 | }
95 | final int n = w * h;
96 |
97 | // Resize so that it matches our paint size.
98 | Bitmap resizedBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
99 | DrawUtils.convertSizeClip(originalOutlineBitmap, resizedBitmap);
100 | Progress.sendIncrementProgress(progressHandler, PROGRESS_RESIZE);
101 |
102 | // Scan through the bitmap. We create the "outline" bitmap that is
103 | // completely black and has the alpha channel set only. We also
104 | // create the "mask" that we will use later when filling.
105 | newState._outlineBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
106 | newState._paintMask = new byte[n];
107 | {
108 | int pixels[] = new int[n];
109 | resizedBitmap.getPixels(pixels, 0, w, 0, 0, w, h);
110 | for (int i2 = 0; i2 < PROGRESS_SCAN; i2++)
111 | {
112 | final int iStart = i2 * n / PROGRESS_SCAN;
113 | final int iEnd = (i2 + 1) * n / PROGRESS_SCAN;
114 | for (int i = iStart; i < iEnd; i++)
115 | {
116 | int alpha = 255 - DrawUtils.brightness(pixels[i]);
117 | newState._paintMask[i] = (alpha < ALPHA_TRESHOLD ? (byte) 1
118 | : (byte) 0);
119 | pixels[i] = alpha << 24;
120 | }
121 | Progress.sendIncrementProgress(progressHandler, 1);
122 | }
123 | newState._outlineBitmap.setPixels(pixels, 0, w, 0, 0, w, h);
124 | }
125 |
126 | // Initialize the rest.
127 | newState._paintedBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
128 | newState._paintedBitmap.eraseColor(Color.WHITE);
129 | newState._workingMask = new byte[n];
130 | newState._pixels = new int[n];
131 | Arrays.fill(newState._pixels, Color.WHITE);
132 |
133 | // Commit our changes. So far we have only worked on local variables
134 | // so we only synchronize now.
135 | synchronized (this)
136 | {
137 | _state = newState;
138 | }
139 | progressHandler.sendEmptyMessage(Progress.MESSAGE_DONE_OK);
140 | }
141 |
142 | public synchronized void saveToFile(File file, Bitmap originalOutlineBitmap,
143 | Handler progressHandler)
144 | {
145 | // Proportion of progress in various places.
146 | // The sum of all progress should be 100.
147 | final int PROGRESS_SCAN_PAINTED = 25;
148 | final int PROGRESS_DRAW_PAINTED = 5;
149 | final int PROGRESS_SCAN_OUTLINE = 45;
150 | final int PROGRESS_DRAW_OUTLINE = 10;
151 | final int PROGRESS_SAVE = 15;
152 |
153 | // First, get a copy of the painted bitmap. After that we do not have
154 | // to deal with class instance any more.
155 | Bitmap painted;
156 | // synchronized (this) // already synchronized
157 | {
158 | painted = _state._paintedBitmap.copy(_state._paintedBitmap.getConfig(),
159 | true);
160 | }
161 | // Now, scan over the original painted bitmap to "extend" the painted
162 | // regions by one pixel to fix accidental white areas because of resizing.
163 | {
164 | final int hp = painted.getHeight();
165 | final int wp = painted.getWidth();
166 | final int np = hp * wp;
167 | int[] origPixels = new int[np];
168 | int[] newPixels = new int[np];
169 | painted.getPixels(newPixels, 0, wp, 0, 0, wp, hp);
170 | System.arraycopy(newPixels, 0, origPixels, 0, np);
171 | for (int y2 = 0; y2 < PROGRESS_SCAN_PAINTED; y2++)
172 | {
173 | final int yStart = y2 * hp / PROGRESS_SCAN_PAINTED;
174 | final int yEnd = (y2 + 1) * hp / PROGRESS_SCAN_PAINTED;
175 | int p = yStart * wp;
176 | for (int y = yStart; y < yEnd; y++)
177 | {
178 | for (int x = 0; x < wp; x++)
179 | {
180 | if (origPixels[p] == Color.WHITE)
181 | {
182 | if (x > 0 && origPixels[p - 1] != Color.WHITE)
183 | {
184 | newPixels[p] = origPixels[p - 1];
185 | }
186 | else if (y > 0 && origPixels[p - wp] != Color.WHITE)
187 | {
188 | newPixels[p] = origPixels[p - wp];
189 | }
190 | else if (x < wp - 1 && origPixels[p + 1] != Color.WHITE)
191 | {
192 | newPixels[p] = origPixels[p + 1];
193 | }
194 | else if (y < hp - 1 && origPixels[p + wp] != Color.WHITE)
195 | {
196 | newPixels[p] = origPixels[p + wp];
197 | }
198 | }
199 | p++;
200 | }
201 | }
202 | Progress.sendIncrementProgress(progressHandler, 1);
203 | }
204 | painted.setPixels(newPixels, 0, wp, 0, 0, wp, hp);
205 | }
206 |
207 | // Calculate the proportions of the result and create it. The result
208 | // has more pixels than the bitmap we paint, it has the maximum
209 | // number of pixels possible with the original outline (while
210 | // maintaining the same aspect ratio as the drawing).
211 | final float aspectRatio = (float) painted.getWidth() / painted.getHeight();
212 | int hr = originalOutlineBitmap.getHeight();
213 | int wr = (int) (hr * aspectRatio);
214 | if (wr > originalOutlineBitmap.getWidth())
215 | {
216 | wr = originalOutlineBitmap.getWidth();
217 | hr = (int) (wr / aspectRatio);
218 | }
219 | int nr = wr * hr;
220 | Bitmap result = Bitmap.createBitmap(wr, hr, Bitmap.Config.ARGB_8888);
221 | Canvas canvas = new Canvas(result);
222 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
223 |
224 | // Draw and scale the painted bitmap onto the result.
225 | canvas.drawBitmap(painted, new Rect(0, 0, painted.getWidth(),
226 | painted.getHeight()), new Rect(0, 0, wr, hr), paint);
227 | Progress.sendIncrementProgress(progressHandler, PROGRESS_DRAW_PAINTED);
228 |
229 | // Process the outline, i.e. get which pixels are transparent and which
230 | // ones are not. This is almost the same as what we do when loading
231 | // except that this image has more pixels.
232 | Bitmap cropped = Bitmap.createBitmap(wr, hr, Bitmap.Config.ARGB_8888);
233 | {
234 | int[] pixels = new int[nr];
235 | // While getting the pixels, we also crop the unneeded parts.
236 | originalOutlineBitmap.getPixels(pixels, 0, wr,
237 | (originalOutlineBitmap.getWidth() - wr) / 2,
238 | (originalOutlineBitmap.getHeight() - hr) / 2, wr, hr);
239 | for (int i2 = 0; i2 < PROGRESS_SCAN_OUTLINE; i2++)
240 | {
241 | final int iStart = i2 * nr / PROGRESS_SCAN_OUTLINE;
242 | final int iEnd = (i2 + 1) * nr / PROGRESS_SCAN_OUTLINE;
243 | for (int i = iStart; i < iEnd; i++)
244 | {
245 | int alpha = 255 - DrawUtils.brightness(pixels[i]);
246 | pixels[i] = alpha << 24;
247 | }
248 | Progress.sendIncrementProgress(progressHandler, 1);
249 | }
250 | cropped.setPixels(pixels, 0, wr, 0, 0, wr, hr);
251 | }
252 |
253 | // As a final drawing step, draw the outline onto the result.
254 | canvas.drawBitmap(cropped, 0, 0, paint);
255 | Progress.sendIncrementProgress(progressHandler, PROGRESS_DRAW_OUTLINE);
256 |
257 | try
258 | {
259 | // Write the result to the dest file.
260 | file.getParentFile().mkdirs();
261 | OutputStream outStream = new FileOutputStream(file);
262 | result.compress(Bitmap.CompressFormat.PNG, 90, outStream);
263 | outStream.close();
264 | Progress.sendIncrementProgress(progressHandler, PROGRESS_SAVE);
265 | }
266 | catch (IOException e)
267 | {
268 | progressHandler.sendEmptyMessage(Progress.MESSAGE_DONE_ERROR);
269 | return;
270 | }
271 |
272 | progressHandler.sendEmptyMessage(Progress.MESSAGE_DONE_OK);
273 | }
274 |
275 | public synchronized boolean isInitialized()
276 | {
277 | return _state._paintedBitmap != null;
278 | }
279 |
280 | public synchronized void setPaintColor(int color)
281 | {
282 | _state._color = color;
283 | _paint.setColor(color);
284 | }
285 |
286 | @Override
287 | protected void onSizeChanged(int w, int h, int oldw, int oldh)
288 | {
289 | super.onSizeChanged(w, h, oldw, oldh);
290 |
291 | synchronized (this)
292 | {
293 | if (_state._width == 0 || _state._height == 0)
294 | {
295 | _state._width = w;
296 | _state._height = h;
297 | if (_lifecycleListener != null)
298 | {
299 | _lifecycleListener.onPreparedToLoad();
300 | }
301 | }
302 | }
303 | }
304 |
305 |
306 |
307 | @Override
308 | protected synchronized void onDraw(Canvas canvas)
309 | {
310 | if (_state._paintedBitmap != null)
311 | {
312 | canvas.drawBitmap(_state._paintedBitmap, 0, 0, _paint);
313 | }
314 | if (_state._outlineBitmap != null)
315 | {
316 | canvas.drawBitmap(_state._outlineBitmap, 0, 0, _paint);
317 | }
318 | }
319 |
320 | @Override
321 | public boolean onTouchEvent(MotionEvent e)
322 | {
323 | if (e.getAction() == MotionEvent.ACTION_DOWN)
324 | {
325 | paint((int) e.getX(), (int) e.getY());
326 | }
327 | return true;
328 | }
329 |
330 | private synchronized void paint(int x, int y)
331 | {
332 | // Copy the original mask to the working mask because it will be
333 | // modified.
334 | System.arraycopy(_state._paintMask, 0, _state._workingMask, 0,
335 | _state._width * _state._height);
336 |
337 | // Do the nasty stuff.
338 | FloodFill.fillRaw(x, y, _state._width, _state._height, _state._workingMask,
339 | _state._pixels, _state._color);
340 |
341 | // And now copy all the pixels back.
342 | _state._paintedBitmap.setPixels(_state._pixels, 0, _state._width, 0, 0,
343 | _state._width, _state._height);
344 | invalidate();
345 | }
346 | private static final int ALPHA_TRESHOLD = 224;
347 | // The listener whom we notify when ready to load images.
348 | private LifecycleListener _lifecycleListener;
349 |
350 | // We keep the state of the current drawing in a different class so that
351 | // we can quickly save and restore it when an orientation change happens.
352 | // Members of this class are not allowed to contain any references to the
353 | // view hierarchy.
354 | private static class State
355 | {
356 | // Bitmap containing the outlines that are never changed.
357 |
358 | private Bitmap _outlineBitmap;
359 | // Bitmap containing everything we have painted so far.
360 | private Bitmap _paintedBitmap;
361 | // Dimensions of both bitmaps.
362 | private int _height;
363 | private int _width;
364 | // Paint with the currently selected color.
365 | private int _color;
366 | // paintMask has 0 for each pixel that cannot be modified and 1
367 | // for each one that can.
368 | private byte _paintMask[];
369 | // workingMask is in fact only needed during the fill - it is a copy
370 | // of paintMask that is modified during the fill. To avoid reallocating
371 | // it each time we store it as a member.
372 | private byte _workingMask[];
373 | // All the pixels in _paintedBitmap. Because accessing an int array is
374 | // much faster than accessing pixels in a bitmap, we operate on this
375 | // and use setPixels() on the bitmap to copy them back.
376 | private int _pixels[];
377 | }
378 | private State _state;
379 | private Paint _paint;
380 | }
381 |
--------------------------------------------------------------------------------
/src/main/java/org/androidsoft/coloring/ui/activity/PaintActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Peter Dornbach.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.androidsoft.coloring.ui.activity;
17 |
18 | import org.androidsoft.coloring.ui.widget.PaintView;
19 | import org.androidsoft.coloring.ui.widget.ColorButton;
20 | import org.androidsoft.coloring.ui.widget.Progress;
21 | import java.io.File;
22 | import java.text.DateFormat;
23 | import java.text.SimpleDateFormat;
24 | import java.util.Date;
25 | import java.util.Iterator;
26 | import java.util.LinkedList;
27 |
28 | import android.app.Dialog;
29 | import android.app.ProgressDialog;
30 | import android.content.ContentValues;
31 | import android.content.Context;
32 | import android.content.Intent;
33 | import android.graphics.Bitmap;
34 | import android.graphics.BitmapFactory;
35 | import android.media.MediaScannerConnection;
36 | import android.media.MediaScannerConnection.MediaScannerConnectionClient;
37 | import android.net.Uri;
38 | import android.os.Bundle;
39 | import android.os.Environment;
40 | import android.os.Handler;
41 | import android.os.Message;
42 | import android.provider.MediaStore.Images;
43 | import android.view.Menu;
44 | import android.view.MenuItem;
45 | import android.view.View;
46 | import android.widget.ProgressBar;
47 | import java.util.List;
48 | import java.util.ArrayList;
49 | import org.androidsoft.coloring.R;
50 |
51 | public class PaintActivity extends AbstractColoringActivity implements
52 | PaintView.LifecycleListener
53 | {
54 |
55 | public static final String FILE_BACKUP = "backup";
56 |
57 | public PaintActivity()
58 | {
59 | _state = new State();
60 | }
61 |
62 | @Override
63 | public void onCreate(Bundle savedInstanceState)
64 | {
65 | super.onCreate(savedInstanceState);
66 |
67 | setContentView(R.layout.paint);
68 | _paintView = (PaintView) findViewById(R.id.paint_view);
69 | _paintView.setLifecycleListener(this);
70 | _progressBar = (ProgressBar) findViewById(R.id.paint_progress);
71 | _progressBar.setMax(Progress.MAX);
72 | _colorButtonManager = new ColorButtonManager();
73 | View pickColorsButton = findViewById(R.id.pick_color_button);
74 | pickColorsButton.setOnClickListener(new PickColorListener());
75 |
76 | final Object previousState = getLastNonConfigurationInstance();
77 | if (previousState == null)
78 | {
79 | // No previous state, this is truly a new activity.
80 | // We need to make the paint view INVISIBLE (and not GONE) so that
81 | // it can measure itself correctly.
82 | _paintView.setVisibility(View.INVISIBLE);
83 | _progressBar.setVisibility(View.GONE);
84 | }
85 | else
86 | {
87 | // We have a previous state, so this is a re-created activity.
88 | // Restore the state of the activity.
89 | SavedState state = (SavedState) previousState;
90 | _state = state._paintActivityState;
91 | _paintView.setState(state._paintViewState);
92 | _colorButtonManager.setState(state._colorButtonState);
93 | _paintView.setVisibility(View.VISIBLE);
94 | _progressBar.setVisibility(View.GONE);
95 | if (_state._loadInProgress)
96 | {
97 | new InitPaintView(_state._loadedResourceId);
98 | }
99 | }
100 | }
101 |
102 | @Override
103 | public boolean onCreateOptionsMenu(Menu menu)
104 | {
105 | getMenuInflater().inflate(R.menu.paint_menu, menu);
106 | return true;
107 | }
108 |
109 | public void onPreparedToLoad()
110 | {
111 | // We need to invoke InitPaintView in a callback otherwise
112 | // the visibility changes do not seem to be effective.
113 | new Handler()
114 | {
115 |
116 | @Override
117 | public void handleMessage(Message m)
118 | {
119 | new InitPaintView(StartNewActivity.randomOutlineId());
120 | }
121 | }.sendEmptyMessage(0);
122 | }
123 |
124 | @Override
125 | public boolean onOptionsItemSelected(MenuItem item)
126 | {
127 | switch (item.getItemId())
128 | {
129 | case R.id.open_new:
130 | startActivityForResult(new Intent(INTENT_START_NEW), REQUEST_START_NEW);
131 | return true;
132 | case R.id.save:
133 | new BitmapSaver();
134 | return true;
135 | case R.id.about:
136 | startActivity(new Intent(INTENT_ABOUT));
137 | return true;
138 | case R.id.share:
139 | new BitmapSharer();
140 | return true;
141 | }
142 | return false;
143 | }
144 |
145 |
146 | @Override
147 | public Object onRetainNonConfigurationInstance()
148 | {
149 | SavedState state = new SavedState();
150 | state._paintActivityState = _state;
151 | state._paintViewState = _paintView.getState();
152 | state._colorButtonState = _colorButtonManager.getState();
153 | return state;
154 | }
155 |
156 | @Override
157 | protected void onActivityResult(int requestCode, int resultCode, Intent data)
158 | {
159 | switch (requestCode)
160 | {
161 | case REQUEST_START_NEW:
162 | if (resultCode != 0)
163 | {
164 | new InitPaintView(resultCode);
165 | }
166 | break;
167 | case REQUEST_PICK_COLOR:
168 | if (resultCode != 0)
169 | {
170 | _colorButtonManager.selectColor(resultCode);
171 | }
172 | break;
173 | }
174 | }
175 |
176 | // @Override
177 | @Override
178 | protected Dialog onCreateDialog(int id)
179 | {
180 | switch (id)
181 | {
182 | case DIALOG_PROGRESS:
183 | _progressDialog = new ProgressDialog(PaintActivity.this);
184 | _progressDialog.setCancelable(false);
185 | _progressDialog.setIcon(android.R.drawable.ic_dialog_info);
186 | _progressDialog.setTitle(R.string.dialog_saving);
187 | _progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
188 | _progressDialog.setMax(Progress.MAX);
189 | if (!_saveInProgress)
190 | {
191 | // This means that the view hierarchy was recreated but there
192 | // is no actual save in progress (in this hierarchy), so let's
193 | // dismiss the dialog.
194 | new Handler()
195 | {
196 |
197 | @Override
198 | public void handleMessage(Message m)
199 | {
200 | _progressDialog.dismiss();
201 | }
202 | }.sendEmptyMessage(0);
203 | }
204 |
205 | return _progressDialog;
206 | }
207 | return null;
208 | }
209 |
210 | private class PickColorListener implements View.OnClickListener
211 | {
212 |
213 | public void onClick(View view)
214 | {
215 | startActivityForResult(new Intent(INTENT_PICK_COLOR), REQUEST_PICK_COLOR);
216 | }
217 | }
218 |
219 | private class ColorButtonManager implements View.OnClickListener
220 | {
221 |
222 | public ColorButtonManager()
223 | {
224 | findAllColorButtons(_colorButtons);
225 | _usedColorButtons.addAll(_colorButtons);
226 | _selectedColorButton = _usedColorButtons.getFirst();
227 | _selectedColorButton.setSelected(true);
228 | Iterator i = _usedColorButtons.iterator();
229 | while (i.hasNext())
230 | {
231 | i.next().setOnClickListener(ColorButtonManager.this);
232 | }
233 | setPaintViewColor();
234 | }
235 |
236 | public void onClick(View view)
237 | {
238 | if (view instanceof ColorButton)
239 | {
240 | selectButton((ColorButton) view);
241 | }
242 | }
243 |
244 | // Select the button that has the given color, or if there is no such
245 | // button then set the least recently used button to have that color.
246 | public void selectColor(int color)
247 | {
248 | _selectedColorButton = selectAndRemove(color);
249 | if (_selectedColorButton == null)
250 | {
251 | // Recycle the last used button to hold the new color.
252 | _selectedColorButton = _usedColorButtons.removeLast();
253 | _selectedColorButton.setColor(color);
254 | _selectedColorButton.setSelected(true);
255 | }
256 | _usedColorButtons.addFirst(_selectedColorButton);
257 | setPaintViewColor();
258 | }
259 |
260 | public Object getState()
261 | {
262 | int[] result = new int[_colorButtons.size() + 1];
263 | int n = _colorButtons.size();
264 | for (int i = 0; i < n; i++)
265 | {
266 | result[i] = _colorButtons.get(i).getColor();
267 | }
268 | result[n] = _selectedColorButton.getColor();
269 | return result;
270 | }
271 |
272 | public void setState(Object o)
273 | {
274 | int[] state = (int[]) o;
275 | int n = _colorButtons.size();
276 | for (int i = 0; i < n; i++)
277 | {
278 | _colorButtons.get(i).setColor(state[i]);
279 | }
280 | selectColor(state[n]);
281 | }
282 |
283 | // Select the given button.
284 | private void selectButton(ColorButton button)
285 | {
286 | _selectedColorButton = selectAndRemove(button.getColor());
287 | _usedColorButtons.addFirst(_selectedColorButton);
288 | setPaintViewColor();
289 | }
290 |
291 | // Set the currently selected color in the paint view.
292 | private void setPaintViewColor()
293 | {
294 | _paintView.setPaintColor(_selectedColorButton.getColor());
295 | }
296 |
297 | // Finds the button with the color. If found, sets it to selected,
298 | // removes it and returns it. If not found, it returns null. All
299 | // other buttons are unselected.
300 | private ColorButton selectAndRemove(int color)
301 | {
302 | ColorButton result = null;
303 | Iterator i = _usedColorButtons.iterator();
304 | while (i.hasNext())
305 | {
306 | ColorButton b = i.next();
307 | if (b.getColor() == color)
308 | {
309 | result = b;
310 | b.setSelected(true);
311 | i.remove();
312 | }
313 | else
314 | {
315 | b.setSelected(false);
316 | }
317 | }
318 | return result;
319 | }
320 | // A list of pointers to all buttons in the order
321 | // in which they have been used.
322 | private List _colorButtons = new ArrayList();
323 | private LinkedList _usedColorButtons = new LinkedList();
324 | private ColorButton _selectedColorButton;
325 | }
326 |
327 | private class InitPaintView implements Runnable
328 | {
329 |
330 | public InitPaintView(int outlineResourceId)
331 | {
332 | // Make the progress bar visible and hide the view
333 | _paintView.setVisibility(View.GONE);
334 | _progressBar.setProgress(0);
335 | _progressBar.setVisibility(View.VISIBLE);
336 | _state._savedImageUri = null;
337 |
338 | _state._loadInProgress = true;
339 | _state._loadedResourceId = outlineResourceId;
340 | _originalOutlineBitmap = BitmapFactory.decodeResource(getResources(),
341 | outlineResourceId);
342 | _handler = new Handler()
343 | {
344 |
345 | @Override
346 | public void handleMessage(Message m)
347 | {
348 | switch (m.what)
349 | {
350 | case Progress.MESSAGE_INCREMENT_PROGRESS:
351 | // Update progress bar.
352 | _progressBar.incrementProgressBy(m.arg1);
353 | break;
354 | case Progress.MESSAGE_DONE_OK:
355 | case Progress.MESSAGE_DONE_ERROR:
356 | // We are done, hide the progress bar and turn
357 | // the paint view back on.
358 | _state._loadInProgress = false;
359 | _paintView.setVisibility(View.VISIBLE);
360 | _progressBar.setVisibility(View.GONE);
361 | break;
362 | }
363 | }
364 | };
365 |
366 | new Thread(this).start();
367 | }
368 |
369 | public void run()
370 | {
371 | _paintView.loadFromBitmap(_originalOutlineBitmap, _handler);
372 | }
373 | private Bitmap _originalOutlineBitmap;
374 | private Handler _handler;
375 | }
376 |
377 | // Class needed to work-around gallery crash bug. If we do not have this
378 | // scanner then the save succeeds but the Pictures app will crash when
379 | // trying to open.
380 | private class MediaScannerNotifier implements MediaScannerConnectionClient
381 | {
382 |
383 | public MediaScannerNotifier(Context context, String path, String mimeType)
384 | {
385 | _path = path;
386 | _mimeType = mimeType;
387 | _connection = new MediaScannerConnection(context, this);
388 | _connection.connect();
389 | }
390 |
391 | public void onMediaScannerConnected()
392 | {
393 | _connection.scanFile(_path, _mimeType);
394 | }
395 |
396 | public void onScanCompleted(String path, final Uri uri)
397 | {
398 | _connection.disconnect();
399 | }
400 | private MediaScannerConnection _connection;
401 | private String _path;
402 | private String _mimeType;
403 | }
404 |
405 | public static interface OnSavedListener
406 | {
407 |
408 | void onSaved(String filename);
409 | }
410 |
411 | private class BitmapSaver implements Runnable
412 | {
413 |
414 | public BitmapSaver()
415 | {
416 | class DelayHandler extends Handler
417 | {
418 |
419 | @Override
420 | public void handleMessage(Message m)
421 | {
422 | // We are done, hide the progress bar and turn
423 | // the paint view back on.
424 | _saveInProgress = false;
425 | _progressDialog.dismiss();
426 | }
427 | }
428 |
429 | class ProgressHandler extends Handler
430 | {
431 |
432 | @Override
433 | public void handleMessage(Message m)
434 | {
435 | switch (m.what)
436 | {
437 | case Progress.MESSAGE_INCREMENT_PROGRESS:
438 | // Update progress bar.
439 | _progressDialog.incrementProgressBy(m.arg1);
440 | break;
441 | case Progress.MESSAGE_DONE_OK:
442 | case Progress.MESSAGE_DONE_ERROR:
443 | if (m.what == Progress.MESSAGE_DONE_OK)
444 | {
445 | finishSaving();
446 | }
447 | String title = getString(R.string.dialog_saving);
448 | if (m.what == Progress.MESSAGE_DONE_OK)
449 | {
450 | title += getString(R.string.dialog_saving_ok);
451 | }
452 | else
453 | {
454 | title += getString(R.string.dialog_saving_error);
455 | }
456 | _progressDialog.setTitle(title);
457 | new DelayHandler().sendEmptyMessageDelayed(0,
458 | SAVE_DIALOG_WAIT_MILLIS);
459 | break;
460 | }
461 | }
462 | }
463 |
464 | if (_paintView.isInitialized())
465 | {
466 | _saveInProgress = true;
467 | showDialog(DIALOG_PROGRESS);
468 | _progressDialog.setTitle(R.string.dialog_saving);
469 | _progressDialog.setProgress(0);
470 | _originalOutlineBitmap = BitmapFactory.decodeResource(getResources(),
471 | _state._loadedResourceId);
472 | _progressHandler = new ProgressHandler();
473 | new Thread(this).start();
474 | }
475 | }
476 |
477 | public void run()
478 | {
479 | // Get a filename.
480 | _fileName = newImageFileName();
481 | _file = new File(Environment.getExternalStorageDirectory(),
482 | getString(R.string.saved_image_path_prefix) + _fileName + ".png");
483 |
484 | // Save the bitmap to a file.
485 | _paintView.saveToFile(_file, _originalOutlineBitmap, _progressHandler);
486 | }
487 |
488 | protected void finishSaving()
489 | {
490 | // Save it to the MediaStore.
491 | ContentValues values = new ContentValues();
492 | values.put(Images.Media.TITLE, _fileName);
493 | values.put(Images.Media.DISPLAY_NAME, _fileName);
494 | values.put(Images.Media.MIME_TYPE, MIME_PNG);
495 | values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
496 | values.put(Images.Media.DATA, _file.toString());
497 | File parentFile = _file.getParentFile();
498 | values.put(Images.Media.BUCKET_ID,
499 | parentFile.toString().toLowerCase().hashCode());
500 | values.put(Images.Media.BUCKET_DISPLAY_NAME,
501 | parentFile.getName().toLowerCase());
502 | _newImageUri = getContentResolver().insert(
503 | Images.Media.EXTERNAL_CONTENT_URI, values);
504 |
505 | // Delete the old version, if we have any.
506 | if (_state._savedImageUri != null)
507 | {
508 | getContentResolver().delete(_state._savedImageUri, null, null);
509 | }
510 | _state._savedImageUri = _newImageUri;
511 |
512 | // Scan the file so that it appears in the system as it should.
513 | if (_newImageUri != null)
514 | {
515 | new MediaScannerNotifier(PaintActivity.this, _file.toString(), MIME_PNG);
516 | }
517 | }
518 |
519 | private String newImageFileName()
520 | {
521 | final DateFormat fmt = new SimpleDateFormat("yyyyMMdd-HHmmss");
522 | return fmt.format(new Date());
523 | }
524 | private Bitmap _originalOutlineBitmap;
525 | private String _fileName;
526 | private File _file;
527 | private Handler _progressHandler;
528 | protected Uri _newImageUri;
529 | }
530 |
531 | private class BitmapSharer extends BitmapSaver
532 | {
533 |
534 | public BitmapSharer()
535 | {
536 | super();
537 | }
538 |
539 | @Override
540 | protected void finishSaving()
541 | {
542 | super.finishSaving();
543 |
544 | if (_newImageUri != null)
545 | {
546 | Intent sharingIntent = new Intent(Intent.ACTION_SEND);
547 | sharingIntent.setType("image/png");
548 | sharingIntent.putExtra(Intent.EXTRA_STREAM, _newImageUri);
549 | startActivity(Intent.createChooser(sharingIntent, getString( R.string.dialog_share )));
550 | }
551 | }
552 | }
553 |
554 | // The state of the whole drawing. This is used to transfer the state if
555 | // the activity is re-created (e.g. due to orientation change).
556 | private static class SavedState
557 | {
558 |
559 | public State _paintActivityState;
560 | public Object _colorButtonState;
561 | public Object _paintViewState;
562 | }
563 |
564 | private static class State
565 | {
566 | // Are we just loading a new outline?
567 |
568 | public boolean _loadInProgress;
569 | // The resource ID of the outline we are coloring.
570 | public int _loadedResourceId;
571 | // If we have already saved a copy of the image, we store the URI here
572 | // so that we can delete the previous version when saved again.
573 | public Uri _savedImageUri;
574 | }
575 | private static final int REQUEST_START_NEW = 0;
576 | private static final int REQUEST_PICK_COLOR = 1;
577 | private static final int DIALOG_PROGRESS = 1;
578 | private static final int SAVE_DIALOG_WAIT_MILLIS = 1500;
579 | private static final String MIME_PNG = "image/png";
580 | // The state that we will carry over if the activity is recreated.
581 | private State _state;
582 | // Main UI elements.
583 | private PaintView _paintView;
584 | private ProgressBar _progressBar;
585 | private ProgressDialog _progressDialog;
586 | // The ColorButtonManager makes sure the state of the ColorButtons visible
587 | // on this activity is in sync.
588 | private ColorButtonManager _colorButtonManager;
589 | // Is there a save in progress?
590 | private boolean _saveInProgress;
591 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------