Skip to content

Commit ad8647c

Browse files
committed
Initial import 2
0 parents  commit ad8647c

33 files changed

+623
-0
lines changed

.classpath

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry kind="lib" path="activation.jar"/>
7+
<classpathentry kind="lib" path="additionnal.jar"/>
8+
<classpathentry kind="lib" path="mail.jar"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>

.project

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Snap</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>

AndroidManifest.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="org.cygx1.snap"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
7+
<activity android:name=".Snap"
8+
android:label="@string/app_name">
9+
<intent-filter>
10+
<action android:name="android.intent.action.MAIN" />
11+
<category android:name="android.intent.category.LAUNCHER" />
12+
</intent-filter>
13+
</activity>
14+
15+
<activity android:name=".SnapPreferences" android:label="@string/app_prefs"></activity>
16+
17+
</application>
18+
19+
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
20+
<uses-feature android:name="android.hardware.camera" />
21+
<uses-feature android:name="android.hardware.camera.autofocus" />
22+
23+
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
24+
</manifest>

activation.jar

50.4 KB
Binary file not shown.

additionnal.jar

45.1 KB
Binary file not shown.

bin/Snap.apk

260 KB
Binary file not shown.

bin/classes.dex

498 KB
Binary file not shown.

bin/org/cygx1/snap/Mail.class

5.09 KB
Binary file not shown.

bin/org/cygx1/snap/Preview.class

3.56 KB
Binary file not shown.

bin/org/cygx1/snap/R$attr.class

328 Bytes
Binary file not shown.

bin/org/cygx1/snap/R$drawable.class

388 Bytes
Binary file not shown.

bin/org/cygx1/snap/R$layout.class

382 Bytes
Binary file not shown.

bin/org/cygx1/snap/R$string.class

589 Bytes
Binary file not shown.

bin/org/cygx1/snap/R$xml.class

378 Bytes
Binary file not shown.

bin/org/cygx1/snap/R.class

505 Bytes
Binary file not shown.

bin/org/cygx1/snap/Snap$1.class

2.04 KB
Binary file not shown.

bin/org/cygx1/snap/Snap$2.class

1.49 KB
Binary file not shown.

bin/org/cygx1/snap/Snap.class

4.54 KB
Binary file not shown.
547 Bytes
Binary file not shown.

bin/resources.ap_

11.6 KB
Binary file not shown.

default.properties

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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

gen/org/cygx1/snap/R.java

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 org.cygx1.snap;
9+
10+
public final class R {
11+
public static final class attr {
12+
}
13+
public static final class drawable {
14+
public static final int icon=0x7f020000;
15+
}
16+
public static final class layout {
17+
public static final int main=0x7f030000;
18+
}
19+
public static final class string {
20+
public static final int app_name=0x7f050001;
21+
public static final int app_prefs=0x7f050004;
22+
public static final int emailPref=0x7f050002;
23+
public static final int hello=0x7f050000;
24+
public static final int passwordPref=0x7f050003;
25+
public static final int recipientPref=0x7f050005;
26+
public static final int subjectPref=0x7f050006;
27+
}
28+
public static final class xml {
29+
public static final int snapprefs=0x7f040000;
30+
}
31+
}

mail.jar

430 KB
Binary file not shown.

res/drawable-hdpi/icon.png

4.05 KB
Loading

res/drawable-ldpi/icon.png

1.68 KB
Loading

res/drawable-mdpi/icon.png

2.51 KB
Loading

res/layout/main.xml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:orientation="vertical" android:layout_width="fill_parent"
4+
android:layout_height="fill_parent">
5+
</LinearLayout>

res/values/strings.xml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="hello">Hello World, Snap!</string>
4+
<string name="app_name">Snap</string>
5+
<string name="emailPref">emailPref</string>
6+
<string name="passwordPref">passwordPref</string>
7+
<string name="app_prefs">Snap Preferences</string>
8+
<string name="recipientPref">recipientPref</string>
9+
<string name="subjectPref">subjectPref</string>
10+
</resources>

res/xml/snapprefs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
3+
<EditTextPreference android:key="@string/emailPref"
4+
android:persistent="true" android:title="Gmail ID" />
5+
<EditTextPreference android:key="@string/passwordPref"
6+
android:persistent="true" android:title="Gmail password" android:password="true" />
7+
<EditTextPreference android:key="@string/recipientPref"
8+
android:persistent="true" android:title="Recipient email" android:summary="Who to send it to" />
9+
<EditTextPreference android:key="@string/subjectPref"
10+
android:persistent="true" android:title="Subject" android:summary="Default email subject" />
11+
</PreferenceScreen>

