Skip to content

Commit db99ea3

Browse files
authored
Merge pull request #115 from FlowCrypt/0.0.9
0.0.9
2 parents e69eff7 + 8affa55 commit db99ea3

File tree

127 files changed

+6187
-2371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+6187
-2371
lines changed

.idea/markdown-navigator/profiles_settings.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FlowCrypt/build.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ buildscript {
1919
apply plugin: 'com.android.application'
2020
apply plugin: 'com.github.gfx.ribbonizer'
2121

22-
SimpleDateFormat simpleDateFormat = new SimpleDateFormat('dd_MM_yyyy_HH_mm');
22+
SimpleDateFormat simpleDateFormat = new SimpleDateFormat('yyyy_MM_dd_HH_mm');
2323

2424
android {
2525
compileSdkVersion COMPILE_SDK_VERSION as int
@@ -116,15 +116,16 @@ dependencies {
116116
compile "com.android.support:design:${ANDROID_SUPPORT_VERSION}"
117117
compile "com.android.support:preference-v14:${ANDROID_SUPPORT_VERSION}"
118118
compile "com.android.support:cardview-v7:${ANDROID_SUPPORT_VERSION}"
119+
compile "com.android.support:customtabs:${ANDROID_SUPPORT_VERSION}"
119120
compile 'com.android.support.constraint:constraint-layout:1.0.2'
120121

121122
compile "com.google.android.gms:play-services-base:${PLAY_SERVICES_VERSION}"
122123
compile "com.google.android.gms:play-services-auth:${PLAY_SERVICES_VERSION}"
123-
compile 'com.google.code.gson:gson:2.7'
124+
compile 'com.google.code.gson:gson:2.8.2'
124125

125126
compile "com.squareup.retrofit2:retrofit:${RETROFIT_VERSION}"
126127
compile "com.squareup.retrofit2:converter-gson:${RETROFIT_VERSION}"
127-
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
128+
compile "com.squareup.okhttp3:logging-interceptor:${OKHTTP_VERSION}"
128129

129130
compile "com.sun.mail:android-mail:${JAVA_MAIL_VERSION}"
130131
compile "com.sun.mail:android-activation:${JAVA_MAIL_VERSION}"
@@ -135,7 +136,7 @@ dependencies {
135136
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
136137
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
137138

138-
compile 'com.eclipsesource.j2v8:j2v8:4.6.0@aar'
139+
compile 'com.eclipsesource.j2v8:j2v8:4.8.0@aar'
139140
compile 'commons-io:commons-io:2.5'
140141
compile 'ch.acra:acra:4.9.2'
141142
compile 'com.hootsuite.android:nachos:1.1.1'

FlowCrypt/src/main/AndroidManifest.xml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1414
<!-- android.permission.READ_EXTERNAL_STORAGE used to import private keys -->
1515
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
16+
<!-- android.permission.WRITE_EXTERNAL_STORAGE used to save attachments -->
17+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1618

1719
<application
1820
android:name=".FlowCryptApplication"
19-
android:allowBackup="true"
21+
android:allowBackup="false"
2022
android:icon="@mipmap/ic_launcher"
2123
android:label="@string/app_name"
2224
android:supportsRtl="true"
@@ -44,13 +46,7 @@
4446
android:screenOrientation="portrait" />
4547

4648
<activity
47-
android:name=".ui.activity.ComposeActivity"
48-
android:label="@string/compose"
49-
android:screenOrientation="portrait" />
50-
51-
<activity
52-
android:name=".ui.activity.ReplyActivity"
53-
android:label="@string/reply"
49+
android:name=".ui.activity.CreateMessageActivity"
5450
android:screenOrientation="portrait" />
5551

5652
<activity
@@ -100,11 +96,21 @@
10096
android:label="@string/help_feedback_or_question"
10197
android:screenOrientation="portrait" />
10298

99+
<activity
100+
android:name=".ui.activity.settings.ExperimentalSettingsActivity"
101+
android:label="@string/experimental_settings"
102+
android:screenOrientation="portrait" />
103+
103104
<activity
104105
android:name=".ui.activity.HtmlViewFromAssetsRawActivity"
105106
android:label="@string/app_name"
106107
android:screenOrientation="portrait" />
107108

109+
<activity
110+
android:name=".ui.activity.AddNewAccountActivity"
111+
android:label="@string/adding_new_account"
112+
android:screenOrientation="portrait" />
113+
108114
<activity android:name=".ui.activity.DevSettingsActivity" />
109115

110116
<!-- Providers -->
@@ -114,6 +120,16 @@
114120
android:enabled="true"
115121
android:exported="false" />
116122

123+
<provider
124+
android:name="android.support.v4.content.FileProvider"
125+
android:authorities="${applicationId}.fileprovider"
126+
android:exported="false"
127+
android:grantUriPermissions="true">
128+
<meta-data
129+
android:name="android.support.FILE_PROVIDER_PATHS"
130+
android:resource="@xml/filepaths" />
131+
</provider>
132+
117133
<!-- Services -->
118134
<service
119135
android:name=".service.EmailAndNameUpdaterService"
@@ -126,6 +142,10 @@
126142
<service
127143
android:name=".service.CheckClipboardToFindPrivateKeyService"
128144
android:exported="false" />
145+
146+
<service
147+
android:name=".service.attachment.AttachmentDownloadManagerService"
148+
android:exported="false" />
129149
</application>
130150

131151
</manifest>

FlowCrypt/src/main/java/com/flowcrypt/email/Constants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ public class Constants {
4141
"preferences_key_is_write_logs_to_file_enable";
4242
public static final String PREFERENCES_KEY_IS_DETECT_MEMORY_LEAK_ENABLE =
4343
"preferences_key_is_detect_memory_leak_enable";
44+
45+
public static final String PREFERENCES_KEY_TEMP_LAST_AUTH_CREDENTIALS =
46+
"preferences_key_temp_last_auth_credentials";
4447
}

FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import com.squareup.leakcanary.LeakCanary;
1616

1717
import org.acra.ACRA;
18-
import org.acra.ReportingInteractionMode;
1918
import org.acra.annotation.ReportsCrashes;
19+
import org.acra.sender.HttpSender;
2020

2121
/**
2222
* The application class for FlowCrypt. Base class for maintaining global application state.
@@ -27,9 +27,9 @@
2727
2828
*/
2929
@ReportsCrashes(
30-
mailTo = Constants.ANDROID_DEVELOPER_SUPPORT_EMAIL,
31-
mode = ReportingInteractionMode.TOAST,
32-
resToastText = R.string.application_crashed)
30+
formUri = "https://api.cryptup.io/help/acra",
31+
httpMethod = HttpSender.Method.POST,
32+
reportType = HttpSender.Type.JSON)
3333
public class FlowCryptApplication extends Application {
3434

3535
@Override
@@ -42,9 +42,7 @@ public void onCreate() {
4242
@Override
4343
protected void attachBaseContext(Context base) {
4444
super.attachBaseContext(base);
45-
if (BuildConfig.DEBUG) {
46-
ACRA.init(this);
47-
}
45+
ACRA.init(this);
4846
}
4947

5048
/**
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Business Source License 1.0 © 2017 FlowCrypt Limited ([email protected]).
3+
* Use limitations apply. See https://github.com/FlowCrypt/flowcrypt-android/blob/master/LICENSE
4+
* Contributors: DenBond7
5+
*/
6+
7+
package com.flowcrypt.email.api.email;
8+
9+
import com.sun.mail.imap.IMAPFolder;
10+
11+
import java.util.Arrays;
12+
import java.util.List;
13+
import java.util.UUID;
14+
15+
import javax.mail.MessagingException;
16+
17+
/**
18+
* @author Denis Bondarenko
19+
* Date: 29.09.2017
20+
* Time: 15:31
21+
22+
*/
23+
24+
public class EmailUtil {
25+
/**
26+
* Generate an unique content id.
27+
*
28+
* @return
29+
*/
30+
public static String generateContentId() {
31+
return "<" + UUID.randomUUID().toString() + "@flowcrypt" + ">";
32+
}
33+
34+
/**
35+
* Check if current folder has {@link JavaEmailConstants#FOLDER_ATTRIBUTE_NO_SELECT}. If the
36+
* folder contains it attribute we will not show this folder in the list.
37+
*
38+
* @param imapFolder The {@link IMAPFolder} object.
39+
* @return true if current folder contains attribute
40+
* {@link JavaEmailConstants#FOLDER_ATTRIBUTE_NO_SELECT}, false otherwise.
41+
* @throws MessagingException
42+
*/
43+
public static boolean isFolderHasNoSelectAttribute(IMAPFolder imapFolder) throws MessagingException {
44+
List<String> attributes = Arrays.asList(imapFolder.getAttributes());
45+
return attributes.contains(JavaEmailConstants.FOLDER_ATTRIBUTE_NO_SELECT);
46+
}
47+
}

FlowCrypt/src/main/java/com/flowcrypt/email/api/email/Folder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.Arrays;
1313

1414
/**
15-
* This is a simple POJO object, which describe an information about the email folder.
15+
* This is a simple POJO object, which describe information about the email folder.
1616
*
1717
* @author DenBond7
1818
* Date: 07.06.2017

FlowCrypt/src/main/java/com/flowcrypt/email/api/email/FoldersManager.java

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.flowcrypt.email.database.dao.source.imap.ImapLabelsDaoSource;
1414
import com.sun.mail.imap.IMAPFolder;
1515

16-
import java.util.Arrays;
1716
import java.util.Collection;
1817
import java.util.LinkedHashMap;
1918
import java.util.LinkedList;
@@ -40,7 +39,7 @@ public FoldersManager() {
4039
}
4140

4241
/**
43-
* Generate a new {@link FoldersManager} using an information from the local database.
42+
* Generate a new {@link FoldersManager} using information from the local database.
4443
*
4544
* @param context Interface to global information about an application environment.
4645
* @param accountName The name of an account.
@@ -69,7 +68,7 @@ public static FoldersManager fromDatabase(Context context, String accountName) {
6968
/**
7069
* Generate a new {@link Folder}
7170
*
72-
* @param imapFolder The {@link IMAPFolder} object which contains an information about a
71+
* @param imapFolder The {@link IMAPFolder} object which contains information about a
7372
* remote folder.
7473
* @param folderAlias The folder alias.
7574
* @return
@@ -86,7 +85,7 @@ public static Folder generateFolder(IMAPFolder imapFolder, String folderAlias) t
8685
/**
8786
* Check if current folder is a custom label.
8887
*
89-
* @param folder The {@link IMAPFolder} object which contains an information about a
88+
* @param folder The {@link IMAPFolder} object which contains information about a
9089
* remote folder.
9190
* @return true if this label is a custom, false otherwise.
9291
* @throws MessagingException
@@ -176,14 +175,14 @@ public void clear() {
176175
/**
177176
* Add a new folder to {@link FoldersManager} to manage it.
178177
*
179-
* @param imapFolder The {@link IMAPFolder} object which contains an information about a
178+
* @param imapFolder The {@link IMAPFolder} object which contains information about a
180179
* remote folder.
181180
* @param folderAlias The folder alias.
182181
* @throws MessagingException
183182
*/
184183
public void addFolder(IMAPFolder imapFolder, String folderAlias) throws MessagingException {
185184
if (imapFolder != null
186-
&& !isFolderHasNoSelectAttribute(imapFolder)
185+
&& !EmailUtil.isFolderHasNoSelectAttribute(imapFolder)
187186
&& !TextUtils.isEmpty(imapFolder.getFullName())
188187
&& !folders.containsKey(imapFolder.getFullName())) {
189188
this.folders.put(prepareFolderKey(imapFolder), generateFolder(imapFolder, folderAlias));
@@ -193,7 +192,7 @@ public void addFolder(IMAPFolder imapFolder, String folderAlias) throws Messagin
193192
/**
194193
* Add a new folder to {@link FoldersManager} to manage it.
195194
*
196-
* @param folder The {@link Folder} object which contains an information about a
195+
* @param folder The {@link Folder} object which contains information about a
197196
* remote folder.
198197
*/
199198
public void addFolder(Folder folder) {
@@ -257,6 +256,16 @@ public List<Folder> getServerFolders() {
257256
return serverFolders;
258257
}
259258

259+
public Folder findInboxFolder() {
260+
for (Folder folder : getAllFolders()) {
261+
if (folder.getServerFullFolderName().equalsIgnoreCase(JavaEmailConstants.FOLDER_INBOX)) {
262+
return folder;
263+
}
264+
}
265+
266+
return null;
267+
}
268+
260269
private String prepareFolderKey(IMAPFolder imapFolder) throws MessagingException {
261270
FolderType folderType = getFolderTypeForImapFodler(imapFolder.getAttributes());
262271
if (folderType == null) {
@@ -276,21 +285,7 @@ private String prepareFolderKey(Folder folder) {
276285
}
277286

278287
/**
279-
* Check if current folder has {@link JavaEmailConstants#FOLDER_ATTRIBUTE_NO_SELECT}. If the
280-
* folder contains it attribute we will not show this folder in the list.
281-
*
282-
* @param imapFolder The {@link IMAPFolder} object.
283-
* @return true if current folder contains attribute
284-
* {@link JavaEmailConstants#FOLDER_ATTRIBUTE_NO_SELECT}, false otherwise.
285-
* @throws MessagingException
286-
*/
287-
private boolean isFolderHasNoSelectAttribute(IMAPFolder imapFolder) throws MessagingException {
288-
List<String> attributes = Arrays.asList(imapFolder.getAttributes());
289-
return attributes.contains(JavaEmailConstants.FOLDER_ATTRIBUTE_NO_SELECT);
290-
}
291-
292-
/**
293-
* This class contains an information about all servers folders types.
288+
* This class contains information about all servers folders types.
294289
*/
295290
public enum FolderType {
296291
INBOX("INBOX"),

FlowCrypt/src/main/java/com/flowcrypt/email/api/email/JavaEmailConstants.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,36 @@
1616
*/
1717

1818
public class JavaEmailConstants {
19+
/*IMAP*/
1920
public static final String PROPERTY_NAME_MAIL_IMAP_SSL_ENABLE = "mail.imap.ssl.enable";
20-
public static final String PROPERTY_NAME_MAIL_IMAP_AUTH_MECHANISMS = "mail.imap.auth" +
21-
".mechanisms";
22-
public static final String MECHANISMS_TYPE_XOAUTH2 = "XOAUTH2";
23-
public static final String GMAIL_IMAP_SERVER = "imap.gmail.com";
21+
public static final String PROPERTY_NAME_MAIL_IMAP_STARTTLS_ENABLE = "mail.imap.starttls.enable";
22+
public static final String PROPERTY_NAME_MAIL_IMAP_AUTH_MECHANISMS = "mail.imap.auth.mechanisms";
23+
public static final String PROPERTY_NAME_MAIL_IMAP_FETCH_SIZE = "mail.imap.fetchsize";
24+
25+
/*SMTP*/
26+
public static final String PROPERTY_NAME_MAIL_SMTP_AUTH = "mail.smtp.auth";
27+
public static final String PROPERTY_NAME_MAIL_SMTP_SSL_ENABLE = "mail.smtp.ssl.enable";
28+
public static final String PROPERTY_NAME_MAIL_SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable";
29+
public static final String PROPERTY_NAME_MAIL_SMTP_AUTH_MECHANISMS = "mail.smtp.auth.mechanisms";
30+
31+
/*AUTH MECHANISMS*/
32+
public static final String AUTH_MECHANISMS_XOAUTH2 = "XOAUTH2";
33+
public static final String AUTH_MECHANISMS_PLAIN = "PLAIN";
34+
public static final String AUTH_MECHANISMS_LOGIN = "LOGIN";
35+
36+
/*PROTOCOLS*/
2437
public static final String PROTOCOL_IMAP = "imap";
2538
public static final String PROTOCOL_SMTP = "smtp";
2639
public static final String PROTOCOL_GIMAPS = "gimaps";
2740
public static final String OAUTH2 = "oauth2:";
41+
2842
public static final String MIME_TYPE_MULTIPART = "multipart/*";
2943
public static final String MIME_TYPE_TEXT_PLAIN = "text/plain";
3044
public static final String MIME_TYPE_TEXT_HTML = "text/html";
3145

3246
public static final String FOLDER_ATTRIBUTE_NO_SELECT = "\\Noselect";
47+
48+
public static final String HEADER_X_ATTACHMENT_ID = "X-Attachment-Id";
49+
public static final String HEADER_CONTENT_ID = "Content-ID";
50+
public static final String FOLDER_INBOX = "INBOX";
3351
}

0 commit comments

Comments
 (0)