Skip to content

Commit bed27cb

Browse files
committed
Added use the right variant of strings when compose different messages.. | Close #72
1 parent 918a7ca commit bed27cb

File tree

11 files changed

+82
-13
lines changed

11 files changed

+82
-13
lines changed

FlowCrypt/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
<activity
4747
android:name=".ui.activity.SecureComposeActivity"
48-
android:label="@string/secure_compose"
48+
android:label="@string/compose"
4949
android:screenOrientation="portrait" />
5050

5151
<activity

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/SecureComposeActivity.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.view.View;
1111

1212
import com.flowcrypt.email.R;
13+
import com.flowcrypt.email.model.MessageEncryptionType;
1314
import com.flowcrypt.email.ui.activity.base.BaseSendingMessageActivity;
1415
import com.flowcrypt.email.ui.activity.fragment.SecureComposeFragment;
1516

@@ -70,9 +71,20 @@ protected void notifyFragmentAboutErrorFromService(int requestCode, int errorTyp
7071
}
7172
}
7273

74+
@Override
75+
protected void notifyFragmentAboutChangeMessageEncryptionType(MessageEncryptionType
76+
messageEncryptionType) {
77+
SecureComposeFragment secureComposeFragment = (SecureComposeFragment)
78+
getSupportFragmentManager().findFragmentById(R.id.secureComposeFragment);
79+
80+
if (secureComposeFragment != null) {
81+
secureComposeFragment.onMessageEncryptionTypeChange(messageEncryptionType);
82+
}
83+
}
84+
7385
@Override
7486
protected String getSecurityTitle() {
75-
return getString(R.string.secure_compose);
87+
return getString(R.string.compose);
7688
}
7789

7890
@Override

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/SecureReplyActivity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,15 @@ protected void notifyFragmentAboutErrorFromService(int requestCode, int errorTyp
9999
secureReplyFragment.onErrorOccurred(requestCode, errorType);
100100
}
101101
}
102+
103+
@Override
104+
protected void notifyFragmentAboutChangeMessageEncryptionType(MessageEncryptionType
105+
messageEncryptionType) {
106+
SecureReplyFragment secureReplyFragment = (SecureReplyFragment)
107+
getSupportFragmentManager().findFragmentById(R.id.secureReplyFragment);
108+
109+
if (secureReplyFragment != null) {
110+
secureReplyFragment.onMessageEncryptionTypeChange(messageEncryptionType);
111+
}
112+
}
102113
}

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/base/BaseSendingMessageActivity.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public abstract class BaseSendingMessageActivity extends BaseBackStackSyncActivi
6262

6363
protected abstract void notifyFragmentAboutErrorFromService(int requestCode, int errorType);
6464

