Android Open Source - BlitzMail Encrypted Edit Text Preference






From Project

Back to project page BlitzMail.

License

The source code is released under:

GNU General Public License

If you think the Android project BlitzMail listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.grobox.blitzmail;
// w  w w  .  ja v a  2 s. co  m
import android.content.Context;
import android.preference.EditTextPreference;
import android.util.AttributeSet;

public class EncryptedEditTextPreference extends EditTextPreference {

  Crypto crypto;

  public EncryptedEditTextPreference(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    crypto = new Crypto(context);
  }

  public EncryptedEditTextPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    crypto = new Crypto(context);
  }

  public EncryptedEditTextPreference(Context context) {
    super(context);
    crypto = new Crypto(context);
  }

  @Override
  public String getText() {    
    String value = super.getText();
    if(value == null) {
      return null;
    } else {
      try {
        return crypto.decrypt(value);
      }
      catch(Exception e) {
        return null;
      }
    }
  }

  @Override
  protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
    super.setText(restoreValue ? getPersistedString(null) : (String) defaultValue);
  }

  @Override
  public void setText(String text) {
    if(text == null) {
      super.setText(null);
      return;
    }
    super.setText(crypto.encrypt(text));
  }
}




Java Source Code List

com.provider.JSSEProvider.java
de.grobox.blitzmail.AsyncMailTask.java
de.grobox.blitzmail.Crypto.java
de.grobox.blitzmail.EncryptedEditTextPreference.java
de.grobox.blitzmail.MailSender.java
de.grobox.blitzmail.MailStorage.java
de.grobox.blitzmail.MainActivity.java
de.grobox.blitzmail.NoteActivity.java
de.grobox.blitzmail.NotificationHandlerActivity.java
de.grobox.blitzmail.PrivateConstants.sample_java
de.grobox.blitzmail.SendActivity.java