|
|
|
@ -26,9 +26,11 @@ import android.content.Intent;
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.Html;
|
|
|
|
|
import android.text.SpannableStringBuilder;
|
|
|
|
|
import android.text.Spanned;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.text.style.ImageSpan;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.Menu;
|
|
|
|
@ -53,6 +55,7 @@ public class ActivitySignature extends ActivityBase {
|
|
|
|
|
private BottomNavigationView bottom_navigation;
|
|
|
|
|
|
|
|
|
|
private boolean raw = false;
|
|
|
|
|
private boolean dirty = false;
|
|
|
|
|
|
|
|
|
|
private static final int REQUEST_IMAGE = 1;
|
|
|
|
|
|
|
|
|
@ -77,6 +80,23 @@ public class ActivitySignature extends ActivityBase {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
etText.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
@Override
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
|
// Do nothing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
dirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
|
// Do nothing
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
style_bar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
|
|
@ -136,8 +156,7 @@ public class ActivitySignature extends ActivityBase {
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
case R.id.menu_edit_html:
|
|
|
|
|
item.setChecked(!item.isChecked());
|
|
|
|
|
raw = item.isChecked();
|
|
|
|
|
load();
|
|
|
|
|
html(item.isChecked());
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
@ -173,6 +192,7 @@ public class ActivitySignature extends ActivityBase {
|
|
|
|
|
return getDrawableByUri(ActivitySignature.this, Uri.parse(source));
|
|
|
|
|
}
|
|
|
|
|
}, null));
|
|
|
|
|
dirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void delete() {
|
|
|
|
@ -191,6 +211,17 @@ public class ActivitySignature extends ActivityBase {
|
|
|
|
|
finish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void html(boolean raw) {
|
|
|
|
|
this.raw = raw;
|
|
|
|
|
|
|
|
|
|
if (!raw || dirty) {
|
|
|
|
|
String html = (raw ? HtmlHelper.toHtml(etText.getText()) : etText.getText().toString());
|
|
|
|
|
getIntent().putExtra("html", html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
load();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void insertImage() {
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
|
|
|
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
|