1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

Optional signatures on per identity basis. Original patch by jiri.tyr (thanks!) slightly modified by me.

Fixes issue 461
This commit is contained in:
cketti 2010-02-08 17:47:00 +00:00
parent 3b6cccdf7a
commit 033e0d40de
9 changed files with 1209 additions and 1063 deletions

View File

@ -48,38 +48,50 @@
android:inputType="textEmailAddress"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="@string/account_settings_signature_label"
android:layout_height="wrap_content"
<CheckBox
android:id="@+id/account_signature_use"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
<EditText
android:id="@+id/account_signature"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView
android:text="@string/account_settings_signature__location_label"
android:layout_height="wrap_content"
android:text="@string/account_settings_signature_use_label" />
<LinearLayout
android:id="@+id/account_signature_layout"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
<RadioGroup
android:id="@+id/account_signature_location"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="@+id/account_signature_location_before_quoted_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text="@string/account_settings_signature_label"
android:layout_height="wrap_content"
android:text="@string/account_settings_signature__location_before_quoted_text" />
<RadioButton
android:id="@+id/account_signature_location_after_quoted_text"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
<EditText
android:id="@+id/account_signature"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
android:layout_height="wrap_content"
android:text="@string/account_settings_signature__location_after_quoted_text" />
</RadioGroup>
android:layout_width="fill_parent" />
<TextView
android:text="@string/account_settings_signature__location_label"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
<RadioGroup
android:id="@+id/account_signature_location"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="@+id/account_signature_location_before_quoted_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/account_settings_signature__location_before_quoted_text" />
<RadioButton
android:id="@+id/account_signature_location_after_quoted_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/account_settings_signature__location_after_quoted_text" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -62,18 +62,28 @@
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
-->
<TextView
android:text="@string/edit_identity_signature_label"
android:layout_height="wrap_content"
<CheckBox
android:id="@+id/signature_use"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
<EditText
android:id="@+id/signature"
android:singleLine="false"
android:layout_height="wrap_content"
android:text="@string/account_settings_signature_use_label" />
<LinearLayout
android:id="@+id/signature_layout"
android:layout_width="fill_parent"
android:hint="@string/edit_identity_signature_hint"
/>
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:text="@string/edit_identity_signature_label"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary" />
<EditText
android:id="@+id/signature"
android:singleLine="false"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="@string/edit_identity_signature_hint"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -506,6 +506,7 @@ Willkommen zum \"K-9 Mail\"-Setup. K-9 ist eine quelloffene E-Mail-Anwendung f
<string name="edit_identity_signature_label">Signatur</string>
<string name="edit_identity_signature_hint">(Optional)</string>
<string name="account_settings_signature_use_label">Signatur verwenden</string>
<string name="account_settings_signature_label">Signatur</string>
<string name="account_settings_signature_summary">Signatur an jede Nachricht anfügen</string>

View File

@ -540,6 +540,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="edit_identity_signature_label">Signature</string>
<string name="edit_identity_signature_hint">(Optional)</string>
<string name="account_settings_signature_use_label">Use Signature</string>
<string name="account_settings_signature_label">Signature</string>
<string name="account_settings_signature_summary">Append a signature to every message you send</string>

View File

