11 |
--------------------------------------------------------------------------------
/default.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system use,
7 | # "build.properties", and override values to adapt the script to your
8 | # project structure.
9 |
10 | # Project target.
11 | target=android-8
12 |
--------------------------------------------------------------------------------
/res/menu/menu2.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/res/layout/ocard.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/res/layout/welcome.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
19 |
20 |
--------------------------------------------------------------------------------
/src/com/android/myapp/help.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.Button;
9 |
10 | public class help extends Activity {
11 | /** Called when the activity is first created. */
12 | private Button back;
13 | @Override
14 | public void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.help);
17 | this.back = (Button)this.findViewById(R.id.htempb);
18 | this.back.setOnClickListener(new OnClickListener() {
19 | @Override
20 | public void onClick(View v) {
21 | startActivity(new Intent(help.this,menu.class));
22 | finish();
23 | }
24 | });
25 | }
26 | }
--------------------------------------------------------------------------------
/src/com/android/myapp/myappmain.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.Button;
9 |
10 | public class myappmain extends Activity {
11 | /** Called when the activity is first created. */
12 | private Button conti;
13 | @Override
14 | public void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.welcome);
17 | this.conti = (Button)this.findViewById(R.id.cont);
18 | this.conti.setOnClickListener(new OnClickListener() {
19 | @Override
20 | public void onClick(View v) {
21 | startActivity(new Intent(myappmain.this,menu.class));
22 | finish();
23 | }
24 | });
25 |
26 | }
27 | }
--------------------------------------------------------------------------------
/proguard.cfg:
--------------------------------------------------------------------------------
1 | -optimizationpasses 5
2 | -dontusemixedcaseclassnames
3 | -dontskipnonpubliclibraryclasses
4 | -dontpreverify
5 | -verbose
6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7 |
8 | -keep public class * extends android.app.Activity
9 | -keep public class * extends android.app.Application
10 | -keep public class * extends android.app.Service
11 | -keep public class * extends android.content.BroadcastReceiver
12 | -keep public class * extends android.content.ContentProvider
13 | -keep public class * extends android.app.backup.BackupAgentHelper
14 | -keep public class * extends android.preference.Preference
15 | -keep public class com.android.vending.licensing.ILicensingService
16 |
17 | -keepclasseswithmembernames class * {
18 | native ;
19 | }
20 |
21 | -keepclasseswithmembernames class * {
22 | public (android.content.Context, android.util.AttributeSet);
23 | }
24 |
25 | -keepclasseswithmembernames class * {
26 | public (android.content.Context, android.util.AttributeSet, int);
27 | }
28 |
29 | -keepclassmembers enum * {
30 | public static **[] values();
31 | public static ** valueOf(java.lang.String);
32 | }
33 |
34 | -keep class * implements android.os.Parcelable {
35 | public static final android.os.Parcelable$Creator *;
36 | }
37 |
--------------------------------------------------------------------------------
/res/layout/help.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
25 |
26 |
36 |
37 |
44 |
45 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Welcome to cardZcreator
4 | cardZcreator
5 | Hello
6 | Ashish here..!!!
7 | Continue
8 | Visiting eCard
9 | Greeting eCard
10 | Wedding eCard
11 | Create my own eCard
12 | Help
13 | Exit
14 | (Select any Template)
15 | \n\tCardZcreator is an android application developed to facilitate its users in easy and fast creation of visiting , greeting and wedding cards.\n\n\tTo create a card choose from one of the various templates available with the application and edit it to your needs.To edit the text of a template click on the text.To go back or save the image click on the menu button and follow on screen steps.\n\n\tAlternatively you can create your own card by selecting "Create my own card" from the menu.A default white workspace is provided.You can add text and images to it by clicking the menu button and following on screen instructions.To change the position of text(image) long click the text(image) until it blinks and continue dragging to desired position.To edit the properties of text(image) short click on text(image) and choose from the menu generated on screen.\n\n
16 |
17 | Mercury
18 | Venus
19 | Earth
20 | Mars
21 | Jupiter
22 | Saturn
23 | Uranus
24 | Neptune
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/com/android/myapp/menu.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.Button;
9 |
10 | public class menu extends Activity {
11 | /** Called when the activity is first created. */
12 | private Button vcard;
13 | private Button gcard;
14 | private Button wcard;
15 | private Button ocard;
16 | private Button help;
17 | private Button exit;
18 | @Override
19 | public void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | setContentView(R.layout.menu);
22 | this.vcard = (Button)this.findViewById(R.id.vcard);
23 | this.vcard.setOnClickListener(new OnClickListener() {
24 | @Override
25 | public void onClick(View v) {
26 | startActivity(new Intent(menu.this,vcard.class));
27 | finish();
28 | }
29 | });
30 | this.gcard = (Button)this.findViewById(R.id.gcard);
31 | this.gcard.setOnClickListener(new OnClickListener() {
32 | @Override
33 | public void onClick(View v) {
34 | startActivity(new Intent(menu.this,gcard.class));
35 | finish();
36 | }
37 | });
38 | this.wcard = (Button)this.findViewById(R.id.wcard);
39 | this.wcard.setOnClickListener(new OnClickListener() {
40 | @Override
41 | public void onClick(View v) {
42 | startActivity(new Intent(menu.this,wcard.class));
43 | finish();
44 | }
45 | });
46 | this.ocard = (Button)this.findViewById(R.id.ocard);
47 | this.ocard.setOnClickListener(new OnClickListener() {
48 | @Override
49 | public void onClick(View v) {
50 | startActivity(new Intent(menu.this,ocard.class));
51 | finish();
52 | }
53 | });
54 | this.help = (Button)this.findViewById(R.id.help);
55 | this.help.setOnClickListener(new OnClickListener() {
56 | @Override
57 | public void onClick(View v) {
58 | startActivity(new Intent(menu.this,help.class));
59 | finish();
60 | }
61 | });
62 | this.exit = (Button)this.findViewById(R.id.exit);
63 | this.exit.setOnClickListener(new OnClickListener() {
64 | @Override
65 | public void onClick(View v) {
66 |
67 | finish();
68 | System.exit(0);
69 | }
70 | });
71 | }
72 | }
--------------------------------------------------------------------------------
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
32 |
33 |
36 |
37 |
40 |
41 |
44 |
45 |
48 |
49 |
52 |
53 |
56 |
57 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/res/layout/vtemp1.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
20 |
21 |
33 |
34 |
46 |
47 |
59 |
60 |
72 |
73 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/res/layout/vtemp2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
19 |
29 |
30 |
40 |
41 |
51 |
52 |
62 |
63 |
73 |
74 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/res/layout/vtemp5.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
19 |
29 |
30 |
40 |
41 |
51 |
52 |
62 |
63 |
73 |
74 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/res/layout/vtemp6.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
19 |
29 |
30 |
40 |
41 |
51 |
52 |
62 |
63 |
73 |
74 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/res/layout/vtemp7.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
19 |
29 |
30 |
40 |
41 |
51 |
52 |
62 |
63 |
73 |
74 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/res/layout/vtemp3.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
19 |
29 |
30 |
40 |
41 |
51 |
52 |
62 |
63 |
73 |
74 |
84 |
85 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/res/layout/vtemp4.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
18 |
19 |
29 |
30 |
40 |
41 |
51 |
52 |
62 |
63 |
73 |
74 |
84 |
85 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/res/layout/wtemp4.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/res/layout/wtemp5.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/com/android/myapp/DropTarget.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.graphics.Rect;
4 |
5 |
6 |
7 | public interface DropTarget {
8 |
9 | /**
10 | * Handle an object being dropped on the DropTarget
11 | *
12 | * @param source DragSource where the drag started
13 | * @param x X coordinate of the drop location
14 | * @param y Y coordinate of the drop location
15 | * @param xOffset Horizontal offset with the object being dragged where the original
16 | * touch happened
17 | * @param yOffset Vertical offset with the object being dragged where the original
18 | * touch happened
19 | * @param dragView The DragView that's being dragged around on screen.
20 | * @param dragInfo Data associated with the object being dragged
21 | *
22 | */
23 | void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
24 | DragView dragView, Object dragInfo);
25 |
26 | void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
27 | DragView dragView, Object dragInfo);
28 |
29 | void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
30 | DragView dragView, Object dragInfo);
31 |
32 | void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
33 | DragView dragView, Object dragInfo);
34 |
35 | /**
36 | * Check if a drop action can occur at, or near, the requested location.
37 | * This may be called repeatedly during a drag, so any calls should return
38 | * quickly.
39 | *
40 | * @param source DragSource where the drag started
41 | * @param x X coordinate of the drop location
42 | * @param y Y coordinate of the drop location
43 | * @param xOffset Horizontal offset with the object being dragged where the
44 | * original touch happened
45 | * @param yOffset Vertical offset with the object being dragged where the
46 | * original touch happened
47 | * @param dragView The DragView that's being dragged around on screen.
48 | * @param dragInfo Data associated with the object being dragged
49 | * @return True if the drop will be accepted, false otherwise.
50 | */
51 | boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
52 | DragView dragView, Object dragInfo);
53 |
54 | /**
55 | * Estimate the surface area where this object would land if dropped at the
56 | * given location.
57 | *
58 | * @param source DragSource where the drag started
59 | * @param x X coordinate of the drop location
60 | * @param y Y coordinate of the drop location
61 | * @param xOffset Horizontal offset with the object being dragged where the
62 | * original touch happened
63 | * @param yOffset Vertical offset with the object being dragged where the
64 | * original touch happened
65 | * @param dragView The DragView that's being dragged around on screen.
66 | * @param dragInfo Data associated with the object being dragged
67 | * @param recycle {@link Rect} object to be possibly recycled.
68 | * @return Estimated area that would be occupied if object was dropped at
69 | * the given location. Should return null if no estimate is found,
70 | * or if this target doesn't provide estimations.
71 | */
72 | Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
73 | DragView dragView, Object dragInfo, Rect recycle);
74 |
75 | // These methods are implemented in Views
76 | void getHitRect(Rect outRect);
77 | void getLocationOnScreen(int[] loc);
78 | int getLeft();
79 | int getTop();
80 | }
81 |
--------------------------------------------------------------------------------
/res/layout/wtemp1.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/res/layout/wtemp2.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/res/layout/wtemp3.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.log
79 | *.scc
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 |
89 | # Visual Studio profiler
90 | *.psess
91 | *.vsp
92 | *.vspx
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | *.ncrunch*
109 | .*crunch*.local.xml
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.Publish.xml
129 | *.pubxml
130 |
131 | # NuGet Packages Directory
132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133 | #packages/
134 |
135 | # Windows Azure Build Output
136 | csx
137 | *.build.csdef
138 |
139 | # Windows Store app package directory
140 | AppPackages/
141 |
142 | # Others
143 | sql/
144 | *.Cache
145 | ClientBin/
146 | [Ss]tyle[Cc]op.*
147 | ~$*
148 | *~
149 | *.dbmdl
150 | *.[Pp]ublish.xml
151 | *.pfx
152 | *.publishsettings
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | App_Data/*.mdf
166 | App_Data/*.ldf
167 |
168 | #############
169 | ## Windows detritus
170 | #############
171 |
172 | # Windows image file caches
173 | Thumbs.db
174 | ehthumbs.db
175 |
176 | # Folder config file
177 | Desktop.ini
178 |
179 | # Recycle Bin used on file shares
180 | $RECYCLE.BIN/
181 |
182 | # Mac crap
183 | .DS_Store
184 |
185 |
186 | #############
187 | ## Python
188 | #############
189 |
190 | *.py[co]
191 |
192 | # Packages
193 | *.egg
194 | *.egg-info
195 | dist/
196 | build/
197 | eggs/
198 | parts/
199 | var/
200 | sdist/
201 | develop-eggs/
202 | .installed.cfg
203 |
204 | # Installer logs
205 | pip-log.txt
206 |
207 | # Unit test / coverage reports
208 | .coverage
209 | .tox
210 |
211 | #Translations
212 | *.mo
213 |
214 | #Mr Developer
215 | .mr.developer.cfg
216 |
--------------------------------------------------------------------------------
/src/com/android/myapp/wcard.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.Button;
9 |
10 | public class wcard extends Activity {
11 | /** Called when the activity is first created. */
12 | private Button back;
13 | private Button help;
14 | private Button wtemp1;
15 | private Button wtemp2;
16 | private Button wtemp3;
17 | private Button wtemp4;
18 | private Button wtemp5;
19 | @Override
20 | public void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.wcard);
23 | this.back = (Button)this.findViewById(R.id.wtempb);
24 | this.back.setOnClickListener(new OnClickListener() {
25 | @Override
26 | public void onClick(View v) {
27 | startActivity(new Intent(wcard.this,menu.class));
28 | finish();
29 | }
30 | });
31 | this.help = (Button)this.findViewById(R.id.wtemph);
32 | this.help.setOnClickListener(new OnClickListener() {
33 | @Override
34 | public void onClick(View v) {
35 | startActivity(new Intent(wcard.this,help.class));
36 | finish();
37 | }
38 | });
39 | this.wtemp1 = (Button)this.findViewById(R.id.wtemp1);
40 | this.wtemp1.setOnClickListener(new OnClickListener() {
41 | @Override
42 | public void onClick(View v) {
43 | Bundle bundle=new Bundle();
44 | bundle.putString("template","one");
45 | Intent newIntent = new Intent(wcard.this,wtemp1.class);
46 | newIntent.putExtras(bundle);
47 | startActivityForResult(newIntent,0);
48 | finish();
49 | }
50 | });
51 | this.wtemp2 = (Button)this.findViewById(R.id.wtemp2);
52 | this.wtemp2.setOnClickListener(new OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | Bundle bundle=new Bundle();
56 | bundle.putString("template","two");
57 | Intent newIntent = new Intent(wcard.this,wtemp1.class);
58 | newIntent.putExtras(bundle);
59 | startActivityForResult(newIntent,0);
60 | finish();
61 | }
62 | });
63 | this.wtemp3 = (Button)this.findViewById(R.id.wtemp3);
64 | this.wtemp3.setOnClickListener(new OnClickListener() {
65 | @Override
66 | public void onClick(View v) {
67 | Bundle bundle=new Bundle();
68 | bundle.putString("template","three");
69 | Intent newIntent = new Intent(wcard.this,wtemp1.class);
70 | newIntent.putExtras(bundle);
71 | startActivityForResult(newIntent,0);
72 | finish();
73 | }
74 | });
75 | this.wtemp4 = (Button)this.findViewById(R.id.wtemp4);
76 | this.wtemp4.setOnClickListener(new OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | Bundle bundle=new Bundle();
80 | bundle.putString("template","four");
81 |
82 | Intent newIntent = new Intent(wcard.this,wtemp1.class);
83 | newIntent.putExtras(bundle);
84 | startActivityForResult(newIntent,0);
85 | finish();
86 | }
87 | });
88 | this.wtemp5 = (Button)this.findViewById(R.id.wtemp5);
89 | this.wtemp5.setOnClickListener(new OnClickListener() {
90 | @Override
91 | public void onClick(View v) {
92 | Bundle bundle=new Bundle();
93 | bundle.putString("template","five");
94 | Intent newIntent = new Intent(wcard.this,wtemp1.class);
95 | newIntent.putExtras(bundle);
96 | startActivityForResult(newIntent,0);
97 | finish();
98 | }
99 | });
100 | }
101 | }
--------------------------------------------------------------------------------
/res/layout/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
16 |
17 |
22 |
23 |
37 |
51 |
65 |
79 |
80 |
81 |
82 |
89 |
90 |
102 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/res/layout/gtemp3.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
94 |
106 |
107 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/res/layout/gtemp4.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
94 |
106 |
107 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/res/layout/gtemp2.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
94 |
106 |
107 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/res/layout/gtemp5.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
94 |
106 |
107 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/res/layout/gtemp6.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
94 |
106 |
107 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/res/layout/gtemp7.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
105 |
106 |
118 |
119 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/res/layout/gtemp8.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
105 |
106 |
118 |
119 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/res/layout/gtemp1.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
92 |
93 |
105 |
106 |
118 |
119 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/src/com/android/myapp/vcard.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.Button;
9 |
10 | public class vcard extends Activity {
11 | /** Called when the activity is first created. */
12 | private Button back;
13 | private Button help;
14 | private Button vtemp1;
15 | private Button vtemp2;
16 | private Button vtemp3;
17 | private Button vtemp4;
18 | private Button vtemp5;
19 | private Button vtemp6;
20 | private Button vtemp7;
21 | @Override
22 | public void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.vcard);
25 | this.back = (Button)this.findViewById(R.id.tempb);
26 | this.back.setOnClickListener(new OnClickListener() {
27 | @Override
28 | public void onClick(View v) {
29 | startActivity(new Intent(vcard.this,menu.class));
30 | finish();
31 | }
32 | });
33 | this.help = (Button)this.findViewById(R.id.temph);
34 | this.help.setOnClickListener(new OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | startActivity(new Intent(vcard.this,help.class));
38 | finish();
39 | }
40 | });
41 | this.vtemp1 = (Button)this.findViewById(R.id.vtemp1);
42 | this.vtemp1.setOnClickListener(new OnClickListener() {
43 | @Override
44 | public void onClick(View v) {
45 | Bundle bundle=new Bundle();
46 | bundle.putString("template","one");
47 | Intent newIntent = new Intent(vcard.this,vtemp1.class);
48 | newIntent.putExtras(bundle);
49 | startActivityForResult(newIntent,0);
50 | finish();
51 | }
52 | });
53 | this.vtemp2 = (Button)this.findViewById(R.id.vtemp2);
54 | this.vtemp2.setOnClickListener(new OnClickListener() {
55 | @Override
56 | public void onClick(View v) {
57 | Bundle bundle=new Bundle();
58 | bundle.putString("template","two");
59 | Intent newIntent = new Intent(vcard.this,vtemp1.class);
60 | newIntent.putExtras(bundle);
61 | startActivityForResult(newIntent,0);
62 | finish();
63 | }
64 | });
65 | this.vtemp3 = (Button)this.findViewById(R.id.vtemp3);
66 | this.vtemp3.setOnClickListener(new OnClickListener() {
67 | @Override
68 | public void onClick(View v) {
69 | Bundle bundle=new Bundle();
70 | bundle.putString("template","three");
71 | Intent newIntent = new Intent(vcard.this,vtemp1.class);
72 | newIntent.putExtras(bundle);
73 | startActivityForResult(newIntent,0);
74 | finish();
75 | }
76 | });
77 | this.vtemp4 = (Button)this.findViewById(R.id.vtemp4);
78 | this.vtemp4.setOnClickListener(new OnClickListener() {
79 | @Override
80 | public void onClick(View v) {
81 | Bundle bundle=new Bundle();
82 | bundle.putString("template","four");
83 | Intent newIntent = new Intent(vcard.this,vtemp1.class);
84 | newIntent.putExtras(bundle);
85 | startActivityForResult(newIntent,0);
86 | finish();
87 | }
88 | });
89 | this.vtemp5 = (Button)this.findViewById(R.id.vtemp5);
90 | this.vtemp5.setOnClickListener(new OnClickListener() {
91 | @Override
92 | public void onClick(View v) {
93 | Bundle bundle=new Bundle();
94 | bundle.putString("template","five");
95 | Intent newIntent = new Intent(vcard.this,vtemp1.class);
96 | newIntent.putExtras(bundle);
97 | startActivityForResult(newIntent,0);
98 | finish();
99 | }
100 | });
101 | this.vtemp6 = (Button)this.findViewById(R.id.vtemp6);
102 | this.vtemp6.setOnClickListener(new OnClickListener() {
103 | @Override
104 | public void onClick(View v) {
105 | Bundle bundle=new Bundle();
106 | bundle.putString("template","six");
107 | Intent newIntent = new Intent(vcard.this,vtemp1.class);
108 | newIntent.putExtras(bundle);
109 | startActivityForResult(newIntent,0);
110 | finish();
111 | }
112 | });
113 | this.vtemp7 = (Button)this.findViewById(R.id.vtemp7);
114 | this.vtemp7.setOnClickListener(new OnClickListener() {
115 | @Override
116 | public void onClick(View v) {
117 | Bundle bundle=new Bundle();
118 | bundle.putString("template","seven");
119 | Intent newIntent = new Intent(vcard.this,vtemp1.class);
120 | newIntent.putExtras(bundle);
121 | startActivityForResult(newIntent,0);
122 | finish();
123 | }
124 | });
125 | }
126 | }
--------------------------------------------------------------------------------
/res/layout/wcard.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
27 |
28 |
35 |
36 |
41 |
42 |
58 |
74 |
90 |
106 |
122 |
123 |
124 |
125 |
132 |
133 |
140 |
141 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/src/com/android/myapp/DragView.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.Canvas;
6 | import android.graphics.Matrix;
7 | import android.graphics.Paint;
8 | import android.graphics.PixelFormat;
9 | import android.os.IBinder;
10 | import android.view.Gravity;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.WindowManager;
14 |
15 |
16 |
17 | public class DragView extends View {
18 | // Number of pixels to add to the dragged item for scaling. Should be even for pixel alignment.
19 | private static final int DRAG_SCALE = 0; // In Launcher, value is 40
20 |
21 | private Bitmap mBitmap;
22 | private Paint mPaint;
23 | private int mRegistrationX;
24 | private int mRegistrationY;
25 |
26 | private float mScale;
27 | private float mAnimationScale = 1.0f;
28 |
29 | private WindowManager.LayoutParams mLayoutParams;
30 | private WindowManager mWindowManager;
31 |
32 | /**
33 | * Construct the drag view.
34 | *
35 | * The registration point is the point inside our view that the touch events should
36 | * be centered upon.
37 | *
38 | * @param context A context
39 | * @param bitmap The view that we're dragging around. We scale it up when we draw it.
40 | * @param registrationX The x coordinate of the registration point.
41 | * @param registrationY The y coordinate of the registration point.
42 | */
43 | public DragView(Context context, Bitmap bitmap, int registrationX, int registrationY,
44 | int left, int top, int width, int height) {
45 | super(context);
46 |
47 | // mWindowManager = WindowManagerImpl.getDefault();
48 | mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
49 |
50 | Matrix scale = new Matrix();
51 | float scaleFactor = width;
52 | scaleFactor = mScale = (scaleFactor + DRAG_SCALE) / scaleFactor;
53 | scale.setScale(scaleFactor, scaleFactor);
54 | mBitmap = Bitmap.createBitmap(bitmap, left, top, width, height, scale, true);
55 |
56 | // The point in our scaled bitmap that the touch events are located
57 | mRegistrationX = registrationX + (DRAG_SCALE / 2);
58 | mRegistrationY = registrationY + (DRAG_SCALE / 2);
59 | }
60 |
61 | @Override
62 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
63 | setMeasuredDimension(mBitmap.getWidth(), mBitmap.getHeight());
64 | }
65 |
66 | @Override
67 | protected void onDraw(Canvas canvas) {
68 | if (true) {
69 | // for debugging
70 | Paint p = new Paint();
71 | p.setStyle(Paint.Style.FILL);
72 | p.setColor(0x88dd0011);
73 | canvas.drawRect(0, 0, getWidth(), getHeight(), p);
74 | }
75 | float scale = mAnimationScale;
76 | if (scale < 0.999f) { // allow for some float error
77 | float width = mBitmap.getWidth();
78 | float offset = (width-(width*scale))/2;
79 | canvas.translate(offset, offset);
80 | canvas.scale(scale, scale);
81 | }
82 | canvas.drawBitmap(mBitmap, 0.0f, 0.0f, mPaint);
83 | }
84 |
85 | @Override
86 | protected void onDetachedFromWindow() {
87 | super.onDetachedFromWindow();
88 | mBitmap.recycle();
89 | }
90 |
91 | public void setPaint(Paint paint) {
92 | mPaint = paint;
93 | invalidate();
94 | }
95 |
96 | /**
97 | * Create a window containing this view and show it.
98 | *
99 | * @param windowToken obtained from v.getWindowToken() from one of your views
100 | * @param touchX the x coordinate the user touched in screen coordinates
101 | * @param touchY the y coordinate the user touched in screen coordinates
102 | */
103 | public void show(IBinder windowToken, int touchX, int touchY) {
104 | WindowManager.LayoutParams lp;
105 | int pixelFormat;
106 |
107 | pixelFormat = PixelFormat.TRANSLUCENT;
108 |
109 | lp = new WindowManager.LayoutParams(
110 | ViewGroup.LayoutParams.WRAP_CONTENT,
111 | ViewGroup.LayoutParams.WRAP_CONTENT,
112 | touchX-mRegistrationX, touchY-mRegistrationY,
113 | WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL,
114 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
115 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
116 | /*| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM*/,
117 | pixelFormat);
118 | // lp.token = mStatusBarView.getWindowToken();
119 | lp.gravity = Gravity.LEFT | Gravity.TOP;
120 | lp.token = windowToken;
121 | lp.setTitle("DragView");
122 | mLayoutParams = lp;
123 |
124 | mWindowManager.addView(this, lp);
125 |
126 | }
127 |
128 | /**
129 | * Move the window containing this view.
130 | *
131 | * @param touchX the x coordinate the user touched in screen coordinates
132 | * @param touchY the y coordinate the user touched in screen coordinates
133 | */
134 | void move(int touchX, int touchY) {
135 | // This is what was done in the Launcher code.
136 | WindowManager.LayoutParams lp = mLayoutParams;
137 | lp.x = touchX - mRegistrationX;
138 | lp.y = touchY - mRegistrationY;
139 | mWindowManager.updateViewLayout(this, lp);
140 | }
141 |
142 | void remove() {
143 | mWindowManager.removeView(this);
144 | }
145 |
146 | }
147 |
--------------------------------------------------------------------------------
/src/com/android/myapp/gcard.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.Button;
9 |
10 | public class gcard extends Activity {
11 | /** Called when the activity is first created. */
12 | private Button back;
13 | private Button help;
14 | private Button gtemp1;
15 | private Button gtemp2;
16 | private Button gtemp3;
17 | private Button gtemp4;
18 | private Button gtemp5;
19 | private Button gtemp6;
20 | private Button gtemp7;
21 | private Button gtemp8;
22 | @Override
23 | public void onCreate(Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.gcard);
26 | this.back = (Button)this.findViewById(R.id.gtempb);
27 | this.back.setOnClickListener(new OnClickListener() {
28 | @Override
29 | public void onClick(View v) {
30 | startActivity(new Intent(gcard.this,menu.class));
31 | finish();
32 | }
33 | });
34 | this.help = (Button)this.findViewById(R.id.gtemph);
35 | this.help.setOnClickListener(new OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | startActivity(new Intent(gcard.this,help.class));
39 | finish();
40 | }
41 | });
42 | this.gtemp1 = (Button)this.findViewById(R.id.gtemp1);
43 | this.gtemp1.setOnClickListener(new OnClickListener() {
44 | @Override
45 | public void onClick(View v) {
46 | Bundle bundle=new Bundle();
47 | bundle.putString("template","one");
48 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
49 | newIntent.putExtras(bundle);
50 | startActivityForResult(newIntent,0);
51 | finish();
52 | }
53 | });
54 | this.gtemp2 = (Button)this.findViewById(R.id.gtemp2);
55 | this.gtemp2.setOnClickListener(new OnClickListener() {
56 | @Override
57 | public void onClick(View v) {
58 | Bundle bundle=new Bundle();
59 | bundle.putString("template","two");
60 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
61 | newIntent.putExtras(bundle);
62 | startActivityForResult(newIntent,0);
63 | finish();
64 | }
65 | });
66 | this.gtemp3 = (Button)this.findViewById(R.id.gtemp3);
67 | this.gtemp3.setOnClickListener(new OnClickListener() {
68 | @Override
69 | public void onClick(View v) {
70 | Bundle bundle=new Bundle();
71 | bundle.putString("template","three");
72 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
73 | newIntent.putExtras(bundle);
74 | startActivityForResult(newIntent,0);
75 | finish();
76 | }
77 | });
78 | this.gtemp4 = (Button)this.findViewById(R.id.gtemp4);
79 | this.gtemp4.setOnClickListener(new OnClickListener() {
80 | @Override
81 | public void onClick(View v) {
82 | Bundle bundle=new Bundle();
83 | bundle.putString("template","four");
84 |
85 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
86 | newIntent.putExtras(bundle);
87 | startActivityForResult(newIntent,0);
88 | finish();
89 | }
90 | });
91 | this.gtemp5 = (Button)this.findViewById(R.id.gtemp5);
92 | this.gtemp5.setOnClickListener(new OnClickListener() {
93 | @Override
94 | public void onClick(View v) {
95 | Bundle bundle=new Bundle();
96 | bundle.putString("template","five");
97 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
98 | newIntent.putExtras(bundle);
99 | startActivityForResult(newIntent,0);
100 | finish();
101 | }
102 | });
103 | this.gtemp6 = (Button)this.findViewById(R.id.gtemp6);
104 | this.gtemp6.setOnClickListener(new OnClickListener() {
105 | @Override
106 | public void onClick(View v) {
107 | Bundle bundle=new Bundle();
108 | bundle.putString("template","six");
109 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
110 | newIntent.putExtras(bundle);
111 | startActivityForResult(newIntent,0);
112 | finish();
113 | }
114 | });
115 | this.gtemp7 = (Button)this.findViewById(R.id.gtemp7);
116 | this.gtemp7.setOnClickListener(new OnClickListener() {
117 | @Override
118 | public void onClick(View v) {
119 | Bundle bundle=new Bundle();
120 | bundle.putString("template","seven");
121 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
122 | newIntent.putExtras(bundle);
123 | startActivityForResult(newIntent,0);
124 | finish();
125 | }
126 | });
127 | this.gtemp8 = (Button)this.findViewById(R.id.gtemp8);
128 | this.gtemp8.setOnClickListener(new OnClickListener() {
129 | @Override
130 | public void onClick(View v) {
131 | Bundle bundle=new Bundle();
132 | bundle.putString("template","eight");
133 | Intent newIntent = new Intent(gcard.this,gtemp1.class);
134 | newIntent.putExtras(bundle);
135 | startActivityForResult(newIntent,0);
136 | finish();
137 | }
138 | });
139 |
140 | }
141 | }
--------------------------------------------------------------------------------
/res/layout/vcard.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
18 |
28 |
29 |
36 |
37 |
42 |
43 |
59 |
75 |
91 |
107 |
123 |
139 |
155 |
156 |
157 |
164 |
165 |
172 |
173 |
181 |
182 |
183 |
--------------------------------------------------------------------------------
/src/com/android/myapp/DragLayer.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.content.Context;
4 | import android.graphics.Rect;
5 | import android.util.AttributeSet;
6 | import android.view.KeyEvent;
7 | import android.view.MotionEvent;
8 | import android.view.View;
9 | import android.widget.Toast;
10 |
11 |
12 |
13 |
14 | public class DragLayer extends MyAbsoluteLayout
15 | implements DragSource, DropTarget{
16 |
17 | DragController mDragController;
18 |
19 | /**
20 | * Used to create a new DragLayer from XML.
21 | *
22 | * @param context The application's context.
23 | * @param attrs The attribtues set containing the Workspace's customization values.
24 | */
25 | public DragLayer (Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | }
28 |
29 | public void setDragController(DragController controller) {
30 | mDragController = controller;
31 | }
32 |
33 | @Override
34 | public boolean dispatchKeyEvent(KeyEvent event) {
35 | return mDragController.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
36 | }
37 |
38 | @Override
39 | public boolean onInterceptTouchEvent(MotionEvent ev) {
40 | return mDragController.onInterceptTouchEvent(ev);
41 | }
42 |
43 | @Override
44 | public boolean onTouchEvent(MotionEvent ev) {
45 | return mDragController.onTouchEvent(ev);
46 | }
47 |
48 | @Override
49 | public boolean dispatchUnhandledMove(View focused, int direction) {
50 | return mDragController.dispatchUnhandledMove(focused, direction);
51 | }
52 |
53 | /**
54 | */
55 | // DragSource interface methods
56 |
57 | /**
58 | * setDragController
59 | *
60 | */
61 |
62 | /* setDragController is already defined. See above. */
63 |
64 | /**
65 | * onDropCompleted
66 | *
67 | */
68 |
69 | public void onDropCompleted (View target, boolean success)
70 | {
71 | toast ("DragLayer2.onDropCompleted: " + target.getId () + " Check that the view moved.");
72 | }
73 |
74 | /**
75 | */
76 | // DropTarget interface implementation
77 |
78 | /**
79 | * Handle an object being dropped on the DropTarget.
80 | * This is the where a dragged view gets repositioned at the end of a drag.
81 | *
82 | * @param source DragSource where the drag started
83 | * @param x X coordinate of the drop location
84 | * @param y Y coordinate of the drop location
85 | * @param xOffset Horizontal offset with the object being dragged where the original
86 | * touch happened
87 | * @param yOffset Vertical offset with the object being dragged where the original
88 | * touch happened
89 | * @param dragView The DragView that's being dragged around on screen.
90 | * @param dragInfo Data associated with the object being dragged
91 | *
92 | */
93 | public void onDrop(DragSource source, int x, int y, int xOffset, int yOffset,
94 | DragView dragView, Object dragInfo)
95 | {
96 | View v = (View) dragInfo;
97 | toast ("DragLayer2.onDrop accepts view: " + v.getId ()
98 | + "x, y, xO, yO :" + new Integer (x) + ", " + new Integer (y) + ", "
99 | + new Integer (xOffset) + ", " + new Integer (yOffset));
100 |
101 | int w = v.getWidth ();
102 | int h = v.getHeight ();
103 | int left = x - xOffset;
104 | int top = y - yOffset;
105 | DragLayer.LayoutParams lp = new DragLayer.LayoutParams (w, h, left, top);
106 | this.updateViewLayout(v, lp);
107 | }
108 |
109 | public void onDragEnter(DragSource source, int x, int y, int xOffset, int yOffset,
110 | DragView dragView, Object dragInfo)
111 | {
112 | }
113 |
114 | public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
115 | DragView dragView, Object dragInfo)
116 | {
117 | }
118 |
119 | public void onDragExit(DragSource source, int x, int y, int xOffset, int yOffset,
120 | DragView dragView, Object dragInfo)
121 | {
122 | }
123 |
124 | /**
125 | * Check if a drop action can occur at, or near, the requested location.
126 | * This may be called repeatedly during a drag, so any calls should return
127 | * quickly.
128 | *
129 | * @param source DragSource where the drag started
130 | * @param x X coordinate of the drop location
131 | * @param y Y coordinate of the drop location
132 | * @param xOffset Horizontal offset with the object being dragged where the
133 | * original touch happened
134 | * @param yOffset Vertical offset with the object being dragged where the
135 | * original touch happened
136 | * @param dragView The DragView that's being dragged around on screen.
137 | * @param dragInfo Data associated with the object being dragged
138 | * @return True if the drop will be accepted, false otherwise.
139 | */
140 | public boolean acceptDrop(DragSource source, int x, int y, int xOffset, int yOffset,
141 | DragView dragView, Object dragInfo)
142 | {
143 | return true;
144 | }
145 |
146 | /**
147 | * Estimate the surface area where this object would land if dropped at the
148 | * given location.
149 | *
150 | * @param source DragSource where the drag started
151 | * @param x X coordinate of the drop location
152 | * @param y Y coordinate of the drop location
153 | * @param xOffset Horizontal offset with the object being dragged where the
154 | * original touch happened
155 | * @param yOffset Vertical offset with the object being dragged where the
156 | * original touch happened
157 | * @param dragView The DragView that's being dragged around on screen.
158 | * @param dragInfo Data associated with the object being dragged
159 | * @param recycle {@link Rect} object to be possibly recycled.
160 | * @return Estimated area that would be occupied if object was dropped at
161 | * the given location. Should return null if no estimate is found,
162 | * or if this target doesn't provide estimations.
163 | */
164 | public Rect estimateDropLocation(DragSource source, int x, int y, int xOffset, int yOffset,
165 | DragView dragView, Object dragInfo, Rect recycle)
166 | {
167 | return null;
168 | }
169 |
170 | /**
171 | */
172 | // More methods
173 |
174 | /**
175 | * Show a string on the screen via Toast.
176 | *
177 | * @param msg String
178 | * @return void
179 | */
180 |
181 | public void toast (String msg)
182 | {
183 | if (!ocard.Debugging) return;
184 | //Toast.makeText (getContext (), msg, Toast.LENGTH_SHORT).show ();
185 | } // end toast
186 |
187 |
188 | }
189 |
--------------------------------------------------------------------------------
/res/layout/gcard.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
28 |
29 |
36 |
41 |
42 |
58 |
74 |
90 |
106 |
122 |
138 |
154 |
170 |
171 |
172 |
173 |
180 |
181 |
188 |
189 |
197 |
198 |
199 |
--------------------------------------------------------------------------------
/gen/com/android/myapp/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.android.myapp;
9 |
10 | public final class R {
11 | public static final class array {
12 | public static final int planets_array=0x7f050000;
13 | }
14 | public static final class attr {
15 | }
16 | public static final class drawable {
17 | public static final int back=0x7f020000;
18 | public static final int gtemp1=0x7f020001;
19 | public static final int gtemp2=0x7f020002;
20 | public static final int gtemp3=0x7f020003;
21 | public static final int gtemp4=0x7f020004;
22 | public static final int gtemp5=0x7f020005;
23 | public static final int gtemp6=0x7f020006;
24 | public static final int gtemp7=0x7f020007;
25 | public static final int gtemp8=0x7f020008;
26 | public static final int icon=0x7f020009;
27 | public static final int test5=0x7f02000a;
28 | public static final int vcard1=0x7f02000b;
29 | public static final int vtemp2=0x7f02000c;
30 | public static final int vtemp3=0x7f02000d;
31 | public static final int vtemp4=0x7f02000e;
32 | public static final int vtemp5=0x7f02000f;
33 | public static final int vtemp6=0x7f020010;
34 | public static final int vtemp7=0x7f020011;
35 | public static final int white=0x7f020012;
36 | public static final int wtemp1=0x7f020013;
37 | public static final int wtemp2=0x7f020014;
38 | public static final int wtemp3=0x7f020015;
39 | public static final int wtemp4=0x7f020016;
40 | public static final int wtemp5=0x7f020017;
41 | }
42 | public static final class id {
43 | public static final int ScrollView01=0x7f070020;
44 | public static final int ScrollView02=0x7f070002;
45 | public static final int ScrollView03=0x7f070012;
46 | public static final int ScrollView04=0x7f070015;
47 | public static final int abs=0x7f07001d;
48 | public static final int abslyt=0x7f07000f;
49 | public static final int addimage=0x7f070037;
50 | public static final int addtext=0x7f070036;
51 | public static final int back=0x7f070034;
52 | public static final int cont=0x7f070033;
53 | public static final int editText1=0x7f070010;
54 | public static final int exit=0x7f07001b;
55 | public static final int gcard=0x7f070017;
56 | public static final int gtemp1=0x7f070003;
57 | public static final int gtemp2=0x7f070004;
58 | public static final int gtemp3=0x7f070005;
59 | public static final int gtemp4=0x7f070006;
60 | public static final int gtemp5=0x7f070007;
61 | public static final int gtemp6=0x7f070008;
62 | public static final int gtemp7=0x7f070009;
63 | public static final int gtemp8=0x7f07000a;
64 | public static final int gtempb=0x7f07000b;
65 | public static final int gtemph=0x7f07000c;
66 | public static final int gtext1=0x7f070000;
67 | public static final int gtext2=0x7f070001;
68 | public static final int hScrollView=0x7f07000e;
69 | public static final int help=0x7f07001a;
70 | public static final int htempb=0x7f070014;
71 | public static final int htext1=0x7f070011;
72 | public static final int htext2=0x7f070013;
73 | public static final int ocard=0x7f070019;
74 | public static final int rl=0x7f07001c;
75 | public static final int save=0x7f070035;
76 | public static final int tempb=0x7f070028;
77 | public static final int temph=0x7f070029;
78 | public static final int text1=0x7f07001e;
79 | public static final int text2=0x7f07001f;
80 | public static final int vScrollView=0x7f07000d;
81 | public static final int vcard=0x7f070016;
82 | public static final int vtemp1=0x7f070021;
83 | public static final int vtemp2=0x7f070022;
84 | public static final int vtemp3=0x7f070023;
85 | public static final int vtemp4=0x7f070024;
86 | public static final int vtemp5=0x7f070025;
87 | public static final int vtemp6=0x7f070026;
88 | public static final int vtemp7=0x7f070027;
89 | public static final int wcard=0x7f070018;
90 | public static final int wtemp1=0x7f07002c;
91 | public static final int wtemp2=0x7f07002d;
92 | public static final int wtemp3=0x7f07002e;
93 | public static final int wtemp4=0x7f07002f;
94 | public static final int wtemp5=0x7f070030;
95 | public static final int wtempb=0x7f070031;
96 | public static final int wtemph=0x7f070032;
97 | public static final int wtext1=0x7f07002a;
98 | public static final int wtext2=0x7f07002b;
99 | }
100 | public static final class layout {
101 | public static final int gcard=0x7f030000;
102 | public static final int gtemp1=0x7f030001;
103 | public static final int gtemp2=0x7f030002;
104 | public static final int gtemp3=0x7f030003;
105 | public static final int gtemp4=0x7f030004;
106 | public static final int gtemp5=0x7f030005;
107 | public static final int gtemp6=0x7f030006;
108 | public static final int gtemp7=0x7f030007;
109 | public static final int gtemp8=0x7f030008;
110 | public static final int help=0x7f030009;
111 | public static final int menu=0x7f03000a;
112 | public static final int ocard=0x7f03000b;
113 | public static final int vcard=0x7f03000c;
114 | public static final int vtemp1=0x7f03000d;
115 | public static final int vtemp2=0x7f03000e;
116 | public static final int vtemp3=0x7f03000f;
117 | public static final int vtemp4=0x7f030010;
118 | public static final int vtemp5=0x7f030011;
119 | public static final int vtemp6=0x7f030012;
120 | public static final int vtemp7=0x7f030013;
121 | public static final int wcard=0x7f030014;
122 | public static final int welcome=0x7f030015;
123 | public static final int wtemp1=0x7f030016;
124 | public static final int wtemp2=0x7f030017;
125 | public static final int wtemp3=0x7f030018;
126 | public static final int wtemp4=0x7f030019;
127 | public static final int wtemp5=0x7f03001a;
128 | }
129 | public static final class menu {
130 | public static final int menu=0x7f060000;
131 | public static final int menu2=0x7f060001;
132 | }
133 | public static final class string {
134 | public static final int app_name=0x7f040001;
135 | public static final int ashish=0x7f040003;
136 | public static final int choose=0x7f04000b;
137 | public static final int cont=0x7f040004;
138 | public static final int exit=0x7f04000a;
139 | public static final int gcard=0x7f040006;
140 | public static final int hello=0x7f040002;
141 | public static final int help=0x7f040009;
142 | public static final int help_content=0x7f04000c;
143 | public static final int ocard=0x7f040008;
144 | public static final int vcard=0x7f040005;
145 | public static final int wcard=0x7f040007;
146 | public static final int welcome=0x7f040000;
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/src/com/android/myapp/MyAbsoluteLayout.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 |
9 |
10 |
11 | public class MyAbsoluteLayout extends ViewGroup {
12 |
13 | public MyAbsoluteLayout(Context context) {
14 | super(context);
15 | }
16 |
17 | public MyAbsoluteLayout(Context context, AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | public MyAbsoluteLayout(Context context, AttributeSet attrs,
22 | int defStyle) {
23 | super(context, attrs, defStyle);
24 | }
25 |
26 | @Override
27 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
28 | int count = getChildCount();
29 |
30 | int maxHeight = 0;
31 | int maxWidth = 0;
32 |
33 | // Find out how big everyone wants to be
34 | measureChildren(widthMeasureSpec, heightMeasureSpec);
35 |
36 | // Find rightmost and bottom-most child
37 | for (int i = 0; i < count; i++) {
38 | View child = getChildAt(i);
39 | if (child.getVisibility() != GONE) {
40 | int childRight;
41 | int childBottom;
42 |
43 | MyAbsoluteLayout.LayoutParams lp
44 | = (MyAbsoluteLayout.LayoutParams) child.getLayoutParams();
45 |
46 | childRight = lp.x + child.getMeasuredWidth();
47 | childBottom = lp.y + child.getMeasuredHeight();
48 |
49 | maxWidth = Math.max(maxWidth, childRight);
50 | maxHeight = Math.max(maxHeight, childBottom);
51 | }
52 | }
53 |
54 | // Account for padding too
55 | maxWidth += getPaddingLeft () + getPaddingRight ();
56 | maxHeight += getPaddingTop () + getPaddingBottom ();
57 | /* original
58 | maxWidth += mPaddingLeft + mPaddingRight;
59 | maxHeight += mPaddingTop + mPaddingBottom;
60 | */
61 |
62 | // Check against minimum height and width
63 | maxHeight = Math.max(maxHeight, getSuggestedMinimumHeight());
64 | maxWidth = Math.max(maxWidth, getSuggestedMinimumWidth());
65 |
66 | setMeasuredDimension(resolveSize(maxWidth, widthMeasureSpec),
67 | resolveSize(maxHeight, heightMeasureSpec));
68 | }
69 |
70 | /**
71 | * Returns a set of layout parameters with a width of
72 | * {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT},
73 | * a height of {@link android.view.ViewGroup.LayoutParams#WRAP_CONTENT}
74 | * and with the coordinates (0, 0).
75 | */
76 | @Override
77 | protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
78 | return new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0);
79 | }
80 |
81 | @Override
82 | protected void onLayout(boolean changed, int l, int t,
83 | int r, int b) {
84 | int count = getChildCount();
85 |
86 | int paddingL = getPaddingLeft ();
87 | int paddingT = getPaddingTop ();
88 | for (int i = 0; i < count; i++) {
89 | View child = getChildAt(i);
90 | if (child.getVisibility() != GONE) {
91 |
92 | MyAbsoluteLayout.LayoutParams lp =
93 | (MyAbsoluteLayout.LayoutParams) child.getLayoutParams();
94 |
95 | int childLeft = paddingL + lp.x;
96 | int childTop = paddingT + lp.y;
97 | /*
98 | int childLeft = mPaddingLeft + lp.x;
99 | int childTop = mPaddingTop + lp.y;
100 | */
101 | child.layout(childLeft, childTop,
102 | childLeft + child.getMeasuredWidth(),
103 | childTop + child.getMeasuredHeight());
104 |
105 | }
106 | }
107 | }
108 |
109 | @Override
110 | public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) {
111 | return new MyAbsoluteLayout.LayoutParams(getContext(), attrs);
112 | }
113 |
114 | // Override to allow type-checking of LayoutParams.
115 | @Override
116 | protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
117 | return p instanceof MyAbsoluteLayout.LayoutParams;
118 | }
119 |
120 | @Override
121 | protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
122 | return new LayoutParams(p);
123 | }
124 |
125 | /**
126 | * Per-child layout information associated with MyAbsoluteLayout.
127 | * See
128 | * {@link android.R.styleable#MyAbsoluteLayout_Layout Absolute Layout Attributes}
129 | * for a list of all child view attributes that this class supports.
130 | */
131 | public static class LayoutParams extends ViewGroup.LayoutParams {
132 | /**
133 | * The horizontal, or X, location of the child within the view group.
134 | */
135 | public int x;
136 | /**
137 | * The vertical, or Y, location of the child within the view group.
138 | */
139 | public int y;
140 |
141 | /**
142 | * Creates a new set of layout parameters with the specified width,
143 | * height and location.
144 | *
145 | * @param width the width, either {@link #MATCH_PARENT},
146 | {@link #WRAP_CONTENT} or a fixed size in pixels
147 | * @param height the height, either {@link #MATCH_PARENT},
148 | {@link #WRAP_CONTENT} or a fixed size in pixels
149 | * @param x the X location of the child
150 | * @param y the Y location of the child
151 | */
152 | public LayoutParams(int width, int height, int x, int y) {
153 | super(width, height);
154 | this.x = x;
155 | this.y = y;
156 | }
157 |
158 | /**
159 | * Creates a new set of layout parameters. The values are extracted from
160 | * the supplied attributes set and context. The XML attributes mapped
161 | * to this set of layout parameters are:
162 | *
163 | *
164 | *
layout_x: the X location of the child
165 | *
layout_y: the Y location of the child
166 | *
All the XML attributes from
167 | * {@link android.view.ViewGroup.LayoutParams}
168 | *
169 | *
170 | * @param c the application environment
171 | * @param attrs the set of attributes from which to extract the layout
172 | * parameters values
173 | */
174 | public LayoutParams(Context c, AttributeSet attrs) {
175 | super(c, attrs);
176 | /* FIX THIS eventually. Without this, I don't think you can put x and y in layout xml files.
177 | TypedArray a = c.obtainStyledAttributes(attrs,
178 | com.android.internal.R.styleable.AbsoluteLayout_Layout);
179 | x = a.getDimensionPixelOffset(
180 | com.android.internal.R.styleable.AbsoluteLayout_Layout_layout_x, 0);
181 | y = a.getDimensionPixelOffset(
182 | com.android.internal.R.styleable.AbsoluteLayout_Layout_layout_y, 0);
183 | a.recycle();
184 | */
185 | }
186 |
187 | /**
188 | * {@inheritDoc}
189 | */
190 | public LayoutParams(ViewGroup.LayoutParams source) {
191 | super(source);
192 | }
193 |
194 | public String debug(String output) {
195 | return output + "Absolute.LayoutParams={width="
196 | + sizeToString(width) + ", height=" + sizeToString(height)
197 | + " x=" + x + " y=" + y + "}";
198 | }
199 |
200 | /**
201 | * Converts the specified size to a readable String.
202 | *
203 | * @param size the size to convert
204 | * @return a String instance representing the supplied size
205 | *
206 | * @hide
207 | */
208 | protected static String sizeToString(int size) {
209 | if (size == WRAP_CONTENT) {
210 | return "wrap-content";
211 | }
212 | if (size == MATCH_PARENT) {
213 | return "match-parent";
214 | }
215 | return String.valueOf(size);
216 | }
217 | } // end class
218 |
219 | }
220 |
--------------------------------------------------------------------------------
/src/com/android/myapp/wtemp1.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 |
6 | import android.app.Activity;
7 | import android.app.Dialog;
8 | import android.content.Intent;
9 | import android.graphics.Bitmap;
10 | import android.graphics.Canvas;
11 | import android.os.Bundle;
12 | import android.os.Environment;
13 | import android.provider.MediaStore;
14 | import android.util.Log;
15 | import android.view.Menu;
16 | import android.view.MenuInflater;
17 | import android.view.MenuItem;
18 | import android.view.View;
19 | import android.view.ViewGroup;
20 | import android.view.View.OnClickListener;
21 | import android.widget.AbsoluteLayout;
22 | import android.widget.Button;
23 | import android.widget.EditText;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 |
27 | public class wtemp1 extends Activity{
28 | private AbsoluteLayout abs;
29 | @Override
30 | public void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | Bundle bundle = this.getIntent().getExtras();
33 | String temp = (String)bundle.get("template");
34 | if(temp.equalsIgnoreCase("one"))
35 | setContentView(R.layout.wtemp1);
36 | else if(temp.equalsIgnoreCase("two"))
37 | setContentView(R.layout.wtemp2);
38 | else if(temp.equalsIgnoreCase("three"))
39 | setContentView(R.layout.wtemp3);
40 | else if(temp.equalsIgnoreCase("four"))
41 | setContentView(R.layout.wtemp4);
42 | else if(temp.equalsIgnoreCase("five"))
43 | setContentView(R.layout.wtemp5);
44 |
45 | abs=(AbsoluteLayout)findViewById(R.id.abslyt);
46 | }
47 | @Override
48 | public boolean onCreateOptionsMenu(Menu menu) {
49 | MenuInflater inflater = getMenuInflater();
50 | inflater.inflate(R.menu.menu, menu);
51 | return true;
52 | }
53 | @Override
54 | public boolean onOptionsItemSelected(MenuItem item) {
55 | switch (item.getItemId()) {
56 | case R.id.back:
57 | final Dialog dialog = new Dialog(wtemp1.this);
58 | LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
59 | LinearLayout l=new LinearLayout(wtemp1.this);
60 | l.setOrientation(LinearLayout.VERTICAL);
61 | TextView t1=new TextView(wtemp1.this);
62 | t1.setLayoutParams(params2);
63 | t1.setText("Sure? Any unsaved");
64 | l.addView(t1);
65 | TextView t2=new TextView(wtemp1.this);
66 | t2.setLayoutParams(params2);
67 | t2.setText("data will be lost ");
68 | l.addView(t2);
69 | final Button b1=new Button(wtemp1.this);
70 | b1.setLayoutParams(params2);
71 | b1.setText("Back");
72 | l.addView(b1);
73 | dialog.setContentView(l);
74 | dialog.setTitle("Back");
75 | dialog.show();
76 | b1.setOnClickListener(new OnClickListener(){
77 | @Override
78 | public void onClick(View v)
79 | {
80 | dialog.dismiss();
81 | startActivity(new Intent(wtemp1.this,wcard.class));
82 | finish();
83 | }
84 | });
85 | break;
86 |
87 | case R.id.save: final Dialog dialog3 = new Dialog(wtemp1.this);
88 | LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
89 | LinearLayout l3=new LinearLayout(wtemp1.this);
90 | l3.setOrientation(LinearLayout.VERTICAL);
91 | final EditText q3=new EditText(wtemp1.this);
92 | q3.setLayoutParams(params3);
93 | l3.addView(q3);
94 | final Button b3=new Button(wtemp1.this);
95 | b3.setLayoutParams(params3);
96 | b3.setText("Save as PNG");
97 | l3.addView(b3);
98 | final Button b4=new Button(wtemp1.this);
99 | b4.setLayoutParams(params3);
100 | b4.setText("Save as JPEG");
101 | l3.addView(b4);
102 | dialog3.setContentView(l3);
103 | dialog3.setTitle("Save Image As");
104 | dialog3.show();
105 | b3.setOnClickListener(new OnClickListener(){
106 | @Override
107 | public void onClick(View v2){
108 | String filename=q3.getText().toString();
109 | if(filename.length()<1)
110 | return;
111 | Bitmap screenBitmap = Bitmap.createBitmap(abs.getMeasuredWidth(),abs.getMeasuredHeight(),Bitmap.Config.ARGB_8888);
112 | Canvas canvas = new Canvas(screenBitmap);
113 | abs.draw(canvas);
114 |
115 |
116 | try{
117 | String state = Environment.getExternalStorageState();
118 | String path = Environment.getExternalStorageDirectory().toString();
119 | FileOutputStream fOut = null;
120 | File file = new File(path,filename+".png");
121 | fOut = new FileOutputStream(file);
122 | screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
123 | fOut.flush();
124 | fOut.close();
125 | MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
126 | dialog3.dismiss();
127 | }
128 | catch(Exception e)
129 | {
130 | Log.i("exception",e.toString());
131 | }
132 |
133 |
134 |
135 |
136 | }
137 | });
138 | b4.setOnClickListener(new OnClickListener(){
139 | @Override
140 | public void onClick(View v2){
141 | String filename=q3.getText().toString();
142 | if(filename.length()<1)
143 | return;
144 | Bitmap screenBitmap = Bitmap.createBitmap(abs.getMeasuredWidth(),abs.getMeasuredHeight(),Bitmap.Config.ARGB_8888);
145 | Canvas canvas = new Canvas(screenBitmap);
146 | abs.draw(canvas);
147 |
148 |
149 | try{
150 | String state = Environment.getExternalStorageState();
151 | String path = Environment.getExternalStorageDirectory().toString();
152 | FileOutputStream fOut = null;
153 | File file = new File(path,filename+".jpeg");
154 | fOut = new FileOutputStream(file);
155 | screenBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
156 | fOut.flush();
157 | fOut.close();
158 | MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
159 | dialog3.dismiss();
160 | }
161 | catch(Exception e)
162 | {
163 | Log.i("exception",e.toString());
164 | }
165 |
166 |
167 |
168 |
169 | }
170 | });
171 | break;
172 | case R.id.help: final Dialog dialog1 = new Dialog(wtemp1.this);
173 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
174 | LinearLayout l1=new LinearLayout(wtemp1.this);
175 | l1.setOrientation(LinearLayout.VERTICAL);
176 | TextView t3=new TextView(wtemp1.this);
177 | t3.setLayoutParams(params);
178 | t3.setText("Sure? Any unsaved");
179 | l1.addView(t3);
180 | TextView t4=new TextView(wtemp1.this);
181 | t4.setLayoutParams(params);
182 | t4.setText("data will be lost ");
183 | l1.addView(t4);
184 | final Button b2=new Button(wtemp1.this);
185 | b2.setLayoutParams(params);
186 | b2.setText("Help");
187 | l1.addView(b2);
188 | dialog1.setContentView(l1);
189 | dialog1.setTitle("Help");
190 | dialog1.show();
191 | b2.setOnClickListener(new OnClickListener(){
192 | @Override
193 | public void onClick(View v)
194 | {
195 | dialog1.dismiss();
196 | startActivity(new Intent(wtemp1.this,help.class));
197 | finish();
198 | }
199 | });
200 | break;
201 | }
202 | return true;
203 | }
204 |
205 | }
206 |
--------------------------------------------------------------------------------
/src/com/android/myapp/vtemp1.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 |
6 | import android.app.Activity;
7 | import android.app.Dialog;
8 | import android.content.Intent;
9 | import android.graphics.Bitmap;
10 | import android.graphics.Canvas;
11 | import android.os.Bundle;
12 | import android.os.Environment;
13 | import android.provider.MediaStore;
14 | import android.util.Log;
15 | import android.view.Menu;
16 | import android.view.MenuInflater;
17 | import android.view.MenuItem;
18 | import android.view.View;
19 | import android.view.ViewGroup;
20 | import android.view.View.OnClickListener;
21 | import android.widget.AbsoluteLayout;
22 | import android.widget.Button;
23 | import android.widget.EditText;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 |
27 | public class vtemp1 extends Activity{
28 | private AbsoluteLayout abs;
29 | @Override
30 | public void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | Bundle bundle = this.getIntent().getExtras();
33 | String temp = (String)bundle.get("template");
34 | if(temp.equalsIgnoreCase("one"))
35 | setContentView(R.layout.vtemp1);
36 | else if(temp.equalsIgnoreCase("two"))
37 | setContentView(R.layout.vtemp2);
38 | else if(temp.equalsIgnoreCase("three"))
39 | setContentView(R.layout.vtemp3);
40 | else if(temp.equalsIgnoreCase("four"))
41 | setContentView(R.layout.vtemp4);
42 | else if(temp.equalsIgnoreCase("five"))
43 | setContentView(R.layout.vtemp5);
44 | else if(temp.equalsIgnoreCase("six"))
45 | setContentView(R.layout.vtemp6);
46 | else if(temp.equalsIgnoreCase("seven"))
47 | setContentView(R.layout.vtemp7);
48 | abs=(AbsoluteLayout)findViewById(R.id.abslyt);
49 | }
50 | @Override
51 | public boolean onCreateOptionsMenu(Menu menu) {
52 | MenuInflater inflater = getMenuInflater();
53 | inflater.inflate(R.menu.menu, menu);
54 | return true;
55 | }
56 | @Override
57 | public boolean onOptionsItemSelected(MenuItem item) {
58 | switch (item.getItemId()) {
59 | case R.id.back:
60 | final Dialog dialog = new Dialog(vtemp1.this);
61 | LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
62 | LinearLayout l=new LinearLayout(vtemp1.this);
63 | l.setOrientation(LinearLayout.VERTICAL);
64 | TextView t1=new TextView(vtemp1.this);
65 | t1.setLayoutParams(params2);
66 | t1.setText("Sure? Any unsaved");
67 | l.addView(t1);
68 | TextView t2=new TextView(vtemp1.this);
69 | t2.setLayoutParams(params2);
70 | t2.setText("data will be lost ");
71 | l.addView(t2);
72 | final Button b1=new Button(vtemp1.this);
73 | b1.setLayoutParams(params2);
74 | b1.setText("Back");
75 | l.addView(b1);
76 | dialog.setContentView(l);
77 | dialog.setTitle("Back");
78 | dialog.show();
79 | b1.setOnClickListener(new OnClickListener(){
80 | @Override
81 | public void onClick(View v)
82 | {
83 | dialog.dismiss();
84 | startActivity(new Intent(vtemp1.this,vcard.class));
85 | finish();
86 | }
87 | });
88 | break;
89 |
90 | case R.id.save: final Dialog dialog3 = new Dialog(vtemp1.this);
91 | LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
92 | LinearLayout l3=new LinearLayout(vtemp1.this);
93 | l3.setOrientation(LinearLayout.VERTICAL);
94 | final EditText q3=new EditText(vtemp1.this);
95 | q3.setLayoutParams(params3);
96 | l3.addView(q3);
97 | final Button b3=new Button(vtemp1.this);
98 | b3.setLayoutParams(params3);
99 | b3.setText("Save as PNG");
100 | l3.addView(b3);
101 | final Button b4=new Button(vtemp1.this);
102 | b4.setLayoutParams(params3);
103 | b4.setText("Save as JPEG");
104 | l3.addView(b4);
105 | dialog3.setContentView(l3);
106 | dialog3.setTitle("Save Image As");
107 | dialog3.show();
108 | b3.setOnClickListener(new OnClickListener(){
109 | @Override
110 | public void onClick(View v2){
111 | String filename=q3.getText().toString();
112 | if(filename.length()<1)
113 | return;
114 | Bitmap screenBitmap = Bitmap.createBitmap(abs.getMeasuredWidth(),abs.getMeasuredHeight(),Bitmap.Config.ARGB_8888);
115 | Canvas canvas = new Canvas(screenBitmap);
116 | abs.draw(canvas);
117 |
118 |
119 | try{
120 | String state = Environment.getExternalStorageState();
121 | Log.i("state",state);
122 | String path = Environment.getExternalStorageDirectory().toString();
123 | FileOutputStream fOut = null;
124 | File file = new File(path,filename+".png");
125 | fOut = new FileOutputStream(file);
126 | screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
127 | fOut.flush();
128 | fOut.close();
129 | MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
130 | dialog3.dismiss();
131 | }
132 | catch(Exception e)
133 | {
134 | Log.i("exception",e.toString());
135 | }
136 | }
137 | });
138 | b4.setOnClickListener(new OnClickListener(){
139 | @Override
140 | public void onClick(View v2){
141 | String filename=q3.getText().toString();
142 | if(filename.length()<1)
143 | return;
144 | Bitmap screenBitmap = Bitmap.createBitmap(abs.getMeasuredWidth(),abs.getMeasuredHeight(),Bitmap.Config.ARGB_8888);
145 | Canvas canvas = new Canvas(screenBitmap);
146 | abs.draw(canvas);
147 |
148 |
149 | try{
150 | String state = Environment.getExternalStorageState();
151 | Log.i("state",state);
152 | String path = Environment.getExternalStorageDirectory().toString();
153 | FileOutputStream fOut = null;
154 | File file = new File(path,filename+".jpeg");
155 | fOut = new FileOutputStream(file);
156 | screenBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
157 | fOut.flush();
158 | fOut.close();
159 | MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
160 | dialog3.dismiss();
161 | }
162 | catch(Exception e)
163 | {
164 | Log.i("exception",e.toString());
165 | }
166 | }
167 | });
168 | break;
169 | case R.id.help: final Dialog dialog1 = new Dialog(vtemp1.this);
170 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
171 | LinearLayout l1=new LinearLayout(vtemp1.this);
172 | l1.setOrientation(LinearLayout.VERTICAL);
173 | TextView t3=new TextView(vtemp1.this);
174 | t3.setLayoutParams(params);
175 | t3.setText("Sure? Any unsaved");
176 | l1.addView(t3);
177 | TextView t4=new TextView(vtemp1.this);
178 | t4.setLayoutParams(params);
179 | t4.setText("data will be lost ");
180 | l1.addView(t4);
181 | final Button b2=new Button(vtemp1.this);
182 | b2.setLayoutParams(params);
183 | b2.setText("Help");
184 | l1.addView(b2);
185 | dialog1.setContentView(l1);
186 | dialog1.setTitle("Help");
187 | dialog1.show();
188 | b2.setOnClickListener(new OnClickListener(){
189 | @Override
190 | public void onClick(View v)
191 | {
192 | dialog1.dismiss();
193 | startActivity(new Intent(vtemp1.this,help.class));
194 | finish();
195 | }
196 | });
197 | break;
198 | }
199 | return true;
200 | }
201 |
202 | }
203 |
--------------------------------------------------------------------------------
/src/com/android/myapp/gtemp1.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 |
6 | import android.app.Activity;
7 | import android.app.Dialog;
8 | import android.content.Intent;
9 | import android.graphics.Bitmap;
10 | import android.graphics.Canvas;
11 | import android.os.Bundle;
12 | import android.os.Environment;
13 | import android.provider.MediaStore;
14 | import android.util.Log;
15 | import android.view.Menu;
16 | import android.view.MenuInflater;
17 | import android.view.MenuItem;
18 | import android.view.View;
19 | import android.view.ViewGroup;
20 | import android.view.View.OnClickListener;
21 | import android.widget.AbsoluteLayout;
22 | import android.widget.Button;
23 | import android.widget.EditText;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 |
27 | public class gtemp1 extends Activity{
28 | private AbsoluteLayout abs;
29 | @Override
30 | public void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | Bundle bundle = this.getIntent().getExtras();
33 | String temp = (String)bundle.get("template");
34 | if(temp.equalsIgnoreCase("one"))
35 | setContentView(R.layout.gtemp1);
36 | else if(temp.equalsIgnoreCase("two"))
37 | setContentView(R.layout.gtemp2);
38 | else if(temp.equalsIgnoreCase("three"))
39 | setContentView(R.layout.gtemp3);
40 | else if(temp.equalsIgnoreCase("four"))
41 | setContentView(R.layout.gtemp4);
42 | else if(temp.equalsIgnoreCase("five"))
43 | setContentView(R.layout.gtemp5);
44 | else if(temp.equalsIgnoreCase("six"))
45 | setContentView(R.layout.gtemp6);
46 | else if(temp.equalsIgnoreCase("seven"))
47 | setContentView(R.layout.gtemp7);
48 | else if(temp.equalsIgnoreCase("eight"))
49 | setContentView(R.layout.gtemp8);
50 | abs=(AbsoluteLayout)findViewById(R.id.abslyt);
51 | }
52 | @Override
53 | public boolean onCreateOptionsMenu(Menu menu) {
54 | MenuInflater inflater = getMenuInflater();
55 | inflater.inflate(R.menu.menu, menu);
56 | return true;
57 | }
58 | @Override
59 | public boolean onOptionsItemSelected(MenuItem item) {
60 | switch (item.getItemId()) {
61 | case R.id.back:
62 | final Dialog dialog = new Dialog(gtemp1.this);
63 | LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
64 | LinearLayout l=new LinearLayout(gtemp1.this);
65 | l.setOrientation(LinearLayout.VERTICAL);
66 | TextView t1=new TextView(gtemp1.this);
67 | t1.setLayoutParams(params2);
68 | t1.setText("Sure? Any unsaved");
69 | l.addView(t1);
70 | TextView t2=new TextView(gtemp1.this);
71 | t2.setLayoutParams(params2);
72 | t2.setText("data will be lost ");
73 | l.addView(t2);
74 | final Button b1=new Button(gtemp1.this);
75 | b1.setLayoutParams(params2);
76 | b1.setText("Back");
77 | l.addView(b1);
78 | dialog.setContentView(l);
79 | dialog.setTitle("Back");
80 | dialog.show();
81 | b1.setOnClickListener(new OnClickListener(){
82 | @Override
83 | public void onClick(View v)
84 | {
85 | dialog.dismiss();
86 | startActivity(new Intent(gtemp1.this,gcard.class));
87 | finish();
88 | }
89 | });
90 | break;
91 |
92 | case R.id.save: final Dialog dialog3 = new Dialog(gtemp1.this);
93 | LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
94 | LinearLayout l3=new LinearLayout(gtemp1.this);
95 | l3.setOrientation(LinearLayout.VERTICAL);
96 | final EditText q3=new EditText(gtemp1.this);
97 | q3.setLayoutParams(params3);
98 | l3.addView(q3);
99 | final Button b3=new Button(gtemp1.this);
100 | b3.setLayoutParams(params3);
101 | b3.setText("Save as PNG");
102 | l3.addView(b3);
103 | final Button b4=new Button(gtemp1.this);
104 | b4.setLayoutParams(params3);
105 | b4.setText("Save as JPEG");
106 | l3.addView(b4);
107 | dialog3.setContentView(l3);
108 | dialog3.setTitle("Save Image As");
109 | dialog3.show();
110 | b3.setOnClickListener(new OnClickListener(){
111 | @Override
112 | public void onClick(View v2){
113 | String filename=q3.getText().toString();
114 | if(filename.length()<1)
115 | return;
116 | Bitmap screenBitmap = Bitmap.createBitmap(abs.getMeasuredWidth(),abs.getMeasuredHeight(),Bitmap.Config.ARGB_8888);
117 | Canvas canvas = new Canvas(screenBitmap);
118 | abs.draw(canvas);
119 |
120 |
121 | try{
122 | String state = Environment.getExternalStorageState();
123 | String path = Environment.getExternalStorageDirectory().toString();
124 | FileOutputStream fOut = null;
125 | File file = new File(path,filename+".png");
126 | fOut = new FileOutputStream(file);
127 | screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut);
128 | fOut.flush();
129 | fOut.close();
130 | MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
131 | dialog3.dismiss();
132 | }
133 | catch(Exception e)
134 | {
135 | Log.i("exception",e.toString());
136 | }
137 |
138 |
139 |
140 |
141 | }
142 | });
143 | b4.setOnClickListener(new OnClickListener(){
144 | @Override
145 | public void onClick(View v2){
146 | String filename=q3.getText().toString();
147 | if(filename.length()<1)
148 | return;
149 | Bitmap screenBitmap = Bitmap.createBitmap(abs.getMeasuredWidth(),abs.getMeasuredHeight(),Bitmap.Config.ARGB_8888);
150 | Canvas canvas = new Canvas(screenBitmap);
151 | abs.draw(canvas);
152 |
153 |
154 | try{
155 | String state = Environment.getExternalStorageState();
156 | String path = Environment.getExternalStorageDirectory().toString();
157 | FileOutputStream fOut = null;
158 | File file = new File(path,filename+".jpeg");
159 | fOut = new FileOutputStream(file);
160 | screenBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
161 | fOut.flush();
162 | fOut.close();
163 | MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
164 | dialog3.dismiss();
165 | }
166 | catch(Exception e)
167 | {
168 | Log.i("exception",e.toString());
169 | }
170 |
171 |
172 |
173 |
174 | }
175 | });
176 | break;
177 | case R.id.help: final Dialog dialog1 = new Dialog(gtemp1.this);
178 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT,0.0F);
179 | LinearLayout l1=new LinearLayout(gtemp1.this);
180 | l1.setOrientation(LinearLayout.VERTICAL);
181 | TextView t3=new TextView(gtemp1.this);
182 | t3.setLayoutParams(params);
183 | t3.setText("Sure? Any unsaved");
184 | l1.addView(t3);
185 | TextView t4=new TextView(gtemp1.this);
186 | t4.setLayoutParams(params);
187 | t4.setText("data will be lost ");
188 | l1.addView(t4);
189 | final Button b2=new Button(gtemp1.this);
190 | b2.setLayoutParams(params);
191 | b2.setText("Help");
192 | l1.addView(b2);
193 | dialog1.setContentView(l1);
194 | dialog1.setTitle("Help");
195 | dialog1.show();
196 | b2.setOnClickListener(new OnClickListener(){
197 | @Override
198 | public void onClick(View v)
199 | {
200 | dialog1.dismiss();
201 | startActivity(new Intent(gtemp1.this,help.class));
202 | finish();
203 | }
204 | });
205 | break;
206 | }
207 | return true;
208 | }
209 |
210 | }
211 |
212 |
--------------------------------------------------------------------------------
/src/com/android/myapp/DragController.java:
--------------------------------------------------------------------------------
1 | package com.android.myapp;
2 |
3 | import java.util.ArrayList;
4 |
5 | import android.content.Context;
6 | import android.graphics.Bitmap;
7 | import android.graphics.Rect;
8 | import android.os.IBinder;
9 | import android.os.Vibrator;
10 | import android.util.DisplayMetrics;
11 | import android.view.KeyEvent;
12 | import android.view.MotionEvent;
13 | import android.view.View;
14 | import android.view.inputmethod.InputMethodManager;
15 | import android.view.WindowManager;
16 |
17 |
18 | public class DragController {
19 | private static final String TAG = "DragController";
20 |
21 | /** Indicates the drag is a move. */
22 | public static int DRAG_ACTION_MOVE = 0;
23 |
24 | /** Indicates the drag is a copy. */
25 | public static int DRAG_ACTION_COPY = 1;
26 |
27 | private static final int VIBRATE_DURATION = 35;
28 |
29 | private static final boolean PROFILE_DRAWING_DURING_DRAG = false;
30 |
31 | private Context mContext;
32 | private Vibrator mVibrator;
33 |
34 | // temporaries to avoid gc thrash
35 | private Rect mRectTemp = new Rect();
36 | private final int[] mCoordinatesTemp = new int[2];
37 |
38 | /** Whether or not we're dragging. */
39 | private boolean mDragging;
40 |
41 | /** X coordinate of the down event. */
42 | private float mMotionDownX;
43 |
44 | /** Y coordinate of the down event. */
45 | private float mMotionDownY;
46 |
47 | /** Info about the screen for clamping. */
48 | private DisplayMetrics mDisplayMetrics = new DisplayMetrics();
49 |
50 | /** Original view that is being dragged. */
51 | private View mOriginator;
52 |
53 | /** X offset from the upper-left corner of the cell to where we touched. */
54 | private float mTouchOffsetX;
55 |
56 | /** Y offset from the upper-left corner of the cell to where we touched. */
57 | private float mTouchOffsetY;
58 |
59 | /** Where the drag originated */
60 | private DragSource mDragSource;
61 |
62 | /** The data associated with the object being dragged */
63 | private Object mDragInfo;
64 |
65 | /** The view that moves around while you drag. */
66 | private DragView mDragView;
67 |
68 | /** Who can receive drop events */
69 | private ArrayList mDropTargets = new ArrayList();
70 |
71 | private DragListener mListener;
72 |
73 | /** The window token used as the parent for the DragView. */
74 | private IBinder mWindowToken;
75 |
76 | private View mMoveTarget;
77 |
78 | private DropTarget mLastDropTarget;
79 |
80 | private InputMethodManager mInputMethodManager;
81 |
82 | /**
83 | * Interface to receive notifications when a drag starts or stops
84 | */
85 | interface DragListener {
86 |
87 | /**
88 | * A drag has begun
89 | *
90 | * @param source An object representing where the drag originated
91 | * @param info The data associated with the object that is being dragged
92 | * @param dragAction The drag action: either {@link DragController#DRAG_ACTION_MOVE}
93 | * or {@link DragController#DRAG_ACTION_COPY}
94 | */
95 | void onDragStart(DragSource source, Object info, int dragAction);
96 |
97 | /**
98 | * The drag has eneded
99 | */
100 | void onDragEnd();
101 | }
102 |
103 | /**
104 | * Used to create a new DragLayer from XML.
105 | *
106 | * @param context The application's context.
107 | */
108 | public DragController(Context context) {
109 | mContext = context;
110 | mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
111 |
112 | }
113 |
114 | /**
115 | * Starts a drag.
116 | * It creates a bitmap of the view being dragged. That bitmap is what you see moving.
117 | * The actual view can be repositioned if that is what the onDrop handle chooses to do.
118 | *
119 | * @param v The view that is being dragged
120 | * @param source An object representing where the drag originated
121 | * @param dragInfo The data associated with the object that is being dragged
122 | * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or
123 | * {@link #DRAG_ACTION_COPY}
124 | */
125 | public void startDrag(View v, DragSource source, Object dragInfo, int dragAction) {
126 | mOriginator = v;
127 |
128 | Bitmap b = getViewBitmap(v);
129 |
130 | if (b == null) {
131 | // out of memory?
132 | return;
133 | }
134 |
135 | int[] loc = mCoordinatesTemp;
136 | v.getLocationOnScreen(loc);
137 | int screenX = loc[0];
138 | int screenY = loc[1];
139 |
140 | startDrag(b, screenX, screenY, 0, 0, b.getWidth(), b.getHeight(),
141 | source, dragInfo, dragAction);
142 |
143 | b.recycle();
144 |
145 | if (dragAction == DRAG_ACTION_MOVE) {
146 | v.setVisibility(View.GONE);
147 | }
148 | }
149 |
150 | /**
151 | * Starts a drag.
152 | *
153 | * @param b The bitmap to display as the drag image. It will be re-scaled to the
154 | * enlarged size.
155 | * @param screenX The x position on screen of the left-top of the bitmap.
156 | * @param screenY The y position on screen of the left-top of the bitmap.
157 | * @param textureLeft The left edge of the region inside b to use.
158 | * @param textureTop The top edge of the region inside b to use.
159 | * @param textureWidth The width of the region inside b to use.
160 | * @param textureHeight The height of the region inside b to use.
161 | * @param source An object representing where the drag originated
162 | * @param dragInfo The data associated with the object that is being dragged
163 | * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or
164 | * {@link #DRAG_ACTION_COPY}
165 | */
166 | public void startDrag(Bitmap b, int screenX, int screenY,
167 | int textureLeft, int textureTop, int textureWidth, int textureHeight,
168 | DragSource source, Object dragInfo, int dragAction) {
169 | if (PROFILE_DRAWING_DURING_DRAG) {
170 | android.os.Debug.startMethodTracing("Launcher");
171 | }
172 |
173 | // Hide soft keyboard, if visible
174 | if (mInputMethodManager == null) {
175 | mInputMethodManager = (InputMethodManager)
176 | mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
177 | }
178 | mInputMethodManager.hideSoftInputFromWindow(mWindowToken, 0);
179 |
180 | if (mListener != null) {
181 | mListener.onDragStart(source, dragInfo, dragAction);
182 | }
183 |
184 | int registrationX = ((int)mMotionDownX) - screenX;
185 | int registrationY = ((int)mMotionDownY) - screenY;
186 |
187 | mTouchOffsetX = mMotionDownX - screenX;
188 | mTouchOffsetY = mMotionDownY - screenY;
189 |
190 | mDragging = true;
191 | mDragSource = source;
192 | mDragInfo = dragInfo;
193 |
194 | mVibrator.vibrate(VIBRATE_DURATION);
195 | DragView dragView = mDragView = new DragView(mContext, b, registrationX, registrationY,
196 | textureLeft, textureTop, textureWidth, textureHeight);
197 | dragView.show(mWindowToken, (int)mMotionDownX, (int)mMotionDownY);
198 | }
199 |
200 | /**
201 | * Draw the view into a bitmap.
202 | */
203 | private Bitmap getViewBitmap(View v) {
204 | v.clearFocus();
205 | v.setPressed(false);
206 |
207 | boolean willNotCache = v.willNotCacheDrawing();
208 | v.setWillNotCacheDrawing(false);
209 |
210 | // Reset the drawing cache background color to fully transparent
211 | // for the duration of this operation
212 | int color = v.getDrawingCacheBackgroundColor();
213 | v.setDrawingCacheBackgroundColor(0);
214 |
215 | if (color != 0) {
216 | v.destroyDrawingCache();
217 | }
218 | v.buildDrawingCache();
219 | Bitmap cacheBitmap = v.getDrawingCache();
220 | if (cacheBitmap == null) {
221 | //Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException());
222 | return null;
223 | }
224 |
225 | Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
226 |
227 | // Restore the view
228 | v.destroyDrawingCache();
229 | v.setWillNotCacheDrawing(willNotCache);
230 | v.setDrawingCacheBackgroundColor(color);
231 |
232 | return bitmap;
233 | }
234 |
235 | /**
236 | * Call this from a drag source view like this:
237 | *
238 | *