Allow to edit custom fields in profile

This commit is contained in:
stom79 2018-08-18 20:12:37 +02:00
parent 91db484928
commit f366776b9a
2 changed files with 29 additions and 31 deletions

View File

@ -192,6 +192,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
private Account account;
private ArrayList<String> splitToot;
private int stepSpliToot;
private boolean removed;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -291,6 +292,7 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
sharedSubject = b.getString("sharedSubject", null);
mentionAccount = b.getString("mentionAccount", null);
idRedirect = b.getString("idRedirect", null);
removed = b.getBoolean("removed");
restoredScheduled = b.getBoolean("restoredScheduled", false);
// ACTION_SEND route
if (b.getInt("uriNumberMast", 0) == 1) {
@ -1780,6 +1782,9 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
StoredStatus draft = new StatusStoredDAO(TootActivity.this, db).getStatus(id);
Status status = draft.getStatus();
//Retrieves attachments
if( removed ){
new StatusStoredDAO(TootActivity.this, db).remove(draft.getId());
}
restored = id;
attachments = status.getMedia_attachments();
int childCount = toot_picture_container.getChildCount();
@ -1796,18 +1801,10 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
toRemove.clear();
}
String content = status.getContent();
List<Mention> tmpMention = status.getMentions();
if( tmpMention != null && tmpMention.size() > 0 ){
for(Mention mention: tmpMention){
String mentionString;
if( mention.getAcct().contains("@"))
mentionString = "@" + mention.getAcct().split("@")[0];
else
mentionString = "@" + mention.getAcct();
if( content.contains(mentionString)){
content = content.replaceAll(mentionString,"@"+mention.getAcct());
}
}
Pattern mentionLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
Matcher matcher = mentionLink.matcher(content);
if (matcher.find()) {
content = matcher.replaceAll("$3@$2");
}
if( attachments != null && attachments.size() > 0){
toot_picture_container.setVisibility(View.VISIBLE);

View File

@ -145,7 +145,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
private List<String> timedMute;
private boolean redraft;
private Status status;
private Status toot;
public StatusListAdapter(Context context, List<String> timedMute, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, int behaviorWithAttachments, int translator, List<Status> statuses){
super();
this.context = context;
@ -1532,20 +1532,28 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
new PostActionAsyncTask(context, doAction, targetedId, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
if( redraft ){
if( status.getIn_reply_to_id() != null && !status.getIn_reply_to_id().trim().equals("null")){
toot = new Status();
toot.setIn_reply_to_id(status.getIn_reply_to_id());
toot.setSensitive(status.isSensitive());
toot.setMedia_attachments(status.getMedia_attachments());
if( status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
toot.setSpoiler_text(status.getSpoiler_text().trim());
toot.setContent(status.getContent());
toot.setVisibility(status.getVisibility());
new RetrieveFeedsAsyncTask(context, RetrieveFeedsAsyncTask.Type.ONESTATUS, status.getIn_reply_to_id(), null, false, false, StatusListAdapter.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else{
String content = status.getContent();
Spanned contentSpan;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
contentSpan = Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY);
else
//noinspection deprecation
contentSpan = Html.fromHtml(content);
status.setContent(contentSpan.toString());
long id = new StatusStoredDAO(context, db).insertStatus(status, null);
toot = new Status();
toot.setSensitive(status.isSensitive());
toot.setMedia_attachments(status.getMedia_attachments());
if( status.getSpoiler_text() != null && status.getSpoiler_text().length() > 0)
toot.setSpoiler_text(status.getSpoiler_text().trim());
toot.setVisibility(status.getVisibility());
toot.setContent(status.getContent());
long id = new StatusStoredDAO(context, db).insertStatus(toot, null);
Intent intentToot = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
b.putLong("restored", id);
b.putBoolean("removed", true);
intentToot.putExtras(b);
context.startActivity(intentToot);
}
@ -1825,18 +1833,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
if( apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0){
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String content = status.getContent();
Spanned contentSpan;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
contentSpan = Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY);
else
//noinspection deprecation
contentSpan = Html.fromHtml(content);
status.setContent(contentSpan.toString());
long id = new StatusStoredDAO(context, db).insertStatus(status, apiResponse.getStatuses().get(0));
long id = new StatusStoredDAO(context, db).insertStatus(toot, apiResponse.getStatuses().get(0));
Intent intentToot = new Intent(context, TootActivity.class);
Bundle b = new Bundle();
b.putLong("restored", id);
b.putBoolean("removed", true);
intentToot.putExtras(b);
context.startActivity(intentToot);
}