| author | Tomas Zeman <tzeman@volny.cz> |
| Fri, 10 Jan 2014 12:50:46 +0100 | |
| changeset 3 | a41c0d4e533c |
| parent 1 | c3780fcb8441 |
| child 5 | 19822c932652 |
| 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; |
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
5 |
import java.io.IOException; |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
6 |
import java.io.OutputStream; |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
7 |
import java.util.Calendar; |
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
8 |
|
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
9 |
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
|
10 |
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
|
11 |
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
|
12 |
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
|
13 |
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
|
14 |
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
|
15 |
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
|
16 |
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
|
17 |
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
|
18 |
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
|
19 |
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
|
20 |
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
|
21 |
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
|
22 |
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
|
23 |
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
|
24 |
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
|
25 |
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
|
26 |
import android.view.View.OnClickListener; |
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
27 |
import android.view.View.OnTouchListener; |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
28 |
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
|
29 |
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
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
35 |
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
|
36 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
37 |
LinearLayout mContent; |
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
38 |
SignatureWidget mSignature; |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
View mView; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
44 |
File mypath; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
45 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
46 |
private String uniqueId; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
47 |
private EditText yourName; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
48 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
49 |
@Override |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
50 |
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
|
51 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
52 |
super.onCreate(savedInstanceState); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
53 |
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
|
54 |
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
|
55 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
60 |
prepareDirectory(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
61 |
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
|
62 |
current = uniqueId + ".png"; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
63 |
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
|
64 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
65 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
66 |
mContent = (LinearLayout) findViewById(R.id.linearLayout); |
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
67 |
mSignature = new SignatureWidget(this, null); |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
68 |
mSignature.setBackgroundColor(Color.WHITE); |
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
69 |
mSignature.setOnTouchListener(new OnTouchListener() {
|
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
70 |
@Override |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
71 |
public boolean onTouch(View v, MotionEvent event) {
|
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
72 |
mGetSign.setEnabled(true); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
73 |
return false; |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
74 |
} |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
75 |
}); |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
mGetSign.setEnabled(false); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
80 |
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
|
81 |
mView = mContent; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
82 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
83 |
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
|
84 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
85 |
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
|
86 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
87 |
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
|
88 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
89 |
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
|
90 |
mSignature.clear(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
91 |
mGetSign.setEnabled(false); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
92 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
93 |
}); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
94 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
95 |
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
|
96 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
97 |
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
|
98 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
99 |
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
|
100 |
boolean error = captureSignature(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
101 |
if(!error){
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
102 |
mView.setDrawingCacheEnabled(true); |
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
103 |
try {
|
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
104 |
FileOutputStream os = new FileOutputStream(mypath); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
105 |
mSignature.save(mView, os); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
106 |
os.flush(); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
107 |
os.close(); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
108 |
setResult(RESULT_OK, new Intent().putExtra("status",
|
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
109 |
"done")); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
110 |
finish(); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
111 |
} catch (IOException e) {
|
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
112 |
Toast.makeText(CaptureSignature.this, String.format( |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
113 |
"Failed to save signature: %", e.getMessage()), |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
114 |
Toast.LENGTH_LONG).show(); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
115 |
} |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
116 |
|
|
1
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 |
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
|
122 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
123 |
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
|
124 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
125 |
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
|
126 |
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
|
127 |
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
|
128 |
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
|
129 |
intent.putExtras(b); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
130 |
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
|
131 |
finish(); |
|
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 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
135 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
136 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
137 |
@Override |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
138 |
protected void onDestroy() {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
139 |
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
|
140 |
super.onDestroy(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
141 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
142 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
143 |
private boolean captureSignature() {
|
|
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 |
boolean error = false; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
146 |
String errorMessage = ""; |
|
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 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
149 |
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
|
150 |
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
|
151 |
error = true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
152 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
153 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
154 |
if(error){
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
toast.show(); |
|
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 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
160 |
return error; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
161 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
162 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
163 |
private String getTodaysDate() {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
164 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
165 |
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
|
166 |
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
|
167 |
((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
|
168 |
(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
|
169 |
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
|
170 |
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
|
171 |
|
|
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 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
174 |
private String getCurrentTime() {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
175 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
176 |
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
|
177 |
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
|
178 |
(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
|
179 |
(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
|
180 |
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
|
181 |
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
|
182 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
183 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
184 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
185 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
186 |
private boolean prepareDirectory() |
|
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 |
try |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
189 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
190 |
if (makedirs()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
191 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
192 |
return true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
193 |
} else {
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
194 |
return false; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
195 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
196 |
} catch (Exception e) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
197 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
198 |
e.printStackTrace(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
199 |
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
|
200 |
return false; |
|
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 |
} |
|
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 |
private boolean makedirs() |
|
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 |
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
|
207 |
if (!tempdir.exists()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
208 |
tempdir.mkdirs(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
209 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
210 |
if (tempdir.isDirectory()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
211 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
212 |
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
|
213 |
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
|
214 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
215 |
if (!file.delete()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
216 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
217 |
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
|
218 |
} |
|
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 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
221 |
return (tempdir.isDirectory()); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
222 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
223 |
|
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
224 |
public static class SignatureWidget extends View |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
225 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
226 |
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
|
227 |
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
|
228 |
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
|
229 |
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
|
230 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
231 |
private float lastTouchX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
232 |
private float lastTouchY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
233 |
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
|
234 |
|
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
235 |
public SignatureWidget(Context context, AttributeSet attrs) |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
236 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
237 |
super(context, attrs); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
238 |
paint.setAntiAlias(true); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
239 |
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
|
240 |
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
|
241 |
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
|
242 |
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
|
243 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
244 |
|
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
245 |
public void save(View parent, OutputStream os) |
|
1
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
246 |
{
|
|
3
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
247 |
Log.v("log_tag", "Width: " + parent.getWidth());
|
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
248 |
Log.v("log_tag", "Height: " + parent.getHeight());
|
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
249 |
Bitmap bm = Bitmap.createBitmap(parent.getWidth(), parent.getHeight(), Bitmap.Config.RGB_565);; |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
250 |
Canvas canvas = new Canvas(bm); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
251 |
parent.draw(canvas); |
|
a41c0d4e533c
CaptureSignature: refactored signature into SignatureWidget (static inner class)
Tomas Zeman <tzeman@volny.cz>
parents:
1
diff
changeset
|
252 |
bm.compress(Bitmap.CompressFormat.PNG, 90, os); |
|
1
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 |
public void clear() |
|
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 |
path.reset(); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
258 |
invalidate(); |
|
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 |
@Override |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
262 |
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
|
263 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
264 |
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
|
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 |
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
|
269 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
273 |
switch (event.getAction()) |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
274 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
275 |
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
|
276 |
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
|
277 |
lastTouchX = eventX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
278 |
lastTouchY = eventY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
279 |
return true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
280 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
281 |
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
|
282 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
283 |
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
|
284 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
285 |
resetDirtyRect(eventX, eventY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
286 |
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
|
287 |
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
|
288 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
289 |
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
|
290 |
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
|
291 |
expandDirtyRect(historicalX, historicalY); |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
292 |
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
|
293 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
294 |
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
|
295 |
break; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
296 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
297 |
default: |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
298 |
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
|
299 |
return false; |
|
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 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
302 |
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
|
303 |
(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
|
304 |
(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
|
305 |
(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
|
306 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
307 |
lastTouchX = eventX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
308 |
lastTouchY = eventY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
309 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
310 |
return true; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
311 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
312 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
313 |
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
|
314 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
315 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
316 |
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
|
317 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
318 |
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
|
319 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
320 |
dirtyRect.left = historicalX; |
|
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 |
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
|
323 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
324 |
dirtyRect.right = historicalX; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
325 |
} |
|
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 |
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
|
328 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
329 |
dirtyRect.top = historicalY; |
|
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 |
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
|
332 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
333 |
dirtyRect.bottom = historicalY; |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
334 |
} |
|
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 |
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
337 |
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
|
338 |
{
|
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
339 |
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
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
344 |
} |
|
c3780fcb8441
Imported code from the blog post (renamed namespace com.as400samplecode -> tz.signaturecapture).
Tomas Zeman <tzeman@volny.cz>
parents:
diff
changeset
|
345 |
} |