src/org/cygx1/snap/Mail.java

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
package org.cygx1.snap;
2+
3+
import java.util.Date;
4+
import java.util.Properties;
5+
6+
import javax.activation.CommandMap;
7+
import javax.activation.DataHandler;
8+
import javax.activation.DataSource;
9+
import javax.activation.FileDataSource;
10+
import javax.activation.MailcapCommandMap;
11+
import javax.mail.BodyPart;
12+
import javax.mail.Multipart;
13+
import javax.mail.PasswordAuthentication;
14+
import javax.mail.Session;
15+
import javax.mail.Transport;
16+
import javax.mail.internet.InternetAddress;
17+
import javax.mail.internet.MimeBodyPart;
18+
import javax.mail.internet.MimeMessage;
19+
import javax.mail.internet.MimeMultipart;
20+
21+
public class Mail extends javax.mail.Authenticator {
22+
private String _user;
23+
private String _pass;
24+
25+
private String[] _to;
26+
private String _from;
27+
28+
private String _port;
29+
private String _sport;
30+
31+
private String _host;
32+
33+
private String _subject;
34+
private String _body;
35+
36+
private boolean _auth;
37+
38+
private boolean _debuggable;
39+
40+
private Multipart _multipart;
41+
42+
public Mail() {
43+
_host = "smtp.gmail.com"; // default smtp server
44+
_port = "465"; // default smtp port
45+
_sport = "465"; // default socketfactory port
46+
47+
_user = ""; // username
48+
_pass = ""; // password
49+
_from = ""; // email sent from
50+
_subject = ""; // email subject
51+
_body = ""; // email body
52+
53+
_debuggable = false; // debug mode on or off - default off
54+
_auth = true; // smtp authentication - default on
55+
56+
_multipart = new MimeMultipart();
57+
58+
// There is something wrong with MailCap, javamail can not find a
59+
// handler for the multipart/mixed part, so this bit needs to be added.
60+
MailcapCommandMap mc = (MailcapCommandMap) CommandMap
61+
.getDefaultCommandMap();
62+
mc
63+
.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
64+
mc
65+
.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
66+
mc
67+
.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
68+
mc
69+
.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
70+
mc
71+
.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
72+
CommandMap.setDefaultCommandMap(mc);
73+
}
74+
75+
public Mail(String user, String pass) {
76+
this();
77+
78+
_user = user;
79+
_pass = pass;
80+
}
81+
82+
public boolean send() throws Exception {
83+
Properties props = _setProperties();
84+
85+
if (!_user.equals("") && !_pass.equals("") && _to.length > 0
86+
&& !_from.equals("") && !_subject.equals("")
87+
/* && !_body.equals("") */) {
88+
Session session = Session.getInstance(props, this);
89+
90+
MimeMessage msg = new MimeMessage(session);
91+
92+
msg.setFrom(new InternetAddress(_from));
93+
94+
InternetAddress[] addressTo = new InternetAddress[_to.length];
95+
for (int i = 0; i < _to.length; i++) {
96+
addressTo[i] = new InternetAddress(_to[i]);
97+
}
98+
msg.setRecipients(MimeMessage.RecipientType.TO, addressTo);
99+
100+
msg.setSubject(_subject);
101+
msg.setSentDate(new Date());
102+
103+
// setup message body
104+
BodyPart messageBodyPart = new MimeBodyPart();
105+
messageBodyPart.setText(_body);
106+
_multipart.addBodyPart(messageBodyPart);
107+
108+
// Put parts in message
109+
msg.setContent(_multipart);
110+
111+
// send email
112+
Transport.send(msg);
113+
114+
return true;
115+
} else {
116+
return false;
117+
}
118+
}
119+
120+
public void addAttachment(String filename) throws Exception {
121+
BodyPart messageBodyPart = new MimeBodyPart();
122+
DataSource source = new FileDataSource(filename);
123+
messageBodyPart.setDataHandler(new DataHandler(source));
124+
messageBodyPart.setFileName(filename);
125+
126+
_multipart.addBodyPart(messageBodyPart);
127+
}
128+
129+
@Override
130+
public PasswordAuthentication getPasswordAuthentication() {
131+
return new PasswordAuthentication(_user, _pass);
132+
}
133+
134+
private Properties _setProperties() {
135+
Properties props = new Properties();
136+
137+
props.put("mail.smtp.host", _host);
138+
139+
if (_debuggable) {
140+
props.put("mail.debug", "true");
141+
}
142+
143+
if (_auth) {
144+
props.put("mail.smtp.auth", "true");
145+
}
146+
147+
props.put("mail.smtp.port", _port);
148+
props.put("mail.smtp.socketFactory.port", _sport);
149+
props.put("mail.smtp.socketFactory.class",
150+
"javax.net.ssl.SSLSocketFactory");
151+
props.put("mail.smtp.socketFactory.fallback", "false");
152+
153+
return props;
154+
}
155+
156+
// the getters and setters
157+
public String getBody() {
158+
return _body;
159+
}
160+
161+
public void setBody(String _body) {
162+
this._body = _body;
163+
}
164+
165+
// more of the getters and setters …..
166+
167+
public void setTo(String[] toArr) {
168+
this._to = toArr;
169+
}
170+
171+
public void setFrom(String string) {
172+
this._from = string;
173+
}
174+
175+
public void setSubject(String string) {
176+
this._subject = string;
177+
}
178+
}

0 commit comments

Comments
 (0)