Some other improvements

This commit is contained in:
stom79 2018-09-15 14:36:19 +02:00
parent 97ddb9698a
commit 8fd4e41206
2 changed files with 25 additions and 27 deletions

View File

@ -714,6 +714,7 @@ public class Status implements Parcelable{
if( !key.startsWith("#") && !key.startsWith("@")) if( !key.startsWith("#") && !key.startsWith("@"))
targetedURL.put(key, matcher.group(1)); targetedURL.put(key, matcher.group(1));
} }
String currentInstance = Helper.getLiveInstance(context);
//Get url to account that are unknown //Get url to account that are unknown
Pattern aLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)"); Pattern aLink = Pattern.compile("(<\\s?a\\s?href=\"https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})\\/(@[\\/\\w._-]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
Matcher matcherALink = aLink.matcher(spannableString.toString()); Matcher matcherALink = aLink.matcher(spannableString.toString());
@ -721,10 +722,25 @@ public class Status implements Parcelable{
while (matcherALink.find()){ while (matcherALink.find()){
String acct = matcherALink.group(3).replace("@",""); String acct = matcherALink.group(3).replace("@","");
String instance = matcherALink.group(2); String instance = matcherALink.group(2);
Account account = new Account(); boolean addAccount = true;
account.setAcct(acct); for(Mention mention: mentions){
account.setInstance(instance); String[] accountMentionAcct = mention.getAcct().split("@");
accountsMentionUnknown.add(account); //Different isntance
if( accountMentionAcct.length > 1){
if( mention.getAcct().equals(acct+"@"+instance))
addAccount = false;
}else {
if( (mention.getUsername()+"@"+currentInstance).equals(acct+"@"+instance))
addAccount = false;
}
if( addAccount) {
Account account = new Account();
account.setAcct(acct);
account.setInstance(instance);
accountsMentionUnknown.add(account);
}
}
} }
aLink = Pattern.compile("(<\\s?a\\s?href=\"(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,6}[\\/]?[^\"@(\\/tags\\/)]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)"); aLink = Pattern.compile("(<\\s?a\\s?href=\"(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,6}[\\/]?[^\"@(\\/tags\\/)]*)\"\\s?[^.]*<\\s?\\/\\s?a\\s?>)");
matcherALink = aLink.matcher(spannableString.toString()); matcherALink = aLink.matcher(spannableString.toString());
@ -895,28 +911,11 @@ public class Status implements Parcelable{
spannableStringT.setSpan(new ClickableSpan() { spannableStringT.setSpan(new ClickableSpan() {
@Override @Override
public void onClick(View textView) { public void onClick(View textView) {
if( type == null || type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE) { Intent intent = new Intent(context, ShowAccountActivity.class);
Intent intent = new Intent(context, ShowAccountActivity.class); Bundle b = new Bundle();
Bundle b = new Bundle(); b.putString("accountId", mention.getId());
b.putString("accountId", mention.getId()); intent.putExtras(b);
intent.putExtras(b); context.startActivity(intent);
context.startActivity(intent);
}else {
String url = mention.getUrl();
Pattern instanceHost = Pattern.compile("https?:\\/\\/([\\da-z\\.-]+\\.[a-z\\.]{2,6})\\/(@[\\/\\w._-]*)");
Matcher matcherAcct = instanceHost.matcher(url);
String instance = null, acct = null;
while (matcherAcct.find()){
instance = matcherAcct.group(1);
acct = matcherAcct.group(2);
}
if( acct != null && instance != null){
Account account = new Account();
account.setInstance(instance);
account.setAcct(acct.replace("@",""));
CrossActions.doCrossProfile(context, account);
}
}
} }
@Override @Override
public void updateDrawState(TextPaint ds) { public void updateDrawState(TextPaint ds) {

View File

@ -34,7 +34,6 @@ import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;