@ -114,6 +114,7 @@ public class Account implements Serializable
identities = new ArrayList<Identity>();
Identity identity = new Identity();
identity.setSignatureUse(true);
identity.setSignature(context.getString(R.string.default_signature));
identity.setDescription(context.getString(R.string.default_identity_description));
identities.add(identity);
@ -125,6 +126,8 @@ public class Account implements Serializable
String mName;
String mEmail;
String mSignature;
boolean mSignatureUse;
public String getName()
{
return mName;
@ -141,6 +144,14 @@ public class Account implements Serializable
{
mEmail = email;
}
public boolean getSignatureUse()
{
return mSignatureUse;
}
public void setSignatureUse(boolean signatureUse)
{
mSignatureUse = signatureUse;
}
public String getSignature()
{
return mSignature;
@ -300,6 +311,7 @@ public class Account implements Serializable
gotOne = false;
String name = prefs.getString(mUuid + ".name." + ident, null);
String email = prefs.getString(mUuid + ".email." + ident, null);
boolean signatureUse = prefs.getBoolean(mUuid + ".signatureUse." + ident, true);
String signature = prefs.getString(mUuid + ".signature." + ident, null);
String description = prefs.getString(mUuid + ".description." + ident, null);
if (email != null)
@ -307,6 +319,7 @@ public class Account implements Serializable
Identity identity = new Identity();
identity.setName(name);
identity.setEmail(email);
identity.setSignatureUse(signatureUse);
identity.setSignature(signature);
identity.setDescription(description);
newIdentities.add(identity);
@ -316,14 +329,17 @@ public class Account implements Serializable
}
while (gotOne);
//FIXME: This can never be true?
if (newIdentities.size() == 0)
{
String name = prefs.getString(mUuid + ".name", null);
String email = prefs.getString(mUuid + ".email", null);
boolean signatureUse = prefs.getBoolean(mUuid + ".signatureUse", true);
String signature = prefs.getString(mUuid + ".signature", null);
Identity identity = new Identity();
identity.setName(name);
identity.setEmail(email);
identity.setSignatureUse(signatureUse);
identity.setSignature(signature);
identity.setDescription(email);
newIdentities.add(identity);
@ -344,6 +360,7 @@ public class Account implements Serializable
{
editor.remove(mUuid + ".name." + ident);
editor.remove(mUuid + ".email." + ident);
editor.remove(mUuid + ".signatureUse." + ident);
editor.remove(mUuid + ".signature." + ident);
editor.remove(mUuid + ".description." + ident);
gotOne = true;
@ -362,6 +379,7 @@ public class Account implements Serializable
{
editor.putString(mUuid + ".name." + ident, identity.getName());
editor.putString(mUuid + ".email." + ident, identity.getEmail());
editor.putBoolean(mUuid + ".signatureUse." + ident, identity.getSignatureUse());
editor.putString(mUuid + ".signature." + ident, identity.getSignature());
editor.putString(mUuid + ".description." + ident, identity.getDescription());
ident++;
@ -423,6 +441,16 @@ public class Account implements Serializable
identities.get(0).setName(name);
}
public boolean getSignatureUse()
{
return identities.get(0).getSignatureUse();
}
public void setSignatureUse(boolean signatureUse)
{
identities.get(0).setSignatureUse(signatureUse);
}
public String getSignature()
{
return identities.get(0).getSignature();

View File

@ -2,7 +2,12 @@ package com.fsck.k9.activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import com.fsck.k9.Account;
import com.fsck.k9.K9Activity;
import com.fsck.k9.Preferences;
@ -21,7 +26,9 @@ public class EditIdentity extends K9Activity
private Account.Identity mIdentity;
private int mIdentityIndex;
private EditText mDescriptionView;
private CheckBox mSignatureUse;
private EditText mSignatureView;
private LinearLayout mSignatureLayout;
private EditText mEmailView;
// private EditText mAlwaysBccView;
private EditText mNameView;
@ -63,8 +70,33 @@ public class EditIdentity extends K9Activity
// mAccountAlwaysBcc = (EditText)findViewById(R.id.bcc);
// mAccountAlwaysBcc.setText(mIdentity.getAlwaysBcc());
mSignatureLayout = (LinearLayout)findViewById(R.id.signature_layout);
mSignatureUse = (CheckBox)findViewById(R.id.signature_use);
mSignatureView = (EditText)findViewById(R.id.signature);
mSignatureView.setText(mIdentity.getSignature());
mSignatureUse.setChecked(mIdentity.getSignatureUse());
mSignatureUse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if (isChecked)
{
mSignatureLayout.setVisibility(View.VISIBLE);
mSignatureView.setText(mIdentity.getSignature());
}
else
{
mSignatureLayout.setVisibility(View.GONE);
}
}
});
if (mSignatureUse.isChecked())
{
mSignatureView.setText(mIdentity.getSignature());
}
else
{
mSignatureLayout.setVisibility(View.GONE);
}
}
@Override
@ -80,6 +112,7 @@ public class EditIdentity extends K9Activity
mIdentity.setEmail(mEmailView.getText().toString());
// mIdentity.setAlwaysBcc(mAccountAlwaysBcc.getText().toString());
mIdentity.setName(mNameView.getText().toString());
mIdentity.setSignatureUse(mSignatureUse.isChecked());
mIdentity.setSignature(mSignatureView.getText().toString());
List<Account.Identity> identities = mAccount.getIdentities();

View File

