mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-24 16:48:50 -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:
parent
3b6cccdf7a
commit
033e0d40de
@ -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>
|
||||
|
@ -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:layout_width="fill_parent"
|
||||
android:hint="@string/edit_identity_signature_hint"
|
||||
/>
|
||||
android:text="@string/account_settings_signature_use_label" />
|
||||
<LinearLayout
|
||||
android:id="@+id/signature_layout"
|
||||
android:layout_width="fill_parent"
|
||||
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>
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user