displaytextactivity: truncate displayed text if too long

This commit is contained in:
Vincent Breitmoser 2015-10-21 21:54:39 +02:00
parent f7bfe932ec
commit d149bfd3db
3 changed files with 13 additions and 0 deletions

View file

@ -79,6 +79,9 @@ public final class Constants {
public static final int TEMPFILE_TTL = 24 * 60 * 60 * 1000; // 1 day
// the maximal length of plaintext to read in encrypt/decrypt text activities
public static final int TEXT_LENGTH_LIMIT = 1024 * 50;
public static final String SAFESLINGER_SERVER = "safeslinger-openpgp.appspot.com";
public static final class Path {

View file

@ -28,9 +28,12 @@ import android.support.v4.app.Fragment;
import android.widget.Toast;
import org.openintents.openpgp.OpenPgpMetadata;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.util.FileHelper;
public class DisplayTextActivity extends BaseActivity {
@ -73,6 +76,11 @@ public class DisplayTextActivity extends BaseActivity {
}
if (plaintext != null) {
if (plaintext.length() > Constants.TEXT_LENGTH_LIMIT) {
plaintext = plaintext.substring(0, Constants.TEXT_LENGTH_LIMIT);
Notify.create(this, R.string.snack_text_too_long, Style.WARN).show();
}
loadFragment(plaintext, result);
} else {
Toast.makeText(this, R.string.error_invalid_data, Toast.LENGTH_LONG).show();

View file

@ -1663,10 +1663,12 @@
<string name="snack_backup_exists">"Backup already exists!"</string>
<string name="snack_backup_saved_dir">"Saved to OpenKeychain directory"</string>
<string name="btn_backup_back">Go back to check</string>
<string name="snack_text_too_long">"Text is too long to show in full!"</string>
<string name="share_log_dialog_title">"Share log?"</string>
<string name="share_log_dialog_message">"While logs can be super helpful for developers to find bugs in OpenKeychain, they can contain potential sensitive information such as data about the updated keys. Please make sure you are okay with sharing this information."</string>
<string name="share_log_dialog_share_button">"Share"</string>
<string name="share_log_dialog_cancel_button">"Cancel"</string>
</resources>