| author | Tomas Zeman <tzeman@volny.cz> |
| Fri, 10 Jan 2014 12:24:07 +0100 | |
| changeset 1 | c3780fcb8441 |
| child 3 | a41c0d4e533c |
| permissions | -rw-r--r-- |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
1 |
package tz.signaturecapture; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
2 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
3 |
import java.io.File; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
4 |
import java.io.FileOutputStream; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
5 |
import java.util.Calendar; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
6 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
7 |
import android.app.Activity; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
8 |
import android.content.Context; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
9 |
import android.content.ContextWrapper; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
10 |
import android.content.Intent; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
11 |
import android.graphics.Bitmap; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
12 |
import android.graphics.Canvas; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
13 |
import android.graphics.Color; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
14 |
import android.graphics.Paint; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
15 |
import android.graphics.Path; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
16 |
import android.graphics.RectF; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
17 |
import android.os.Bundle; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
18 |
import android.os.Environment; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
19 |
import android.provider.MediaStore.Images; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
20 |
import android.util.AttributeSet; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
21 |
import android.util.Log; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
22 |
import android.view.Gravity; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
23 |
import android.view.MotionEvent; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
24 |
import android.view.View; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
25 |
import android.view.View.OnClickListener; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
26 |
import android.view.ViewGroup.LayoutParams; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
27 |
import android.view.Window; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
28 |
import android.widget.Button; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
29 |
import android.widget.EditText; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
30 |
import android.widget.LinearLayout; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
31 |
import android.widget.Toast; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
32 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
33 |
public class CaptureSignature extends Activity {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
34 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
35 |
LinearLayout mContent; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
36 |
signature mSignature; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
37 |
Button mClear, mGetSign, mCancel; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
38 |
public static String tempDir; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
39 |
public int count = 1; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
40 |
public String current = null; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
41 |
private Bitmap mBitmap; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
42 |
View mView; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
43 |
File mypath; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
44 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
45 |
private String uniqueId; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
46 |
private EditText yourName; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
47 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
48 |
@Override |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
49 |
public void onCreate(Bundle savedInstanceState) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
50 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
51 |
super.onCreate(savedInstanceState); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
52 |
this.requestWindowFeature(Window.FEATURE_NO_TITLE); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
53 |
setContentView(R.layout.signature); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
54 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
55 |
tempDir = Environment.getExternalStorageDirectory() + "/" + getResources().getString(R.string.external_dir) + "/"; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
56 |
ContextWrapper cw = new ContextWrapper(getApplicationContext()); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
57 |
File directory = cw.getDir(getResources().getString(R.string.external_dir), Context.MODE_PRIVATE); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
58 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
59 |
prepareDirectory(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
60 |
uniqueId = getTodaysDate() + "_" + getCurrentTime() + "_" + Math.random(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
61 |
current = uniqueId + ".png"; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
62 |
mypath= new File(directory,current); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
63 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
64 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
65 |
mContent = (LinearLayout) findViewById(R.id.linearLayout); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
66 |
mSignature = new signature(this, null); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
67 |
mSignature.setBackgroundColor(Color.WHITE); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
68 |
mContent.addView(mSignature, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
69 |
mClear = (Button)findViewById(R.id.clear); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
70 |
mGetSign = (Button)findViewById(R.id.getsign); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
71 |
mGetSign.setEnabled(false); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
72 |
mCancel = (Button)findViewById(R.id.cancel); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
73 |
mView = mContent; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
74 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
75 |
yourName = (EditText) findViewById(R.id.yourName); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
76 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
77 |
mClear.setOnClickListener(new OnClickListener() |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
78 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
79 |
public void onClick(View v) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
80 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
81 |
Log.v("log_tag", "Panel Cleared");
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
82 |
mSignature.clear(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
83 |
mGetSign.setEnabled(false); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
84 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
85 |
}); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
86 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
87 |
mGetSign.setOnClickListener(new OnClickListener() |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
88 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
89 |
public void onClick(View v) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
90 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
91 |
Log.v("log_tag", "Panel Saved");
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
92 |
boolean error = captureSignature(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
93 |
if(!error){
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
94 |
mView.setDrawingCacheEnabled(true); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
95 |
mSignature.save(mView); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
96 |
Bundle b = new Bundle(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
97 |
b.putString("status", "done");
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
98 |
Intent intent = new Intent(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
99 |
intent.putExtras(b); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
100 |
setResult(RESULT_OK,intent); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
101 |
finish(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
102 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
103 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
104 |
}); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
105 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
106 |
mCancel.setOnClickListener(new OnClickListener() |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
107 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
108 |
public void onClick(View v) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
109 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
110 |
Log.v("log_tag", "Panel Canceled");
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
111 |
Bundle b = new Bundle(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
112 |
b.putString("status", "cancel");
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
113 |
Intent intent = new Intent(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
114 |
intent.putExtras(b); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
115 |
setResult(RESULT_OK,intent); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
116 |
finish(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
117 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
118 |
}); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
119 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
120 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
121 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
122 |
@Override |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
123 |
protected void onDestroy() {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
124 |
Log.w("GetSignature", "onDestory");
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
125 |
super.onDestroy(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
126 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
127 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
128 |
private boolean captureSignature() {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
129 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
130 |
boolean error = false; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
131 |
String errorMessage = ""; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
132 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
133 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
134 |
if(yourName.getText().toString().equalsIgnoreCase("")){
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
135 |
errorMessage = errorMessage + "Please enter your Name\n"; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
136 |
error = true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
137 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
138 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
139 |
if(error){
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
140 |
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
141 |
toast.setGravity(Gravity.TOP, 105, 50); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
142 |
toast.show(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
143 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
144 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
145 |
return error; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
146 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
147 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
148 |
private String getTodaysDate() {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
149 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
150 |
final Calendar c = Calendar.getInstance(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
151 |
int todaysDate = (c.get(Calendar.YEAR) * 10000) + |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
152 |
((c.get(Calendar.MONTH) + 1) * 100) + |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
153 |
(c.get(Calendar.DAY_OF_MONTH)); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
154 |
Log.w("DATE:",String.valueOf(todaysDate));
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
155 |
return(String.valueOf(todaysDate)); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
156 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
157 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
158 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
159 |
private String getCurrentTime() {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
160 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
161 |
final Calendar c = Calendar.getInstance(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
162 |
int currentTime = (c.get(Calendar.HOUR_OF_DAY) * 10000) + |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
163 |
(c.get(Calendar.MINUTE) * 100) + |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
164 |
(c.get(Calendar.SECOND)); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
165 |
Log.w("TIME:",String.valueOf(currentTime));
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
166 |
return(String.valueOf(currentTime)); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
167 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
168 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
169 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
170 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
171 |
private boolean prepareDirectory() |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
172 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
173 |
try |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
174 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
175 |
if (makedirs()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
176 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
177 |
return true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
178 |
} else {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
179 |
return false; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
180 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
181 |
} catch (Exception e) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
182 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
183 |
e.printStackTrace(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
184 |
Toast.makeText(this, "Could not initiate File System.. Is Sdcard mounted properly?", 1000).show(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
185 |
return false; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
186 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
187 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
188 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
189 |
private boolean makedirs() |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
190 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
191 |
File tempdir = new File(tempDir); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
192 |
if (!tempdir.exists()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
193 |
tempdir.mkdirs(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
194 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
195 |
if (tempdir.isDirectory()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
196 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
197 |
File[] files = tempdir.listFiles(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
198 |
for (File file : files) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
199 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
200 |
if (!file.delete()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
201 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
202 |
System.out.println("Failed to delete " + file);
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
203 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
204 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
205 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
206 |
return (tempdir.isDirectory()); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
207 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
208 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
209 |
public class signature extends View |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
210 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
211 |
private static final float STROKE_WIDTH = 5f; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
212 |
private static final float HALF_STROKE_WIDTH = STROKE_WIDTH / 2; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
213 |
private Paint paint = new Paint(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
214 |
private Path path = new Path(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
215 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
216 |
private float lastTouchX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
217 |
private float lastTouchY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
218 |
private final RectF dirtyRect = new RectF(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
219 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
220 |
public signature(Context context, AttributeSet attrs) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
221 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
222 |
super(context, attrs); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
223 |
paint.setAntiAlias(true); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
224 |
paint.setColor(Color.BLACK); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
225 |
paint.setStyle(Paint.Style.STROKE); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
226 |
paint.setStrokeJoin(Paint.Join.ROUND); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
227 |
paint.setStrokeWidth(STROKE_WIDTH); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
228 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
229 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
230 |
public void save(View v) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
231 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
232 |
Log.v("log_tag", "Width: " + v.getWidth());
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
233 |
Log.v("log_tag", "Height: " + v.getHeight());
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
234 |
if(mBitmap == null) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
235 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
236 |
mBitmap = Bitmap.createBitmap (mContent.getWidth(), mContent.getHeight(), Bitmap.Config.RGB_565);; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
237 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
238 |
Canvas canvas = new Canvas(mBitmap); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
239 |
try |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
240 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
241 |
FileOutputStream mFileOutStream = new FileOutputStream(mypath); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
242 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
243 |
v.draw(canvas); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
244 |
mBitmap.compress(Bitmap.CompressFormat.PNG, 90, mFileOutStream); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
245 |
mFileOutStream.flush(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
246 |
mFileOutStream.close(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
247 |
String url = Images.Media.insertImage(getContentResolver(), mBitmap, "title", null); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
248 |
Log.v("log_tag","url: " + url);
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
249 |
//In case you want to delete the file |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
250 |
//boolean deleted = mypath.delete(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
251 |
//Log.v("log_tag","deleted: " + mypath.toString() + deleted);
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
252 |
//If you want to convert the image to string use base64 converter |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
253 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
254 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
255 |
catch(Exception e) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
256 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
257 |
Log.v("log_tag", e.toString());
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
258 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
259 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
260 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
261 |
public void clear() |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
262 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
263 |
path.reset(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
264 |
invalidate(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
265 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
266 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
267 |
@Override |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
268 |
protected void onDraw(Canvas canvas) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
269 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
270 |
canvas.drawPath(path, paint); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
271 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
272 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
273 |
@Override |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
274 |
public boolean onTouchEvent(MotionEvent event) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
275 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
276 |
float eventX = event.getX(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
277 |
float eventY = event.getY(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
278 |
mGetSign.setEnabled(true); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
279 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
280 |
switch (event.getAction()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
281 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
282 |
case MotionEvent.ACTION_DOWN: |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
283 |
path.moveTo(eventX, eventY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
284 |
lastTouchX = eventX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
285 |
lastTouchY = eventY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
286 |
return true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
287 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
288 |
case MotionEvent.ACTION_MOVE: |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
289 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
290 |
case MotionEvent.ACTION_UP: |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
291 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
292 |
resetDirtyRect(eventX, eventY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
293 |
int historySize = event.getHistorySize(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
294 |
for (int i = 0; i < historySize; i++) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
295 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
296 |
float historicalX = event.getHistoricalX(i); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
297 |
float historicalY = event.getHistoricalY(i); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
298 |
expandDirtyRect(historicalX, historicalY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
299 |
path.lineTo(historicalX, historicalY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
300 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
301 |
path.lineTo(eventX, eventY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
302 |
break; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
303 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
304 |
default: |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
305 |
debug("Ignored touch event: " + event.toString());
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
306 |
return false; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
307 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
308 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
309 |
invalidate((int) (dirtyRect.left - HALF_STROKE_WIDTH), |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
310 |
(int) (dirtyRect.top - HALF_STROKE_WIDTH), |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
311 |
(int) (dirtyRect.right + HALF_STROKE_WIDTH), |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
312 |
(int) (dirtyRect.bottom + HALF_STROKE_WIDTH)); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
313 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
314 |
lastTouchX = eventX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
315 |
lastTouchY = eventY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
316 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
317 |
return true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
318 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
319 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
320 |
private void debug(String string){
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
321 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
322 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
323 |
private void expandDirtyRect(float historicalX, float historicalY) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
324 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
325 |
if (historicalX < dirtyRect.left) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
326 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
327 |
dirtyRect.left = historicalX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
328 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
329 |
else if (historicalX > dirtyRect.right) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
330 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
331 |
dirtyRect.right = historicalX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
332 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
333 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
334 |
if (historicalY < dirtyRect.top) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
335 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
336 |
dirtyRect.top = historicalY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
337 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
338 |
else if (historicalY > dirtyRect.bottom) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
339 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
340 |
dirtyRect.bottom = historicalY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
341 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
342 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
343 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
344 |
private void resetDirtyRect(float eventX, float eventY) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
345 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
346 |
dirtyRect.left = Math.min(lastTouchX, eventX); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
347 |
dirtyRect.right = Math.max(lastTouchX, eventX); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
348 |
dirtyRect.top = Math.min(lastTouchY, eventY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
349 |
dirtyRect.bottom = Math.max(lastTouchY, eventY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
350 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
351 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
352 |
} |