forked from mirrors/Fedilab
Fix mentions / DM from profiles
This commit is contained in:
parent
ca9c9cfcab
commit
b15fdabc90
4 changed files with 42 additions and 7 deletions
|
@ -97,6 +97,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
private String instance, token;
|
private String instance, token;
|
||||||
private Uri photoFileUri;
|
private Uri photoFileUri;
|
||||||
private ScheduledStatus scheduledStatus;
|
private ScheduledStatus scheduledStatus;
|
||||||
|
private String visibility;
|
||||||
|
private app.fedilab.android.client.mastodon.entities.Account accountMention;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -124,6 +126,8 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
account = (Account) b.getSerializable(Helper.ARG_ACCOUNT);
|
account = (Account) b.getSerializable(Helper.ARG_ACCOUNT);
|
||||||
instance = b.getString(Helper.ARG_INSTANCE, BaseMainActivity.currentInstance);
|
instance = b.getString(Helper.ARG_INSTANCE, BaseMainActivity.currentInstance);
|
||||||
token = b.getString(Helper.ARG_TOKEN, BaseMainActivity.currentToken);
|
token = b.getString(Helper.ARG_TOKEN, BaseMainActivity.currentToken);
|
||||||
|
visibility = b.getString(Helper.ARG_VISIBILITY, null);
|
||||||
|
accountMention = (app.fedilab.android.client.mastodon.entities.Account) b.getSerializable(Helper.ARG_ACCOUNT_MENTION);
|
||||||
}
|
}
|
||||||
binding.toolbar.setPopupTheme(Helper.popupStyle());
|
binding.toolbar.setPopupTheme(Helper.popupStyle());
|
||||||
//Edit a scheduled status from server
|
//Edit a scheduled status from server
|
||||||
|
@ -177,7 +181,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
}
|
}
|
||||||
int statusCount = statusList.size();
|
int statusCount = statusList.size();
|
||||||
statusList.addAll(statusDraft.statusDraftList);
|
statusList.addAll(statusDraft.statusDraftList);
|
||||||
composeAdapter = new ComposeAdapter(statusList, statusCount, account);
|
composeAdapter = new ComposeAdapter(statusList, statusCount, account, accountMention, visibility);
|
||||||
composeAdapter.manageDrafts = this;
|
composeAdapter.manageDrafts = this;
|
||||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
||||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
|
@ -218,7 +222,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
}
|
}
|
||||||
//StatusDraftList at this point should only have one element
|
//StatusDraftList at this point should only have one element
|
||||||
statusList.addAll(statusDraftList);
|
statusList.addAll(statusDraftList);
|
||||||
composeAdapter = new ComposeAdapter(statusList, statusCount, account);
|
composeAdapter = new ComposeAdapter(statusList, statusCount, account, accountMention, visibility);
|
||||||
composeAdapter.manageDrafts = this;
|
composeAdapter.manageDrafts = this;
|
||||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
||||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
|
@ -231,7 +235,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
|
||||||
} else {
|
} else {
|
||||||
//Compose without replying
|
//Compose without replying
|
||||||
statusList.addAll(statusDraftList);
|
statusList.addAll(statusDraftList);
|
||||||
composeAdapter = new ComposeAdapter(statusList, 0, account);
|
composeAdapter = new ComposeAdapter(statusList, 0, account, accountMention, visibility);
|
||||||
composeAdapter.manageDrafts = this;
|
composeAdapter.manageDrafts = this;
|
||||||
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
|
||||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
|
|
|
@ -834,7 +834,7 @@ public class ProfileActivity extends BaseActivity {
|
||||||
} else if (itemId == R.id.action_direct_message) {
|
} else if (itemId == R.id.action_direct_message) {
|
||||||
Intent intent = new Intent(ProfileActivity.this, ComposeActivity.class);
|
Intent intent = new Intent(ProfileActivity.this, ComposeActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putSerializable(Helper.ARG_ACCOUNT, account);
|
b.putSerializable(Helper.ARG_ACCOUNT_MENTION, account);
|
||||||
b.putString(Helper.ARG_VISIBILITY, "direct");
|
b.putString(Helper.ARG_VISIBILITY, "direct");
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -908,7 +908,7 @@ public class ProfileActivity extends BaseActivity {
|
||||||
Bundle b;
|
Bundle b;
|
||||||
intent = new Intent(ProfileActivity.this, ComposeActivity.class);
|
intent = new Intent(ProfileActivity.this, ComposeActivity.class);
|
||||||
b = new Bundle();
|
b = new Bundle();
|
||||||
b.putSerializable(Helper.ARG_ACCOUNT, account.acct);
|
b.putSerializable(Helper.ARG_ACCOUNT_MENTION, account);
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -57,6 +57,7 @@ import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.webkit.CookieManager;
|
import android.webkit.CookieManager;
|
||||||
import android.webkit.MimeTypeMap;
|
import android.webkit.MimeTypeMap;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
|
@ -176,6 +177,7 @@ public class Helper {
|
||||||
public static final String ARG_STATUS_DRAFT_ID = "ARG_STATUS_DRAFT_ID";
|
public static final String ARG_STATUS_DRAFT_ID = "ARG_STATUS_DRAFT_ID";
|
||||||
public static final String ARG_STATUS_REPLY = "ARG_STATUS_REPLY";
|
public static final String ARG_STATUS_REPLY = "ARG_STATUS_REPLY";
|
||||||
public static final String ARG_ACCOUNT = "ARG_ACCOUNT";
|
public static final String ARG_ACCOUNT = "ARG_ACCOUNT";
|
||||||
|
public static final String ARG_ACCOUNT_MENTION = "ARG_ACCOUNT_MENTION";
|
||||||
public static final String ARG_MINIFIED = "ARG_MINIFIED";
|
public static final String ARG_MINIFIED = "ARG_MINIFIED";
|
||||||
public static final String ARG_STATUS_REPORT = "ARG_STATUS_REPORT";
|
public static final String ARG_STATUS_REPORT = "ARG_STATUS_REPORT";
|
||||||
public static final String ARG_STATUS_MENTION = "ARG_STATUS_MENTION";
|
public static final String ARG_STATUS_MENTION = "ARG_STATUS_MENTION";
|
||||||
|
@ -1411,4 +1413,10 @@ public class Helper {
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showKeyboard(Context context, View view) {
|
||||||
|
view.requestFocus();
|
||||||
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,11 +121,16 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
private int statusCount;
|
private int statusCount;
|
||||||
private Context context;
|
private Context context;
|
||||||
private AlertDialog alertDialogEmoji;
|
private AlertDialog alertDialogEmoji;
|
||||||
|
private final String visibility;
|
||||||
|
private final app.fedilab.android.client.mastodon.entities.Account mentionedAccount;
|
||||||
|
|
||||||
public ComposeAdapter(List<Status> statusList, int statusCount, Account account) {
|
public ComposeAdapter(List<Status> statusList, int statusCount, Account account, app.fedilab.android.client.mastodon.entities.Account mentionedAccount, String visibility) {
|
||||||
this.statusList = statusList;
|
this.statusList = statusList;
|
||||||
this.statusCount = statusCount;
|
this.statusCount = statusCount;
|
||||||
this.account = account;
|
this.account = account;
|
||||||
|
this.mentionedAccount = mentionedAccount;
|
||||||
|
this.visibility = visibility;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateCharacterCount(ComposeViewHolder composeViewHolder) {
|
private static void updateCharacterCount(ComposeViewHolder composeViewHolder) {
|
||||||
|
@ -214,6 +219,21 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
holder.binding.content.setSelection(statusDraft.cursorPosition); //Put cursor at the end
|
holder.binding.content.setSelection(statusDraft.cursorPosition); //Put cursor at the end
|
||||||
buttonVisibility(holder);
|
buttonVisibility(holder);
|
||||||
});
|
});
|
||||||
|
} else if (mentionedAccount != null) {
|
||||||
|
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean capitalize = sharedpreferences.getBoolean(context.getString(R.string.SET_CAPITALIZE), true);
|
||||||
|
if (capitalize) {
|
||||||
|
statusDraft.text = mentionedAccount.acct + "\n";
|
||||||
|
} else {
|
||||||
|
statusDraft.text = mentionedAccount.acct + " ";
|
||||||
|
}
|
||||||
|
holder.binding.content.setText(statusDraft.text);
|
||||||
|
updateCharacterCount(holder);
|
||||||
|
holder.binding.content.requestFocus();
|
||||||
|
holder.binding.content.post(() -> {
|
||||||
|
buttonVisibility(holder);
|
||||||
|
holder.binding.content.setSelection(statusDraft.text.length()); //Put cursor at the end
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
holder.binding.content.requestFocus();
|
holder.binding.content.requestFocus();
|
||||||
}
|
}
|
||||||
|
@ -1025,6 +1045,10 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
holder.binding.attachmentChoicesPanel.setVisibility(View.GONE);
|
holder.binding.attachmentChoicesPanel.setVisibility(View.GONE);
|
||||||
pickupMedia(ComposeActivity.mediaType.ALL, position);
|
pickupMedia(ComposeActivity.mediaType.ALL, position);
|
||||||
});
|
});
|
||||||
|
//Used for DM
|
||||||
|
if (visibility != null) {
|
||||||
|
statusDraft.visibility = visibility;
|
||||||
|
}
|
||||||
if (statusDraft.visibility == null) {
|
if (statusDraft.visibility == null) {
|
||||||
if (position > 0) {
|
if (position > 0) {
|
||||||
statusDraft.visibility = statusList.get(position - 1).visibility;
|
statusDraft.visibility = statusList.get(position - 1).visibility;
|
||||||
|
@ -1092,7 +1116,6 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
displayAttachments(holder, position, -1);
|
displayAttachments(holder, position, -1);
|
||||||
|
|
||||||
manageMentions(context, statusDraft, holder);
|
manageMentions(context, statusDraft, holder);
|
||||||
//For some instances this value can be null, we have to transform the html content
|
//For some instances this value can be null, we have to transform the html content
|
||||||
if (statusDraft.text == null && statusDraft.content != null) {
|
if (statusDraft.text == null && statusDraft.content != null) {
|
||||||
|
|
Loading…
Reference in a new issue