Fixes issue #21

Adds a mention button in profile page
This commit is contained in:
stom79 2017-11-05 08:06:23 +01:00
parent 281cccadb8
commit b2767716b1
3 changed files with 24 additions and 2 deletions

View File

@ -312,10 +312,12 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
if( isOwner) {
popup.getMenu().findItem(R.id.action_block).setVisible(false);
popup.getMenu().findItem(R.id.action_mute).setVisible(false);
popup.getMenu().findItem(R.id.action_mention).setVisible(false);
stringArrayConf = getResources().getStringArray(R.array.more_action_owner_confirm);
}else {
popup.getMenu().findItem(R.id.action_block).setVisible(true);
popup.getMenu().findItem(R.id.action_mute).setVisible(true);
popup.getMenu().findItem(R.id.action_mention).setVisible(true);
stringArrayConf = getResources().getStringArray(R.array.more_action_confirm);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@ -349,6 +351,13 @@ public class ShowAccountActivity extends AppCompatActivity implements OnPostActi
startActivity(intent);
}
return true;
case R.id.action_mention:
Intent intent = new Intent(getApplicationContext(), TootActivity.class);
Bundle b = new Bundle();
b.putString("mentionAccount", account.getAcct());
intent.putExtras(b);
startActivity(intent);
return true;
case R.id.action_mute:
builderInner = new AlertDialog.Builder(ShowAccountActivity.this);
builderInner.setTitle(stringArrayConf[0]);

View File

@ -192,6 +192,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
private View popup_trans;
private AlertDialog dialogTrans;
private AlertDialog alertDialogEmoji;
private String mentionAccount;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -289,6 +290,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
sharedContent = b.getString("sharedContent", null);
sharedContentIni = b.getString("sharedContent", null);
sharedSubject = b.getString("sharedSubject", null);
mentionAccount = b.getString("mentionAccount", null);
restoredScheduled = b.getBoolean("restoredScheduled", false);
// ACTION_SEND route
if (b.getInt("uriNumber", 0) == 1) {
@ -307,7 +309,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
}
restored = b.getLong("restored", -1);
}
initialContent = toot_content.getText().toString();
if(restoredScheduled){
toot_it.setVisibility(View.GONE);
invalidateOptionsMenu();
@ -327,6 +329,11 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
else
userId = accountReply.getId();
if( mentionAccount != null){
toot_content.setText(String.format("@%s\n", mentionAccount));
toot_content.setSelection(toot_content.getText().length());
toot_space_left.setText(String.valueOf(toot_content.length()));
}
if( tootMention != null && urlMention != null && fileMention != null) {
Bitmap pictureMention = BitmapFactory.decodeFile(getCacheDir() + "/" + fileMention);
if (pictureMention != null) {
@ -342,6 +349,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
toot_content.setText(String.format("\n\nvia @%s\n\n%s\n\n", tootMention, urlMention));
toot_space_left.setText(String.valueOf(toot_content.length()));
}
initialContent = toot_content.getText().toString();
Account account;
if( accountReply == null)
account = new AccountDAO(getApplicationContext(),db).getAccountByID(userId);
@ -1736,7 +1744,7 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
//Nothing to store here....
if(toot_content.getText().toString().trim().length() == 0 && (attachments == null || attachments.size() <1) && toot_cw_content.getText().toString().trim().length() == 0)
return;
if( initialContent.equals(toot_content.getText().toString()))
if( initialContent.trim().equals(toot_content.getText().toString().trim()))
return;
Status toot = new Status();
toot.setSensitive(isSensitive);

View File

@ -26,4 +26,9 @@
android:title="@string/more_action_2"
android:icon="@drawable/ic_block"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_mention"
android:title="@string/more_action_7"
android:icon="@drawable/ic_chat_bubble_outline"
app:showAsAction="ifRoom" />
</menu>