Skip to content

Commit

Permalink
Prepared a template for displaying details of a message. Described on…
Browse files Browse the repository at this point in the history
…ly logic. No design.
  • Loading branch information
DenBond7 committed May 4, 2017
1 parent fe0aa32 commit f14e433
Show file tree
Hide file tree
Showing 21 changed files with 619 additions and 41 deletions.
9 changes: 4 additions & 5 deletions FlowCrypt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,25 @@ dependencies {
compile "com.android.support:support-v4:${ANDROID_SUPPORT_VERSION}"
compile "com.android.support:appcompat-v7:${ANDROID_SUPPORT_VERSION}"
compile "com.android.support:design:${ANDROID_SUPPORT_VERSION}"
compile 'com.android.support.constraint:constraint-layout:1.0.2'

compile "com.google.android.gms:play-services-base:${PLAY_SERVICES_VERSION}"
compile "com.google.android.gms:play-services-auth:${PLAY_SERVICES_VERSION}"
compile 'com.google.code.gson:gson:2.7'

compile "com.squareup.retrofit2:retrofit:${RETROFIT_VERSION}"
compile "com.squareup.retrofit2:converter-gson:${RETROFIT_VERSION}"

compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'

compile "com.sun.mail:android-mail:${JAVA_MAIL_VERSION}"
compile "com.sun.mail:android-activation:${JAVA_MAIL_VERSION}"
compile("com.sun.mail:gimap:${JAVA_MAIL_VERSION}") {
exclude group: 'com.sun.mail'
}


testCompile "junit:junit:${JUNIT_VERSION}"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.7'
compile 'com.eclipsesource.j2v8:j2v8:4.6.0@aar'
compile 'commons-io:commons-io:2.5'
compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'
compile 'ch.acra:acra:4.9.2'
compile 'org.jsoup:jsoup:1.10.2'
}
8 changes: 8 additions & 0 deletions FlowCrypt/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.flowcrypt.email.ui.activity.SplashActivity" />
</activity>
<activity
android:name=".ui.activity.MessageDetailsActivity"
android:parentActivityName=".ui.activity.EmailManagerActivity"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.flowcrypt.email.ui.activity.EmailManagerActivity" />
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public class JavaEmailConstants {
public static final String PROTOCOL_IMAP = "imap";
public static final String PROTOCOL_GIMAPS = "gimaps";
public static final String OAUTH2 = "oauth2:";
public static final String CONTENT_TYPE_MULTIPART = "multipart";
public static final String MIME_TYPE_MULTIPART = "multipart/*";
public static final String MIME_TYPE_TEXT_PLAIN = "text/plain";
public static final String MIME_TYPE_TEXT_HTML = "text/html";
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Date;

/**
* Simple POJO class which describe a message model.
* Simple POJO class which describe a general message details.
*
* @author DenBond7
* Date: 28.04.2017
Expand All @@ -17,16 +17,16 @@
public class GeneralMessageDetails implements Parcelable {
public static final Creator<GeneralMessageDetails> CREATOR = new
Creator<GeneralMessageDetails>() {
@Override
public GeneralMessageDetails createFromParcel(Parcel source) {
return new GeneralMessageDetails(source);
}
@Override
public GeneralMessageDetails createFromParcel(Parcel source) {
return new GeneralMessageDetails(source);
}

@Override
public GeneralMessageDetails[] newArray(int size) {
return new GeneralMessageDetails[size];
}
};
@Override
public GeneralMessageDetails[] newArray(int size) {
return new GeneralMessageDetails[size];
}
};

private String from;
private String subject;
Expand All @@ -40,6 +40,9 @@ public GeneralMessageDetails(String from, String subject, Date receiveDate, long
this.uid = uid;
}

public GeneralMessageDetails() {
}

protected GeneralMessageDetails(Parcel in) {
this.from = in.readString();
this.subject = in.readString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.flowcrypt.email.api.email.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.Date;

/**
* Simple POJO class which describe a message model.
*
* @author DenBond7
* Date: 04.05.2017
* Time: 9:57
* E-mail: DenBond7@gmail.com
*/

public class MessageInfo implements Parcelable {
public static final Creator<MessageInfo> CREATOR = new Creator<MessageInfo>() {
@Override
public MessageInfo createFromParcel(Parcel source) {
return new MessageInfo(source);
}

@Override
public MessageInfo[] newArray(int size) {
return new MessageInfo[size];
}
};

private String subject;
private ArrayList<String> from;
private String message;
private Date receiveDate;

public MessageInfo() {
}

protected MessageInfo(Parcel in) {
this.subject = in.readString();
this.from = in.createStringArrayList();
this.message = in.readString();
long tmpReceiveDate = in.readLong();
this.receiveDate = tmpReceiveDate == -1 ? null : new Date(tmpReceiveDate);
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.subject);
dest.writeStringList(this.from);
dest.writeString(this.message);
dest.writeLong(this.receiveDate != null ? this.receiveDate.getTime() : -1);
}

@Override
public String toString() {
return "MessageInfo{" +
"subject='" + subject + '\'' +
", from=" + from +
", message='" + message + '\'' +
", receiveDate=" + receiveDate +
'}';
}

public String getSubject() {
return subject;
}

public void setSubject(String subject) {
this.subject = subject;
}

public ArrayList<String> getFrom() {
return from;
}

public void setFrom(ArrayList<String> from) {
this.from = from;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public Date getReceiveDate() {
return receiveDate;
}

public void setReceiveDate(Date receiveDate) {
this.receiveDate = receiveDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void handleSignInResult(GoogleSignInResult googleSignInResult, boolean is
UIUtil.showInfoSnackbar(getRootView(), googleSignInResult.getStatus()
.getStatusMessage());
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.flowcrypt.email.ui.activity;

import android.accounts.Account;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;

import com.flowcrypt.email.BuildConfig;
import com.flowcrypt.email.R;
import com.flowcrypt.email.api.email.model.GeneralMessageDetails;
import com.flowcrypt.email.ui.activity.base.BaseAuthenticationActivity;
import com.flowcrypt.email.ui.activity.fragment.MessageDetailsFragment;
import com.flowcrypt.email.util.UIUtil;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;

/**
* This activity describe details of some message.
*
* @author DenBond7
* Date: 03.05.2017
* Time: 16:29
* E-mail: DenBond7@gmail.com
*/
public class MessageDetailsActivity extends BaseAuthenticationActivity {
public static final String EXTRA_KEY_GENERAL_MESSAGE_DETAILS = BuildConfig.APPLICATION_ID + "" +
".EXTRA_KEY_GENERAL_MESSAGE_DETAILS";

private GeneralMessageDetails generalMessageDetails;

public static Intent getIntent(Context context, GeneralMessageDetails generalMessageDetails) {
Intent intent = new Intent(context, MessageDetailsActivity.class);
intent.putExtra(EXTRA_KEY_GENERAL_MESSAGE_DETAILS, generalMessageDetails);
return intent;
}

@Override
public View getRootView() {
return null;
}

@Override
public void handleSignInResult(GoogleSignInResult googleSignInResult, boolean isOnStartCall) {
if (googleSignInResult.isSuccess()) {
GoogleSignInAccount googleSignInAccount = googleSignInResult.getSignInAccount();
if (googleSignInAccount != null) {
updateMessageDetailsFragment(googleSignInAccount.getAccount());
}
} else if (!TextUtils.isEmpty(googleSignInResult.getStatus().getStatusMessage())) {
UIUtil.showInfoSnackbar(getRootView(), googleSignInResult.getStatus()
.getStatusMessage());
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initViews();
if (getIntent() != null && getIntent().hasExtra(EXTRA_KEY_GENERAL_MESSAGE_DETAILS)) {
this.generalMessageDetails = getIntent().getParcelableExtra
(EXTRA_KEY_GENERAL_MESSAGE_DETAILS);
}
}

private void updateMessageDetailsFragment(Account account) {
MessageDetailsFragment messageDetailsFragment = (MessageDetailsFragment)
getSupportFragmentManager()
.findFragmentById(R.id.messageDetailsFragment);

if (messageDetailsFragment != null) {
messageDetailsFragment.setGeneralMessageDetails(generalMessageDetails);
messageDetailsFragment.updateAccount(account);
}
}

private void initViews() {
setContentView(R.layout.activity_message_details);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}

}
Loading

0 comments on commit f14e433

Please sign in to comment.