1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

Reduce MessageCompos LOC

This commit is contained in:
ligi 2015-01-29 16:36:15 +01:00
parent 828a580eb8
commit a51b608e5e
2 changed files with 32 additions and 44 deletions

View File

@ -88,6 +88,7 @@ import com.fsck.k9.crypto.PgpData;
import com.fsck.k9.fragment.ProgressDialogFragment; import com.fsck.k9.fragment.ProgressDialogFragment;
import com.fsck.k9.helper.ContactItem; import com.fsck.k9.helper.ContactItem;
import com.fsck.k9.helper.Contacts; import com.fsck.k9.helper.Contacts;
import com.fsck.k9.helper.SimpleTextWatcher;
import com.fsck.k9.mail.filter.Base64; import com.fsck.k9.mail.filter.Base64;
import com.fsck.k9.helper.HtmlConverter; import com.fsck.k9.helper.HtmlConverter;
import com.fsck.k9.helper.IdentityHelper; import com.fsck.k9.helper.IdentityHelper;
@ -615,63 +616,28 @@ public class MessageCompose extends K9Activity implements OnClickListener,
} }
}); });
TextWatcher watcher = new TextWatcher() { TextWatcher draftNeedsChangingTextWatcher = new SimpleTextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int before, int after) {
/* do nothing */
}
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
mDraftNeedsSaving = true; mDraftNeedsSaving = true;
} }
@Override
public void afterTextChanged(android.text.Editable s) { /* do nothing */ }
}; };
// For watching changes to the To:, Cc:, and Bcc: fields for auto-encryption on a matching TextWatcher signTextWatcher = new SimpleTextWatcher() {
// address.
TextWatcher recipientWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int before, int after) {
/* do nothing */
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
mDraftNeedsSaving = true;
}
@Override
public void afterTextChanged(android.text.Editable s) {
/* do nothing */
}
};
TextWatcher sigwatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int before, int after) {
/* do nothing */
}
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
mDraftNeedsSaving = true; mDraftNeedsSaving = true;
mSignatureChanged = true; mSignatureChanged = true;
} }
@Override
public void afterTextChanged(android.text.Editable s) { /* do nothing */ }
}; };
mToView.addTextChangedListener(recipientWatcher); mToView.addTextChangedListener(draftNeedsChangingTextWatcher);
mCcView.addTextChangedListener(recipientWatcher); mCcView.addTextChangedListener(draftNeedsChangingTextWatcher);
mBccView.addTextChangedListener(recipientWatcher); mBccView.addTextChangedListener(draftNeedsChangingTextWatcher);
mSubjectView.addTextChangedListener(watcher); mSubjectView.addTextChangedListener(draftNeedsChangingTextWatcher);
mMessageContentView.addTextChangedListener(watcher); mMessageContentView.addTextChangedListener(draftNeedsChangingTextWatcher);
mQuotedText.addTextChangedListener(watcher); mQuotedText.addTextChangedListener(draftNeedsChangingTextWatcher);
/* Yes, there really are people who ship versions of android without a contact picker */ /* Yes, there really are people who ship versions of android without a contact picker */
if (mContacts.hasContactPicker()) { if (mContacts.hasContactPicker()) {
@ -759,7 +725,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
mSignatureView = lowerSignature; mSignatureView = lowerSignature;
upperSignature.setVisibility(View.GONE); upperSignature.setVisibility(View.GONE);
} }
mSignatureView.addTextChangedListener(sigwatcher); mSignatureView.addTextChangedListener(signTextWatcher);
if (!mIdentity.getSignatureUse()) { if (!mIdentity.getSignatureUse()) {
mSignatureView.setVisibility(View.GONE); mSignatureView.setVisibility(View.GONE);

View File

@ -0,0 +1,22 @@
package com.fsck.k9.helper;
import android.text.Editable;
import android.text.TextWatcher;
/**
* all methods empty - but this way we can have TextWatchers with less boilder-plate where
* we just override the methods we want and not always al 3
*/
public class SimpleTextWatcher implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
}