65+
protected abstract void notifyFragmentAboutChangeMessageEncryptionType(MessageEncryptionType
66+
messageEncryptionType);
67+
6568
@Override
6669
public void onCreate(@Nullable Bundle savedInstanceState) {
6770
super.onCreate(savedInstanceState);
@@ -79,7 +82,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
7982
if (messageEncryptionType == null) {
8083
messageEncryptionType = MessageEncryptionType.ENCRYPTED;
8184
} else {
82-
onChangeMessageEncryptedType(messageEncryptionType);
85+
onMessageEncryptionTypeChange(messageEncryptionType);
8386
}
8487
}
8588
}
@@ -111,11 +114,11 @@ public boolean onOptionsItemSelected(MenuItem item) {
111114
case R.id.menuActionSwitchType:
112115
switch (messageEncryptionType) {
113116
case ENCRYPTED:
114-
onChangeMessageEncryptedType(MessageEncryptionType.STANDARD);
117+
onMessageEncryptionTypeChange(MessageEncryptionType.STANDARD);
115118
break;
116119

117120
case STANDARD:
118-
onChangeMessageEncryptedType(MessageEncryptionType.ENCRYPTED);
121+
onMessageEncryptionTypeChange(MessageEncryptionType.ENCRYPTED);
119122
break;
120123
}
121124
return true;
@@ -177,7 +180,7 @@ public String getSenderEmail() {
177180
}
178181

179182
@Override
180-
public void onChangeMessageEncryptedType(MessageEncryptionType messageEncryptionType) {
183+
public void onMessageEncryptionTypeChange(MessageEncryptionType messageEncryptionType) {
181184
this.messageEncryptionType = messageEncryptionType;
182185
switch (messageEncryptionType) {
183186
case ENCRYPTED:
@@ -198,6 +201,7 @@ public void onChangeMessageEncryptedType(MessageEncryptionType messageEncryption
198201
}
199202

200203
invalidateOptionsMenu();
204+
notifyFragmentAboutChangeMessageEncryptionType(messageEncryptionType);
201205
}
202206

203207
@Override

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/SecureComposeFragment.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.os.Bundle;
1313
import android.support.annotation.Nullable;
1414
import android.support.design.widget.Snackbar;
15+
import android.support.design.widget.TextInputLayout;
1516
import android.text.SpannableStringBuilder;
1617
import android.text.TextUtils;
1718
import android.view.LayoutInflater;
@@ -56,6 +57,7 @@ public class SecureComposeFragment extends BaseSendSecurityMessageFragment imple
5657
private NachoTextView recipientEditTextView;
5758
private EditText editTextEmailSubject;
5859
private EditText editTextEmailMessage;
60+
private TextInputLayout textInputLayoutEmailMessage;
5961
private View layoutContent;
6062
private View progressBarCheckContactsDetails;
6163

@@ -227,6 +229,21 @@ public void handleSuccessLoaderResult(int loaderId, Object result) {
227229
}
228230
}
229231

232+
@Override
233+
public void onMessageEncryptionTypeChange(MessageEncryptionType messageEncryptionType) {
234+
String emailMassageHint = null;
235+
switch (messageEncryptionType) {
236+
case ENCRYPTED:
237+
emailMassageHint = getString(R.string.prompt_compose_security_email);
238+
break;
239+
240+
case STANDARD:
241+
emailMassageHint = getString(R.string.prompt_compose_standard_email);
242+
break;
243+
}
244+
textInputLayoutEmailMessage.setHint(emailMassageHint);
245+
}
246+
230247
/**
231248
* Remove the current {@link PgpContact} from recipients.
232249
*
@@ -280,6 +297,8 @@ private void initViews(View view) {
280297

281298
editTextEmailSubject = (EditText) view.findViewById(R.id.editTextEmailSubject);
282299
editTextEmailMessage = (EditText) view.findViewById(R.id.editTextEmailMessage);
300+
textInputLayoutEmailMessage = (TextInputLayout) view.findViewById(R.id
301+
.textInputLayoutEmailMessage);
283302

284303
layoutContent = view.findViewById(R.id.scrollView);
285304
progressBarCheckContactsDetails = view.findViewById(R.id.progressBarCheckContactsDetails);

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/SecureReplyFragment.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.os.Bundle;
1010
import android.support.annotation.Nullable;
1111
import android.support.design.widget.Snackbar;
12+
import android.support.design.widget.TextInputLayout;
1213
import android.text.TextUtils;
1314
import android.view.LayoutInflater;
1415
import android.view.Menu;
@@ -53,10 +54,26 @@ public class SecureReplyFragment extends BaseSendSecurityMessageFragment {
5354
private IncomingMessageInfo incomingMessageInfo;
5455
private View layoutContent;
5556
private View progressBarCheckContactsDetails;
57+
private TextInputLayout textInputLayoutReplyEmailMessage;
5658

5759
public SecureReplyFragment() {
5860
}
5961

62+
@Override
63+
public void onMessageEncryptionTypeChange(MessageEncryptionType messageEncryptionType) {
64+
String emailMassageHint = null;
65+
switch (messageEncryptionType) {
66+
case ENCRYPTED:
67+
emailMassageHint = getString(R.string.prompt_compose_security_email);
68+
break;
69+
70+
case STANDARD:
71+
emailMassageHint = getString(R.string.prompt_compose_standard_email);
72+
break;
73+
}
74+
textInputLayoutReplyEmailMessage.setHint(emailMassageHint);
75+
}
76+
6077
@Override
6178
public void onCreate(@Nullable Bundle savedInstanceState) {
6279
super.onCreate(savedInstanceState);
@@ -188,10 +205,12 @@ private void updateViews() {
188205

189206
private void initViews(View view) {
190207
this.textViewReplyRecipient = (TextView) view.findViewById(R.id.textViewReplyRecipient);
191-
this.editTextReplyEmailMessage = (EditText) view.findViewById(R.id
192-
.editTextReplyEmailMessage);
208+
this.editTextReplyEmailMessage =
209+
(EditText) view.findViewById(R.id.editTextReplyEmailMessage);
210+
this.textInputLayoutReplyEmailMessage =
211+
(TextInputLayout) view.findViewById(R.id.textInputLayoutReplyEmailMessage);
193212
this.layoutContent = view.findViewById(R.id.layoutForm);
194-
this.progressBarCheckContactsDetails = view.findViewById(R.id
195-
.progressBarCheckContactsDetails);
213+
this.progressBarCheckContactsDetails =
214+
view.findViewById(R.id.progressBarCheckContactsDetails);
196215
}
197216
}

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/base/BaseSendSecurityMessageFragment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public BaseSendSecurityMessageFragment() {
6161
pgpContacts = new ArrayList<>();
6262
}
6363

64+
public abstract void onMessageEncryptionTypeChange(MessageEncryptionType messageEncryptionType);
65+
6466
/**
6567
* Generate an outgoing message info from entered information by user.
6668
*
@@ -312,7 +314,7 @@ public boolean isMessageSendingNow() {
312314
* @param messageEncryptionType The new message encryption type.
313315
*/
314316
protected void switchMessageEncryptionType(MessageEncryptionType messageEncryptionType) {
315-
onChangeMessageEncryptedTypeListener.onChangeMessageEncryptedType(messageEncryptionType);
317+
onChangeMessageEncryptedTypeListener.onMessageEncryptionTypeChange(messageEncryptionType);
316318
}
317319

318320
/**

FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/listeners/OnChangeMessageEncryptedTypeListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public interface OnChangeMessageEncryptedTypeListener {
2424
*
2525
* @param messageEncryptionType The new message encryption type.
2626
*/
27-
void onChangeMessageEncryptedType(MessageEncryptionType messageEncryptionType);
27+
void onMessageEncryptionTypeChange(MessageEncryptionType messageEncryptionType);
2828

2929
MessageEncryptionType getMessageEncryptionType();
3030
}

FlowCrypt/src/main/res/layout/fragment_secure_compose.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
</android.support.design.widget.TextInputLayout>
7878

7979
<android.support.design.widget.TextInputLayout
80+
android:id="@+id/textInputLayoutEmailMessage"
8081
android:layout_width="match_parent"
8182
android:layout_height="wrap_content">
8283

FlowCrypt/src/main/res/layout/fragment_security_reply.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
app:layout_constraintTop_toTopOf="@+id/textViewReplyRecipient" />
5757

5858
<android.support.design.widget.TextInputLayout
59+
android:id="@+id/textInputLayoutReplyEmailMessage"
5960
android:layout_width="0dp"
6061
android:layout_height="wrap_content"
6162
android:layout_marginTop="@dimen/default_margin_content_small"

0 commit comments

Comments
 (0)