@ -494,6 +494,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
mSignatureView.addTextChangedListener(sigwatcher);
if (!mIdentity.getSignatureUse())
{
mSignatureView.setVisibility(View.GONE);
}
if (!mSourceMessageProcessed)
{
updateFrom();
@ -740,11 +745,14 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private String appendSignature(String text)
{
String signature= mSignatureView.getText().toString();
if (signature != null && ! signature.contentEquals(""))
if (mIdentity.getSignatureUse())
{
text += "\n" + signature;
String signature = mSignatureView.getText().toString();
if (signature != null && !signature.contentEquals(""))
{
text += "\n" + signature;
}
}
return text;
@ -1037,7 +1045,15 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private void updateSignature()
{
mSignatureView.setText(mIdentity.getSignature());
if (mIdentity.getSignatureUse())
{
mSignatureView.setText(mIdentity.getSignature());
mSignatureView.setVisibility(View.VISIBLE);
}
else
{
mSignatureView.setVisibility(View.GONE);
}
}
public void onClick(View view)

View File

@ -134,6 +134,9 @@ public class AccountSetupBasics extends K9Activity
boolean valid = Utility.requiredFieldValid(mEmailView)
&& Utility.requiredFieldValid(mPasswordView)
&& mEmailValidator.isValid(email);
//FIXME: "foo@bar .com" will validate
/*&& email.contains("@"); */ // Not sure if this is a good idea or not
mNextButton.setEnabled(valid);
mManualSetupButton.setEnabled(valid);

View File

@ -4,7 +4,12 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import com.fsck.k9.Account;
import com.fsck.k9.K9Activity;
@ -22,9 +27,10 @@ public class AccountSetupComposition extends K9Activity
private EditText mAccountEmail;
private EditText mAccountAlwaysBcc;
private EditText mAccountName;
private CheckBox mAccountSignatureUse;
private RadioButton mAccountSignatureBeforeLocation;
private RadioButton mAccountSignatureAfterLocation;
private LinearLayout mAccountSignatureLayout;
public static void actionEditCompositionSettings(Activity context, Account account)
{
@ -62,14 +68,46 @@ public class AccountSetupComposition extends K9Activity
mAccountAlwaysBcc = (EditText)findViewById(R.id.account_always_bcc);
mAccountAlwaysBcc.setText(mAccount.getAlwaysBcc());
mAccountSignatureLayout = (LinearLayout)findViewById(R.id.account_signature_layout);
mAccountSignatureUse = (CheckBox)findViewById(R.id.account_signature_use);
boolean useSignature = mAccount.getSignatureUse();
mAccountSignatureUse.setChecked(useSignature);
mAccountSignatureUse.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if (isChecked)
{
mAccountSignatureLayout.setVisibility(View.VISIBLE);
mAccountSignature.setText(mAccount.getSignature());
boolean isSignatureBeforeQuotedText = mAccount.isSignatureBeforeQuotedText();
mAccountSignatureBeforeLocation.setChecked(isSignatureBeforeQuotedText);
mAccountSignatureAfterLocation.setChecked(!isSignatureBeforeQuotedText);
}
else
{
mAccountSignatureLayout.setVisibility(View.GONE);
}
}
});
mAccountSignature = (EditText)findViewById(R.id.account_signature);
mAccountSignature.setText(mAccount.getSignature());
mAccountSignatureBeforeLocation = (RadioButton)findViewById(R.id.account_signature_location_before_quoted_text);
mAccountSignatureAfterLocation = (RadioButton)findViewById(R.id.account_signature_location_after_quoted_text);
boolean isSignatureBeforeQuotedText = mAccount.isSignatureBeforeQuotedText();
mAccountSignatureBeforeLocation.setChecked(isSignatureBeforeQuotedText);
mAccountSignatureAfterLocation.setChecked(!isSignatureBeforeQuotedText);
if (useSignature)
{
mAccountSignature.setText(mAccount.getSignature());
boolean isSignatureBeforeQuotedText = mAccount.isSignatureBeforeQuotedText();
mAccountSignatureBeforeLocation.setChecked(isSignatureBeforeQuotedText);
mAccountSignatureAfterLocation.setChecked(!isSignatureBeforeQuotedText);
}
else
{
mAccountSignatureLayout.setVisibility(View.GONE);
}
}
@Override
@ -84,9 +122,13 @@ public class AccountSetupComposition extends K9Activity
mAccount.setEmail(mAccountEmail.getText().toString());
mAccount.setAlwaysBcc(mAccountAlwaysBcc.getText().toString());
mAccount.setName(mAccountName.getText().toString());
mAccount.setSignature(mAccountSignature.getText().toString());
boolean isSignatureBeforeQuotedText = mAccountSignatureBeforeLocation.isChecked();
mAccount.setSignatureBeforeQuotedText(isSignatureBeforeQuotedText);
mAccount.setSignatureUse(mAccountSignatureUse.isChecked());
if (mAccountSignatureUse.isChecked())
{
mAccount.setSignature(mAccountSignature.getText().toString());
boolean isSignatureBeforeQuotedText = mAccountSignatureBeforeLocation.isChecked();
mAccount.setSignatureBeforeQuotedText(isSignatureBeforeQuotedText);
}
mAccount.save(Preferences.getPreferences(this));
}